anv/buffer_view: Store a bo + offset instead of buffer pointer
authorJason Ekstrand <jason.ekstrand@intel.com>
Mon, 14 Dec 2015 22:09:35 +0000 (14:09 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Mon, 14 Dec 2015 22:10:40 +0000 (14:10 -0800)
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
src/vulkan/anv_image.c
src/vulkan/anv_private.h

index 0531cd80f4f923a145f41da027f02a79b4b29302..fa6943689d8d60390c6143db016199ef593a4d56 100644 (file)
@@ -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:
index 3b3751ad1e188da37c427067169fa4f3a76c45fc..dcad2affb2c497cd10dfab9680c05c5eed2ea9bf 100644 (file)
@@ -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);
index 07854d3e3579dddc64870171bd40925d9209e8c2..d2b65711fc4092eb6f2e460299fa59d386cc2460 100644 (file)
@@ -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;
 };