Skip to content

Commit c39f4ab

Browse files
NativeEngine: report depth present when stencil-without-depth allocates depth/stencil
When generateStencilBuffer is requested without generateDepth, CreateFrameBuffer still allocates a combined D24S8 depth/stencil attachment, but the FrameBuffer was constructed with hasDepth=generateDepth (false). That made HasDepth() return false, so Clear/DrawInternal skipped depth clear and Z-writes against a depth buffer that actually exists. Report hasDepth as (generateDepth || generateStencilBuffer). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 73adf6f commit c39f4ab

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

Plugins/NativeEngine/Source/NativeEngine.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1878,7 +1878,11 @@ namespace Babylon
18781878
throw Napi::Error::New(info.Env(), "Failed to create frame buffer");
18791879
}
18801880

1881-
Graphics::FrameBuffer* frameBuffer = new Graphics::FrameBuffer(m_deviceContext, frameBufferHandle, width, height, false, generateDepth, generateStencilBuffer, depthStencilAttachmentIndex);
1881+
// Stencil-without-depth still allocates a combined depth/stencil attachment above, so the framebuffer
1882+
// genuinely has depth in that case too. Report hasDepth accordingly, otherwise Clear/DrawInternal would
1883+
// skip depth clear and Z-writes against a depth buffer that actually exists.
1884+
const bool hasDepthAttachment = generateDepth || generateStencilBuffer;
1885+
Graphics::FrameBuffer* frameBuffer = new Graphics::FrameBuffer(m_deviceContext, frameBufferHandle, width, height, false, hasDepthAttachment, generateStencilBuffer, depthStencilAttachmentIndex);
18821886

18831887
// For a standalone depth/stencil texture request, alias the framebuffer's readable depth attachment back
18841888
// into the caller-supplied texture so Babylon can sample it (e.g. fluid rendering's depth copy). The

0 commit comments

Comments
 (0)