GE Debugger: Normalize framebuffer texture preview.

Previously, we would show the render-to-texture with its original
dimensions.  While useful, this skewed the preview coordinates and was
sometimes confusing.  Additionally, depth texturing didn't preview.

This pads and subsets the texture preview so it's the right size.
This commit is contained in:
Unknown W. Brackets committed 2022-10-10 21:54:24 -07:00
1 parent fc9f200224
commit 48c39543af
3 files changed
+27 -2

No files matched your search

+5
View File
@@ -985,6 +985,11 @@ void GPUDebugBuffer::Free() {
data_ = NULL;
}
void GPUDebugBuffer::ZeroBytes() {
_dbg_assert_(data_);
memset(data_, 0, PixelSize() * stride_ * height_);
}
u32 GPUDebugBuffer::PixelSize() const {
switch (fmt_) {
case GPU_DBG_FORMAT_8888:
+2
View File
@@ -136,6 +136,8 @@ struct GPUDebugBuffer {
void Allocate(u32 stride, u32 height, GPUDebugBufferFormat fmt, bool flipped = false);
void Free();
void ZeroBytes();
u8 *GetData() {
return data_;
}
+20 -2
View File
@@ -1167,8 +1167,26 @@ bool TextureCacheCommon::GetCurrentFramebufferTextureDebug(GPUDebugBuffer &buffe
return false;
VirtualFramebuffer *vfb = nextFramebufferTexture_;
buffer.Allocate(vfb->bufferWidth, vfb->bufferHeight, GPU_DBG_FORMAT_8888, false);
bool retval = draw_->CopyFramebufferToMemorySync(vfb->fbo, Draw::FB_COLOR_BIT, 0, 0, vfb->bufferWidth, vfb->bufferHeight, Draw::DataFormat::R8G8B8A8_UNORM, buffer.GetData(), vfb->bufferWidth, "GetCurrentTextureDebug");
u8 sf = vfb->renderScaleFactor;
int x = gstate_c.curTextureXOffset * sf;
int y = gstate_c.curTextureYOffset * sf;
int desiredW = gstate.getTextureWidth(0) * sf;
int desiredH = gstate.getTextureHeight(0) * sf;
int w = std::min(desiredW, vfb->bufferWidth * sf - x);
int h = std::min(desiredH, vfb->bufferHeight * sf - y);
bool retval;
if (nextFramebufferTextureChannel_ == RASTER_DEPTH) {
buffer.Allocate(desiredW, desiredH, GPU_DBG_FORMAT_FLOAT, false);
if (w < desiredW || h < desiredH)
buffer.ZeroBytes();
retval = draw_->CopyFramebufferToMemorySync(vfb->fbo, Draw::FB_DEPTH_BIT, x, y, w, h, Draw::DataFormat::D32F, buffer.GetData(), desiredW, "GetCurrentTextureDebug");
} else {
buffer.Allocate(desiredW, desiredH, GPU_DBG_FORMAT_8888, false);
if (w < desiredW || h < desiredH)
buffer.ZeroBytes();
retval = draw_->CopyFramebufferToMemorySync(vfb->fbo, Draw::FB_COLOR_BIT, x, y, w, h, Draw::DataFormat::R8G8B8A8_UNORM, buffer.GetData(), desiredW, "GetCurrentTextureDebug");
}
// Vulkan requires us to re-apply all dynamic state for each command buffer, and the above will cause us to start a new cmdbuf.
// So let's dirty the things that are involved in Vulkan dynamic state. Readbacks are not frequent so this won't hurt other backends.