summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authordegasus <wickmarkus@web.de>2014-05-30 15:59:29 +0200
committerdegasus <wickmarkus@web.de>2014-06-19 16:33:33 +0200
commite456a5e64f3980eb3469e8d5362a689a9db123d6 (patch)
treefe8d8d1a337ef64b14cc5ba8166474c24200b508 /Source/Core
parentd93f2973f7330a033253d94a738f820231bb6623 (diff)
PixelShader: remove the duplicated ppl constants
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/VideoCommon/ConstantManager.h5
-rw-r--r--Source/Core/VideoCommon/PixelShaderGen.cpp11
-rw-r--r--Source/Core/VideoCommon/PixelShaderGen.h5
-rw-r--r--Source/Core/VideoCommon/PixelShaderManager.cpp72
-rw-r--r--Source/Core/VideoCommon/PixelShaderManager.h2
-rw-r--r--Source/Core/VideoCommon/XFStructs.cpp3
6 files changed, 4 insertions, 94 deletions
diff --git a/Source/Core/VideoCommon/ConstantManager.h b/Source/Core/VideoCommon/ConstantManager.h
index b03d2ced6d..79313cd6e8 100644
--- a/Source/Core/VideoCommon/ConstantManager.h
+++ b/Source/Core/VideoCommon/ConstantManager.h
@@ -21,11 +21,6 @@ struct PixelShaderConstants
int4 fogcolor;
int4 fogi;
float4 fogf[2];
-
- // For pixel lighting
- int4 plight_colors[8];
- float4 plights[32];
- int4 pmaterials[4];
};
struct VertexShaderConstants
diff --git a/Source/Core/VideoCommon/PixelShaderGen.cpp b/Source/Core/VideoCommon/PixelShaderGen.cpp
index dd010f1583..a8e98822aa 100644
--- a/Source/Core/VideoCommon/PixelShaderGen.cpp
+++ b/Source/Core/VideoCommon/PixelShaderGen.cpp
@@ -237,11 +237,6 @@ static inline void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_T
"\tint4 " I_FOGCOLOR";\n"
"\tint4 " I_FOGI";\n"
"\tfloat4 " I_FOGF"[2];\n"
-
- // For pixel lighting - TODO: Should only be defined when per pixel lighting is enabled!
- "\tint4 " I_PLIGHT_COLORS"[8];\n"
- "\tfloat4 " I_PLIGHTS"[32];\n"
- "\tint4 " I_PMATERIALS"[4];\n"
"};\n");
if (ApiType == API_OPENGL)
@@ -377,9 +372,9 @@ static inline void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_T
"\tfloat3 ldir, h;\n"
"\tfloat dist, dist2, attn;\n");
- out.SetConstantsUsed(C_PLIGHT_COLORS, C_PLIGHT_COLORS+7); // 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_PLIGHT_COLORS, C_PLIGHT_COLORS+7); // TODO: Can be optimized further
+ //out.SetConstantsUsed(C_PLIGHTS, C_PLIGHTS+31); // TODO: Can be optimized further
+ //out.SetConstantsUsed(C_PMATERIALS, C_PMATERIALS+3);
uid_data.components = components;
GenerateLightingShader<T>(out, uid_data.lighting, components, I_MATERIALS, I_LIGHT_COLORS, I_LIGHTS, "colors_", "colors_");
}
diff --git a/Source/Core/VideoCommon/PixelShaderGen.h b/Source/Core/VideoCommon/PixelShaderGen.h
index 135e4928f1..60092c71b8 100644
--- a/Source/Core/VideoCommon/PixelShaderGen.h
+++ b/Source/Core/VideoCommon/PixelShaderGen.h
@@ -36,10 +36,7 @@
#define C_FOGI (C_FOGCOLOR + 1) //28
#define C_FOGF (C_FOGI + 1) //29
-#define C_PLIGHT_COLORS (C_FOGF + 2)
-#define C_PLIGHTS (C_PLIGHT_COLORS + 8)
-#define C_PMATERIALS (C_PLIGHTS + 32)
-#define C_PENVCONST_END (C_PMATERIALS + 4)
+#define C_PENVCONST_END (C_FOGF + 2)
// Different ways to achieve rendering with destination alpha
enum DSTALPHA_MODE
diff --git a/Source/Core/VideoCommon/PixelShaderManager.cpp b/Source/Core/VideoCommon/PixelShaderManager.cpp
index bb1819eb76..3ea6713ebd 100644
--- a/Source/Core/VideoCommon/PixelShaderManager.cpp
+++ b/Source/Core/VideoCommon/PixelShaderManager.cpp
@@ -14,7 +14,6 @@
static bool s_bFogRangeAdjustChanged;
static bool s_bViewPortChanged;
-static int nLightsChanged[2]; // min,max
PixelShaderConstants PixelShaderManager::constants;
bool PixelShaderManager::dirty;
@@ -29,7 +28,6 @@ void PixelShaderManager::Dirty()
{
s_bFogRangeAdjustChanged = true;
s_bViewPortChanged = true;
- nLightsChanged[0] = 0; nLightsChanged[1] = 0x80;
SetColorChanged(0, 0);
SetColorChanged(0, 1);
@@ -100,44 +98,6 @@ void PixelShaderManager::SetConstants()
s_bFogRangeAdjustChanged = false;
}
- if (g_ActiveConfig.bEnablePixelLighting) // config check added because the code in here was crashing for me inside SetPSConstant4f
- {
- if (nLightsChanged[0] >= 0)
- {
- // TODO: Outdated comment
- // lights don't have a 1 to 1 mapping, the color component needs to be converted to 4 floats
- int istart = nLightsChanged[0] / 0x10;
- int iend = (nLightsChanged[1] + 15) / 0x10;
-
- for (int i = istart; i < iend; ++i)
- {
- const Light& light = xfmem.lights[i];
- constants.plight_colors[i][0] = light.color[3];
- constants.plight_colors[i][1] = light.color[2];
- constants.plight_colors[i][2] = light.color[1];
- constants.plight_colors[i][3] = light.color[0];
- const float* xfmemptr = light.cosatt;
-
- for (int j = 0; j < 4; ++j, xfmemptr += 3)
- {
- if (j == 1 &&
- fabs(xfmemptr[0]) < 0.00001f &&
- fabs(xfmemptr[1]) < 0.00001f &&
- fabs(xfmemptr[2]) < 0.00001f)
- // dist attenuation, make sure not equal to 0!!!
- constants.plights[4*i+j][0] = 0.00001f;
- else
- constants.plights[4*i+j][0] = xfmemptr[0];
- constants.plights[4*i+j][1] = xfmemptr[1];
- constants.plights[4*i+j][2] = xfmemptr[2];
- }
- }
- dirty = true;
-
- nLightsChanged[0] = nLightsChanged[1] = -1;
- }
- }
-
if (s_bViewPortChanged)
{
constants.zbias[1][0] = xfmem.viewport.farZ;
@@ -303,38 +263,6 @@ void PixelShaderManager::SetFogRangeAdjustChanged()
s_bFogRangeAdjustChanged = true;
}
-void PixelShaderManager::InvalidateXFRange(int start, int end)
-{
- if (start < XFMEM_LIGHTS_END && end > XFMEM_LIGHTS)
- {
- int _start = start < XFMEM_LIGHTS ? XFMEM_LIGHTS : start-XFMEM_LIGHTS;
- int _end = end < XFMEM_LIGHTS_END ? end-XFMEM_LIGHTS : XFMEM_LIGHTS_END-XFMEM_LIGHTS;
-
- if (nLightsChanged[0] == -1 )
- {
- nLightsChanged[0] = _start;
- nLightsChanged[1] = _end;
- }
- else
- {
- if (nLightsChanged[0] > _start) nLightsChanged[0] = _start;
- if (nLightsChanged[1] < _end) nLightsChanged[1] = _end;
- }
- }
-}
-
-void PixelShaderManager::SetMaterialColorChanged(int index, u32 color)
-{
- if (g_ActiveConfig.bEnablePixelLighting)
- {
- constants.pmaterials[index][0] = (color >> 24) & 0xFF;
- constants.pmaterials[index][1] = (color >> 16) & 0xFF;
- constants.pmaterials[index][2] = (color >> 8) & 0xFF;
- constants.pmaterials[index][3] = (color) & 0xFF;
- dirty = true;
- }
-}
-
void PixelShaderManager::DoState(PointerWrap &p)
{
p.Do(constants);
diff --git a/Source/Core/VideoCommon/PixelShaderManager.h b/Source/Core/VideoCommon/PixelShaderManager.h
index bd0c904b43..5c07b0522a 100644
--- a/Source/Core/VideoCommon/PixelShaderManager.h
+++ b/Source/Core/VideoCommon/PixelShaderManager.h
@@ -39,8 +39,6 @@ public:
static void SetFogColorChanged();
static void SetFogParamChanged();
static void SetFogRangeAdjustChanged();
- static void InvalidateXFRange(int start, int end);
- static void SetMaterialColorChanged(int index, u32 color);
static PixelShaderConstants constants;
static bool dirty;
diff --git a/Source/Core/VideoCommon/XFStructs.cpp b/Source/Core/VideoCommon/XFStructs.cpp
index 62a17ad829..fb20c3d289 100644
--- a/Source/Core/VideoCommon/XFStructs.cpp
+++ b/Source/Core/VideoCommon/XFStructs.cpp
@@ -15,7 +15,6 @@ void XFMemWritten(u32 transferSize, u32 baseAddress)
{
VertexManager::Flush();
VertexShaderManager::InvalidateXFRange(baseAddress, baseAddress + transferSize);
- PixelShaderManager::InvalidateXFRange(baseAddress, baseAddress + transferSize);
}
void XFRegWritten(int transferSize, u32 baseAddress, u32 *pData)
@@ -61,7 +60,6 @@ void XFRegWritten(int transferSize, u32 baseAddress, u32 *pData)
{
VertexManager::Flush();
VertexShaderManager::SetMaterialColorChanged(chan, newValue);
- PixelShaderManager::SetMaterialColorChanged(chan, newValue);
}
break;
}
@@ -74,7 +72,6 @@ void XFRegWritten(int transferSize, u32 baseAddress, u32 *pData)
{
VertexManager::Flush();
VertexShaderManager::SetMaterialColorChanged(chan + 2, newValue);
- PixelShaderManager::SetMaterialColorChanged(chan + 2, newValue);
}
break;
}