GL: Add error checking function
This is to ease the debugging process on Apple GL implementation.
This commit is contained in:
parent
e51c428be6
commit
b43f4fda19
Notes:
blender-bot
2023-06-12 00:52:52 +02:00
Referenced by commit 9dd4d87f18
, GPU: Fix compilation issue caused by rBb43f4fda19b9
|
@ -327,6 +327,8 @@ void GLBatch::bind(int i_first)
|
|||
|
||||
void GLBatch::draw(int v_first, int v_count, int i_first, int i_count)
|
||||
{
|
||||
GL_CHECK_ERROR("Batch Pre drawing");
|
||||
|
||||
this->bind(i_first);
|
||||
|
||||
BLI_assert(v_count > 0 && i_count > 0);
|
||||
|
@ -353,6 +355,7 @@ void GLBatch::draw(int v_first, int v_count, int i_first, int i_count)
|
|||
glDrawElementsInstancedBaseVertex(
|
||||
gl_type, v_count, index_type, v_first_ofs, i_count, base_index);
|
||||
}
|
||||
GL_CHECK_ERROR("Batch Post-drawing Indexed");
|
||||
}
|
||||
else {
|
||||
#ifdef __APPLE__
|
||||
|
@ -367,6 +370,7 @@ void GLBatch::draw(int v_first, int v_count, int i_first, int i_count)
|
|||
#ifdef __APPLE__
|
||||
glEnable(GL_PRIMITIVE_RESTART);
|
||||
#endif
|
||||
GL_CHECK_ERROR("Batch Post-drawing Non-indexed");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
*/
|
||||
|
||||
#include "BLI_assert.h"
|
||||
#include "BLI_system.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "GPU_framebuffer.h"
|
||||
|
@ -238,3 +239,37 @@ void GLContext::framebuffer_unregister(struct GPUFrameBuffer *fb)
|
|||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Error Checking
|
||||
*
|
||||
* This is only useful for implementation that does not support the KHR_debug extension.
|
||||
* \{ */
|
||||
|
||||
void GLContext::check_error(const char *info)
|
||||
{
|
||||
GLenum error = glGetError();
|
||||
|
||||
#define ERROR_CASE(err) \
|
||||
case err: \
|
||||
fprintf(stderr, "GL error: %s : %s\n", #err, info); \
|
||||
BLI_system_backtrace(stderr); \
|
||||
break;
|
||||
|
||||
switch (error) {
|
||||
ERROR_CASE(GL_INVALID_ENUM)
|
||||
ERROR_CASE(GL_INVALID_VALUE)
|
||||
ERROR_CASE(GL_INVALID_OPERATION)
|
||||
ERROR_CASE(GL_INVALID_FRAMEBUFFER_OPERATION)
|
||||
ERROR_CASE(GL_OUT_OF_MEMORY)
|
||||
ERROR_CASE(GL_STACK_UNDERFLOW)
|
||||
ERROR_CASE(GL_STACK_OVERFLOW)
|
||||
case GL_NO_ERROR:
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "Unknown GL error: %x : %s", error, info);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
|
|
@ -34,6 +34,15 @@
|
|||
|
||||
#include <mutex>
|
||||
|
||||
#ifdef DEBUG
|
||||
/* Enabled on MacOS by default since there is no support for debug callbacks. */
|
||||
# ifdef __APPLE__
|
||||
# define GL_CHECK_ERROR(info) GLContext::check_error(info)
|
||||
# else
|
||||
# define GL_CHECK_ERROR(info)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
namespace blender {
|
||||
namespace gpu {
|
||||
|
||||
|
@ -78,6 +87,8 @@ class GLContext : public GPUContext {
|
|||
GLContext(void *ghost_window, GLSharedOrphanLists &shared_orphan_list);
|
||||
~GLContext();
|
||||
|
||||
static void check_error(const char *info);
|
||||
|
||||
void activate(void) override;
|
||||
void deactivate(void) override;
|
||||
|
||||
|
|
Loading…
Reference in New Issue