nvk: Add a stub implementation of buffer views

We don't actually populate the TIC entries yet but we can at least
pretend and stick them in descriptor sets.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
This commit is contained in:
Faith Ekstrand
2023-01-30 20:11:49 -06:00
committed by Marge Bot
parent 8d3f185a4d
commit c9bf974472
5 changed files with 64 additions and 5 deletions
+2
View File
@@ -4,6 +4,8 @@ nvk_files = files(
'nvk_bo_sync.h',
'nvk_buffer.c',
'nvk_buffer.h',
'nvk_buffer_view.c',
'nvk_buffer_view.h',
'nvk_cmd_blit.c',
'nvk_cmd_buffer.c',
'nvk_cmd_buffer.h',
+36
View File
@@ -0,0 +1,36 @@
#include "nvk_buffer_view.h"
#include "nvk_device.h"
VKAPI_ATTR VkResult VKAPI_CALL
nvk_CreateBufferView(VkDevice _device,
const VkBufferViewCreateInfo *pCreateInfo,
const VkAllocationCallbacks *pAllocator,
VkBufferView *pBufferView)
{
VK_FROM_HANDLE(nvk_device, device, _device);
struct nvk_buffer_view *view;
view = vk_buffer_view_create(&device->vk, pCreateInfo,
pAllocator, sizeof(*view));
if (!view)
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
*pBufferView = nvk_buffer_view_to_handle(view);
return VK_SUCCESS;
}
VKAPI_ATTR void VKAPI_CALL
nvk_DestroyBufferView(VkDevice _device,
VkBufferView bufferView,
const VkAllocationCallbacks *pAllocator)
{
VK_FROM_HANDLE(nvk_device, device, _device);
VK_FROM_HANDLE(nvk_buffer_view, view, bufferView);
if (!view)
return;
vk_buffer_view_destroy(&device->vk, pAllocator, &view->vk);
}
+18
View File
@@ -0,0 +1,18 @@
#ifndef NVK_BUFFER_VIEW_H
#define NVK_BUFFER_VIEW_H 1
#include "nvk_private.h"
#include "vulkan/runtime/vk_buffer_view.h"
struct nvk_buffer_view {
struct vk_buffer_view vk;
/** Index in the image descriptor table */
uint32_t desc_index;
};
VK_DEFINE_HANDLE_CASTS(nvk_buffer_view, vk.base, VkBufferView,
VK_OBJECT_TYPE_BUFFER_VIEW)
#endif
+6 -1
View File
@@ -1,6 +1,7 @@
#include "nvk_descriptor_set.h"
#include "nvk_buffer.h"
#include "nvk_buffer_view.h"
#include "nvk_descriptor_set_layout.h"
#include "nvk_device.h"
#include "nvk_image_view.h"
@@ -75,7 +76,11 @@ write_buffer_view_desc(struct nvk_descriptor_set *set,
const VkBufferView bufferView,
uint32_t binding, uint32_t elem)
{
/* TODO */
VK_FROM_HANDLE(nvk_buffer_view, view, bufferView);
struct nvk_image_descriptor *desc = desc_ubo_data(set, binding, elem);
assert(view->desc_index < (1 << 20));
desc->image_index = view->desc_index;
}
static void
@@ -31,12 +31,10 @@ nvk_descriptor_stride_align_for_type(VkDescriptorType type,
case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
*stride = *align = sizeof(struct nvk_image_descriptor);
break;
case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
unreachable("TODO: Implement texel buffers");
*stride = *align = sizeof(struct nvk_image_descriptor);
break;
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER: