diff options
author | Jason Ekstrand <[email protected]> | 2015-12-14 16:51:12 -0800 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2015-12-14 16:51:12 -0800 |
commit | 783a21192c7cc35113ec089354369e1ad34a7df9 (patch) | |
tree | 33527f0a57bb175119f82970d90301735be49f2e /src/vulkan/anv_image.c | |
parent | 1f98bf8da028c4d0e2b47cc1a59e6f004e2207a1 (diff) |
anv: Add support for storage texel buffers
Diffstat (limited to 'src/vulkan/anv_image.c')
-rw-r--r-- | src/vulkan/anv_image.c | 64 |
1 files changed, 53 insertions, 11 deletions
diff --git a/src/vulkan/anv_image.c b/src/vulkan/anv_image.c index 659fe80b320..159af6d19b0 100644 --- a/src/vulkan/anv_image.c +++ b/src/vulkan/anv_image.c @@ -505,26 +505,45 @@ anv_CreateBufferView(VkDevice _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); + const struct anv_format *format = + anv_format_for_vk_format(pCreateInfo->format); + + view->format = format->surface_format; view->bo = buffer->bo; view->offset = buffer->offset + pCreateInfo->offset; + view->range = pCreateInfo->range; - view->surface_state = - anv_state_pool_alloc(&device->surface_state_pool, 64, 64); + if (buffer->usage & VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT) { + 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, + view->format, + view->offset, pCreateInfo->range, + format->isl_layout->bpb / 8); + } else { + view->surface_state = (struct anv_state){ 0 }; + } + + if (buffer->usage & VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT) { + view->storage_surface_state = + anv_state_pool_alloc(&device->surface_state_pool, 64, 64); - anv_fill_buffer_surface_state(device, view->surface_state.map, - format->surface_format, - view->offset, pCreateInfo->range, - format->isl_layout->bpb / 8); + enum isl_format storage_format = + isl_lower_storage_image_format(&device->isl_dev, view->format); + + anv_fill_buffer_surface_state(device, view->storage_surface_state.map, + storage_format, + view->offset, pCreateInfo->range, + format->isl_layout->bpb / 8); + } else { + view->storage_surface_state = (struct anv_state){ 0 }; + } *pView = anv_buffer_view_to_handle(view); @@ -538,7 +557,14 @@ anv_DestroyBufferView(VkDevice _device, VkBufferView bufferView, 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); + if (view->surface_state.alloc_size > 0) + anv_state_pool_free(&device->surface_state_pool, + view->surface_state); + + if (view->storage_surface_state.alloc_size > 0) + anv_state_pool_free(&device->surface_state_pool, + view->storage_surface_state); + anv_free2(&device->alloc, pAllocator, view); } @@ -599,3 +625,19 @@ anv_image_view_fill_image_param(struct anv_device *device, memset(param, 0, sizeof *param); anv_finishme("Actually fill out brw_image_param"); } + +void +anv_buffer_view_fill_image_param(struct anv_device *device, + struct anv_buffer_view *view, + struct brw_image_param *param) +{ + /* Set the swizzling shifts to all-ones to effectively disable swizzling -- + * See emit_address_calculation() in brw_fs_surface_builder.cpp for a more + * detailed explanation of these parameters. + */ + param->swizzling[0] = 0xff; + param->swizzling[1] = 0xff; + + param->stride[0] = isl_format_layouts[view->format].bpb / 8; + param->size[0] = view->range / param->stride[0]; +} |