summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--hlsl/artwork_support/post.fx33
-rw-r--r--hlsl/distortion.fx7
-rw-r--r--hlsl/focus.fx18
-rw-r--r--hlsl/post.fx30
-rw-r--r--hlsl/prescale.fx10
-rw-r--r--src/osd/modules/render/d3d/d3dhlsl.cpp176
-rw-r--r--src/osd/modules/render/d3d/d3dhlsl.h1
-rw-r--r--src/osd/modules/render/drawd3d.cpp33
-rw-r--r--src/osd/modules/render/drawd3d.h3
9 files changed, 131 insertions, 180 deletions
diff --git a/hlsl/artwork_support/post.fx b/hlsl/artwork_support/post.fx
index 48530272c9d..8da6dabf1ab 100644
--- a/hlsl/artwork_support/post.fx
+++ b/hlsl/artwork_support/post.fx
@@ -74,11 +74,6 @@ static const float GelfondSchneider = 2.6651442f; // 2^sqrt(2) (Gelfond-Schneide
// Functions
//-----------------------------------------------------------------------------
-bool xor(bool a, bool b)
-{
- return (a || b) && !(a && b);
-}
-
// www.stackoverflow.com/questions/5149544/can-i-generate-a-random-number-inside-a-pixel-shader/
float random(float2 seed)
{
@@ -114,8 +109,8 @@ uniform float2 QuadDims; // size of the screen quad
uniform float2 ShadowDims = float2(32.0f, 32.0f); // size of the shadow texture (extended to power-of-two size)
uniform float2 ShadowUVOffset = float2(0.0f, 0.0f);
-uniform bool OrientationSwapXY = false; // false landscape, true portrait for default screen orientation
-uniform bool RotationSwapXY = false; // swapped default screen orientation due to screen rotation
+uniform bool SwapXY = false;
+
uniform int RotationType = 0; // 0 = 0°, 1 = 90°, 2 = 180°, 3 = 270°
uniform bool PrepareBloom = false; // disables some effects for rendering bloom textures
@@ -126,7 +121,7 @@ VS_OUTPUT vs_main(VS_INPUT Input)
VS_OUTPUT Output = (VS_OUTPUT)0;
float2 shadowUVOffset = ShadowUVOffset;
- shadowUVOffset = xor(OrientationSwapXY, RotationSwapXY)
+ shadowUVOffset = SwapXY
? shadowUVOffset.yx
: shadowUVOffset.xy;
@@ -227,7 +222,7 @@ float GetSpotAddend(float2 coord, float amount)
// normalized screen canvas ratio
float2 CanvasRatio = PrepareVector
? float2(1.0f, QuadDims.y / QuadDims.x)
- : float2(1.0f, xor(OrientationSwapXY, RotationSwapXY)
+ : float2(1.0f, SwapXY
? QuadDims.x / QuadDims.y
: QuadDims.y / QuadDims.x);
@@ -240,7 +235,7 @@ float GetSpotAddend(float2 coord, float amount)
: RotationType == 3 // 270°
? float2(0.25f, 0.25f)
: float2(-0.25f, 0.25f)
- : OrientationSwapXY
+ : SwapXY
? float2(0.25f, 0.25f)
: float2(-0.25f, 0.25f);
@@ -272,7 +267,7 @@ float GetRoundCornerFactor(float2 coord, float radiusAmount, float smoothAmount)
float2 CanvasDims = PrepareVector
? ScreenDims
- : xor(OrientationSwapXY, RotationSwapXY)
+ : SwapXY
? QuadDims.yx / SourceRect
: QuadDims.xy / SourceRect;
@@ -375,9 +370,7 @@ float4 ps_main(PS_INPUT Input) : COLOR
float2 ScreenTexelDims = 1.0f / ScreenDims;
float2 SourceTexelDims = 1.0f / SourceDims;
- float2 HalfSourceRect = PrepareVector
- ? float2(0.5f, 0.5f)
- : SourceRect * 0.5f;
+ float2 HalfSourceRect = SourceRect * 0.5f;
float2 ScreenCoord = Input.ScreenCoord / ScreenDims;
ScreenCoord = GetCoords(ScreenCoord, float2(0.5f, 0.5f), CurvatureAmount * 0.25f); // reduced amount
@@ -406,34 +399,34 @@ float4 ps_main(PS_INPUT Input) : COLOR
if (!PrepareBloom)
{
float2 shadowDims = ShadowDims;
- shadowDims = xor(OrientationSwapXY, RotationSwapXY)
+ shadowDims = SwapXY
? shadowDims.yx
: shadowDims.xy;
float2 shadowUV = ShadowUV;
- // shadowUV = xor(OrientationSwapXY, RotationSwapXY)
+ // shadowUV = SwapXY
// ? shadowUV.yx
// : shadowUV.xy;
float2 screenCoord = ShadowTileMode == 0 ? ScreenCoord : BaseCoord;
- screenCoord = xor(OrientationSwapXY, RotationSwapXY)
+ screenCoord = SwapXY
? screenCoord.yx
: screenCoord.xy;
float2 shadowCount = ShadowCount;
- shadowCount = xor(OrientationSwapXY, RotationSwapXY)
+ shadowCount = SwapXY
? shadowCount.yx
: shadowCount.xy;
float2 shadowTile = ((ShadowTileMode == 0 ? ScreenTexelDims : SourceTexelDims) * shadowCount);
- shadowTile = xor(OrientationSwapXY, RotationSwapXY)
+ shadowTile = SwapXY
? shadowTile.yx
: shadowTile.xy;
float2 ShadowFrac = frac(screenCoord / shadowTile);
float2 ShadowCoord = (ShadowFrac * shadowUV);
ShadowCoord += 0.5f / shadowDims; // half texel offset
- // ShadowCoord = xor(OrientationSwapXY, RotationSwapXY)
+ // ShadowCoord = SwapXY
// ? ShadowCoord.yx
// : ShadowCoord.xy;
diff --git a/hlsl/distortion.fx b/hlsl/distortion.fx
index f9dd51b697b..63d35789393 100644
--- a/hlsl/distortion.fx
+++ b/hlsl/distortion.fx
@@ -59,11 +59,6 @@ static const float GelfondSchneider = 2.6651442f; // 2^sqrt(2) (Gelfond-Schneide
// Functions
//-----------------------------------------------------------------------------
-bool xor(bool a, bool b)
-{
- return (a || b) && !(a && b);
-}
-
// www.stackoverflow.com/questions/5149544/can-i-generate-a-random-number-inside-a-pixel-shader/
float random(float2 seed)
{
@@ -122,8 +117,6 @@ uniform float SmoothBorderAmount = 0.0f;
uniform float VignettingAmount = 0.0f;
uniform float ReflectionAmount = 0.0f;
-uniform bool OrientationSwapXY = false; // false landscape, true portrait for default screen orientation
-uniform bool RotationSwapXY = false; // swapped default screen orientation due to screen rotation
uniform int RotationType = 0; // 0 = 0°, 1 = 90°, 2 = 180°, 3 = 270°
float2 GetRatioCorrection()
diff --git a/hlsl/focus.fx b/hlsl/focus.fx
index 6da8ab928a2..c5e5262fedd 100644
--- a/hlsl/focus.fx
+++ b/hlsl/focus.fx
@@ -46,15 +46,6 @@ struct PS_INPUT
};
//-----------------------------------------------------------------------------
-// Functions
-//-----------------------------------------------------------------------------
-
-bool xor(bool a, bool b)
-{
- return (a || b) && !(a && b);
-}
-
-//-----------------------------------------------------------------------------
// Defocus Vertex Shader
//-----------------------------------------------------------------------------
@@ -98,18 +89,19 @@ float2 Coord8Offset = float2( 1.00f, -0.25f);
uniform float2 Defocus = float2(0.0f, 0.0f);
-uniform bool OrientationSwapXY = false; // false landscape, true portrait for default screen orientation
-uniform bool RotationSwapXY = false; // swapped default screen orientation due to screen rotation
+uniform bool SwapXY = false;
float4 ps_main(PS_INPUT Input) : COLOR
{
float2 QuadRatio =
- float2(1.0f, xor(OrientationSwapXY, RotationSwapXY)
+ float2(1.0f, SwapXY
? QuadDims.y / QuadDims.x
: QuadDims.x / QuadDims.y);
// imaginary texel dimensions independed from quad dimensions, but dependend on quad ratio
- float2 DefocusTexelDims = (1.0f / 1024.0) * SourceRect * QuadRatio * Defocus;
+ float2 TexelDims = (1.0f / 1024.0) * SourceRect * QuadRatio;
+
+ float2 DefocusTexelDims = Defocus * TexelDims;
float4 d = tex2D(DiffuseSampler, Input.TexCoord);
float3 d1 = tex2D(DiffuseSampler, Input.TexCoord + Coord1Offset * DefocusTexelDims).rgb;
diff --git a/hlsl/post.fx b/hlsl/post.fx
index 2b175dedf90..4415298a2f8 100644
--- a/hlsl/post.fx
+++ b/hlsl/post.fx
@@ -67,15 +67,6 @@ struct PS_INPUT
static const float PI = 3.1415927f;
//-----------------------------------------------------------------------------
-// Functions
-//-----------------------------------------------------------------------------
-
-bool xor(bool a, bool b)
-{
- return (a || b) && !(a && b);
-}
-
-//-----------------------------------------------------------------------------
// Scanline & Shadowmask Vertex Shader
//-----------------------------------------------------------------------------
@@ -87,8 +78,7 @@ uniform float2 TargetDims; // size of the target surface
uniform float2 ShadowDims = float2(32.0f, 32.0f); // size of the shadow texture (extended to power-of-two size)
uniform float2 ShadowUVOffset = float2(0.0f, 0.0f);
-uniform bool OrientationSwapXY = false; // false landscape, true portrait for default screen orientation
-uniform bool RotationSwapXY = false; // swapped default screen orientation due to screen rotation
+uniform bool SwapXY = false;
uniform bool PrepareBloom = false; // disables some effects for rendering bloom textures
uniform bool PrepareVector = false;
@@ -98,7 +88,7 @@ VS_OUTPUT vs_main(VS_INPUT Input)
VS_OUTPUT Output = (VS_OUTPUT)0;
float2 shadowUVOffset = ShadowUVOffset;
- shadowUVOffset = xor(OrientationSwapXY, RotationSwapXY)
+ shadowUVOffset = SwapXY
? shadowUVOffset.yx
: shadowUVOffset.xy;
@@ -170,9 +160,7 @@ float4 ps_main(PS_INPUT Input) : COLOR
float2 ScreenTexelDims = 1.0f / ScreenDims;
float2 SourceTexelDims = 1.0f / SourceDims;
- float2 HalfSourceRect = PrepareVector
- ? float2(0.5f, 0.5f)
- : SourceRect * 0.5f;
+ float2 HalfSourceRect = SourceRect * 0.5f;
float2 ScreenCoord = Input.ScreenCoord / ScreenDims;
float2 BaseCoord = GetAdjustedCoords(Input.TexCoord, HalfSourceRect);
@@ -190,34 +178,34 @@ float4 ps_main(PS_INPUT Input) : COLOR
if (!PrepareBloom)
{
float2 shadowDims = ShadowDims;
- shadowDims = xor(OrientationSwapXY, RotationSwapXY)
+ shadowDims = SwapXY
? shadowDims.yx
: shadowDims.xy;
float2 shadowUV = ShadowUV;
- // shadowUV = xor(OrientationSwapXY, RotationSwapXY)
+ // shadowUV = SwapXY
// ? shadowUV.yx
// : shadowUV.xy;
float2 screenCoord = ShadowTileMode == 0 ? ScreenCoord : BaseCoord;
- screenCoord = xor(OrientationSwapXY, RotationSwapXY)
+ screenCoord = SwapXY
? screenCoord.yx
: screenCoord.xy;
float2 shadowCount = ShadowCount;
- shadowCount = xor(OrientationSwapXY, RotationSwapXY)
+ shadowCount = SwapXY
? shadowCount.yx
: shadowCount.xy;
float2 shadowTile = ((ShadowTileMode == 0 ? ScreenTexelDims : SourceTexelDims) * shadowCount);
- shadowTile = xor(OrientationSwapXY, RotationSwapXY)
+ shadowTile = SwapXY
? shadowTile.yx
: shadowTile.xy;
float2 ShadowFrac = frac(screenCoord / shadowTile);
float2 ShadowCoord = (ShadowFrac * shadowUV);
ShadowCoord += 0.5f / shadowDims; // half texel offset
- // ShadowCoord = xor(OrientationSwapXY, RotationSwapXY)
+ // ShadowCoord = SwapXY
// ? ShadowCoord.yx
// : ShadowCoord.xy;
diff --git a/hlsl/prescale.fx b/hlsl/prescale.fx
index 33b2a4efb06..846c02577ce 100644
--- a/hlsl/prescale.fx
+++ b/hlsl/prescale.fx
@@ -49,6 +49,7 @@ struct PS_INPUT
//-----------------------------------------------------------------------------
uniform float2 ScreenDims;
+uniform float2 TargetDims;
VS_OUTPUT vs_main(VS_INPUT Input)
{
@@ -56,11 +57,12 @@ VS_OUTPUT vs_main(VS_INPUT Input)
Output.Position = float4(Input.Position.xyz, 1.0f);
Output.Position.xy /= ScreenDims;
- Output.Position.y = 1.0f - Output.Position.y;
- Output.Position.xy -= 0.5f;
- Output.Position *= float4(2.0f, 2.0f, 1.0f, 1.0f);
+ 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 + 0.5f / ScreenDims;
+ Output.TexCoord = Input.TexCoord;
+ Output.TexCoord += 0.5f / TargetDims; // half texel offset correction (DX9)
return Output;
}
diff --git a/src/osd/modules/render/d3d/d3dhlsl.cpp b/src/osd/modules/render/d3d/d3dhlsl.cpp
index a7333a14d0c..c135019ca23 100644
--- a/src/osd/modules/render/d3d/d3dhlsl.cpp
+++ b/src/osd/modules/render/d3d/d3dhlsl.cpp
@@ -940,9 +940,33 @@ int shaders::create_resources(bool reset)
return 1;
}
- yiq_encode_effect->add_uniform("ScreenDims", uniform::UT_VEC2, uniform::CU_SCREEN_DIMS);
- yiq_encode_effect->add_uniform("SourceDims", uniform::UT_VEC2, uniform::CU_SOURCE_DIMS);
- yiq_encode_effect->add_uniform("SourceRect", uniform::UT_VEC2, uniform::CU_SOURCE_RECT);
+ effect *effects[14] = {
+ default_effect,
+ post_effect,
+ distortion_effect,
+ prescale_effect,
+ phosphor_effect,
+ focus_effect,
+ deconverge_effect,
+ color_effect,
+ yiq_encode_effect,
+ yiq_decode_effect,
+ color_effect,
+ bloom_effect,
+ downsample_effect,
+ vector_effect
+ };
+
+ for (int i = 0; i < 14; 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);
+ effects[i]->add_uniform("SwapXY", uniform::UT_BOOL, uniform::CU_SWAP_XY);
+ }
+
yiq_encode_effect->add_uniform("CCValue", uniform::UT_FLOAT, uniform::CU_NTSC_CCFREQ);
yiq_encode_effect->add_uniform("AValue", uniform::UT_FLOAT, uniform::CU_NTSC_A);
yiq_encode_effect->add_uniform("BValue", uniform::UT_FLOAT, uniform::CU_NTSC_B);
@@ -952,10 +976,7 @@ int shaders::create_resources(bool reset)
yiq_encode_effect->add_uniform("IFreqResponse", uniform::UT_FLOAT, uniform::CU_NTSC_IFREQ);
yiq_encode_effect->add_uniform("QFreqResponse", uniform::UT_FLOAT, uniform::CU_NTSC_QFREQ);
yiq_encode_effect->add_uniform("ScanTime", uniform::UT_FLOAT, uniform::CU_NTSC_HTIME);
-
- yiq_decode_effect->add_uniform("ScreenDims", uniform::UT_VEC2, uniform::CU_SCREEN_DIMS);
- yiq_decode_effect->add_uniform("SourceDims", uniform::UT_VEC2, uniform::CU_SOURCE_DIMS);
- yiq_decode_effect->add_uniform("SourceRect", uniform::UT_VEC2, uniform::CU_SOURCE_RECT);
+
yiq_decode_effect->add_uniform("CCValue", uniform::UT_FLOAT, uniform::CU_NTSC_CCFREQ);
yiq_decode_effect->add_uniform("AValue", uniform::UT_FLOAT, uniform::CU_NTSC_A);
yiq_decode_effect->add_uniform("BValue", uniform::UT_FLOAT, uniform::CU_NTSC_B);
@@ -967,9 +988,6 @@ int shaders::create_resources(bool reset)
yiq_decode_effect->add_uniform("QFreqResponse", uniform::UT_FLOAT, uniform::CU_NTSC_QFREQ);
yiq_decode_effect->add_uniform("ScanTime", uniform::UT_FLOAT, uniform::CU_NTSC_HTIME);
- color_effect->add_uniform("ScreenDims", uniform::UT_VEC2, uniform::CU_SCREEN_DIMS);
- color_effect->add_uniform("SourceDims", uniform::UT_VEC2, uniform::CU_SOURCE_DIMS);
-
color_effect->add_uniform("RedRatios", uniform::UT_VEC3, uniform::CU_COLOR_RED_RATIOS);
color_effect->add_uniform("GrnRatios", uniform::UT_VEC3, uniform::CU_COLOR_GRN_RATIOS);
color_effect->add_uniform("BluRatios", uniform::UT_VEC3, uniform::CU_COLOR_BLU_RATIOS);
@@ -977,39 +995,15 @@ int shaders::create_resources(bool reset)
color_effect->add_uniform("Scale", uniform::UT_VEC3, uniform::CU_COLOR_SCALE);
color_effect->add_uniform("Saturation", uniform::UT_FLOAT, uniform::CU_COLOR_SATURATION);
- prescale_effect->add_uniform("ScreenDims", uniform::UT_VEC2, uniform::CU_SCREEN_DIMS);
-
- deconverge_effect->add_uniform("ScreenDims", uniform::UT_VEC2, uniform::CU_SCREEN_DIMS);
- deconverge_effect->add_uniform("SourceDims", uniform::UT_VEC2, uniform::CU_SOURCE_DIMS);
- deconverge_effect->add_uniform("SourceRect", uniform::UT_VEC2, uniform::CU_SOURCE_RECT);
deconverge_effect->add_uniform("ConvergeX", uniform::UT_VEC3, uniform::CU_CONVERGE_LINEAR_X);
deconverge_effect->add_uniform("ConvergeY", uniform::UT_VEC3, uniform::CU_CONVERGE_LINEAR_Y);
deconverge_effect->add_uniform("RadialConvergeX", uniform::UT_VEC3, uniform::CU_CONVERGE_RADIAL_X);
deconverge_effect->add_uniform("RadialConvergeY", uniform::UT_VEC3, uniform::CU_CONVERGE_RADIAL_Y);
- focus_effect->add_uniform("ScreenDims", uniform::UT_VEC2, uniform::CU_SCREEN_DIMS);
- focus_effect->add_uniform("TargetDims", uniform::UT_VEC2, uniform::CU_TARGET_DIMS);
- focus_effect->add_uniform("SourceRect", uniform::UT_VEC2, uniform::CU_SOURCE_RECT);
- focus_effect->add_uniform("QuadDims", uniform::UT_VEC2, uniform::CU_QUAD_DIMS);
focus_effect->add_uniform("Defocus", uniform::UT_VEC2, uniform::CU_FOCUS_SIZE);
- focus_effect->add_uniform("OrientationSwapXY", uniform::UT_BOOL, uniform::CU_ORIENTATION_SWAP);
- focus_effect->add_uniform("RotationSwapXY", uniform::UT_BOOL, uniform::CU_ROTATION_SWAP);
-
- phosphor_effect->add_uniform("ScreenDims", uniform::UT_VEC2, uniform::CU_SCREEN_DIMS);
- phosphor_effect->add_uniform("TargetDims", uniform::UT_VEC2, uniform::CU_TARGET_DIMS);
+
phosphor_effect->add_uniform("Phosphor", uniform::UT_VEC3, uniform::CU_PHOSPHOR_LIFE);
- downsample_effect->add_uniform("ScreenDims", uniform::UT_VEC2, uniform::CU_SCREEN_DIMS);
-
- bloom_effect->add_uniform("ScreenDims", uniform::UT_VEC2, uniform::CU_SCREEN_DIMS);
- bloom_effect->add_uniform("TargetDims", uniform::UT_VEC2, uniform::CU_TARGET_DIMS);
-
- post_effect->add_uniform("SourceDims", uniform::UT_VEC2, uniform::CU_SOURCE_DIMS);
- post_effect->add_uniform("SourceRect", uniform::UT_VEC2, uniform::CU_SOURCE_RECT);
- post_effect->add_uniform("ScreenDims", uniform::UT_VEC2, uniform::CU_SCREEN_DIMS);
- post_effect->add_uniform("TargetDims", uniform::UT_VEC2, uniform::CU_TARGET_DIMS);
- post_effect->add_uniform("QuadDims", uniform::UT_VEC2, uniform::CU_QUAD_DIMS); // backward compatibility
-
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
@@ -1030,29 +1024,16 @@ int shaders::create_resources(bool reset)
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("OrientationSwapXY", uniform::UT_BOOL, uniform::CU_ORIENTATION_SWAP);
- post_effect->add_uniform("RotationSwapXY", uniform::UT_BOOL, uniform::CU_ROTATION_SWAP);
post_effect->add_uniform("RotationType", uniform::UT_INT, uniform::CU_ROTATION_TYPE);
- distortion_effect->add_uniform("ScreenDims", uniform::UT_VEC2, uniform::CU_SCREEN_DIMS);
- distortion_effect->add_uniform("TargetDims", uniform::UT_VEC2, uniform::CU_TARGET_DIMS);
- distortion_effect->add_uniform("QuadDims", uniform::UT_VEC2, uniform::CU_QUAD_DIMS);
-
distortion_effect->add_uniform("VignettingAmount", uniform::UT_FLOAT, uniform::CU_POST_VIGNETTING);
distortion_effect->add_uniform("CurvatureAmount", uniform::UT_FLOAT, uniform::CU_POST_CURVATURE);
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("OrientationSwapXY", uniform::UT_BOOL, uniform::CU_ORIENTATION_SWAP);
- distortion_effect->add_uniform("RotationSwapXY", uniform::UT_BOOL, uniform::CU_ROTATION_SWAP);
distortion_effect->add_uniform("RotationType", uniform::UT_INT, uniform::CU_ROTATION_TYPE);
- vector_effect->add_uniform("ScreenDims", uniform::UT_VEC2, uniform::CU_SCREEN_DIMS);
-
- default_effect->add_uniform("ScreenDims", uniform::UT_VEC2, uniform::CU_SCREEN_DIMS);
- default_effect->add_uniform("TargetDims", uniform::UT_VEC2, uniform::CU_TARGET_DIMS);
-
initialized = true;
return 0;
@@ -1359,6 +1340,15 @@ int shaders::deconverge_pass(render_target *rt, int source_index, poly_info *pol
{
int next_index = source_index;
+ // skip deconverge if no influencing settings
+ if (options->converge_x[0] == 0.0f && options->converge_x[1] == 0.0f && options->converge_x[2] == 0.0f &&
+ options->converge_y[0] == 0.0f && options->converge_y[1] == 0.0f && options->converge_y[2] == 0.0f &&
+ options->radial_converge_x[0] == 0.0f && options->radial_converge_x[1] == 0.0f && options->radial_converge_x[2] == 0.0f &&
+ options->radial_converge_y[0] == 0.0f && options->radial_converge_y[1] == 0.0f && options->radial_converge_y[2] == 0.0f)
+ {
+ return next_index;
+ }
+
curr_effect = deconverge_effect;
curr_effect->update_uniforms();
curr_effect->set_texture("Diffuse", rt->prescale_texture[next_index]);
@@ -1373,11 +1363,8 @@ int shaders::defocus_pass(render_target *rt, int source_index, poly_info *poly,
{
int next_index = source_index;
- float defocus_x = options->defocus[0];
- float defocus_y = options->defocus[1];
-
// skip defocus if no influencing settings
- if (defocus_x == 0.0f && defocus_y == 0.0f)
+ if (options->defocus[0] == 0.0f && options->defocus[1] == 0.0f)
{
return next_index;
}
@@ -1396,6 +1383,12 @@ int shaders::phosphor_pass(render_target *rt, cache_target *ct, int source_index
{
int next_index = source_index;
+ // skip phosphor if no influencing settings
+ if (options->phosphor[0] == 0.0f && options->defocus[1] == 0.0f && options->defocus[2] == 0.0f)
+ {
+ return next_index;
+ }
+
curr_effect = phosphor_effect;
curr_effect->update_uniforms();
curr_effect->set_texture("Diffuse", rt->prescale_texture[next_index]);
@@ -1421,8 +1414,6 @@ int shaders::post_pass(render_target *rt, int source_index, poly_info *poly, int
{
int next_index = source_index;
- texture_info *texture = poly->get_texture();
-
bool prepare_vector =
machine->first_screen()->screen_type() == SCREEN_TYPE_VECTOR;
@@ -1459,7 +1450,7 @@ int shaders::post_pass(render_target *rt, int source_index, poly_info *poly, int
curr_effect->set_vector("BackColor", 3, back_color);
curr_effect->set_vector("ScreenScale", 2, screen_scale);
curr_effect->set_vector("ScreenOffset", 2, screen_offset);
- curr_effect->set_float("ScanlineOffset", texture->get_cur_frame() == 0 ? 0.0f : options->scanline_offset);
+ curr_effect->set_float("ScanlineOffset", curr_texture->get_cur_frame() == 0 ? 0.0f : options->scanline_offset);
curr_effect->set_bool("PrepareBloom", prepare_bloom);
curr_effect->set_bool("PrepareVector", prepare_vector);
@@ -1473,16 +1464,15 @@ int shaders::downsample_pass(render_target *rt, int source_index, poly_info *pol
{
int next_index = source_index;
- bool prepare_vector =
- machine->first_screen()->screen_type() == SCREEN_TYPE_VECTOR;
- float bloom_rescale = options->bloom_scale;
-
// skip downsample if no influencing settings
- if (bloom_rescale == 0.0f)
+ if (options->bloom_scale == 0.0f)
{
return next_index;
}
+ bool prepare_vector =
+ machine->first_screen()->screen_type() == SCREEN_TYPE_VECTOR;
+
curr_effect = downsample_effect;
curr_effect->update_uniforms();
curr_effect->set_bool("PrepareVector", prepare_vector);
@@ -1519,10 +1509,8 @@ int shaders::bloom_pass(render_target *rt, int source_index, poly_info *poly, in
{
int next_index = source_index;
- float bloom_rescale = options->bloom_scale;
-
// skip bloom if no influencing settings
- if (bloom_rescale == 0.0f)
+ if (options->bloom_scale == 0.0f)
{
return next_index;
}
@@ -1558,7 +1546,7 @@ int shaders::bloom_pass(render_target *rt, int source_index, poly_info *poly, in
curr_effect->set_vector("LevelASize", 2, bloom_dims[10]);
curr_effect->set_int("BloomBlendMode", options->bloom_blend_mode);
- curr_effect->set_float("BloomScale", bloom_rescale);
+ curr_effect->set_float("BloomScale", options->bloom_scale);
curr_effect->set_vector("BloomOverdrive", 3, options->bloom_overdrive);
curr_effect->set_texture("DiffuseA", rt->prescale_texture[next_index]);
@@ -1755,7 +1743,7 @@ void shaders::render_quad(poly_info *poly, int vertnum)
// render on screen
d3d->set_wrap(D3DTADDRESS_MIRROR);
next_index = screen_pass(rt, next_index, poly, vertnum);
- d3d->set_wrap(PRIMFLAG_GET_TEXWRAP(poly->get_texture()->get_flags()) ? D3DTADDRESS_WRAP : D3DTADDRESS_CLAMP);
+ d3d->set_wrap(PRIMFLAG_GET_TEXWRAP(curr_texture->get_flags()) ? D3DTADDRESS_WRAP : D3DTADDRESS_CLAMP);
curr_texture->increment_frame_count();
curr_texture->mask_frame_count(options->yiq_phase_count);
@@ -2961,37 +2949,67 @@ void uniform::update()
}
case CU_SOURCE_DIMS:
{
- vec2f sourcedims = shadersys->curr_texture->get_rawdims();
- m_shader->set_vector("SourceDims", 2, &sourcedims.c.x);
+ if (shadersys->curr_texture != NULL)
+ {
+ vec2f sourcedims = shadersys->curr_texture->get_rawdims();
+ m_shader->set_vector("SourceDims", 2, &sourcedims.c.x);
+ }
+
break;
}
case CU_SOURCE_RECT:
- {
- vec2f delta = shadersys->curr_texture->get_uvstop() - shadersys->curr_texture->get_uvstart();
- m_shader->set_vector("SourceRect", 2, &delta.c.x);
+ {
+ bool prepare_vector =
+ d3d->window().machine().first_screen()->screen_type() == SCREEN_TYPE_VECTOR;
+
+ if (prepare_vector)
+ {
+ float delta[2] = { 1.0f, 1.0f };
+ m_shader->set_vector("SourceRect", 2, delta);
+ break;
+ }
+
+ if (shadersys->curr_texture != NULL)
+ {
+ vec2f delta = shadersys->curr_texture->get_uvstop() - shadersys->curr_texture->get_uvstart();
+ m_shader->set_vector("SourceRect", 2, &delta.c.x);
+ break;
+ }
+
break;
}
case CU_TARGET_DIMS:
{
- if (shadersys->curr_render_target == NULL)
+ if (shadersys->curr_render_target != NULL)
{
- float targetdims[2] = { 0.0f, 0.0f };
- m_shader->set_vector("TargetDims", 2, targetdims);
- }
- else
- {
- float targetdims[2] = { static_cast<float>(shadersys->curr_render_target->target_width), static_cast<float>(shadersys->curr_render_target->target_height) };
+ float targetdims[2] = {
+ static_cast<float>(shadersys->curr_render_target->target_width),
+ static_cast<float>(shadersys->curr_render_target->target_height) };
m_shader->set_vector("TargetDims", 2, targetdims);
}
break;
}
case CU_QUAD_DIMS:
{
- float quaddims[2] = { shadersys->curr_poly->get_prim_width(), shadersys->curr_poly->get_prim_height() };
- m_shader->set_vector("QuadDims", 2, quaddims);
+ if (shadersys->curr_poly != NULL)
+ {
+ float quaddims[2] = {
+ shadersys->curr_poly->get_prim_width(),
+ shadersys->curr_poly->get_prim_height() };
+ m_shader->set_vector("QuadDims", 2, quaddims);
+ }
break;
}
+ case CU_SWAP_XY:
+ {
+ bool orientation_swap_xy =
+ (d3d->window().machine().system().flags & ORIENTATION_SWAP_XY) == ORIENTATION_SWAP_XY;
+ bool rotation_swap_xy =
+ (d3d->window().target()->orientation() & ROT90) == ROT90 ||
+ (d3d->window().target()->orientation() & ROT270) == ROT270;
+ m_shader->set_bool("SwapXY", orientation_swap_xy ^ rotation_swap_xy);
+ }
case CU_ORIENTATION_SWAP:
{
bool orientation_swap_xy =
diff --git a/src/osd/modules/render/d3d/d3dhlsl.h b/src/osd/modules/render/d3d/d3dhlsl.h
index b8bb5ac6f89..709253c7004 100644
--- a/src/osd/modules/render/d3d/d3dhlsl.h
+++ b/src/osd/modules/render/d3d/d3dhlsl.h
@@ -50,6 +50,7 @@ public:
CU_TARGET_DIMS,
CU_QUAD_DIMS,
+ CU_SWAP_XY,
CU_ORIENTATION_SWAP,
CU_ROTATION_SWAP,
CU_ROTATION_TYPE,
diff --git a/src/osd/modules/render/drawd3d.cpp b/src/osd/modules/render/drawd3d.cpp
index ee99588ebdf..4f3d9e2bf56 100644
--- a/src/osd/modules/render/drawd3d.cpp
+++ b/src/osd/modules/render/drawd3d.cpp
@@ -2734,20 +2734,6 @@ void texture_info::prescale()
cache_target::~cache_target()
{
- for (int index = 0; index < 11; index++)
- {
- if (bloom_texture[index] != NULL)
- {
- (*d3dintf->texture.release)(bloom_texture[index]);
- bloom_texture[index] = NULL;
- }
- if (bloom_target[index] != NULL)
- {
- (*d3dintf->surface.release)(bloom_target[index]);
- bloom_target[index] = NULL;
- }
- }
-
if (last_texture != NULL)
{
(*d3dintf->texture.release)(last_texture);
@@ -2767,25 +2753,6 @@ cache_target::~cache_target()
bool cache_target::init(renderer *d3d, base *d3dintf, int width, int height, int prescale_x, int prescale_y)
{
- int bloom_index = 0;
- int bloom_size = (width < height) ? width : height;
- int bloom_width = width;
- int bloom_height = height;
- for (; bloom_size >= 2 && bloom_index < 11; bloom_size >>= 1)
- {
- bloom_width >>= 1;
- bloom_height >>= 1;
-
- HRESULT result = (*d3dintf->device.create_texture)(d3d->get_device(), bloom_width, bloom_height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &bloom_texture[bloom_index]);
- if (result != D3D_OK)
- {
- return false;
- }
- (*d3dintf->texture.get_surface_level)(bloom_texture[bloom_index], 0, &bloom_target[bloom_index]);
-
- bloom_index++;
- }
-
HRESULT result = (*d3dintf->device.create_texture)(d3d->get_device(), width * prescale_x, height * prescale_y, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &last_texture);
if (result != D3D_OK)
{
diff --git a/src/osd/modules/render/drawd3d.h b/src/osd/modules/render/drawd3d.h
index ab5385914b5..906bd7711b8 100644
--- a/src/osd/modules/render/drawd3d.h
+++ b/src/osd/modules/render/drawd3d.h
@@ -53,9 +53,6 @@ public:
cache_target *next;
cache_target *prev;
-
- surface *bloom_target[11];
- texture *bloom_texture[11];
};
/* render_target is the information about a Direct3D render target chain */