VideoCommon: Assume we always use a geometry shader, not just for stereoscopy.

This commit is contained in:
Jules Blok 2014-12-15 21:09:25 +01:00
parent 382e1c22db
commit 275af9c5e4
3 changed files with 15 additions and 79 deletions

View File

@ -316,34 +316,14 @@ static inline void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_T
// As a workaround, we interpolate at the centroid of the coveraged pixel, which // As a workaround, we interpolate at the centroid of the coveraged pixel, which
// is always inside the primitive. // is always inside the primitive.
// Without MSAA, this flag is defined to have no effect. // Without MSAA, this flag is defined to have no effect.
out.Write("centroid in VS_OUTPUT vs;\n");
uid_data->stereo = g_ActiveConfig.iStereoMode > 0; uid_data->stereo = g_ActiveConfig.iStereoMode > 0;
if (g_ActiveConfig.iStereoMode > 0) if (g_ActiveConfig.iStereoMode > 0)
{
out.Write("centroid in VS_OUTPUT vs;\n");
out.Write("flat in int layer;\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"); out.Write("void main()\n{\n");
if (g_ActiveConfig.iStereoMode > 0)
{
// compute window position if needed because binding semantic WPOS is not widely supported // compute window position if needed because binding semantic WPOS is not widely supported
// Let's set up attributes // Let's set up attributes
for (unsigned int i = 0; i < numTexgen; ++i) for (unsigned int i = 0; i < numTexgen; ++i)
@ -355,12 +335,11 @@ static inline void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_T
{ {
out.Write("\tfloat4 Normal = vs.Normal;\n"); out.Write("\tfloat4 Normal = vs.Normal;\n");
} }
}
// On Mali, global variables must be initialized as constants. // On Mali, global variables must be initialized as constants.
// This is why we initialize these variables locally instead. // This is why we initialize these variables locally instead.
out.Write("\tfloat4 colors_0 = %s;\n", (g_ActiveConfig.iStereoMode > 0) ? "vs.colors_0" : "colors_02"); out.Write("\tfloat4 colors_0 = vs.colors_0;\n");
out.Write("\tfloat4 colors_1 = %s;\n", (g_ActiveConfig.iStereoMode > 0) ? "vs.colors_1" : "colors_12"); out.Write("\tfloat4 colors_1 = vs.colors_1;\n");
out.Write("\tfloat4 rawpos = gl_FragCoord;\n"); out.Write("\tfloat4 rawpos = gl_FragCoord;\n");
} }

View File

@ -72,33 +72,9 @@ static inline void GenerateVertexShader(T& out, u32 components, API_TYPE api_typ
out.Write("in float%d tex%d; // ATTR%d,\n", hastexmtx ? 3 : 2, i, SHADER_TEXTURE0_ATTRIB + i); out.Write("in float%d tex%d; // ATTR%d,\n", hastexmtx ? 3 : 2, i, SHADER_TEXTURE0_ATTRIB + i);
} }
uid_data->stereo = g_ActiveConfig.iStereoMode > 0;
if (g_ActiveConfig.iStereoMode > 0)
{
out.Write("centroid out VS_OUTPUT o;\n"); 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"); out.Write("void main()\n{\n");
if (g_ActiveConfig.iStereoMode <= 0)
out.Write("VS_OUTPUT o;\n");
} }
else // D3D else // D3D
{ {
@ -384,25 +360,6 @@ static inline void GenerateVertexShader(T& out, u32 components, API_TYPE api_typ
if (api_type == API_OPENGL) if (api_type == API_OPENGL)
{ {
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"); out.Write("gl_Position = o.pos;\n");
} }
else // D3D else // D3D

View File

@ -37,7 +37,7 @@ struct vertex_shader_uid_data
u32 numColorChans : 2; u32 numColorChans : 2;
u32 dualTexTrans_enabled : 1; u32 dualTexTrans_enabled : 1;
u32 pixel_lighting : 1; u32 pixel_lighting : 1;
u32 stereo : 1; u32 pad : 1;
u32 texMtxInfo_n_projection : 16; // Stored separately to guarantee that the texMtxInfo struct is 8 bits wide u32 texMtxInfo_n_projection : 16; // Stored separately to guarantee that the texMtxInfo struct is 8 bits wide
struct { struct {