diff --git a/src/intel/vulkan/anv_blorp.c b/src/intel/vulkan/anv_blorp.c index ebeb9014f8f..4d72585f4b0 100644 --- a/src/intel/vulkan/anv_blorp.c +++ b/src/intel/vulkan/anv_blorp.c @@ -218,22 +218,28 @@ get_blorp_surf_for_anv_image(const struct anv_device *device, ISL_SURF_USAGE_RENDER_TARGET_BIT : ISL_SURF_USAGE_TEXTURE_BIT; const struct anv_surface *surface = &image->planes[plane].primary_surface; + const struct anv_address address = + anv_image_address(image, plane, surface->offset); + *blorp_surf = (struct blorp_surf) { .surf = &surface->isl, .addr = { - .buffer = image->planes[plane].address.bo, - .offset = image->planes[plane].address.offset + surface->offset, - .mocs = anv_mocs(device, image->planes[plane].address.bo, mocs_usage), + .buffer = address.bo, + .offset = address.offset, + .mocs = anv_mocs(device, address.bo, mocs_usage), }, }; if (aux_usage != ISL_AUX_USAGE_NONE) { const struct anv_surface *aux_surface = &image->planes[plane].aux_surface; + const struct anv_address aux_address = + anv_image_address(image, plane, aux_surface->offset); + blorp_surf->aux_surf = &aux_surface->isl, blorp_surf->aux_addr = (struct blorp_address) { - .buffer = image->planes[plane].address.bo, - .offset = image->planes[plane].address.offset + aux_surface->offset, - .mocs = anv_mocs(device, image->planes[plane].address.bo, 0), + .buffer = aux_address.bo, + .offset = aux_address.offset, + .mocs = anv_mocs(device, aux_address.bo, 0), }; blorp_surf->aux_usage = aux_usage; @@ -279,14 +285,16 @@ get_blorp_surf_for_anv_shadow_image(const struct anv_device *device, if (!anv_surface_is_valid(&image->planes[plane].shadow_surface)) return false; + const struct anv_surface *surface = &image->planes[plane].shadow_surface; + const struct anv_address address = + anv_image_address(image, plane, surface->offset); + *blorp_surf = (struct blorp_surf) { - .surf = &image->planes[plane].shadow_surface.isl, + .surf = &surface->isl, .addr = { - .buffer = image->planes[plane].address.bo, - .offset = image->planes[plane].address.offset + - image->planes[plane].shadow_surface.offset, - .mocs = anv_mocs(device, image->planes[plane].address.bo, - ISL_SURF_USAGE_RENDER_TARGET_BIT), + .buffer = address.bo, + .offset = address.offset, + .mocs = anv_mocs(device, address.bo, ISL_SURF_USAGE_RENDER_TARGET_BIT), }, }; diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c index 7811bedea46..b056e44aad0 100644 --- a/src/intel/vulkan/anv_image.c +++ b/src/intel/vulkan/anv_image.c @@ -1897,7 +1897,7 @@ anv_image_fill_surface_state(struct anv_device *device, clear_color = &default_clear_color; const struct anv_address address = - anv_address_add(image->planes[plane].address, surface->offset); + anv_image_address(image, plane, surface->offset); if (view_usage == ISL_SURF_USAGE_STORAGE_BIT && !(flags & ANV_IMAGE_VIEW_STATE_STORAGE_WRITE_ONLY) && @@ -1984,8 +1984,7 @@ 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 = anv_address_add(image->planes[plane].address, - aux_surface->offset); + aux_address = anv_image_address(image, plane, aux_surface->offset); } state_inout->aux_address = aux_address; diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index c0e436186ea..0cde2352e74 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -3899,6 +3899,14 @@ anv_image_aux_layers(const struct anv_image * const image, return MAX2(image->array_size, image->extent.depth >> miplevel); } +static inline struct anv_address MUST_CHECK +anv_image_address(const struct anv_image *image, + uint32_t plane, uint64_t offset) +{ + assert(image->planes[plane].address.offset == 0); + return anv_address_add(image->planes[plane].address, offset); +} + static inline struct anv_address anv_image_get_clear_color_addr(UNUSED const struct anv_device *device, const struct anv_image *image, @@ -3907,8 +3915,8 @@ anv_image_get_clear_color_addr(UNUSED 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 anv_address_add(image->planes[plane].address, - image->planes[plane].fast_clear_state_offset); + return anv_image_address(image, plane, + 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 eddc8e1e47f..2e60fc67705 100644 --- a/src/intel/vulkan/genX_cmd_buffer.c +++ b/src/intel/vulkan/genX_cmd_buffer.c @@ -466,8 +466,7 @@ anv_image_init_aux_tt(struct anv_cmd_buffer *cmd_buffer, const struct anv_surface *surface = &image->planes[plane].primary_surface; uint64_t base_address = - anv_address_physical(anv_address_add(image->planes[plane].address, - surface->offset)); + anv_address_physical(anv_image_address(image, plane, surface->offset)); const struct isl_surf *isl_surf = &image->planes[plane].primary_surface.isl; uint64_t format_bits = gen_aux_map_format_bits_for_isl_surf(isl_surf); @@ -5204,33 +5203,37 @@ cmd_buffer_emit_depth_stencil(struct anv_cmd_buffer *cmd_buffer) if (image && (image->aspects & VK_IMAGE_ASPECT_DEPTH_BIT)) { uint32_t depth_plane = anv_image_aspect_to_plane(image->aspects, VK_IMAGE_ASPECT_DEPTH_BIT); - const struct anv_surface *surface = &image->planes[depth_plane].primary_surface; + const struct anv_surface *depth_surface = + &image->planes[depth_plane].primary_surface; + const struct anv_address depth_address = + anv_image_address(image, depth_plane, depth_surface->offset); - info.depth_surf = &surface->isl; + info.depth_surf = &depth_surface->isl; info.depth_address = anv_batch_emit_reloc(&cmd_buffer->batch, dw + device->isl_dev.ds.depth_offset / 4, - image->planes[depth_plane].address.bo, - image->planes[depth_plane].address.offset + - surface->offset); + depth_address.bo, depth_address.offset); info.mocs = - anv_mocs(device, image->planes[depth_plane].address.bo, - ISL_SURF_USAGE_DEPTH_BIT); + anv_mocs(device, depth_address.bo, ISL_SURF_USAGE_DEPTH_BIT); const uint32_t ds = cmd_buffer->state.subpass->depth_stencil_attachment->attachment; info.hiz_usage = cmd_buffer->state.attachments[ds].aux_usage; if (info.hiz_usage != ISL_AUX_USAGE_NONE) { assert(isl_aux_usage_has_hiz(info.hiz_usage)); - info.hiz_surf = &image->planes[depth_plane].aux_surface.isl; + + const struct anv_surface *hiz_surface = + &image->planes[depth_plane].aux_surface; + const struct anv_address hiz_address = + anv_image_address(image, depth_plane, hiz_surface->offset); + + info.hiz_surf = &hiz_surface->isl; info.hiz_address = anv_batch_emit_reloc(&cmd_buffer->batch, dw + device->isl_dev.ds.hiz_offset / 4, - image->planes[depth_plane].address.bo, - image->planes[depth_plane].address.offset + - image->planes[depth_plane].aux_surface.offset); + hiz_address.bo, hiz_address.offset); info.depth_clear_value = ANV_HZ_FC_VAL; } @@ -5239,20 +5242,20 @@ cmd_buffer_emit_depth_stencil(struct anv_cmd_buffer *cmd_buffer) if (image && (image->aspects & VK_IMAGE_ASPECT_STENCIL_BIT)) { uint32_t stencil_plane = anv_image_aspect_to_plane(image->aspects, VK_IMAGE_ASPECT_STENCIL_BIT); - const struct anv_surface *surface = &image->planes[stencil_plane].primary_surface; + const struct anv_surface *stencil_surface = + &image->planes[stencil_plane].primary_surface; + const struct anv_address stencil_address = + anv_image_address(image, stencil_plane, stencil_surface->offset); - info.stencil_surf = &surface->isl; + info.stencil_surf = &stencil_surface->isl; info.stencil_aux_usage = image->planes[stencil_plane].aux_usage; info.stencil_address = anv_batch_emit_reloc(&cmd_buffer->batch, dw + device->isl_dev.ds.stencil_offset / 4, - image->planes[stencil_plane].address.bo, - image->planes[stencil_plane].address.offset + - surface->offset); + stencil_address.bo, stencil_address.offset); info.mocs = - anv_mocs(device, image->planes[stencil_plane].address.bo, - ISL_SURF_USAGE_STENCIL_BIT); + anv_mocs(device, stencil_address.bo, ISL_SURF_USAGE_STENCIL_BIT); } isl_emit_depth_stencil_hiz_s(&device->isl_dev, dw, &info);