PixelShaderGen: Sample the correct texture layer.

This commit is contained in:
Jules Blok 2014-10-27 00:29:37 +01:00
parent f6ea293027
commit d9e280e338
2 changed files with 9 additions and 3 deletions

View File

@ -77,12 +77,15 @@ static inline void GenerateGeometryShader(T& out, u32 components, API_TYPE ApiTy
out.Write("centroid in VS_OUTPUT v[];\n");
out.Write("centroid out VS_OUTPUT o;\n");
out.Write("flat out int eye;\n");
out.Write("void main()\n{\n");
out.Write("\tfor (int i = 0; i < gl_in.length(); ++i) {\n");
out.Write("\t\to = v[i];\n");
out.Write("\t\to.pos = float4(dot(" I_STEREOPROJECTION"[gl_InvocationID * 4 + 0], v[i].rawpos), dot(" I_STEREOPROJECTION"[gl_InvocationID * 4 + 1], v[i].rawpos), dot(" I_STEREOPROJECTION"[gl_InvocationID * 4 + 2], v[i].rawpos), dot(" I_STEREOPROJECTION"[gl_InvocationID * 4 + 3], v[i].rawpos)); \n");
out.Write("\t\teye = gl_InvocationID;\n");
out.Write("\t\to.pos = float4(dot(" I_STEREOPROJECTION"[eye * 4 + 0], v[i].rawpos), dot(" I_STEREOPROJECTION"[eye * 4 + 1], v[i].rawpos), dot(" I_STEREOPROJECTION"[eye * 4 + 2], v[i].rawpos), dot(" I_STEREOPROJECTION"[eye * 4 + 3], v[i].rawpos)); \n");
out.Write("\t\tgl_Position = o.pos;\n");
out.Write("\t\tgl_Layer = gl_InvocationID;\n");
out.Write("\t\tgl_Layer = eye;\n");
out.Write("\t\tEmitVertex();\n");
out.Write("\t}\n");
out.Write("\tEndPrimitive();\n");

View File

@ -335,6 +335,9 @@ static inline void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_T
// Without MSAA, this flag is defined to have no effect.
out.Write("centroid in VS_OUTPUT o;\n");
if (g_ActiveConfig.bStereo)
out.Write("flat in int eye;\n");
out.Write("void main()\n{\n");
// compute window position if needed because binding semantic WPOS is not widely supported
@ -936,7 +939,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, float3(%s.xy * " I_TEXDIMS"[%d].xy, 0.0))).%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.bStereo ? "eye" : "0.0", texswap);
}
static const char *tevAlphaFuncsTable[] =