Rename DepthTestEnable to DepthEnable in Graphics PSO to match actual logic

This commit is contained in:
Wojtek Figat
2023-01-31 14:04:00 +01:00
parent c39d1283f8
commit c46ea56af2
16 changed files with 35 additions and 30 deletions

View File

@@ -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);
}

View File

@@ -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;

View File

@@ -24,16 +24,16 @@ public:
{
DECLARE_SCRIPTING_TYPE_NO_SPAWN(Description);
/// <summary>
/// Enable/disable depth (DepthFunc and DepthWriteEnable)
/// </summary>
API_FIELD() bool DepthEnable;
/// <summary>
/// Enable/disable depth write
/// </summary>
API_FIELD() bool DepthWriteEnable;
/// <summary>
/// Enable/disable depth test
/// </summary>
API_FIELD() bool DepthTestEnable;
/// <summary>
/// Enable/disable depth clipping
/// </summary>

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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)

View File

@@ -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");

View File

@@ -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;

View File

@@ -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<int32>(desc.DepthFunc) + (desc.DepthTestEnable ? 0 : 9) + (desc.DepthWriteEnable ? 0 : 18);
DepthStencilStateIndex = static_cast<int32>(desc.DepthFunc) + (desc.DepthEnable ? 0 : 9) + (desc.DepthWriteEnable ? 0 : 18);
RasterizerStateIndex = static_cast<int32>(desc.CullMode) + (desc.Wireframe ? 0 : 3) + (desc.DepthClipEnable ? 0 : 6);
BlendState = _device->GetBlendState(desc.BlendMode);

View File

@@ -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<D3D12_COMPARISON_FUNC>(desc.DepthFunc);
psDesc.DepthStencilState.StencilEnable = FALSE;

View File

@@ -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;

View File

@@ -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");

View File

@@ -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)

View File

@@ -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;
}

View File

@@ -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;