Cleanup (nw)

- options are reset to loaded preset when game is closed
- changed default values of options to result in no effects activated
- init_slider_list() does not returns but sets g_slider_list directly
- removed unnecessary oriented_vector_texcoords
This commit is contained in:
ImJezze 2016-03-13 17:11:08 +01:00
parent b1a392a45f
commit c2d4e3c018
5 changed files with 69 additions and 88 deletions

View file

@ -102,17 +102,17 @@ vector_length_ratio 500.0 Vector fade length (4.0 - vectors fade t
Bloom Post-Processing Options
-----------------------------
Name Default Values Description
bloom_blend_mode 0 or 1 0 for addition blend mode or 1 for darken blend mode.
bloom_scale 0.500 Bloom intensity factor. (0.000-2.000)
bloom_overdrive 0.00,0.00,0.00 Bloom overdrive factor to bright full saturated colors. (0.000-2.000)
bloom_blend_mode 0 or 1 0 for brighten blend mode or 1 for darken blend mode.
bloom_scale 0.0 Bloom intensity factor. (0.000-2.000)
bloom_overdrive 0.0,0.0,0.0 Bloom overdrive factor to bright full saturated colors. (0.000-2.000)
bloom_lvl0_weight 1.00 Bloom level 0 (full-size target) weight. (0.00-1.00)
bloom_lvl1_weight 0.21 Bloom level 1 (half-size target) weight. (0.00-1.00)
bloom_lvl2_weight 0.19 Bloom level 2 (quarter-size target) weight. (0.00-1.00)
bloom_lvl3_weight 0.17 Bloom level 3 (.) weight. (0.00-1.00)
bloom_lvl4_weight 0.14 Bloom level 4 (.) weight. (0.00-1.00)
bloom_lvl5_weight 0.14 Bloom level 5 (.) weight. (0.00-1.00)
bloom_lvl6_weight 0.13 Bloom level 6 (.) weight. (0.00-1.00)
bloom_lvl7_weight 0.12 Bloom level 7 (.) weight. (0.00-1.00)
bloom_lvl8_weight 0.11 Bloom level 8 (.) weight. (0.00-1.00)
bloom_lvl9_weight 0.10 Bloom level 9 (.) weight. (0.00-1.00)
bloom_lvl10_weight 0.09 Bloom level 10 (1x1 target) weight. (0.00-1.00)
bloom_lvl1_weight 0.64 Bloom level 1 (1/2-size target) weight. (0.00-1.00)
bloom_lvl2_weight 0.32 Bloom level 2 (1/4-size target) weight. (0.00-1.00)
bloom_lvl3_weight 0.16 Bloom level 3 (1/8-size target) weight. (0.00-1.00)
bloom_lvl4_weight 0.08 Bloom level 4 (1/16-size target) weight. (0.00-1.00)
bloom_lvl5_weight 0.04 Bloom level 5 (1/32-size target) weight. (0.00-1.00)
bloom_lvl6_weight 0.04 Bloom level 6 (1/64-size target) weight. (0.00-1.00)
bloom_lvl7_weight 0.02 Bloom level 7 (1/128-size target) weight. (0.00-1.00)
bloom_lvl8_weight 0.02 Bloom level 8 (1/256-size target) weight. (0.00-1.00)
bloom_lvl9_weight 0.01 Bloom level 9 (1/512-size target) weight. (0.00-1.00)
bloom_lvl10_weight 0.01 Bloom level 10 (1/1024-size target) weight. (0.00-1.00)

View file

@ -255,7 +255,7 @@ uniform float2 Level56Weight;
uniform float2 Level78Weight;
uniform float2 Level9AWeight;
uniform int BloomBlendMode = 0; // 0 addition, 1 darken
uniform int BloomBlendMode = 0; // 0 brighten, 1 darken
uniform float BloomScale;
uniform float3 BloomOverdrive;
@ -281,7 +281,7 @@ float4 ps_main(PS_INPUT Input) : COLOR
float3 blend;
// addition
// brighten
if (BloomBlendMode == 0)
{
texel0 *= Level0Weight;

View file

@ -102,7 +102,7 @@ struct object_transform
// GLOBAL VARIABLES
//**************************************************************************
// precomputed UV coordinates for raster primitive with various orientations
// precomputed UV coordinates for various orientations
static const render_quad_texuv oriented_texcoords[8] =
{
{ { 0,0 }, { 1,0 }, { 0,1 }, { 1,1 } }, // 0
@ -115,12 +115,6 @@ static const render_quad_texuv oriented_texcoords[8] =
{ { 1,1 }, { 1,0 }, { 0,1 }, { 0,0 } } // ORIENTATION_SWAP_XY | ORIENTATION_FLIP_X | ORIENTATION_FLIP_Y
};
// precomputed UV coordinates for vector primitive
static const render_quad_texuv oriented_vector_texcoords[1] =
{
{ { 0,0 }, { 1,0 }, { 0,1 }, { 1,1 } }
};
// layer orders
static const int layer_order_standard[] = { ITEM_LAYER_SCREEN, ITEM_LAYER_OVERLAY, ITEM_LAYER_BACKDROP, ITEM_LAYER_BEZEL, ITEM_LAYER_CPANEL, ITEM_LAYER_MARQUEE };
static const int layer_order_alternate[] = { ITEM_LAYER_BACKDROP, ITEM_LAYER_SCREEN, ITEM_LAYER_OVERLAY, ITEM_LAYER_BEZEL, ITEM_LAYER_CPANEL, ITEM_LAYER_MARQUEE };
@ -1776,28 +1770,14 @@ void render_target::add_container_primitives(render_primitive_list &list, const
? PRIMFLAG_BLENDMODE(blendmode)
: PRIMFLAG_BLENDMODE(PRIMFLAG_GET_BLENDMODE(curitem->flags()));
}
else if (curitem->flags() & PRIMFLAG_VECTORBUF_MASK)
{
// adjust the color for brightness/contrast/gamma
prim->color.r = container.apply_brightness_contrast_gamma_fp(prim->color.r);
prim->color.g = container.apply_brightness_contrast_gamma_fp(prim->color.g);
prim->color.b = container.apply_brightness_contrast_gamma_fp(prim->color.b);
// determine UV coordinates
prim->texcoords = oriented_vector_texcoords[0];
// apply clipping
clipped = render_clip_quad(&prim->bounds, &cliprect, &prim->texcoords);
// no texture
prim->texture.base = nullptr;
// set the basic flags
prim->flags = (curitem->flags() & ~PRIMFLAG_BLENDMODE_MASK)
| PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA);
}
else
{
if (curitem->flags() & PRIMFLAG_VECTORBUF_MASK)
{
// determine UV coordinates
prim->texcoords = oriented_texcoords[0];
}
// adjust the color for brightness/contrast/gamma
prim->color.r = container.apply_brightness_contrast_gamma_fp(prim->color.r);
prim->color.g = container.apply_brightness_contrast_gamma_fp(prim->color.g);

View file

@ -407,8 +407,6 @@ void shaders::toggle()
{
// free shader resources before renderer resources
delete_resources(false);
g_slider_list = nullptr;
}
master_enable = !master_enable;
@ -433,10 +431,6 @@ void shaders::toggle()
{
master_enable = false;
}
else
{
g_slider_list = init_slider_list();
}
}
}
}
@ -659,9 +653,14 @@ void shaders::init(d3d_base *d3dintf, running_machine *machine, renderer_d3d9 *r
// check if no driver loaded (not all settings might be loaded yet)
if (&machine->system() == &GAME_NAME(___empty))
{
options->params_init = false;
last_options.params_init = false;
return;
}
enumerate_screens();
windows_options &winoptions = downcast<windows_options &>(machine->options());
master_enable = winoptions.d3d_hlsl_enable();
@ -744,8 +743,6 @@ void shaders::init(d3d_base *d3dintf, running_machine *machine, renderer_d3d9 *r
}
options->params_dirty = true;
g_slider_list = init_slider_list();
}
@ -1005,6 +1002,8 @@ int shaders::create_resources(bool reset)
initialized = true;
init_slider_list();
return 0;
}
@ -1675,12 +1674,12 @@ void shaders::render_quad(poly_info *poly, int vertnum)
curr_texture->increment_frame_count();
curr_texture->mask_frame_count(options->yiq_phase_count);
options->params_dirty = false;
curr_screen++;
}
else if (PRIMFLAG_GET_VECTOR(poly->get_flags()) && vector_enable)
{
lines_pending = true;
curr_render_target = find_render_target(d3d->get_width(), d3d->get_height(), 0, 0);
d3d_render_target *rt = curr_render_target;
@ -1690,8 +1689,6 @@ void shaders::render_quad(poly_info *poly, int vertnum)
return;
}
lines_pending = true;
int next_index = 0;
next_index = vector_pass(rt, next_index, poly, vertnum);
@ -1704,6 +1701,8 @@ void shaders::render_quad(poly_info *poly, int vertnum)
}
else if (PRIMFLAG_GET_VECTORBUF(poly->get_flags()) && vector_enable)
{
curr_screen = curr_screen < num_screens ? curr_screen : 0;
curr_render_target = find_render_target(d3d->get_width(), d3d->get_height(), 0, 0);
d3d_render_target *rt = curr_render_target;
@ -1747,12 +1746,16 @@ void shaders::render_quad(poly_info *poly, int vertnum)
}
lines_pending = false;
curr_screen++;
}
else
{
ui_pass(poly, vertnum);
}
options->params_dirty = false;
curr_render_target = nullptr;
curr_texture = nullptr;
curr_poly = nullptr;
@ -1957,8 +1960,6 @@ bool shaders::register_texture(render_primitive *prim, texture_info *texture)
return false;
}
enumerate_screens();
bool swap_xy = d3d->swap_xy();
int target_width = swap_xy
? static_cast<int>(prim->get_quad_height() + 0.5f)
@ -1973,8 +1974,6 @@ bool shaders::register_texture(render_primitive *prim, texture_info *texture)
return false;
}
options->params_dirty = true;
return true;
}
@ -2117,6 +2116,8 @@ void shaders::delete_resources(bool reset)
}
shadow_bitmap.reset();
g_slider_list = nullptr;
}
@ -2346,7 +2347,7 @@ slider_desc shaders::s_sliders[] =
{ "Scanline Darkness", 0, 0, 100, 1, SLIDER_FLOAT, SLIDER_SCREEN_TYPE_LCD_OR_RASTER, SLIDER_SCANLINE_ALPHA, 0.01f, "%1.2f", {} },
{ "Scanline Screen Scale", 0, 100, 400, 1, SLIDER_FLOAT, SLIDER_SCREEN_TYPE_LCD_OR_RASTER, SLIDER_SCANLINE_SCALE, 0.01f, "%1.2f", {} },
{ "Scanline Height", 0, 100, 400, 1, SLIDER_FLOAT, SLIDER_SCREEN_TYPE_LCD_OR_RASTER, SLIDER_SCANLINE_HEIGHT, 0.01f, "%1.2f", {} },
{ "Scanline Brightness", 0, 100, 400, 1, SLIDER_FLOAT, SLIDER_SCREEN_TYPE_LCD_OR_RASTER, SLIDER_SCANLINE_BRIGHT_SCALE, 0.01f, "%1.2f", {} },
{ "Scanline Brightness", 0, 100, 200, 1, SLIDER_FLOAT, SLIDER_SCREEN_TYPE_LCD_OR_RASTER, SLIDER_SCANLINE_BRIGHT_SCALE, 0.01f, "%1.2f", {} },
{ "Scanline Brightness Overdrive", 0, 0, 100, 1, SLIDER_FLOAT, SLIDER_SCREEN_TYPE_LCD_OR_RASTER, SLIDER_SCANLINE_BRIGHT_OFFSET, 0.01f, "%1.2f", {} },
{ "Scanline Jitter", 0, 0, 100, 1, SLIDER_FLOAT, SLIDER_SCREEN_TYPE_LCD_OR_RASTER, SLIDER_SCANLINE_JITTER, 0.01f, "%1.2f", {} },
{ "Hum Bar Darkness", 0, 0, 100, 1, SLIDER_FLOAT, SLIDER_SCREEN_TYPE_LCD_OR_RASTER, SLIDER_HUM_BAR_ALPHA, 0.01f, "%2.2f", {} },
@ -2468,20 +2469,19 @@ void *shaders::get_slider_option(int id, int index)
return nullptr;
}
slider_state *shaders::init_slider_list()
void shaders::init_slider_list()
{
if (!master_enable || !d3dintf->post_fx_available)
{
g_slider_list = nullptr;
return nullptr;
}
slider_state *listhead = nullptr;
slider_state **tailptr = &listhead;
for (int index = 0; s_sliders[index].name != nullptr; index++)
for (int i = 0; s_sliders[i].name != nullptr; i++)
{
slider_desc *desc = &s_sliders[index];
slider_desc *desc = &s_sliders[i];
int screen_type = machine->first_screen()->screen_type();
if ((screen_type == SCREEN_TYPE_VECTOR && (desc->screen_type & SLIDER_SCREEN_TYPE_VECTOR) == SLIDER_SCREEN_TYPE_VECTOR) ||
@ -2501,9 +2501,10 @@ slider_state *shaders::init_slider_list()
count = 1;
break;
}
for (int index = 0; index < count; index++)
for (int j = 0; j < count; j++)
{
slider* slider_arg = new slider(desc, get_slider_option(desc->id, index), &options->params_dirty);
slider* slider_arg = new slider(desc, get_slider_option(desc->id, j), &options->params_dirty);
sliders.push_back(slider_arg);
std::string name = desc->name;
switch (desc->slider_type)
@ -2511,13 +2512,13 @@ slider_state *shaders::init_slider_list()
case SLIDER_VEC2:
{
std::string names[2] = { " X", " Y" };
name = name + names[index];
name = name + names[j];
break;
}
case SLIDER_COLOR:
{
std::string names[3] = { " Red", " Green", " Blue" };
name = name + names[index];
name = name + names[j];
break;
}
default:
@ -2529,7 +2530,7 @@ slider_state *shaders::init_slider_list()
}
}
return listhead;
g_slider_list = listhead;
}

