ShaderGen: drop PerPixelLighting + 8Texcoord hack
D3D9 only supports 8 texcoords. But we need a new one for ppl, so we just store it in the first 4 texcoords in the free 4th component. This isn't needed for both d3d11 and ogl3, so just remove it.
This commit is contained in:
parent
f62579761c
commit
bd80de14f4
|
@ -316,8 +316,6 @@ static inline void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_T
|
||||||
|
|
||||||
// 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
|
||||||
if (xfregs.numTexGen.numTexGens < 7)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < xfregs.numTexGen.numTexGens; ++i)
|
for (int i = 0; i < xfregs.numTexGen.numTexGens; ++i)
|
||||||
out.Write("VARYIN float3 uv%d_2;\n", i);
|
out.Write("VARYIN float3 uv%d_2;\n", i);
|
||||||
out.Write("VARYIN float4 clipPos_2;\n");
|
out.Write("VARYIN float4 clipPos_2;\n");
|
||||||
|
@ -325,26 +323,6 @@ static inline void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_T
|
||||||
{
|
{
|
||||||
out.Write("VARYIN float4 Normal_2;\n");
|
out.Write("VARYIN float4 Normal_2;\n");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// wpos is in w of first 4 texcoords
|
|
||||||
if (g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < 8; ++i)
|
|
||||||
{
|
|
||||||
out.Write("VARYIN float4 uv%d_2;\n", i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (unsigned int i = 0; i < xfregs.numTexGen.numTexGens; ++i)
|
|
||||||
{
|
|
||||||
out.Write("VARYIN float%d uv%d_2;\n", i < 4 ? 4 : 3 , i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
out.Write("float4 clipPos;\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (forced_early_z)
|
if (forced_early_z)
|
||||||
{
|
{
|
||||||
|
@ -433,8 +411,6 @@ static inline void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_T
|
||||||
out.Write("float4 colors_1 = colors_12;\n");
|
out.Write("float4 colors_1 = colors_12;\n");
|
||||||
// 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
|
||||||
if (xfregs.numTexGen.numTexGens < 7)
|
|
||||||
{
|
|
||||||
if(numTexgen)
|
if(numTexgen)
|
||||||
for (int i = 0; i < 8; ++i)
|
for (int i = 0; i < 8; ++i)
|
||||||
if(i < xfregs.numTexGen.numTexGens)
|
if(i < xfregs.numTexGen.numTexGens)
|
||||||
|
@ -445,38 +421,11 @@ static inline void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_T
|
||||||
out.Write("float4 Normal = Normal_2;\n");
|
out.Write("float4 Normal = Normal_2;\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
// wpos is in w of first 4 texcoords
|
|
||||||
if (g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < 8; ++i)
|
|
||||||
{
|
|
||||||
out.Write("float4 uv%d = uv%d_2;\n", i, i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (unsigned int i = 0; i < xfregs.numTexGen.numTexGens; ++i)
|
|
||||||
{
|
|
||||||
out.Write("float%d uv%d = uv%d_2;\n", i < 4 ? 4 : 3 , i, i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
|
if (g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
|
||||||
{
|
|
||||||
if (xfregs.numTexGen.numTexGens < 7)
|
|
||||||
{
|
{
|
||||||
out.Write("\tfloat3 _norm0 = normalize(Normal.xyz);\n\n");
|
out.Write("\tfloat3 _norm0 = normalize(Normal.xyz);\n\n");
|
||||||
out.Write("\tfloat3 pos = float3(clipPos.x,clipPos.y,Normal.w);\n");
|
out.Write("\tfloat3 pos = float3(clipPos.x,clipPos.y,Normal.w);\n");
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
out.Write("\tfloat3 _norm0 = normalize(float3(uv4.w,uv5.w,uv6.w));\n\n");
|
|
||||||
out.Write("\tfloat3 pos = float3(uv0.w,uv1.w,uv7.w);\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
out.Write("\tfloat4 mat, lacc;\n"
|
out.Write("\tfloat4 mat, lacc;\n"
|
||||||
"\tfloat3 ldir, h;\n"
|
"\tfloat3 ldir, h;\n"
|
||||||
|
@ -488,10 +437,7 @@ static inline void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_T
|
||||||
GenerateLightingShader<T>(out, uid_data.lighting, components, I_PMATERIALS, I_PLIGHTS, "colors_", "colors_");
|
GenerateLightingShader<T>(out, uid_data.lighting, components, I_PMATERIALS, I_PLIGHTS, "colors_", "colors_");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (numTexgen < 7)
|
|
||||||
out.Write("\tclipPos = float4(rawpos.x, rawpos.y, clipPos.z, clipPos.w);\n");
|
out.Write("\tclipPos = float4(rawpos.x, rawpos.y, clipPos.z, clipPos.w);\n");
|
||||||
else
|
|
||||||
out.Write("\tclipPos = float4(rawpos.x, rawpos.y, uv2.w, uv3.w);\n");
|
|
||||||
|
|
||||||
// HACK to handle cases where the tex gen is not enabled
|
// HACK to handle cases where the tex gen is not enabled
|
||||||
if (numTexgen == 0)
|
if (numTexgen == 0)
|
||||||
|
|
|
@ -45,8 +45,6 @@ static inline void GenerateVSOutputStruct(T& object, u32 components, API_TYPE ap
|
||||||
DefineVSOutputStructMember(object, api_type, "float4", "colors_", 0, "COLOR", 0);
|
DefineVSOutputStructMember(object, api_type, "float4", "colors_", 0, "COLOR", 0);
|
||||||
DefineVSOutputStructMember(object, api_type, "float4", "colors_", 1, "COLOR", 1);
|
DefineVSOutputStructMember(object, api_type, "float4", "colors_", 1, "COLOR", 1);
|
||||||
|
|
||||||
if (xfregs.numTexGen.numTexGens < 7)
|
|
||||||
{
|
|
||||||
for (unsigned int i = 0; i < xfregs.numTexGen.numTexGens; ++i)
|
for (unsigned int i = 0; i < xfregs.numTexGen.numTexGens; ++i)
|
||||||
DefineVSOutputStructMember(object, api_type, "float3", "tex", i, "TEXCOORD", i);
|
DefineVSOutputStructMember(object, api_type, "float3", "tex", i, "TEXCOORD", i);
|
||||||
|
|
||||||
|
@ -54,15 +52,7 @@ static inline void GenerateVSOutputStruct(T& object, u32 components, API_TYPE ap
|
||||||
|
|
||||||
if(g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
|
if(g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
|
||||||
DefineVSOutputStructMember(object, api_type, "float4", "Normal", -1, "TEXCOORD", xfregs.numTexGen.numTexGens + 1);
|
DefineVSOutputStructMember(object, api_type, "float4", "Normal", -1, "TEXCOORD", xfregs.numTexGen.numTexGens + 1);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Store clip position in the w component of first 4 texcoords
|
|
||||||
bool ppl = g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting;
|
|
||||||
int num_texcoords = ppl ? 8 : xfregs.numTexGen.numTexGens;
|
|
||||||
for (int i = 0; i < num_texcoords; ++i)
|
|
||||||
DefineVSOutputStructMember(object, api_type, (ppl || i < 4) ? "float4" : "float3", "tex", i, "TEXCOORD", i);
|
|
||||||
}
|
|
||||||
object.Write("};\n");
|
object.Write("};\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,29 +130,13 @@ static inline void GenerateVertexShader(T& out, u32 components, API_TYPE api_typ
|
||||||
}
|
}
|
||||||
|
|
||||||
// Let's set up attributes
|
// Let's set up attributes
|
||||||
if (xfregs.numTexGen.numTexGens < 7)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < 8; ++i)
|
for (int i = 0; i < 8; ++i)
|
||||||
if (i < xfregs.numTexGen.numTexGens)
|
if (i < xfregs.numTexGen.numTexGens)
|
||||||
out.Write("VARYOUT float3 uv%d_2;\n", i);
|
out.Write("VARYOUT float3 uv%d_2;\n", i);
|
||||||
out.Write("VARYOUT float4 clipPos_2;\n");
|
out.Write("VARYOUT float4 clipPos_2;\n");
|
||||||
if (g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
|
if (g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
|
||||||
out.Write("VARYOUT float4 Normal_2;\n");
|
out.Write("VARYOUT float4 Normal_2;\n");
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// wpos is in w of first 4 texcoords
|
|
||||||
if (g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < 8; ++i)
|
|
||||||
out.Write("VARYOUT float4 uv%d_2;\n", i);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (unsigned int i = 0; i < xfregs.numTexGen.numTexGens; ++i)
|
|
||||||
out.Write("VARYOUT float%d uv%d_2;\n", i < 4 ? 4 : 3 , i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
out.Write("VARYOUT float4 colors_02;\n");
|
out.Write("VARYOUT float4 colors_02;\n");
|
||||||
out.Write("VARYOUT float4 colors_12;\n");
|
out.Write("VARYOUT float4 colors_12;\n");
|
||||||
|
|
||||||
|
@ -408,34 +382,11 @@ static inline void GenerateVertexShader(T& out, u32 components, API_TYPE api_typ
|
||||||
}
|
}
|
||||||
|
|
||||||
// clipPos/w needs to be done in pixel shader, not here
|
// clipPos/w needs to be done in pixel shader, not here
|
||||||
if (xfregs.numTexGen.numTexGens < 7)
|
|
||||||
{
|
|
||||||
out.Write("o.clipPos = float4(pos.x,pos.y,o.pos.z,o.pos.w);\n");
|
out.Write("o.clipPos = float4(pos.x,pos.y,o.pos.z,o.pos.w);\n");
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
out.Write("o.tex0.w = pos.x;\n");
|
|
||||||
out.Write("o.tex1.w = pos.y;\n");
|
|
||||||
out.Write("o.tex2.w = o.pos.z;\n");
|
|
||||||
out.Write("o.tex3.w = o.pos.w;\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
|
if(g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
|
||||||
{
|
|
||||||
if (xfregs.numTexGen.numTexGens < 7)
|
|
||||||
{
|
{
|
||||||
out.Write("o.Normal = float4(_norm0.x,_norm0.y,_norm0.z,pos.z);\n");
|
out.Write("o.Normal = float4(_norm0.x,_norm0.y,_norm0.z,pos.z);\n");
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
out.Write("o.tex4.w = _norm0.x;\n");
|
|
||||||
out.Write("o.tex5.w = _norm0.y;\n");
|
|
||||||
out.Write("o.tex6.w = _norm0.z;\n");
|
|
||||||
if (xfregs.numTexGen.numTexGens < 8)
|
|
||||||
out.Write("o.tex7 = pos.xyzz;\n");
|
|
||||||
else
|
|
||||||
out.Write("o.tex7.w = pos.z;\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (components & VB_HAS_COL0)
|
if (components & VB_HAS_COL0)
|
||||||
out.Write("o.colors_0 = color0;\n");
|
out.Write("o.colors_0 = color0;\n");
|
||||||
|
@ -481,28 +432,12 @@ static inline void GenerateVertexShader(T& out, u32 components, API_TYPE api_typ
|
||||||
// Will look better when we bind uniforms in GLSL 1.3
|
// Will look better when we bind uniforms in GLSL 1.3
|
||||||
// clipPos/w needs to be done in pixel shader, not here
|
// clipPos/w needs to be done in pixel shader, not here
|
||||||
|
|
||||||
if (xfregs.numTexGen.numTexGens < 7)
|
|
||||||
{
|
|
||||||
for (unsigned int i = 0; i < xfregs.numTexGen.numTexGens; ++i)
|
for (unsigned int i = 0; i < xfregs.numTexGen.numTexGens; ++i)
|
||||||
out.Write(" uv%d_2.xyz = o.tex%d;\n", i, i);
|
out.Write(" uv%d_2.xyz = o.tex%d;\n", i, i);
|
||||||
out.Write(" clipPos_2 = o.clipPos;\n");
|
out.Write(" clipPos_2 = o.clipPos;\n");
|
||||||
if(g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
|
if(g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
|
||||||
out.Write(" Normal_2 = o.Normal;\n");
|
out.Write(" Normal_2 = o.Normal;\n");
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// clip position is in w of first 4 texcoords
|
|
||||||
if (g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < 8; ++i)
|
|
||||||
out.Write(" uv%d_2 = o.tex%d;\n", i, i);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (unsigned int i = 0; i < xfregs.numTexGen.numTexGens; ++i)
|
|
||||||
out.Write(" uv%d_2%s = o.tex%d;\n", i, i < 4 ? ".xyzw" : ".xyz" , i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
out.Write("colors_02 = o.colors_0;\n");
|
out.Write("colors_02 = o.colors_0;\n");
|
||||||
out.Write("colors_12 = o.colors_1;\n");
|
out.Write("colors_12 = o.colors_1;\n");
|
||||||
out.Write("gl_Position = o.pos;\n");
|
out.Write("gl_Position = o.pos;\n");
|
||||||
|
|
Loading…
Reference in New Issue