anv: Use an address for each anv_image plane
authorJason Ekstrand <jason.ekstrand@intel.com>
Thu, 31 May 2018 01:55:00 +0000 (18:55 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Thu, 31 May 2018 23:51:46 +0000 (16:51 -0700)
This is better than having BO and offset fields.

Reviewed-by: Scott D Phillips <scott.d.phillips@intel.com>
src/intel/vulkan/anv_blorp.c
src/intel/vulkan/anv_image.c
src/intel/vulkan/anv_intel.c
src/intel/vulkan/anv_private.h
src/intel/vulkan/genX_cmd_buffer.c

index 359ebfb3ca1193582069bcde050d80d69569be7a..5373faaa680dfa22321cd7069c942b9a692a2822 100644 (file)
@@ -207,8 +207,8 @@ get_blorp_surf_for_anv_image(const struct anv_device *device,
    *blorp_surf = (struct blorp_surf) {
       .surf = &surface->isl,
       .addr = {
-         .buffer = image->planes[plane].bo,
-         .offset = image->planes[plane].bo_offset + surface->offset,
+         .buffer = image->planes[plane].address.bo,
+         .offset = image->planes[plane].address.offset + surface->offset,
          .mocs = device->default_mocs,
       },
    };
@@ -217,8 +217,8 @@ get_blorp_surf_for_anv_image(const struct anv_device *device,
       const struct anv_surface *aux_surface = &image->planes[plane].aux_surface;
       blorp_surf->aux_surf = &aux_surface->isl,
       blorp_surf->aux_addr = (struct blorp_address) {
-         .buffer = image->planes[plane].bo,
-         .offset = image->planes[plane].bo_offset + aux_surface->offset,
+         .buffer = image->planes[plane].address.bo,
+         .offset = image->planes[plane].address.offset + aux_surface->offset,
          .mocs = device->default_mocs,
       };
       blorp_surf->aux_usage = aux_usage;
@@ -1411,8 +1411,8 @@ anv_image_copy_to_shadow(struct anv_cmd_buffer *cmd_buffer,
    struct blorp_surf shadow_surf = {
       .surf = &image->planes[0].shadow_surface.isl,
       .addr = {
-         .buffer = image->planes[0].bo,
-         .offset = image->planes[0].bo_offset +
+         .buffer = image->planes[0].address.bo,
+         .offset = image->planes[0].address.offset +
                    image->planes[0].shadow_surface.offset,
          .mocs = cmd_buffer->device->default_mocs,
       },
index bbb740e2c628b4822a0202b6e19c41e6ea0ba302..c62bf7ae2b591e6e3468f7f803e43f9d519c8f39 100644 (file)
@@ -658,8 +658,9 @@ anv_DestroyImage(VkDevice _device, VkImage _image,
 
    for (uint32_t p = 0; p < image->n_planes; ++p) {
       if (image->planes[p].bo_is_owned) {
-         assert(image->planes[p].bo != NULL);
-         anv_bo_cache_release(device, &device->bo_cache, image->planes[p].bo);
+         assert(image->planes[p].address.bo != NULL);
+         anv_bo_cache_release(device, &device->bo_cache,
+                              image->planes[p].address.bo);
       }
    }
 
@@ -675,13 +676,14 @@ static void anv_image_bind_memory_plane(struct anv_device *device,
    assert(!image->planes[plane].bo_is_owned);
 
    if (!memory) {
-      image->planes[plane].bo = NULL;
-      image->planes[plane].bo_offset = 0;
+      image->planes[plane].address = ANV_NULL_ADDRESS;
       return;
    }
 
-   image->planes[plane].bo = memory->bo;
-   image->planes[plane].bo_offset = memory_offset;
+   image->planes[plane].address = (struct anv_address) {
+      .bo = memory->bo,
+      .offset = memory_offset,
+   };
 }
 
 VkResult anv_BindImageMemory(
@@ -1067,10 +1069,8 @@ anv_image_fill_surface_state(struct anv_device *device,
    if (!clear_color)
       clear_color = &default_clear_color;
 
-   const struct anv_address address = {
-      .bo = image->planes[plane].bo,
-      .offset = image->planes[plane].bo_offset + surface->offset,
-   };
+   const struct anv_address address =
+      anv_address_add(image->planes[plane].address, surface->offset);
 
    if (view_usage == ISL_SURF_USAGE_STORAGE_BIT &&
        !(flags & ANV_IMAGE_VIEW_STATE_STORAGE_WRITE_ONLY) &&
@@ -1159,10 +1159,8 @@ anv_image_fill_surface_state(struct anv_device *device,
 
       struct anv_address aux_address = ANV_NULL_ADDRESS;
       if (aux_usage != ISL_AUX_USAGE_NONE) {
-         aux_address = (struct anv_address) {
-            .bo = image->planes[plane].bo,
-            .offset = image->planes[plane].bo_offset + aux_surface->offset,
-         };
+         aux_address = anv_address_add(image->planes[plane].address,
+                                       aux_surface->offset);
       }
       state_inout->aux_address = aux_address;
 
index 976c83308e31ecc664cd154d7674ab9986aed37f..7ddde70b9c445edcdbeb07a9727300f1d3ca363f 100644 (file)
@@ -93,8 +93,10 @@ VkResult anv_CreateDmaBufImageINTEL(
    if (device->instance->physicalDevice.supports_48bit_addresses)
       mem->bo->flags |= EXEC_OBJECT_SUPPORTS_48B_ADDRESS;
 
-   image->planes[0].bo = mem->bo;
-   image->planes[0].bo_offset = 0;
+   image->planes[0].address = (struct anv_address) {
+      .bo = mem->bo,
+      .offset = 0,
+   };
 
    assert(image->extent.width > 0);
    assert(image->extent.height > 0);
index ecc0cb90595b878bacad7c5e52da385bbbfcce1c..5e07617054cc6b56d0c1c5ecb8cc8324fe3ed1e4 100644 (file)
@@ -2630,8 +2630,7 @@ struct anv_image {
       /**
        * BO associated with this plane, set when bound.
        */
-      struct anv_bo *bo;
-      VkDeviceSize bo_offset;
+      struct anv_address address;
 
       /**
        * When destroying the image, also free the bo.
@@ -2691,11 +2690,8 @@ anv_image_get_clear_color_addr(const struct anv_device *device,
    assert(image->aspects & VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV);
 
    uint32_t plane = anv_image_aspect_to_plane(image->aspects, aspect);
-   return (struct anv_address) {
-      .bo = image->planes[plane].bo,
-      .offset = image->planes[plane].bo_offset +
-                image->planes[plane].fast_clear_state_offset,
-   };
+   return anv_address_add(image->planes[plane].address,
+                          image->planes[plane].fast_clear_state_offset);
 }
 
 static inline struct anv_address
index 97b0f86b9907dce84d9e49c38178cf54c884464f..97b321ccaebe2e8f3718e24fd6cc49a87e09c133 100644 (file)
@@ -3371,8 +3371,8 @@ cmd_buffer_emit_depth_stencil(struct anv_cmd_buffer *cmd_buffer)
       info.depth_address =
          anv_batch_emit_reloc(&cmd_buffer->batch,
                               dw + device->isl_dev.ds.depth_offset / 4,
-                              image->planes[depth_plane].bo,
-                              image->planes[depth_plane].bo_offset +
+                              image->planes[depth_plane].address.bo,
+                              image->planes[depth_plane].address.offset +
                               surface->offset);
 
       const uint32_t ds =
@@ -3384,8 +3384,8 @@ cmd_buffer_emit_depth_stencil(struct anv_cmd_buffer *cmd_buffer)
          info.hiz_address =
             anv_batch_emit_reloc(&cmd_buffer->batch,
                                  dw + device->isl_dev.ds.hiz_offset / 4,
-                                 image->planes[depth_plane].bo,
-                                 image->planes[depth_plane].bo_offset +
+                                 image->planes[depth_plane].address.bo,
+                                 image->planes[depth_plane].address.offset +
                                  image->planes[depth_plane].aux_surface.offset);
 
          info.depth_clear_value = ANV_HZ_FC_VAL;
@@ -3402,8 +3402,9 @@ cmd_buffer_emit_depth_stencil(struct anv_cmd_buffer *cmd_buffer)
       info.stencil_address =
          anv_batch_emit_reloc(&cmd_buffer->batch,
                               dw + device->isl_dev.ds.stencil_offset / 4,
-                              image->planes[stencil_plane].bo,
-                              image->planes[stencil_plane].bo_offset + surface->offset);
+                              image->planes[stencil_plane].address.bo,
+                              image->planes[stencil_plane].address.offset +
+                              surface->offset);
    }
 
    isl_emit_depth_stencil_hiz_s(&device->isl_dev, dw, &info);