From 74c09d064b5aa2216ffc4fe5f6c4ea685915de83 Mon Sep 17 00:00:00 2001 From: baldurk Date: Thu, 28 Jul 2016 20:40:25 +0200 Subject: [PATCH] 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. --- renderdoc/driver/gl/gl_driver.cpp | 1 + renderdoc/driver/gl/gl_driver.h | 14 +++++-- renderdoc/driver/gl/gl_shader_refl.cpp | 37 ++++++++++++------- renderdoc/driver/gl/gl_shader_refl.h | 6 ++- .../driver/gl/wrappers/gl_shader_funcs.cpp | 20 +++++----- 5 files changed, 49 insertions(+), 29 deletions(-) diff --git a/renderdoc/driver/gl/gl_driver.cpp b/renderdoc/driver/gl/gl_driver.cpp index afba3938c..dc6479672 100644 --- a/renderdoc/driver/gl/gl_driver.cpp +++ b/renderdoc/driver/gl/gl_driver.cpp @@ -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); diff --git a/renderdoc/driver/gl/gl_driver.h b/renderdoc/driver/gl/gl_driver.h index d1917fe6b..1e4c59716 100644 --- a/renderdoc/driver/gl/gl_driver.h +++ b/renderdoc/driver/gl/gl_driver.h @@ -114,7 +114,6 @@ private: friend class GLReplay; friend class GLResourceManager; - const GLHookSet &GetHookset() { return m_Real; } vector m_DebugMessages; void Serialise_DebugMessages(); vector 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 GetUsage(ResourceId id) { return m_ResourceUses[id]; } void CreateContext(GLWindowingData winData, void *shareContext, GLInitParams initParams, bool core, bool attribsCreate); diff --git a/renderdoc/driver/gl/gl_shader_refl.cpp b/renderdoc/driver/gl/gl_shader_refl.cpp index 2d3b3fc11..02b6ed7b0 100644 --- a/renderdoc/driver/gl/gl_shader_refl.cpp +++ b/renderdoc/driver/gl/gl_shader_refl.cpp @@ -24,6 +24,7 @@ #include "gl_shader_refl.h" #include +#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 &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 sources, +GLuint MakeSeparableShaderProgram(WrappedOpenGL &gl, GLenum type, vector sources, vector *includepaths) { // in and out blocks are added separately, in case one is there already diff --git a/renderdoc/driver/gl/gl_shader_refl.h b/renderdoc/driver/gl/gl_shader_refl.h index a9c78a899..06d59b83b 100644 --- a/renderdoc/driver/gl/gl_shader_refl.h +++ b/renderdoc/driver/gl/gl_shader_refl.h @@ -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 sources, vector *includepaths); +GLuint MakeSeparableShaderProgram(WrappedOpenGL &gl, GLenum type, std::vector sources, + vector *includepaths); void CheckVertexOutputUses(const std::vector &sources, bool &pointSizeUsed, bool &clipDistanceUsed); diff --git a/renderdoc/driver/gl/wrappers/gl_shader_funcs.cpp b/renderdoc/driver/gl/wrappers/gl_shader_funcs.cpp index 6cb28e7a4..d7c9e33a3 100644 --- a/renderdoc/driver/gl/wrappers/gl_shader_funcs.cpp +++ b/renderdoc/driver/gl/wrappers/gl_shader_funcs.cpp @@ -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 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); } }