From af9ee4a4e4084ec991992a409c7256f422c33234 Mon Sep 17 00:00:00 2001 From: Ryan Holtz Date: Mon, 31 Dec 2012 17:35:24 +0000 Subject: [PATCH] [HLSL] Fixed crash when using presets. [MooglyGuy] [HLSL] Restored old HLSL prescale behavior, with 0 being auto-detect. [MooglyGuy] --- src/osd/windows/d3dhlsl.c | 41 ++++++++++++++++++++++++++------------- src/osd/windows/drawd3d.c | 3 +++ src/osd/windows/winmain.c | 4 ++-- 3 files changed, 32 insertions(+), 16 deletions(-) diff --git a/src/osd/windows/d3dhlsl.c b/src/osd/windows/d3dhlsl.c index c54761a674d..cc76f96cf57 100644 --- a/src/osd/windows/d3dhlsl.c +++ b/src/osd/windows/d3dhlsl.c @@ -193,8 +193,8 @@ hlsl_info::hlsl_info() master_enable = false; prescale_size_x = 1; prescale_size_y = 1; - prescale_force_x = 1; - prescale_force_y = 1; + prescale_force_x = 0; + prescale_force_y = 0; preset = -1; shadow_texture = NULL; options = NULL; @@ -1003,8 +1003,8 @@ int hlsl_info::create_resources() shadow_texture = texture_create(d3d, &texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXFORMAT(TEXFORMAT_ARGB32)); } - prescale_force_x = 1; - prescale_force_y = 1; + prescale_force_x = 0; + prescale_force_y = 0; if(!read_ini) { @@ -1058,14 +1058,7 @@ int hlsl_info::create_resources() options->yiq_scan_time = winoptions.screen_yiq_scan_time(); options->yiq_phase_count = winoptions.screen_yiq_phase_count(); } - if (!prescale_force_x) - { - prescale_force_x = 1; - } - if (!prescale_force_y) - { - prescale_force_y = 1; - } + g_slider_list = init_slider_list(); const char *fx_dir = downcast(window->machine().options()).screen_post_fx_dir(); @@ -1904,7 +1897,7 @@ bool hlsl_info::add_render_target(d3d_info* d3d, d3d_texture_info* info, int wid d3d_cache_target* cache = find_cache_target(target->screen_index, info->texinfo.width, info->texinfo.height); if (cache == NULL) { - if (!add_cache_target(d3d, info, width, height, xprescale * prescale_force_x, yprescale * prescale_force_y, target->screen_index)) + if (!add_cache_target(d3d, info, width, height, xprescale, yprescale, target->screen_index)) { global_free(target); return false; @@ -1956,10 +1949,30 @@ bool hlsl_info::register_texture(d3d_texture_info *texture, int width, int heigh d3d_info *d3d = (d3d_info *)window->drawdata; - // Find the nearest prescale factor that is over our screen size int hlsl_prescale_x = prescale_force_x; int hlsl_prescale_y = prescale_force_y; + // Find the nearest prescale factor that is over our screen size + if (hlsl_prescale_x == 0) + { + hlsl_prescale_x = 1; + while (width * xscale * hlsl_prescale_x < d3d->width) + { + hlsl_prescale_x++; + } + hlsl_prescale_x--; + } + + if (hlsl_prescale_y == 0) + { + hlsl_prescale_y = 1; + while (height * yscale * hlsl_prescale_y < d3d->height) + { + hlsl_prescale_y++; + } + hlsl_prescale_y--; + } + if (!add_render_target(d3d, texture, width, height, xscale * hlsl_prescale_x, yscale * hlsl_prescale_y)) return false; diff --git a/src/osd/windows/drawd3d.c b/src/osd/windows/drawd3d.c index 7adb6b1c694..ec92033cbe5 100644 --- a/src/osd/windows/drawd3d.c +++ b/src/osd/windows/drawd3d.c @@ -1802,7 +1802,9 @@ d3d_texture_info *texture_create(d3d_info *d3d, const render_texinfo *texsource, texture->type = d3d->dynamic_supported ? TEXTURE_TYPE_DYNAMIC : TEXTURE_TYPE_PLAIN; if (d3d->hlsl->enabled() && !d3d->hlsl->register_texture(texture)) + { goto error; + } break; } @@ -1844,6 +1846,7 @@ d3d_texture_info *texture_create(d3d_info *d3d, const render_texinfo *texsource, { if (d3d->hlsl->enabled() && !d3d->hlsl->register_prescaled_texture(texture)) { + printf("hlsl issue 2\n"); goto error; } break; diff --git a/src/osd/windows/winmain.c b/src/osd/windows/winmain.c index c63e5acd001..bc871803fbb 100644 --- a/src/osd/windows/winmain.c +++ b/src/osd/windows/winmain.c @@ -338,8 +338,8 @@ const options_entry windows_options::s_option_entries[] = { WINOPTION_HLSL_INI_READ, "0", OPTION_BOOLEAN, "enable HLSL INI reading" }, { WINOPTION_HLSL_INI_WRITE, "0", OPTION_BOOLEAN, "enable HLSL INI writing" }, { WINOPTION_HLSL_INI_NAME, "%g", OPTION_STRING, "HLSL INI file name for this game" }, - { WINOPTION_HLSL_PRESCALE_X, "2", OPTION_INTEGER, "HLSL pre-scale override factor for X" }, - { WINOPTION_HLSL_PRESCALE_Y, "2", OPTION_INTEGER, "HLSL pre-scale override factor for Y" }, + { WINOPTION_HLSL_PRESCALE_X, "0", OPTION_INTEGER, "HLSL pre-scale override factor for X (0 for auto)" }, + { WINOPTION_HLSL_PRESCALE_Y, "0", OPTION_INTEGER, "HLSL pre-scale override factor for Y (0 for auto)" }, { WINOPTION_HLSL_PRESET";(-1-3)", "-1", OPTION_INTEGER, "HLSL preset to use (0-3)" }, { WINOPTION_HLSL_WRITE, NULL, OPTION_STRING, "enable HLSL AVI writing (huge disk bandwidth suggested)" }, { WINOPTION_HLSL_SNAP_WIDTH, "2048", OPTION_STRING, "HLSL upscaled-snapshot width" },