From ca2d87e5e38f84a1f4336c995fa71fb0e235e667 Mon Sep 17 00:00:00 2001
From: GPUCode <47210458+GPUCode@users.noreply.github.com>
Date: Fri, 30 Jun 2023 02:16:54 +0300
Subject: [PATCH] renderer_opengl: Add debug scopes to logging (#6650)

---
 src/video_core/renderer_opengl/gl_driver.cpp          | 2 ++
 src/video_core/renderer_opengl/gl_texture_runtime.cpp | 7 +++++++
 2 files changed, 9 insertions(+)

diff --git a/src/video_core/renderer_opengl/gl_driver.cpp b/src/video_core/renderer_opengl/gl_driver.cpp
index 08f6b9ae9..9951d0ae7 100644
--- a/src/video_core/renderer_opengl/gl_driver.cpp
+++ b/src/video_core/renderer_opengl/gl_driver.cpp
@@ -44,6 +44,8 @@ inline std::string_view GetType(GLenum type) {
         RET(PERFORMANCE);
         RET(OTHER);
         RET(MARKER);
+        RET(POP_GROUP);
+        RET(PUSH_GROUP);
     default:
         UNREACHABLE();
     }
diff --git a/src/video_core/renderer_opengl/gl_texture_runtime.cpp b/src/video_core/renderer_opengl/gl_texture_runtime.cpp
index fcbcf957c..e9c6816fb 100644
--- a/src/video_core/renderer_opengl/gl_texture_runtime.cpp
+++ b/src/video_core/renderer_opengl/gl_texture_runtime.cpp
@@ -3,6 +3,7 @@
 // Refer to the license.txt file included.
 
 #include "common/scope_exit.h"
+#include "common/settings.h"
 #include "video_core/custom_textures/material.h"
 #include "video_core/regs.h"
 #include "video_core/renderer_base.h"
@@ -702,10 +703,16 @@ Sampler::~Sampler() = default;
 
 DebugScope::DebugScope(TextureRuntime& runtime, Common::Vec4f, std::string_view label)
     : local_scope_depth{global_scope_depth++} {
+    if (!Settings::values.renderer_debug) {
+        return;
+    }
     glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, local_scope_depth, label.size(), label.data());
 }
 
 DebugScope::~DebugScope() {
+    if (!Settings::values.renderer_debug) {
+        return;
+    }
     glPopDebugGroup();
     global_scope_depth--;
 }