also check for glsl errors on linking, activation GLSL_DEBUG again (slowdown on shader compilation)
This commit is contained in:
parent
9987765b1f
commit
f079b04a5d
|
@ -28,9 +28,6 @@
|
|||
|
||||
#include "GLUtil.h"
|
||||
|
||||
// this should be removed in future, but as long as glsl is unstable, we should really read this messages
|
||||
#define DEBUG_GLSL
|
||||
|
||||
GLWindow GLWin;
|
||||
cInterfaceBase *GLInterface;
|
||||
|
||||
|
|
|
@ -69,6 +69,9 @@ bool OpenGL_ReportFBOError(const char *function, const char *file, int line);
|
|||
#define GL_REPORT_PROGRAM_ERROR() (void)0
|
||||
#endif
|
||||
|
||||
// this should be removed in future, but as long as glsl is unstable, we should really read this messages
|
||||
#define DEBUG_GLSL
|
||||
|
||||
// Isn't defined if we aren't using GLEW 1.6
|
||||
#ifndef GL_ONE_MINUS_SRC1_ALPHA
|
||||
#define GL_ONE_MINUS_SRC1_ALPHA 0x88FB
|
||||
|
|
|
@ -145,6 +145,7 @@ bool PixelShaderCache::CompilePixelShader(FRAGMENTSHADER& ps, const char* pstrpr
|
|||
char szTemp[MAX_PATH];
|
||||
sprintf(szTemp, "ps_%d.txt", result);
|
||||
FILE *fp = fopen(szTemp, "wb");
|
||||
fwrite(infoLog, strlen(infoLog), 1, fp);
|
||||
fwrite(pstrprogram, strlen(pstrprogram), 1, fp);
|
||||
fclose(fp);
|
||||
delete[] infoLog;
|
||||
|
|
|
@ -185,6 +185,48 @@ void ProgramShaderCache::SetBothShaders(GLuint PS, GLuint VS)
|
|||
|
||||
glLinkProgram(entry.prog_id);
|
||||
|
||||
#if defined(_DEBUG) || defined(DEBUGFAST) || defined(DEBUG_GLSL)
|
||||
GLsizei length = 0;
|
||||
glGetProgramiv(entry.prog_id, GL_INFO_LOG_LENGTH, &length);
|
||||
if (length > 1)
|
||||
{
|
||||
GLsizei charsWritten;
|
||||
GLchar* infoLog = new GLchar[length];
|
||||
glGetProgramInfoLog(entry.prog_id, length, &charsWritten, infoLog);
|
||||
ERROR_LOG(VIDEO, "Program info log:\n%s", infoLog);
|
||||
char szTemp[MAX_PATH];
|
||||
sprintf(szTemp, "p_%d.txt", entry.prog_id);
|
||||
FILE *fp = fopen(szTemp, "wb");
|
||||
fwrite(infoLog, length, 1, fp);
|
||||
delete[] infoLog;
|
||||
|
||||
glGetShaderiv(VS, GL_SHADER_SOURCE_LENGTH, &length);
|
||||
GLchar* src = new GLchar[length];
|
||||
glGetShaderSource(VS, length, &charsWritten, src);
|
||||
fwrite(src, strlen(src), 1, fp);
|
||||
delete [] src;
|
||||
|
||||
glGetShaderiv(PS, GL_SHADER_SOURCE_LENGTH, &length);
|
||||
src = new GLchar[length];
|
||||
glGetShaderSource(PS, length, &charsWritten, src);
|
||||
fwrite(src, strlen(src), 1, fp);
|
||||
delete [] src;
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
GLint linkStatus;
|
||||
glGetProgramiv(entry.prog_id, GL_LINK_STATUS, &linkStatus);
|
||||
if (linkStatus != GL_TRUE)
|
||||
{
|
||||
// Compile failed
|
||||
ERROR_LOG(VIDEO, "Program linking failed; see info log");
|
||||
|
||||
// Don't try to use this shader
|
||||
glDeleteProgram(entry.prog_id);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
glUseProgram(entry.prog_id);
|
||||
|
||||
SetProgramVariables(entry);
|
||||
|
|
|
@ -131,6 +131,7 @@ bool VertexShaderCache::CompileVertexShader(VERTEXSHADER& vs, const char* pstrpr
|
|||
char szTemp[MAX_PATH];
|
||||
sprintf(szTemp, "vs_%d.txt", result);
|
||||
FILE *fp = fopen(szTemp, "wb");
|
||||
fwrite(infoLog, strlen(infoLog), 1, fp);
|
||||
fwrite(pstrprogram, strlen(pstrprogram), 1, fp);
|
||||
fclose(fp);
|
||||
delete[] infoLog;
|
||||
|
|
Loading…
Reference in New Issue