mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-15 05:47:56 -07:00
ShaderGen: Optimize out most function calls for uid generation.
This commit is contained in:
parent
fe2ca814c5
commit
c05aa0141d
@ -243,16 +243,18 @@ static inline void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_T
|
||||
? out.template GetUidData<pixel_shader_uid_data>() : dummy_data;
|
||||
|
||||
out.SetBuffer(text);
|
||||
const bool is_writing_shadercode = (out.GetBuffer() != NULL);
|
||||
#ifndef ANDROID
|
||||
locale_t locale;
|
||||
locale_t old_locale;
|
||||
if (out.GetBuffer() != NULL)
|
||||
if (is_writing_shadercode)
|
||||
{
|
||||
locale = newlocale(LC_NUMERIC_MASK, "C", NULL); // New locale for compilation
|
||||
old_locale = uselocale(locale); // Apply the locale for this thread
|
||||
}
|
||||
#endif
|
||||
|
||||
if (is_writing_shadercode)
|
||||
text[sizeof(text) - 1] = 0x7C; // canary
|
||||
|
||||
unsigned int numStages = bpmem.genMode.numtevstages + 1;
|
||||
@ -372,7 +374,7 @@ static inline void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_T
|
||||
// It just allows it, but it seems that all drivers do.
|
||||
out.Write("layout(early_fragment_tests) in;\n");
|
||||
}
|
||||
else if (bpmem.UseEarlyDepthTest() && (g_ActiveConfig.bFastDepthCalc || bpmem.alpha_test.TestResult() == AlphaTest::UNDETERMINED))
|
||||
else if (bpmem.UseEarlyDepthTest() && (g_ActiveConfig.bFastDepthCalc || bpmem.alpha_test.TestResult() == AlphaTest::UNDETERMINED) && is_writing_shadercode)
|
||||
{
|
||||
static bool warn_once = true;
|
||||
if (warn_once)
|
||||
@ -388,7 +390,7 @@ static inline void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_T
|
||||
{
|
||||
out.Write("[earlydepthstencil]\n");
|
||||
}
|
||||
else if (bpmem.UseEarlyDepthTest() && (g_ActiveConfig.bFastDepthCalc || bpmem.alpha_test.TestResult() == AlphaTest::UNDETERMINED))
|
||||
else if (bpmem.UseEarlyDepthTest() && (g_ActiveConfig.bFastDepthCalc || bpmem.alpha_test.TestResult() == AlphaTest::UNDETERMINED) && is_writing_shadercode)
|
||||
{
|
||||
static bool warn_once = true;
|
||||
if (warn_once)
|
||||
@ -705,16 +707,16 @@ static inline void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_T
|
||||
|
||||
out.Write("}\n");
|
||||
|
||||
if (is_writing_shadercode)
|
||||
{
|
||||
if (text[sizeof(text) - 1] != 0x7C)
|
||||
PanicAlert("PixelShader generator - buffer too small, canary has been eaten!");
|
||||
|
||||
#ifndef ANDROID
|
||||
if (out.GetBuffer() != NULL)
|
||||
{
|
||||
uselocale(old_locale); // restore locale
|
||||
freelocale(locale);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1273,7 +1275,7 @@ static inline void WriteFog(T& out, pixel_shader_uid_data& uid_data)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bpmem.fog.c_proj_fsel.fsel != 2)
|
||||
if (bpmem.fog.c_proj_fsel.fsel != 2 && out.GetBuffer() != NULL)
|
||||
WARN_LOG(VIDEO, "Unknown Fog Type! %08x", bpmem.fog.c_proj_fsel.fsel);
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
static char text[16768];
|
||||
|
||||
template<class T>
|
||||
static inline void DefineVSOutputStructMember(T& object, API_TYPE api_type, const char* type, const char* name, int var_index, const char* semantic, int semantic_index = -1)
|
||||
static void DefineVSOutputStructMember(T& object, API_TYPE api_type, const char* type, const char* name, int var_index, const char* semantic, int semantic_index = -1)
|
||||
{
|
||||
object.Write(" %s %s", type, name);
|
||||
if (var_index != -1)
|
||||
@ -75,15 +75,18 @@ static inline void GenerateVertexShader(T& out, u32 components, API_TYPE api_typ
|
||||
? out.template GetUidData<vertex_shader_uid_data>() : dummy_data;
|
||||
|
||||
out.SetBuffer(text);
|
||||
const bool is_writing_shadercode = (out.GetBuffer() != NULL);
|
||||
#ifndef ANDROID
|
||||
locale_t locale;
|
||||
locale_t old_locale;
|
||||
if (out.GetBuffer() != NULL)
|
||||
if (is_writing_shadercode)
|
||||
{
|
||||
locale = newlocale(LC_NUMERIC_MASK, "C", NULL); // New locale for compilation
|
||||
old_locale = uselocale(locale); // Apply the locale for this thread
|
||||
}
|
||||
#endif
|
||||
|
||||
if (is_writing_shadercode)
|
||||
text[sizeof(text) - 1] = 0x7C; // canary
|
||||
|
||||
_assert_(bpmem.genMode.numtexgens == xfregs.numTexGen.numTexGens);
|
||||
@ -225,7 +228,7 @@ static inline void GenerateVertexShader(T& out, u32 components, API_TYPE api_typ
|
||||
out.Write("int posmtx = int(fposmtx);\n");
|
||||
}
|
||||
|
||||
if (DriverDetails::HasBug(DriverDetails::BUG_NODYNUBOACCESS))
|
||||
if (is_writing_shadercode && DriverDetails::HasBug(DriverDetails::BUG_NODYNUBOACCESS))
|
||||
{
|
||||
// This'll cause issues, but it can't be helped
|
||||
out.Write("float4 pos = float4(dot(" I_TRANSFORMMATRICES"[0], rawpos), dot(" I_TRANSFORMMATRICES"[1], rawpos), dot(" I_TRANSFORMMATRICES"[2], rawpos), 1);\n");
|
||||
@ -547,16 +550,16 @@ static inline void GenerateVertexShader(T& out, u32 components, API_TYPE api_typ
|
||||
out.Write("return o;\n}\n");
|
||||
}
|
||||
|
||||
if (is_writing_shadercode)
|
||||
{
|
||||
if (text[sizeof(text) - 1] != 0x7C)
|
||||
PanicAlert("VertexShader generator - buffer too small, canary has been eaten!");
|
||||
|
||||
#ifndef ANDROID
|
||||
if (out.GetBuffer() != NULL)
|
||||
{
|
||||
uselocale(old_locale); // restore locale
|
||||
freelocale(locale);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void GetVertexShaderUid(VertexShaderUid& object, u32 components, API_TYPE api_type)
|
||||
|
Loading…
Reference in New Issue
Block a user