Skip to content

Commit db83052

Browse files
committed
gl_shader: make possible to never compile a shader, do it for “proxy”
1 parent e7396f4 commit db83052

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

src/engine/renderer/gl_shader.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1081,6 +1081,10 @@ bool GLShaderManager::BuildPermutation( GLShader* shader, int index, const bool
10811081
return false;
10821082
}
10831083

1084+
if ( shader->IsCompileSkip() ) {
1085+
return false;
1086+
}
1087+
10841088
if ( IsUnusedPermutation( compileMacros.c_str() ) ) {
10851089
return false;
10861090
}
@@ -3045,7 +3049,7 @@ GlobalUBOProxy::GlobalUBOProxy() :
30453049
/* HACK: A GLShader* is required to initialise uniforms,
30463050
but we don't need the GLSL shader itself, so we won't actually build it */
30473051
GLShader( "proxy", 0,
3048-
false, "screenSpace", "generic", true ),
3052+
false, "screenSpace", "generic", true, true ),
30493053
// CONST
30503054
u_ColorMap3D( this ),
30513055
u_DepthMap( this ),

src/engine/renderer/gl_shader.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ class GLShader {
188188

189189
const bool worldShader;
190190
const bool pushSkip;
191+
const bool compileSkip;
191192
protected:
192193
int _activeMacros = 0;
193194
int _deformIndex = 0;
@@ -212,7 +213,7 @@ class GLShader {
212213
GLShader( const std::string& name, uint32_t vertexAttribsRequired,
213214
const bool useMaterialSystem,
214215
const std::string newVertexShaderName, const std::string newFragmentShaderName,
215-
const bool newPushSkip = false ) :
216+
const bool newPushSkip = false, const bool compileSkip = false ) :
216217
_name( name ),
217218
_vertexAttribsRequired( vertexAttribsRequired ),
218219
_useMaterialSystem( useMaterialSystem ),
@@ -222,12 +223,14 @@ class GLShader {
222223
hasFragmentShader( true ),
223224
hasComputeShader( false ),
224225
worldShader( false ),
225-
pushSkip( newPushSkip ) {
226+
pushSkip( newPushSkip ),
227+
compileSkip( compileSkip ) {
226228
}
227229

228230
GLShader( const std::string& name,
229231
const bool useMaterialSystem,
230-
const std::string newComputeShaderName, const bool newWorldShader = false ) :
232+
const std::string newComputeShaderName, const bool newWorldShader = false,
233+
const bool compileSkip = false ) :
231234
_name( name ),
232235
_vertexAttribsRequired( 0 ),
233236
_useMaterialSystem( useMaterialSystem ),
@@ -236,7 +239,8 @@ class GLShader {
236239
hasFragmentShader( false ),
237240
hasComputeShader( true ),
238241
worldShader( newWorldShader ),
239-
pushSkip( false ) {
242+
pushSkip( false ),
243+
compileSkip( compileSkip ) {
240244
}
241245

242246
public:
@@ -268,6 +272,10 @@ class GLShader {
268272
return currentProgram;
269273
}
270274

275+
bool IsCompileSkip() const {
276+
return compileSkip;
277+
}
278+
271279
protected:
272280
void PostProcessUniforms();
273281
uint32_t GetUniqueCompileMacros( size_t permutation, const int type ) const;

0 commit comments

Comments
 (0)