From bf411dd393f0b449d3b6508039949ff036d7fbcb Mon Sep 17 00:00:00 2001 From: Ciro Mondueri Date: Fri, 7 Oct 2022 21:28:18 -0300 Subject: [PATCH] d3d12: fixes triangle list primitive state change not ackd. after touch call (#2951) Suppose this is the draw call sequence in a frame: - triangle strip - touch (required to apply stencil changes for example) - triangle list Touch masks the change (as it's triangle list by default) by setting changedFlags, but not primIndex. When the triangle list is processed, the STATE_PT is already set to triangle list, so the test for changedFlags is skipped and primIndex stays with triangle strip. The fix detects the change in the STATE_PT and updates primIndex. --- src/renderer_d3d12.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/renderer_d3d12.cpp b/src/renderer_d3d12.cpp index cd8249084..75f051b38 100644 --- a/src/renderer_d3d12.cpp +++ b/src/renderer_d3d12.cpp @@ -6640,6 +6640,9 @@ namespace bgfx { namespace d3d12 uint64_t changedFlags = currentState.m_stateFlags ^ draw.m_stateFlags; currentState.m_stateFlags = newFlags; + if (0 != (BGFX_STATE_PT_MASK & changedFlags)) + primIndex = uint8_t((newFlags&BGFX_STATE_PT_MASK)>>BGFX_STATE_PT_SHIFT); + const uint64_t newStencil = draw.m_stencil; uint64_t changedStencil = (currentState.m_stencil ^ draw.m_stencil) & BGFX_STENCIL_FUNC_REF_MASK; currentState.m_stencil = newStencil;