Permalink
Browse files

GLES: Report shader errors with shader desc.

  • Loading branch information...
unknownbrackets committed Nov 30, 2017
1 parent 9a71ac7 commit e0ccbd31b63ea0b7640440207467cc2140ec70f3
Showing with 17 additions and 11 deletions.
  1. +16 −10 GPU/GLES/ShaderManagerGLES.cpp
  2. +1 −1 GPU/GLES/ShaderManagerGLES.h
@@ -43,7 +43,7 @@
#include "GPU/GLES/DrawEngineGLES.h"
#include "FramebufferManagerGLES.h"
Shader::Shader(const char *code, uint32_t glShaderType, bool useHWTransform, uint32_t attrMask, uint64_t uniformMask)
Shader::Shader(const ShaderID &id, const char *code, uint32_t glShaderType, bool useHWTransform, uint32_t attrMask, uint64_t uniformMask)
: failed_(false), useHWTransform_(useHWTransform), attrMask_(attrMask), uniformMask_(uniformMask) {
PROFILE_THIS_SCOPE("shadercomp");
isFragment_ = glShaderType == GL_FRAGMENT_SHADER;
@@ -70,10 +70,12 @@ Shader::Shader(const char *code, uint32_t glShaderType, bool useHWTransform, uin
ELOG("Error in shader compilation! %s\n", infoLog);
ELOG("Shader source:\n%s\n", (const char *)code);
#endif
ERROR_LOG(G3D, "Error in shader compilation!\n");
ERROR_LOG(G3D, "Info log: %s\n", infoLog);
std::string desc = GetShaderString(SHADER_STRING_SHORT_DESC, id);
ERROR_LOG(G3D, "Error in shader compilation for: %s", desc.c_str());
ERROR_LOG(G3D, "Info log: %s", infoLog);
ERROR_LOG(G3D, "Shader source:\n%s\n", (const char *)code);
Reporting::ReportMessage("Error in shader compilation: info: %s / code: %s", infoLog, (const char *)code);
Reporting::ReportMessage("Error in shader compilation: info: %s\n%s\n%s", infoLog, desc.c_str(), (const char *)code);
#ifdef SHADERLOG
OutputDebugStringUTF8(infoLog);
#endif
@@ -141,13 +143,17 @@ LinkedShader::LinkedShader(ShaderID VSID, Shader *vs, ShaderID FSID, Shader *fs,
ELOG("Could not link program:\n %s", buf);
#endif
ERROR_LOG(G3D, "Could not link program:\n %s", buf);
ERROR_LOG(G3D, "VS desc:\n%s\n", vs->GetShaderString(SHADER_STRING_SHORT_DESC, VSID).c_str());
ERROR_LOG(G3D, "FS desc:\n%s\n", fs->GetShaderString(SHADER_STRING_SHORT_DESC, FSID).c_str());
std::string vs_desc = vs->GetShaderString(SHADER_STRING_SHORT_DESC, VSID);
std::string fs_desc = fs->GetShaderString(SHADER_STRING_SHORT_DESC, FSID);
std::string vs_source = vs->GetShaderString(SHADER_STRING_SOURCE_CODE, VSID);
std::string fs_source = fs->GetShaderString(SHADER_STRING_SOURCE_CODE, FSID);
ERROR_LOG(G3D, "VS desc:\n%s", vs_desc.c_str());
ERROR_LOG(G3D, "FS desc:\n%s", fs_desc.c_str());
ERROR_LOG(G3D, "VS:\n%s\n", vs_source.c_str());
ERROR_LOG(G3D, "FS:\n%s\n", fs_source.c_str());
Reporting::ReportMessage("Error in shader program link: info: %s / fs: %s / vs: %s", buf, fs_source.c_str(), vs_source.c_str());
Reporting::ReportMessage("Error in shader program link: info: %s\nfs: %s\n%s\nvs: %s\n%s", buf, fs_desc.c_str(), fs_source.c_str(), vs_desc.c_str(), vs_source.c_str());
#ifdef SHADERLOG
OutputDebugStringUTF8(buf);
OutputDebugStringUTF8(vs_source.c_str());
@@ -738,15 +744,15 @@ Shader *ShaderManagerGLES::CompileFragmentShader(ShaderID FSID) {
if (!GenerateFragmentShader(FSID, codeBuffer_, &uniformMask)) {
return nullptr;
}
return new Shader(codeBuffer_, GL_FRAGMENT_SHADER, false, 0, uniformMask);
return new Shader(FSID, codeBuffer_, GL_FRAGMENT_SHADER, false, 0, uniformMask);
}
Shader *ShaderManagerGLES::CompileVertexShader(ShaderID VSID) {
bool useHWTransform = VSID.Bit(VS_BIT_USE_HW_TRANSFORM);
uint32_t attrMask;
uint64_t uniformMask;
GenerateVertexShader(VSID, codeBuffer_, &attrMask, &uniformMask);
return new Shader(codeBuffer_, GL_VERTEX_SHADER, useHWTransform, attrMask, uniformMask);
return new Shader(VSID, codeBuffer_, GL_VERTEX_SHADER, useHWTransform, attrMask, uniformMask);
}
Shader *ShaderManagerGLES::ApplyVertexShader(int prim, u32 vertType, ShaderID *VSID) {
@@ -797,7 +803,7 @@ Shader *ShaderManagerGLES::ApplyVertexShader(int prim, u32 vertType, ShaderID *V
uint32_t attrMask;
uint64_t uniformMask;
GenerateVertexShader(vsidTemp, codeBuffer_, &attrMask, &uniformMask);
vs = new Shader(codeBuffer_, GL_VERTEX_SHADER, false, attrMask, uniformMask);
vs = new Shader(vsidTemp, codeBuffer_, GL_VERTEX_SHADER, false, attrMask, uniformMask);
}
vsCache_.Insert(*VSID, vs);
@@ -124,7 +124,7 @@ class LinkedShader {
class Shader {
public:
Shader(const char *code, uint32_t glShaderType, bool useHWTransform, uint32_t attrMask, uint64_t uniformMask);
Shader(const ShaderID &id, const char *code, uint32_t glShaderType, bool useHWTransform, uint32_t attrMask, uint64_t uniformMask);
~Shader();
uint32_t shader;

0 comments on commit e0ccbd3

Please sign in to comment.