@@ -304,6 +304,13 @@ void OpenGLDriver::bindSampler(GLuint unit, GLuint sampler) noexcept {
304
304
void OpenGLDriver::setPushConstant (backend::ShaderStage stage, uint8_t index,
305
305
backend::PushConstantVariant value) {
306
306
assert_invariant (stage == ShaderStage::VERTEX || stage == ShaderStage::FRAGMENT);
307
+
308
+ #if FILAMENT_ENABLE_MATDBG
309
+ if (UTILS_UNLIKELY (!mValidProgram )) {
310
+ return ;
311
+ }
312
+ #endif
313
+
307
314
utils::Slice<std::pair<GLint, ConstantType>> constants;
308
315
if (stage == ShaderStage::VERTEX) {
309
316
constants = mCurrentPushConstants ->vertexConstants ;
@@ -340,15 +347,11 @@ void OpenGLDriver::bindTexture(GLuint unit, GLTexture const* t) noexcept {
340
347
}
341
348
342
349
bool OpenGLDriver::useProgram (OpenGLProgram* p) noexcept {
343
- if (UTILS_UNLIKELY (!p->isValid ())) {
344
- // If the program is not valid, we can't call use().
345
- return false ;
346
- }
347
-
348
350
// set-up textures and samplers in the proper TMUs (as specified in setSamplers)
349
- p->use (this , mContext );
351
+ bool const success = p->use (this , mContext );
352
+ assert_invariant (success == p->isValid ());
350
353
351
- if (UTILS_UNLIKELY (mContext .isES2 ())) {
354
+ if (UTILS_UNLIKELY (mContext .isES2 () && success )) {
352
355
for (uint32_t i = 0 ; i < Program::UNIFORM_BINDING_COUNT; i++) {
353
356
auto [id, buffer, age] = mContext .getEs2UniformBinding (i);
354
357
if (buffer) {
@@ -359,7 +362,8 @@ bool OpenGLDriver::useProgram(OpenGLProgram* p) noexcept {
359
362
// when mPlatform.isSRGBSwapChainSupported() is false (no need to check though).
360
363
p->setRec709ColorSpace (mRec709OutputColorspace );
361
364
}
362
- return true ;
365
+
366
+ return success;
363
367
}
364
368
365
369
0 commit comments