Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2020-09-04 23:19:36 +0300
committerClément Foucault <foucault.clem@gmail.com>2020-09-05 18:49:14 +0300
commit7d4adbdfaba4f23b2adbf96f97ce18806aca31c8 (patch)
tree4797d2fda9bb09a0c9a33b1b49a5f12b8a4e3bb9 /source/blender/gpu/opengl/gl_debug.cc
parent541de201fe24ededf9ba9535d6919fd7087c020d (diff)
GLTexture: Add validation for empty slots before drawing
This is to have better error detection in debug builds. This is not a replacement for a full check like in renderdoc but it might catch some issues early on.
Diffstat (limited to 'source/blender/gpu/opengl/gl_debug.cc')
-rw-r--r--source/blender/gpu/opengl/gl_debug.cc18
1 files changed, 17 insertions, 1 deletions
diff --git a/source/blender/gpu/opengl/gl_debug.cc b/source/blender/gpu/opengl/gl_debug.cc
index da1f40e6417..674ca2f0bf1 100644
--- a/source/blender/gpu/opengl/gl_debug.cc
+++ b/source/blender/gpu/opengl/gl_debug.cc
@@ -186,7 +186,12 @@ void check_gl_resources(const char *info)
uint16_t ubo_needed = interface->enabled_ubo_mask_;
ubo_needed &= ~ctx->bound_ubo_slots;
- if (ubo_needed == 0) {
+ /* NOTE: This only check binding. To be valid, the bound texture needs to
+ * be the same format/target the shader expects. */
+ uint64_t tex_needed = interface->enabled_tex_mask_;
+ tex_needed &= ~ctx->state_manager_active_get()->bound_texture_slots();
+
+ if (ubo_needed == 0 && tex_needed == 0) {
return;
}
@@ -200,6 +205,17 @@ void check_gl_resources(const char *info)
debug_callback(0, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, 0, msg, NULL);
}
}
+
+ for (int i = 0; tex_needed != 0; i++, tex_needed >>= 1) {
+ if ((tex_needed & 1) != 0) {
+ const ShaderInput *tex_input = interface->texture_get(i);
+ const char *tex_name = interface->input_name_get(tex_input);
+ const char *sh_name = ctx->shader->name_get();
+ char msg[256];
+ SNPRINTF(msg, "Missing Texture bind at slot %d : %s > %s : %s", i, sh_name, tex_name, info);
+ debug_callback(0, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, 0, msg, NULL);
+ }
+ }
}
void raise_gl_error(const char *msg)