From: Lionel Landwerlin Date: Mon, 14 Jan 2019 18:06:33 +0000 (+0000) Subject: anv: implement VK_EXT_depth_clip_enable X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f5092136755854b8b9591af93fa264a1b78737a1;p=mesa.git anv: implement VK_EXT_depth_clip_enable A new extension allowing the user to explictly specify the clipping behavior. Signed-off-by: Lionel Landwerlin --- diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index 74739c0da51..3120865466a 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -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; diff --git a/src/intel/vulkan/anv_extensions.py b/src/intel/vulkan/anv_extensions.py index e502b5d5685..2317854e929 100644 --- a/src/intel/vulkan/anv_extensions.py +++ b/src/intel/vulkan/anv_extensions.py @@ -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'), diff --git a/src/intel/vulkan/anv_pipeline.c b/src/intel/vulkan/anv_pipeline.c index e2024212bd9..b64cf44373b 100644 --- a/src/intel/vulkan/anv_pipeline.c +++ b/src/intel/vulkan/anv_pipeline.c @@ -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; diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index faa2d9a95a4..7624aace593 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -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; diff --git a/src/intel/vulkan/genX_pipeline.c b/src/intel/vulkan/genX_pipeline.c index 2a7044a425e..6255e5d83c5 100644 --- a/src/intel/vulkan/genX_pipeline.c +++ b/src/intel/vulkan/genX_pipeline.c @@ -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