[HLSL] Fixed crash when using presets. [MooglyGuy]

[HLSL] Restored old HLSL prescale behavior, with 0 being auto-detect. [MooglyGuy]
This commit is contained in:
Ryan Holtz 2012-12-31 17:35:24 +00:00
parent d58eef5b12
commit af9ee4a4e4
3 changed files with 32 additions and 16 deletions

View file

@ -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<windows_options &>(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;

View file

@ -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;

View file

@ -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" },