mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-01 10:18:05 +02:00
lavapipe: move to common create render pass code
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9550>
This commit is contained in:
parent
8475ab7f92
commit
c843e3b5b4
1 changed files with 0 additions and 147 deletions
|
|
@ -135,153 +135,6 @@ lvp_render_pass_compile(struct lvp_render_pass *pass)
|
|||
}
|
||||
}
|
||||
|
||||
static unsigned
|
||||
lvp_num_subpass_attachments(const VkSubpassDescription *desc)
|
||||
{
|
||||
return desc->inputAttachmentCount +
|
||||
desc->colorAttachmentCount +
|
||||
(desc->pResolveAttachments ? desc->colorAttachmentCount : 0) +
|
||||
(desc->pDepthStencilAttachment != NULL);
|
||||
}
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL lvp_CreateRenderPass(
|
||||
VkDevice _device,
|
||||
const VkRenderPassCreateInfo* pCreateInfo,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
VkRenderPass* pRenderPass)
|
||||
{
|
||||
LVP_FROM_HANDLE(lvp_device, device, _device);
|
||||
struct lvp_render_pass *pass;
|
||||
size_t size;
|
||||
size_t attachments_offset;
|
||||
VkRenderPassMultiviewCreateInfo *multiview_info = NULL;
|
||||
|
||||
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO);
|
||||
|
||||
size = sizeof(*pass);
|
||||
size += pCreateInfo->subpassCount * sizeof(pass->subpasses[0]);
|
||||
attachments_offset = size;
|
||||
size += pCreateInfo->attachmentCount * sizeof(pass->attachments[0]);
|
||||
|
||||
pass = vk_alloc2(&device->vk.alloc, pAllocator, size, 8,
|
||||
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
|
||||
if (pass == NULL)
|
||||
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
|
||||
/* Clear the subpasses along with the parent pass. This required because
|
||||
* each array member of lvp_subpass must be a valid pointer if not NULL.
|
||||
*/
|
||||
memset(pass, 0, size);
|
||||
|
||||
vk_object_base_init(&device->vk, &pass->base,
|
||||
VK_OBJECT_TYPE_RENDER_PASS);
|
||||
pass->attachment_count = pCreateInfo->attachmentCount;
|
||||
pass->subpass_count = pCreateInfo->subpassCount;
|
||||
pass->attachments = (struct lvp_render_pass_attachment *)((char *)pass + attachments_offset);
|
||||
|
||||
vk_foreach_struct(ext, pCreateInfo->pNext) {
|
||||
switch(ext->sType) {
|
||||
case VK_STRUCTURE_TYPE_RENDER_PASS_MULTIVIEW_CREATE_INFO:
|
||||
multiview_info = (VkRenderPassMultiviewCreateInfo*)ext;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < pCreateInfo->attachmentCount; i++) {
|
||||
struct lvp_render_pass_attachment *att = &pass->attachments[i];
|
||||
|
||||
att->format = pCreateInfo->pAttachments[i].format;
|
||||
att->samples = pCreateInfo->pAttachments[i].samples;
|
||||
att->load_op = pCreateInfo->pAttachments[i].loadOp;
|
||||
att->stencil_load_op = pCreateInfo->pAttachments[i].stencilLoadOp;
|
||||
att->final_layout = pCreateInfo->pAttachments[i].finalLayout;
|
||||
att->first_subpass_idx = UINT32_MAX;
|
||||
}
|
||||
|
||||
uint32_t subpass_attachment_count = 0;
|
||||
for (uint32_t i = 0; i < pCreateInfo->subpassCount; i++) {
|
||||
subpass_attachment_count += lvp_num_subpass_attachments(&pCreateInfo->pSubpasses[i]);
|
||||
}
|
||||
|
||||
if (subpass_attachment_count) {
|
||||
pass->subpass_attachments =
|
||||
vk_alloc2(&device->vk.alloc, pAllocator,
|
||||
subpass_attachment_count * sizeof(struct lvp_subpass_attachment), 8,
|
||||
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
|
||||
if (pass->subpass_attachments == NULL) {
|
||||
vk_free2(&device->vk.alloc, pAllocator, pass);
|
||||
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
}
|
||||
} else
|
||||
pass->subpass_attachments = NULL;
|
||||
|
||||
struct lvp_subpass_attachment *p = pass->subpass_attachments;
|
||||
for (uint32_t i = 0; i < pCreateInfo->subpassCount; i++) {
|
||||
const VkSubpassDescription *desc = &pCreateInfo->pSubpasses[i];
|
||||
struct lvp_subpass *subpass = &pass->subpasses[i];
|
||||
|
||||
subpass->input_count = desc->inputAttachmentCount;
|
||||
subpass->color_count = desc->colorAttachmentCount;
|
||||
subpass->attachment_count = lvp_num_subpass_attachments(desc);
|
||||
subpass->attachments = p;
|
||||
|
||||
if (multiview_info)
|
||||
subpass->view_mask = multiview_info->pViewMasks[i];
|
||||
|
||||
if (desc->inputAttachmentCount > 0) {
|
||||
subpass->input_attachments = p;
|
||||
p += desc->inputAttachmentCount;
|
||||
|
||||
for (uint32_t j = 0; j < desc->inputAttachmentCount; j++) {
|
||||
subpass->input_attachments[j] = (struct lvp_subpass_attachment) {
|
||||
.attachment = desc->pInputAttachments[j].attachment,
|
||||
.layout = desc->pInputAttachments[j].layout,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (desc->colorAttachmentCount > 0) {
|
||||
subpass->color_attachments = p;
|
||||
p += desc->colorAttachmentCount;
|
||||
|
||||
for (uint32_t j = 0; j < desc->colorAttachmentCount; j++) {
|
||||
subpass->color_attachments[j] = (struct lvp_subpass_attachment) {
|
||||
.attachment = desc->pColorAttachments[j].attachment,
|
||||
.layout = desc->pColorAttachments[j].layout,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (desc->pResolveAttachments) {
|
||||
subpass->resolve_attachments = p;
|
||||
p += desc->colorAttachmentCount;
|
||||
|
||||
for (uint32_t j = 0; j < desc->colorAttachmentCount; j++) {
|
||||
subpass->resolve_attachments[j] = (struct lvp_subpass_attachment) {
|
||||
.attachment = desc->pResolveAttachments[j].attachment,
|
||||
.layout = desc->pResolveAttachments[j].layout,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (desc->pDepthStencilAttachment) {
|
||||
subpass->depth_stencil_attachment = p++;
|
||||
|
||||
*subpass->depth_stencil_attachment = (struct lvp_subpass_attachment) {
|
||||
.attachment = desc->pDepthStencilAttachment->attachment,
|
||||
.layout = desc->pDepthStencilAttachment->layout,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
lvp_render_pass_compile(pass);
|
||||
*pRenderPass = lvp_render_pass_to_handle(pass);
|
||||
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
static unsigned
|
||||
lvp_num_subpass_attachments2(const VkSubpassDescription2 *desc)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue