command_buffer->state = MESA_VK_COMMAND_BUFFER_STATE_INITIAL;
command_buffer->record_result = VK_SUCCESS;
vk_cmd_queue_init(&command_buffer->cmd_queue, &pool->alloc);
+ vk_meta_object_list_init(&command_buffer->meta_objects);
util_dynarray_init(&command_buffer->labels, NULL);
command_buffer->region_begin = true;
command_buffer->record_result = VK_SUCCESS;
vk_command_buffer_reset_render_pass(command_buffer);
vk_cmd_queue_reset(&command_buffer->cmd_queue);
+ vk_meta_object_list_reset(command_buffer->base.device,
+ &command_buffer->meta_objects);
util_dynarray_clear(&command_buffer->labels);
command_buffer->region_begin = true;
}
vk_command_buffer_reset_render_pass(command_buffer);
vk_cmd_queue_finish(&command_buffer->cmd_queue);
util_dynarray_fini(&command_buffer->labels);
+ vk_meta_object_list_finish(command_buffer->base.device,
+ &command_buffer->meta_objects);
vk_object_base_finish(&command_buffer->base);
}
#include "vk_cmd_queue.h"
#include "vk_graphics_state.h"
#include "vk_log.h"
+#include "vk_meta.h"
#include "vk_object.h"
#include "util/list.h"
#include "util/u_dynarray.h"
/** Command list for emulated secondary command buffers */
struct vk_cmd_queue cmd_queue;
+ /** Object list for meta objects */
+ struct vk_meta_object_list meta_objects;
+
/**
* VK_EXT_debug_utils
*
#include "vk_meta.h"
+#include "vk_command_buffer.h"
#include "vk_device.h"
#include "vk_util.h"
(uint64_t)pipeline);
return VK_SUCCESS;
}
+
+void
+vk_meta_object_list_init(struct vk_meta_object_list *mol)
+{
+ util_dynarray_init(&mol->arr, NULL);
+}
+
+void
+vk_meta_object_list_reset(struct vk_device *device,
+ struct vk_meta_object_list *mol)
+{
+ util_dynarray_foreach(&mol->arr, struct vk_object_base *, obj)
+ destroy_object(device, *obj);
+
+ util_dynarray_clear(&mol->arr);
+}
+
+void
+vk_meta_object_list_finish(struct vk_device *device,
+ struct vk_meta_object_list *mol)
+{
+ vk_meta_object_list_reset(device, mol);
+ util_dynarray_fini(&mol->arr);
+}
+
+VkResult
+vk_meta_create_buffer(struct vk_command_buffer *cmd,
+ struct vk_meta_device *meta,
+ const VkBufferCreateInfo *info,
+ VkBuffer *buffer_out)
+{
+ struct vk_device *device = cmd->base.device;
+ const struct vk_device_dispatch_table *disp = &device->dispatch_table;
+ VkDevice _device = vk_device_to_handle(device);
+
+ VkResult result = disp->CreateBuffer(_device, info, NULL, buffer_out);
+ if (unlikely(result != VK_SUCCESS))
+ return result;
+
+ vk_meta_object_list_add_handle(&cmd->meta_objects,
+ VK_OBJECT_TYPE_BUFFER,
+ (uint64_t)*buffer_out);
+ return VK_SUCCESS;
+}
+
+VkResult
+vk_meta_create_image_view(struct vk_command_buffer *cmd,
+ struct vk_meta_device *meta,
+ const VkImageViewCreateInfo *info,
+ VkImageView *image_view_out)
+{
+ struct vk_device *device = cmd->base.device;
+ const struct vk_device_dispatch_table *disp = &device->dispatch_table;
+ VkDevice _device = vk_device_to_handle(device);
+
+ VkResult result = disp->CreateImageView(_device, info, NULL, image_view_out);
+ if (unlikely(result != VK_SUCCESS))
+ return result;
+
+ vk_meta_object_list_add_handle(&cmd->meta_objects,
+ VK_OBJECT_TYPE_IMAGE_VIEW,
+ (uint64_t)*image_view_out);
+ return VK_SUCCESS;
+}
#ifndef VK_META_H
#define VK_META_H
-#include <vulkan/vulkan_core.h>
-
#include "vk_limits.h"
+#include "vk_object.h"
#include "util/simple_mtx.h"
+#include "util/u_dynarray.h"
#ifdef __cplusplus
extern "C" {
const void *key_data, size_t key_size,
VkPipeline *pipeline_out);
+struct vk_meta_object_list {
+ struct util_dynarray arr;
+};
+
+void vk_meta_object_list_init(struct vk_meta_object_list *mol);
+void vk_meta_object_list_reset(struct vk_device *device,
+ struct vk_meta_object_list *mol);
+void vk_meta_object_list_finish(struct vk_device *device,
+ struct vk_meta_object_list *mol);
+
+static inline void
+vk_meta_object_list_add_obj(struct vk_meta_object_list *mol,
+ struct vk_object_base *obj)
+{
+ util_dynarray_append(&mol->arr, struct vk_object_base *, obj);
+}
+
+static inline void
+vk_meta_object_list_add_handle(struct vk_meta_object_list *mol,
+ VkObjectType obj_type,
+ uint64_t handle)
+{
+ vk_meta_object_list_add_obj(mol,
+ vk_object_base_from_u64_handle(handle, obj_type));
+}
+
+VkResult vk_meta_create_buffer(struct vk_command_buffer *cmd,
+ struct vk_meta_device *meta,
+ const VkBufferCreateInfo *info,
+ VkBuffer *buffer_out);
+VkResult vk_meta_create_image_view(struct vk_command_buffer *cmd,
+ struct vk_meta_device *meta,
+ const VkImageViewCreateInfo *info,
+ VkImageView *image_view_out);
+
#ifdef __cplusplus
}
#endif