summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon
diff options
context:
space:
mode:
authorNeoBrainX <NeoBrainX@googlemail.com>2011-09-29 23:32:05 +0200
committerNeoBrainX <NeoBrainX@googlemail.com>2011-09-29 23:32:39 +0200
commit81c614fa07dd4949351d1fd13f9bbf03a956cdac (patch)
tree86fd500b02b03228af40126978c58f6052426d50 /Source/Core/VideoCommon
parentddfe219293e3af9e04f7020f0557736e1762370b (diff)
Clean up various things.
Diffstat (limited to 'Source/Core/VideoCommon')
-rw-r--r--Source/Core/VideoCommon/Src/PixelShaderGen.cpp19
-rw-r--r--Source/Core/VideoCommon/Src/PixelShaderGen.h17
-rw-r--r--Source/Core/VideoCommon/Src/VertexShaderGen.cpp4
-rw-r--r--Source/Core/VideoCommon/Src/VertexShaderGen.h3
4 files changed, 18 insertions, 25 deletions
diff --git a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp
index f52c6b4190..1726855d54 100644
--- a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp
+++ b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp
@@ -27,8 +27,6 @@
#include "VideoConfig.h"
#include "NativeVertexFormat.h"
-PIXELSHADERUID last_pixel_shader_uid;
-
static int AlphaPreTest();
static void StageHash(int stage, u32* out)
@@ -104,8 +102,9 @@ static void StageHash(int stage, u32* out)
// a unique identifier, basically containing all the bits. Yup, it's a lot ....
// It would likely be a lot more efficient to build this incrementally as the attributes
// are set...
-void GetPixelShaderId(PIXELSHADERUID *uid, DSTALPHA_MODE dstAlphaMode)
+void GetPixelShaderId(PIXELSHADERUID *uid, DSTALPHA_MODE dstAlphaMode, u32 components)
{
+ memset(uid->values, 0, sizeof(uid->values));
uid->values[0] |= bpmem.genMode.numtevstages; // 4
uid->values[0] |= bpmem.genMode.numtexgens << 4; // 4
uid->values[0] |= dstAlphaMode << 8; // 2
@@ -192,13 +191,17 @@ void GetPixelShaderId(PIXELSHADERUID *uid, DSTALPHA_MODE dstAlphaMode)
++ptr;
if (enablePL)
+ {
ptr += GetLightingShaderId(ptr);
+ *ptr++ = components;
+ }
uid->num_values = ptr - uid->values;
}
-void GetSafePixelShaderId(PIXELSHADERUIDSAFE *uid, DSTALPHA_MODE dstAlphaMode)
+void GetSafePixelShaderId(PIXELSHADERUIDSAFE *uid, DSTALPHA_MODE dstAlphaMode, u32 components)
{
+ memset(uid->values, 0, sizeof(uid->values));
u32* ptr = uid->values;
*ptr++ = dstAlphaMode; // 0
*ptr++ = bpmem.genMode.hex; // 1
@@ -211,11 +214,11 @@ void GetSafePixelShaderId(PIXELSHADERUIDSAFE *uid, DSTALPHA_MODE dstAlphaMode)
if (g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
{
- // TODO: Include register states for lighting shader
*ptr++ = xfregs.color[0].hex;
*ptr++ = xfregs.alpha[0].hex;
*ptr++ = xfregs.color[1].hex;
*ptr++ = xfregs.alpha[1].hex;
+ *ptr++ = components;
}
for (unsigned int i = 0; i < 8; ++i)
@@ -251,7 +254,7 @@ void ValidatePixelShaderIDs(API_TYPE api, PIXELSHADERUIDSAFE old_id, const std::
return;
PIXELSHADERUIDSAFE new_id;
- GetSafePixelShaderId(&new_id, dstAlphaMode);
+ GetSafePixelShaderId(&new_id, dstAlphaMode, components);
if (!(old_id == new_id))
{
@@ -874,13 +877,13 @@ static void WriteStage(char *&p, int n, API_TYPE ApiType)
}
else if (bpmem.tevind[n].mid <= 7 && bHasTexCoord)
{ // s matrix
- // TODO: Might become negative?
+ _assert_(bpmem.tevind[n].mid >= 5);
int mtxidx = 2*(bpmem.tevind[n].mid-5);
WRITE(p, "float2 indtevtrans%d = "I_INDTEXMTX"[%d].ww * uv%d.xy * indtevcrd%d.xx;\n", n, mtxidx, texcoord, n);
}
else if (bpmem.tevind[n].mid <= 11 && bHasTexCoord)
{ // t matrix
- // TODO: Might become negative?
+ _assert_(bpmem.tevind[n].mid >= 9);
int mtxidx = 2*(bpmem.tevind[n].mid-9);
WRITE(p, "float2 indtevtrans%d = "I_INDTEXMTX"[%d].ww * uv%d.xy * indtevcrd%d.yy;\n", n, mtxidx, texcoord, n);
}
diff --git a/Source/Core/VideoCommon/Src/PixelShaderGen.h b/Source/Core/VideoCommon/Src/PixelShaderGen.h
index b24b656784..31242a916e 100644
--- a/Source/Core/VideoCommon/Src/PixelShaderGen.h
+++ b/Source/Core/VideoCommon/Src/PixelShaderGen.h
@@ -44,8 +44,8 @@
#define C_PLIGHTS (C_FOG + 3)
#define C_PMATERIALS (C_PLIGHTS + 40)
#define C_PENVCONST_END (C_PMATERIALS + 4)
-#define PIXELSHADERUID_MAX_VALUES 69
-#define PIXELSHADERUID_MAX_VALUES_SAFE 117
+#define PIXELSHADERUID_MAX_VALUES 70
+#define PIXELSHADERUID_MAX_VALUES_SAFE 120
// DO NOT make anything in this class virtual.
template<bool safe>
@@ -53,14 +53,10 @@ class _PIXELSHADERUID
{
public:
u32 values[safe ? PIXELSHADERUID_MAX_VALUES_SAFE : PIXELSHADERUID_MAX_VALUES];
- u16 num_values;
+ int num_values;
_PIXELSHADERUID()
{
- memset(values, 0, sizeof(values));
-
- if (safe) num_values = sizeof(values) / sizeof(values[0]);
- else num_values = 0;
}
_PIXELSHADERUID(const _PIXELSHADERUID& r)
@@ -119,13 +115,10 @@ enum DSTALPHA_MODE
const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType, u32 components);
-// TODO: Wtf, those need components as well! -.-
-void GetPixelShaderId(PIXELSHADERUID *uid, DSTALPHA_MODE dstAlphaMode);
-void GetSafePixelShaderId(PIXELSHADERUIDSAFE *uid, DSTALPHA_MODE dstAlphaMode);
+void GetPixelShaderId(PIXELSHADERUID *uid, DSTALPHA_MODE dstAlphaMode, u32 components);
+void GetSafePixelShaderId(PIXELSHADERUIDSAFE *uid, DSTALPHA_MODE dstAlphaMode, u32 components);
// Used to make sure that our optimized pixel shader IDs don't lose any possible shader code changes
void ValidatePixelShaderIDs(API_TYPE api, PIXELSHADERUIDSAFE old_id, const std::string& old_code, DSTALPHA_MODE dstAlphaMode, u32 components);
-extern PIXELSHADERUID last_pixel_shader_uid;
-
#endif // GCOGL_PIXELSHADER_H
diff --git a/Source/Core/VideoCommon/Src/VertexShaderGen.cpp b/Source/Core/VideoCommon/Src/VertexShaderGen.cpp
index 8400fde9a5..5076f9f044 100644
--- a/Source/Core/VideoCommon/Src/VertexShaderGen.cpp
+++ b/Source/Core/VideoCommon/Src/VertexShaderGen.cpp
@@ -26,12 +26,11 @@
#include "VertexShaderGen.h"
#include "VideoConfig.h"
-VERTEXSHADERUID last_vertex_shader_uid;
-
// Mash together all the inputs that contribute to the code of a generated vertex shader into
// a unique identifier, basically containing all the bits. Yup, it's a lot ....
void GetVertexShaderId(VERTEXSHADERUID *uid, u32 components)
{
+ memset(uid->values, 0, sizeof(uid->values));
uid->values[0] = components |
(xfregs.numTexGen.numTexGens << 23) |
(xfregs.numChan.numColorChans << 27) |
@@ -67,6 +66,7 @@ void GetVertexShaderId(VERTEXSHADERUID *uid, u32 components)
void GetSafeVertexShaderId(VERTEXSHADERUIDSAFE *uid, u32 components)
{
// Just store all used registers here without caring whether we need all bits or less.
+ memset(uid->values, 0, sizeof(uid->values));
u32* ptr = uid->values;
*ptr++ = components;
*ptr++ = xfregs.numTexGen.hex;
diff --git a/Source/Core/VideoCommon/Src/VertexShaderGen.h b/Source/Core/VideoCommon/Src/VertexShaderGen.h
index 0680be3c86..0c522286b1 100644
--- a/Source/Core/VideoCommon/Src/VertexShaderGen.h
+++ b/Source/Core/VideoCommon/Src/VertexShaderGen.h
@@ -57,7 +57,6 @@ public:
_VERTEXSHADERUID()
{
- memset(values, 0, sizeof(values));
}
_VERTEXSHADERUID(const _VERTEXSHADERUID& r)
@@ -116,6 +115,4 @@ void GetSafeVertexShaderId(VERTEXSHADERUIDSAFE *uid, u32 components);
// Used to make sure that our optimized vertex shader IDs don't lose any possible shader code changes
void ValidateVertexShaderIDs(API_TYPE api, VERTEXSHADERUIDSAFE old_id, const std::string& old_code, u32 components);
-extern VERTEXSHADERUID last_vertex_shader_uid;
-
#endif // GCOGL_VERTEXSHADER_H