anv: implement VK_EXT_depth_clip_enable
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>
Mon, 14 Jan 2019 18:06:33 +0000 (18:06 +0000)
committerLionel Landwerlin <lionel.g.landwerlin@intel.com>
Wed, 20 Feb 2019 09:57:58 +0000 (09:57 +0000)
A new extension allowing the user to explictly specify the clipping
behavior.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
src/intel/vulkan/anv_device.c
src/intel/vulkan/anv_extensions.py
src/intel/vulkan/anv_pipeline.c
src/intel/vulkan/anv_private.h
src/intel/vulkan/genX_pipeline.c

index 74739c0da5151903d90d9874ed9009efb2ae4c84..3120865466afc894975b99593b00bdf64d62f991 100644 (file)
@@ -943,6 +943,13 @@ void anv_GetPhysicalDeviceFeatures2(
          break;
       }
 
+      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_CLIP_ENABLE_FEATURES_EXT: {
+         VkPhysicalDeviceDepthClipEnableFeaturesEXT *features =
+            (VkPhysicalDeviceDepthClipEnableFeaturesEXT *)ext;
+         features->depthClipEnable = VK_TRUE;
+         break;
+      }
+
       case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES: {
          VkPhysicalDeviceMultiviewFeatures *features =
             (VkPhysicalDeviceMultiviewFeatures *)ext;
index e502b5d56853e34371c667efb65b4482fc871cc9..2317854e929148d1e7020256d604aac3b768e40c 100644 (file)
@@ -122,6 +122,7 @@ EXTENSIONS = [
     Extension('VK_EXT_calibrated_timestamps',             1, True),
     Extension('VK_EXT_conditional_rendering',             1, 'device->info.gen >= 8 || device->info.is_haswell'),
     Extension('VK_EXT_debug_report',                      8, True),
+    Extension('VK_EXT_depth_clip_enable',                 1, True),
     Extension('VK_EXT_direct_mode_display',               1, 'VK_USE_PLATFORM_DISPLAY_KHR'),
     Extension('VK_EXT_display_control',                   1, 'VK_USE_PLATFORM_DISPLAY_KHR'),
     Extension('VK_EXT_display_surface_counter',           1, 'VK_USE_PLATFORM_DISPLAY_KHR'),
index e2024212bd95a5a6f6dff62132fe8a6cd7833a40..b64cf44373b692b8210584c91bee98fcfa9ddef1 100644 (file)
@@ -1517,6 +1517,16 @@ anv_pipeline_init(struct anv_pipeline *pipeline,
    pipeline->depth_clamp_enable = pCreateInfo->pRasterizationState &&
                                   pCreateInfo->pRasterizationState->depthClampEnable;
 
+   /* Previously we enabled depth clipping when !depthClampEnable.
+    * DepthClipStateCreateInfo now makes depth clipping explicit so if the
+    * clipping info is available, use its enable value to determine clipping,
+    * otherwise fallback to the previous !depthClampEnable logic.
+    */
+   const VkPipelineRasterizationDepthClipStateCreateInfoEXT *clip_info =
+      vk_find_struct_const(pCreateInfo->pRasterizationState->pNext,
+                           PIPELINE_RASTERIZATION_DEPTH_CLIP_STATE_CREATE_INFO_EXT);
+   pipeline->depth_clip_enable = clip_info ? clip_info->depthClipEnable : !pipeline->depth_clamp_enable;
+
    pipeline->sample_shading_enable = pCreateInfo->pMultisampleState &&
                                      pCreateInfo->pMultisampleState->sampleShadingEnable;
 
index faa2d9a95a4bbb42630d8a418503035c77ef8495..7624aace5930394449329e161e2d305a7570c4d3 100644 (file)
@@ -2624,6 +2624,7 @@ struct anv_pipeline {
    bool                                         writes_stencil;
    bool                                         stencil_test_enable;
    bool                                         depth_clamp_enable;
+   bool                                         depth_clip_enable;
    bool                                         sample_shading_enable;
    bool                                         kill_pixel;
 
index 2a7044a425e8ee8403acedf5845baa03ea6d898f..6255e5d83c58efbd820497de7a7b13d16fc91cad 100644 (file)
@@ -508,10 +508,10 @@ emit_rs_state(struct anv_pipeline *pipeline,
 
 #if GEN_GEN >= 9
    /* GEN9+ splits ViewportZClipTestEnable into near and far enable bits */
-   raster.ViewportZFarClipTestEnable = !pipeline->depth_clamp_enable;
-   raster.ViewportZNearClipTestEnable = !pipeline->depth_clamp_enable;
+   raster.ViewportZFarClipTestEnable = pipeline->depth_clip_enable;
+   raster.ViewportZNearClipTestEnable = pipeline->depth_clip_enable;
 #elif GEN_GEN >= 8
-   raster.ViewportZClipTestEnable = !pipeline->depth_clamp_enable;
+   raster.ViewportZClipTestEnable = pipeline->depth_clip_enable;
 #endif
 
    raster.GlobalDepthOffsetEnableSolid = rs_info->depthBiasEnable;
@@ -1113,7 +1113,7 @@ emit_3dstate_clip(struct anv_pipeline *pipeline,
 #if GEN_GEN == 7
       clip.FrontWinding            = vk_to_gen_front_face[rs_info->frontFace];
       clip.CullMode                = vk_to_gen_cullmode[rs_info->cullMode];
-      clip.ViewportZClipTestEnable = !pipeline->depth_clamp_enable;
+      clip.ViewportZClipTestEnable = pipeline->depth_clip_enable;
       clip.UserClipDistanceClipTestEnableBitmask = last->clip_distance_mask;
       clip.UserClipDistanceCullTestEnableBitmask = last->cull_distance_mask;
 #else