Mesa (main): dzn: Enable depth-bounds testing
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Jun 9 16:19:30 UTC 2022
Module: Mesa
Branch: main
Commit: e6301b886b4a741ff6994987d12d32218c359d5a
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e6301b886b4a741ff6994987d12d32218c359d5a
Author: Boris Brezillon <boris.brezillon at collabora.com>
Date: Thu Jun 9 16:02:33 2022 +0200
dzn: Enable depth-bounds testing
Reviewed-by: Jesse Natalie <jenatali at microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16948>
---
src/microsoft/vulkan/dzn_cmd_buffer.c | 21 ++++++++++++++++++++-
src/microsoft/vulkan/dzn_device.c | 11 ++++++++++-
src/microsoft/vulkan/dzn_pipeline.c | 8 +++++++-
src/microsoft/vulkan/dzn_private.h | 10 ++++++++++
4 files changed, 47 insertions(+), 3 deletions(-)
diff --git a/src/microsoft/vulkan/dzn_cmd_buffer.c b/src/microsoft/vulkan/dzn_cmd_buffer.c
index 473c755b9d0..22d3ae3bca6 100644
--- a/src/microsoft/vulkan/dzn_cmd_buffer.c
+++ b/src/microsoft/vulkan/dzn_cmd_buffer.c
@@ -2365,6 +2365,16 @@ dzn_cmd_buffer_update_blend_constants(struct dzn_cmd_buffer *cmdbuf)
cmdbuf->state.blend.constants);
}
+static void
+dzn_cmd_buffer_update_depth_bounds(struct dzn_cmd_buffer *cmdbuf)
+{
+ if (cmdbuf->state.dirty & DZN_CMD_DIRTY_DEPTH_BOUNDS) {
+ ID3D12GraphicsCommandList1_OMSetDepthBounds(cmdbuf->cmdlist,
+ cmdbuf->state.zsa.depth_bounds.min,
+ cmdbuf->state.zsa.depth_bounds.max);
+ }
+}
+
static VkResult
dzn_cmd_buffer_triangle_fan_create_index(struct dzn_cmd_buffer *cmdbuf, uint32_t *vertex_count)
{
@@ -2507,6 +2517,7 @@ dzn_cmd_buffer_prepare_draw(struct dzn_cmd_buffer *cmdbuf, bool indexed)
dzn_cmd_buffer_update_push_constants(cmdbuf, VK_PIPELINE_BIND_POINT_GRAPHICS);
dzn_cmd_buffer_update_zsa(cmdbuf);
dzn_cmd_buffer_update_blend_constants(cmdbuf);
+ dzn_cmd_buffer_update_depth_bounds(cmdbuf);
if (indexed)
dzn_cmd_buffer_update_ibview(cmdbuf);
@@ -3597,6 +3608,12 @@ dzn_CmdBindPipeline(VkCommandBuffer commandBuffer,
cmdbuf->state.dirty |= DZN_CMD_DIRTY_STENCIL_REF;
}
+ if (gfx->zsa.depth_bounds.enable && !gfx->zsa.depth_bounds.dynamic) {
+ cmdbuf->state.zsa.depth_bounds.min = gfx->zsa.depth_bounds.min;
+ cmdbuf->state.zsa.depth_bounds.max = gfx->zsa.depth_bounds.max;
+ cmdbuf->state.dirty |= DZN_CMD_DIRTY_DEPTH_BOUNDS;
+ }
+
if (!gfx->blend.dynamic_constants) {
memcpy(cmdbuf->state.blend.constants, gfx->blend.constants,
sizeof(cmdbuf->state.blend.constants));
@@ -4342,7 +4359,9 @@ dzn_CmdSetDepthBounds(VkCommandBuffer commandBuffer,
{
VK_FROM_HANDLE(dzn_cmd_buffer, cmdbuf, commandBuffer);
- ID3D12GraphicsCommandList1_OMSetDepthBounds(cmdbuf->cmdlist, minDepthBounds, maxDepthBounds);
+ cmdbuf->state.zsa.depth_bounds.min = minDepthBounds;
+ cmdbuf->state.zsa.depth_bounds.max = maxDepthBounds;
+ cmdbuf->state.dirty |= DZN_CMD_DIRTY_DEPTH_BOUNDS;
}
VKAPI_ATTR void VKAPI_CALL
diff --git a/src/microsoft/vulkan/dzn_device.c b/src/microsoft/vulkan/dzn_device.c
index 23e30a59757..6055b360ed2 100644
--- a/src/microsoft/vulkan/dzn_device.c
+++ b/src/microsoft/vulkan/dzn_device.c
@@ -318,6 +318,7 @@ dzn_physical_device_cache_caps(struct dzn_physical_device *pdev)
ID3D12Device1_CheckFeatureSupport(pdev->dev, D3D12_FEATURE_ARCHITECTURE1, &pdev->architecture, sizeof(pdev->architecture));
ID3D12Device1_CheckFeatureSupport(pdev->dev, D3D12_FEATURE_D3D12_OPTIONS, &pdev->options, sizeof(pdev->options));
+ ID3D12Device1_CheckFeatureSupport(pdev->dev, D3D12_FEATURE_D3D12_OPTIONS2, &pdev->options2, sizeof(pdev->options2));
pdev->queue_families[pdev->queue_family_count++] = (struct dzn_queue_family) {
.props = {
@@ -1029,6 +1030,14 @@ dzn_physical_device_supports_bc(struct dzn_physical_device *pdev)
return dzn_physical_device_supports_compressed_format(pdev, formats, ARRAY_SIZE(formats));
}
+static bool
+dzn_physical_device_supports_depth_bounds(struct dzn_physical_device *pdev)
+{
+ dzn_physical_device_get_d3d12_dev(pdev);
+
+ return pdev->options2.DepthBoundsTestSupported;
+}
+
VKAPI_ATTR void VKAPI_CALL
dzn_GetPhysicalDeviceFeatures2(VkPhysicalDevice physicalDevice,
VkPhysicalDeviceFeatures2 *pFeatures)
@@ -1050,7 +1059,7 @@ dzn_GetPhysicalDeviceFeatures2(VkPhysicalDevice physicalDevice,
.depthClamp = false,
.depthBiasClamp = false,
.fillModeNonSolid = false,
- .depthBounds = false,
+ .depthBounds = dzn_physical_device_supports_depth_bounds(pdev),
.wideLines = false,
.largePoints = false,
.alphaToOne = false,
diff --git a/src/microsoft/vulkan/dzn_pipeline.c b/src/microsoft/vulkan/dzn_pipeline.c
index 626cd6a307e..132784144b0 100644
--- a/src/microsoft/vulkan/dzn_pipeline.c
+++ b/src/microsoft/vulkan/dzn_pipeline.c
@@ -792,7 +792,6 @@ dzn_graphics_pipeline_translate_zsa(struct dzn_graphics_pipeline *pipeline,
if (!in_zsa)
return;
- /* TODO: depthBoundsTestEnable */
d3d12_gfx_pipeline_state_stream_new_desc(out, DEPTH_STENCIL1, D3D12_DEPTH_STENCIL_DESC1, desc);
desc->DepthEnable = in_zsa->depthTestEnable;
@@ -801,6 +800,10 @@ dzn_graphics_pipeline_translate_zsa(struct dzn_graphics_pipeline *pipeline,
D3D12_DEPTH_WRITE_MASK_ALL : D3D12_DEPTH_WRITE_MASK_ZERO;
desc->DepthFunc =
dzn_translate_compare_op(in_zsa->depthCompareOp);
+ pipeline->zsa.depth_bounds.enable = in_zsa->depthBoundsTestEnable;
+ pipeline->zsa.depth_bounds.min = in_zsa->minDepthBounds;
+ pipeline->zsa.depth_bounds.max = in_zsa->maxDepthBounds;
+ desc->DepthBoundsTestEnable = in_zsa->depthBoundsTestEnable;
desc->StencilEnable = in_zsa->stencilTestEnable;
if (in_zsa->stencilTestEnable) {
desc->FrontFace.StencilFailOp =
@@ -1069,6 +1072,9 @@ dzn_graphics_pipeline_create(struct dzn_device *device,
case VK_DYNAMIC_STATE_BLEND_CONSTANTS:
pipeline->blend.dynamic_constants = true;
break;
+ case VK_DYNAMIC_STATE_DEPTH_BOUNDS:
+ pipeline->zsa.depth_bounds.dynamic = true;
+ break;
default: unreachable("Unsupported dynamic state");
}
}
diff --git a/src/microsoft/vulkan/dzn_private.h b/src/microsoft/vulkan/dzn_private.h
index 3542d15052c..7b84d18e95a 100644
--- a/src/microsoft/vulkan/dzn_private.h
+++ b/src/microsoft/vulkan/dzn_private.h
@@ -190,6 +190,7 @@ struct dzn_physical_device {
D3D_FEATURE_LEVEL feature_level;
D3D12_FEATURE_DATA_ARCHITECTURE1 architecture;
D3D12_FEATURE_DATA_D3D12_OPTIONS options;
+ D3D12_FEATURE_DATA_D3D12_OPTIONS2 options2;
VkPhysicalDeviceMemoryProperties memory;
D3D12_HEAP_FLAGS heap_flags_for_mem_type[VK_MAX_MEMORY_TYPES];
const struct vk_sync_type *sync_types[MAX_SYNC_TYPES + 1];
@@ -292,6 +293,7 @@ enum dzn_cmd_dirty {
DZN_CMD_DIRTY_STENCIL_COMPARE_MASK = 1 << 4,
DZN_CMD_DIRTY_STENCIL_WRITE_MASK = 1 << 5,
DZN_CMD_DIRTY_BLEND_CONSTANTS = 1 << 6,
+ DZN_CMD_DIRTY_DEPTH_BOUNDS = 1 << 7,
};
#define MAX_VBS 16
@@ -474,6 +476,9 @@ struct dzn_cmd_buffer_state {
uint32_t ref, compare_mask, write_mask;
} front, back;
} stencil_test;
+ struct {
+ float min, max;
+ } depth_bounds;
} zsa;
struct {
float constants[4];
@@ -735,6 +740,11 @@ struct dzn_graphics_pipeline {
bool uses_ref;
} front, back;
} stencil_test;
+ struct {
+ bool enable;
+ bool dynamic;
+ float min, max;
+ } depth_bounds;
} zsa;
struct {
More information about the mesa-commit
mailing list