diff --git a/renderdoc/driver/d3d12/d3d12_command_list_wrap.cpp b/renderdoc/driver/d3d12/d3d12_command_list_wrap.cpp index 4cd4bf137..bd25d55eb 100644 --- a/renderdoc/driver/d3d12/d3d12_command_list_wrap.cpp +++ b/renderdoc/driver/d3d12/d3d12_command_list_wrap.cpp @@ -596,16 +596,86 @@ void WrappedID3D12GraphicsCommandList::RSSetScissorRects(UINT NumRects, const D3 } } +bool WrappedID3D12GraphicsCommandList::Serialise_OMSetBlendFactor(const FLOAT BlendFactor[4]) +{ + SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID()); + + float factor[4] = {1.0f, 1.0f, 1.0f, 1.0f}; + + if(m_State >= WRITING && BlendFactor) + memcpy(factor, BlendFactor, sizeof(float) * 4); + + m_pSerialiser->SerialisePODArray<4>("BlendFactor", factor); + + if(m_State < WRITING) + m_Cmd->m_LastCmdListID = CommandList; + + if(m_State == EXECUTING) + { + if(m_Cmd->ShouldRerecordCmd(CommandList) && m_Cmd->InRerecordRange(CommandList)) + { + Unwrap(m_Cmd->RerecordCmdList(CommandList))->OMSetBlendFactor(factor); + + memcpy(m_Cmd->m_RenderState.blendFactor, factor, sizeof(factor)); + } + } + else if(m_State == READING) + { + GetList(CommandList)->OMSetBlendFactor(factor); + } + + return true; +} + void WrappedID3D12GraphicsCommandList::OMSetBlendFactor(const FLOAT BlendFactor[4]) { - D3D12NOTIMP(__PRETTY_FUNCTION_SIGNATURE__); m_pReal->OMSetBlendFactor(BlendFactor); + + if(m_State >= WRITING) + { + SCOPED_SERIALISE_CONTEXT(SET_BLENDFACTOR); + Serialise_OMSetBlendFactor(BlendFactor); + + m_ListRecord->AddChunk(scope.Get()); + } +} + +bool WrappedID3D12GraphicsCommandList::Serialise_OMSetStencilRef(UINT StencilRef) +{ + SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID()); + SERIALISE_ELEMENT(UINT, ref, StencilRef); + + if(m_State < WRITING) + m_Cmd->m_LastCmdListID = CommandList; + + if(m_State == EXECUTING) + { + if(m_Cmd->ShouldRerecordCmd(CommandList) && m_Cmd->InRerecordRange(CommandList)) + { + Unwrap(m_Cmd->RerecordCmdList(CommandList))->OMSetStencilRef(ref); + + m_Cmd->m_RenderState.stencilRef = ref; + } + } + else if(m_State == READING) + { + GetList(CommandList)->OMSetStencilRef(ref); + } + + return true; } void WrappedID3D12GraphicsCommandList::OMSetStencilRef(UINT StencilRef) { - D3D12NOTIMP(__PRETTY_FUNCTION_SIGNATURE__); m_pReal->OMSetStencilRef(StencilRef); + + if(m_State >= WRITING) + { + SCOPED_SERIALISE_CONTEXT(SET_STENCIL); + Serialise_OMSetStencilRef(StencilRef); + + m_ListRecord->AddChunk(scope.Get()); + } } bool WrappedID3D12GraphicsCommandList::Serialise_SetDescriptorHeaps( diff --git a/renderdoc/driver/d3d12/d3d12_commands.cpp b/renderdoc/driver/d3d12/d3d12_commands.cpp index 6e9cc53a6..3b37001b8 100644 --- a/renderdoc/driver/d3d12/d3d12_commands.cpp +++ b/renderdoc/driver/d3d12/d3d12_commands.cpp @@ -304,6 +304,8 @@ void WrappedID3D12CommandQueue::ProcessChunk(uint64_t offset, D3D12ChunkType chu case SET_VBUFFERS: m_ReplayList->Serialise_IASetVertexBuffers(0, 0, NULL); break; case SET_VIEWPORTS: m_ReplayList->Serialise_RSSetViewports(0, NULL); break; case SET_SCISSORS: m_ReplayList->Serialise_RSSetScissorRects(0, NULL); break; + case SET_STENCIL: m_ReplayList->Serialise_OMSetStencilRef(0); break; + case SET_BLENDFACTOR: m_ReplayList->Serialise_OMSetBlendFactor(NULL); break; case SET_PIPE: m_ReplayList->Serialise_SetPipelineState(NULL); break; case SET_RTVS: m_ReplayList->Serialise_OMSetRenderTargets(0, NULL, FALSE, NULL); break; case SET_DESC_HEAPS: m_ReplayList->Serialise_SetDescriptorHeaps(0, NULL); break; diff --git a/renderdoc/driver/d3d12/d3d12_common.h b/renderdoc/driver/d3d12/d3d12_common.h index 46af33d4b..d1b383fdb 100644 --- a/renderdoc/driver/d3d12/d3d12_common.h +++ b/renderdoc/driver/d3d12/d3d12_common.h @@ -275,6 +275,8 @@ void Serialiser::Serialise(const char *name, D3D12Descriptor &el); D3D12_CHUNK_MACRO(SET_PIPE, "ID3D12GraphicsCommandList::SetPipelineState") \ D3D12_CHUNK_MACRO(SET_DESC_HEAPS, "ID3D12GraphicsCommandList::SetDescriptorHeaps") \ D3D12_CHUNK_MACRO(SET_RTVS, "ID3D12GraphicsCommandList::OMSetRenderTargets") \ + D3D12_CHUNK_MACRO(SET_STENCIL, "ID3D12GraphicsCommandList::OMSetStencilRef") \ + D3D12_CHUNK_MACRO(SET_BLENDFACTOR, "ID3D12GraphicsCommandList::OMSetBlendFactor") \ \ D3D12_CHUNK_MACRO(SET_GFX_ROOT_TABLE, \ "ID3D12GraphicsCommandList::SetGraphicsRootDescriptorTable") \ diff --git a/renderdoc/driver/d3d12/d3d12_state.cpp b/renderdoc/driver/d3d12/d3d12_state.cpp index 7868e2610..517fe94f4 100644 --- a/renderdoc/driver/d3d12/d3d12_state.cpp +++ b/renderdoc/driver/d3d12/d3d12_state.cpp @@ -46,6 +46,9 @@ D3D12RenderState::D3D12RenderState() topo = D3D_PRIMITIVE_TOPOLOGY_UNDEFINED; + stencilRef = 0; + RDCEraseEl(blendFactor); + RDCEraseEl(ibuffer); vbuffers.clear(); } @@ -69,6 +72,8 @@ D3D12RenderState &D3D12RenderState::operator=(const D3D12RenderState &o) compute.sigelems = o.compute.sigelems; topo = o.topo; + stencilRef = o.stencilRef; + memcpy(blendFactor, o.blendFactor, sizeof(blendFactor)); ibuffer = o.ibuffer; vbuffers = o.vbuffers; @@ -90,6 +95,9 @@ void D3D12RenderState::ApplyState(ID3D12GraphicsCommandList *cmd) if(topo != D3D_PRIMITIVE_TOPOLOGY_UNDEFINED) cmd->IASetPrimitiveTopology(topo); + cmd->OMSetStencilRef(stencilRef); + cmd->OMSetBlendFactor(blendFactor); + if(ibuffer.buf != ResourceId()) { D3D12_INDEX_BUFFER_VIEW ib; diff --git a/renderdoc/driver/d3d12/d3d12_state.h b/renderdoc/driver/d3d12/d3d12_state.h index 087aebfbe..c3049811d 100644 --- a/renderdoc/driver/d3d12/d3d12_state.h +++ b/renderdoc/driver/d3d12/d3d12_state.h @@ -167,6 +167,8 @@ struct D3D12RenderState ResourceId pipe; D3D12_PRIMITIVE_TOPOLOGY topo; + UINT stencilRef; + float blendFactor[4]; struct IdxBuffer {