ShaderGen: inline constant shaders
This commit is contained in:
parent
b0878c54b2
commit
c82991df5b
|
@ -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");
|
||||
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"
|
||||
|
||||
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");
|
||||
// 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);
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue