summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--hlsl/prescale.fx2
-rw-r--r--hlsl/primary.fx106
-rw-r--r--src/osd/modules/render/d3d/d3dhlsl.cpp25
-rw-r--r--src/osd/modules/render/d3d/d3dhlsl.h6
-rw-r--r--src/osd/modules/render/drawd3d.cpp28
5 files changed, 112 insertions, 55 deletions
diff --git a/hlsl/prescale.fx b/hlsl/prescale.fx
index 1cbcaa0f753..419254acd07 100644
--- a/hlsl/prescale.fx
+++ b/hlsl/prescale.fx
@@ -107,4 +107,4 @@ technique DefaultTechnique
VertexShader = compile vs_3_0 vs_main();
PixelShader = compile ps_3_0 ps_main();
}
-} \ No newline at end of file
+}
diff --git a/hlsl/primary.fx b/hlsl/primary.fx
index 3f08afd3dca..2086132a0e7 100644
--- a/hlsl/primary.fx
+++ b/hlsl/primary.fx
@@ -46,18 +46,18 @@ struct PS_INPUT
};
//-----------------------------------------------------------------------------
-// Primary Vertex Shader
+// Primary Vertex Shaders
//-----------------------------------------------------------------------------
static const float Epsilon = 1.0e-7f;
uniform float2 ScreenDims;
uniform float2 TargetDims;
+uniform float2 QuadDims;
-uniform bool PostPass;
uniform bool VectorScreen;
-VS_OUTPUT vs_main(VS_INPUT Input)
+VS_OUTPUT vs_screen_main(VS_INPUT Input)
{
VS_OUTPUT Output = (VS_OUTPUT)0;
@@ -67,18 +67,43 @@ VS_OUTPUT vs_main(VS_INPUT Input)
Output.Position.xy -= 0.5f; // center
Output.Position.xy *= 2.0f; // zoom
- float2 targetDims = TargetDims + Epsilon; // bug: with exact target dimensions the font disappears
+ Output.TexCoord = Input.Position.xy / ScreenDims;
+ Output.TexCoord += 0.5f / TargetDims; // half texel offset correction (DX9)
- if (PostPass)
- {
- Output.TexCoord = Input.Position.xy / ScreenDims;
- Output.TexCoord += 0.5f / targetDims; // half texel offset correction (DX9)
- }
- else
- {
- Output.TexCoord = Input.TexCoord;
- // Output.TexCoord += 0.5f / targetDims; // half texel offset correction (DX9)
- }
+ Output.Color = Input.Color;
+
+ return Output;
+}
+
+VS_OUTPUT vs_vector_buffer_main(VS_INPUT Input)
+{
+ VS_OUTPUT Output = (VS_OUTPUT)0;
+
+ Output.Position = float4(Input.Position.xyz, 1.0f);
+ Output.Position.xy /= ScreenDims;
+ Output.Position.y = 1.0f - Output.Position.y; // flip y
+ Output.Position.xy -= 0.5f; // center
+ Output.Position.xy *= 2.0f; // zoom
+
+ Output.TexCoord = Input.Position.xy / ScreenDims;
+ Output.TexCoord += 0.5f / TargetDims; // half texel offset correction (DX9)
+
+ Output.Color = Input.Color;
+
+ return Output;
+}
+
+VS_OUTPUT vs_ui_main(VS_INPUT Input)
+{
+ VS_OUTPUT Output = (VS_OUTPUT)0;
+
+ Output.Position = float4(Input.Position.xyz, 1.0f);
+ Output.Position.xy /= ScreenDims;
+ Output.Position.y = 1.0f - Output.Position.y; // flip y
+ Output.Position.xy -= 0.5f; // center
+ Output.Position.xy *= 2.0f; // zoom
+
+ Output.TexCoord = Input.TexCoord;
Output.Color = Input.Color;
@@ -86,30 +111,65 @@ VS_OUTPUT vs_main(VS_INPUT Input)
}
//-----------------------------------------------------------------------------
-// Primary Pixel Shader
+// Primary Pixel Shaders
//-----------------------------------------------------------------------------
-float4 ps_main(PS_INPUT Input) : COLOR
+float4 ps_screen_main(PS_INPUT Input) : COLOR
+{
+ float4 BaseTexel = tex2D(DiffuseSampler, Input.TexCoord);
+
+ return BaseTexel;
+}
+
+float4 ps_vector_buffer_main(PS_INPUT Input) : COLOR
{
float4 BaseTexel = tex2D(DiffuseSampler, Input.TexCoord);
- BaseTexel *= PostPass && VectorScreen
- ? Input.Color + float4(1.0f, 1.0f, 1.0f, 0.0f)
- : Input.Color;
+ BaseTexel *= Input.Color + float4(1.0f, 1.0f, 1.0f, 0.0f);
+
+ return BaseTexel;
+}
+
+float4 ps_ui_main(PS_INPUT Input) : COLOR
+{
+ float4 BaseTexel = tex2D(DiffuseSampler, Input.TexCoord);
+ BaseTexel *= Input.Color;
return BaseTexel;
}
//-----------------------------------------------------------------------------
-// Primary Technique
+// Primary Techniques
//-----------------------------------------------------------------------------
-technique DefaultTechnique
+technique ScreenTechnique
+{
+ pass Pass0
+ {
+ Lighting = FALSE;
+
+ VertexShader = compile vs_2_0 vs_screen_main();
+ PixelShader = compile ps_2_0 ps_screen_main();
+ }
+}
+
+technique VectorBufferTechnique
+{
+ pass Pass0
+ {
+ Lighting = FALSE;
+
+ VertexShader = compile vs_2_0 vs_vector_buffer_main();
+ PixelShader = compile ps_2_0 ps_vector_buffer_main();
+ }
+}
+
+technique UiTechnique
{
pass Pass0
{
Lighting = FALSE;
- VertexShader = compile vs_2_0 vs_main();
- PixelShader = compile ps_2_0 ps_main();
+ VertexShader = compile vs_2_0 vs_ui_main();
+ PixelShader = compile ps_2_0 ps_ui_main();
}
}
diff --git a/src/osd/modules/render/d3d/d3dhlsl.cpp b/src/osd/modules/render/d3d/d3dhlsl.cpp
index 5fc5e9a4899..1b635b94c8f 100644
--- a/src/osd/modules/render/d3d/d3dhlsl.cpp
+++ b/src/osd/modules/render/d3d/d3dhlsl.cpp
@@ -977,18 +977,11 @@ int shaders::create_resources(bool reset)
phosphor_effect->add_uniform("Phosphor", uniform::UT_VEC3, uniform::CU_PHOSPHOR_LIFE);
- post_effect->add_uniform("VignettingAmount", uniform::UT_FLOAT, uniform::CU_POST_VIGNETTING); // backward compatibility
- post_effect->add_uniform("CurvatureAmount", uniform::UT_FLOAT, uniform::CU_POST_CURVATURE); // backward compatibility
- post_effect->add_uniform("RoundCornerAmount", uniform::UT_FLOAT, uniform::CU_POST_ROUND_CORNER); // backward compatibility
- post_effect->add_uniform("SmoothBorderAmount", uniform::UT_FLOAT, uniform::CU_POST_SMOOTH_BORDER); // backward compatibility
- post_effect->add_uniform("ReflectionAmount", uniform::UT_FLOAT, uniform::CU_POST_REFLECTION); // backward compatibility
-
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);
post_effect->add_uniform("ShadowUV", uniform::UT_VEC2, uniform::CU_POST_SHADOW_UV);
post_effect->add_uniform("ShadowUVOffset", uniform::UT_VEC2, uniform::CU_POST_SHADOW_UV_OFFSET);
post_effect->add_uniform("ShadowDims", uniform::UT_VEC2, uniform::CU_POST_SHADOW_DIMS);
-
post_effect->add_uniform("ScanlineAlpha", uniform::UT_FLOAT, uniform::CU_POST_SCANLINE_ALPHA);
post_effect->add_uniform("ScanlineScale", uniform::UT_FLOAT, uniform::CU_POST_SCANLINE_SCALE);
post_effect->add_uniform("ScanlineHeight", uniform::UT_FLOAT, uniform::CU_POST_SCANLINE_HEIGHT);
@@ -996,7 +989,6 @@ int shaders::create_resources(bool reset)
post_effect->add_uniform("ScanlineBrightOffset", uniform::UT_FLOAT, uniform::CU_POST_SCANLINE_BRIGHT_OFFSET);
post_effect->add_uniform("Power", uniform::UT_VEC3, uniform::CU_POST_POWER);
post_effect->add_uniform("Floor", uniform::UT_VEC3, uniform::CU_POST_FLOOR);
-
post_effect->add_uniform("RotationType", uniform::UT_INT, uniform::CU_ROTATION_TYPE);
distortion_effect->add_uniform("VignettingAmount", uniform::UT_FLOAT, uniform::CU_POST_VIGNETTING);
@@ -1004,7 +996,6 @@ int shaders::create_resources(bool reset)
distortion_effect->add_uniform("RoundCornerAmount", uniform::UT_FLOAT, uniform::CU_POST_ROUND_CORNER);
distortion_effect->add_uniform("SmoothBorderAmount", uniform::UT_FLOAT, uniform::CU_POST_SMOOTH_BORDER);
distortion_effect->add_uniform("ReflectionAmount", uniform::UT_FLOAT, uniform::CU_POST_REFLECTION);
-
distortion_effect->add_uniform("RotationType", uniform::UT_INT, uniform::CU_ROTATION_TYPE);
initialized = true;
@@ -1026,7 +1017,7 @@ void shaders::begin_draw()
curr_effect = default_effect;
- default_effect->set_technique("DefaultTechnique");
+ default_effect->set_technique("ScreenTechnique");
post_effect->set_technique("DefaultTechnique");
distortion_effect->set_technique("DefaultTechnique");
prescale_effect->set_technique("DefaultTechnique");
@@ -1605,9 +1596,9 @@ int shaders::vector_buffer_pass(d3d_render_target *rt, int source_index, poly_in
curr_effect = default_effect;
curr_effect->update_uniforms();
+ curr_effect->set_technique("VectorBufferTechnique");
curr_effect->set_texture("Diffuse", rt->target_texture[next_index]);
- curr_effect->set_bool("PostPass", true);
next_index = rt->next_index(next_index);
// blit(rt->target_surface[next_index], true, D3DPT_TRIANGLELIST, 0, 2);
@@ -1622,11 +1613,11 @@ int shaders::screen_pass(d3d_render_target *rt, int source_index, poly_info *pol
curr_effect = default_effect;
curr_effect->update_uniforms();
+ curr_effect->set_technique("ScreenTechnique");
curr_effect->set_texture("Diffuse", rt->target_texture[next_index]);
- curr_effect->set_bool("PostPass", true);
- // we do not clear the backbuffe here because multiple screens might rendered into
+ // we do not clear the backbuffe here because multiple screens might be rendered into
blit(backbuffer, false, poly->get_type(), vertnum, poly->get_count());
if (avi_output_file != NULL)
@@ -1644,11 +1635,11 @@ int shaders::screen_pass(d3d_render_target *rt, int source_index, poly_info *pol
return next_index;
}
-void shaders::menu_pass(poly_info *poly, int vertnum)
+void shaders::ui_pass(poly_info *poly, int vertnum)
{
curr_effect = default_effect;
curr_effect->update_uniforms();
- curr_effect->set_bool("PostPass", false);
+ curr_effect->set_technique("UiTechnique");
blit(NULL, false, poly->get_type(), vertnum, poly->get_count());
}
@@ -1786,7 +1777,7 @@ void shaders::render_quad(poly_info *poly, int vertnum)
}
else
{
- menu_pass(poly, vertnum);
+ ui_pass(poly, vertnum);
}
curr_render_target = NULL;
@@ -1965,7 +1956,7 @@ void shaders::enumerate_screens()
// shaders::register_texture(texture::info)
//============================================================
-bool shaders::register_texture(texture_info *texture)
+bool shaders::register_texture(render_primitive *prim, texture_info *texture)
{
if (!master_enable || !d3dintf->post_fx_available)
{
diff --git a/src/osd/modules/render/d3d/d3dhlsl.h b/src/osd/modules/render/d3d/d3dhlsl.h
index 5d59aabc6e2..caab833e7d7 100644
--- a/src/osd/modules/render/d3d/d3dhlsl.h
+++ b/src/osd/modules/render/d3d/d3dhlsl.h
@@ -290,7 +290,7 @@ public:
void init_effect_info(poly_info *poly);
void render_quad(poly_info *poly, int vertnum);
- bool register_texture(texture_info *texture);
+ bool register_texture(render_primitive *prim, texture_info *texture);
bool add_render_target(renderer_d3d9* d3d, texture_info* info, int width, int height, int target_width, int target_height);
bool add_cache_target(renderer_d3d9* d3d, texture_info* info, int width, int height, int screen_index);
@@ -344,8 +344,6 @@ private:
void end_avi_recording();
void begin_avi_recording(const char *name);
- bool register_texture(texture_info *texture, int width, int height, int xscale, int yscale);
-
d3d_render_target* find_render_target(int width, int height, UINT32 screen_index, UINT32 page_index);
cache_target * find_cache_target(UINT32 screen_index, int width, int height);
void remove_cache_target(cache_target *cache);
@@ -366,7 +364,7 @@ private:
int vector_pass(d3d_render_target *rt, int source_index, poly_info *poly, int vertnum);
int vector_buffer_pass(d3d_render_target *rt, int source_index, poly_info *poly, int vertnum);
int screen_pass(d3d_render_target *rt, int source_index, poly_info *poly, int vertnum);
- void menu_pass(poly_info *poly, int vertnum);
+ void ui_pass(poly_info *poly, int vertnum);
d3d_base * d3dintf; // D3D interface
diff --git a/src/osd/modules/render/drawd3d.cpp b/src/osd/modules/render/drawd3d.cpp
index edce723c475..4037c9c0bbe 100644
--- a/src/osd/modules/render/drawd3d.cpp
+++ b/src/osd/modules/render/drawd3d.cpp
@@ -694,8 +694,20 @@ void d3d_texture_manager::update_textures()
texture_info *texture = find_texinfo(&prim->texture, prim->flags);
if (texture == nullptr)
{
- // if there isn't one, create a new texture
- global_alloc(texture_info(this, &prim->texture, m_renderer->window().prescale(), prim->flags));
+ if (m_renderer->get_shaders()->enabled())
+ {
+ // create a new texture without prescale, shaders will handle the prescale
+ texture = global_alloc(texture_info(this, &prim->texture, 1, prim->flags));
+ if (texture != nullptr)
+ {
+ m_renderer->get_shaders()->register_texture(prim, texture);
+ }
+ }
+ else
+ {
+ // create a new texture
+ texture = global_alloc(texture_info(this, &prim->texture, m_renderer->window().prescale(), prim->flags));
+ }
}
else
{
@@ -1689,11 +1701,12 @@ void renderer_d3d9::draw_quad(const render_primitive *prim)
float height = prim->bounds.y1 - prim->bounds.y0;
// set the texture coordinates
- if(texture != nullptr)
+ if (texture != nullptr)
{
vec2f& start = texture->get_uvstart();
vec2f& stop = texture->get_uvstop();
vec2f delta = stop - start;
+
vertex[0].u0 = start.c.x + delta.c.x * prim->texcoords.tl.u;
vertex[0].v0 = start.c.y + delta.c.y * prim->texcoords.tl.v;
vertex[1].u0 = start.c.x + delta.c.x * prim->texcoords.tr.u;
@@ -2018,11 +2031,11 @@ texture_info::texture_info(d3d_texture_manager *manager, const render_texinfo* t
}
// screen textures with no prescaling are pretty easy and shaders handle prescale itself
- if ((m_xprescale == 1 && m_yprescale == 1) || m_renderer->get_shaders()->enabled())
+ if (m_xprescale == 1 && m_yprescale == 1)
{
// required to compute the size
m_type = m_texture_manager->is_dynamic_supported() ? TEXTURE_TYPE_DYNAMIC : TEXTURE_TYPE_PLAIN;
-
+
// compute the size
compute_size(texsource->width, texsource->height);
@@ -2030,11 +2043,6 @@ texture_info::texture_info(d3d_texture_manager *manager, const render_texinfo* t
if (result == D3D_OK)
{
m_d3dfinaltex = m_d3dtex;
- if (m_renderer->get_shaders()->enabled() && !m_renderer->get_shaders()->register_texture(this))
- {
- goto error;
- }
-
break;
}
}