nvk: Add stub implementations of VkImage and VkImageView

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
This commit is contained in:
Faith Ekstrand
2023-01-30 20:11:46 -06:00
committed by Marge Bot
parent c5775c7ed6
commit 32b7d178fd
5 changed files with 131 additions and 0 deletions

View File

@@ -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',

View File

@@ -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);
}

View File

@@ -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

View File

@@ -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);
}

View File

@@ -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