Added oversampling option

- and some cleanup
This commit is contained in:
ImJezze 2016-03-25 16:40:32 +01:00
parent 6c95a27490
commit c731b59cbe
6 changed files with 28 additions and 33 deletions

View file

@ -3,6 +3,7 @@ HLSL-Related Enable Switches
Name Values Description
hlsl_enable 0/1 Enables HLSL post-processing in Direct3D 9 modes.
hlsl_oversampling 0/1 Enables HLSL oversampling.
yiq_enable 0/1 Enables YIQ-colorspace post-processing. Causes a
performance drop but gives a much more authentic
NTSC TV appearance on TV-based systems when configured
@ -103,7 +104,7 @@ Bloom Post-Processing Options
-----------------------------
Name Default Values Description
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_scale 0.0 Bloom intensity factor. (0.000-4.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.64 Bloom level 1 (1/2-size target) weight. (0.00-1.00)

View file

@ -55,8 +55,6 @@ uniform float2 ScreenDims;
uniform float2 TargetDims;
uniform float2 QuadDims;
uniform int BloomLevel;
uniform bool VectorScreen;
static const float2 Coord0Offset = float2(-0.5f, -0.5f);

View file

@ -69,6 +69,7 @@ shaders::shaders() :
{
master_enable = false;
vector_enable = true;
oversampling_enable = false;
shadow_texture = nullptr;
options = nullptr;
paused = true;
@ -664,6 +665,7 @@ void shaders::init(d3d_base *d3dintf, running_machine *machine, renderer_d3d9 *r
windows_options &winoptions = downcast<windows_options &>(machine->options());
master_enable = winoptions.d3d_hlsl_enable();
oversampling_enable = winoptions.d3d_hlsl_oversampling();
snap_width = winoptions.d3d_snap_width();
snap_height = winoptions.d3d_snap_height();
@ -945,7 +947,6 @@ int shaders::create_resources(bool reset)
for (int i = 0; i < 13; i++)
{
effects[i]->add_uniform("SourceDims", uniform::UT_VEC2, uniform::CU_SOURCE_DIMS);
effects[i]->add_uniform("SourceRect", uniform::UT_VEC2, uniform::CU_SOURCE_RECT);
effects[i]->add_uniform("TargetDims", uniform::UT_VEC2, uniform::CU_TARGET_DIMS);
effects[i]->add_uniform("ScreenDims", uniform::UT_VEC2, uniform::CU_SCREEN_DIMS);
effects[i]->add_uniform("QuadDims", uniform::UT_VEC2, uniform::CU_QUAD_DIMS);
@ -1438,7 +1439,6 @@ int shaders::downsample_pass(d3d_render_target *rt, int source_index, poly_info
for (int bloom_index = 0; bloom_index < rt->bloom_count; bloom_index++)
{
curr_effect->set_vector("TargetDims", 2, rt->bloom_dims[bloom_index]);
curr_effect->set_int("BloomLevel", bloom_index + 1);
curr_effect->set_texture("DiffuseTexture",
bloom_index == 0
? rt->source_texture[next_index]
@ -1824,6 +1824,9 @@ d3d_render_target* shaders::get_texture_target(render_primitive *prim, texture_i
? static_cast<int>(prim->get_quad_width() + 0.5f)
: static_cast<int>(prim->get_quad_height() + 0.5f);
target_width *= oversampling_enable ? 2 : 1;
target_height *= oversampling_enable ? 2 : 1;
// find render target and check if the size of the target quad has changed
d3d_render_target *target = find_render_target(texture);
if (target != nullptr && target->target_width == target_width && target->target_height == target_height)
@ -1846,6 +1849,9 @@ d3d_render_target* shaders::get_vector_target(render_primitive *prim)
int target_width = static_cast<int>(prim->get_quad_width() + 0.5f);
int target_height = static_cast<int>(prim->get_quad_height() + 0.5f);
target_width *= oversampling_enable ? 2 : 1;
target_height *= oversampling_enable ? 2 : 1;
// find render target and check of the size of the target quad has changed
d3d_render_target *target = find_render_target(d3d->get_width(), d3d->get_height(), 0, 0);
if (target != nullptr && target->target_width == target_width && target->target_height == target_height)
@ -1863,7 +1869,10 @@ void shaders::create_vector_target(render_primitive *prim)
int target_width = static_cast<int>(prim->get_quad_width() + 0.5f);
int target_height = static_cast<int>(prim->get_quad_height() + 0.5f);
osd_printf_verbose("create_vector_target() - %f, %f; %d, %d\n", prim->get_quad_width(), prim->get_quad_height(), (int)(prim->get_quad_width() + 0.5f), (int)(prim->get_quad_height() + 0.5f));
target_width *= oversampling_enable ? 2 : 1;
target_height *= oversampling_enable ? 2 : 1;
osd_printf_verbose("create_vector_target() - %d, %d\n", target_width, target_height);
if (!add_render_target(d3d, nullptr, d3d->get_width(), d3d->get_height(), target_width, target_height))
{
vector_enable = false;
@ -1970,7 +1979,10 @@ bool shaders::register_texture(render_primitive *prim, texture_info *texture)
? static_cast<int>(prim->get_quad_width() + 0.5f)
: static_cast<int>(prim->get_quad_height() + 0.5f);
osd_printf_verbose("register_texture() - %f, %f; %d, %d\n", prim->get_quad_width(), prim->get_quad_height(), (int)(prim->get_quad_width() + 0.5f), (int)(prim->get_quad_height() + 0.5f));
target_width *= oversampling_enable ? 2 : 1;
target_height *= oversampling_enable ? 2 : 1;
osd_printf_verbose("register_texture() - %d, %d\n", target_width, target_height);
if (!add_render_target(d3d, texture, texture->get_width(), texture->get_height(), target_width, target_height))
{
return false;
@ -2369,7 +2381,7 @@ slider_desc shaders::s_sliders[] =
{ "Floor,", 0, 0, 100, 1, SLIDER_COLOR, SLIDER_SCREEN_TYPE_ANY, SLIDER_FLOOR, 0.01f, "%2.2f", {} },
{ "Phosphor Life,", 0, 0, 100, 1, SLIDER_COLOR, SLIDER_SCREEN_TYPE_ANY, SLIDER_PHOSPHOR, 0.01f, "%2.2f", {} },
{ "Bloom Blend Mode", 0, 0, 1, 1, SLIDER_INT_ENUM, SLIDER_SCREEN_TYPE_ANY, SLIDER_BLOOM_BLEND_MODE, 0, "%s", { "Brighten", "Darken" } },
{ "Bloom Scale", 0, 0, 2000, 5, SLIDER_FLOAT, SLIDER_SCREEN_TYPE_ANY, SLIDER_BLOOM_SCALE, 0.001f, "%1.3f", {} },
{ "Bloom Scale", 0, 0, 4000, 5, SLIDER_FLOAT, SLIDER_SCREEN_TYPE_ANY, SLIDER_BLOOM_SCALE, 0.001f, "%1.3f", {} },
{ "Bloom Overdrive,", 0, 0, 2000, 5, SLIDER_COLOR, SLIDER_SCREEN_TYPE_ANY, SLIDER_BLOOM_OVERDRIVE, 0.001f, "%1.3f", {} },
{ "Bloom Level 0 Scale", 0, 100, 100, 1, SLIDER_FLOAT, SLIDER_SCREEN_TYPE_ANY, SLIDER_BLOOM_LVL0_SCALE, 0.01f, "%1.2f", {} },
{ "Bloom Level 1 Scale", 0, 0, 100, 1, SLIDER_FLOAT, SLIDER_SCREEN_TYPE_ANY, SLIDER_BLOOM_LVL1_SCALE, 0.01f, "%1.2f", {} },
@ -2605,35 +2617,16 @@ void uniform::update()
}
case CU_SOURCE_DIMS:
{
if (shadersys->curr_texture != nullptr)
if (shadersys->curr_texture)
{
vec2f sourcedims = shadersys->curr_texture->get_rawdims();
m_shader->set_vector("SourceDims", 2, &sourcedims.c.x);
}
else
{
vec2f sourcedims = d3d->get_dims();
m_shader->set_vector("SourceDims", 2, &sourcedims.c.x);
}
break;
}
case CU_SOURCE_RECT:
{
if (shadersys->curr_texture != nullptr)
{
vec2f delta = shadersys->curr_texture->get_uvstop() - shadersys->curr_texture->get_uvstart();
m_shader->set_vector("SourceRect", 2, &delta.c.x);
}
else
{
float delta[2] = { 1.0f, 1.0f };
m_shader->set_vector("SourceRect", 2, delta);
}
break;
}
case CU_TARGET_DIMS:
{
if (shadersys->curr_render_target != nullptr)
if (shadersys->curr_render_target)
{
float targetdims[2] = {
static_cast<float>(shadersys->curr_render_target->target_width),
@ -2644,7 +2637,7 @@ void uniform::update()
}
case CU_QUAD_DIMS:
{
if (shadersys->curr_poly != nullptr)
if (shadersys->curr_poly)
{
float quaddims[2] = {
// round

View file

@ -45,7 +45,6 @@ public:
{
CU_SCREEN_DIMS = 0,
CU_SOURCE_DIMS,
CU_SOURCE_RECT,
CU_TARGET_DIMS,
CU_QUAD_DIMS,
@ -384,6 +383,7 @@ private:
bool master_enable; // overall enable flag
bool vector_enable; // vector post-processing enable flag
bool oversampling_enable; // oversampling enable flag
bool paused; // whether or not rendering is currently paused
int num_screens; // number of emulated physical screens
int curr_screen; // current screen for render target operations

View file

@ -277,8 +277,9 @@ const options_entry windows_options::s_option_entries[] =
// post-processing options
{ nullptr, nullptr, OPTION_HEADER, "DIRECT3D POST-PROCESSING OPTIONS" },
{ WINOPTION_HLSL_ENABLE";hlsl", "0", OPTION_BOOLEAN, "enables HLSL post-processing (PS3.0 required)" },
{ WINOPTION_HLSLPATH, "hlsl", OPTION_STRING, "path to hlsl files" },
{ WINOPTION_HLSL_ENABLE";hlsl", "0", OPTION_BOOLEAN, "enables HLSL post-processing (PS3.0 required)" },
{ WINOPTION_HLSL_OVERSAMPLING, "0", OPTION_BOOLEAN, "enables HLSL oversampling" },
{ WINOPTION_HLSL_WRITE, nullptr, OPTION_STRING, "enables HLSL AVI writing (huge disk bandwidth suggested)" },
{ WINOPTION_HLSL_SNAP_WIDTH, "2048", OPTION_STRING, "HLSL upscaled-snapshot width" },
{ WINOPTION_HLSL_SNAP_HEIGHT, "1536", OPTION_STRING, "HLSL upscaled-snapshot height" },

View file

@ -26,8 +26,9 @@
#define WINOPTION_MENU "menu"
// core post-processing options
#define WINOPTION_HLSL_ENABLE "hlsl_enable"
#define WINOPTION_HLSLPATH "hlslpath"
#define WINOPTION_HLSL_ENABLE "hlsl_enable"
#define WINOPTION_HLSL_OVERSAMPLING "hlsl_oversampling"
#define WINOPTION_HLSL_WRITE "hlsl_write"
#define WINOPTION_HLSL_SNAP_WIDTH "hlsl_snap_width"
#define WINOPTION_HLSL_SNAP_HEIGHT "hlsl_snap_height"
@ -128,6 +129,7 @@ public:
// core post-processing options
const char *screen_post_fx_dir() const { return value(WINOPTION_HLSLPATH); }
bool d3d_hlsl_enable() const { return bool_value(WINOPTION_HLSL_ENABLE); }
bool d3d_hlsl_oversampling() const { return bool_value(WINOPTION_HLSL_OVERSAMPLING); }
const char *d3d_hlsl_write() const { return value(WINOPTION_HLSL_WRITE); }
int d3d_snap_width() const { return int_value(WINOPTION_HLSL_SNAP_WIDTH); }
int d3d_snap_height() const { return int_value(WINOPTION_HLSL_SNAP_HEIGHT); }