Clean up usage of EXT_debug_marker and KHR_debug in the backends.
In RendererGL, the EXT_debug_marker functions were calling the
KHR_debug entry points, now they fall back only when EXT_debug_marker is
missing.
Separated the ContextImpl methods for the two extensions.
BUG=781164
Change-Id: I615b5965b705e55eb730ebefa6e27e0ee6d86c31
Reviewed-on: https://chromium-review.googlesource.com/786337
Reviewed-by: Yuly Novikov <ynovikov@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Geoff Lang <geofflang@chromium.org>
diff --git a/src/libANGLE/Context.cpp b/src/libANGLE/Context.cpp
index f2d09e8..645152d 100644
--- a/src/libANGLE/Context.cpp
+++ b/src/libANGLE/Context.cpp
@@ -3936,11 +3936,13 @@
{
std::string msg(message, (length > 0) ? static_cast<size_t>(length) : strlen(message));
mGLState.getDebug().pushGroup(source, id, std::move(msg));
+ mImplementation->pushDebugGroup(source, id, length, message);
}
void Context::popDebugGroup()
{
mGLState.getDebug().popGroup();
+ mImplementation->popDebugGroup();
}
void Context::bufferData(BufferBinding target, GLsizeiptr size, const void *data, BufferUsage usage)
diff --git a/src/libANGLE/renderer/ContextImpl.h b/src/libANGLE/renderer/ContextImpl.h
index 68f9ddb..2cd52e4 100644
--- a/src/libANGLE/renderer/ContextImpl.h
+++ b/src/libANGLE/renderer/ContextImpl.h
@@ -130,11 +130,15 @@
virtual std::string getVendorString() const = 0;
virtual std::string getRendererDescription() const = 0;
- // Debug markers.
+ // EXT_debug_marker
virtual void insertEventMarker(GLsizei length, const char *marker) = 0;
virtual void pushGroupMarker(GLsizei length, const char *marker) = 0;
virtual void popGroupMarker() = 0;
+ // KHR_debug
+ virtual void pushDebugGroup(GLenum source, GLuint id, GLsizei length, const char *message) = 0;
+ virtual void popDebugGroup() = 0;
+
// State sync with dirty bits.
virtual void syncState(const gl::Context *context, const gl::State::DirtyBits &dirtyBits) = 0;
diff --git a/src/libANGLE/renderer/d3d/d3d11/Context11.cpp b/src/libANGLE/renderer/d3d/d3d11/Context11.cpp
index d5cf230..3ef6043 100644
--- a/src/libANGLE/renderer/d3d/d3d11/Context11.cpp
+++ b/src/libANGLE/renderer/d3d/d3d11/Context11.cpp
@@ -261,6 +261,18 @@
mRenderer->getAnnotator()->endEvent();
}
+void Context11::pushDebugGroup(GLenum source, GLuint id, GLsizei length, const char *message)
+{
+ // Fall through to the EXT_debug_marker functions
+ pushGroupMarker(length, message);
+}
+
+void Context11::popDebugGroup()
+{
+ // Fall through to the EXT_debug_marker functions
+ popGroupMarker();
+}
+
void Context11::syncState(const gl::Context *context, const gl::State::DirtyBits &dirtyBits)
{
mRenderer->getStateManager()->syncState(context, dirtyBits);
diff --git a/src/libANGLE/renderer/d3d/d3d11/Context11.h b/src/libANGLE/renderer/d3d/d3d11/Context11.h
index b70ff34..95194f8 100644
--- a/src/libANGLE/renderer/d3d/d3d11/Context11.h
+++ b/src/libANGLE/renderer/d3d/d3d11/Context11.h
@@ -110,11 +110,15 @@
std::string getVendorString() const override;
std::string getRendererDescription() const override;
- // Debug markers.
+ // EXT_debug_marker
void insertEventMarker(GLsizei length, const char *marker) override;
void pushGroupMarker(GLsizei length, const char *marker) override;
void popGroupMarker() override;
+ // KHR_debug
+ void pushDebugGroup(GLenum source, GLuint id, GLsizei length, const char *message) override;
+ void popDebugGroup() override;
+
// State sync with dirty bits.
void syncState(const gl::Context *context, const gl::State::DirtyBits &dirtyBits) override;
diff --git a/src/libANGLE/renderer/d3d/d3d9/Context9.cpp b/src/libANGLE/renderer/d3d/d3d9/Context9.cpp
index 6f4262b..6320dec 100644
--- a/src/libANGLE/renderer/d3d/d3d9/Context9.cpp
+++ b/src/libANGLE/renderer/d3d/d3d9/Context9.cpp
@@ -240,6 +240,18 @@
mRenderer->getAnnotator()->endEvent();
}
+void Context9::pushDebugGroup(GLenum source, GLuint id, GLsizei length, const char *message)
+{
+ // Fall through to the EXT_debug_marker functions
+ pushGroupMarker(length, message);
+}
+
+void Context9::popDebugGroup()
+{
+ // Fall through to the EXT_debug_marker functions
+ popGroupMarker();
+}
+
void Context9::syncState(const gl::Context *context, const gl::State::DirtyBits &dirtyBits)
{
mRenderer->getStateManager()->syncState(mState.getState(), dirtyBits);
diff --git a/src/libANGLE/renderer/d3d/d3d9/Context9.h b/src/libANGLE/renderer/d3d/d3d9/Context9.h
index 8bde431..f4fb74d 100644
--- a/src/libANGLE/renderer/d3d/d3d9/Context9.h
+++ b/src/libANGLE/renderer/d3d/d3d9/Context9.h
@@ -110,11 +110,15 @@
std::string getVendorString() const override;
std::string getRendererDescription() const override;
- // Debug markers.
+ // EXT_debug_marker
void insertEventMarker(GLsizei length, const char *marker) override;
void pushGroupMarker(GLsizei length, const char *marker) override;
void popGroupMarker() override;
+ // KHR_debug
+ void pushDebugGroup(GLenum source, GLuint id, GLsizei length, const char *message) override;
+ void popDebugGroup() override;
+
// State sync with dirty bits.
void syncState(const gl::Context *context, const gl::State::DirtyBits &dirtyBits) override;
diff --git a/src/libANGLE/renderer/gl/ContextGL.cpp b/src/libANGLE/renderer/gl/ContextGL.cpp
index b325b18..4b368db 100644
--- a/src/libANGLE/renderer/gl/ContextGL.cpp
+++ b/src/libANGLE/renderer/gl/ContextGL.cpp
@@ -341,6 +341,16 @@
mRenderer->popGroupMarker();
}
+void ContextGL::pushDebugGroup(GLenum source, GLuint id, GLsizei length, const char *message)
+{
+ mRenderer->pushDebugGroup(source, id, length, message);
+}
+
+void ContextGL::popDebugGroup()
+{
+ mRenderer->popDebugGroup();
+}
+
void ContextGL::syncState(const gl::Context *context, const gl::State::DirtyBits &dirtyBits)
{
mRenderer->getStateManager()->syncState(context, dirtyBits);
diff --git a/src/libANGLE/renderer/gl/ContextGL.h b/src/libANGLE/renderer/gl/ContextGL.h
index e888616..2295b4d 100644
--- a/src/libANGLE/renderer/gl/ContextGL.h
+++ b/src/libANGLE/renderer/gl/ContextGL.h
@@ -162,11 +162,15 @@
std::string getVendorString() const override;
std::string getRendererDescription() const override;
- // Debug markers.
+ // EXT_debug_marker
void insertEventMarker(GLsizei length, const char *marker) override;
void pushGroupMarker(GLsizei length, const char *marker) override;
void popGroupMarker() override;
+ // KHR_debug
+ void pushDebugGroup(GLenum source, GLuint id, GLsizei length, const char *message) override;
+ void popDebugGroup() override;
+
// State sync with dirty bits.
void syncState(const gl::Context *context, const gl::State::DirtyBits &dirtyBits) override;
diff --git a/src/libANGLE/renderer/gl/DispatchTableGL_autogen.cpp b/src/libANGLE/renderer/gl/DispatchTableGL_autogen.cpp
index 1082aba..2c71f7f 100644
--- a/src/libANGLE/renderer/gl/DispatchTableGL_autogen.cpp
+++ b/src/libANGLE/renderer/gl/DispatchTableGL_autogen.cpp
@@ -2624,6 +2624,13 @@
ASSIGN("glGetObjectLabelEXT", getObjectLabel);
}
+ if (extensions.count("GL_EXT_debug_marker") != 0)
+ {
+ ASSIGN("glInsertEventMarkerEXT", insertEventMarkerEXT);
+ ASSIGN("glPopGroupMarkerEXT", popGroupMarkerEXT);
+ ASSIGN("glPushGroupMarkerEXT", pushGroupMarkerEXT);
+ }
+
if (extensions.count("GL_EXT_draw_instanced") != 0)
{
ASSIGN("glDrawArraysInstancedEXT", drawArraysInstanced);
@@ -5331,6 +5338,13 @@
getObjectLabel = &glGetObjectLabelNULL;
}
+ if (extensions.count("GL_EXT_debug_marker") != 0)
+ {
+ insertEventMarkerEXT = &glInsertEventMarkerEXTNULL;
+ popGroupMarkerEXT = &glPopGroupMarkerEXTNULL;
+ pushGroupMarkerEXT = &glPushGroupMarkerEXTNULL;
+ }
+
if (extensions.count("GL_EXT_draw_instanced") != 0)
{
drawArraysInstanced = &glDrawArraysInstancedNULL;
diff --git a/src/libANGLE/renderer/gl/DispatchTableGL_autogen.h b/src/libANGLE/renderer/gl/DispatchTableGL_autogen.h
index 06110a3..1f09309 100644
--- a/src/libANGLE/renderer/gl/DispatchTableGL_autogen.h
+++ b/src/libANGLE/renderer/gl/DispatchTableGL_autogen.h
@@ -731,6 +731,11 @@
PFNGLBLENDBARRIERPROC blendBarrier = nullptr;
PFNGLPRIMITIVEBOUNDINGBOXPROC primitiveBoundingBox = nullptr;
+ // EXT_debug_marker
+ PFNGLINSERTEVENTMARKEREXTPROC insertEventMarkerEXT = nullptr;
+ PFNGLPOPGROUPMARKEREXTPROC popGroupMarkerEXT = nullptr;
+ PFNGLPUSHGROUPMARKEREXTPROC pushGroupMarkerEXT = nullptr;
+
// GL_EXT_discard_framebuffer
PFNGLDISCARDFRAMEBUFFEREXTPROC discardFramebufferEXT = nullptr;
diff --git a/src/libANGLE/renderer/gl/RendererGL.cpp b/src/libANGLE/renderer/gl/RendererGL.cpp
index 63a430d..00a4172 100644
--- a/src/libANGLE/renderer/gl/RendererGL.cpp
+++ b/src/libANGLE/renderer/gl/RendererGL.cpp
@@ -548,18 +548,69 @@
void RendererGL::insertEventMarker(GLsizei length, const char *marker)
{
- mFunctions->debugMessageInsert(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_MARKER, 0,
- GL_DEBUG_SEVERITY_NOTIFICATION, length, marker);
+ if (mFunctions->insertEventMarkerEXT)
+ {
+ mFunctions->insertEventMarkerEXT(length, marker);
+ }
+ else if (mFunctions->debugMessageInsert)
+ {
+ mFunctions->debugMessageInsert(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_MARKER, 0,
+ GL_DEBUG_SEVERITY_NOTIFICATION, length, marker);
+ }
+ else
+ {
+ UNREACHABLE();
+ }
}
void RendererGL::pushGroupMarker(GLsizei length, const char *marker)
{
- mFunctions->pushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, length, marker);
+ if (mFunctions->pushGroupMarkerEXT)
+ {
+ mFunctions->pushGroupMarkerEXT(length, marker);
+ }
+ else if (mFunctions->pushDebugGroup)
+ {
+ // Fall back to KHR_debug to implement EXT_debug_marker
+ mFunctions->pushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, length, marker);
+ }
+ else
+ {
+ UNREACHABLE();
+ }
}
void RendererGL::popGroupMarker()
{
- mFunctions->popDebugGroup();
+ if (mFunctions->popGroupMarkerEXT)
+ {
+ mFunctions->popGroupMarkerEXT();
+ }
+ else if (mFunctions->popDebugGroup)
+ {
+ // Fall back to KHR_debug to implement EXT_debug_marker
+ mFunctions->popDebugGroup();
+ }
+ else
+ {
+ UNREACHABLE();
+ }
+}
+
+void RendererGL::pushDebugGroup(GLenum source, GLuint id, GLsizei length, const char *message)
+{
+ if (mFunctions->pushDebugGroup)
+ {
+ mFunctions->pushDebugGroup(source, id, length, message);
+ }
+}
+
+void RendererGL::popDebugGroup()
+{
+ if (mFunctions->popDebugGroup)
+ {
+ mFunctions->popDebugGroup();
+ }
}
std::string RendererGL::getVendorString() const
diff --git a/src/libANGLE/renderer/gl/RendererGL.h b/src/libANGLE/renderer/gl/RendererGL.h
index 964a1cd..e83e17d 100644
--- a/src/libANGLE/renderer/gl/RendererGL.h
+++ b/src/libANGLE/renderer/gl/RendererGL.h
@@ -149,6 +149,10 @@
void pushGroupMarker(GLsizei length, const char *marker);
void popGroupMarker();
+ // KHR_debug
+ void pushDebugGroup(GLenum source, GLuint id, GLsizei length, const char *message);
+ void popDebugGroup();
+
std::string getVendorString() const;
std::string getRendererDescription() const;
diff --git a/src/libANGLE/renderer/gl/functionsgl_typedefs.h b/src/libANGLE/renderer/gl/functionsgl_typedefs.h
index f7c65a3..d590d48 100644
--- a/src/libANGLE/renderer/gl/functionsgl_typedefs.h
+++ b/src/libANGLE/renderer/gl/functionsgl_typedefs.h
@@ -904,6 +904,13 @@
GLenum pname,
GLsizei bufSize,
GLint *params);
+
+// EXT_debug_marker
+typedef void(INTERNAL_GL_APIENTRY *PFNGLINSERTEVENTMARKEREXTPROC)(GLsizei length,
+ const GLchar *marker);
+typedef void(INTERNAL_GL_APIENTRY *PFNGLPUSHGROUPMARKEREXTPROC)(GLsizei length,
+ const GLchar *marker);
+typedef void(INTERNAL_GL_APIENTRY *PFNGLPOPGROUPMARKEREXTPROC)(void);
}
#endif // LIBANGLE_RENDERER_GL_FUNCTIONSGLTYPEDEFS_H_
diff --git a/src/libANGLE/renderer/gl/gl_bindings_data.json b/src/libANGLE/renderer/gl/gl_bindings_data.json
index d4e0a2f..10aab37 100644
--- a/src/libANGLE/renderer/gl/gl_bindings_data.json
+++ b/src/libANGLE/renderer/gl/gl_bindings_data.json
@@ -783,5 +783,12 @@
"GL_NV_internalformat_sample_query":
[
"GetInternalformatSampleivNV"
+ ],
+
+ "GL_EXT_debug_marker":
+ [
+ "InsertEventMarkerEXT",
+ "PushGroupMarkerEXT",
+ "PopGroupMarkerEXT"
]
}
diff --git a/src/libANGLE/renderer/gl/null_functions.cpp b/src/libANGLE/renderer/gl/null_functions.cpp
index d7f52da..ad67e1a 100644
--- a/src/libANGLE/renderer/gl/null_functions.cpp
+++ b/src/libANGLE/renderer/gl/null_functions.cpp
@@ -1960,6 +1960,10 @@
{
}
+void INTERNAL_GL_APIENTRY glInsertEventMarkerEXTNULL(GLsizei length, const GLchar *marker)
+{
+}
+
void INTERNAL_GL_APIENTRY glInvalidateBufferDataNULL(GLuint buffer)
{
}
@@ -2352,6 +2356,10 @@
{
}
+void INTERNAL_GL_APIENTRY glPopGroupMarkerEXTNULL()
+{
+}
+
void INTERNAL_GL_APIENTRY glPrimitiveBoundingBoxNULL(GLfloat minX,
GLfloat minY,
GLfloat minZ,
@@ -2742,6 +2750,10 @@
{
}
+void INTERNAL_GL_APIENTRY glPushGroupMarkerEXTNULL(GLsizei length, const GLchar *marker)
+{
+}
+
void INTERNAL_GL_APIENTRY glQueryCounterNULL(GLuint id, GLenum target)
{
}
diff --git a/src/libANGLE/renderer/gl/null_functions.h b/src/libANGLE/renderer/gl/null_functions.h
index 4843e4d..c4dc6de 100644
--- a/src/libANGLE/renderer/gl/null_functions.h
+++ b/src/libANGLE/renderer/gl/null_functions.h
@@ -972,6 +972,7 @@
GLsizei bufSize,
GLuint *params);
void INTERNAL_GL_APIENTRY glHintNULL(GLenum target, GLenum mode);
+void INTERNAL_GL_APIENTRY glInsertEventMarkerEXTNULL(GLsizei length, const GLchar *marker);
void INTERNAL_GL_APIENTRY glInvalidateBufferDataNULL(GLuint buffer);
void INTERNAL_GL_APIENTRY glInvalidateBufferSubDataNULL(GLuint buffer,
GLintptr offset,
@@ -1133,6 +1134,7 @@
void INTERNAL_GL_APIENTRY glPolygonModeNULL(GLenum face, GLenum mode);
void INTERNAL_GL_APIENTRY glPolygonOffsetNULL(GLfloat factor, GLfloat units);
void INTERNAL_GL_APIENTRY glPopDebugGroupNULL();
+void INTERNAL_GL_APIENTRY glPopGroupMarkerEXTNULL();
void INTERNAL_GL_APIENTRY glPrimitiveBoundingBoxNULL(GLfloat minX,
GLfloat minY,
GLfloat minZ,
@@ -1355,6 +1357,7 @@
GLuint id,
GLsizei length,
const GLchar *message);
+void INTERNAL_GL_APIENTRY glPushGroupMarkerEXTNULL(GLsizei length, const GLchar *marker);
void INTERNAL_GL_APIENTRY glQueryCounterNULL(GLuint id, GLenum target);
void INTERNAL_GL_APIENTRY glReadBufferNULL(GLenum src);
void INTERNAL_GL_APIENTRY glReadPixelsNULL(GLint x,
diff --git a/src/libANGLE/renderer/gl/renderergl_utils.cpp b/src/libANGLE/renderer/gl/renderergl_utils.cpp
index 4cf9a3d..f5c23be 100644
--- a/src/libANGLE/renderer/gl/renderergl_utils.cpp
+++ b/src/libANGLE/renderer/gl/renderergl_utils.cpp
@@ -935,9 +935,12 @@
extensions->packSubimage = functions->standard == STANDARD_GL_DESKTOP ||
functions->isAtLeastGLES(gl::Version(3, 0)) ||
functions->hasGLESExtension("GL_NV_pack_subimage");
- extensions->debugMarker =
- functions->isAtLeastGL(gl::Version(4, 3)) || functions->hasGLExtension("GL_KHR_debug") ||
- functions->isAtLeastGLES(gl::Version(3, 2)) || functions->hasGLESExtension("GL_KHR_debug");
+ extensions->debugMarker = functions->isAtLeastGL(gl::Version(4, 3)) ||
+ functions->hasGLExtension("GL_KHR_debug") ||
+ functions->hasGLExtension("GL_EXT_debug_marker") ||
+ functions->isAtLeastGLES(gl::Version(3, 2)) ||
+ functions->hasGLESExtension("GL_KHR_debug") ||
+ functions->hasGLESExtension("GL_EXT_debug_marker");
if (functions->isAtLeastGL(gl::Version(3, 3)) ||
functions->hasGLExtension("GL_ARB_timer_query") ||
functions->hasGLESExtension("GL_EXT_disjoint_timer_query"))
diff --git a/src/libANGLE/renderer/null/ContextNULL.cpp b/src/libANGLE/renderer/null/ContextNULL.cpp
index abd5c88..0240898 100644
--- a/src/libANGLE/renderer/null/ContextNULL.cpp
+++ b/src/libANGLE/renderer/null/ContextNULL.cpp
@@ -280,6 +280,14 @@
{
}
+void ContextNULL::pushDebugGroup(GLenum source, GLuint id, GLsizei length, const char *message)
+{
+}
+
+void ContextNULL::popDebugGroup()
+{
+}
+
void ContextNULL::syncState(const gl::Context *context, const gl::State::DirtyBits &dirtyBits)
{
}
diff --git a/src/libANGLE/renderer/null/ContextNULL.h b/src/libANGLE/renderer/null/ContextNULL.h
index 74feb73..b418431 100644
--- a/src/libANGLE/renderer/null/ContextNULL.h
+++ b/src/libANGLE/renderer/null/ContextNULL.h
@@ -132,11 +132,15 @@
std::string getVendorString() const override;
std::string getRendererDescription() const override;
- // Debug markers.
+ // EXT_debug_marker
void insertEventMarker(GLsizei length, const char *marker) override;
void pushGroupMarker(GLsizei length, const char *marker) override;
void popGroupMarker() override;
+ // KHR_debug
+ void pushDebugGroup(GLenum source, GLuint id, GLsizei length, const char *message) override;
+ void popDebugGroup() override;
+
// State sync with dirty bits.
void syncState(const gl::Context *context, const gl::State::DirtyBits &dirtyBits) override;
diff --git a/src/libANGLE/renderer/vulkan/ContextVk.cpp b/src/libANGLE/renderer/vulkan/ContextVk.cpp
index 0ba2082..4659281 100644
--- a/src/libANGLE/renderer/vulkan/ContextVk.cpp
+++ b/src/libANGLE/renderer/vulkan/ContextVk.cpp
@@ -503,6 +503,16 @@
UNIMPLEMENTED();
}
+void ContextVk::pushDebugGroup(GLenum source, GLuint id, GLsizei length, const char *message)
+{
+ UNIMPLEMENTED();
+}
+
+void ContextVk::popDebugGroup()
+{
+ UNIMPLEMENTED();
+}
+
void ContextVk::syncState(const gl::Context *context, const gl::State::DirtyBits &dirtyBits)
{
if (dirtyBits.any())
diff --git a/src/libANGLE/renderer/vulkan/ContextVk.h b/src/libANGLE/renderer/vulkan/ContextVk.h
index 2963f99..857c19e 100644
--- a/src/libANGLE/renderer/vulkan/ContextVk.h
+++ b/src/libANGLE/renderer/vulkan/ContextVk.h
@@ -77,11 +77,15 @@
std::string getVendorString() const override;
std::string getRendererDescription() const override;
- // Debug markers.
+ // EXT_debug_marker
void insertEventMarker(GLsizei length, const char *marker) override;
void pushGroupMarker(GLsizei length, const char *marker) override;
void popGroupMarker() override;
+ // KHR_debug
+ void pushDebugGroup(GLenum source, GLuint id, GLsizei length, const char *message) override;
+ void popDebugGroup() override;
+
// State sync with dirty bits.
void syncState(const gl::Context *context, const gl::State::DirtyBits &dirtyBits) override;