venus: use common vk_image as vn_image base
This change only switches the object base, and is to prepare for using vk_alloc_ahardware_buffer. Large refactor via leveraging existing common vk_image state tracking will be followed. Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25184>
This commit is contained in:
@@ -37,6 +37,7 @@
|
||||
#include "vk_alloc.h"
|
||||
#include "vk_debug_report.h"
|
||||
#include "vk_device.h"
|
||||
#include "vk_image.h"
|
||||
#include "vk_instance.h"
|
||||
#include "vk_object.h"
|
||||
#include "vk_physical_device.h"
|
||||
@@ -146,6 +147,12 @@ struct vn_queue_base {
|
||||
vn_object_id id;
|
||||
};
|
||||
|
||||
/* base class of vn_image */
|
||||
struct vn_image_base {
|
||||
struct vk_image base;
|
||||
vn_object_id id;
|
||||
};
|
||||
|
||||
/* base class of other driver objects */
|
||||
struct vn_object_base {
|
||||
struct vk_object_base base;
|
||||
@@ -364,6 +371,9 @@ vn_object_set_id(void *obj, vn_object_id id, VkObjectType type)
|
||||
case VK_OBJECT_TYPE_QUEUE:
|
||||
((struct vn_queue_base *)obj)->id = id;
|
||||
break;
|
||||
case VK_OBJECT_TYPE_IMAGE:
|
||||
((struct vn_image_base *)obj)->id = id;
|
||||
break;
|
||||
default:
|
||||
((struct vn_object_base *)obj)->id = id;
|
||||
break;
|
||||
@@ -383,6 +393,8 @@ vn_object_get_id(const void *obj, VkObjectType type)
|
||||
return ((struct vn_device_base *)obj)->id;
|
||||
case VK_OBJECT_TYPE_QUEUE:
|
||||
return ((struct vn_queue_base *)obj)->id;
|
||||
case VK_OBJECT_TYPE_IMAGE:
|
||||
return ((struct vn_image_base *)obj)->id;
|
||||
default:
|
||||
return ((struct vn_object_base *)obj)->id;
|
||||
}
|
||||
|
@@ -226,20 +226,16 @@ vn_image_create(struct vn_device *dev,
|
||||
const VkAllocationCallbacks *alloc,
|
||||
struct vn_image **out_img)
|
||||
{
|
||||
struct vn_image *img = NULL;
|
||||
VkResult result = VK_SUCCESS;
|
||||
|
||||
img = vk_zalloc(alloc, sizeof(*img), VN_DEFAULT_ALIGN,
|
||||
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
|
||||
struct vn_image *img =
|
||||
vk_image_create(&dev->base.base, create_info, alloc, sizeof(*img));
|
||||
if (!img)
|
||||
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||
|
||||
vn_object_base_init(&img->base, VK_OBJECT_TYPE_IMAGE, &dev->base);
|
||||
vn_object_set_id(img, (uintptr_t)img, VK_OBJECT_TYPE_IMAGE);
|
||||
|
||||
result = vn_image_init(dev, create_info, img);
|
||||
VkResult result = vn_image_init(dev, create_info, img);
|
||||
if (result != VK_SUCCESS) {
|
||||
vn_object_base_fini(&img->base);
|
||||
vk_free(alloc, img);
|
||||
vk_image_destroy(&dev->base.base, alloc, &img->base.base);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -264,20 +260,16 @@ vn_image_create_deferred(struct vn_device *dev,
|
||||
const VkAllocationCallbacks *alloc,
|
||||
struct vn_image **out_img)
|
||||
{
|
||||
struct vn_image *img = NULL;
|
||||
VkResult result = VK_SUCCESS;
|
||||
|
||||
img = vk_zalloc(alloc, sizeof(*img), VN_DEFAULT_ALIGN,
|
||||
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
|
||||
struct vn_image *img =
|
||||
vk_image_create(&dev->base.base, create_info, alloc, sizeof(*img));
|
||||
if (!img)
|
||||
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||
|
||||
vn_object_base_init(&img->base, VK_OBJECT_TYPE_IMAGE, &dev->base);
|
||||
vn_object_set_id(img, (uintptr_t)img, VK_OBJECT_TYPE_IMAGE);
|
||||
|
||||
result = vn_image_deferred_info_init(img, create_info, alloc);
|
||||
VkResult result = vn_image_deferred_info_init(img, create_info, alloc);
|
||||
if (result != VK_SUCCESS) {
|
||||
vn_object_base_fini(&img->base);
|
||||
vk_free(alloc, img);
|
||||
vk_image_destroy(&dev->base.base, alloc, &img->base.base);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -459,8 +451,7 @@ vn_DestroyImage(VkDevice device,
|
||||
|
||||
vn_image_deferred_info_fini(img, alloc);
|
||||
|
||||
vn_object_base_fini(&img->base);
|
||||
vk_free(alloc, img);
|
||||
vk_image_destroy(&dev->base.base, alloc, &img->base.base);
|
||||
}
|
||||
|
||||
void
|
||||
|
@@ -37,7 +37,7 @@ struct vn_image_create_deferred_info {
|
||||
};
|
||||
|
||||
struct vn_image {
|
||||
struct vn_object_base base;
|
||||
struct vn_image_base base;
|
||||
|
||||
VkSharingMode sharing_mode;
|
||||
|
||||
@@ -67,7 +67,7 @@ struct vn_image {
|
||||
} wsi;
|
||||
};
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(vn_image,
|
||||
base.base,
|
||||
base.base.base,
|
||||
VkImage,
|
||||
VK_OBJECT_TYPE_IMAGE)
|
||||
|
||||
|
Reference in New Issue
Block a user