diff --git a/Common/GPU/OpenGL/GLQueueRunner.cpp b/Common/GPU/OpenGL/GLQueueRunner.cpp index dd34c47cf4..c2a909b7cc 100644 --- a/Common/GPU/OpenGL/GLQueueRunner.cpp +++ b/Common/GPU/OpenGL/GLQueueRunner.cpp @@ -1843,3 +1843,44 @@ GLRFramebuffer::~GLRFramebuffer() { glDeleteRenderbuffers(1, &stencil_buffer); CHECK_GL_ERROR_IF_DEBUG(); } + +std::string GLQueueRunner::StepToString(const GLRStep &step) const { + char buffer[256]; + switch (step.stepType) { + case GLRStepType::RENDER: + { + int w = step.render.framebuffer ? step.render.framebuffer->width : targetWidth_; + int h = step.render.framebuffer ? step.render.framebuffer->height : targetHeight_; + snprintf(buffer, sizeof(buffer), "RENDER %s %s (draws: %d, %dx%d)", step.tag, step.render.framebuffer ? step.render.framebuffer->Tag() : "", -1, w, h); + break; + } + case GLRStepType::COPY: + snprintf(buffer, sizeof(buffer), "COPY '%s' %s -> %s (%dx%d, %s)", step.tag, step.copy.src->Tag(), step.copy.dst->Tag(), step.copy.srcRect.w, step.copy.srcRect.h, GLRAspectToString((GLRAspect)step.copy.aspectMask)); + break; + case GLRStepType::BLIT: + snprintf(buffer, sizeof(buffer), "BLIT '%s' %s -> %s (%dx%d->%dx%d, %s)", step.tag, step.copy.src->Tag(), step.copy.dst->Tag(), step.blit.srcRect.w, step.blit.srcRect.h, step.blit.dstRect.w, step.blit.dstRect.h, GLRAspectToString((GLRAspect)step.blit.aspectMask)); + break; + case GLRStepType::READBACK: + snprintf(buffer, sizeof(buffer), "READBACK '%s' %s (%dx%d, %s)", step.tag, step.readback.src ? step.readback.src->Tag() : "(backbuffer)", step.readback.srcRect.w, step.readback.srcRect.h, GLRAspectToString((GLRAspect)step.readback.aspectMask)); + break; + case GLRStepType::READBACK_IMAGE: + snprintf(buffer, sizeof(buffer), "READBACK_IMAGE '%s' (%dx%d)", step.tag, step.readback_image.srcRect.w, step.readback_image.srcRect.h); + break; + case GLRStepType::RENDER_SKIP: + snprintf(buffer, sizeof(buffer), "(RENDER_SKIP) %s", step.tag); + break; + default: + buffer[0] = 0; + break; + } + return std::string(buffer); +} + +const char *GLRAspectToString(GLRAspect aspect) { + switch (aspect) { + case GLR_ASPECT_COLOR: return "COLOR"; + case GLR_ASPECT_DEPTH: return "DEPTH"; + case GLR_ASPECT_STENCIL: return "STENCIL"; + default: return "N/A"; + } +} diff --git a/Common/GPU/OpenGL/GLQueueRunner.h b/Common/GPU/OpenGL/GLQueueRunner.h index c309688a9d..111cd4e6de 100644 --- a/Common/GPU/OpenGL/GLQueueRunner.h +++ b/Common/GPU/OpenGL/GLQueueRunner.h @@ -290,11 +290,12 @@ enum class GLRRenderPassAction { class GLRFramebuffer; -enum { +enum GLRAspect { GLR_ASPECT_COLOR = 1, GLR_ASPECT_DEPTH = 2, GLR_ASPECT_STENCIL = 3, }; +const char *GLRAspectToString(GLRAspect aspect); struct GLRStep { GLRStep(GLRStepType _type) : stepType(_type) {} @@ -389,6 +390,8 @@ private: GLenum fbo_get_fb_target(bool read, GLuint **cached); void fbo_unbind(); + std::string StepToString(const GLRStep &step) const; + GLRFramebuffer *curFB_ = nullptr; GLuint globalVAO_ = 0; diff --git a/Common/GPU/OpenGL/GLRenderManager.h b/Common/GPU/OpenGL/GLRenderManager.h index c03a6ed56f..3298d6317f 100644 --- a/Common/GPU/OpenGL/GLRenderManager.h +++ b/Common/GPU/OpenGL/GLRenderManager.h @@ -53,13 +53,14 @@ public: class GLRFramebuffer { public: - GLRFramebuffer(const Draw::DeviceCaps &caps, int _width, int _height, bool z_stencil) + GLRFramebuffer(const Draw::DeviceCaps &caps, int _width, int _height, bool z_stencil, const char *tag) : color_texture(caps, _width, _height, 1, 1), z_stencil_texture(caps, _width, _height, 1, 1), width(_width), height(_height), z_stencil_(z_stencil) { } - ~GLRFramebuffer(); + const char *Tag() const { return tag_.c_str(); } + GLuint handle = 0; GLRTexture color_texture; // Either z_stencil_texture, z_stencil_buffer, or (z_buffer and stencil_buffer) are set. @@ -71,8 +72,10 @@ public: int width; int height; GLuint colorDepth = 0; - bool z_stencil_; + +private: + std::string tag_; }; // We need to create some custom heap-allocated types so we can forward things that need to be created on the GL thread, before @@ -283,10 +286,10 @@ public: return step.create_shader.shader; } - GLRFramebuffer *CreateFramebuffer(int width, int height, bool z_stencil) { + GLRFramebuffer *CreateFramebuffer(int width, int height, bool z_stencil, const char *tag) { GLRInitStep &step = initSteps_.push_uninitialized(); step.stepType = GLRInitStepType::CREATE_FRAMEBUFFER; - step.create_framebuffer.framebuffer = new GLRFramebuffer(caps_, width, height, z_stencil); + step.create_framebuffer.framebuffer = new GLRFramebuffer(caps_, width, height, z_stencil, tag); return step.create_framebuffer.framebuffer; } diff --git a/Common/GPU/OpenGL/thin3d_gl.cpp b/Common/GPU/OpenGL/thin3d_gl.cpp index c2fa1deb28..d4054987f0 100644 --- a/Common/GPU/OpenGL/thin3d_gl.cpp +++ b/Common/GPU/OpenGL/thin3d_gl.cpp @@ -1447,7 +1447,7 @@ Framebuffer *OpenGLContext::CreateFramebuffer(const FramebufferDesc &desc) { // TODO: Support multiview later. (It's our only use case for multi layers). _dbg_assert_(desc.numLayers == 1); - GLRFramebuffer *framebuffer = renderManager_.CreateFramebuffer(desc.width, desc.height, desc.z_stencil); + GLRFramebuffer *framebuffer = renderManager_.CreateFramebuffer(desc.width, desc.height, desc.z_stencil, desc.tag); OpenGLFramebuffer *fbo = new OpenGLFramebuffer(&renderManager_, framebuffer); return fbo; }