mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-15 13:57:57 -07:00
PixelShaderManager: Disable constant cache (won't work in the non-UBO path of the opengl backend).
ShaderGen: Replace typeid usage with more general code.
This commit is contained in:
parent
b2517c0308
commit
3c02f227db
@ -28,7 +28,7 @@
|
||||
template<class T,class UidType>
|
||||
void GenerateLightShader(T& object, int index, int litchan_index, const char* lightsName, int coloralpha)
|
||||
{
|
||||
#define SetUidField(name, value) if (typeid(T) == typeid(UidType)) { object.GetUidData().name = value; };
|
||||
#define SetUidField(name, value) if (&object.GetUidData() != NULL) { object.GetUidData().name = value; };
|
||||
const LitChannel& chan = (litchan_index > 1) ? xfregs.alpha[litchan_index-2] : xfregs.color[litchan_index];
|
||||
const char* swizzle = "xyzw";
|
||||
if (coloralpha == 1 ) swizzle = "xyz";
|
||||
|
@ -19,7 +19,6 @@
|
||||
#include <cmath>
|
||||
#include <assert.h>
|
||||
#include <locale.h>
|
||||
#include <typeinfo>
|
||||
|
||||
#include "LightingShaderGen.h"
|
||||
#include "PixelShaderGen.h"
|
||||
@ -271,13 +270,12 @@ template<class T>
|
||||
void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType, u32 components)
|
||||
{
|
||||
// TODO: Can be optimized if using alpha pass
|
||||
#define SetUidField(name, value) if (typeid(T) == typeid(PixelShaderUid)) {out.GetUidData().name = value; };
|
||||
#define OR_UidField(name, value) if (typeid(T) == typeid(PixelShaderUid)) {out.GetUidData().name |= value; };
|
||||
if (typeid(T) == typeid(PixelShaderCode))
|
||||
{
|
||||
setlocale(LC_NUMERIC, "C"); // Reset locale for compilation
|
||||
#define SetUidField(name, value) if (&out.GetUidData() != NULL) {out.GetUidData().name = value; };
|
||||
#define OR_UidField(name, value) if (&out.GetUidData() != NULL) {out.GetUidData().name |= value; };
|
||||
out.SetBuffer(text);
|
||||
}
|
||||
if (out.GetBuffer() != NULL)
|
||||
setlocale(LC_NUMERIC, "C"); // Reset locale for compilation
|
||||
|
||||
/// text[sizeof(text) - 1] = 0x7C; // canary
|
||||
|
||||
unsigned int numStages = bpmem.genMode.numtevstages + 1;
|
||||
@ -669,6 +667,7 @@ void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType, u
|
||||
/// if (text[sizeof(text) - 1] != 0x7C)
|
||||
/// PanicAlert("PixelShader generator - buffer too small, canary has been eaten!");
|
||||
|
||||
if (out.GetBuffer() != NULL)
|
||||
setlocale(LC_NUMERIC, ""); // restore locale
|
||||
}
|
||||
|
||||
|
@ -46,9 +46,9 @@ static float s_constant_cache[C_PENVCONST_END*4];
|
||||
|
||||
inline void SetPSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4)
|
||||
{
|
||||
if (s_constant_cache[const_number*4] == f1 && s_constant_cache[const_number*4+1] == f2 &&
|
||||
s_constant_cache[const_number*4+2] == f3 && s_constant_cache[const_number*4+3] == f4)
|
||||
return;
|
||||
// if (s_constant_cache[const_number*4] == f1 && s_constant_cache[const_number*4+1] == f2 &&
|
||||
// s_constant_cache[const_number*4+2] == f3 && s_constant_cache[const_number*4+3] == f4)
|
||||
// return;
|
||||
|
||||
g_renderer->SetPSConstant4f(const_number, f1, f2, f3, f4);
|
||||
s_constant_cache[const_number*4] = f1;
|
||||
@ -59,9 +59,9 @@ inline void SetPSConstant4f(unsigned int const_number, float f1, float f2, float
|
||||
|
||||
inline void SetPSConstant4fv(unsigned int const_number, const float *f)
|
||||
{
|
||||
if (s_constant_cache[const_number*4] == f[0] && s_constant_cache[const_number*4+1] == f[1] &&
|
||||
s_constant_cache[const_number*4+2] == f[2] && s_constant_cache[const_number*4+3] == f[3])
|
||||
return;
|
||||
// if (s_constant_cache[const_number*4] == f[0] && s_constant_cache[const_number*4+1] == f[1] &&
|
||||
// s_constant_cache[const_number*4+2] == f[2] && s_constant_cache[const_number*4+3] == f[3])
|
||||
// return;
|
||||
|
||||
g_renderer->SetPSConstant4fv(const_number, f);
|
||||
s_constant_cache[const_number*4] = f[0];
|
||||
@ -72,11 +72,11 @@ inline void SetPSConstant4fv(unsigned int const_number, const float *f)
|
||||
|
||||
inline void SetMultiPSConstant4fv(unsigned int const_number, unsigned int count, const float *f)
|
||||
{
|
||||
for (unsigned int i = 0; i < 4*count; ++i)
|
||||
if (s_constant_cache[const_number*4+i] != f[i])
|
||||
break;
|
||||
else if (i == 4*count-1)
|
||||
return;
|
||||
// for (unsigned int i = 0; i < 4*count; ++i)
|
||||
// if (s_constant_cache[const_number*4+i] != f[i])
|
||||
// break;
|
||||
// else if (i == 4*count-1)
|
||||
// return;
|
||||
|
||||
g_renderer->SetMultiPSConstant4fv(const_number, count, f);
|
||||
for (unsigned int i = 0; i < 4*count; ++i)
|
||||
@ -149,7 +149,7 @@ void PixelShaderManager::SetConstants(u32 components)
|
||||
{
|
||||
for (int i = 0; i < 8; ++i)
|
||||
{
|
||||
if (s_nTexDimsChanged & (1<<i) && constant_profile.ConstantIsUsed(C_TEXDIMS+i))
|
||||
if ((s_nTexDimsChanged & (1<<i)) && constant_profile.ConstantIsUsed(C_TEXDIMS+i))
|
||||
{
|
||||
++necessary_updates;
|
||||
SetPSTextureDims(i);
|
||||
|
@ -33,7 +33,7 @@ public:
|
||||
const char* GetBuffer() { return NULL; }
|
||||
void SetBuffer(char* buffer) { }
|
||||
inline void SetConstantsUsed(unsigned int first_index, unsigned int last_index) {}
|
||||
uid_data& GetUidData() { return *(uid_data*)NULL; }
|
||||
uid_data& GetUidData() { return *(uid_data*)NULL; } // TODO: can be moved out, just make this GetUidData<T> instead
|
||||
};
|
||||
|
||||
template<class uid_data>
|
||||
@ -122,7 +122,8 @@ public:
|
||||
|
||||
inline bool ConstantIsUsed(unsigned int index)
|
||||
{
|
||||
return constant_usage[index];
|
||||
return true;
|
||||
// return constant_usage[index];
|
||||
}
|
||||
private:
|
||||
std::vector<bool> constant_usage; // TODO: Is vector<bool> appropriate here?
|
||||
|
@ -17,7 +17,6 @@
|
||||
|
||||
#include <math.h>
|
||||
#include <locale.h>
|
||||
#include <typeinfo>
|
||||
|
||||
#include "NativeVertexFormat.h"
|
||||
|
||||
@ -85,14 +84,11 @@ template<class T>
|
||||
void GenerateVertexShader(T& out, u32 components, API_TYPE api_type)
|
||||
{
|
||||
#undef SetUidField
|
||||
#define SetUidField(name, value) if (typeid(T) == typeid(VertexShaderUid)) {out.GetUidData().name = value; };
|
||||
#define SetUidField(name, value) if (&out.GetUidData() != NULL) {out.GetUidData().name = value; };
|
||||
|
||||
if (typeid(T) == typeid(VertexShaderCode))
|
||||
{
|
||||
out.SetBuffer(text);
|
||||
if (out.GetBuffer() != NULL)
|
||||
setlocale(LC_NUMERIC, "C"); // Reset locale for compilation
|
||||
}
|
||||
|
||||
|
||||
// text[sizeof(text) - 1] = 0x7C; // canary
|
||||
|
||||
@ -523,7 +519,7 @@ void GenerateVertexShader(T& out, u32 components, API_TYPE api_type)
|
||||
|
||||
/// if (text[sizeof(text) - 1] != 0x7C)
|
||||
/// PanicAlert("VertexShader generator - buffer too small, canary has been eaten!");
|
||||
if (typeid(T) == typeid(VertexShaderCode))
|
||||
if (out.GetBuffer() != NULL)
|
||||
setlocale(LC_NUMERIC, ""); // restore locale
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user