ShaderGen: use cbuffers for D3D
This commit is contained in:
parent
fe9fcfdd07
commit
b0878c54b2
|
@ -221,6 +221,8 @@ static inline void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_T
|
||||||
|
|
||||||
if (ApiType == API_OPENGL)
|
if (ApiType == API_OPENGL)
|
||||||
out.Write("layout(std140%s) uniform PSBlock {\n", g_ActiveConfig.backend_info.bSupportsBindingLayout ? ", binding = 1" : "");
|
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_COLORS, "int4", I_COLORS"[4]");
|
||||||
DeclareUniform(out, ApiType, C_KCOLORS, "int4", I_KCOLORS"[4]");
|
DeclareUniform(out, ApiType, C_KCOLORS, "int4", I_KCOLORS"[4]");
|
||||||
|
@ -238,8 +240,7 @@ static inline void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_T
|
||||||
DeclareUniform(out, ApiType, C_PLIGHTS, "float4", I_PLIGHTS"[32]");
|
DeclareUniform(out, ApiType, C_PLIGHTS, "float4", I_PLIGHTS"[32]");
|
||||||
DeclareUniform(out, ApiType, C_PMATERIALS, "int4", I_PMATERIALS"[4]");
|
DeclareUniform(out, ApiType, C_PMATERIALS, "int4", I_PMATERIALS"[4]");
|
||||||
|
|
||||||
if (ApiType == API_OPENGL)
|
out.Write("};\n");
|
||||||
out.Write("};\n");
|
|
||||||
|
|
||||||
const bool forced_early_z = g_ActiveConfig.backend_info.bSupportsEarlyZ && bpmem.UseEarlyDepthTest() && (g_ActiveConfig.bFastDepthCalc || bpmem.alpha_test.TestResult() == AlphaTest::UNDETERMINED);
|
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);
|
const bool per_pixel_depth = (bpmem.ztex2.op != ZTEXTURE_DISABLE && bpmem.UseLateDepthTest()) || (!g_ActiveConfig.bFastDepthCalc && bpmem.zmode.testenable && !forced_early_z);
|
||||||
|
|
|
@ -151,31 +151,10 @@ private:
|
||||||
std::vector<bool> constant_usage; // TODO: Is vector<bool> appropriate here?
|
std::vector<bool> constant_usage; // TODO: Is vector<bool> appropriate here?
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class T>
|
|
||||||
static inline void WriteRegister(T& object, API_TYPE ApiType, const char *prefix, const u32 num)
|
|
||||||
{
|
|
||||||
if (ApiType == API_OPENGL)
|
|
||||||
return; // Nothing to do here
|
|
||||||
|
|
||||||
object.Write(" : register(%s%d)", prefix, num);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
static inline void WriteLocation(T& object, API_TYPE ApiType)
|
|
||||||
{
|
|
||||||
if (ApiType == API_OPENGL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
object.Write("uniform ");
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
static inline void DeclareUniform(T& object, API_TYPE api_type, const u32 num, const char* type, const char* name)
|
static inline void DeclareUniform(T& object, API_TYPE api_type, const u32 num, const char* type, const char* name)
|
||||||
{
|
{
|
||||||
WriteLocation(object, api_type);
|
object.Write("%s %s;\n", type, name);
|
||||||
object.Write("%s %s ", type, name);
|
|
||||||
WriteRegister(object, api_type, "c", num);
|
|
||||||
object.Write(";\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -84,6 +84,8 @@ static inline void GenerateVertexShader(T& out, u32 components, API_TYPE api_typ
|
||||||
// uniforms
|
// uniforms
|
||||||
if (api_type == API_OPENGL)
|
if (api_type == API_OPENGL)
|
||||||
out.Write("layout(std140%s) uniform VSBlock {\n", g_ActiveConfig.backend_info.bSupportsBindingLayout ? ", binding = 2" : "");
|
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_POSNORMALMATRIX, "float4", I_POSNORMALMATRIX"[6]");
|
||||||
DeclareUniform(out, api_type, C_PROJECTION, "float4", I_PROJECTION"[4]");
|
DeclareUniform(out, api_type, C_PROJECTION, "float4", I_PROJECTION"[4]");
|
||||||
|
@ -96,8 +98,7 @@ static inline void GenerateVertexShader(T& out, u32 components, API_TYPE api_typ
|
||||||
DeclareUniform(out, api_type, C_POSTTRANSFORMMATRICES, "float4", I_POSTTRANSFORMMATRICES"[64]");
|
DeclareUniform(out, api_type, C_POSTTRANSFORMMATRICES, "float4", I_POSTTRANSFORMMATRICES"[64]");
|
||||||
DeclareUniform(out, api_type, C_DEPTHPARAMS, "float4", I_DEPTHPARAMS);
|
DeclareUniform(out, api_type, C_DEPTHPARAMS, "float4", I_DEPTHPARAMS);
|
||||||
|
|
||||||
if (api_type == API_OPENGL)
|
out.Write("};\n");
|
||||||
out.Write("};\n");
|
|
||||||
|
|
||||||
GenerateVSOutputStruct(out, api_type);
|
GenerateVSOutputStruct(out, api_type);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue