anv/image: Add anv_image_address()
It calculates the address to a surface or to metadata in the image. Refactor only. No intended change in behavior. This patch prepares for, and reduces much noise in, the upcoming patch that rewrites image memory tracking. Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8097>
This commit is contained in:

committed by
chadversary

parent
1ef0fd3b70
commit
bb7d627865
@@ -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;
|
ISL_SURF_USAGE_RENDER_TARGET_BIT : ISL_SURF_USAGE_TEXTURE_BIT;
|
||||||
|
|
||||||
const struct anv_surface *surface = &image->planes[plane].primary_surface;
|
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) {
|
*blorp_surf = (struct blorp_surf) {
|
||||||
.surf = &surface->isl,
|
.surf = &surface->isl,
|
||||||
.addr = {
|
.addr = {
|
||||||
.buffer = image->planes[plane].address.bo,
|
.buffer = address.bo,
|
||||||
.offset = image->planes[plane].address.offset + surface->offset,
|
.offset = address.offset,
|
||||||
.mocs = anv_mocs(device, image->planes[plane].address.bo, mocs_usage),
|
.mocs = anv_mocs(device, address.bo, mocs_usage),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
if (aux_usage != ISL_AUX_USAGE_NONE) {
|
if (aux_usage != ISL_AUX_USAGE_NONE) {
|
||||||
const struct anv_surface *aux_surface = &image->planes[plane].aux_surface;
|
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_surf = &aux_surface->isl,
|
||||||
blorp_surf->aux_addr = (struct blorp_address) {
|
blorp_surf->aux_addr = (struct blorp_address) {
|
||||||
.buffer = image->planes[plane].address.bo,
|
.buffer = aux_address.bo,
|
||||||
.offset = image->planes[plane].address.offset + aux_surface->offset,
|
.offset = aux_address.offset,
|
||||||
.mocs = anv_mocs(device, image->planes[plane].address.bo, 0),
|
.mocs = anv_mocs(device, aux_address.bo, 0),
|
||||||
};
|
};
|
||||||
blorp_surf->aux_usage = aux_usage;
|
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))
|
if (!anv_surface_is_valid(&image->planes[plane].shadow_surface))
|
||||||
return false;
|
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) {
|
*blorp_surf = (struct blorp_surf) {
|
||||||
.surf = &image->planes[plane].shadow_surface.isl,
|
.surf = &surface->isl,
|
||||||
.addr = {
|
.addr = {
|
||||||
.buffer = image->planes[plane].address.bo,
|
.buffer = address.bo,
|
||||||
.offset = image->planes[plane].address.offset +
|
.offset = address.offset,
|
||||||
image->planes[plane].shadow_surface.offset,
|
.mocs = anv_mocs(device, address.bo, ISL_SURF_USAGE_RENDER_TARGET_BIT),
|
||||||
.mocs = anv_mocs(device, image->planes[plane].address.bo,
|
|
||||||
ISL_SURF_USAGE_RENDER_TARGET_BIT),
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -1897,7 +1897,7 @@ anv_image_fill_surface_state(struct anv_device *device,
|
|||||||
clear_color = &default_clear_color;
|
clear_color = &default_clear_color;
|
||||||
|
|
||||||
const struct anv_address address =
|
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 &&
|
if (view_usage == ISL_SURF_USAGE_STORAGE_BIT &&
|
||||||
!(flags & ANV_IMAGE_VIEW_STATE_STORAGE_WRITE_ONLY) &&
|
!(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;
|
struct anv_address aux_address = ANV_NULL_ADDRESS;
|
||||||
if (aux_usage != ISL_AUX_USAGE_NONE) {
|
if (aux_usage != ISL_AUX_USAGE_NONE) {
|
||||||
aux_address = anv_address_add(image->planes[plane].address,
|
aux_address = anv_image_address(image, plane, aux_surface->offset);
|
||||||
aux_surface->offset);
|
|
||||||
}
|
}
|
||||||
state_inout->aux_address = aux_address;
|
state_inout->aux_address = aux_address;
|
||||||
|
|
||||||
|
@@ -3899,6 +3899,14 @@ anv_image_aux_layers(const struct anv_image * const image,
|
|||||||
return MAX2(image->array_size, image->extent.depth >> miplevel);
|
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
|
static inline struct anv_address
|
||||||
anv_image_get_clear_color_addr(UNUSED const struct anv_device *device,
|
anv_image_get_clear_color_addr(UNUSED const struct anv_device *device,
|
||||||
const struct anv_image *image,
|
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);
|
assert(image->aspects & VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV);
|
||||||
|
|
||||||
uint32_t plane = anv_image_aspect_to_plane(image->aspects, aspect);
|
uint32_t plane = anv_image_aspect_to_plane(image->aspects, aspect);
|
||||||
return anv_address_add(image->planes[plane].address,
|
return anv_image_address(image, plane,
|
||||||
image->planes[plane].fast_clear_state_offset);
|
image->planes[plane].fast_clear_state_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline struct anv_address
|
static inline struct anv_address
|
||||||
|
@@ -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;
|
const struct anv_surface *surface = &image->planes[plane].primary_surface;
|
||||||
uint64_t base_address =
|
uint64_t base_address =
|
||||||
anv_address_physical(anv_address_add(image->planes[plane].address,
|
anv_address_physical(anv_image_address(image, plane, surface->offset));
|
||||||
surface->offset));
|
|
||||||
|
|
||||||
const struct isl_surf *isl_surf = &image->planes[plane].primary_surface.isl;
|
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);
|
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)) {
|
if (image && (image->aspects & VK_IMAGE_ASPECT_DEPTH_BIT)) {
|
||||||
uint32_t depth_plane =
|
uint32_t depth_plane =
|
||||||
anv_image_aspect_to_plane(image->aspects, VK_IMAGE_ASPECT_DEPTH_BIT);
|
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 =
|
info.depth_address =
|
||||||
anv_batch_emit_reloc(&cmd_buffer->batch,
|
anv_batch_emit_reloc(&cmd_buffer->batch,
|
||||||
dw + device->isl_dev.ds.depth_offset / 4,
|
dw + device->isl_dev.ds.depth_offset / 4,
|
||||||
image->planes[depth_plane].address.bo,
|
depth_address.bo, depth_address.offset);
|
||||||
image->planes[depth_plane].address.offset +
|
|
||||||
surface->offset);
|
|
||||||
info.mocs =
|
info.mocs =
|
||||||
anv_mocs(device, image->planes[depth_plane].address.bo,
|
anv_mocs(device, depth_address.bo, ISL_SURF_USAGE_DEPTH_BIT);
|
||||||
ISL_SURF_USAGE_DEPTH_BIT);
|
|
||||||
|
|
||||||
const uint32_t ds =
|
const uint32_t ds =
|
||||||
cmd_buffer->state.subpass->depth_stencil_attachment->attachment;
|
cmd_buffer->state.subpass->depth_stencil_attachment->attachment;
|
||||||
info.hiz_usage = cmd_buffer->state.attachments[ds].aux_usage;
|
info.hiz_usage = cmd_buffer->state.attachments[ds].aux_usage;
|
||||||
if (info.hiz_usage != ISL_AUX_USAGE_NONE) {
|
if (info.hiz_usage != ISL_AUX_USAGE_NONE) {
|
||||||
assert(isl_aux_usage_has_hiz(info.hiz_usage));
|
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 =
|
info.hiz_address =
|
||||||
anv_batch_emit_reloc(&cmd_buffer->batch,
|
anv_batch_emit_reloc(&cmd_buffer->batch,
|
||||||
dw + device->isl_dev.ds.hiz_offset / 4,
|
dw + device->isl_dev.ds.hiz_offset / 4,
|
||||||
image->planes[depth_plane].address.bo,
|
hiz_address.bo, hiz_address.offset);
|
||||||
image->planes[depth_plane].address.offset +
|
|
||||||
image->planes[depth_plane].aux_surface.offset);
|
|
||||||
|
|
||||||
info.depth_clear_value = ANV_HZ_FC_VAL;
|
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)) {
|
if (image && (image->aspects & VK_IMAGE_ASPECT_STENCIL_BIT)) {
|
||||||
uint32_t stencil_plane =
|
uint32_t stencil_plane =
|
||||||
anv_image_aspect_to_plane(image->aspects, VK_IMAGE_ASPECT_STENCIL_BIT);
|
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_aux_usage = image->planes[stencil_plane].aux_usage;
|
||||||
info.stencil_address =
|
info.stencil_address =
|
||||||
anv_batch_emit_reloc(&cmd_buffer->batch,
|
anv_batch_emit_reloc(&cmd_buffer->batch,
|
||||||
dw + device->isl_dev.ds.stencil_offset / 4,
|
dw + device->isl_dev.ds.stencil_offset / 4,
|
||||||
image->planes[stencil_plane].address.bo,
|
stencil_address.bo, stencil_address.offset);
|
||||||
image->planes[stencil_plane].address.offset +
|
|
||||||
surface->offset);
|
|
||||||
info.mocs =
|
info.mocs =
|
||||||
anv_mocs(device, image->planes[stencil_plane].address.bo,
|
anv_mocs(device, stencil_address.bo, ISL_SURF_USAGE_STENCIL_BIT);
|
||||||
ISL_SURF_USAGE_STENCIL_BIT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
isl_emit_depth_stencil_hiz_s(&device->isl_dev, dw, &info);
|
isl_emit_depth_stencil_hiz_s(&device->isl_dev, dw, &info);
|
||||||
|
Reference in New Issue
Block a user