diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2019-03-29 19:09:29 +0100 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2019-04-05 11:49:17 +0200 |
commit | c02010ab6c8958f6897921c82cf47411de759269 (patch) | |
tree | 031d0b9f17d66c62232249b416fd327a2a519488 /src/mbgl/gl | |
parent | 543b678982037595895a474f3a69348dc235e0fa (diff) | |
download | qtlocation-mapboxgl-c02010ab6c8958f6897921c82cf47411de759269.tar.gz |
[core] move debug groups to gfx::CommandEncoder
Diffstat (limited to 'src/mbgl/gl')
-rw-r--r-- | src/mbgl/gl/command_encoder.cpp | 31 | ||||
-rw-r--r-- | src/mbgl/gl/command_encoder.hpp | 6 | ||||
-rw-r--r-- | src/mbgl/gl/context.cpp | 3 | ||||
-rw-r--r-- | src/mbgl/gl/debugging.cpp | 35 | ||||
-rw-r--r-- | src/mbgl/gl/debugging.hpp | 37 |
5 files changed, 36 insertions, 76 deletions
diff --git a/src/mbgl/gl/command_encoder.cpp b/src/mbgl/gl/command_encoder.cpp index 82046202bc..e1bf5e1187 100644 --- a/src/mbgl/gl/command_encoder.cpp +++ b/src/mbgl/gl/command_encoder.cpp @@ -1,12 +1,43 @@ #include <mbgl/gl/command_encoder.hpp> #include <mbgl/gl/context.hpp> +#include <mbgl/gl/debugging_extension.hpp> +#include <mbgl/platform/gl_functions.hpp> + +#include <cstring> namespace mbgl { namespace gl { CommandEncoder::~CommandEncoder() { + const auto debugGroup(createDebugGroup("cleanup")); context.performCleanup(); } +void CommandEncoder::pushDebugGroup(const char* name) { + (void)name; +#ifndef NDEBUG + if (auto debugging = context.getDebuggingExtension()) { + if (debugging->pushDebugGroup) { + MBGL_CHECK_ERROR(debugging->pushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, + platform::GLsizei(strlen(name)), name)); + } else if (debugging->pushGroupMarkerEXT) { + MBGL_CHECK_ERROR(debugging->pushGroupMarkerEXT(platform::GLsizei(strlen(name) + 1), name)); + } + } +#endif +} + +void CommandEncoder::popDebugGroup() { +#ifndef NDEBUG + if (auto debugging = context.getDebuggingExtension()) { + if (debugging->popDebugGroup) { + MBGL_CHECK_ERROR(debugging->popDebugGroup()); + } else if (debugging->popGroupMarkerEXT) { + MBGL_CHECK_ERROR(debugging->popGroupMarkerEXT()); + } + } +#endif +} + } // namespace gl } // namespace mbgl diff --git a/src/mbgl/gl/command_encoder.hpp b/src/mbgl/gl/command_encoder.hpp index 0cfe80f433..b4f7d2af13 100644 --- a/src/mbgl/gl/command_encoder.hpp +++ b/src/mbgl/gl/command_encoder.hpp @@ -7,7 +7,7 @@ namespace gl { class Context; -class CommandEncoder : public gfx::CommandEncoder { +class CommandEncoder final : public gfx::CommandEncoder { public: explicit CommandEncoder(gl::Context& context_) : context(context_) { } @@ -15,6 +15,10 @@ public: ~CommandEncoder() override; private: + void pushDebugGroup(const char* name) override; + void popDebugGroup() override; + +public: gl::Context& context; }; diff --git a/src/mbgl/gl/context.cpp b/src/mbgl/gl/context.cpp index 97c1cd24d7..bc93042e25 100644 --- a/src/mbgl/gl/context.cpp +++ b/src/mbgl/gl/context.cpp @@ -7,7 +7,6 @@ #include <mbgl/gl/draw_scope_resource.hpp> #include <mbgl/gl/texture.hpp> #include <mbgl/gl/command_encoder.hpp> -#include <mbgl/gl/debugging.hpp> #include <mbgl/gl/debugging_extension.hpp> #include <mbgl/gl/vertex_array_extension.hpp> #include <mbgl/gl/program_binary_extension.hpp> @@ -726,8 +725,6 @@ void Context::performCleanup() { // TODO: Find a better way to unbind VAOs after we're done with them without introducing // unnecessary bind(0)/bind(N) sequences. { - MBGL_DEBUG_GROUP(*this, "cleanup"); - activeTextureUnit = 1; texture[1] = 0; activeTextureUnit = 0; diff --git a/src/mbgl/gl/debugging.cpp b/src/mbgl/gl/debugging.cpp deleted file mode 100644 index 54cee5fc09..0000000000 --- a/src/mbgl/gl/debugging.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include <mbgl/gl/debugging.hpp> -#include <mbgl/gl/context.hpp> -#include <mbgl/gl/debugging_extension.hpp> - -namespace mbgl { -namespace gl { - -using namespace platform; - -#ifndef NDEBUG - -DebugGroup::DebugGroup(const gfx::Context& context_, const std::string& name) : context(context_) { - if (auto debugging = reinterpret_cast<const gl::Context&>(context).getDebuggingExtension()) { - if (debugging->pushDebugGroup) { - MBGL_CHECK_ERROR(debugging->pushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, GLsizei(name.size()), name.c_str())); - } else if (debugging->pushGroupMarkerEXT) { - MBGL_CHECK_ERROR(debugging->pushGroupMarkerEXT(GLsizei(name.size() + 1), name.c_str())); - } - } -} - -DebugGroup::~DebugGroup() { - if (auto debugging = reinterpret_cast<const gl::Context&>(context).getDebuggingExtension()) { - if (debugging->popDebugGroup) { - MBGL_CHECK_ERROR(debugging->popDebugGroup()); - } else if (debugging->popGroupMarkerEXT) { - MBGL_CHECK_ERROR(debugging->popGroupMarkerEXT()); - } - } -} - -#endif - -} // namespace gl -} // namespace mbgl diff --git a/src/mbgl/gl/debugging.hpp b/src/mbgl/gl/debugging.hpp deleted file mode 100644 index d85eb631be..0000000000 --- a/src/mbgl/gl/debugging.hpp +++ /dev/null @@ -1,37 +0,0 @@ -#pragma once - -#include <mbgl/util/noncopyable.hpp> - -#include <string> - -namespace mbgl { - -namespace gfx { -class Context; -} // namespace gfx - -namespace gl { - -#ifndef NDEBUG - -class DebugGroup : private util::noncopyable { -public: - DebugGroup(const gfx::Context&, const std::string&); - ~DebugGroup(); - -private: - const gfx::Context& context; -}; - -#define __MBGL_DEBUG_GROUP_NAME2(counter) __MBGL_DEBUG_GROUP_##counter -#define __MBGL_DEBUG_GROUP_NAME(counter) __MBGL_DEBUG_GROUP_NAME2(counter) -#define MBGL_DEBUG_GROUP(context, name) const ::mbgl::gl::DebugGroup __MBGL_DEBUG_GROUP_NAME(__LINE__)(context, name); - -#else - -#define MBGL_DEBUG_GROUP(context, name) - -#endif - -} // namespace gl -} // namespace mbgl |