diff --git a/gfx/drivers/gx2_gfx.c b/gfx/drivers/gx2_gfx.c index e66be65c03..ae0922a5fa 100644 --- a/gfx/drivers/gx2_gfx.c +++ b/gfx/drivers/gx2_gfx.c @@ -205,6 +205,7 @@ static uint32_t wiiu_gfx_get_flags(void *data); static void *wiiu_gfx_init(const video_info_t *video, input_driver_t **input, void **input_data) { + unsigned i; settings_t *settings = config_get_ptr(); float refresh_rate = 60.0f / 1.001f; u32 size = 0; @@ -240,8 +241,11 @@ static void *wiiu_gfx_init(const video_info_t *video, wiiu->rgb32 = video->rgb32; /* setup scanbuffers */ +#if 0 + wiiu->render_mode = wiiu_render_mode_map[GX2_TV_SCAN_MODE_480P]; +#else wiiu->render_mode = wiiu_render_mode_map[GX2GetSystemTVScanMode()]; -// wiiu->render_mode = wiiu_render_mode_map[GX2_TV_SCAN_MODE_480P]; +#endif GX2CalcTVSize(wiiu->render_mode.mode, GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8, GX2_BUFFERING_MODE_DOUBLE, &size, &tmp); @@ -390,31 +394,45 @@ static void *wiiu_gfx_init(const video_info_t *video, * sizeof(*wiiu->vertex_cache_tex.v), GX2_VERTEX_BUFFER_ALIGNMENT); /* Initialize samplers */ - for (int i = 0; i < RARCH_WRAP_MAX; i++) + for (i = 0; i < RARCH_WRAP_MAX; i++) { switch (i) { - case RARCH_WRAP_BORDER: - GX2InitSampler(&wiiu->sampler_nearest[i], GX2_TEX_CLAMP_MODE_CLAMP_BORDER, - GX2_TEX_XY_FILTER_MODE_POINT); - GX2InitSampler(&wiiu->sampler_linear[i], GX2_TEX_CLAMP_MODE_CLAMP_BORDER, - GX2_TEX_XY_FILTER_MODE_LINEAR); - break; + case RARCH_WRAP_BORDER: + GX2InitSampler(&wiiu->sampler_nearest[i], + GX2_TEX_CLAMP_MODE_CLAMP_BORDER, + GX2_TEX_XY_FILTER_MODE_POINT); + GX2InitSampler(&wiiu->sampler_linear[i], + GX2_TEX_CLAMP_MODE_CLAMP_BORDER, + GX2_TEX_XY_FILTER_MODE_LINEAR); + break; - case RARCH_WRAP_EDGE: - GX2InitSampler(&wiiu->sampler_nearest[i], GX2_TEX_CLAMP_MODE_CLAMP, GX2_TEX_XY_FILTER_MODE_POINT); - GX2InitSampler(&wiiu->sampler_linear[i], GX2_TEX_CLAMP_MODE_CLAMP, GX2_TEX_XY_FILTER_MODE_LINEAR); - break; + case RARCH_WRAP_EDGE: + GX2InitSampler(&wiiu->sampler_nearest[i], + GX2_TEX_CLAMP_MODE_CLAMP, + GX2_TEX_XY_FILTER_MODE_POINT); + GX2InitSampler(&wiiu->sampler_linear[i], + GX2_TEX_CLAMP_MODE_CLAMP, + GX2_TEX_XY_FILTER_MODE_LINEAR); + break; - case RARCH_WRAP_REPEAT: - GX2InitSampler(&wiiu->sampler_nearest[i], GX2_TEX_CLAMP_MODE_WRAP, GX2_TEX_XY_FILTER_MODE_POINT); - GX2InitSampler(&wiiu->sampler_linear[i], GX2_TEX_CLAMP_MODE_WRAP, GX2_TEX_XY_FILTER_MODE_LINEAR); - break; + case RARCH_WRAP_REPEAT: + GX2InitSampler(&wiiu->sampler_nearest[i], + GX2_TEX_CLAMP_MODE_WRAP, + GX2_TEX_XY_FILTER_MODE_POINT); + GX2InitSampler(&wiiu->sampler_linear[i], + GX2_TEX_CLAMP_MODE_WRAP, + GX2_TEX_XY_FILTER_MODE_LINEAR); + break; - case RARCH_WRAP_MIRRORED_REPEAT: - GX2InitSampler(&wiiu->sampler_nearest[i], GX2_TEX_CLAMP_MODE_MIRROR, GX2_TEX_XY_FILTER_MODE_POINT); - GX2InitSampler(&wiiu->sampler_linear[i], GX2_TEX_CLAMP_MODE_MIRROR, GX2_TEX_XY_FILTER_MODE_LINEAR); - break; + case RARCH_WRAP_MIRRORED_REPEAT: + GX2InitSampler(&wiiu->sampler_nearest[i], + GX2_TEX_CLAMP_MODE_MIRROR, + GX2_TEX_XY_FILTER_MODE_POINT); + GX2InitSampler(&wiiu->sampler_linear[i], + GX2_TEX_CLAMP_MODE_MIRROR, + GX2_TEX_XY_FILTER_MODE_LINEAR); + break; } } @@ -543,8 +561,6 @@ static bool gx2_overlay_load(void *data, { struct gx2_overlay_data *o = (struct gx2_overlay_data *)&gx2->overlay[i]; - //GX2Texture* o->tex = calloc(1, sizeof(GX2Texture)); - memset(&o->tex, 0, sizeof(GX2Texture)); o->tex.surface.width = images[i].width; o->tex.surface.height = images[i].height; @@ -645,10 +661,11 @@ static void gx2_get_overlay_interface(void *data, static void wiiu_free_shader_preset(wiiu_video_t *wiiu) { + unsigned i; if (!wiiu->shader_preset) return; - for (int i = 0; i < wiiu->shader_preset->passes; i++) + for (i = 0; i < wiiu->shader_preset->passes; i++) { gfd_free(wiiu->pass[i].gfd); MEM2_free(wiiu->pass[i].vs_ubos[0]); @@ -663,7 +680,7 @@ static void wiiu_free_shader_preset(wiiu_video_t *wiiu) memset(wiiu->pass, 0, sizeof(wiiu->pass)); - for (int i = 0; i < wiiu->shader_preset->luts; i++) + for (i = 0; i < wiiu->shader_preset->luts; i++) { MEM2_free(wiiu->luts[i].surface.image); wiiu->luts[i].surface.image = NULL; @@ -736,11 +753,13 @@ static void wiiu_gfx_free(void *data) static bool wiiu_init_frame_textures(wiiu_video_t *wiiu, unsigned width, unsigned height) { + unsigned i; + MEM2_free(wiiu->texture.surface.image); if (wiiu->shader_preset) { - for (int i = 0; i < wiiu->shader_preset->passes; i++) + for (i = 0; i < wiiu->shader_preset->passes; i++) { if(wiiu->pass[i].mem1) MEM1_free(wiiu->pass[i].texture.surface.image); @@ -782,7 +801,7 @@ static bool wiiu_init_frame_textures(wiiu_video_t *wiiu, unsigned width, unsigne if (wiiu->shader_preset) { - for (int i = 0; i < wiiu->shader_preset->passes; i++) + for (i = 0; i < wiiu->shader_preset->passes; i++) { struct video_shader_pass *pass = &wiiu->shader_preset->pass[i]; @@ -833,7 +852,9 @@ static bool wiiu_init_frame_textures(wiiu_video_t *wiiu, unsigned width, unsigne wiiu->pass[i].texture.surface.width = width; wiiu->pass[i].texture.surface.height = height; wiiu->pass[i].texture.surface.depth = 1; - // wiiu->pass[i].texture.surface.mipLevels = 1; +#if 0 + wiiu->pass[i].texture.surface.mipLevels = 1; +#endif wiiu->pass[i].texture.surface.format = pass->fbo.fp_fbo ? GX2_SURFACE_FORMAT_FLOAT_R32_G32_B32_A32 : pass->fbo.srgb_fbo ? GX2_SURFACE_FORMAT_SRGB_R8_G8_B8_A8 : @@ -883,11 +904,13 @@ static bool wiiu_init_frame_textures(wiiu_video_t *wiiu, unsigned width, unsigne return true; } -static void wiiu_gfx_update_uniform_block(wiiu_video_t *wiiu, int pass, float *ubo, int id, +static void wiiu_gfx_update_uniform_block(wiiu_video_t *wiiu, + int pass, float *ubo, int id, int size, int uniformVarCount, GX2UniformVar *uniformVars, uint64_t frame_count, int32_t frame_direction) { - for (int i = 0; i < uniformVarCount; i++) + unsigned i; + for (i = 0; i < uniformVarCount; i++) { if (uniformVars[i].block != id) continue; @@ -1040,12 +1063,6 @@ static bool wiiu_gfx_frame(void *data, const void *frame, unsigned width, unsigned height, uint64_t frame_count, unsigned pitch, const char *msg, video_frame_info_t *video_info) { -#if 0 - static float fps; - static u32 frames; - static u32 lastTick, currentTick; - u32 diff; -#endif uint32_t i; wiiu_video_t *wiiu = (wiiu_video_t *) data; @@ -1074,30 +1091,6 @@ static bool wiiu_gfx_frame(void *data, const void *frame, if (!width || !height) return true; -#if 0 - currentTick = OSGetSystemTick(); - diff = currentTick - lastTick; - - frames++; - - if (diff > wiiu_timer_clock) - { - fps = (float)frames * ((float) wiiu_timer_clock / (float) diff); - lastTick = currentTick; - frames = 0; - } - - static u32 last_frame_tick; - - if (!(wiiu->menu.enable)) - printf("frame time : %10.6f ms \r", - (float)(currentTick - last_frame_tick) * 1000.0f / (float)wiiu_timer_clock); - - last_frame_tick = currentTick; - printf("fps: %8.8f frames : %5i\r", fps, wiiu->frames++); - fflush(stdout); -#endif - if (wiiu->should_resize) wiiu_gfx_update_viewport(wiiu); @@ -1435,6 +1428,7 @@ static bool wiiu_gfx_suppress_screensaver(void *data, bool enable) static bool wiiu_gfx_set_shader(void *data, enum rarch_shader_type type, const char *path) { + unsigned i; config_file_t *conf = NULL; wiiu_video_t *wiiu = (wiiu_video_t *)data; @@ -1465,17 +1459,13 @@ static bool wiiu_gfx_set_shader(void *data, return false; } -#if 0 - video_shader_resolve_parameters(conf, wiiu->shader_preset); -#else - for (int i = 0; i < wiiu->shader_preset->passes; i++) + for (i = 0; i < wiiu->shader_preset->passes; i++) slang_preprocess_parse_parameters(wiiu->shader_preset->pass[i].source.path, wiiu->shader_preset); video_shader_resolve_current_parameters(conf, wiiu->shader_preset); -#endif config_file_free(conf); - for (int i = 0; i < wiiu->shader_preset->passes; i++) + for (i = 0; i < wiiu->shader_preset->passes; i++) { char gfdpath[PATH_MAX_LENGTH]; struct video_shader_pass *pass = &wiiu->shader_preset->pass[i]; @@ -1520,7 +1510,7 @@ static bool wiiu_gfx_set_shader(void *data, } } - for (int i = 0; i < wiiu->shader_preset->luts; i++) + for (i = 0; i < wiiu->shader_preset->luts; i++) { struct texture_image image = {};