Skip to content
Snippets Groups Projects
Commit 1d726940 authored by Faith Ekstrand's avatar Faith Ekstrand :speech_balloon:
Browse files

vulkan: Add a common CmdBegin/EndRederPass implementation


This implements vkCmdBeginRenderPass, vkCmdEndRenderPass, and
vkCmdNextSubpass in terms of the new vkCmdBegin/EndRendering included in
VK_KHR_dynamic_rendering and Vulkan 1.3.  All subpass dependencies and
implicit layout transitions are turned into actual barriers.  It does
require VK_KHR_synchronization2 because it always uses the 64-bit
version of the pipeline stage and access bitfields.

Reviewed-by: default avatarIvan Briano <ivan.briano@intel.com>
Part-of: <mesa/mesa!14961>
parent 874aeb87
No related branches found
No related tags found
No related merge requests found
......@@ -48,6 +48,7 @@ vk_command_buffer_init(struct vk_command_buffer *command_buffer,
void
vk_command_buffer_reset(struct vk_command_buffer *command_buffer)
{
vk_command_buffer_reset_render_pass(command_buffer);
vk_cmd_queue_reset(&command_buffer->cmd_queue);
util_dynarray_clear(&command_buffer->labels);
command_buffer->region_begin = true;
......@@ -57,6 +58,7 @@ void
vk_command_buffer_finish(struct vk_command_buffer *command_buffer)
{
list_del(&command_buffer->pool_link);
vk_command_buffer_reset_render_pass(command_buffer);
vk_cmd_queue_finish(&command_buffer->cmd_queue);
util_dynarray_fini(&command_buffer->labels);
vk_object_base_finish(&command_buffer->base);
......
......@@ -34,6 +34,32 @@ extern "C" {
#endif
struct vk_command_pool;
struct vk_framebuffer;
struct vk_image_view;
struct vk_render_pass;
/* Since VkSubpassDescription2::viewMask is a 32-bit integer, there are a
* maximum of 32 possible views.
*/
#define MESA_VK_MAX_MULTIVIEW_VIEW_COUNT 32
struct vk_attachment_view_state {
VkImageLayout layout;
VkImageLayout stencil_layout;
};
struct vk_attachment_state {
struct vk_image_view *image_view;
/** A running tally of which views have been loaded */
uint32_t views_loaded;
/** Per-view state */
struct vk_attachment_view_state views[MESA_VK_MAX_MULTIVIEW_VIEW_COUNT];
/** VkRenderPassBeginInfo::pClearValues[i] */
VkClearValue clear_value;
};
struct vk_command_buffer {
struct vk_object_base base;
......@@ -95,6 +121,15 @@ struct vk_command_buffer {
*/
struct util_dynarray labels;
bool region_begin;
struct vk_render_pass *render_pass;
uint32_t subpass_idx;
struct vk_framebuffer *framebuffer;
VkRect2D render_area;
/* This uses the same trick as STACK_ARRAY */
struct vk_attachment_state *attachments;
struct vk_attachment_state _attachments[8];
};
VK_DEFINE_HANDLE_CASTS(vk_command_buffer, base, VkCommandBuffer,
......@@ -105,6 +140,9 @@ vk_command_buffer_init(struct vk_command_buffer *command_buffer,
struct vk_command_pool *pool,
VkCommandBufferLevel level);
void
vk_command_buffer_reset_render_pass(struct vk_command_buffer *cmd_buffer);
void
vk_command_buffer_reset(struct vk_command_buffer *command_buffer);
......
This diff is collapsed.
......@@ -58,6 +58,14 @@ struct vk_subpass_attachment {
*/
VkImageLayout stencil_layout;
/** A per-view mask for if this is the last use of this attachment
*
* If the same render pass attachment is used multiple ways within a
* subpass, corresponding last_subpass bits will be set in all of them.
* For the non-multiview case, only the first bit is used.
*/
uint32_t last_subpass;
/** Resolve attachment, if any */
struct vk_subpass_attachment *resolve;
};
......@@ -93,7 +101,12 @@ struct vk_subpass {
/** VkSubpassDescriptionDepthStencilResolve::pDepthStencilResolveAttachment */
struct vk_subpass_attachment *depth_stencil_resolve_attachment;
/** VkSubpassDescription2::viewMask */
/** VkSubpassDescription2::viewMask or 1 for non-multiview
*
* For all view masks in the vk_render_pass data structure, we use a mask
* of 1 for non-multiview instead of a mask of 0. To determine if the
* render pass is multiview or not, see vk_render_pass::is_multiview.
*/
uint32_t view_mask;
/** VkSubpassDescriptionDepthStencilResolve::depthResolveMode */
......@@ -113,6 +126,12 @@ struct vk_render_pass_attachment {
/** VkAttachmentDescription2::samples */
uint32_t samples;
/** Views in which this attachment is used, 0 for unused
*
* For non-multiview, this will be 1 if the attachment is used.
*/
uint32_t view_mask;
/** VkAttachmentDescription2::loadOp */
VkAttachmentLoadOp load_op;
......@@ -177,6 +196,15 @@ struct vk_subpass_dependency {
struct vk_render_pass {
struct vk_object_base base;
/** True if this render pass uses multiview
*
* This is true if all subpasses have viewMask != 0.
*/
bool is_multiview;
/** Views used by this render pass or 1 for non-multiview */
uint32_t view_mask;
/** VkRenderPassCreateInfo2::attachmentCount */
uint32_t attachment_count;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment