};
struct vk_command_buffer_ops {
+ /** Creates a command buffer
+ *
+ * Used by the common command pool implementation. This function MUST
+ * call `vk_command_buffer_finish()`. Notably, this function does not
+ * receive any additional parameters such as the level. The level will be
+ * set by `vk_common_AllocateCommandBuffers()` and the driver must not rely
+ * on it until `vkBeginCommandBuffer()` time.
+ */
+ VkResult (*create)(struct vk_command_pool *,
+ struct vk_command_buffer **);
+
/** Resets the command buffer
*
* Used by the common command pool implementation. This function MUST
pool->flags = pCreateInfo->flags;
pool->queue_family_index = pCreateInfo->queueFamilyIndex;
pool->alloc = pAllocator ? *pAllocator : device->alloc;
+ pool->command_buffer_ops = device->command_buffer_ops;
list_inithead(&pool->command_buffers);
return VK_SUCCESS;
return VK_SUCCESS;
}
+VKAPI_ATTR VkResult VKAPI_CALL
+vk_common_AllocateCommandBuffers(VkDevice device,
+ const VkCommandBufferAllocateInfo *pAllocateInfo,
+ VkCommandBuffer *pCommandBuffers)
+{
+ VK_FROM_HANDLE(vk_command_pool, pool, pAllocateInfo->commandPool);
+ VkResult result;
+ uint32_t i;
+
+ assert(device == vk_device_to_handle(pool->base.device));
+
+ for (i = 0; i < pAllocateInfo->commandBufferCount; i++) {
+ struct vk_command_buffer *cmd_buffer;
+ result = pool->command_buffer_ops->create(pool, &cmd_buffer);
+ if (unlikely(result != VK_SUCCESS))
+ goto fail;
+
+ cmd_buffer->level = pAllocateInfo->level;
+
+ pCommandBuffers[i] = vk_command_buffer_to_handle(cmd_buffer);
+ }
+
+ return VK_SUCCESS;
+
+fail:
+ while (i--) {
+ VK_FROM_HANDLE(vk_command_buffer, cmd_buffer, pCommandBuffers[i]);
+ cmd_buffer->ops->destroy(cmd_buffer);
+ }
+ for (i = 0; i < pAllocateInfo->commandBufferCount; i++)
+ pCommandBuffers[i] = VK_NULL_HANDLE;
+
+ return result;
+}
+
VKAPI_ATTR void VKAPI_CALL
vk_common_FreeCommandBuffers(VkDevice device,
VkCommandPool commandPool,
/** Allocator passed to vkCreateCommandPool() */
VkAllocationCallbacks alloc;
+ /** Command buffer vtable for command buffers allocated from this pool */
+ const struct vk_command_buffer_ops *command_buffer_ops;
+
/** List of all command buffers */
struct list_head command_buffers;
};
extern "C" {
#endif
+struct vk_command_buffer_ops;
struct vk_sync;
enum vk_queue_submit_mode {
*/
const struct vk_device_dispatch_table *command_dispatch_table;
+ /** Command buffer vtable when using the common command pool */
+ const struct vk_command_buffer_ops *command_buffer_ops;
+
/* For VK_EXT_private_data */
uint32_t private_data_next_index;