From dba28da07532072fbaa6ef51133234f10e0cac74 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Mon, 14 Dec 2015 14:09:35 -0800 Subject: [PATCH] anv/buffer_view: Store a bo + offset instead of buffer pointer This is what image_view does. Also, we really need to do this so that we can properly handle the combined offsets from the buffer and from pCreateInfo. This fixes some of the nonzero offset buffer view CTS tests. --- src/vulkan/anv_cmd_buffer.c | 4 ++-- src/vulkan/anv_image.c | 6 ++++-- src/vulkan/anv_private.h | 4 +++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/vulkan/anv_cmd_buffer.c b/src/vulkan/anv_cmd_buffer.c index 0531cd80f4f..fa6943689d8 100644 --- a/src/vulkan/anv_cmd_buffer.c +++ b/src/vulkan/anv_cmd_buffer.c @@ -731,8 +731,8 @@ 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; + bo = desc->buffer_view->bo; + bo_offset = desc->buffer_view->offset; break; case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER: diff --git a/src/vulkan/anv_image.c b/src/vulkan/anv_image.c index 3b3751ad1e1..dcad2affb2c 100644 --- a/src/vulkan/anv_image.c +++ b/src/vulkan/anv_image.c @@ -512,7 +512,9 @@ anv_CreateBufferView(VkDevice _device, if (!view) return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); - view->buffer = buffer; + view->bo = buffer->bo; + view->offset = buffer->offset + pCreateInfo->offset; + view->surface_state = anv_state_pool_alloc(&device->surface_state_pool, 64, 64); @@ -520,7 +522,7 @@ anv_CreateBufferView(VkDevice _device, anv_format_for_vk_format(pCreateInfo->format); anv_fill_buffer_surface_state(device, view->surface_state.map, format, - pCreateInfo->offset, pCreateInfo->range, + view->offset, pCreateInfo->range, format->isl_layout->bpb / 8); *pView = anv_buffer_view_to_handle(view); diff --git a/src/vulkan/anv_private.h b/src/vulkan/anv_private.h index 07854d3e357..d2b65711fc4 100644 --- a/src/vulkan/anv_private.h +++ b/src/vulkan/anv_private.h @@ -1517,7 +1517,9 @@ gen9_image_view_init(struct anv_image_view *iview, struct anv_cmd_buffer *cmd_buffer); struct anv_buffer_view { - struct anv_buffer *buffer; + struct anv_bo *bo; + uint32_t offset; /**< Offset into bo. */ + struct anv_state surface_state; }; -- 2.30.2