From 3235bb70c861c64a4df5394ed4caca3c6e8edfa5 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sat, 17 Jun 2023 12:13:38 +0900 Subject: [PATCH] [vulkan] Move attachement specs into frambuffer This does a better job of keeping related data together. --- include/QF/Vulkan/render.h | 4 +- libs/video/renderer/vulkan/render_load.c | 16 +-- libs/video/renderer/vulkan/rp_main_def.plist | 110 +++++++++---------- libs/video/renderer/vulkan/vkparse.plist | 10 +- 4 files changed, 69 insertions(+), 71 deletions(-) diff --git a/include/QF/Vulkan/render.h b/include/QF/Vulkan/render.h index ef1b5ff45..8adee7233 100644 --- a/include/QF/Vulkan/render.h +++ b/include/QF/Vulkan/render.h @@ -195,7 +195,7 @@ typedef struct qfv_subpassinfo_s { } qfv_subpassinfo_t; typedef struct qfv_framebufferinfo_s { - qfv_reference_t *attachments; + qfv_attachmentinfo_t *attachments; uint32_t num_attachments; uint32_t width; uint32_t height; @@ -206,8 +206,6 @@ typedef struct qfv_renderpassinfo_s { vec4f_t color; const char *name; void *pNext; - uint32_t num_attachments; - qfv_attachmentinfo_t *attachments; qfv_framebufferinfo_t framebuffer; uint32_t num_subpasses; qfv_subpassinfo_t *subpasses; diff --git a/libs/video/renderer/vulkan/render_load.c b/libs/video/renderer/vulkan/render_load.c index 872d5aa92..105689446 100644 --- a/libs/video/renderer/vulkan/render_load.c +++ b/libs/video/renderer/vulkan/render_load.c @@ -146,7 +146,7 @@ count_sp_stuff (qfv_subpassinfo_t *spi, objcount_t *counts) static void count_rp_stuff (qfv_renderpassinfo_t *rpi, objcount_t *counts) { - counts->num_attachments += rpi->num_attachments; + counts->num_attachments += rpi->framebuffer.num_attachments; counts->num_subpasses += rpi->num_subpasses; for (uint32_t i = 0; i < rpi->num_subpasses; i++) { count_sp_stuff (&rpi->subpasses[i], counts); @@ -519,8 +519,8 @@ init_plCreate (VkGraphicsPipelineCreateInfo *plc, const qfv_pipelineinfo_t *pli, static uint32_t __attribute__((pure)) find_attachment (qfv_reference_t *ref, objstate_t *s) { - for (uint32_t i = 0; i < s->rpi->num_attachments; i++) { - __auto_type a = &s->rpi->attachments[i]; + for (uint32_t i = 0; i < s->rpi->framebuffer.num_attachments; i++) { + __auto_type a = &s->rpi->framebuffer.attachments[i]; if (strcmp (ref->name, a->name) == 0) { return i; } @@ -671,8 +671,8 @@ init_rpCreate (uint32_t index, const qfv_renderinfo_t *rinfo, objstate_t *s) __auto_type subpasses = &s->ptr.subpass[s->inds.num_subpasses]; __auto_type dependencies = &s->ptr.depend[s->inds.num_dependencies]; - for (uint32_t i = 0; i < s->rpi->num_attachments; i++) { - init_atCreate (i, s->rpi->attachments, s); + for (uint32_t i = 0; i < s->rpi->framebuffer.num_attachments; i++) { + init_atCreate (i, s->rpi->framebuffer.attachments, s); s->inds.num_attachments++; } @@ -685,7 +685,7 @@ init_rpCreate (uint32_t index, const qfv_renderinfo_t *rinfo, objstate_t *s) *s->rpc = (VkRenderPassCreateInfo) { .sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, - .attachmentCount = s->rpi->num_attachments, + .attachmentCount = s->rpi->framebuffer.num_attachments, .pAttachments = attachments, .subpassCount = s->rpi->num_subpasses, .pSubpasses = subpasses, @@ -777,12 +777,12 @@ init_renderpass (qfv_renderpass_t *rp, qfv_renderpassinfo_t *rpinfo, .beginInfo = (VkRenderPassBeginInfo) { .sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, .renderPass = s->ptr.rp[s->inds.num_renderpasses], - .clearValueCount = rpinfo->num_attachments, + .clearValueCount = rpinfo->framebuffer.num_attachments, .pClearValues = &jp->clearvalues[s->inds.num_attachments], }, .subpassContents = VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS, }; - s->inds.num_attachments += rpinfo->num_attachments; + s->inds.num_attachments += rpinfo->framebuffer.num_attachments; for (uint32_t i = 0; i < rpinfo->num_subpasses; i++) { init_subpass (&rp->subpasses[i], &rpinfo->subpasses[i], jp, s); rp->subpasses[i].inherit.renderPass = rp->beginInfo.renderPass; diff --git a/libs/video/renderer/vulkan/rp_main_def.plist b/libs/video/renderer/vulkan/rp_main_def.plist index ce42ca3bd..20f09c8a9 100644 --- a/libs/video/renderer/vulkan/rp_main_def.plist +++ b/libs/video/renderer/vulkan/rp_main_def.plist @@ -846,55 +846,55 @@ output = { renderpasses = { deferred = { color = "[0, 1, 0, 1]"; - attachments = { - depth = { - @inherit = $attachment_base; - format = $images.depth.format; - loadOp = clear; - finalLayout = depth_stencil_attachment_optimal; - clearValue = { depthStencil = { depth = 1; stencil = 0; }; }; - view = $imageviews.depth; - }; - color = { - @inherit = $attachment_base; - format = $images.color.format; - loadOp = clear; - view = $imageviews.color; - }; - emission = { - @inherit = $attachment_base; - format = $images.emission.format; - loadOp = clear; - view = $imageviews.emission; - }; - normal = { - @inherit = $attachment_base; - format = $images.normal.format; - view = $imageviews.normal; - }; - position = { - @inherit = $attachment_base; - format = $images.position.format; - view = $imageviews.position; - }; - opaque = { - @inherit = $attachment_base; - format = $images.opaque.format; - view = $imageviews.opaque; - }; - output = { - @inherit = $attachment_base; - format = $render_output.format; - loadOp = clear; - storeOp = store; - finalLayout = $render_output.finalLayout; - view = $imageviews.output; - }; - }; framebuffer = { width = $render_output.extent.width; height = $render_output.extent.height; layers = 1; + attachments = { + depth = { + @inherit = $attachment_base; + format = $images.depth.format; + loadOp = clear; + finalLayout = depth_stencil_attachment_optimal; + clearValue = { depthStencil = { depth = 1; stencil = 0; }; }; + view = $imageviews.depth; + }; + color = { + @inherit = $attachment_base; + format = $images.color.format; + loadOp = clear; + view = $imageviews.color; + }; + emission = { + @inherit = $attachment_base; + format = $images.emission.format; + loadOp = clear; + view = $imageviews.emission; + }; + normal = { + @inherit = $attachment_base; + format = $images.normal.format; + view = $imageviews.normal; + }; + position = { + @inherit = $attachment_base; + format = $images.position.format; + view = $imageviews.position; + }; + opaque = { + @inherit = $attachment_base; + format = $images.opaque.format; + view = $imageviews.opaque; + }; + output = { + @inherit = $attachment_base; + format = $render_output.format; + loadOp = clear; + storeOp = store; + finalLayout = $render_output.finalLayout; + view = $imageviews.output; + }; + }; }; subpasses = { depth = { @@ -1242,20 +1242,20 @@ renderpasses = { }; output = { color = "[0, 1, 1, 1]"; - attachments = { - output = { - @inherit = $attachment_base; - format = $render_output.format; - loadOp = clear; - storeOp = store; - finalLayout = present_src_khr; - view = $render_output.view; - }; - }; framebuffer = { width = $render_output.extent.width; height = $render_output.extent.height; layers = 1; + attachments = { + output = { + @inherit = $attachment_base; + format = $render_output.format; + loadOp = clear; + storeOp = store; + finalLayout = present_src_khr; + view = $render_output.view; + }; + }; }; subpasses = { compose = { diff --git a/libs/video/renderer/vulkan/vkparse.plist b/libs/video/renderer/vulkan/vkparse.plist index 977814651..c53fa7a32 100644 --- a/libs/video/renderer/vulkan/vkparse.plist +++ b/libs/video/renderer/vulkan/vkparse.plist @@ -629,6 +629,11 @@ parse = { width = auto; height = auto; layers = auto; + attachments = { + type = (labeledarray, qfv_attachmentinfo_t, name); + size = num_attachments; + values = attachments; + }; }; qfv_reference_s = { .name = qfv_reference_t; @@ -641,11 +646,6 @@ parse = { qfv_renderpassinfo_s = { .name = qfv_renderpassinfo_t; color = auto; - attachments = { - type = (labeledarray, qfv_attachmentinfo_t, name); - size = num_attachments; - values = attachments; - }; framebuffer = auto; subpasses = { type = (labeledarray, qfv_subpassinfo_t, name);