diff --git a/ext/native/thin3d/GLQueueRunner.cpp b/ext/native/thin3d/GLQueueRunner.cpp index c67e3fcfc3..cb5d63d847 100644 --- a/ext/native/thin3d/GLQueueRunner.cpp +++ b/ext/native/thin3d/GLQueueRunner.cpp @@ -56,6 +56,8 @@ void GLQueueRunner::CreateDeviceObjects() { populate(GL_EXTENSIONS); } CHECK_GL_ERROR_IF_DEBUG(); + + useDebugGroups_ = !gl_extensions.IsGLES && gl_extensions.VersionGEThan(4, 3); } void GLQueueRunner::DestroyDeviceObjects() { @@ -132,6 +134,11 @@ void GLQueueRunner::RunInitSteps(const std::vector &steps, bool ski return; } +#if !defined(USING_GLES2) + if (useDebugGroups_) + glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 1, -1, "InitSteps"); +#endif + CHECK_GL_ERROR_IF_DEBUG(); glActiveTexture(GL_TEXTURE0); GLuint boundTexture = (GLuint)-1; @@ -379,6 +386,14 @@ void GLQueueRunner::RunInitSteps(const std::vector &steps, bool ski WARN_LOG(G3D, "Got an error after init: %08x (%s)", err, GLEnumToString(err).c_str()); } } + + glBindBuffer(GL_ARRAY_BUFFER, 0); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + +#if !defined(USING_GLES2) + if (useDebugGroups_) + glPopDebugGroup(); +#endif } void GLQueueRunner::InitCreateFramebuffer(const GLRInitStep &step) { @@ -598,6 +613,12 @@ void GLQueueRunner::RunSteps(const std::vector &steps, bool skipGLCal size_t renderCount = 0; for (size_t i = 0; i < steps.size(); i++) { const GLRStep &step = *steps[i]; + +#if !defined(USING_GLES2) + if (useDebugGroups_) + glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, (GLuint)i + 10000, -1, step.tag); +#endif + switch (step.stepType) { case GLRStepType::RENDER: renderCount++; @@ -621,6 +642,12 @@ void GLQueueRunner::RunSteps(const std::vector &steps, bool skipGLCal Crash(); break; } + +#if !defined(USING_GLES2) + if (useDebugGroups_) + glPopDebugGroup(); +#endif + delete steps[i]; } CHECK_GL_ERROR_IF_DEBUG(); diff --git a/ext/native/thin3d/GLQueueRunner.h b/ext/native/thin3d/GLQueueRunner.h index 8fb5165415..d62c61e4ba 100644 --- a/ext/native/thin3d/GLQueueRunner.h +++ b/ext/native/thin3d/GLQueueRunner.h @@ -421,4 +421,5 @@ private: std::unordered_map glStrings_; bool sawOutOfMemory_ = false; + bool useDebugGroups_ = false; };