venus: use common vk_command_buffer

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34083>
This commit is contained in:
Yiwei Zhang
2025-03-14 17:35:04 -07:00
committed by Marge Bot
parent 7a3c18fa8e
commit 0a324d37da
3 changed files with 37 additions and 7 deletions
+5 -5
View File
@@ -774,7 +774,7 @@ vn_DestroyCommandPool(VkDevice device,
&pool->command_buffers, head) {
vn_cmd_reset(cmd);
vn_cs_encoder_fini(&cmd->cs);
vn_object_base_fini(&cmd->base);
vn_command_buffer_base_fini(&cmd->base);
vk_free(alloc, cmd);
}
@@ -850,7 +850,7 @@ vn_AllocateCommandBuffers(VkDevice device,
cmd = vn_command_buffer_from_handle(pCommandBuffers[j]);
vn_cs_encoder_fini(&cmd->cs);
list_del(&cmd->head);
vn_object_base_fini(&cmd->base);
vn_command_buffer_base_fini(&cmd->base);
vk_free(alloc, cmd);
}
memset(pCommandBuffers, 0,
@@ -858,8 +858,8 @@ vn_AllocateCommandBuffers(VkDevice device,
return vn_error(dev->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
}
vn_object_base_init(&cmd->base, VK_OBJECT_TYPE_COMMAND_BUFFER,
&dev->base);
vn_command_buffer_base_init(&cmd->base, &pool->base, NULL,
pAllocateInfo->level);
cmd->pool = pool;
cmd->level = pAllocateInfo->level;
cmd->state = VN_COMMAND_BUFFER_STATE_INITIAL;
@@ -905,7 +905,7 @@ vn_FreeCommandBuffers(VkDevice device,
vn_cmd_reset(cmd);
vn_cs_encoder_fini(&cmd->cs);
vn_object_base_fini(&cmd->base);
vn_command_buffer_base_fini(&cmd->base);
vk_free(alloc, cmd);
}
}
+2 -2
View File
@@ -77,7 +77,7 @@ struct vn_command_buffer_builder {
struct vn_query_feedback_cmd;
struct vn_command_buffer {
struct vn_object_base base;
struct vn_command_buffer_base base;
struct vn_command_pool *pool;
VkCommandBufferLevel level;
@@ -91,7 +91,7 @@ struct vn_command_buffer {
struct list_head head;
};
VK_DEFINE_HANDLE_CASTS(vn_command_buffer,
base.vk,
base.vk.base,
VkCommandBuffer,
VK_OBJECT_TYPE_COMMAND_BUFFER)
+30
View File
@@ -39,6 +39,7 @@
#include "util/u_math.h"
#include "util/xmlconfig.h"
#include "vk_alloc.h"
#include "vk_command_buffer.h"
#include "vk_command_pool.h"
#include "vk_debug_report.h"
#include "vk_device.h"
@@ -166,6 +167,12 @@ struct vn_command_pool_base {
vn_object_id id;
};
/* base class of vn_command_buffer */
struct vn_command_buffer_base {
struct vk_command_buffer vk;
vn_object_id id;
};
/* base class of vn_device_memory */
struct vn_device_memory_base {
struct vk_device_memory vk;
@@ -511,6 +518,24 @@ vn_command_pool_base_fini(struct vn_command_pool_base *cmd_pool)
vk_command_pool_finish(&cmd_pool->vk);
}
static inline VkResult
vn_command_buffer_base_init(struct vn_command_buffer_base *cmd,
struct vn_command_pool_base *cmd_pool,
const struct vk_command_buffer_ops *ops,
VkCommandBufferLevel level)
{
VkResult result =
vk_command_buffer_init(&cmd_pool->vk, &cmd->vk, ops, level);
cmd->id = vn_get_next_obj_id();
return result;
}
static inline void
vn_command_buffer_base_fini(struct vn_command_buffer_base *cmd)
{
vk_command_buffer_finish(&cmd->vk);
}
static inline void
vn_object_base_init(struct vn_object_base *obj,
VkObjectType type,
@@ -546,6 +571,9 @@ vn_object_set_id(void *obj, vn_object_id id, VkObjectType type)
case VK_OBJECT_TYPE_COMMAND_POOL:
((struct vn_command_pool_base *)obj)->id = id;
break;
case VK_OBJECT_TYPE_COMMAND_BUFFER:
((struct vn_command_buffer_base *)obj)->id = id;
break;
case VK_OBJECT_TYPE_DEVICE_MEMORY:
((struct vn_device_memory_base *)obj)->id = id;
break;
@@ -573,6 +601,8 @@ vn_object_get_id(const void *obj, VkObjectType type)
return ((struct vn_queue_base *)obj)->id;
case VK_OBJECT_TYPE_COMMAND_POOL:
return ((struct vn_command_pool_base *)obj)->id;
case VK_OBJECT_TYPE_COMMAND_BUFFER:
return ((struct vn_command_buffer_base *)obj)->id;
case VK_OBJECT_TYPE_DEVICE_MEMORY:
return ((struct vn_device_memory_base *)obj)->id;
case VK_OBJECT_TYPE_IMAGE: