summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authordegasus <wickmarkus@web.de>2014-03-17 10:29:32 +0100
committerdegasus <wickmarkus@web.de>2014-05-05 17:06:37 +0200
commitc82991df5ba360986f18cfee32c34405f65df09f (patch)
tree57df5cc8c0081714a206b48a876731d76de70164 /Source
parentb0878c54b2a2ee1e0fd45f037562a9a6a61d919c (diff)
ShaderGen: inline constant shaders
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/VideoCommon/PixelShaderGen.cpp35
-rw-r--r--Source/Core/VideoCommon/ShaderGenCommon.h7
-rw-r--r--Source/Core/VideoCommon/VertexShaderGen.cpp25
3 files changed, 29 insertions, 38 deletions
diff --git a/Source/Core/VideoCommon/PixelShaderGen.cpp b/Source/Core/VideoCommon/PixelShaderGen.cpp
index ec58c606f1..3ce0403f6c 100644
--- a/Source/Core/VideoCommon/PixelShaderGen.cpp
+++ b/Source/Core/VideoCommon/PixelShaderGen.cpp
@@ -223,24 +223,23 @@ static inline void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_T
out.Write("layout(std140%s) uniform PSBlock {\n", g_ActiveConfig.backend_info.bSupportsBindingLayout ? ", binding = 1" : "");
else
out.Write("cbuffer PSBlock {\n");
-
- DeclareUniform(out, ApiType, C_COLORS, "int4", I_COLORS"[4]");
- DeclareUniform(out, ApiType, C_KCOLORS, "int4", I_KCOLORS"[4]");
- DeclareUniform(out, ApiType, C_ALPHA, "int4", I_ALPHA);
- DeclareUniform(out, ApiType, C_TEXDIMS, "float4", I_TEXDIMS"[8]");
- DeclareUniform(out, ApiType, C_ZBIAS, "int4", I_ZBIAS"[2]");
- DeclareUniform(out, ApiType, C_INDTEXSCALE, "int4", I_INDTEXSCALE"[2]");
- DeclareUniform(out, ApiType, C_INDTEXMTX, "int4", I_INDTEXMTX"[6]");
- DeclareUniform(out, ApiType, C_FOGCOLOR, "int4", I_FOGCOLOR);
- DeclareUniform(out, ApiType, C_FOGI, "int4", I_FOGI);
- DeclareUniform(out, ApiType, C_FOGF, "float4", I_FOGF"[2]");
-
- // For pixel lighting - TODO: Should only be defined when per pixel lighting is enabled!
- DeclareUniform(out, ApiType, C_PLIGHT_COLORS, "int4", I_PLIGHT_COLORS"[8]");
- DeclareUniform(out, ApiType, C_PLIGHTS, "float4", I_PLIGHTS"[32]");
- DeclareUniform(out, ApiType, C_PMATERIALS, "int4", I_PMATERIALS"[4]");
-
- out.Write("};\n");
+ out.Write(
+ "\tint4 " I_COLORS"[4];\n"
+ "\tint4 " I_KCOLORS"[4];\n"
+ "\tint4 " I_ALPHA";\n"
+ "\tfloat4 " I_TEXDIMS"[8];\n"
+ "\tint4 " I_ZBIAS"[2];\n"
+ "\tint4 " I_INDTEXSCALE"[2];\n"
+ "\tint4 " I_INDTEXMTX"[6];\n"
+ "\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");
const bool forced_early_z = g_ActiveConfig.backend_info.bSupportsEarlyZ && bpmem.UseEarlyDepthTest() && (g_ActiveConfig.bFastDepthCalc || bpmem.alpha_test.TestResult() == AlphaTest::UNDETERMINED);
const bool per_pixel_depth = (bpmem.ztex2.op != ZTEXTURE_DISABLE && bpmem.UseLateDepthTest()) || (!g_ActiveConfig.bFastDepthCalc && bpmem.zmode.testenable && !forced_early_z);
diff --git a/Source/Core/VideoCommon/ShaderGenCommon.h b/Source/Core/VideoCommon/ShaderGenCommon.h
index bf9b382633..5b79f30221 100644
--- a/Source/Core/VideoCommon/ShaderGenCommon.h
+++ b/Source/Core/VideoCommon/ShaderGenCommon.h
@@ -150,13 +150,6 @@ public:
private:
std::vector<bool> constant_usage; // TODO: Is vector<bool> appropriate here?
};
-
-template<class T>
-static inline void DeclareUniform(T& object, API_TYPE api_type, const u32 num, const char* type, const char* name)
-{
- object.Write("%s %s;\n", type, name);
-}
-
/**
* Checks if there has been
*/
diff --git a/Source/Core/VideoCommon/VertexShaderGen.cpp b/Source/Core/VideoCommon/VertexShaderGen.cpp
index 05d67ed8e5..32bd8ae9fb 100644
--- a/Source/Core/VideoCommon/VertexShaderGen.cpp
+++ b/Source/Core/VideoCommon/VertexShaderGen.cpp
@@ -86,19 +86,18 @@ static inline void GenerateVertexShader(T& out, u32 components, API_TYPE api_typ
out.Write("layout(std140%s) uniform VSBlock {\n", g_ActiveConfig.backend_info.bSupportsBindingLayout ? ", binding = 2" : "");
else
out.Write("cbuffer VSBlock {\n");
-
- DeclareUniform(out, api_type, C_POSNORMALMATRIX, "float4", I_POSNORMALMATRIX"[6]");
- DeclareUniform(out, api_type, C_PROJECTION, "float4", I_PROJECTION"[4]");
- DeclareUniform(out, api_type, C_MATERIALS, "int4", I_MATERIALS"[4]");
- DeclareUniform(out, api_type, C_LIGHT_COLORS, "int4", I_LIGHT_COLORS"[8]");
- DeclareUniform(out, api_type, C_LIGHTS, "float4", I_LIGHTS"[32]");
- DeclareUniform(out, api_type, C_TEXMATRICES, "float4", I_TEXMATRICES"[24]");
- DeclareUniform(out, api_type, C_TRANSFORMMATRICES, "float4", I_TRANSFORMMATRICES"[64]");
- DeclareUniform(out, api_type, C_NORMALMATRICES, "float4", I_NORMALMATRICES"[32]");
- DeclareUniform(out, api_type, C_POSTTRANSFORMMATRICES, "float4", I_POSTTRANSFORMMATRICES"[64]");
- DeclareUniform(out, api_type, C_DEPTHPARAMS, "float4", I_DEPTHPARAMS);
-
- out.Write("};\n");
+ out.Write(
+ "\tfloat4 " I_POSNORMALMATRIX"[6];\n"
+ "\tfloat4 " I_PROJECTION"[4];\n"
+ "\tint4 " I_MATERIALS"[4];\n"
+ "\tint4 " I_LIGHT_COLORS"[8];\n"
+ "\tfloat4 " I_LIGHTS"[32];\n"
+ "\tfloat4 " I_TEXMATRICES"[24];\n"
+ "\tfloat4 " I_TRANSFORMMATRICES"[64];\n"
+ "\tfloat4 " I_NORMALMATRICES"[32];\n"
+ "\tfloat4 " I_POSTTRANSFORMMATRICES"[64];\n"
+ "\tfloat4 " I_DEPTHPARAMS";\n"
+ "};\n");
GenerateVSOutputStruct(out, api_type);