thin3d: Add Framebuffer::HasDepthStencil, check it before depth/stencil copies

ResizeFramebufFBO now asks the framebuffer whether it has a depth/stencil
buffer instead of guessing from the z address and stride.

Vulkan CopyFramebuffer gets the debug asserts and bail-out BlitFramebuffer
already had, and GL copies and blits get the same, so a copy out of a
framebuffer without depth/stencil asserts where it's queued instead of in
the queue runner.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Henrik RydgårdandClaude Opus 5.5 committed 2026-10-16 17:44:09 +02:00
1 parent 8fb0f74255
commit 074b66b49b
6 files changed
+35 -5

No files matched your search

+2 -3
View File
@@ -2035,9 +2035,8 @@ void FramebufferManagerCommon::ResizeFramebufFBO(VirtualFramebuffer *vfb, int w,
if (vfb->usageFlags & FB_USAGE_RENDER_DEPTH) {
BlitFramebuffer(vfb, 0, 0, &old, 0, 0, std::min((u16)oldWidth, std::min(vfb->bufferWidth, vfb->width)), std::min((u16)oldHeight, std::min(vfb->height, vfb->bufferHeight)), 0, RASTER_DEPTH, "BlitDepth_ResizeFramebufFBO");
}
// A color framebuffer from CreateRAMFramebuffer (no z address or stride) has no depth/stencil buffer to copy from.
const bool oldHasStencil = old.z_address != 0 || old.z_stride != 0;
if (!skipCopy && vfb->fb_format != GE_FORMAT_565 && oldHasStencil) {
// A color framebuffer from CreateRAMFramebuffer has no depth/stencil buffer to copy from.
if (!skipCopy && vfb->fb_format != GE_FORMAT_565 && old.fbo->HasDepthStencil()) {
// Keep the stencil too (Need for Speed Shift stencil tests right after its framebuffer grows from 480 to
// 512 wide). D3D11 has no separate stencil copy, but copies it along with the depth above.
const int stencilW = std::min(old.renderWidth, vfb->renderWidth);