From c46ea56af2783968d7dfea3e43aba1a34d528c47 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Tue, 31 Jan 2023 14:04:00 +0100 Subject: [PATCH] Rename `DepthTestEnable` to `DepthEnable` in Graphics PSO to match actual logic --- Source/Engine/Debug/DebugDraw.cpp | 6 +++--- Source/Engine/Graphics/GPUDevice.cpp | 2 +- Source/Engine/Graphics/GPUPipelineState.h | 10 +++++----- .../Graphics/Materials/DeferredMaterialShader.cpp | 11 ++++++++--- .../Graphics/Materials/DeformableMaterialShader.cpp | 4 ++-- .../Graphics/Materials/ForwardMaterialShader.cpp | 4 ++-- .../Engine/Graphics/Materials/GUIMaterialShader.cpp | 4 ++-- .../Graphics/Materials/ParticleMaterialShader.cpp | 2 +- .../Graphics/Materials/TerrainMaterialShader.cpp | 4 ++-- .../DirectX/DX11/GPUPipelineStateDX11.cpp | 2 +- .../DirectX/DX12/GPUPipelineStateDX12.cpp | 2 +- .../GraphicsDevice/Vulkan/GPUPipelineStateVulkan.cpp | 2 +- Source/Engine/Render2D/Render2D.cpp | 2 +- Source/Engine/Renderer/GI/GlobalSurfaceAtlasPass.cpp | 4 ++-- Source/Engine/Renderer/LightPass.cpp | 4 ++-- Source/Engine/Renderer/Utils/MultiScaler.cpp | 2 +- 16 files changed, 35 insertions(+), 30 deletions(-) diff --git a/Source/Engine/Debug/DebugDraw.cpp b/Source/Engine/Debug/DebugDraw.cpp index 0b58172ab..a1dfa0b61 100644 --- a/Source/Engine/Debug/DebugDraw.cpp +++ b/Source/Engine/Debug/DebugDraw.cpp @@ -140,13 +140,13 @@ struct PsData bool Create(GPUPipelineState::Description& desc) { - desc.DepthTestEnable = true; + desc.DepthEnable = true; desc.DepthWriteEnable = false; Depth = GPUDevice::Instance->CreatePipelineState(); if (Depth->Init(desc)) return true; - desc.DepthTestEnable = false; + desc.DepthEnable = false; NoDepthTest = GPUDevice::Instance->CreatePipelineState(); if (NoDepthTest->Init(desc)) return false; @@ -156,7 +156,7 @@ struct PsData NoDepthTestDepthWrite = GPUDevice::Instance->CreatePipelineState(); if (NoDepthTestDepthWrite->Init(desc)) return false; - desc.DepthTestEnable = true; + desc.DepthEnable = true; DepthWrite = GPUDevice::Instance->CreatePipelineState(); return DepthWrite->Init(desc); } diff --git a/Source/Engine/Graphics/GPUDevice.cpp b/Source/Engine/Graphics/GPUDevice.cpp index 1c3ade229..fe7c59e3a 100644 --- a/Source/Engine/Graphics/GPUDevice.cpp +++ b/Source/Engine/Graphics/GPUDevice.cpp @@ -76,7 +76,7 @@ bool GPUPipelineState::Init(const Description& desc) Complexity += tessCost; if (desc.DepthWriteEnable) Complexity += 5; - if (desc.DepthTestEnable) + if (desc.DepthEnable) Complexity += 5; if (desc.BlendMode.BlendEnable) Complexity += 20; diff --git a/Source/Engine/Graphics/GPUPipelineState.h b/Source/Engine/Graphics/GPUPipelineState.h index a8f9c449b..647d8da04 100644 --- a/Source/Engine/Graphics/GPUPipelineState.h +++ b/Source/Engine/Graphics/GPUPipelineState.h @@ -24,16 +24,16 @@ public: { DECLARE_SCRIPTING_TYPE_NO_SPAWN(Description); + /// + /// Enable/disable depth (DepthFunc and DepthWriteEnable) + /// + API_FIELD() bool DepthEnable; + /// /// Enable/disable depth write /// API_FIELD() bool DepthWriteEnable; - /// - /// Enable/disable depth test - /// - API_FIELD() bool DepthTestEnable; - /// /// Enable/disable depth clipping /// diff --git a/Source/Engine/Graphics/Materials/DeferredMaterialShader.cpp b/Source/Engine/Graphics/Materials/DeferredMaterialShader.cpp index 9e5f43957..52a0bd551 100644 --- a/Source/Engine/Graphics/Materials/DeferredMaterialShader.cpp +++ b/Source/Engine/Graphics/Materials/DeferredMaterialShader.cpp @@ -137,8 +137,13 @@ void DeferredMaterialShader::Unload() bool DeferredMaterialShader::Load() { auto psDesc = GPUPipelineState::Description::Default; - psDesc.DepthTestEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthTest) == MaterialFeaturesFlags::None; psDesc.DepthWriteEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthWrite) == MaterialFeaturesFlags::None; + if (EnumHasAnyFlags(_info.FeaturesFlags, MaterialFeaturesFlags::DisableDepthTest)) + { + psDesc.DepthFunc = ComparisonFunc::Always; + if (!psDesc.DepthWriteEnable) + psDesc.DepthEnable = false; + } // Check if use tessellation (both material and runtime supports it) const bool useTess = _info.TessellationMode != TessellationMethod::None && GPUDevice::Instance->Limits.HasTessellation; @@ -183,7 +188,7 @@ bool DeferredMaterialShader::Load() // Motion Vectors pass psDesc.DepthWriteEnable = false; - psDesc.DepthTestEnable = true; + psDesc.DepthEnable = true; psDesc.DepthFunc = ComparisonFunc::LessEqual; psDesc.VS = _shader->GetVS("VS"); psDesc.PS = _shader->GetPS("PS_MotionVectors"); @@ -201,7 +206,7 @@ bool DeferredMaterialShader::Load() psDesc.CullMode = CullMode::TwoSided; psDesc.DepthClipEnable = false; psDesc.DepthWriteEnable = true; - psDesc.DepthTestEnable = true; + psDesc.DepthEnable = true; psDesc.DepthFunc = ComparisonFunc::Less; psDesc.HS = nullptr; psDesc.DS = nullptr; diff --git a/Source/Engine/Graphics/Materials/DeformableMaterialShader.cpp b/Source/Engine/Graphics/Materials/DeformableMaterialShader.cpp index 83bfc457b..24775241b 100644 --- a/Source/Engine/Graphics/Materials/DeformableMaterialShader.cpp +++ b/Source/Engine/Graphics/Materials/DeformableMaterialShader.cpp @@ -112,7 +112,7 @@ bool DeformableMaterialShader::Load() { _drawModes = DrawPass::Depth | DrawPass::QuadOverdraw; auto psDesc = GPUPipelineState::Description::Default; - psDesc.DepthTestEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthTest) == MaterialFeaturesFlags::None; + psDesc.DepthEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthTest) == MaterialFeaturesFlags::None; psDesc.DepthWriteEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthWrite) == MaterialFeaturesFlags::None; // Check if use tessellation (both material and runtime supports it) @@ -170,7 +170,7 @@ bool DeformableMaterialShader::Load() psDesc.CullMode = CullMode::TwoSided; psDesc.DepthClipEnable = false; psDesc.DepthWriteEnable = true; - psDesc.DepthTestEnable = true; + psDesc.DepthEnable = true; psDesc.DepthFunc = ComparisonFunc::Less; psDesc.HS = nullptr; psDesc.DS = nullptr; diff --git a/Source/Engine/Graphics/Materials/ForwardMaterialShader.cpp b/Source/Engine/Graphics/Materials/ForwardMaterialShader.cpp index a1646a154..d391f3295 100644 --- a/Source/Engine/Graphics/Materials/ForwardMaterialShader.cpp +++ b/Source/Engine/Graphics/Materials/ForwardMaterialShader.cpp @@ -130,7 +130,7 @@ bool ForwardMaterialShader::Load() _drawModes = DrawPass::Depth | DrawPass::Forward | DrawPass::QuadOverdraw; auto psDesc = GPUPipelineState::Description::Default; - psDesc.DepthTestEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthTest) == MaterialFeaturesFlags::None; + psDesc.DepthEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthTest) == MaterialFeaturesFlags::None; psDesc.DepthWriteEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthWrite) == MaterialFeaturesFlags::None; // Check if use tessellation (both material and runtime supports it) @@ -200,7 +200,7 @@ bool ForwardMaterialShader::Load() psDesc.CullMode = CullMode::TwoSided; psDesc.DepthClipEnable = false; psDesc.DepthWriteEnable = true; - psDesc.DepthTestEnable = true; + psDesc.DepthEnable = true; psDesc.DepthFunc = ComparisonFunc::Less; psDesc.HS = nullptr; psDesc.DS = nullptr; diff --git a/Source/Engine/Graphics/Materials/GUIMaterialShader.cpp b/Source/Engine/Graphics/Materials/GUIMaterialShader.cpp index 795d16311..17be156bb 100644 --- a/Source/Engine/Graphics/Materials/GUIMaterialShader.cpp +++ b/Source/Engine/Graphics/Materials/GUIMaterialShader.cpp @@ -89,13 +89,13 @@ bool GUIMaterialShader::Load() psDesc0.PS = _shader->GetPS("PS_GUI"); psDesc0.BlendMode = BlendingMode::AlphaBlend; - psDesc0.DepthTestEnable = psDesc0.DepthWriteEnable = true; + psDesc0.DepthEnable = psDesc0.DepthWriteEnable = true; _cache.Depth = GPUDevice::Instance->CreatePipelineState(); _cache.NoDepth = GPUDevice::Instance->CreatePipelineState(); bool failed = _cache.Depth->Init(psDesc0); - psDesc0.DepthTestEnable = psDesc0.DepthWriteEnable = false; + psDesc0.DepthEnable = psDesc0.DepthWriteEnable = false; failed |= _cache.NoDepth->Init(psDesc0); if (failed) diff --git a/Source/Engine/Graphics/Materials/ParticleMaterialShader.cpp b/Source/Engine/Graphics/Materials/ParticleMaterialShader.cpp index 43dd9d447..ec39ef41b 100644 --- a/Source/Engine/Graphics/Materials/ParticleMaterialShader.cpp +++ b/Source/Engine/Graphics/Materials/ParticleMaterialShader.cpp @@ -189,7 +189,7 @@ bool ParticleMaterialShader::Load() { _drawModes = DrawPass::Depth | DrawPass::Forward | DrawPass::QuadOverdraw; GPUPipelineState::Description psDesc = GPUPipelineState::Description::Default; - psDesc.DepthTestEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthTest) == MaterialFeaturesFlags::None; + psDesc.DepthEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthTest) == MaterialFeaturesFlags::None; psDesc.DepthWriteEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthWrite) == MaterialFeaturesFlags::None; auto vsSprite = _shader->GetVS("VS_Sprite"); diff --git a/Source/Engine/Graphics/Materials/TerrainMaterialShader.cpp b/Source/Engine/Graphics/Materials/TerrainMaterialShader.cpp index 7c25a12fc..575f71b34 100644 --- a/Source/Engine/Graphics/Materials/TerrainMaterialShader.cpp +++ b/Source/Engine/Graphics/Materials/TerrainMaterialShader.cpp @@ -133,7 +133,7 @@ void TerrainMaterialShader::Unload() bool TerrainMaterialShader::Load() { GPUPipelineState::Description psDesc = GPUPipelineState::Description::Default; - psDesc.DepthTestEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthTest) == MaterialFeaturesFlags::None; + psDesc.DepthEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthTest) == MaterialFeaturesFlags::None; psDesc.DepthWriteEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthWrite) == MaterialFeaturesFlags::None; // Check if use tessellation (both material and runtime supports it) @@ -182,7 +182,7 @@ bool TerrainMaterialShader::Load() psDesc.BlendMode = BlendingMode::Opaque; psDesc.DepthClipEnable = false; psDesc.DepthWriteEnable = true; - psDesc.DepthTestEnable = true; + psDesc.DepthEnable = true; psDesc.DepthFunc = ComparisonFunc::Less; psDesc.HS = nullptr; psDesc.DS = nullptr; diff --git a/Source/Engine/GraphicsDevice/DirectX/DX11/GPUPipelineStateDX11.cpp b/Source/Engine/GraphicsDevice/DirectX/DX11/GPUPipelineStateDX11.cpp index 97c1281a3..e3458fcae 100644 --- a/Source/Engine/GraphicsDevice/DirectX/DX11/GPUPipelineStateDX11.cpp +++ b/Source/Engine/GraphicsDevice/DirectX/DX11/GPUPipelineStateDX11.cpp @@ -48,7 +48,7 @@ bool GPUPipelineStateDX11::Init(const Description& desc) PrimitiveTopology = (D3D11_PRIMITIVE_TOPOLOGY)((int32)D3D11_PRIMITIVE_TOPOLOGY_1_CONTROL_POINT_PATCHLIST + (HS->GetControlPointsCount() - 1)); // States - DepthStencilStateIndex = static_cast(desc.DepthFunc) + (desc.DepthTestEnable ? 0 : 9) + (desc.DepthWriteEnable ? 0 : 18); + DepthStencilStateIndex = static_cast(desc.DepthFunc) + (desc.DepthEnable ? 0 : 9) + (desc.DepthWriteEnable ? 0 : 18); RasterizerStateIndex = static_cast(desc.CullMode) + (desc.Wireframe ? 0 : 3) + (desc.DepthClipEnable ? 0 : 6); BlendState = _device->GetBlendState(desc.BlendMode); diff --git a/Source/Engine/GraphicsDevice/DirectX/DX12/GPUPipelineStateDX12.cpp b/Source/Engine/GraphicsDevice/DirectX/DX12/GPUPipelineStateDX12.cpp index 982a27661..3bfe09401 100644 --- a/Source/Engine/GraphicsDevice/DirectX/DX12/GPUPipelineStateDX12.cpp +++ b/Source/Engine/GraphicsDevice/DirectX/DX12/GPUPipelineStateDX12.cpp @@ -172,7 +172,7 @@ bool GPUPipelineStateDX12::Init(const Description& desc) } // Depth State - psDesc.DepthStencilState.DepthEnable = !!desc.DepthTestEnable; + psDesc.DepthStencilState.DepthEnable = !!desc.DepthEnable; psDesc.DepthStencilState.DepthWriteMask = desc.DepthWriteEnable ? D3D12_DEPTH_WRITE_MASK_ALL : D3D12_DEPTH_WRITE_MASK_ZERO; psDesc.DepthStencilState.DepthFunc = static_cast(desc.DepthFunc); psDesc.DepthStencilState.StencilEnable = FALSE; diff --git a/Source/Engine/GraphicsDevice/Vulkan/GPUPipelineStateVulkan.cpp b/Source/Engine/GraphicsDevice/Vulkan/GPUPipelineStateVulkan.cpp index 236a8c7ce..935f37873 100644 --- a/Source/Engine/GraphicsDevice/Vulkan/GPUPipelineStateVulkan.cpp +++ b/Source/Engine/GraphicsDevice/Vulkan/GPUPipelineStateVulkan.cpp @@ -286,7 +286,7 @@ bool GPUPipelineStateVulkan::Init(const Description& desc) // Depth Stencil RenderToolsVulkan::ZeroStruct(_descDepthStencil, VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO); - _descDepthStencil.depthTestEnable = desc.DepthTestEnable; + _descDepthStencil.depthTestEnable = desc.DepthEnable; _descDepthStencil.depthWriteEnable = desc.DepthWriteEnable; _descDepthStencil.depthCompareOp = RenderToolsVulkan::ToVulkanCompareOp(desc.DepthFunc); _desc.pDepthStencilState = &_descDepthStencil; diff --git a/Source/Engine/Render2D/Render2D.cpp b/Source/Engine/Render2D/Render2D.cpp index 1fd384d44..b56c3e1a2 100644 --- a/Source/Engine/Render2D/Render2D.cpp +++ b/Source/Engine/Render2D/Render2D.cpp @@ -481,7 +481,7 @@ bool CachedPSO::Init(GPUShader* shader, bool useDepth) // Create pipeline states GPUPipelineState::Description desc = GPUPipelineState::Description::DefaultFullscreenTriangle; - desc.DepthTestEnable = desc.DepthWriteEnable = useDepth; + desc.DepthEnable = desc.DepthWriteEnable = useDepth; desc.DepthWriteEnable = false; desc.DepthClipEnable = false; desc.VS = shader->GetVS("VS"); diff --git a/Source/Engine/Renderer/GI/GlobalSurfaceAtlasPass.cpp b/Source/Engine/Renderer/GI/GlobalSurfaceAtlasPass.cpp index d4ac81f98..2ca702d4f 100644 --- a/Source/Engine/Renderer/GI/GlobalSurfaceAtlasPass.cpp +++ b/Source/Engine/Renderer/GI/GlobalSurfaceAtlasPass.cpp @@ -284,7 +284,7 @@ bool GlobalSurfaceAtlasPass::setupResources() if (!_psClear) { _psClear = device->CreatePipelineState(); - psDesc.DepthTestEnable = true; + psDesc.DepthEnable = true; psDesc.DepthWriteEnable = true; psDesc.DepthFunc = ComparisonFunc::Always; psDesc.VS = shader->GetVS("VS_Atlas"); @@ -292,7 +292,7 @@ bool GlobalSurfaceAtlasPass::setupResources() if (_psClear->Init(psDesc)) return true; } - psDesc.DepthTestEnable = false; + psDesc.DepthEnable = false; psDesc.DepthWriteEnable = false; psDesc.DepthFunc = ComparisonFunc::Never; if (!_psClearLighting) diff --git a/Source/Engine/Renderer/LightPass.cpp b/Source/Engine/Renderer/LightPass.cpp index 0b98067d7..0dda82171 100644 --- a/Source/Engine/Renderer/LightPass.cpp +++ b/Source/Engine/Renderer/LightPass.cpp @@ -98,7 +98,7 @@ bool LightPass::setupResources() if (_psLightPointInverted.Create(psDesc, shader, "PS_Point")) return true; psDesc.CullMode = CullMode::Normal; - psDesc.DepthTestEnable = true; + psDesc.DepthEnable = true; if (_psLightPointNormal.Create(psDesc, shader, "PS_Point")) return true; } @@ -112,7 +112,7 @@ bool LightPass::setupResources() if (_psLightSpotInverted.Create(psDesc, shader, "PS_Spot")) return true; psDesc.CullMode = CullMode::Normal; - psDesc.DepthTestEnable = true; + psDesc.DepthEnable = true; if (_psLightSpotNormal.Create(psDesc, shader, "PS_Spot")) return true; } diff --git a/Source/Engine/Renderer/Utils/MultiScaler.cpp b/Source/Engine/Renderer/Utils/MultiScaler.cpp index ce0b4ac3a..036c586a6 100644 --- a/Source/Engine/Renderer/Utils/MultiScaler.cpp +++ b/Source/Engine/Renderer/Utils/MultiScaler.cpp @@ -76,7 +76,7 @@ bool MultiScaler::setupResources() { psDesc.PS = shader->GetPS("PS_HalfDepth"); psDesc.DepthWriteEnable = true; - psDesc.DepthTestEnable = true; + psDesc.DepthEnable = true; psDesc.DepthFunc = ComparisonFunc::Always; if (_psHalfDepth->Init(psDesc)) return true;