diff options
author | Jason Ekstrand <[email protected]> | 2015-12-12 16:11:23 -0800 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2015-12-12 16:11:23 -0800 |
commit | c56186026fce7a28db2fe7cabf58a11328877123 (patch) | |
tree | 126126ebfb54e697a4fa0d16dd26598a2fdfd9a1 /src/vulkan/anv_image.c | |
parent | fd944197f27ff428f2599eb03bc0c4085c9fbc6a (diff) |
anv: Add initial support for texel buffers
Diffstat (limited to 'src/vulkan/anv_image.c')
-rw-r--r-- | src/vulkan/anv_image.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/vulkan/anv_image.c b/src/vulkan/anv_image.c index dc52e6b368c..ffc7ae8cae6 100644 --- a/src/vulkan/anv_image.c +++ b/src/vulkan/anv_image.c @@ -506,6 +506,50 @@ anv_DestroyImageView(VkDevice _device, VkImageView _iview, anv_free2(&device->alloc, pAllocator, iview); } +VkResult +anv_CreateBufferView(VkDevice _device, + const VkBufferViewCreateInfo *pCreateInfo, + const VkAllocationCallbacks *pAllocator, + VkBufferView *pView) +{ + ANV_FROM_HANDLE(anv_device, device, _device); + ANV_FROM_HANDLE(anv_buffer, buffer, pCreateInfo->buffer); + struct anv_buffer_view *view; + + /* TODO: Storage texel buffers */ + + view = anv_alloc2(&device->alloc, pAllocator, sizeof(*view), 8, + VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); + if (!view) + return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); + + view->buffer = buffer; + view->surface_state = + anv_state_pool_alloc(&device->surface_state_pool, 64, 64); + + const struct anv_format *format = + anv_format_for_vk_format(pCreateInfo->format); + + anv_fill_buffer_surface_state(device, view->surface_state.map, format, + pCreateInfo->offset, pCreateInfo->range, + format->isl_layout->bpb / 8); + + *pView = anv_buffer_view_to_handle(view); + + return VK_SUCCESS; +} + +void +anv_DestroyBufferView(VkDevice _device, VkBufferView bufferView, + const VkAllocationCallbacks *pAllocator) +{ + ANV_FROM_HANDLE(anv_device, device, _device); + ANV_FROM_HANDLE(anv_buffer_view, view, bufferView); + + anv_state_pool_free(&device->surface_state_pool, view->surface_state); + anv_free2(&device->alloc, pAllocator, view); +} + struct anv_surface * anv_image_get_surface_for_aspect_mask(struct anv_image *image, VkImageAspectFlags aspect_mask) { |