diff --git a/Source/Engine/Debug/DebugDraw.cpp b/Source/Engine/Debug/DebugDraw.cpp index 891792d79..7330f4339 100644 --- a/Source/Engine/Debug/DebugDraw.cpp +++ b/Source/Engine/Debug/DebugDraw.cpp @@ -638,10 +638,10 @@ void DebugDrawService::Update() // Default desc.PS = shader->GetPS("PS", 0); - desc.PrimitiveTopologyType = PrimitiveTopologyType::Line; + desc.PrimitiveTopology = PrimitiveTopologyType::Line; failed |= DebugDrawPsLinesDefault.Create(desc); desc.PS = shader->GetPS("PS", 1); - desc.PrimitiveTopologyType = PrimitiveTopologyType::Triangle; + desc.PrimitiveTopology = PrimitiveTopologyType::Triangle; failed |= DebugDrawPsTrianglesDefault.Create(desc); desc.Wireframe = true; failed |= DebugDrawPsWireTrianglesDefault.Create(desc); @@ -649,10 +649,10 @@ void DebugDrawService::Update() // Depth Test desc.Wireframe = false; desc.PS = shader->GetPS("PS", 2); - desc.PrimitiveTopologyType = PrimitiveTopologyType::Line; + desc.PrimitiveTopology = PrimitiveTopologyType::Line; failed |= DebugDrawPsLinesDepthTest.Create(desc); desc.PS = shader->GetPS("PS", 3); - desc.PrimitiveTopologyType = PrimitiveTopologyType::Triangle; + desc.PrimitiveTopology = PrimitiveTopologyType::Triangle; failed |= DebugDrawPsTrianglesDepthTest.Create(desc); desc.Wireframe = true; failed |= DebugDrawPsWireTrianglesDepthTest.Create(desc); diff --git a/Source/Engine/Graphics/GPUPipelineState.h b/Source/Engine/Graphics/GPUPipelineState.h index 725b1bb74..b9b6395e4 100644 --- a/Source/Engine/Graphics/GPUPipelineState.h +++ b/Source/Engine/Graphics/GPUPipelineState.h @@ -72,7 +72,7 @@ public: /// /// Input primitives topology /// - API_FIELD() PrimitiveTopologyType PrimitiveTopologyType; + API_FIELD() PrimitiveTopologyType PrimitiveTopology; /// /// True if use wireframe rendering, otherwise false diff --git a/Source/Engine/GraphicsDevice/DirectX/DX11/GPUPipelineStateDX11.cpp b/Source/Engine/GraphicsDevice/DirectX/DX11/GPUPipelineStateDX11.cpp index e3458fcae..18a774793 100644 --- a/Source/Engine/GraphicsDevice/DirectX/DX11/GPUPipelineStateDX11.cpp +++ b/Source/Engine/GraphicsDevice/DirectX/DX11/GPUPipelineStateDX11.cpp @@ -43,7 +43,7 @@ bool GPUPipelineStateDX11::Init(const Description& desc) D3D11_PRIMITIVE_TOPOLOGY_LINELIST, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST, }; - PrimitiveTopology = D3D11_primTypes[static_cast(desc.PrimitiveTopologyType)]; + PrimitiveTopology = D3D11_primTypes[static_cast(desc.PrimitiveTopology)]; if (HS) PrimitiveTopology = (D3D11_PRIMITIVE_TOPOLOGY)((int32)D3D11_PRIMITIVE_TOPOLOGY_1_CONTROL_POINT_PATCHLIST + (HS->GetControlPointsCount() - 1)); diff --git a/Source/Engine/GraphicsDevice/DirectX/DX12/GPUContextDX12.cpp b/Source/Engine/GraphicsDevice/DirectX/DX12/GPUContextDX12.cpp index 107895cf5..343caabac 100644 --- a/Source/Engine/GraphicsDevice/DirectX/DX12/GPUContextDX12.cpp +++ b/Source/Engine/GraphicsDevice/DirectX/DX12/GPUContextDX12.cpp @@ -223,6 +223,7 @@ void GPUContextDX12::Reset() _srMaskDirtyGraphics = 0; _srMaskDirtyCompute = 0; _stencilRef = 0; + _primitiveTopology = D3D_PRIMITIVE_TOPOLOGY_UNDEFINED; _psDirtyFlag = false; _isCompute = false; _currentCompute = nullptr; @@ -545,7 +546,11 @@ void GPUContextDX12::flushPS() // Change state ASSERT(_currentState->IsValid()); _commandList->SetPipelineState(_currentState->GetState(_rtDepth, _rtCount, _rtHandles)); - _commandList->IASetPrimitiveTopology(_currentState->PrimitiveTopologyType); + if (_primitiveTopology != _currentState->PrimitiveTopology) + { + _primitiveTopology = _currentState->PrimitiveTopology; + _commandList->IASetPrimitiveTopology(_primitiveTopology); + } RENDER_STAT_PS_STATE_CHANGE(); } diff --git a/Source/Engine/GraphicsDevice/DirectX/DX12/GPUContextDX12.h b/Source/Engine/GraphicsDevice/DirectX/DX12/GPUContextDX12.h index 45dfa8162..a8f2fdb22 100644 --- a/Source/Engine/GraphicsDevice/DirectX/DX12/GPUContextDX12.h +++ b/Source/Engine/GraphicsDevice/DirectX/DX12/GPUContextDX12.h @@ -48,6 +48,7 @@ private: uint32 _srMaskDirtyGraphics; uint32 _srMaskDirtyCompute; uint32 _stencilRef; + D3D_PRIMITIVE_TOPOLOGY _primitiveTopology; int32 _isCompute : 1; int32 _rtDirtyFlag : 1; diff --git a/Source/Engine/GraphicsDevice/DirectX/DX12/GPUPipelineStateDX12.cpp b/Source/Engine/GraphicsDevice/DirectX/DX12/GPUPipelineStateDX12.cpp index 6a87f100d..b23d4d2fe 100644 --- a/Source/Engine/GraphicsDevice/DirectX/DX12/GPUPipelineStateDX12.cpp +++ b/Source/Engine/GraphicsDevice/DirectX/DX12/GPUPipelineStateDX12.cpp @@ -157,12 +157,12 @@ bool GPUPipelineStateDX12::Init(const Description& desc) D3D_PRIMITIVE_TOPOLOGY_LINELIST, D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST, }; - psDesc.PrimitiveTopologyType = primTypes1[(int32)desc.PrimitiveTopologyType]; - PrimitiveTopologyType = primTypes2[(int32)desc.PrimitiveTopologyType]; + psDesc.PrimitiveTopologyType = primTypes1[(int32)desc.PrimitiveTopology]; + PrimitiveTopology = primTypes2[(int32)desc.PrimitiveTopology]; if (desc.HS) { psDesc.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_PATCH; - PrimitiveTopologyType = (D3D_PRIMITIVE_TOPOLOGY)((int32)D3D_PRIMITIVE_TOPOLOGY_1_CONTROL_POINT_PATCHLIST + (desc.HS->GetControlPointsCount() - 1)); + PrimitiveTopology = (D3D_PRIMITIVE_TOPOLOGY)((int32)D3D_PRIMITIVE_TOPOLOGY_1_CONTROL_POINT_PATCHLIST + (desc.HS->GetControlPointsCount() - 1)); } // Depth State diff --git a/Source/Engine/GraphicsDevice/DirectX/DX12/GPUPipelineStateDX12.h b/Source/Engine/GraphicsDevice/DirectX/DX12/GPUPipelineStateDX12.h index fc02699eb..2764ce235 100644 --- a/Source/Engine/GraphicsDevice/DirectX/DX12/GPUPipelineStateDX12.h +++ b/Source/Engine/GraphicsDevice/DirectX/DX12/GPUPipelineStateDX12.h @@ -55,7 +55,7 @@ public: public: - D3D_PRIMITIVE_TOPOLOGY PrimitiveTopologyType = D3D_PRIMITIVE_TOPOLOGY_UNDEFINED; + D3D_PRIMITIVE_TOPOLOGY PrimitiveTopology = D3D_PRIMITIVE_TOPOLOGY_UNDEFINED; DxShaderHeader Header; /// diff --git a/Source/Engine/GraphicsDevice/Vulkan/GPUPipelineStateVulkan.cpp b/Source/Engine/GraphicsDevice/Vulkan/GPUPipelineStateVulkan.cpp index d2ccf7da1..5946aee20 100644 --- a/Source/Engine/GraphicsDevice/Vulkan/GPUPipelineStateVulkan.cpp +++ b/Source/Engine/GraphicsDevice/Vulkan/GPUPipelineStateVulkan.cpp @@ -239,7 +239,7 @@ bool GPUPipelineStateVulkan::Init(const Description& desc) // Input Assembly RenderToolsVulkan::ZeroStruct(_descInputAssembly, VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO);; - switch (desc.PrimitiveTopologyType) + switch (desc.PrimitiveTopology) { case PrimitiveTopologyType::Point: _descInputAssembly.topology = VK_PRIMITIVE_TOPOLOGY_POINT_LIST; diff --git a/Source/Engine/Renderer/DepthOfFieldPass.cpp b/Source/Engine/Renderer/DepthOfFieldPass.cpp index e5d772aba..4c43ccdbf 100644 --- a/Source/Engine/Renderer/DepthOfFieldPass.cpp +++ b/Source/Engine/Renderer/DepthOfFieldPass.cpp @@ -157,7 +157,7 @@ bool DepthOfFieldPass::setupResources() psDesc.GS = shader->GetGS("GS_Bokeh"); psDesc.PS = shader->GetPS("PS_Bokeh"); psDesc.BlendMode = BlendingMode::Additive; - psDesc.PrimitiveTopologyType = PrimitiveTopologyType::Point; + psDesc.PrimitiveTopology = PrimitiveTopologyType::Point; if (_psBokeh->Init(psDesc)) return true; }