Skip to content
This repository was archived by the owner on Sep 15, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions icd/api/graphics_pipeline_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1026,7 +1026,6 @@ static void CopyPreRasterizationShaderState(
}
pInfo->immedInfo.dynamicGraphicsState = libInfo.immedInfo.dynamicGraphicsState;
pInfo->immedInfo.viewportParams = libInfo.immedInfo.viewportParams;
pInfo->immedInfo.depthClampOverride = libInfo.immedInfo.depthClampOverride;
pInfo->immedInfo.scissorRectParams = libInfo.immedInfo.scissorRectParams;
pInfo->immedInfo.rasterizerDiscardEnable = libInfo.immedInfo.rasterizerDiscardEnable;

Expand Down Expand Up @@ -1369,15 +1368,17 @@ static void BuildViewportState(
const auto* pClampControl = pPipelineViewportDepthClampControlCreateInfoEXT;
if (pClampControl != nullptr)
{
const auto* pClampRange = pClampControl->pDepthClampRange;
switch (pClampControl->depthClampMode)
{
case VK_DEPTH_CLAMP_MODE_VIEWPORT_RANGE_EXT:
// set min > max to disable the override
pInfo->immedInfo.depthClampOverride.minDepthClamp = 1.0f;
pInfo->immedInfo.depthClampOverride.maxDepthClamp = 0.0f;
pInfo->immedInfo.viewportParams.depthClampOverride.minDepth = 1.0f;
pInfo->immedInfo.viewportParams.depthClampOverride.maxDepth = 0.0f;
break;
case VK_DEPTH_CLAMP_MODE_USER_DEFINED_RANGE_EXT:
pInfo->immedInfo.depthClampOverride = *pClampControl->pDepthClampRange;
pInfo->immedInfo.viewportParams.depthClampOverride.minDepth = pClampRange->minDepthClamp;
pInfo->immedInfo.viewportParams.depthClampOverride.maxDepth = pClampRange->maxDepthClamp;
break;
default:
VK_ASSERT(!"Unexpected depthClampMode");
Expand All @@ -1387,8 +1388,8 @@ static void BuildViewportState(
else
{
// set min > max to disable the override
pInfo->immedInfo.depthClampOverride.minDepthClamp = 1.0f;
pInfo->immedInfo.depthClampOverride.maxDepthClamp = 0.0f;
pInfo->immedInfo.viewportParams.depthClampOverride.minDepth = 1.0f;
pInfo->immedInfo.viewportParams.depthClampOverride.maxDepth = 0.0f;
}
}

Expand Down
2 changes: 0 additions & 2 deletions icd/api/include/graphics_pipeline_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ struct GraphicsPipelineObjectImmedInfo
Pal::PointLineRasterStateParams pointLineRasterParams;
Pal::LineStippleStateParams lineStippleParams;
Pal::ViewportParams viewportParams;
// min > max means that the override is not active
VkDepthClampRangeEXT depthClampOverride;
Pal::ScissorRectParams scissorRectParams;
Pal::StencilRefMaskParams stencilRefMasks;
SamplePattern samplePattern;
Expand Down
3 changes: 0 additions & 3 deletions icd/api/include/vk_cmdbuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,6 @@ struct AllGpuRenderState
uint32_t fragmentShadingRate;
} staticTokens;

// min > max means that the override is not active
VkDepthClampRangeEXT depthClampOverride;

// Which Vulkan PipelineBindPoint currently owns the state of each PAL pipeline bind point. This is
// relevant because e.g. multiple Vulkan pipeline bind points are implemented as compute pipelines and used through
// the same PAL pipeline bind point.
Expand Down
75 changes: 38 additions & 37 deletions icd/api/vk_cmdbuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1747,9 +1747,6 @@ void CmdBuffer::ResetPipelineState()

memset(&m_allGpuState.samplePattern, 0u, sizeof(m_allGpuState.samplePattern));

m_allGpuState.depthClampOverride.minDepthClamp = 1.0f;
m_allGpuState.depthClampOverride.maxDepthClamp = 0.0f;

uint32_t bindIdx = 0;

do
Expand Down Expand Up @@ -1799,20 +1796,21 @@ void CmdBuffer::ResetPipelineState()
{
PerGpuRenderState* pPerGpuState = PerGpuState(deviceIdx);

pPerGpuState->pMsaaState = nullptr;
pPerGpuState->pColorBlendState = nullptr;
pPerGpuState->pDepthStencilState = nullptr;
pPerGpuState->scissor.count = 1;
pPerGpuState->scissor.scissors[0] = {};
pPerGpuState->viewport.count = 1;
pPerGpuState->viewport.viewports[0] = {};
pPerGpuState->viewport.horzClipRatio = FLT_MAX;
pPerGpuState->viewport.vertClipRatio = FLT_MAX;
pPerGpuState->viewport.horzDiscardRatio = 1.0f;
pPerGpuState->viewport.vertDiscardRatio = 1.0f;
pPerGpuState->viewport.depthRange = Pal::DepthRange::ZeroToOne;
pPerGpuState->maxPipelineStackSizes = {};
pPerGpuState->dynamicPipelineStackSize = 0;
pPerGpuState->pMsaaState = nullptr;
pPerGpuState->pColorBlendState = nullptr;
pPerGpuState->pDepthStencilState = nullptr;
pPerGpuState->scissor.count = 1;
pPerGpuState->scissor.scissors[0] = {};
pPerGpuState->viewport.count = 1;
pPerGpuState->viewport.viewports[0] = {};
pPerGpuState->viewport.horzClipRatio = FLT_MAX;
pPerGpuState->viewport.vertClipRatio = FLT_MAX;
pPerGpuState->viewport.horzDiscardRatio = 1.0f;
pPerGpuState->viewport.vertDiscardRatio = 1.0f;
pPerGpuState->viewport.depthRange = Pal::DepthRange::ZeroToOne;
pPerGpuState->viewport.depthClampOverride = { 1.0f, 0.0f };
pPerGpuState->maxPipelineStackSizes = {};
pPerGpuState->dynamicPipelineStackSize = 0;

deviceIdx++;
}
Expand Down Expand Up @@ -10198,19 +10196,31 @@ void CmdBuffer::CmdSetDepthClampRangeEXT(
VkDepthClampModeEXT depthClampMode,
const VkDepthClampRangeEXT* pDepthClampRange)
{
switch (depthClampMode)
VK_ASSERT(m_cbBeginDeviceMask == m_pDevice->GetPalDeviceMask());
utils::IterateMask deviceGroup(m_cbBeginDeviceMask);
do
{
case VK_DEPTH_CLAMP_MODE_VIEWPORT_RANGE_EXT:
m_allGpuState.depthClampOverride.minDepthClamp = 1.0f;
m_allGpuState.depthClampOverride.maxDepthClamp = 0.0f;
break;
case VK_DEPTH_CLAMP_MODE_USER_DEFINED_RANGE_EXT:
m_allGpuState.depthClampOverride = *pDepthClampRange;
break;
default:
VK_ASSERT(!"Unexpected depthClampMode");
break;
const uint32_t deviceIdx = deviceGroup.Index();

switch (depthClampMode)
{
case VK_DEPTH_CLAMP_MODE_VIEWPORT_RANGE_EXT:
PerGpuState(deviceIdx)->viewport.depthClampOverride.minDepth = 1.0f;
PerGpuState(deviceIdx)->viewport.depthClampOverride.maxDepth = 0.0f;
break;
case VK_DEPTH_CLAMP_MODE_USER_DEFINED_RANGE_EXT:
PerGpuState(deviceIdx)->viewport.depthClampOverride.minDepth = pDepthClampRange->minDepthClamp;
PerGpuState(deviceIdx)->viewport.depthClampOverride.maxDepth = pDepthClampRange->maxDepthClamp;
break;
default:
VK_ASSERT(!"Unexpected depthClampMode");
break;
}
}
while (deviceGroup.IterateNext());

m_allGpuState.dirtyGraphics.viewport = 1;
m_allGpuState.staticTokens.viewports = DynamicRenderStateToken;
}

// =====================================================================================================================
Expand Down Expand Up @@ -12578,15 +12588,6 @@ void CmdBuffer::ValidateGraphicsStates()
viewportParams.horzDiscardRatio = 10.0f;
viewportParams.vertDiscardRatio = 10.0f;
}
if (m_allGpuState.depthClampOverride.minDepthClamp <= m_allGpuState.depthClampOverride.maxDepthClamp)
{
for (uint32_t i = 0; i < viewportParams.count; ++i)
{
auto* const pViewport = &viewportParams.viewports[i];
pViewport->minDepth = m_allGpuState.depthClampOverride.minDepthClamp;
pViewport->maxDepth = m_allGpuState.depthClampOverride.maxDepthClamp;
}
}
PalCmdBuffer(deviceIdx)->CmdSetViewports(viewportParams);

DbgBarrierPostCmd(DbgBarrierSetDynamicPipelineState);
Expand Down
21 changes: 16 additions & 5 deletions icd/api/vk_graphics_pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1752,6 +1752,22 @@ void GraphicsPipeline::BindToCmdBuffer(
} while (deviceGroup.IterateNext());
}

