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-01 03:41:29 +0300
committerClément Foucault <foucault.clem@gmail.com>2020-09-01 13:03:52 +0300
commit53a806f6dffb2a778e383a82c3d0cdb6e9d9d552 (patch)
tree3bfc9bb0d705a1c198c19b62fe134bda525e51ad /source/blender/gpu/opengl/gl_debug.cc
parent5ec0250df9d8cf44d099e5b6fffca99bf9cf0c46 (diff)
GPU: Move UBO binding validation to GL backend
This also make the validation quicker by tracking the currently bound slots.
Diffstat (limited to 'source/blender/gpu/opengl/gl_debug.cc')
-rw-r--r--source/blender/gpu/opengl/gl_debug.cc31
1 files changed, 30 insertions, 1 deletions
diff --git a/source/blender/gpu/opengl/gl_debug.cc b/source/blender/gpu/opengl/gl_debug.cc
index 2dc0835adfb..fb3c4f52fd0 100644
--- a/source/blender/gpu/opengl/gl_debug.cc
+++ b/source/blender/gpu/opengl/gl_debug.cc
@@ -30,6 +30,9 @@
#include "glew-mx.h"
+#include "gl_context.hh"
+#include "gl_uniform_buffer.hh"
+
#include "gl_debug.hh"
#include <stdio.h>
@@ -140,7 +143,8 @@ void init_gl_callbacks(void)
/* -------------------------------------------------------------------- */
/** \name Error Checking
*
- * This is only useful for implementation that does not support the KHR_debug extension.
+ * This is only useful for implementation that does not support the KHR_debug extension OR when the
+ * implementations do not report any errors even when clearly doing shady things.
* \{ */
void check_gl_error(const char *info)
@@ -173,6 +177,31 @@ void check_gl_error(const char *info)
}
}
+void check_gl_resources(const char *info)
+{
+ GLContext *ctx = static_cast<GLContext *>(GPU_context_active_get());
+ ShaderInterface *interface = ctx->shader->interface;
+ /* NOTE: This only check binding. To be valid, the bound ubo needs to
+ * be big enough to feed the data range the shader awaits. */
+ uint16_t ubo_needed = interface->enabled_ubo_mask_;
+ ubo_needed &= ~ctx->bound_ubo_slots;
+
+ if (ubo_needed == 0) {
+ return;
+ }
+
+ for (int i = 0; ubo_needed != 0; i++, ubo_needed >>= 1) {
+ if ((ubo_needed & 1) != 0) {
+ const ShaderInput *ubo_input = interface->ubo_get(i);
+ const char *ubo_name = interface->input_name_get(ubo_input);
+ const char *sh_name = ctx->shader->name_get();
+ char msg[256];
+ SNPRINTF(msg, "Missing UBO bind at slot %d : %s > %s : %s", i, sh_name, ubo_name, info);
+ debug_callback(0, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, 0, msg, NULL);
+ }
+ }
+}
+
/** \} */
} // namespace blender::gpu::debug \ No newline at end of file