mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-12-01 00:21:43 +00:00
- only use shader cache on Intel
This commit is contained in:
parent
48fd91227c
commit
b4aa4bf0ac
2 changed files with 24 additions and 5 deletions
|
@ -56,10 +56,24 @@ struct ProgramBinary
|
|||
TArray<uint8_t> data;
|
||||
};
|
||||
|
||||
const char *ShaderMagic = "ZDSC";
|
||||
static const char *ShaderMagic = "ZDSC";
|
||||
|
||||
static std::map<FString, std::unique_ptr<ProgramBinary>> ShaderCache; // Not a TMap because it doesn't support unique_ptr move semantics
|
||||
|
||||
bool IsShaderCacheActive()
|
||||
{
|
||||
static bool active = true;
|
||||
static bool firstcall = true;
|
||||
|
||||
if (firstcall)
|
||||
{
|
||||
const char *vendor = (const char *)glGetString(GL_VENDOR);
|
||||
active = strstr(vendor, "Intel") == nullptr;
|
||||
firstcall = false;
|
||||
}
|
||||
return active;
|
||||
}
|
||||
|
||||
static FString CalcProgramBinaryChecksum(const FString &vertex, const FString &fragment)
|
||||
{
|
||||
const GLubyte *vendor = glGetString(GL_VENDOR);
|
||||
|
@ -421,7 +435,9 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
|
|||
FGLDebug::LabelObject(GL_PROGRAM, hShader, name);
|
||||
|
||||
uint32_t binaryFormat = 0;
|
||||
TArray<uint8_t> binary = LoadCachedProgramBinary(vp_comb, fp_comb, binaryFormat);
|
||||
TArray<uint8_t> binary;
|
||||
if (IsShaderCacheActive())
|
||||
binary = LoadCachedProgramBinary(vp_comb, fp_comb, binaryFormat);
|
||||
|
||||
bool linked = false;
|
||||
if (binary.Size() > 0 && glProgramBinary)
|
||||
|
@ -481,7 +497,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
|
|||
// only print message if there's an error.
|
||||
I_Error("Init Shader '%s':\n%s\n", name, error.GetChars());
|
||||
}
|
||||
else if (glProgramBinary)
|
||||
else if (glProgramBinary && IsShaderCacheActive())
|
||||
{
|
||||
int binaryLength = 0;
|
||||
glGetProgramiv(hShader, GL_PROGRAM_BINARY_LENGTH, &binaryLength);
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
namespace OpenGLRenderer
|
||||
{
|
||||
|
||||
bool IsShaderCacheActive();
|
||||
TArray<uint8_t> LoadCachedProgramBinary(const FString &vertex, const FString &fragment, uint32_t &binaryFormat);
|
||||
void SaveCachedProgramBinary(const FString &vertex, const FString &fragment, const TArray<uint8_t> &binary, uint32_t binaryFormat);
|
||||
|
||||
|
@ -142,7 +143,9 @@ void FShaderProgram::Link(const char *name)
|
|||
FGLDebug::LabelObject(GL_PROGRAM, mProgram, name);
|
||||
|
||||
uint32_t binaryFormat = 0;
|
||||
TArray<uint8_t> binary = LoadCachedProgramBinary(mShaderSources[Vertex], mShaderSources[Fragment], binaryFormat);
|
||||
TArray<uint8_t> binary;
|
||||
if (IsShaderCacheActive())
|
||||
binary = LoadCachedProgramBinary(mShaderSources[Vertex], mShaderSources[Fragment], binaryFormat);
|
||||
|
||||
bool loadedFromBinary = false;
|
||||
if (binary.Size() > 0 && glProgramBinary)
|
||||
|
@ -168,7 +171,7 @@ void FShaderProgram::Link(const char *name)
|
|||
{
|
||||
I_FatalError("Link Shader '%s':\n%s\n", name, GetProgramInfoLog(mProgram).GetChars());
|
||||
}
|
||||
else if (glProgramBinary)
|
||||
else if (glProgramBinary && IsShaderCacheActive())
|
||||
{
|
||||
int binaryLength = 0;
|
||||
glGetProgramiv(mProgram, GL_PROGRAM_BINARY_LENGTH, &binaryLength);
|
||||
|
|
Loading…
Reference in a new issue