View file

@ -308,21 +308,21 @@ const options_entry windows_options::s_option_entries[] =
{ WINOPTION_SCANLINE_BRIGHT_OFFSET";fs_scanbo(0.0-1.0)", "0.0", OPTION_FLOAT, "overall brightness offset value for scanlines (additive)" },
{ WINOPTION_SCANLINE_JITTER";fs_scanjt(0.0-4.0)", "0.0", OPTION_FLOAT, "overall interlace jitter scaling value for scanlines" },
{ WINOPTION_HUM_BAR_ALPHA";fs_humba(0.0-1.0)", "0.0", OPTION_FLOAT, "overall alpha scaling value for hum bar" },
{ WINOPTION_DEFOCUS";fs_focus", "1.0,0.0", OPTION_STRING, "overall defocus value in screen-relative coords" },
{ WINOPTION_CONVERGE_X";fs_convx", "0.25,0.00,-0.25", OPTION_STRING, "convergence in screen-relative X direction" },
{ WINOPTION_CONVERGE_Y";fs_convy", "0.0,0.25,-0.25", OPTION_STRING, "convergence in screen-relative Y direction" },
{ WINOPTION_DEFOCUS";fs_focus", "0.0,0.0", OPTION_STRING, "overall defocus value in screen-relative coords" },
{ WINOPTION_CONVERGE_X";fs_convx", "0.0,0.0,0.0", OPTION_STRING, "convergence in screen-relative X direction" },
{ WINOPTION_CONVERGE_Y";fs_convy", "0.0,0.0,0.0", OPTION_STRING, "convergence in screen-relative Y direction" },
{ WINOPTION_RADIAL_CONVERGE_X";fs_rconvx", "0.0,0.0,0.0", OPTION_STRING, "radial convergence in screen-relative X direction" },
{ WINOPTION_RADIAL_CONVERGE_Y";fs_rconvy", "0.0,0.0,0.0", OPTION_STRING, "radial convergence in screen-relative Y direction" },
/* RGB colorspace convolution below this line */
{ WINOPTION_RED_RATIO";fs_redratio", "1.0,0.0,0.0", OPTION_STRING, "red output signal generated by input signal" },
{ WINOPTION_GRN_RATIO";fs_grnratio", "0.0,1.0,0.0", OPTION_STRING, "green output signal generated by input signal" },
{ WINOPTION_BLU_RATIO";fs_bluratio", "0.0,0.0,1.0", OPTION_STRING, "blue output signal generated by input signal" },
{ WINOPTION_SATURATION";fs_sat(0.0-4.0)", "1.4", OPTION_FLOAT, "saturation scaling value" },
{ WINOPTION_SATURATION";fs_sat(0.0-4.0)", "1.0", OPTION_FLOAT, "saturation scaling value" },
{ WINOPTION_OFFSET";fs_offset", "0.0,0.0,0.0", OPTION_STRING, "signal offset value (additive)" },
{ WINOPTION_SCALE";fs_scale", "0.95,0.95,0.95", OPTION_STRING, "signal scaling value (multiplicative)" },
{ WINOPTION_POWER";fs_power", "0.8,0.8,0.8", OPTION_STRING, "signal power value (exponential)" },
{ WINOPTION_FLOOR";fs_floor", "0.05,0.05,0.05", OPTION_STRING, "signal floor level" },
{ WINOPTION_PHOSPHOR";fs_phosphor", "0.4,0.4,0.4", OPTION_STRING, "phosphorescence decay rate (0.0 is instant, 1.0 is forever)" },
{ WINOPTION_SCALE";fs_scale", "1.0,1.0,1.0", OPTION_STRING, "signal scaling value (multiplicative)" },
{ WINOPTION_POWER";fs_power", "1.0,1.0,1.0", OPTION_STRING, "signal power value (exponential)" },
{ WINOPTION_FLOOR";fs_floor", "0.0,0.0,0.0", OPTION_STRING, "signal floor level" },
{ WINOPTION_PHOSPHOR";fs_phosphor", "0.0,0.0,0.0", OPTION_STRING, "phosphorescence decay rate (0.0 is instant, 1.0 is forever)" },
/* NTSC simulation below this line */
{ nullptr, nullptr, OPTION_HEADER, "NTSC POST-PROCESSING OPTIONS" },
{ WINOPTION_YIQ_ENABLE";yiq", "0", OPTION_BOOLEAN, "enables YIQ-space HLSL post-processing" },
@ -344,20 +344,20 @@ const options_entry windows_options::s_option_entries[] =
{ WINOPTION_VECTOR_LENGTH_RATIO";vecsize", "500.0", OPTION_FLOAT, "Vector fade length (4.0 - vectors fade the most at and above 4 pixels, etc.)" },
/* Bloom below this line */
{ nullptr, nullptr, OPTION_HEADER, "BLOOM POST-PROCESSING OPTIONS" },
{ WINOPTION_BLOOM_BLEND_MODE, "0", OPTION_INTEGER, "bloom blend mode (0 for addition, 1 for darken)" },
{ WINOPTION_BLOOM_SCALE, "0.25", OPTION_FLOAT, "Intensity factor for bloom" },
{ WINOPTION_BLOOM_BLEND_MODE, "0", OPTION_INTEGER, "bloom blend mode (0 for brighten, 1 for darken)" },
{ WINOPTION_BLOOM_SCALE, "0.0", OPTION_FLOAT, "Intensity factor for bloom" },
{ WINOPTION_BLOOM_OVERDRIVE, "1.0,1.0,1.0", OPTION_STRING, "Overdrive factor for bloom" },
{ WINOPTION_BLOOM_LEVEL0_WEIGHT, "1.0", OPTION_FLOAT, "Bloom level 0 (full-size target) weight" },
{ WINOPTION_BLOOM_LEVEL1_WEIGHT, "0.64", OPTION_FLOAT, "Bloom level 1 (half-size target) weight" },
{ WINOPTION_BLOOM_LEVEL2_WEIGHT, "0.32", OPTION_FLOAT, "Bloom level 2 (quarter-size target) weight" },
{ WINOPTION_BLOOM_LEVEL3_WEIGHT, "0.16", OPTION_FLOAT, "Bloom level 3 (.) weight" },
{ WINOPTION_BLOOM_LEVEL4_WEIGHT, "0.08", OPTION_FLOAT, "Bloom level 4 (.) weight" },
{ WINOPTION_BLOOM_LEVEL5_WEIGHT, "0.04", OPTION_FLOAT, "Bloom level 5 (.) weight" },
{ WINOPTION_BLOOM_LEVEL6_WEIGHT, "0.04", OPTION_FLOAT, "Bloom level 6 (.) weight" },
{ WINOPTION_BLOOM_LEVEL7_WEIGHT, "0.02", OPTION_FLOAT, "Bloom level 7 (.) weight" },
{ WINOPTION_BLOOM_LEVEL8_WEIGHT, "0.02", OPTION_FLOAT, "Bloom level 8 (.) weight" },
{ WINOPTION_BLOOM_LEVEL9_WEIGHT, "0.01", OPTION_FLOAT, "Bloom level 9 (.) weight" },
{ WINOPTION_BLOOM_LEVEL10_WEIGHT, "0.01", OPTION_FLOAT, "Bloom level 10 (1x1 target) weight" },
{ WINOPTION_BLOOM_LEVEL1_WEIGHT, "0.64", OPTION_FLOAT, "Bloom level 1 (1/2-size target) weight" },
{ WINOPTION_BLOOM_LEVEL2_WEIGHT, "0.32", OPTION_FLOAT, "Bloom level 2 (1/4-size target) weight" },
{ WINOPTION_BLOOM_LEVEL3_WEIGHT, "0.16", OPTION_FLOAT, "Bloom level 3 (1/8-size target) weight" },
{ WINOPTION_BLOOM_LEVEL4_WEIGHT, "0.08", OPTION_FLOAT, "Bloom level 4 (1/16-size target) weight" },
{ WINOPTION_BLOOM_LEVEL5_WEIGHT, "0.04", OPTION_FLOAT, "Bloom level 5 (1/32-size target) weight" },
{ WINOPTION_BLOOM_LEVEL6_WEIGHT, "0.04", OPTION_FLOAT, "Bloom level 6 (1/64-size target) weight" },
{ WINOPTION_BLOOM_LEVEL7_WEIGHT, "0.02", OPTION_FLOAT, "Bloom level 7 (1/128-size target) weight" },
{ WINOPTION_BLOOM_LEVEL8_WEIGHT, "0.02", OPTION_FLOAT, "Bloom level 8 (1/256-size target) weight" },
{ WINOPTION_BLOOM_LEVEL9_WEIGHT, "0.01", OPTION_FLOAT, "Bloom level 9 (1/512-size target) weight" },
{ WINOPTION_BLOOM_LEVEL10_WEIGHT, "0.01", OPTION_FLOAT, "Bloom level 10 (1/1024-size target) weight" },
// full screen options
{ nullptr, nullptr, OPTION_HEADER, "FULL SCREEN OPTIONS" },