D3D12: Fixed setting draw scissor.

This commit is contained in:
Branimir Karadžić 2022-12-22 20:21:39 -08:00
parent 9eb0d2953e
commit eb7f79c358

View File

@ -6787,6 +6787,8 @@ namespace bgfx { namespace d3d12
} }
} }
if (0 != draw.m_streamMask)
{
const uint64_t newFlags = draw.m_stateFlags; const uint64_t newFlags = draw.m_stateFlags;
uint64_t changedFlags = currentState.m_stateFlags ^ draw.m_stateFlags; uint64_t changedFlags = currentState.m_stateFlags ^ draw.m_stateFlags;
currentState.m_stateFlags = newFlags; currentState.m_stateFlags = newFlags;
@ -6800,24 +6802,10 @@ namespace bgfx { namespace d3d12
uint64_t changedStencil = (currentState.m_stencil ^ draw.m_stencil) & BGFX_STENCIL_FUNC_REF_MASK; uint64_t changedStencil = (currentState.m_stencil ^ draw.m_stencil) & BGFX_STENCIL_FUNC_REF_MASK;
currentState.m_stencil = newStencil; currentState.m_stencil = newStencil;
if (resetState) if (resetState
|| commandListChanged)
{ {
wasCompute = false; wasCompute = false;
currentState.clear();
currentState.m_scissor = !draw.m_scissor;
changedFlags = BGFX_STATE_MASK;
changedStencil = packStencil(BGFX_STENCIL_MASK, BGFX_STENCIL_MASK);
currentState.m_stateFlags = newFlags;
currentState.m_stencil = newStencil;
currentBind.clear();
commandListChanged = true;
}
if (commandListChanged)
{
commandListChanged = false; commandListChanged = false;
m_commandList->SetGraphicsRootSignature(m_rootSignature); m_commandList->SetGraphicsRootSignature(m_rootSignature);
@ -6847,8 +6835,6 @@ namespace bgfx { namespace d3d12
bool constantsChanged = draw.m_uniformBegin < draw.m_uniformEnd; bool constantsChanged = draw.m_uniformBegin < draw.m_uniformEnd;
rendererUpdateUniforms(this, _render->m_uniformBuffer[draw.m_uniformIdx], draw.m_uniformBegin, draw.m_uniformEnd); rendererUpdateUniforms(this, _render->m_uniformBuffer[draw.m_uniformIdx], draw.m_uniformBegin, draw.m_uniformEnd);
if (0 != draw.m_streamMask)
{
currentState.m_streamMask = draw.m_streamMask; currentState.m_streamMask = draw.m_streamMask;
currentState.m_instanceDataBuffer.idx = draw.m_instanceDataBuffer.idx; currentState.m_instanceDataBuffer.idx = draw.m_instanceDataBuffer.idx;
currentState.m_instanceDataOffset = draw.m_instanceDataOffset; currentState.m_instanceDataOffset = draw.m_instanceDataOffset;
@ -6891,8 +6877,8 @@ namespace bgfx { namespace d3d12
} }
} }
ID3D12PipelineState* pso = ID3D12PipelineState* pso = getPipelineState(
getPipelineState(state state
, draw.m_stencil , draw.m_stencil
, numStreams , numStreams
, layouts , layouts
@ -6900,14 +6886,14 @@ namespace bgfx { namespace d3d12
, uint8_t(draw.m_instanceDataStride/16) , uint8_t(draw.m_instanceDataStride/16)
); );
uint16_t scissor = draw.m_scissor; const uint32_t bindHash = bx::hash<bx::HashMurmur2A>(renderBind.m_bind, sizeof(renderBind.m_bind) );
uint32_t bindHash = bx::hash<bx::HashMurmur2A>(renderBind.m_bind, sizeof(renderBind.m_bind) );
if (currentBindHash != bindHash if (currentBindHash != bindHash
|| 0 != changedStencil || 0 != changedStencil
|| (hasFactor && blendFactor != draw.m_rgba) || (hasFactor && blendFactor != draw.m_rgba)
|| (0 != (BGFX_STATE_PT_MASK & changedFlags) || (0 != (BGFX_STATE_PT_MASK & changedFlags)
|| prim.m_topology != s_primInfo[primIndex].m_topology) || prim.m_topology != s_primInfo[primIndex].m_topology)
|| currentState.m_scissor != scissor || currentState.m_scissor != draw.m_scissor
|| pso != currentPso || pso != currentPso
|| hasOcclusionQuery) || hasOcclusionQuery)
{ {
@ -7053,6 +7039,7 @@ namespace bgfx { namespace d3d12
m_commandList->IASetPrimitiveTopology(prim.m_topology); m_commandList->IASetPrimitiveTopology(prim.m_topology);
} }
const uint16_t scissor = draw.m_scissor;
if (currentState.m_scissor != scissor) if (currentState.m_scissor != scissor)
{ {
currentState.m_scissor = scissor; currentState.m_scissor = scissor;