[Mesa-dev] [PATCH v4 12/23] anv: Use an address for each anv_image plane
Jason Ekstrand
jason at jlekstrand.net
Thu May 31 15:46:33 UTC 2018
This is better than having BO and offset fields.
---
src/intel/vulkan/anv_blorp.c | 12 ++++++------
src/intel/vulkan/anv_image.c | 26 ++++++++++++--------------
src/intel/vulkan/anv_intel.c | 6 ++++--
src/intel/vulkan/anv_private.h | 10 +++-------
src/intel/vulkan/genX_cmd_buffer.c | 13 +++++++------
5 files changed, 32 insertions(+), 35 deletions(-)
diff --git a/src/intel/vulkan/anv_blorp.c b/src/intel/vulkan/anv_blorp.c
index 359ebfb..5373faa 100644
--- a/src/intel/vulkan/anv_blorp.c
+++ b/src/intel/vulkan/anv_blorp.c
@@ -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,
},
diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
index bbb740e..c62bf7a 100644
--- a/src/intel/vulkan/anv_image.c
+++ b/src/intel/vulkan/anv_image.c
@@ -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;
diff --git a/src/intel/vulkan/anv_intel.c b/src/intel/vulkan/anv_intel.c
index 976c833..7ddde70 100644
--- a/src/intel/vulkan/anv_intel.c
+++ b/src/intel/vulkan/anv_intel.c
@@ -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);
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index ecc0cb9..5e07617 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -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
diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c
index 97b0f86..97b321c 100644
--- a/src/intel/vulkan/genX_cmd_buffer.c
+++ b/src/intel/vulkan/genX_cmd_buffer.c
@@ -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);
--
2.5.0.400.gff86faf
More information about the mesa-dev
mailing list