v3dv: implement vk{Create,Destroy}BufferView

For now this is not particularly useful, since we can't bind this to
a texel buffer descriptor yet.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
This commit is contained in:
Iago Toral Quiroga
2020-02-26 09:07:42 +01:00
committed by Marge Bot
parent 43c1fa492a
commit aba2a66fb8
2 changed files with 67 additions and 0 deletions
+53
View File
@@ -494,3 +494,56 @@ v3dv_DestroyImageView(VkDevice _device,
vk_free2(&device->alloc, pAllocator, image_view);
}
VkResult
v3dv_CreateBufferView(VkDevice _device,
const VkBufferViewCreateInfo *pCreateInfo,
const VkAllocationCallbacks *pAllocator,
VkBufferView *pView)
{
V3DV_FROM_HANDLE(v3dv_device, device, _device);
const struct v3dv_buffer *buffer =
v3dv_buffer_from_handle(pCreateInfo->buffer);
struct v3dv_buffer_view *view =
vk_alloc2(&device->alloc, pAllocator, sizeof(*view), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (!view)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
uint32_t range;
if (pCreateInfo->range == VK_WHOLE_SIZE)
range = buffer->size - pCreateInfo->offset;
else
range = pCreateInfo->range;
enum pipe_format pipe_format = vk_format_to_pipe_format(pCreateInfo->format);
uint32_t num_elements = range / util_format_get_blocksize(pipe_format);
view->buffer = buffer;
view->offset = pCreateInfo->offset;
view->size = view->offset + range;
view->num_elements = num_elements;
view->vk_format = pCreateInfo->format;
view->format = v3dv_get_format(view->vk_format);
v3dv_get_internal_type_bpp_for_output_format(view->format->rt_type,
&view->internal_type,
&view->internal_bpp);
*pView = v3dv_buffer_view_to_handle(view);
return VK_SUCCESS;
}
void
v3dv_DestroyBufferView(VkDevice _device,
VkBufferView bufferView,
const VkAllocationCallbacks *pAllocator)
{
V3DV_FROM_HANDLE(v3dv_device, device, _device);
V3DV_FROM_HANDLE(v3dv_buffer_view, buffer_view, bufferView);
vk_free2(&device->alloc, pAllocator, buffer_view);
}
+14
View File
@@ -349,6 +349,19 @@ struct v3dv_buffer {
VkDeviceSize mem_offset;
};
struct v3dv_buffer_view {
const struct v3dv_buffer *buffer;
VkFormat vk_format;
const struct v3dv_format *format;
uint32_t internal_bpp;
uint32_t internal_type;
uint32_t offset;
uint32_t size;
uint32_t num_elements;
};
struct v3dv_subpass_attachment {
uint32_t attachment;
VkImageLayout layout;
@@ -1001,6 +1014,7 @@ V3DV_DEFINE_HANDLE_CASTS(v3dv_queue, VkQueue)
V3DV_DEFINE_NONDISP_HANDLE_CASTS(v3dv_cmd_pool, VkCommandPool)
V3DV_DEFINE_NONDISP_HANDLE_CASTS(v3dv_buffer, VkBuffer)
V3DV_DEFINE_NONDISP_HANDLE_CASTS(v3dv_buffer_view, VkBufferView)
V3DV_DEFINE_NONDISP_HANDLE_CASTS(v3dv_device_memory, VkDeviceMemory)
V3DV_DEFINE_NONDISP_HANDLE_CASTS(v3dv_descriptor_pool, VkDescriptorPool)
V3DV_DEFINE_NONDISP_HANDLE_CASTS(v3dv_descriptor_set, VkDescriptorSet)