nvk: enable EXT_depth_clip_control
authorDave Airlie <airlied@redhat.com>
Wed, 26 Jul 2023 07:27:43 +0000 (17:27 +1000)
committerMarge Bot <emma+marge@anholt.net>
Fri, 4 Aug 2023 21:32:07 +0000 (21:32 +0000)
This is already handled in the dynamic state.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>

src/nouveau/vulkan/nvk_cmd_draw.c
src/nouveau/vulkan/nvk_physical_device.c

index a725999..7e41da8 100644 (file)
@@ -926,18 +926,25 @@ nvk_flush_vp_state(struct nvk_cmd_buffer *cmd)
 
    /* Nothing to do for MESA_VK_DYNAMIC_VP_VIEWPORT_COUNT */
 
-   if (BITSET_TEST(dyn->dirty, MESA_VK_DYNAMIC_VP_VIEWPORTS)) {
+   if (BITSET_TEST(dyn->dirty, MESA_VK_DYNAMIC_VP_VIEWPORTS) ||
+       BITSET_TEST(dyn->dirty, MESA_VK_DYNAMIC_VP_DEPTH_CLIP_NEGATIVE_ONE_TO_ONE)) {
       for (uint32_t i = 0; i < dyn->vp.viewport_count; i++) {
          const VkViewport *vp = &dyn->vp.viewports[i];
 
          P_MTHD(p, NV9097, SET_VIEWPORT_SCALE_X(i));
          P_NV9097_SET_VIEWPORT_SCALE_X(p, i, fui(0.5f * vp->width));
          P_NV9097_SET_VIEWPORT_SCALE_Y(p, i, fui(0.5f * vp->height));
-         P_NV9097_SET_VIEWPORT_SCALE_Z(p, i, fui(vp->maxDepth - vp->minDepth));
+         if (dyn->vp.depth_clip_negative_one_to_one)
+            P_NV9097_SET_VIEWPORT_SCALE_Z(p, i, fui(0.5f * (vp->maxDepth - vp->minDepth)));
+         else
+            P_NV9097_SET_VIEWPORT_SCALE_Z(p, i, fui(vp->maxDepth - vp->minDepth));
 
          P_NV9097_SET_VIEWPORT_OFFSET_X(p, i, fui(vp->x + 0.5f * vp->width));
          P_NV9097_SET_VIEWPORT_OFFSET_Y(p, i, fui(vp->y + 0.5f * vp->height));
-         P_NV9097_SET_VIEWPORT_OFFSET_Z(p, i, fui(vp->minDepth));
+         if (dyn->vp.depth_clip_negative_one_to_one)
+            P_NV9097_SET_VIEWPORT_OFFSET_Z(p, i, fui(0.5f * (vp->minDepth + vp->maxDepth)));
+         else
+            P_NV9097_SET_VIEWPORT_OFFSET_Z(p, i, fui(vp->minDepth));
 
          float xmin = vp->x;
          float xmax = vp->x + vp->width;
index bf1bbea..a3a663e 100644 (file)
@@ -374,6 +374,7 @@ nvk_get_device_extensions(const struct nv_device_info *info,
       .EXT_border_color_swizzle = true,
       .EXT_buffer_device_address = true,
       .EXT_custom_border_color = true,
+      .EXT_depth_clip_control = true,
       .EXT_descriptor_indexing = true,
       .EXT_extended_dynamic_state = true,
       .EXT_extended_dynamic_state2 = true,
@@ -525,6 +526,9 @@ nvk_get_device_features(const struct nv_device_info *info,
       .customBorderColors = true,
       .customBorderColorWithoutFormat = true,
 
+      /* VK_EXT_depth_clip_control */
+      .depthClipControl = true,
+
       /* VK_EXT_extended_dynamic_state */
       .extendedDynamicState = true,