Skip to content

Commit ce5904d

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 33d1859 commit ce5904d

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
@@ -1871,7 +1871,11 @@ namespace Babylon
18711871
throw Napi::Error::New(info.Env(), "Failed to create frame buffer");
18721872
}
18731873

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

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

0 commit comments

Comments
 (0)