From 1d5eeefd9b10df5d12eb2961d29bbae8a35befc8 Mon Sep 17 00:00:00 2001 From: Connor Abbott Date: Wed, 29 Mar 2023 10:28:25 +0200 Subject: [PATCH] vk/graphics_state: Remove vk_subpass_info It only has a subset of the renderpass state, whereas with turnip we need to use pretty much all of it at one point or another. Just allow the driver to pass in the entire vk_render_pass_state if it's using its own renderpass implementation. Reviewed-by: Lionel Landwerlin Part-of: --- docs/vulkan/graphics-state.rst | 12 ++++-------- src/imagination/vulkan/pvr_pipeline.c | 12 +++++++----- src/vulkan/runtime/vk_graphics_state.c | 13 +++++++------ src/vulkan/runtime/vk_graphics_state.h | 24 ++---------------------- 4 files changed, 20 insertions(+), 41 deletions(-) diff --git a/docs/vulkan/graphics-state.rst b/docs/vulkan/graphics-state.rst index aace5b40835..4cfd623bcd0 100644 --- a/docs/vulkan/graphics-state.rst +++ b/docs/vulkan/graphics-state.rst @@ -30,20 +30,16 @@ the render pass and dynamic rendering. For drivers which use structure will be populated as if for dynamic rendering, regardless of which path is used. Drivers which use their own render pass structure should parse the render pass, if available, and pass a -:cpp:struct:`vk_subpass_info` into +:cpp:struct:`vk_render_pass_state` to the `driver_rp` argument of :cpp:func:`vk_graphics_pipeline_state_fill()` with the relevant information from the specified subpass. If a render pass is available, :cpp:struct:`vk_render_pass_state` will be populated with the -:cpp:type:`VkRenderPass` handle and subpass index as well as the -information from the :cpp:struct:`vk_render_pass_state`. If dynamic -rendering is used or the driver does not provide a -:cpp:struct:`vk_subpass_info` structure, :cpp:struct:`vk_render_pass_state` +the information from the :cpp:struct:`driver_rp`. If dynamic +rendering is used or the driver provides a `NULL` +:cpp:struct:`driver_rp`, the :cpp:struct:`vk_render_pass_state` structure will be populated for dynamic rendering, including color, depth, and stencil attachment formats. -.. doxygenstruct:: vk_subpass_info - :members: - The usual flow for creating a full graphics pipeline (not library) looks like this: diff --git a/src/imagination/vulkan/pvr_pipeline.c b/src/imagination/vulkan/pvr_pipeline.c index ae26b9b596f..7a1d68e64a3 100644 --- a/src/imagination/vulkan/pvr_pipeline.c +++ b/src/imagination/vulkan/pvr_pipeline.c @@ -2242,8 +2242,8 @@ err_free_build_context: return result; } -static struct vk_subpass_info -pvr_create_subpass_info(const VkGraphicsPipelineCreateInfo *const info) +static struct vk_render_pass_state +pvr_create_renderpass_state(const VkGraphicsPipelineCreateInfo *const info) { PVR_FROM_HANDLE(pvr_render_pass, pass, info->renderPass); const struct pvr_render_subpass *const subpass = @@ -2263,8 +2263,10 @@ pvr_create_subpass_info(const VkGraphicsPipelineCreateInfo *const info) pass->attachments[subpass->depth_stencil_attachment].aspects; } - return (struct vk_subpass_info){ + return (struct vk_render_pass_state){ .attachment_aspects = attachment_aspects, + .render_pass = info->renderPass, + .subpass = info->subpass, /* TODO: This is only needed for VK_KHR_create_renderpass2 (or core 1.2), * which is not currently supported. @@ -2282,7 +2284,7 @@ pvr_graphics_pipeline_init(struct pvr_device *device, { struct vk_dynamic_graphics_state *const dynamic_state = &gfx_pipeline->dynamic_state; - const struct vk_subpass_info sp_info = pvr_create_subpass_info(pCreateInfo); + const struct vk_render_pass_state rp_state = pvr_create_renderpass_state(pCreateInfo); struct vk_graphics_pipeline_all_state all_state; struct vk_graphics_pipeline_state state = { 0 }; @@ -2294,7 +2296,7 @@ pvr_graphics_pipeline_init(struct pvr_device *device, result = vk_graphics_pipeline_state_fill(&device->vk, &state, pCreateInfo, - &sp_info, + &rp_state, &all_state, NULL, 0, diff --git a/src/vulkan/runtime/vk_graphics_state.c b/src/vulkan/runtime/vk_graphics_state.c index fe063637384..844dda943ae 100644 --- a/src/vulkan/runtime/vk_graphics_state.c +++ b/src/vulkan/runtime/vk_graphics_state.c @@ -1012,8 +1012,8 @@ vk_render_pass_state_is_complete(const struct vk_render_pass_state *rp) static void vk_render_pass_state_init(struct vk_render_pass_state *rp, const struct vk_render_pass_state *old_rp, + const struct vk_render_pass_state *driver_rp, const VkGraphicsPipelineCreateInfo *info, - const struct vk_subpass_info *sp_info, VkGraphicsPipelineLibraryFlagsEXT lib) { VkPipelineCreateFlags valid_pipeline_flags = 0; @@ -1048,9 +1048,10 @@ vk_render_pass_state_init(struct vk_render_pass_state *rp, .stencil_attachment_format = VK_FORMAT_UNDEFINED, }; - if (info->renderPass != VK_NULL_HANDLE && sp_info != NULL) { - rp->attachment_aspects = sp_info->attachment_aspects; - rp->view_mask = sp_info->view_mask; + if (info->renderPass != VK_NULL_HANDLE && driver_rp != NULL) { + assert(driver_rp->render_pass == info->renderPass); + assert(driver_rp->subpass == info->subpass); + *rp = *driver_rp; return; } @@ -1187,7 +1188,7 @@ VkResult vk_graphics_pipeline_state_fill(const struct vk_device *device, struct vk_graphics_pipeline_state *state, const VkGraphicsPipelineCreateInfo *info, - const struct vk_subpass_info *sp_info, + const struct vk_render_pass_state *driver_rp, struct vk_graphics_pipeline_all_state *all, const VkAllocationCallbacks *alloc, VkSystemAllocationScope scope, @@ -1307,7 +1308,7 @@ vk_graphics_pipeline_state_fill(const struct vk_device *device, if (lib & (VK_GRAPHICS_PIPELINE_LIBRARY_PRE_RASTERIZATION_SHADERS_BIT_EXT | VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT | VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT)) { - vk_render_pass_state_init(&rp, state->rp, info, sp_info, lib); + vk_render_pass_state_init(&rp, state->rp, driver_rp, info, lib); needs |= MESA_VK_GRAPHICS_STATE_RENDER_PASS_BIT; diff --git a/src/vulkan/runtime/vk_graphics_state.h b/src/vulkan/runtime/vk_graphics_state.h index 09ae1b407bf..192e7835ea7 100644 --- a/src/vulkan/runtime/vk_graphics_state.h +++ b/src/vulkan/runtime/vk_graphics_state.h @@ -867,26 +867,6 @@ struct vk_graphics_pipeline_state { const struct vk_render_pass_state *rp; }; -/** Struct for extra information that we need from the subpass. - * - * This struct need only be provided if the driver has its own render pass - * implementation. If the driver uses the common render pass implementation, - * we can get this information ourselves. - */ -struct vk_subpass_info { - /** VkSubpassDescription2::viewMask */ - uint32_t view_mask; - - /** - * Aspects of all attachments used as color or depth/stencil attachments - * in the subpass. Input and resolve attachments should not be considered - * when computing the attachments aspect mask. This is used to determine - * whether or not depth/stencil and color blend state are required for a - * pipeline. - */ - VkImageAspectFlags attachment_aspects; -}; - /** Populate a vk_graphics_pipeline_state from VkGraphicsPipelineCreateInfo * * This function crawls the provided VkGraphicsPipelineCreateInfo and uses it @@ -913,7 +893,7 @@ struct vk_subpass_info { * @param[in] device The Vulkan device * @param[out] state The graphics pipeline state to populate * @param[in] info The pCreateInfo from vkCreateGraphicsPipelines - * @param[in] sp_info Subpass info if the driver implements render + * @param[in] driver_rp Renderpass state if the driver implements render * passes itself. This should be NULL for drivers * that use the common render pass infrastructure * built on top of dynamic rendering. @@ -933,7 +913,7 @@ VkResult vk_graphics_pipeline_state_fill(const struct vk_device *device, struct vk_graphics_pipeline_state *state, const VkGraphicsPipelineCreateInfo *info, - const struct vk_subpass_info *sp_info, + const struct vk_render_pass_state *rp_info, struct vk_graphics_pipeline_all_state *all, const VkAllocationCallbacks *alloc, VkSystemAllocationScope scope,