Suppress debug messages when trying to make separable prorgams

* We half-expect the first attempt to fail, and we want to ignore any
  debug message spew from that failed compilation - if we fail after
  patching, we print out the output log then.
This commit is contained in:
baldurk
2016-07-28 20:40:25 +02:00
parent f8a915165f
commit 74c09d064b
5 changed files with 49 additions and 29 deletions
+1
View File
@@ -728,6 +728,7 @@ WrappedOpenGL::WrappedOpenGL(const char *logfile, const GLHookSet &funcs) : m_Re
m_RealDebugFunc = NULL;
m_RealDebugFuncParam = NULL;
m_SuppressDebugMessages = false;
m_DrawcallStack.push_back(&m_ParentDrawcall);
+11 -3
View File
@@ -114,7 +114,6 @@ private:
friend class GLReplay;
friend class GLResourceManager;
const GLHookSet &GetHookset() { return m_Real; }
vector<DebugMessage> m_DebugMessages;
void Serialise_DebugMessages();
vector<DebugMessage> GetDebugMessages();
@@ -123,12 +122,19 @@ private:
const void *m_RealDebugFuncParam;
string m_DebugMsgContext;
bool m_SuppressDebugMessages;
void DebugSnoop(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length,
const GLchar *message);
static void APIENTRY DebugSnoopStatic(GLenum source, GLenum type, GLuint id, GLenum severity,
GLsizei length, const GLchar *message, const void *userParam)
{
((WrappedOpenGL *)userParam)->DebugSnoop(source, type, id, severity, length, message);
WrappedOpenGL *me = (WrappedOpenGL *)userParam;
if(me->m_SuppressDebugMessages)
return;
me->DebugSnoop(source, type, id, severity, length, message);
}
// checks if the given object has tons of updates. If so it's probably
@@ -276,7 +282,7 @@ private:
ShaderReflection reflection;
GLuint prog;
void Compile(const GLHookSet &gl);
void Compile(WrappedOpenGL &gl);
};
struct ProgramData
@@ -481,6 +487,7 @@ public:
GLReplay *GetReplay() { return &m_Replay; }
void *GetCtx();
const GLHookSet &GetHookset() { return m_Real; }
void SetDebugMsgContext(const char *context) { m_DebugMsgContext = context; }
void AddDebugMessage(DebugMessage msg)
{
@@ -504,6 +511,7 @@ public:
const DrawcallTreeNode &GetRootDraw() { return m_ParentDrawcall; }
const FetchDrawcall *GetDrawcall(uint32_t eventID);
void SuppressDebugMessages(bool suppress) { m_SuppressDebugMessages = suppress; }
vector<EventUsage> GetUsage(ResourceId id) { return m_ResourceUses[id]; }
void CreateContext(GLWindowingData winData, void *shareContext, GLInitParams initParams,
bool core, bool attribsCreate);
+23 -14
View File
@@ -24,6 +24,7 @@
#include "gl_shader_refl.h"
#include <algorithm>
#include "gl_driver.h"
// declare versions of ShaderConstant/ShaderVariableType with vectors
// to more easily build up the members of nested structures
@@ -169,43 +170,51 @@ void CheckVertexOutputUses(const vector<string> &sources, bool &pointSizeUsed, b
// little utility function that if necessary emulates glCreateShaderProgramv functionality but using
// glCompileShaderIncludeARB
static GLuint CreateSepProgram(const GLHookSet &gl, GLenum type, GLsizei numSources,
static GLuint CreateSepProgram(WrappedOpenGL &gl, GLenum type, GLsizei numSources,
const char **sources, GLsizei numPaths, const char **paths)
{
// by the nature of this function, it might fail - we don't want to spew
// false positive looking messages into the log.
gl.SuppressDebugMessages(true);
const GLHookSet &real = gl.GetHookset();
GLuint program = 0;
// definition of glCreateShaderProgramv from the spec
GLuint shader = gl.glCreateShader(type);
GLuint shader = real.glCreateShader(type);
if(shader)
{
gl.glShaderSource(shader, numSources, sources, NULL);
real.glShaderSource(shader, numSources, sources, NULL);
if(paths == NULL)
gl.glCompileShader(shader);
real.glCompileShader(shader);
else
gl.glCompileShaderIncludeARB(shader, numPaths, paths, NULL);
real.glCompileShaderIncludeARB(shader, numPaths, paths, NULL);
GLuint program = gl.glCreateProgram();
program = real.glCreateProgram();
if(program)
{
GLint compiled = 0;
gl.glGetShaderiv(shader, eGL_COMPILE_STATUS, &compiled);
gl.glProgramParameteri(program, eGL_PROGRAM_SEPARABLE, GL_TRUE);
real.glGetShaderiv(shader, eGL_COMPILE_STATUS, &compiled);
real.glProgramParameteri(program, eGL_PROGRAM_SEPARABLE, GL_TRUE);
if(compiled)
{
gl.glAttachShader(program, shader);
gl.glLinkProgram(program);
real.glAttachShader(program, shader);
real.glLinkProgram(program);
// we deliberately leave the shaders attached so this program can be re-linked.
// they will be cleaned up when the program is deleted
// gl.glDetachShader(program, shader);
}
}
gl.glDeleteShader(shader);
return program;
real.glDeleteShader(shader);
}
return 0;
gl.SuppressDebugMessages(false);
return program;
}
static bool isspacetab(char c)
@@ -223,7 +232,7 @@ static bool iswhitespace(char c)
return isspacetab(c) || isnewline(c);
}
GLuint MakeSeparableShaderProgram(const GLHookSet &gl, GLenum type, vector<string> sources,
GLuint MakeSeparableShaderProgram(WrappedOpenGL &gl, GLenum type, vector<string> sources,
vector<string> *includepaths)
{
// in and out blocks are added separately, in case one is there already
+4 -2
View File
@@ -25,9 +25,11 @@
#include "replay/replay_driver.h"
#include "gl_hookset.h"
class WrappedOpenGL;
void MakeShaderReflection(const GLHookSet &gl, GLenum shadType, GLuint sepProg,
ShaderReflection &refl, bool pointSizeUsed, bool clipDistanceUsed);
GLuint MakeSeparableShaderProgram(const GLHookSet &gl, GLenum type,
std::vector<std::string> sources, vector<string> *includepaths);
GLuint MakeSeparableShaderProgram(WrappedOpenGL &gl, GLenum type, std::vector<std::string> sources,
vector<string> *includepaths);
void CheckVertexOutputUses(const std::vector<std::string> &sources, bool &pointSizeUsed,
bool &clipDistanceUsed);
@@ -29,7 +29,7 @@
#include "driver/shaders/spirv/spirv_common.h"
#include "serialise/string_utils.h"
void WrappedOpenGL::ShaderData::Compile(const GLHookSet &gl)
void WrappedOpenGL::ShaderData::Compile(WrappedOpenGL &gl)
{
bool pointSizeUsed = false, clipDistanceUsed = false;
if(type == eGL_VERTEX_SHADER)
@@ -48,7 +48,7 @@ void WrappedOpenGL::ShaderData::Compile(const GLHookSet &gl)
else
{
prog = sepProg;
MakeShaderReflection(gl, type, sepProg, reflection, pointSizeUsed, clipDistanceUsed);
MakeShaderReflection(gl.GetHookset(), type, sepProg, reflection, pointSizeUsed, clipDistanceUsed);
vector<uint32_t> spirvwords;
@@ -203,7 +203,7 @@ bool WrappedOpenGL::Serialise_glCompileShader(GLuint shader)
{
ResourceId liveId = GetResourceManager()->GetLiveID(id);
m_Shaders[liveId].Compile(m_Real);
m_Shaders[liveId].Compile(*this);
m_Real.glCompileShader(GetResourceManager()->GetLiveResource(id).name);
}
@@ -228,7 +228,7 @@ void WrappedOpenGL::glCompileShader(GLuint shader)
}
else
{
m_Shaders[GetResourceManager()->GetID(ShaderRes(GetCtx(), shader))].Compile(m_Real);
m_Shaders[GetResourceManager()->GetID(ShaderRes(GetCtx(), shader))].Compile(*this);
}
}
@@ -398,7 +398,7 @@ bool WrappedOpenGL::Serialise_glCreateShaderProgramv(GLuint program, GLenum type
GLuint real = m_Real.glCreateShaderProgramv(Type, Count, sources);
// we want a separate program that we can mess about with for making overlays
// and relink without having to worry about restoring the 'real' program state.
GLuint sepprog = MakeSeparableShaderProgram(m_Real, Type, src, NULL);
GLuint sepprog = MakeSeparableShaderProgram(*this, Type, src, NULL);
delete[] sources;
@@ -418,7 +418,7 @@ bool WrappedOpenGL::Serialise_glCreateShaderProgramv(GLuint program, GLenum type
shadDetails.sources.swap(src);
shadDetails.prog = sepprog;
shadDetails.Compile(m_Real);
shadDetails.Compile(*this);
GetResourceManager()->AddLiveResource(id, res);
}
@@ -461,7 +461,7 @@ GLuint WrappedOpenGL::glCreateShaderProgramv(GLenum type, GLsizei count, const G
for(GLsizei i = 0; i < count; i++)
src.push_back(strings[i]);
GLuint sepprog = MakeSeparableShaderProgram(m_Real, type, src, NULL);
GLuint sepprog = MakeSeparableShaderProgram(*this, type, src, NULL);
auto &progDetails = m_Programs[id];
@@ -475,7 +475,7 @@ GLuint WrappedOpenGL::glCreateShaderProgramv(GLenum type, GLsizei count, const G
shadDetails.sources.swap(src);
shadDetails.prog = sepprog;
shadDetails.Compile(m_Real);
shadDetails.Compile(*this);
}
return real;
@@ -1398,7 +1398,7 @@ bool WrappedOpenGL::Serialise_glCompileShaderIncludeARB(GLuint shader, GLsizei c
for(int32_t i = 0; i < Count; i++)
shadDetails.includepaths.push_back(pathstrings[i]);
shadDetails.Compile(m_Real);
shadDetails.Compile(*this);
m_Real.glCompileShaderIncludeARB(GetResourceManager()->GetLiveResource(id).name, Count,
pathstrings, NULL);
@@ -1437,7 +1437,7 @@ void WrappedOpenGL::glCompileShaderIncludeARB(GLuint shader, GLsizei count,
for(int32_t i = 0; i < count; i++)
shadDetails.includepaths.push_back(path[i]);
shadDetails.Compile(m_Real);
shadDetails.Compile(*this);
}
}