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 | |
parent | fd944197f27ff428f2599eb03bc0c4085c9fbc6a (diff) |
anv: Add initial support for texel buffers
-rw-r--r-- | src/vulkan/anv_cmd_buffer.c | 5 | ||||
-rw-r--r-- | src/vulkan/anv_descriptor_set.c | 10 | ||||
-rw-r--r-- | src/vulkan/anv_device.c | 17 | ||||
-rw-r--r-- | src/vulkan/anv_image.c | 44 | ||||
-rw-r--r-- | src/vulkan/anv_private.h | 8 |
5 files changed, 66 insertions, 18 deletions
diff --git a/src/vulkan/anv_cmd_buffer.c b/src/vulkan/anv_cmd_buffer.c index 8ade08ea746..0531cd80f4f 100644 --- a/src/vulkan/anv_cmd_buffer.c +++ b/src/vulkan/anv_cmd_buffer.c @@ -730,6 +730,11 @@ anv_cmd_buffer_emit_binding_table(struct anv_cmd_buffer *cmd_buffer, } case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER: + surface_state = desc->buffer_view->surface_state; + bo = desc->buffer_view->buffer->bo; + bo_offset = desc->buffer_view->buffer->offset; + break; + case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER: assert(!"Unsupported descriptor type"); break; diff --git a/src/vulkan/anv_descriptor_set.c b/src/vulkan/anv_descriptor_set.c index 9c4210025e3..52d2ffecdd6 100644 --- a/src/vulkan/anv_descriptor_set.c +++ b/src/vulkan/anv_descriptor_set.c @@ -483,7 +483,15 @@ void anv_UpdateDescriptorSets( case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER: case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER: - anv_finishme("texel buffers not implemented"); + for (uint32_t j = 0; j < write->descriptorCount; j++) { + ANV_FROM_HANDLE(anv_buffer_view, bview, + write->pTexelBufferView[j]); + + desc[j] = (struct anv_descriptor) { + .type = write->descriptorType, + .buffer_view = bview, + }; + } break; case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT: diff --git a/src/vulkan/anv_device.c b/src/vulkan/anv_device.c index 7556d8353d5..7ddad58cf6f 100644 --- a/src/vulkan/anv_device.c +++ b/src/vulkan/anv_device.c @@ -1514,23 +1514,6 @@ anv_fill_buffer_surface_state(struct anv_device *device, void *state, } } -VkResult anv_CreateBufferView( - VkDevice _device, - const VkBufferViewCreateInfo* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkBufferView* pView) -{ - stub_return(VK_ERROR_INCOMPATIBLE_DRIVER); -} - -void anv_DestroyBufferView( - VkDevice _device, - VkBufferView _bview, - const VkAllocationCallbacks* pAllocator) -{ - stub(); -} - void anv_DestroySampler( VkDevice _device, VkSampler _sampler, 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) { diff --git a/src/vulkan/anv_private.h b/src/vulkan/anv_private.h index a180b9c69c3..3b5a4be8355 100644 --- a/src/vulkan/anv_private.h +++ b/src/vulkan/anv_private.h @@ -851,6 +851,8 @@ struct anv_descriptor { struct anv_sampler *sampler; }; + struct anv_buffer_view *buffer_view; + struct { struct anv_buffer *buffer; uint64_t offset; @@ -1516,6 +1518,11 @@ gen9_image_view_init(struct anv_image_view *iview, const VkImageViewCreateInfo* pCreateInfo, struct anv_cmd_buffer *cmd_buffer); +struct anv_buffer_view { + struct anv_buffer *buffer; + struct anv_state surface_state; +}; + void anv_fill_buffer_surface_state(struct anv_device *device, void *state, const struct anv_format *format, uint32_t offset, uint32_t range, @@ -1636,6 +1643,7 @@ ANV_DEFINE_HANDLE_CASTS(anv_queue, VkQueue) ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_cmd_pool, VkCommandPool) ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_buffer, VkBuffer) +ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_buffer_view, VkBufferView) ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_descriptor_set, VkDescriptorSet) ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_descriptor_set_layout, VkDescriptorSetLayout) ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_device_memory, VkDeviceMemory) |