From 76eb0adf03a9fa8858d0b86b54966e2d0029035f Mon Sep 17 00:00:00 2001 From: Conor McCarthy Date: Tue, 18 Jul 2023 15:50:18 +1000 Subject: [PATCH] vkd3d: Support depth bounds test. --- libs/vkd3d/device.c | 4 +--- libs/vkd3d/state.c | 11 +++++++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c index a158697b..79028fc3 100644 --- a/libs/vkd3d/device.c +++ b/libs/vkd3d/device.c @@ -1522,9 +1522,7 @@ static HRESULT vkd3d_init_device_caps(struct d3d12_device *device, device->feature_options1.ExpandedComputeResourceStates = TRUE; device->feature_options1.Int64ShaderOps = features->shaderInt64; - /* Depth bounds test is enabled in D3D12_DEPTH_STENCIL_DESC1, which is not - * supported. */ - device->feature_options2.DepthBoundsTestSupported = FALSE; + device->feature_options2.DepthBoundsTestSupported = features->depthBounds; /* d3d12_command_list_SetSamplePositions() is not implemented. */ device->feature_options2.ProgrammableSamplePositionsTier = D3D12_PROGRAMMABLE_SAMPLE_POSITIONS_TIER_NOT_SUPPORTED; diff --git a/libs/vkd3d/state.c b/libs/vkd3d/state.c index 47dbb208..de0e04ea 100644 --- a/libs/vkd3d/state.c +++ b/libs/vkd3d/state.c @@ -2659,7 +2659,7 @@ static void ds_desc_from_d3d12(struct VkPipelineDepthStencilStateCreateInfo *vk_ vk_desc->depthWriteEnable = VK_FALSE; vk_desc->depthCompareOp = VK_COMPARE_OP_NEVER; } - vk_desc->depthBoundsTestEnable = VK_FALSE; + vk_desc->depthBoundsTestEnable = d3d12_desc->DepthBoundsTestEnable; if ((vk_desc->stencilTestEnable = d3d12_desc->StencilEnable)) { vk_stencil_op_state_from_d3d12(&vk_desc->front, &d3d12_desc->FrontFace, @@ -3068,6 +3068,12 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s graphics->rt_count = rt_count; ds_desc_from_d3d12(&graphics->ds_desc, &desc->depth_stencil_state); + if (graphics->ds_desc.depthBoundsTestEnable && !device->feature_options2.DepthBoundsTestSupported) + { + WARN("Depth bounds test not supported by device.\n"); + hr = E_INVALIDARG; + goto fail; + } if (desc->dsv_format == DXGI_FORMAT_UNKNOWN && graphics->ds_desc.depthTestEnable && !graphics->ds_desc.depthWriteEnable && graphics->ds_desc.depthCompareOp == VK_COMPARE_OP_ALWAYS && !graphics->ds_desc.stencilTestEnable) @@ -3077,7 +3083,8 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s } graphics->dsv_format = VK_FORMAT_UNDEFINED; - if (graphics->ds_desc.depthTestEnable || graphics->ds_desc.stencilTestEnable) + if (graphics->ds_desc.depthTestEnable || graphics->ds_desc.stencilTestEnable + || graphics->ds_desc.depthBoundsTestEnable) { if (desc->dsv_format == DXGI_FORMAT_UNKNOWN) {