From: Faith Ekstrand Date: Tue, 31 Jan 2023 02:11:46 +0000 (-0600) Subject: nvk: Add stub implementations of VkImage and VkImageView X-Git-Tag: upstream/23.3.3~4625 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=32b7d178fda5e6e3e4bf14e74b0163103d056d88;p=platform%2Fupstream%2Fmesa.git nvk: Add stub implementations of VkImage and VkImageView Part-of: --- diff --git a/src/nouveau/vulkan/meson.build b/src/nouveau/vulkan/meson.build index 63e0e33..edbd971 100644 --- a/src/nouveau/vulkan/meson.build +++ b/src/nouveau/vulkan/meson.build @@ -1,6 +1,10 @@ nvk_files = files( 'nvk_device.c', 'nvk_device.h', + 'nvk_image.c', + 'nvk_image.h', + 'nvk_image_view.c', + 'nvk_image_view.h', 'nvk_instance.c', 'nvk_instance.h', 'nvk_physical_device.c', diff --git a/src/nouveau/vulkan/nvk_image.c b/src/nouveau/vulkan/nvk_image.c new file mode 100644 index 0000000..b1aaf2a --- /dev/null +++ b/src/nouveau/vulkan/nvk_image.c @@ -0,0 +1,55 @@ +#include "nvk_image.h" + +#include "nvk_device.h" + +static VkResult nvk_image_init(struct nvk_device *device, + struct nvk_image *image, + const VkImageCreateInfo *pCreateInfo) +{ + vk_image_init(&device->vk, &image->vk, pCreateInfo); + return VK_SUCCESS; +} + +static void nvk_image_finish(struct nvk_image *image) +{ + vk_image_finish(&image->vk); +} + +VKAPI_ATTR VkResult VKAPI_CALL nvk_CreateImage(VkDevice _device, + const VkImageCreateInfo *pCreateInfo, + const VkAllocationCallbacks *pAllocator, + VkImage *pImage) +{ + VK_FROM_HANDLE(nvk_device, device, _device); + struct nvk_image *image; + VkResult result; + + image = vk_zalloc2( + &device->vk.alloc, pAllocator, sizeof(*image), 8, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); + if (!image) + return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY); + + result = nvk_image_init(device, image, pCreateInfo); + if (result != VK_SUCCESS) { + vk_free2(&device->vk.alloc, pAllocator, image); + return result; + } + + *pImage = nvk_image_to_handle(image); + + return VK_SUCCESS; +} + +VKAPI_ATTR void VKAPI_CALL nvk_DestroyImage(VkDevice _device, + VkImage _image, + const VkAllocationCallbacks *pAllocator) +{ + VK_FROM_HANDLE(nvk_device, device, _device); + VK_FROM_HANDLE(nvk_image, image, _image); + + if (!image) + return; + + nvk_image_finish(image); + vk_free2(&device->vk.alloc, pAllocator, image); +} diff --git a/src/nouveau/vulkan/nvk_image.h b/src/nouveau/vulkan/nvk_image.h new file mode 100644 index 0000000..8139b2c --- /dev/null +++ b/src/nouveau/vulkan/nvk_image.h @@ -0,0 +1,14 @@ +#ifndef NVK_IMAGE +#define NVK_IMAGE 1 + +#include "nvk_private.h" + +#include "vulkan/runtime/vk_image.h" + +struct nvk_image { + struct vk_image vk; +}; + +VK_DEFINE_HANDLE_CASTS(nvk_image, vk.base, VkImage, VK_OBJECT_TYPE_IMAGE) + +#endif diff --git a/src/nouveau/vulkan/nvk_image_view.c b/src/nouveau/vulkan/nvk_image_view.c new file mode 100644 index 0000000..0399a7c --- /dev/null +++ b/src/nouveau/vulkan/nvk_image_view.c @@ -0,0 +1,41 @@ +#include "nvk_image_view.h" + +#include "nvk_device.h" +#include "nvk_image.h" + +static VkResult nvk_image_view_init(struct nvk_device *device, + struct nvk_image_view *view, + const VkImageViewCreateInfo *pCreateInfo) +{ + return VK_SUCCESS; +} + +VKAPI_ATTR VkResult VKAPI_CALL nvk_CreateImageView(VkDevice _device, + const VkImageViewCreateInfo *pCreateInfo, + const VkAllocationCallbacks *pAllocator, + VkImageView *pView) +{ + VK_FROM_HANDLE(nvk_device, device, _device); + struct nvk_image_view *view; + + view = vk_image_view_create(&device->vk, false, pCreateInfo, pAllocator, sizeof(*view)); + if (view == NULL) + return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY); + + *pView = nvk_image_view_to_handle(view); + + return VK_SUCCESS; +} + +VKAPI_ATTR void VKAPI_CALL vkDestroyImageView(VkDevice _device, + VkImageView imageView, + const VkAllocationCallbacks *pAllocator) +{ + VK_FROM_HANDLE(nvk_device, device, _device); + VK_FROM_HANDLE(nvk_image_view, view, imageView); + + if (!view) + return; + + vk_image_view_destroy(&device->vk, pAllocator, &view->vk); +} diff --git a/src/nouveau/vulkan/nvk_image_view.h b/src/nouveau/vulkan/nvk_image_view.h new file mode 100644 index 0000000..0b90812 --- /dev/null +++ b/src/nouveau/vulkan/nvk_image_view.h @@ -0,0 +1,17 @@ +#ifndef NVK_IMAGE_VIEW +#define NVK_IMAGE_VIEW 1 + +#include "nvk_private.h" + +#include "vulkan/runtime/vk_image.h" + +struct nvk_image_view { + struct vk_image_view vk; + + /** Index in the image descriptor table */ + uint32_t desc_idx; +}; + +VK_DEFINE_HANDLE_CASTS(nvk_image_view, vk.base, VkImageView, VK_OBJECT_TYPE_IMAGE_VIEW) + +#endif