From 2c010f530edca88b0595df2f2aed0ab5d06ad18c Mon Sep 17 00:00:00 2001 From: degasus Date: Fri, 18 Jan 2013 12:49:48 +0100 Subject: [PATCH] report glsl shader warings as errors --- .../Plugin_VideoOGL/Src/PixelShaderCache.cpp | 31 ++++++++--------- .../Plugin_VideoOGL/Src/VertexShaderCache.cpp | 33 ++++++++++--------- 2 files changed, 33 insertions(+), 31 deletions(-) diff --git a/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp b/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp index 24f239afa2..27591f6c5c 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp @@ -133,6 +133,22 @@ bool PixelShaderCache::CompilePixelShader(FRAGMENTSHADER& ps, const char* pstrpr glShaderSource(result, 1, &pstrprogram, NULL); glCompileShader(result); + + GLsizei length = 0; + glGetShaderiv(result, GL_INFO_LOG_LENGTH, &length); + if (length > 1) + { + GLsizei charsWritten; + GLchar* infoLog = new GLchar[length]; + glGetShaderInfoLog(result, length, &charsWritten, infoLog); + ERROR_LOG(VIDEO, "PS Shader info log:\n%s", infoLog); + char szTemp[MAX_PATH]; + sprintf(szTemp, "ps_%d.txt", result); + FILE *fp = fopen(szTemp, "wb"); + fwrite(pstrprogram, strlen(pstrprogram), 1, fp); + fclose(fp); + delete[] infoLog; + } GLint compileStatus; glGetShaderiv(result, GL_COMPILE_STATUS, &compileStatus); @@ -141,21 +157,6 @@ bool PixelShaderCache::CompilePixelShader(FRAGMENTSHADER& ps, const char* pstrpr // Compile failed ERROR_LOG(VIDEO, "Shader compilation failed; see info log"); - GLsizei length = 0; - glGetShaderiv(result, GL_INFO_LOG_LENGTH, &length); - if (length > 0) - { - GLsizei charsWritten; - GLchar* infoLog = new GLchar[length]; - glGetShaderInfoLog(result, length, &charsWritten, infoLog); - WARN_LOG(VIDEO, "PS Shader info log:\n%s", infoLog); - char szTemp[MAX_PATH]; - sprintf(szTemp, "ps_%d.txt", result); - FILE *fp = fopen(szTemp, "wb"); - fwrite(pstrprogram, strlen(pstrprogram), 1, fp); - fclose(fp); - delete[] infoLog; - } // Don't try to use this shader glDeleteShader(result); return false; diff --git a/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderCache.cpp b/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderCache.cpp index 8af90cdc32..d816a952ca 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderCache.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderCache.cpp @@ -119,6 +119,22 @@ bool VertexShaderCache::CompileVertexShader(VERTEXSHADER& vs, const char* pstrpr glShaderSource(result, 1, &pstrprogram, NULL); glCompileShader(result); + + GLsizei length = 0; + glGetShaderiv(result, GL_INFO_LOG_LENGTH, &length); + if (length > 1) + { + GLsizei charsWritten; + GLchar* infoLog = new GLchar[length]; + glGetShaderInfoLog(result, length, &charsWritten, infoLog); + ERROR_LOG(VIDEO, "VS Shader info log:\n%s", infoLog); + char szTemp[MAX_PATH]; + sprintf(szTemp, "vs_%d.txt", result); + FILE *fp = fopen(szTemp, "wb"); + fwrite(pstrprogram, strlen(pstrprogram), 1, fp); + fclose(fp); + delete[] infoLog; + } GLint compileStatus; glGetShaderiv(result, GL_COMPILE_STATUS, &compileStatus); @@ -126,22 +142,7 @@ bool VertexShaderCache::CompileVertexShader(VERTEXSHADER& vs, const char* pstrpr { // Compile failed ERROR_LOG(VIDEO, "Shader compilation failed; see info log"); - - GLsizei length = 0; - glGetShaderiv(result, GL_INFO_LOG_LENGTH, &length); - if (length > 0) - { - GLsizei charsWritten; - GLchar* infoLog = new GLchar[length]; - glGetShaderInfoLog(result, length, &charsWritten, infoLog); - WARN_LOG(VIDEO, "VS Shader info log:\n%s", infoLog); - char szTemp[MAX_PATH]; - sprintf(szTemp, "vs_%d.txt", result); - FILE *fp = fopen(szTemp, "wb"); - fwrite(pstrprogram, strlen(pstrprogram), 1, fp); - fclose(fp); - delete[] infoLog; - } + // Don't try to use this shader glDeleteShader(result); return false;