LightingShader: Drop xfmem usage.
Our shaders must only depend on the UID, not on any global state.
This commit is contained in:
parent
829fc8f0ad
commit
083be0832f
|
@ -72,9 +72,9 @@ static void GenerateLightShader(ShaderCode& object, const LightingUidData& uid_d
|
||||||
// inColorName is color in vs and colors_ in ps
|
// inColorName is color in vs and colors_ in ps
|
||||||
// dest is o.colors_ in vs and colors_ in ps
|
// dest is o.colors_ in vs and colors_ in ps
|
||||||
void GenerateLightingShaderCode(ShaderCode& object, const LightingUidData& uid_data, int components,
|
void GenerateLightingShaderCode(ShaderCode& object, const LightingUidData& uid_data, int components,
|
||||||
const char* inColorName, const char* dest)
|
u32 numColorChans, const char* inColorName, const char* dest)
|
||||||
{
|
{
|
||||||
for (unsigned int j = 0; j < xfmem.numChan.numColorChans; j++)
|
for (unsigned int j = 0; j < numColorChans; j++)
|
||||||
{
|
{
|
||||||
object.Write("{\n");
|
object.Write("{\n");
|
||||||
|
|
||||||
|
|
|
@ -47,5 +47,5 @@ static const char s_lighting_struct[] = "struct Light {\n"
|
||||||
"};\n";
|
"};\n";
|
||||||
|
|
||||||
void GenerateLightingShaderCode(ShaderCode& object, const LightingUidData& uid_data, int components,
|
void GenerateLightingShaderCode(ShaderCode& object, const LightingUidData& uid_data, int components,
|
||||||
const char* inColorName, const char* dest);
|
u32 numColorChans, const char* inColorName, const char* dest);
|
||||||
void GetLightingShaderUid(LightingUidData& uid_data);
|
void GetLightingShaderUid(LightingUidData& uid_data);
|
||||||
|
|
|
@ -207,7 +207,7 @@ PixelShaderUid GetPixelShaderUid(DSTALPHA_MODE dstAlphaMode)
|
||||||
// The lighting shader only needs the two color bits of the 23bit component bit array.
|
// The lighting shader only needs the two color bits of the 23bit component bit array.
|
||||||
uid_data->components =
|
uid_data->components =
|
||||||
(VertexLoaderManager::g_current_components & (VB_HAS_COL0 | VB_HAS_COL1)) >> VB_COL_SHIFT;
|
(VertexLoaderManager::g_current_components & (VB_HAS_COL0 | VB_HAS_COL1)) >> VB_COL_SHIFT;
|
||||||
;
|
uid_data->numColorChans = xfmem.numChan.numColorChans;
|
||||||
GetLightingShaderUid(uid_data->lighting);
|
GetLightingShaderUid(uid_data->lighting);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -649,7 +649,7 @@ ShaderCode GeneratePixelShaderCode(APIType ApiType, const pixel_shader_uid_data*
|
||||||
// out.SetConstantsUsed(C_PLIGHTS, C_PLIGHTS+31); // TODO: Can be optimized further
|
// out.SetConstantsUsed(C_PLIGHTS, C_PLIGHTS+31); // TODO: Can be optimized further
|
||||||
// out.SetConstantsUsed(C_PMATERIALS, C_PMATERIALS+3);
|
// out.SetConstantsUsed(C_PMATERIALS, C_PMATERIALS+3);
|
||||||
GenerateLightingShaderCode(out, uid_data->lighting, uid_data->components << VB_COL_SHIFT,
|
GenerateLightingShaderCode(out, uid_data->lighting, uid_data->components << VB_COL_SHIFT,
|
||||||
"colors_", "col");
|
uid_data->numColorChans, "colors_", "col");
|
||||||
}
|
}
|
||||||
|
|
||||||
// HACK to handle cases where the tex gen is not enabled
|
// HACK to handle cases where the tex gen is not enabled
|
||||||
|
|
|
@ -52,7 +52,8 @@ struct pixel_shader_uid_data
|
||||||
u32 zfreeze : 1;
|
u32 zfreeze : 1;
|
||||||
u32 msaa : 1;
|
u32 msaa : 1;
|
||||||
u32 ssaa : 1;
|
u32 ssaa : 1;
|
||||||
u32 pad : 16;
|
u32 numColorChans : 2;
|
||||||
|
u32 pad : 14;
|
||||||
|
|
||||||
u32 texMtxInfo_n_projection : 8; // 8x1 bit
|
u32 texMtxInfo_n_projection : 8; // 8x1 bit
|
||||||
u32 tevindref_bi0 : 3;
|
u32 tevindref_bi0 : 3;
|
||||||
|
|
|
@ -250,7 +250,8 @@ ShaderCode GenerateVertexShaderCode(APIType api_type, const vertex_shader_uid_da
|
||||||
out.Write("o.colors_0 = float4(1.0, 1.0, 1.0, 1.0);\n");
|
out.Write("o.colors_0 = float4(1.0, 1.0, 1.0, 1.0);\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
GenerateLightingShaderCode(out, uid_data->lighting, uid_data->components, "color", "o.colors_");
|
GenerateLightingShaderCode(out, uid_data->lighting, uid_data->components, uid_data->numColorChans,
|
||||||
|
"color", "o.colors_");
|
||||||
|
|
||||||
if (uid_data->numColorChans < 2)
|
if (uid_data->numColorChans < 2)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue