diff --git a/src/gallium/frontends/lavapipe/lvp_device.c b/src/gallium/frontends/lavapipe/lvp_device.c index 1f2bd6843b0..f430874d668 100644 --- a/src/gallium/frontends/lavapipe/lvp_device.c +++ b/src/gallium/frontends/lavapipe/lvp_device.c @@ -129,6 +129,7 @@ static const struct vk_device_extension_table lvp_device_extensions_supported = .EXT_calibrated_timestamps = true, .EXT_color_write_enable = true, .EXT_conditional_rendering = true, + .EXT_depth_clip_enable = true, .EXT_extended_dynamic_state = true, .EXT_extended_dynamic_state2 = true, .EXT_external_memory_host = true, @@ -668,6 +669,15 @@ VKAPI_ATTR void VKAPI_CALL lvp_GetPhysicalDeviceFeatures2( features->multiDraw = true; break; } + case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_CLIP_ENABLE_FEATURES_EXT: { + VkPhysicalDeviceDepthClipEnableFeaturesEXT *features = + (VkPhysicalDeviceDepthClipEnableFeaturesEXT *)ext; + if (pdevice->pscreen->get_param(pdevice->pscreen, PIPE_CAP_DEPTH_CLAMP_ENABLE) != 0) + features->depthClipEnable = true; + else + features->depthClipEnable = false; + break; + } case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_2_FEATURES_EXT: { VkPhysicalDeviceExtendedDynamicState2FeaturesEXT *features = (VkPhysicalDeviceExtendedDynamicState2FeaturesEXT *)ext; features->extendedDynamicState2 = true; diff --git a/src/gallium/frontends/lavapipe/lvp_execute.c b/src/gallium/frontends/lavapipe/lvp_execute.c index 919b7ee08ce..8d7dbcc5d6d 100644 --- a/src/gallium/frontends/lavapipe/lvp_execute.c +++ b/src/gallium/frontends/lavapipe/lvp_execute.c @@ -526,7 +526,14 @@ static void handle_graphics_pipeline(struct vk_cmd_queue_entry *cmd, /* rasterization state */ if (pipeline->graphics_create_info.pRasterizationState) { const VkPipelineRasterizationStateCreateInfo *rsc = pipeline->graphics_create_info.pRasterizationState; - state->rs_state.depth_clip_near = state->rs_state.depth_clip_far = !rsc->depthClampEnable; + const VkPipelineRasterizationDepthClipStateCreateInfoEXT *depth_clip_state = + vk_find_struct_const(rsc->pNext, PIPELINE_RASTERIZATION_DEPTH_CLIP_STATE_CREATE_INFO_EXT); + state->rs_state.depth_clamp = rsc->depthClampEnable; + if (!depth_clip_state) + state->rs_state.depth_clip_near = state->rs_state.depth_clip_far = !rsc->depthClampEnable; + else + state->rs_state.depth_clip_near = state->rs_state.depth_clip_far = depth_clip_state->depthClipEnable; + if (!dynamic_states[conv_dynamic_state_idx(VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT)]) state->rs_state.rasterizer_discard = rsc->rasterizerDiscardEnable; diff --git a/src/gallium/frontends/lavapipe/lvp_pipeline.c b/src/gallium/frontends/lavapipe/lvp_pipeline.c index 94002b8c451..07172fd789f 100644 --- a/src/gallium/frontends/lavapipe/lvp_pipeline.c +++ b/src/gallium/frontends/lavapipe/lvp_pipeline.c @@ -127,7 +127,7 @@ deep_copy_vertex_input_state(void *mem_ctx, vk_foreach_struct(ext, src->pNext) { switch (ext->sType) { case VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT: { - VkPipelineVertexInputDivisorStateCreateInfoEXT *ext_src = (VkPipelineVertexInputDivisorStateCreateInfoEXT *)ext;; + VkPipelineVertexInputDivisorStateCreateInfoEXT *ext_src = (VkPipelineVertexInputDivisorStateCreateInfoEXT *)ext; VkPipelineVertexInputDivisorStateCreateInfoEXT *ext_dst = ralloc(mem_ctx, VkPipelineVertexInputDivisorStateCreateInfoEXT); ext_dst->sType = ext_src->sType; @@ -239,6 +239,35 @@ deep_copy_dynamic_state(void *mem_ctx, return VK_SUCCESS; } + +static VkResult +deep_copy_rasterization_state(void *mem_ctx, + VkPipelineRasterizationStateCreateInfo *dst, + const VkPipelineRasterizationStateCreateInfo *src) +{ + memcpy(dst, src, sizeof(VkPipelineRasterizationStateCreateInfo)); + dst->pNext = NULL; + + if (src->pNext) { + vk_foreach_struct(ext, src->pNext) { + switch (ext->sType) { + case VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_DEPTH_CLIP_STATE_CREATE_INFO_EXT: { + VkPipelineRasterizationDepthClipStateCreateInfoEXT *ext_src = (VkPipelineRasterizationDepthClipStateCreateInfoEXT *)ext; + VkPipelineRasterizationDepthClipStateCreateInfoEXT *ext_dst = ralloc(mem_ctx, VkPipelineRasterizationDepthClipStateCreateInfoEXT); + ext_dst->sType = ext_src->sType; + ext_dst->flags = ext_src->flags; + ext_dst->depthClipEnable = ext_src->depthClipEnable; + dst->pNext = ext_dst; + break; + } + default: + break; + } + } + } + return VK_SUCCESS; +} + static VkResult deep_copy_graphics_create_info(void *mem_ctx, VkGraphicsPipelineCreateInfo *dst, @@ -248,6 +277,7 @@ deep_copy_graphics_create_info(void *mem_ctx, VkResult result; VkPipelineShaderStageCreateInfo *stages; VkPipelineVertexInputStateCreateInfo *vertex_input; + VkPipelineRasterizationStateCreateInfo *rasterization_state; LVP_FROM_HANDLE(lvp_render_pass, pass, src->renderPass); dst->sType = src->sType; @@ -313,10 +343,11 @@ deep_copy_graphics_create_info(void *mem_ctx, dst->pViewportState = NULL; /* pRasterizationState */ - LVP_PIPELINE_DUP(dst->pRasterizationState, - src->pRasterizationState, - VkPipelineRasterizationStateCreateInfo, - 1); + rasterization_state = ralloc(mem_ctx, VkPipelineRasterizationStateCreateInfo); + if (!rasterization_state) + return VK_ERROR_OUT_OF_HOST_MEMORY; + deep_copy_rasterization_state(mem_ctx, rasterization_state, src->pRasterizationState); + dst->pRasterizationState = rasterization_state; /* pMultisampleState */ if (src->pMultisampleState && !rasterization_disabled) {