diff options
Diffstat (limited to 'Source/Core/VideoCommon/PixelShaderGen.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/PixelShaderGen.cpp | 78 |
1 files changed, 47 insertions, 31 deletions
diff --git a/Source/Core/VideoCommon/PixelShaderGen.cpp b/Source/Core/VideoCommon/PixelShaderGen.cpp index c0b45fdfda..71e534df0a 100644 --- a/Source/Core/VideoCommon/PixelShaderGen.cpp +++ b/Source/Core/VideoCommon/PixelShaderGen.cpp @@ -16,6 +16,7 @@ #include "VideoCommon/LightingShaderGen.h" #include "VideoCommon/NativeVertexFormat.h" #include "VideoCommon/PixelShaderGen.h" +#include "VideoCommon/VertexShaderGen.h" #include "VideoCommon/VideoConfig.h" #include "VideoCommon/XFMemory.h" // for texture projection mode @@ -206,7 +207,7 @@ static inline void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_T { // Declare samplers for (int i = 0; i < 8; ++i) - out.Write("SAMPLER_BINDING(%d) uniform sampler2D samp%d;\n", i, i); + out.Write("SAMPLER_BINDING(%d) uniform sampler2DArray samp%d;\n", i, i); } else // D3D { @@ -253,17 +254,8 @@ static inline void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_T { out.Write("cbuffer VSBlock : register(b1) {\n"); } - out.Write( - "\tfloat4 " I_POSNORMALMATRIX"[6];\n" - "\tfloat4 " I_PROJECTION"[4];\n" - "\tint4 " I_MATERIALS"[4];\n" - "\tLight " I_LIGHTS"[8];\n" - "\tfloat4 " I_TEXMATRICES"[24];\n" - "\tfloat4 " I_TRANSFORMMATRICES"[64];\n" - "\tfloat4 " I_NORMALMATRICES"[32];\n" - "\tfloat4 " I_POSTTRANSFORMMATRICES"[64];\n" - "\tfloat4 " I_DEPTHPARAMS";\n" - "};\n"); + out.Write(s_shader_uniforms); + out.Write("};\n"); } if (g_ActiveConfig.backend_info.bSupportsBBox) @@ -275,6 +267,8 @@ static inline void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_T ); } + GenerateVSOutputStruct(out, ApiType); + const bool forced_early_z = g_ActiveConfig.backend_info.bSupportsEarlyZ && bpmem.UseEarlyDepthTest() && (g_ActiveConfig.bFastDepthCalc || bpmem.alpha_test.TestResult() == AlphaTest::UNDETERMINED); const bool per_pixel_depth = (bpmem.ztex2.op != ZTEXTURE_DISABLE && bpmem.UseLateDepthTest()) || (!g_ActiveConfig.bFastDepthCalc && bpmem.zmode.testenable && !forced_early_z); @@ -325,22 +319,52 @@ static inline void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_T // 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"); - - // compute window position if needed because binding semantic WPOS is not widely supported - // Let's set up attributes - for (unsigned int i = 0; i < numTexgen; ++i) + uid_data->stereo = g_ActiveConfig.iStereoMode > 0; + if (g_ActiveConfig.iStereoMode > 0) { - out.Write("centroid in float3 uv%d;\n", i); + out.Write("centroid in VS_OUTPUT f;\n"); + out.Write("flat in int layer;\n"); } - out.Write("centroid in float4 clipPos;\n"); - if (g_ActiveConfig.bEnablePixelLighting) + else { - out.Write("centroid in float4 Normal;\n"); + out.Write("centroid in float4 colors_02;\n"); + out.Write("centroid in float4 colors_12;\n"); + + // compute window position if needed because binding semantic WPOS is not widely supported + // Let's set up attributes + for (unsigned int i = 0; i < numTexgen; ++i) + { + out.Write("centroid in float3 uv%d;\n", i); + } + out.Write("centroid in float4 clipPos;\n"); + if (g_ActiveConfig.bEnablePixelLighting) + { + out.Write("centroid in float4 Normal;\n"); + } } out.Write("void main()\n{\n"); + + if (g_ActiveConfig.iStereoMode > 0) + { + // compute window position if needed because binding semantic WPOS is not widely supported + // Let's set up attributes + for (unsigned int i = 0; i < numTexgen; ++i) + { + out.Write("\tfloat3 uv%d = f.tex%d;\n", i, i); + } + out.Write("\tfloat4 clipPos = f.clipPos;\n"); + if (g_ActiveConfig.bEnablePixelLighting) + { + out.Write("\tfloat4 Normal = f.Normal;\n"); + } + } + + // On Mali, global variables must be initialized as constants. + // This is why we initialize these variables locally instead. + out.Write("\tfloat4 colors_0 = %s;\n", (g_ActiveConfig.iStereoMode > 0) ? "f.colors_0" : "colors_02"); + out.Write("\tfloat4 colors_1 = %s;\n", (g_ActiveConfig.iStereoMode > 0) ? "f.colors_1" : "colors_12"); + out.Write("\tfloat4 rawpos = gl_FragCoord;\n"); } else // D3D @@ -370,14 +394,6 @@ static inline void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_T "\tint2 wrappedcoord=int2(0,0), tempcoord=int2(0,0);\n" "\tint4 tevin_a=int4(0,0,0,0),tevin_b=int4(0,0,0,0),tevin_c=int4(0,0,0,0),tevin_d=int4(0,0,0,0);\n\n"); // tev combiner inputs - if (ApiType == API_OPENGL) - { - // On Mali, global variables must be initialized as constants. - // This is why we initialize these variables locally instead. - out.Write("\tfloat4 colors_0 = colors_02;\n"); - out.Write("\tfloat4 colors_1 = colors_12;\n"); - } - if (g_ActiveConfig.bEnablePixelLighting) { out.Write("\tfloat3 _norm0 = normalize(Normal.xyz);\n\n"); @@ -931,7 +947,7 @@ static inline void SampleTexture(T& out, const char *texcoords, const char *texs if (ApiType == API_D3D) out.Write("iround(255.0 * Tex%d.Sample(samp%d,%s.xy * " I_TEXDIMS"[%d].xy)).%s;\n", texmap,texmap, texcoords, texmap, texswap); else - out.Write("iround(255.0 * texture(samp%d,%s.xy * " I_TEXDIMS"[%d].xy)).%s;\n", texmap, texcoords, texmap, texswap); + out.Write("iround(255.0 * texture(samp%d, float3(%s.xy * " I_TEXDIMS"[%d].xy, %s))).%s;\n", texmap, texcoords, texmap, g_ActiveConfig.iStereoMode > 0 ? "layer" : "0.0", texswap); } static const char *tevAlphaFuncsTable[] = |
