Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 6 additions & 25 deletions src/engine/renderer/gl_shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,7 @@ void GLShaderManager::BuildShaderProgram( ShaderProgramDescriptor* descriptor )
glGetProgramiv( program, GL_LINK_STATUS, &linked );

if ( !linked ) {
Log::Warn( "Link log:" );
Log::Warn( "Link log for %s:", descriptor->mainShader );
Log::Warn( GetInfoLog( program ) );
ThrowShaderError( "Shader program failed to link!" );
}
Expand Down Expand Up @@ -1065,6 +1065,10 @@ bool GLShaderManager::BuildPermutation( GLShader* shader, int index, const bool
return false;
}

if ( shader->SkipCompilation() ) {
return false;
}

if ( IsUnusedPermutation( compileMacros.c_str() ) ) {
return false;
}
Expand Down Expand Up @@ -1984,29 +1988,6 @@ std::string GLShaderManager::GetInfoLog( GLuint object ) const
return out;
}

void GLShaderManager::LinkProgram( GLuint program ) const
{
GLint linked;

#ifdef GL_ARB_get_program_binary
// Apparently, this is necessary to get the binary program via glGetProgramBinary
if( glConfig.getProgramBinaryAvailable )
{
glProgramParameteri( program, GL_PROGRAM_BINARY_RETRIEVABLE_HINT, GL_TRUE );
}
#endif
glLinkProgram( program );

glGetProgramiv( program, GL_LINK_STATUS, &linked );

if ( !linked )
{
Log::Warn( "Link log:" );
Log::Warn( GetInfoLog( program ) );
ThrowShaderError( "Shaders failed to link!" );
}
}

void GLShaderManager::BindAttribLocations( GLuint program ) const
{
for ( uint32_t i = 0; i < ATTR_INDEX_MAX; i++ )
Expand Down Expand Up @@ -3036,7 +3017,7 @@ GlobalUBOProxy::GlobalUBOProxy() :
/* HACK: A GLShader* is required to initialise uniforms,
but we don't need the GLSL shader itself, so we won't actually build it */
GLShader( "proxy", 0,
false, "screenSpace", "generic", true ),
false, "screenSpace", "generic", true, true ),
// CONST
u_ColorMap3D( this ),
u_DepthMap( this ),
Expand Down
14 changes: 10 additions & 4 deletions src/engine/renderer/gl_shader.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ class GLShader {

const bool worldShader;
const bool pushSkip;
const bool compileSkip;
protected:
int _activeMacros = 0;
int _deformIndex = 0;
Expand All @@ -212,7 +213,7 @@ class GLShader {
GLShader( const std::string& name, uint32_t vertexAttribsRequired,
const bool useMaterialSystem,
const std::string newVertexShaderName, const std::string newFragmentShaderName,
const bool newPushSkip = false ) :
const bool newPushSkip = false, const bool compileSkip = false ) :
_name( name ),
_vertexAttribsRequired( vertexAttribsRequired ),
_useMaterialSystem( useMaterialSystem ),
Expand All @@ -222,7 +223,8 @@ class GLShader {
hasFragmentShader( true ),
hasComputeShader( false ),
worldShader( false ),
pushSkip( newPushSkip ) {
pushSkip( newPushSkip ),
compileSkip( compileSkip ) {
}

GLShader( const std::string& name,
Expand All @@ -236,7 +238,8 @@ class GLShader {
hasFragmentShader( false ),
hasComputeShader( true ),
worldShader( newWorldShader ),
pushSkip( false ) {
pushSkip( false ),
compileSkip( false ) {
}

public:
Expand Down Expand Up @@ -268,6 +271,10 @@ class GLShader {
return currentProgram;
}

bool SkipCompilation() const {
return compileSkip;
}

protected:
void PostProcessUniforms();
uint32_t GetUniqueCompileMacros( size_t permutation, const int type ) const;
Expand Down Expand Up @@ -550,7 +557,6 @@ class GLShaderManager {
std::string BuildDeformShaderText( const std::string& steps );
std::string ProcessInserts( const std::string& shaderText ) const;

void LinkProgram( GLuint program ) const;
void BindAttribLocations( GLuint program ) const;
void PrintShaderSource( Str::StringRef programName, GLuint object, std::vector<InfoLogEntry>& infoLogLines ) const;

Expand Down
Loading