summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/PixelShaderGen.cpp
diff options
context:
space:
mode:
authordegasus <wickmarkus@web.de>2014-03-17 08:57:54 +0100
committerdegasus <wickmarkus@web.de>2014-05-05 17:06:36 +0200
commit3e14bf511f2b367cc85f2b68d44de503341c704b (patch)
tree196cae45d6235ad8ed514ee957d7b243135c7b59 /Source/Core/VideoCommon/PixelShaderGen.cpp
parent25b8edd2a6c18b60586bbb39d539b939c1dc8515 (diff)
ShaderGen/D3D: inline centroid
Diffstat (limited to 'Source/Core/VideoCommon/PixelShaderGen.cpp')
-rw-r--r--Source/Core/VideoCommon/PixelShaderGen.cpp21
1 files changed, 13 insertions, 8 deletions
diff --git a/Source/Core/VideoCommon/PixelShaderGen.cpp b/Source/Core/VideoCommon/PixelShaderGen.cpp
index 6211066f4d..b08124faa0 100644
--- a/Source/Core/VideoCommon/PixelShaderGen.cpp
+++ b/Source/Core/VideoCommon/PixelShaderGen.cpp
@@ -253,6 +253,14 @@ static inline void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_T
if (per_pixel_depth)
out.Write("#define depth gl_FragDepth\n");
+ // We use the flag "centroid" to fix some MSAA rendering bugs. With MSAA, the
+ // pixel shader will be executed for each pixel which has at least one passed sample.
+ // So there may be rendered pixels where the center of the pixel isn't in the primitive.
+ // As the pixel shader usually renders at the center of the pixel, this position may be
+ // outside the primitive. This will lead to sampling outside the texture, sign changes, ...
+ // As a workaround, we interpolate at the centroid of the coveraged pixel, which
+ // is always inside the primitive.
+ // Without MSAA, this flag is defined to have no effect.
out.Write("centroid in float4 colors_02;\n");
out.Write("centroid in float4 colors_12;\n");
@@ -303,18 +311,15 @@ static inline void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_T
dstAlphaMode == DSTALPHA_DUAL_SOURCE_BLEND ? "\n out float4 ocol1 : SV_Target1," : "",
per_pixel_depth ? "\n out float depth : SV_Depth," : "");
- // Use centroid sampling to make MSAA work properly
- const char* optCentroid = "centroid";
-
- out.Write(" in %s float4 colors_0 : COLOR0,\n", optCentroid);
- out.Write(" in %s float4 colors_1 : COLOR1", optCentroid);
+ out.Write(" in centroid float4 colors_0 : COLOR0,\n");
+ out.Write(" in centroid float4 colors_1 : COLOR1");
// compute window position if needed because binding semantic WPOS is not widely supported
for (unsigned int i = 0; i < numTexgen; ++i)
- out.Write(",\n in %s float3 uv%d : TEXCOORD%d", optCentroid, i, i);
- out.Write(",\n in %s float4 clipPos : TEXCOORD%d", optCentroid, numTexgen);
+ out.Write(",\n in centroid float3 uv%d : TEXCOORD%d", i, i);
+ out.Write(",\n in centroid float4 clipPos : TEXCOORD%d", numTexgen);
if (g_ActiveConfig.bEnablePixelLighting)
- out.Write(",\n in %s float4 Normal : TEXCOORD%d", optCentroid, numTexgen + 1);
+ out.Write(",\n in centroid float4 Normal : TEXCOORD%d", numTexgen + 1);
out.Write(" ) {\n");
}