Commit 07956bbc authored by Dave Airlie's avatar Dave Airlie Committed by Marge Bot
Browse files

lavapipe: VK_KHR_depth_stencil_resolve support



This adds support for depth stencil resolves to lavapipe.
Reviewed-by: default avatarRoland Scheidegger <sroland@vmware.com>
Part-of: <!12504>
parent 3235b695
Pipeline #392564 waiting for manual action with stages
in 3 minutes and 6 seconds
......@@ -448,7 +448,7 @@ Vulkan 1.2 -- all DONE: anv, vn
VK_KHR_8bit_storage DONE (anv/gen8+, lvp, radv, vn)
VK_KHR_buffer_device_address DONE (anv/gen8+, lvp, radv, vn)
VK_KHR_create_renderpass2 DONE (anv, lvp, radv, tu, vn)
VK_KHR_depth_stencil_resolve DONE (anv, radv, tu, vn)
VK_KHR_depth_stencil_resolve DONE (anv, lvp, radv, tu, vn)
VK_KHR_draw_indirect_count DONE (anv, lvp, radv, tu, vn)
VK_KHR_driver_properties DONE (anv, lvp, radv, vn)
VK_KHR_image_format_list DONE (anv, lvp, radv, tu, v3dv, vn)
......
......@@ -8,3 +8,4 @@ GL_AMD_pinned_memory on llvmpipe
GL 4.5 compatibility on llvmpipe
VK_EXT_primitive_topology_list_restart on RADV.
ES 3.2 on zink
VK_KHR_depth_stencil_resolve on lavapipe
......@@ -95,6 +95,7 @@ static const struct vk_device_extension_table lvp_device_extensions_supported =
.KHR_create_renderpass2 = true,
.KHR_copy_commands2 = true,
.KHR_dedicated_allocation = true,
.KHR_depth_stencil_resolve = true,
.KHR_descriptor_update_template = true,
.KHR_device_group = true,
.KHR_draw_indirect_count = true,
......@@ -1022,6 +1023,15 @@ VKAPI_ATTR void VKAPI_CALL lvp_GetPhysicalDeviceProperties2(
props->maxMultiDrawCount = 2048;
break;
}
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_STENCIL_RESOLVE_PROPERTIES: {
VkPhysicalDeviceDepthStencilResolveProperties *properties =
(VkPhysicalDeviceDepthStencilResolveProperties *)ext;
properties->supportedDepthResolveModes = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT | VK_RESOLVE_MODE_AVERAGE_BIT;
properties->supportedStencilResolveModes = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT;
properties->independentResolveNone = false;
properties->independentResolve = false;
break;
}
default:
break;
}
......
......@@ -1545,6 +1545,60 @@ slow_clear:
static void render_pass_resolve(struct rendering_state *state)
{
const struct lvp_subpass *subpass = &state->pass->subpasses[state->subpass];
if (subpass->depth_stencil_attachment && subpass->ds_resolve_attachment) {
struct lvp_subpass_attachment src_att = *subpass->depth_stencil_attachment;
struct lvp_subpass_attachment dst_att = *subpass->ds_resolve_attachment;
if (dst_att.attachment != VK_ATTACHMENT_UNUSED) {
int num_blits = 1;
if (subpass->depth_resolve_mode != subpass->stencil_resolve_mode)
num_blits = 2;
for (unsigned i = 0; i < num_blits; i++) {
if (i == 0 && subpass->depth_resolve_mode == VK_RESOLVE_MODE_NONE)
continue;
if (i == 1 && subpass->stencil_resolve_mode == VK_RESOLVE_MODE_NONE)
continue;
struct lvp_image_view *src_imgv = get_attachment(state, src_att.attachment);
struct lvp_image_view *dst_imgv = get_attachment(state, dst_att.attachment);
struct pipe_blit_info info;
memset(&info, 0, sizeof(info));
info.src.resource = src_imgv->image->bo;
info.dst.resource = dst_imgv->image->bo;
info.src.format = src_imgv->pformat;
info.dst.format = dst_imgv->pformat;
info.filter = PIPE_TEX_FILTER_NEAREST;
if (num_blits == 1)
info.mask = PIPE_MASK_ZS;
else if (i == 0)
info.mask = PIPE_MASK_Z;
else
info.mask = PIPE_MASK_S;
if (i == 0 && subpass->depth_resolve_mode == VK_RESOLVE_MODE_SAMPLE_ZERO_BIT)
info.sample0_only = true;
if (i == 1 && subpass->stencil_resolve_mode == VK_RESOLVE_MODE_SAMPLE_ZERO_BIT)
info.sample0_only = true;
info.src.box.x = state->render_area.offset.x;
info.src.box.y = state->render_area.offset.y;
info.src.box.width = state->render_area.extent.width;
info.src.box.height = state->render_area.extent.height;
info.src.box.depth = state->vk_framebuffer->layers;
info.dst.box = info.src.box;
state->pctx->blit(state->pctx, &info);
}
}
}
if (!subpass->has_color_resolve)
return;
for (uint32_t i = 0; i < subpass->color_count; i++) {
......
......@@ -138,10 +138,14 @@ lvp_render_pass_compile(struct lvp_render_pass *pass)
static unsigned
lvp_num_subpass_attachments2(const VkSubpassDescription2 *desc)
{
const VkSubpassDescriptionDepthStencilResolve *ds_resolve =
vk_find_struct_const(desc->pNext,
SUBPASS_DESCRIPTION_DEPTH_STENCIL_RESOLVE);
return desc->inputAttachmentCount +
desc->colorAttachmentCount +
(desc->pResolveAttachments ? desc->colorAttachmentCount : 0) +
(desc->pDepthStencilAttachment != NULL);
(desc->pDepthStencilAttachment != NULL) +
(ds_resolve && ds_resolve->pDepthStencilResolveAttachment);
}
VKAPI_ATTR VkResult VKAPI_CALL lvp_CreateRenderPass2(
......@@ -262,6 +266,21 @@ VKAPI_ATTR VkResult VKAPI_CALL lvp_CreateRenderPass2(
.layout = desc->pDepthStencilAttachment->layout,
};
}
const VkSubpassDescriptionDepthStencilResolve *ds_resolve =
vk_find_struct_const(desc->pNext, SUBPASS_DESCRIPTION_DEPTH_STENCIL_RESOLVE);
if (ds_resolve && ds_resolve->pDepthStencilResolveAttachment) {
subpass->ds_resolve_attachment = p++;
*subpass->ds_resolve_attachment = (struct lvp_subpass_attachment){
.attachment = ds_resolve->pDepthStencilResolveAttachment->attachment,
.layout = ds_resolve->pDepthStencilResolveAttachment->layout,
};
subpass->depth_resolve_mode = ds_resolve->depthResolveMode;
subpass->stencil_resolve_mode = ds_resolve->stencilResolveMode;
}
}
lvp_render_pass_compile(pass);
......
......@@ -290,6 +290,8 @@ struct lvp_subpass {
struct lvp_subpass_attachment * resolve_attachments;
struct lvp_subpass_attachment * depth_stencil_attachment;
struct lvp_subpass_attachment * ds_resolve_attachment;
VkResolveModeFlagBits depth_resolve_mode;
VkResolveModeFlagBits stencil_resolve_mode;
/** Subpass has at least one color resolve attachment */
bool has_color_resolve;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment