lavapipe: implement VK_EXT_depth_clip_enable
v2: fix pipeline creation, need a deep copy for rasterization state now Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12260>
This commit is contained in:

committed by
Marge Bot

parent
49337ec410
commit
1a554fd610
@@ -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;
|
||||
|
@@ -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;
|
||||
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;
|
||||
|
||||
|
@@ -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) {
|
||||
|
Reference in New Issue
Block a user