[Bf-blender-cvs] [05e84b16947] tmp-gldebuglayer: One macro to rule them all

Clément Foucault noreply at git.blender.org
Wed Sep 9 01:50:22 CEST 2020


Commit: 05e84b16947e745831dd4ca84c6dd74e327c6cf5
Author: Clément Foucault
Date:   Wed Sep 9 01:48:53 2020 +0200
Branches: tmp-gldebuglayer
https://developer.blender.org/rB05e84b16947e745831dd4ca84c6dd74e327c6cf5

One macro to rule them all

===================================================================

M	source/blender/gpu/opengl/gl_debug_layer.cc

===================================================================

diff --git a/source/blender/gpu/opengl/gl_debug_layer.cc b/source/blender/gpu/opengl/gl_debug_layer.cc
index 61e51724d90..0b32b3f3bf9 100644
--- a/source/blender/gpu/opengl/gl_debug_layer.cc
+++ b/source/blender/gpu/opengl/gl_debug_layer.cc
@@ -79,23 +79,25 @@ namespace blender::gpu::debug {
 #define ARG_LIST_CALL(...) VA_NARGS_CALL_OVERLOAD(_VA_ARG_LIST_CALL, __VA_ARGS__)
 /* clang-format on */
 
-#define DEBUG_FUNC_DECLARE_VAL(pfn, rtn_type, fn, ...) \
-  pfn real_##fn; \
-  static rtn_type GLAPIENTRY debug_##fn(ARG_LIST(__VA_ARGS__)) \
-  { \
-    check_gl_error("generated before " #fn); \
-    rtn_type ret = real_##fn(ARG_LIST_CALL(__VA_ARGS__)); \
-    check_gl_error("" #fn); \
-    return ret; \
-  }
+typedef void *GPUvoidptr;
 
-#define DEBUG_FUNC_DECLARE(pfn, fn, ...) \
+#define GPUvoidptr_set void *ret =
+#define GPUvoidptr_ret return ret
+
+#define GLboolean_set GLboolean ret =
+#define GLboolean_ret return ret
+
+#define void_set
+#define void_ret
+
+#define DEBUG_FUNC_DECLARE(pfn, rtn_type, fn, ...) \
   pfn real_##fn; \
-  static void GLAPIENTRY debug_##fn(ARG_LIST(__VA_ARGS__)) \
+  static rtn_type GLAPIENTRY debug_##fn(ARG_LIST(__VA_ARGS__)) \
   { \
     check_gl_error("generated before " #fn); \
-    real_##fn(ARG_LIST_CALL(__VA_ARGS__)); \
+    rtn_type##_set real_##fn(ARG_LIST_CALL(__VA_ARGS__)); \
     check_gl_error("" #fn); \
+    rtn_type##_ret; \
   }
 
 #define DEBUG_FUNC_DUMMY(pfn, fn, ...) \
@@ -111,45 +113,45 @@ namespace blender::gpu::debug {
 
 /* Avoid very long declarations. */
 /* clang-format off */
-DEBUG_FUNC_DECLARE_VAL(PFNGLMAPBUFFERRANGEPROC, void *, glMapBufferRange, GLenum, target, GLintptr, offset, GLsizeiptr, length, GLbitfield, access);
-DEBUG_FUNC_DECLARE_VAL(PFNGLUNMAPBUFFERPROC, GLboolean, glUnmapBuffer, GLenum, target);
-DEBUG_FUNC_DECLARE(PFNGLBEGINQUERYPROC, glBeginQuery, GLenum, target, GLuint, id);
-DEBUG_FUNC_DECLARE(PFNGLBEGINTRANSFORMFEEDBACKPROC, glBeginTransformFeedback, GLenum, primitiveMode);
-DEBUG_FUNC_DECLARE(PFNGLBINDBUFFERBASEPROC, glBindBufferBase, GLenum, target, GLuint, index, GLuint, buffer);
-DEBUG_FUNC_DECLARE(PFNGLBINDBUFFERPROC, glBindBuffer, GLenum, target, GLuint, buffer);
-DEBUG_FUNC_DECLARE(PFNGLBINDFRAMEBUFFERPROC, glBindFramebuffer, GLenum, target, GLuint, framebuffer);
-DEBUG_FUNC_DECLARE(PFNGLBINDSAMPLERPROC, glBindSampler, GLuint, unit, GLuint, sampler);
-DEBUG_FUNC_DECLARE(PFNGLBINDVERTEXARRAYPROC, glBindVertexArray, GLuint, array);
-DEBUG_FUNC_DECLARE(PFNGLBLITFRAMEBUFFERPROC, glBlitFramebuffer, GLint, srcX0, GLint, srcY0, GLint, srcX1, GLint, srcY1, GLint, dstX0, GLint, dstY0, GLint, dstX1, GLint, dstY1, GLbitfield, mask, GLenum, filter);
-DEBUG_FUNC_DECLARE(PFNGLBUFFERDATAPROC, glBufferData, GLenum, target, GLsizeiptr, size, const void *, data, GLenum, usage);
-DEBUG_FUNC_DECLARE(PFNGLBUFFERSUBDATAPROC, glBufferSubData, GLenum, target, GLintptr, offset, GLsizeiptr, size, const void *, data);
-DEBUG_FUNC_DECLARE(PFNGLDELETEBUFFERSPROC, glDeleteBuffers, GLsizei, n, const GLuint *, buffers);
-DEBUG_FUNC_DECLARE(PFNGLDELETEFRAMEBUFFERSPROC, glDeleteFramebuffers, GLsizei, n, const GLuint*, framebuffers);
-DEBUG_FUNC_DECLARE(PFNGLDELETEPROGRAMPROC, glDeleteProgram, GLuint, program);
-DEBUG_FUNC_DECLARE(PFNGLDELETEQUERIESPROC, glDeleteQueries, GLsizei, n, const GLuint *, ids);
-DEBUG_FUNC_DECLARE(PFNGLDELETESAMPLERSPROC, glDeleteSamplers, GLsizei, count, const GLuint *, samplers);
-DEBUG_FUNC_DECLARE(PFNGLDELETESHADERPROC, glDeleteShader, GLuint, shader);
-DEBUG_FUNC_DECLARE(PFNGLDELETEVERTEXARRAYSPROC, glDeleteVertexArrays, GLsizei, n, const GLuint *, arrays);
-DEBUG_FUNC_DECLARE(PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC, glDrawArraysInstancedBaseInstance, GLenum, mode, GLint, first, GLsizei, count, GLsizei, primcount, GLuint, baseinstance);
-DEBUG_FUNC_DECLARE(PFNGLDRAWARRAYSINSTANCEDPROC, glDrawArraysInstanced, GLenum, mode, GLint, first, GLsizei, count, GLsizei, primcount);
-DEBUG_FUNC_DECLARE(PFNGLDRAWBUFFERSPROC, glDrawBuffers, GLsizei, n, const GLenum*, bufs);
-DEBUG_FUNC_DECLARE(PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC, glDrawElementsInstancedBaseVertexBaseInstance, GLenum, mode, GLsizei, count, GLenum, type, const void *, indices, GLsizei, primcount, GLint, basevertex, GLuint, baseinstance);
-DEBUG_FUNC_DECLARE(PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC, glDrawElementsInstancedBaseVertex, GLenum, mode, GLsizei, count, GLenum, type, const void *, indices, GLsizei, instancecount, GLint, basevertex);
-DEBUG_FUNC_DECLARE(PFNGLENDQUERYPROC, glEndQuery, GLenum, target);
-DEBUG_FUNC_DECLARE(PFNGLENDTRANSFORMFEEDBACKPROC, glEndTransformFeedback, void);
-DEBUG_FUNC_DECLARE(PFNGLFRAMEBUFFERTEXTURE2DPROC, glFramebufferTexture2D, GLenum, target, GLenum, attachment, GLenum, textarget, GLuint, texture, GLint, level);
-DEBUG_FUNC_DECLARE(PFNGLFRAMEBUFFERTEXTURELAYERPROC, glFramebufferTextureLayer, GLenum, target, GLenum, attachment, GLuint, texture, GLint, level, GLint, layer);
-DEBUG_FUNC_DECLARE(PFNGLFRAMEBUFFERTEXTUREPROC, glFramebufferTexture, GLenum, target, GLenum, attachment, GLuint, texture, GLint, level);
-DEBUG_FUNC_DECLARE(PFNGLGENBUFFERSPROC, glGenBuffers, GLsizei, n, GLuint *, buffers);
-DEBUG_FUNC_DECLARE(PFNGLGENERATEMIPMAPPROC, glGenerateMipmap, GLenum, target);
-DEBUG_FUNC_DECLARE(PFNGLGENERATETEXTUREMIPMAPPROC, glGenerateTextureMipmap, GLuint, texture);
-DEBUG_FUNC_DECLARE(PFNGLGENFRAMEBUFFERSPROC, glGenFramebuffers, GLsizei, n, GLuint *, framebuffers);
-DEBUG_FUNC_DECLARE(PFNGLGENQUERIESPROC, glGenQueries, GLsizei, n, GLuint *, ids);
-DEBUG_FUNC_DECLARE(PFNGLGENSAMPLERSPROC, glGenSamplers, GLsizei, n, GLuint *, samplers);
-DEBUG_FUNC_DECLARE(PFNGLGENVERTEXARRAYSPROC, glGenVertexArrays, GLsizei, n, GLuint *, arrays);
-DEBUG_FUNC_DECLARE(PFNGLLINKPROGRAMPROC, glLinkProgram, GLuint, program);
-DEBUG_FUNC_DECLARE(PFNGLTEXTUREBUFFERPROC, glTextureBuffer, GLuint, texture, GLenum, internalformat, GLuint, buffer);
-DEBUG_FUNC_DECLARE(PFNGLUSEPROGRAMPROC, glUseProgram, GLuint, program);
+DEBUG_FUNC_DECLARE(PFNGLBEGINQUERYPROC, void, glBeginQuery, GLenum, target, GLuint, id);
+DEBUG_FUNC_DECLARE(PFNGLBEGINTRANSFORMFEEDBACKPROC, void, glBeginTransformFeedback, GLenum, primitiveMode);
+DEBUG_FUNC_DECLARE(PFNGLBINDBUFFERBASEPROC, void, glBindBufferBase, GLenum, target, GLuint, index, GLuint, buffer);
+DEBUG_FUNC_DECLARE(PFNGLBINDBUFFERPROC, void, glBindBuffer, GLenum, target, GLuint, buffer);
+DEBUG_FUNC_DECLARE(PFNGLBINDFRAMEBUFFERPROC, void, glBindFramebuffer, GLenum, target, GLuint, framebuffer);
+DEBUG_FUNC_DECLARE(PFNGLBINDSAMPLERPROC, void, glBindSampler, GLuint, unit, GLuint, sampler);
+DEBUG_FUNC_DECLARE(PFNGLBINDVERTEXARRAYPROC, void, glBindVertexArray, GLuint, array);
+DEBUG_FUNC_DECLARE(PFNGLBLITFRAMEBUFFERPROC, void, glBlitFramebuffer, GLint, srcX0, GLint, srcY0, GLint, srcX1, GLint, srcY1, GLint, dstX0, GLint, dstY0, GLint, dstX1, GLint, dstY1, GLbitfield, mask, GLenum, filter);
+DEBUG_FUNC_DECLARE(PFNGLBUFFERDATAPROC, void, glBufferData, GLenum, target, GLsizeiptr, size, const void *, data, GLenum, usage);
+DEBUG_FUNC_DECLARE(PFNGLBUFFERSUBDATAPROC, void, glBufferSubData, GLenum, target, GLintptr, offset, GLsizeiptr, size, const void *, data);
+DEBUG_FUNC_DECLARE(PFNGLDELETEBUFFERSPROC, void, glDeleteBuffers, GLsizei, n, const GLuint *, buffers);
+DEBUG_FUNC_DECLARE(PFNGLDELETEFRAMEBUFFERSPROC, void, glDeleteFramebuffers, GLsizei, n, const GLuint*, framebuffers);
+DEBUG_FUNC_DECLARE(PFNGLDELETEPROGRAMPROC, void, glDeleteProgram, GLuint, program);
+DEBUG_FUNC_DECLARE(PFNGLDELETEQUERIESPROC, void, glDeleteQueries, GLsizei, n, const GLuint *, ids);
+DEBUG_FUNC_DECLARE(PFNGLDELETESAMPLERSPROC, void, glDeleteSamplers, GLsizei, count, const GLuint *, samplers);
+DEBUG_FUNC_DECLARE(PFNGLDELETESHADERPROC, void, glDeleteShader, GLuint, shader);
+DEBUG_FUNC_DECLARE(PFNGLDELETEVERTEXARRAYSPROC, void, glDeleteVertexArrays, GLsizei, n, const GLuint *, arrays);
+DEBUG_FUNC_DECLARE(PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC, void, glDrawArraysInstancedBaseInstance, GLenum, mode, GLint, first, GLsizei, count, GLsizei, primcount, GLuint, baseinstance);
+DEBUG_FUNC_DECLARE(PFNGLDRAWARRAYSINSTANCEDPROC, void, glDrawArraysInstanced, GLenum, mode, GLint, first, GLsizei, count, GLsizei, primcount);
+DEBUG_FUNC_DECLARE(PFNGLDRAWBUFFERSPROC, void, glDrawBuffers, GLsizei, n, const GLenum*, bufs);
+DEBUG_FUNC_DECLARE(PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC, void, glDrawElementsInstancedBaseVertexBaseInstance, GLenum, mode, GLsizei, count, GLenum, type, const void *, indices, GLsizei, primcount, GLint, basevertex, GLuint, baseinstance);
+DEBUG_FUNC_DECLARE(PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC, void, glDrawElementsInstancedBaseVertex, GLenum, mode, GLsizei, count, GLenum, type, const void *, indices, GLsizei, instancecount, GLint, basevertex);
+DEBUG_FUNC_DECLARE(PFNGLENDQUERYPROC, void, glEndQuery, GLenum, target);
+DEBUG_FUNC_DECLARE(PFNGLENDTRANSFORMFEEDBACKPROC, void, glEndTransformFeedback, void);
+DEBUG_FUNC_DECLARE(PFNGLFRAMEBUFFERTEXTURE2DPROC, void, glFramebufferTexture2D, GLenum, target, GLenum, attachment, GLenum, textarget, GLuint, texture, GLint, level);
+DEBUG_FUNC_DECLARE(PFNGLFRAMEBUFFERTEXTURELAYERPROC, void, glFramebufferTextureLayer, GLenum, target, GLenum, attachment, GLuint, texture, GLint, level, GLint, layer);
+DEBUG_FUNC_DECLARE(PFNGLFRAMEBUFFERTEXTUREPROC, void, glFramebufferTexture, GLenum, target, GLenum, attachment, GLuint, texture, GLint, level);
+DEBUG_FUNC_DECLARE(PFNGLGENBUFFERSPROC, void, glGenBuffers, GLsizei, n, GLuint *, buffers);
+DEBUG_FUNC_DECLARE(PFNGLGENERATEMIPMAPPROC, void, glGenerateMipmap, GLenum, target);
+DEBUG_FUNC_DECLARE(PFNGLGENERATETEXTUREMIPMAPPROC, void, glGenerateTextureMipmap, GLuint, texture);
+DEBUG_FUNC_DECLARE(PFNGLGENFRAMEBUFFERSPROC, void, glGenFramebuffers, GLsizei, n, GLuint *, framebuffers);
+DEBUG_FUNC_DECLARE(PFNGLGENQUERIESPROC, void, glGenQueries, GLsizei, n, GLuint *, ids);
+DEBUG_FUNC_DECLARE(PFNGLGENSAMPLERSPROC, void, glGenSamplers, GLsizei, n, GLuint *, samplers);
+DEBUG_FUNC_DECLARE(PFNGLGENVERTEXARRAYSPROC, void, glGenVertexArrays, GLsizei, n, GLuint *, arrays);
+DEBUG_FUNC_DECLARE(PFNGLLINKPROGRAMPROC, void, glLinkProgram, GLuint, program);
+DEBUG_FUNC_DECLARE(PFNGLMAPBUFFERRANGEPRO

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list