summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/modules/render/d3d/d3dhlsl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/osd/modules/render/d3d/d3dhlsl.cpp')
-rw-r--r--src/osd/modules/render/d3d/d3dhlsl.cpp93
1 files changed, 72 insertions, 21 deletions
diff --git a/src/osd/modules/render/d3d/d3dhlsl.cpp b/src/osd/modules/render/d3d/d3dhlsl.cpp
index 1e0f42a7bd8..9ae9521a3a7 100644
--- a/src/osd/modules/render/d3d/d3dhlsl.cpp
+++ b/src/osd/modules/render/d3d/d3dhlsl.cpp
@@ -1,5 +1,4 @@
// license:BSD-3-Clause
-//
// copyright-holders:Aaron Giles
//============================================================
//
@@ -170,9 +169,9 @@ shaders::shaders() :
snap_copy_target(nullptr), snap_copy_texture(nullptr), snap_target(nullptr), snap_texture(nullptr),
snap_width(0), snap_height(0), initialized(false), backbuffer(nullptr), curr_effect(nullptr),
default_effect(nullptr), prescale_effect(nullptr), post_effect(nullptr), distortion_effect(nullptr),
- focus_effect(nullptr), phosphor_effect(nullptr), deconverge_effect(nullptr), color_effect(nullptr),
- ntsc_effect(nullptr), bloom_effect(nullptr), downsample_effect(nullptr), vector_effect(nullptr),
- curr_texture(nullptr), curr_render_target(nullptr), curr_poly(nullptr),
+ focus_effect(nullptr), phosphor_effect(nullptr), ghosting_effect(nullptr), deconverge_effect(nullptr),
+ color_effect(nullptr), ntsc_effect(nullptr), bloom_effect(nullptr), downsample_effect(nullptr),
+ vector_effect(nullptr), curr_texture(nullptr), curr_render_target(nullptr), curr_poly(nullptr),
d3dx_create_effect_from_file_ptr(nullptr)
{
}
@@ -524,7 +523,10 @@ bool shaders::init(d3d_base *d3dintf, running_machine *machine, renderer_d3d9 *r
options->phosphor_time, true);
get_vector(winoptions.screen_phosphor_beta(), 3,
options->phosphor_beta, true);
- options->lcd_persistence = winoptions.screen_lcd_persistence();
+ get_vector(winoptions.screen_lcd_rise_time(), 3,
+ options->lcd_rise_time, true);
+ get_vector(winoptions.screen_lcd_fall_time(), 3,
+ options->lcd_fall_time, true);
options->saturation = winoptions.screen_saturation();
options->yiq_enable = winoptions.screen_yiq_enable();
options->yiq_jitter = winoptions.screen_yiq_jitter();
@@ -715,6 +717,7 @@ int shaders::create_resources()
distortion_effect = new effect(this, d3d->get_device(), "distortion.fx", fx_dir);
prescale_effect = new effect(this, d3d->get_device(), "prescale.fx", fx_dir);
phosphor_effect = new effect(this, d3d->get_device(), "phosphor.fx", fx_dir);
+ ghosting_effect = new effect(this, d3d->get_device(), "ghosting.fx", fx_dir);
focus_effect = new effect(this, d3d->get_device(), "focus.fx", fx_dir);
deconverge_effect = new effect(this, d3d->get_device(), "deconverge.fx", fx_dir);
color_effect = new effect(this, d3d->get_device(), "color.fx", fx_dir);
@@ -728,6 +731,7 @@ int shaders::create_resources()
!distortion_effect->is_valid() ||
!prescale_effect->is_valid() ||
!phosphor_effect->is_valid() ||
+ !ghosting_effect->is_valid() ||
!focus_effect->is_valid() ||
!deconverge_effect->is_valid() ||
!color_effect->is_valid() ||
@@ -739,12 +743,13 @@ int shaders::create_resources()
return 1;
}
- effect *effects[13] = {
+ effect *effects[14] = {
default_effect,
post_effect,
distortion_effect,
prescale_effect,
phosphor_effect,
+ ghosting_effect,
focus_effect,
deconverge_effect,
color_effect,
@@ -755,7 +760,7 @@ int shaders::create_resources()
vector_effect
};
- for (int i = 0; i < 13; i++)
+ for (int i = 0; i < 14; i++)
{
effects[i]->add_uniform("SourceDims", uniform::UT_VEC2, uniform::CU_SOURCE_DIMS);
effects[i]->add_uniform("TargetDims", uniform::UT_VEC2, uniform::CU_TARGET_DIMS);
@@ -795,7 +800,9 @@ int shaders::create_resources()
phosphor_effect->add_uniform("Mode", uniform::UT_INT, uniform::CU_PHOSPHOR_MODE);
phosphor_effect->add_uniform("TimeConstant", uniform::UT_VEC3, uniform::CU_PHOSPHOR_TIME);
phosphor_effect->add_uniform("Beta", uniform::UT_VEC3, uniform::CU_PHOSPHOR_BETA);
- phosphor_effect->add_uniform("LCDTau", uniform::UT_FLOAT, uniform::CU_LCD_PERSISTENCE);
+
+ ghosting_effect->add_uniform("LCDRise", uniform::UT_FLOAT, uniform::CU_LCD_RISE_TIME);
+ ghosting_effect->add_uniform("LCDFall", uniform::UT_FLOAT, uniform::CU_LCD_FALL_TIME);
post_effect->add_uniform("ShadowAlpha", uniform::UT_FLOAT, uniform::CU_POST_SHADOW_ALPHA);
post_effect->add_uniform("ShadowCount", uniform::UT_VEC2, uniform::CU_POST_SHADOW_COUNT);
@@ -848,6 +855,7 @@ void shaders::begin_draw()
distortion_effect->set_technique("DefaultTechnique");
prescale_effect->set_technique("DefaultTechnique");
phosphor_effect->set_technique("DefaultTechnique");
+ ghosting_effect->set_technique("DefaultTechnique");
focus_effect->set_technique("DefaultTechnique");
deconverge_effect->set_technique("DefaultTechnique");
color_effect->set_technique("DefaultTechnique");
@@ -1079,10 +1087,9 @@ int shaders::phosphor_pass(d3d_render_target *rt, int source_index, poly_info *p
int next_index = source_index;
auto stype = machine->first_screen()->screen_type();
- // skip phosphor if mode is off
- if ((options->phosphor_mode == 0 && stype == SCREEN_TYPE_RASTER) ||
- (options->phosphor_mode == 0 && stype == SCREEN_TYPE_VECTOR) ||
- (options->lcd_persistence == 0 && stype == SCREEN_TYPE_LCD))
+ // skip if screen doesn't use phosphors
+ if ((stype != SCREEN_TYPE_RASTER && stype != SCREEN_TYPE_VECTOR) ||
+ options->phosphor_mode == 0)
{
return next_index;
}
@@ -1093,10 +1100,6 @@ int shaders::phosphor_pass(d3d_render_target *rt, int source_index, poly_info *p
curr_effect->set_texture("LastPass", rt->cache_texture);
curr_effect->set_bool("Passthrough", false);
curr_effect->set_float("DeltaTime", delta_time());
- if (stype == SCREEN_TYPE_LCD)
- curr_effect->set_bool("LCD", true);
- else
- curr_effect->set_bool("LCD", false);
next_index = rt->next_index(next_index);
blit(rt->target_surface[next_index], false, D3DPT_TRIANGLELIST, 0, 2);
@@ -1112,6 +1115,38 @@ int shaders::phosphor_pass(d3d_render_target *rt, int source_index, poly_info *p
return next_index;
}
+int shaders::ghosting_pass(d3d_render_target *rt, int source_index, poly_info *poly, int vertnum)
+{
+ int next_index = source_index;
+ auto stype = machine->first_screen()->screen_type();
+
+ if (stype != SCREEN_TYPE_LCD ||
+ (options->lcd_rise_time == 0 && options->lcd_fall_time == 0))
+ {
+ return next_index;
+ }
+
+ curr_effect = ghosting_effect;
+ curr_effect->update_uniforms();
+ curr_effect->set_texture("Diffuse", rt->target_texture[next_index]);
+ curr_effect->set_texture("LastPass", rt->cache_texture);
+ curr_effect->set_bool("Passthrough", false);
+ curr_effect->set_float("DeltaTime", delta_time());
+
+ next_index = rt->next_index(next_index);
+ blit(rt->target_surface[next_index], false, D3DPT_TRIANGLELIST, 0, 2);
+
+ // Pass along our ghost'd screen
+ curr_effect->update_uniforms();
+ curr_effect->set_texture("Diffuse", rt->target_texture[next_index]);
+ curr_effect->set_texture("LastPass", rt->target_texture[next_index]);
+ curr_effect->set_bool("Passthrough", true);
+
+ blit(rt->cache_surface, false, D3DPT_TRIANGLELIST, 0, 2);
+
+ return next_index;
+}
+
int shaders::post_pass(d3d_render_target *rt, int source_index, poly_info *poly, int vertnum, bool prepare_bloom)
{
int next_index = source_index;
@@ -1379,8 +1414,10 @@ void shaders::render_quad(poly_info *poly, int vertnum)
next_index = deconverge_pass(rt, next_index, poly, vertnum); // handled in bgfx
next_index = defocus_pass(rt, next_index, poly, vertnum);
next_index = phosphor_pass(rt, next_index, poly, vertnum);
+ next_index = ghosting_pass(rt, next_index, poly, vertnum);
// create bloom textures
+ // This may be phosphor or ghosting, depending on screen type
int phosphor_index = next_index;
next_index = post_pass(rt, next_index, poly, vertnum, true);
next_index = downsample_pass(rt, next_index, poly, vertnum);
@@ -1458,8 +1495,10 @@ void shaders::render_quad(poly_info *poly, int vertnum)
next_index = deconverge_pass(rt, next_index, poly, vertnum);
next_index = defocus_pass(rt, next_index, poly, vertnum);
next_index = phosphor_pass(rt, next_index, poly, vertnum);
+ next_index = ghosting_pass(rt, next_index, poly, vertnum);
// create bloom textures
+ // This may be phosphor or ghosting, depending on screen type
int phosphor_index = next_index;
next_index = post_pass(rt, next_index, poly, vertnum, true);
next_index = downsample_pass(rt, next_index, poly, vertnum);
@@ -1750,6 +1789,11 @@ void shaders::delete_resources()
delete phosphor_effect;
phosphor_effect = nullptr;
}
+ if (ghosting_effect != nullptr)
+ {
+ delete ghosting_effect;
+ ghosting_effect = nullptr;
+ }
if (focus_effect != nullptr)
{
delete focus_effect;
@@ -1967,7 +2011,8 @@ enum slider_option
SLIDER_PHOSPHOR_MODE,
SLIDER_PHOSPHOR_TIME,
SLIDER_PHOSPHOR_BETA,
- SLIDER_LCD_PERSISTENCE,
+ SLIDER_LCD_RISE_TIME,
+ SLIDER_LCD_FALL_TIME,
SLIDER_BLOOM_BLEND_MODE,
SLIDER_BLOOM_SCALE,
SLIDER_BLOOM_OVERDRIVE,
@@ -2049,7 +2094,8 @@ slider_desc shaders::s_sliders[] =
{ "Phosphor Persistence Mode,", 0, 0, 2, 1, SLIDER_INT_ENUM, SLIDER_SCREEN_TYPE_RASTER_OR_VECTOR, SLIDER_PHOSPHOR_MODE, 0, "%s", { "Off", "Exponential", "Inverse Power" } },
{ "Phosphor Persistence Time Constant,",1, 5000, 10000,10, SLIDER_COLOR, SLIDER_SCREEN_TYPE_RASTER_OR_VECTOR, SLIDER_PHOSPHOR_TIME, 0.0001f, "%4.4f", {} },
{ "Phosphor Persistence beta,", 50, 100, 200, 1, SLIDER_COLOR, SLIDER_SCREEN_TYPE_RASTER_OR_VECTOR, SLIDER_PHOSPHOR_BETA, 0.01f, "%2.2f", {} },
- { "LCD Perisistence,", 0, 20, 100, 1, SLIDER_FLOAT, SLIDER_SCREEN_TYPE_LCD, SLIDER_LCD_PERSISTENCE, 0.001f, "%3.3f", {} },
+ { "LCD Rise Time Constant,", 0, 50, 100, 1, SLIDER_COLOR, SLIDER_SCREEN_TYPE_LCD, SLIDER_LCD_RISE_TIME, 0.01f, "%2.2f", {} },
+ { "LCD Fall Time Constant,", 0, 50, 100, 1, SLIDER_COLOR, SLIDER_SCREEN_TYPE_LCD, SLIDER_LCD_FALL_TIME, 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 Overdrive,", 0, 0, 2000, 5, SLIDER_COLOR, SLIDER_SCREEN_TYPE_ANY, SLIDER_BLOOM_OVERDRIVE, 0.001f, "%1.3f", {} },
@@ -2124,7 +2170,8 @@ void *shaders::get_slider_option(int id, int index)
case SLIDER_PHOSPHOR_MODE: return &(options->phosphor_mode);
case SLIDER_PHOSPHOR_TIME: return &(options->phosphor_time[index]);
case SLIDER_PHOSPHOR_BETA: return &(options->phosphor_beta[index]);
- case SLIDER_LCD_PERSISTENCE: return &(options->lcd_persistence);
+ case SLIDER_LCD_RISE_TIME: return &(options->lcd_rise_time[index]);
+ case SLIDER_LCD_FALL_TIME: return &(options->lcd_fall_time[index]);
case SLIDER_BLOOM_BLEND_MODE: return &(options->bloom_blend_mode);
case SLIDER_BLOOM_SCALE: return &(options->bloom_scale);
case SLIDER_BLOOM_OVERDRIVE: return &(options->bloom_overdrive[index]);
@@ -2421,8 +2468,12 @@ void uniform::update()
m_shader->set_vector("Beta", 3, options->phosphor_beta);
break;
- case CU_LCD_PERSISTENCE:
- m_shader->set_float("LCDTau", options->lcd_persistence);
+ case CU_LCD_RISE_TIME:
+ m_shader->set_vector("LCDRise", 3, options->lcd_rise_time);
+ break;
+ case CU_LCD_FALL_TIME:
+ m_shader->set_vector("LCDFall", 3, options->lcd_fall_time);
+ break;
case CU_POST_REFLECTION:
m_shader->set_float("ReflectionAmount", options->reflection);