ShaderGen: Only pass VS_OUTPUT between shaders if stereo 3D is enabled.
GLSL130 doesn't support passing structs between shaders. This is not a problem for stereo 3D which has a GLSL150 requirement.
This commit is contained in:
parent
51a4d6a4be
commit
27f3f804a0
|
@ -64,8 +64,8 @@ static inline void GenerateGeometryShader(T& out, u32 components, API_TYPE ApiTy
|
|||
|
||||
GenerateVSOutputStruct(out, ApiType);
|
||||
|
||||
out.Write("centroid in VS_OUTPUT v[];\n");
|
||||
out.Write("centroid out VS_OUTPUT o;\n");
|
||||
out.Write("centroid in VS_OUTPUT o[];\n");
|
||||
out.Write("centroid out VS_OUTPUT f;\n");
|
||||
|
||||
out.Write("flat out int layer;\n");
|
||||
|
||||
|
@ -79,15 +79,15 @@ static inline void GenerateGeometryShader(T& out, u32 components, API_TYPE ApiTy
|
|||
out.Write("\tgl_Layer = layer;\n");
|
||||
|
||||
out.Write("\tfor (int i = 0; i < gl_in.length(); ++i) {\n");
|
||||
out.Write("\t\to = v[i];\n");
|
||||
out.Write("\t\tf = o[i];\n");
|
||||
|
||||
if (g_ActiveConfig.iStereoMode > 0)
|
||||
{
|
||||
out.Write("\t\to.clipPos.x += o.clipPos.w * " I_STEREOOFFSET"[layer] * " I_PROJECTION"[0][0];\n");
|
||||
out.Write("\t\to.pos.x += o.pos.w * " I_STEREOOFFSET"[layer] * " I_PROJECTION"[0][0];\n");
|
||||
out.Write("\t\tf.clipPos.x += f.clipPos.w * " I_STEREOOFFSET"[layer] * " I_PROJECTION"[0][0];\n");
|
||||
out.Write("\t\tf.pos.x += f.pos.w * " I_STEREOOFFSET"[layer] * " I_PROJECTION"[0][0];\n");
|
||||
}
|
||||
|
||||
out.Write("\t\tgl_Position = o.pos;\n");
|
||||
out.Write("\t\tgl_Position = f.pos;\n");
|
||||
out.Write("\t\tEmitVertex();\n");
|
||||
out.Write("\t}\n");
|
||||
out.Write("\tEndPrimitive();\n");
|
||||
|
|
|
@ -319,30 +319,51 @@ 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 VS_OUTPUT o;\n");
|
||||
|
||||
uid_data->stereo = g_ActiveConfig.iStereoMode > 0;
|
||||
if (g_ActiveConfig.iStereoMode > 0)
|
||||
{
|
||||
out.Write("centroid in VS_OUTPUT f;\n");
|
||||
out.Write("flat in int layer;\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
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");
|
||||
|
||||
// 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)
|
||||
if (g_ActiveConfig.iStereoMode > 0)
|
||||
{
|
||||
out.Write("\tfloat3 uv%d = o.tex%d;\n", i, i);
|
||||
}
|
||||
out.Write("\tfloat4 clipPos = o.clipPos;\n");
|
||||
if (g_ActiveConfig.bEnablePixelLighting)
|
||||
{
|
||||
out.Write("\tfloat4 Normal = o.Normal;\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("\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 = o.colors_0;\n");
|
||||
out.Write("\tfloat4 colors_1 = o.colors_1;\n");
|
||||
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");
|
||||
}
|
||||
|
|
|
@ -123,11 +123,31 @@ static inline void GenerateVertexShader(T& out, u32 components, API_TYPE api_typ
|
|||
}
|
||||
|
||||
uid_data->stereo = g_ActiveConfig.iStereoMode > 0;
|
||||
out.Write("centroid out VS_OUTPUT %s;\n", (g_ActiveConfig.iStereoMode > 0) ? "v" : "o");
|
||||
if (g_ActiveConfig.iStereoMode > 0)
|
||||
{
|
||||
out.Write("centroid out VS_OUTPUT o;\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Let's set up attributes
|
||||
for (size_t i = 0; i < 8; ++i)
|
||||
{
|
||||
if (i < xfmem.numTexGen.numTexGens)
|
||||
{
|
||||
out.Write("centroid out float3 uv%d;\n", i);
|
||||
}
|
||||
}
|
||||
|
||||
out.Write("centroid out float4 clipPos;\n");
|
||||
if (g_ActiveConfig.bEnablePixelLighting)
|
||||
out.Write("centroid out float4 Normal;\n");
|
||||
out.Write("centroid out float4 colors_02;\n");
|
||||
out.Write("centroid out float4 colors_12;\n");
|
||||
}
|
||||
|
||||
out.Write("void main()\n{\n");
|
||||
|
||||
if (g_ActiveConfig.iStereoMode > 0)
|
||||
if (g_ActiveConfig.iStereoMode <= 0)
|
||||
out.Write("VS_OUTPUT o;\n");
|
||||
}
|
||||
else // D3D
|
||||
|
@ -414,8 +434,24 @@ static inline void GenerateVertexShader(T& out, u32 components, API_TYPE api_typ
|
|||
|
||||
if (api_type == API_OPENGL)
|
||||
{
|
||||
if (g_ActiveConfig.iStereoMode > 0)
|
||||
out.Write("v = o;\n");
|
||||
if (g_ActiveConfig.iStereoMode <= 0)
|
||||
{
|
||||
// Bit ugly here
|
||||
// TODO: Make pretty
|
||||
// Will look better when we bind uniforms in GLSL 1.3
|
||||
// clipPos/w needs to be done in pixel shader, not here
|
||||
|
||||
for (unsigned int i = 0; i < xfmem.numTexGen.numTexGens; ++i)
|
||||
out.Write("uv%d.xyz = o.tex%d;\n", i, i);
|
||||
|
||||
out.Write("clipPos = o.clipPos;\n");
|
||||
|
||||
if (g_ActiveConfig.bEnablePixelLighting)
|
||||
out.Write("Normal = o.Normal;\n");
|
||||
|
||||
out.Write("colors_02 = o.colors_0;\n");
|
||||
out.Write("colors_12 = o.colors_1;\n");
|
||||
}
|
||||
|
||||
out.Write("gl_Position = o.pos;\n");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue