2021-04-07 15:19:46 -07:00
|
|
|
/*
|
|
|
|
|
* Copyright 2019 Google LLC
|
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
|
*
|
|
|
|
|
* based in part on anv and radv which are:
|
|
|
|
|
* Copyright © 2015 Intel Corporation
|
|
|
|
|
* Copyright © 2016 Red Hat.
|
|
|
|
|
* Copyright © 2016 Bas Nieuwenhuizen
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef VN_COMMAND_BUFFER_H
|
|
|
|
|
#define VN_COMMAND_BUFFER_H
|
|
|
|
|
|
|
|
|
|
#include "vn_common.h"
|
|
|
|
|
|
|
|
|
|
#include "vn_cs.h"
|
2023-09-26 16:36:58 -07:00
|
|
|
#include "vn_feedback.h"
|
2021-04-07 15:19:46 -07:00
|
|
|
|
|
|
|
|
struct vn_command_pool {
|
|
|
|
|
struct vn_object_base base;
|
|
|
|
|
|
|
|
|
|
VkAllocationCallbacks allocator;
|
2023-07-04 15:21:23 -07:00
|
|
|
struct vn_device *device;
|
2021-05-05 09:24:29 -07:00
|
|
|
uint32_t queue_family_index;
|
|
|
|
|
|
2021-04-07 15:19:46 -07:00
|
|
|
struct list_head command_buffers;
|
2023-07-06 13:18:00 -07:00
|
|
|
|
2024-01-22 09:51:46 -08:00
|
|
|
/* This list of free query batches has dual usage depending if
|
|
|
|
|
* the command pool is a vn_feedback_pool. The usage is exclusive
|
|
|
|
|
* and the list only contains recycled query batches allocated
|
|
|
|
|
* from the cmd pool itself so no locking is needed between the two
|
|
|
|
|
* usages.
|
|
|
|
|
*
|
|
|
|
|
* For feedback cmd pool, batch alloc and free with the free list is
|
|
|
|
|
* during queue submissions. Thus proper locking is needed since
|
|
|
|
|
* submissions with different queues are not externally synchronized.
|
|
|
|
|
*
|
|
|
|
|
* For a normal cmd pool, it recycles query batches used for
|
|
|
|
|
* injecting query copies/resets and merging batches for secondary
|
|
|
|
|
* command buffers during recording. No additional locking is needed
|
|
|
|
|
* as those commands are already protected by external synchronization.
|
|
|
|
|
*/
|
2023-07-06 13:18:00 -07:00
|
|
|
struct list_head free_query_batches;
|
2023-07-08 22:11:44 -07:00
|
|
|
|
2024-02-14 14:22:22 -08:00
|
|
|
/* for scrubbing VK_IMAGE_LAYOUT_PRESENT_SRC_KHR */
|
|
|
|
|
struct vn_cached_storage storage;
|
2021-04-07 15:19:46 -07:00
|
|
|
};
|
|
|
|
|
VK_DEFINE_NONDISP_HANDLE_CASTS(vn_command_pool,
|
|
|
|
|
base.base,
|
|
|
|
|
VkCommandPool,
|
|
|
|
|
VK_OBJECT_TYPE_COMMAND_POOL)
|
|
|
|
|
|
|
|
|
|
enum vn_command_buffer_state {
|
|
|
|
|
VN_COMMAND_BUFFER_STATE_INITIAL,
|
|
|
|
|
VN_COMMAND_BUFFER_STATE_RECORDING,
|
|
|
|
|
VN_COMMAND_BUFFER_STATE_EXECUTABLE,
|
|
|
|
|
VN_COMMAND_BUFFER_STATE_INVALID,
|
|
|
|
|
};
|
|
|
|
|
|
2023-07-11 19:49:43 -07:00
|
|
|
/* command buffer builder to:
|
|
|
|
|
* - fix wsi image ownership and layout transitions
|
|
|
|
|
* - scrub ignored bits in VkCommandBufferBeginInfo
|
|
|
|
|
* - support asynchronization query optimization (query feedback)
|
|
|
|
|
*/
|
2021-05-05 12:15:31 -07:00
|
|
|
struct vn_command_buffer_builder {
|
2023-07-11 19:49:43 -07:00
|
|
|
/* track the active legacy render pass */
|
2021-05-05 12:24:21 -07:00
|
|
|
const struct vn_render_pass *render_pass;
|
2023-07-11 19:49:43 -07:00
|
|
|
/* track the wsi images requiring layout fixes */
|
2021-05-05 16:17:34 -07:00
|
|
|
const struct vn_image **present_src_images;
|
2023-07-11 19:49:43 -07:00
|
|
|
/* track if inside a render pass instance */
|
|
|
|
|
bool in_render_pass;
|
|
|
|
|
/* track the active subpass for view mask used in the subpass */
|
|
|
|
|
uint32_t subpass_index;
|
|
|
|
|
/* track the active view mask inside a render pass instance */
|
|
|
|
|
uint32_t view_mask;
|
2023-09-26 16:04:18 -07:00
|
|
|
/* track if VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT was set */
|
|
|
|
|
bool is_simultaneous;
|
2023-07-11 19:49:43 -07:00
|
|
|
/* track the query feedbacks deferred outside the render pass instance */
|
|
|
|
|
struct list_head query_batches;
|
2021-05-05 12:15:31 -07:00
|
|
|
};
|
|
|
|
|
|
2021-04-07 15:19:46 -07:00
|
|
|
struct vn_command_buffer {
|
|
|
|
|
struct vn_object_base base;
|
|
|
|
|
|
2023-07-04 15:21:23 -07:00
|
|
|
struct vn_command_pool *pool;
|
2021-05-05 09:24:29 -07:00
|
|
|
VkCommandBufferLevel level;
|
2021-04-07 15:19:46 -07:00
|
|
|
enum vn_command_buffer_state state;
|
|
|
|
|
struct vn_cs_encoder cs;
|
2022-04-26 19:25:54 +00:00
|
|
|
|
|
|
|
|
uint32_t draw_cmd_batched;
|
2023-06-30 08:37:12 -07:00
|
|
|
|
2023-07-11 19:49:43 -07:00
|
|
|
struct vn_command_buffer_builder builder;
|
|
|
|
|
|
2024-02-15 10:16:16 -08:00
|
|
|
struct vn_query_feedback_cmd *linked_qfb_cmd;
|
2023-09-26 16:04:18 -07:00
|
|
|
|
2023-07-11 19:49:43 -07:00
|
|
|
struct list_head head;
|
2021-04-07 15:19:46 -07:00
|
|
|
};
|
|
|
|
|
VK_DEFINE_HANDLE_CASTS(vn_command_buffer,
|
|
|
|
|
base.base,
|
|
|
|
|
VkCommandBuffer,
|
|
|
|
|
VK_OBJECT_TYPE_COMMAND_BUFFER)
|
|
|
|
|
|
2023-09-26 16:36:58 -07:00
|
|
|
struct vn_feedback_query_batch *
|
|
|
|
|
vn_cmd_query_batch_alloc(struct vn_command_pool *pool,
|
|
|
|
|
struct vn_query_pool *query_pool,
|
|
|
|
|
uint32_t query,
|
|
|
|
|
uint32_t query_count,
|
|
|
|
|
bool copy);
|
2021-04-07 15:19:46 -07:00
|
|
|
#endif /* VN_COMMAND_BUFFER_H */
|