if (ContainsStaticState(DynamicStatesInternal::DepthClampControl))
{
utils::IterateMask deviceGroup(pCmdBuffer->GetDeviceMask());
do
{
Pal::DepthClamp* pDepthClamp = &(pCmdBuffer->PerGpuState(deviceGroup.Index())->viewport.depthClampOverride);

if (pDepthClamp->minDepth != m_info.viewportParams.depthClampOverride.minDepth ||
pDepthClamp->maxDepth != m_info.viewportParams.depthClampOverride.maxDepth)
{
*pDepthClamp = m_info.viewportParams.depthClampOverride;
pRenderState->dirtyGraphics.viewport = 1;
}
} while (deviceGroup.IterateNext());
}

Pal::DepthRange depthRange = pGfxDynamicBindInfo->depthRange;
if (ContainsStaticState(DynamicStatesInternal::DepthClipNegativeOneToOne))
{
Expand All @@ -1771,11 +1787,6 @@ void GraphicsPipeline::BindToCmdBuffer(
}
}

if (ContainsStaticState(DynamicStatesInternal::DepthClampControl))
{
pRenderState->depthClampOverride = m_info.depthClampOverride;
}

if (ContainsStaticState(DynamicStatesInternal::Scissor))
{
if (CmdBuffer::IsStaticStateDifferent(oldTokens.scissorRect, newTokens.scissorRect))
Expand Down