anv/image: Add an aux_usage field for "default" aux

Initially, the field is set to ISL_AUX_USAGE_NONE so this commit shouldn't
bring any functional changes.  Setting this field to something else will
cause all sampled and storage image views to be created with AUX and blorp
will start trying to respect it so set with care.
This commit is contained in:
Jason Ekstrand
2016-10-25 10:32:18 -07:00
parent 338cdc172a
commit edb7f67bd9
4 changed files with 45 additions and 19 deletions

View File

@@ -169,8 +169,12 @@ get_blorp_surf_for_anv_buffer(struct anv_device *device,
static void
get_blorp_surf_for_anv_image(const struct anv_image *image,
VkImageAspectFlags aspect,
enum isl_aux_usage aux_usage,
struct blorp_surf *blorp_surf)
{
if (aspect == VK_IMAGE_ASPECT_STENCIL_BIT)
aux_usage = ISL_AUX_USAGE_NONE;
const struct anv_surface *surface =
anv_image_get_surface_for_aspect_mask(image, aspect);
@@ -181,6 +185,15 @@ get_blorp_surf_for_anv_image(const struct anv_image *image,
.offset = image->offset + surface->offset,
},
};
if (aux_usage != ISL_AUX_USAGE_NONE) {
blorp_surf->aux_surf = &image->aux_surface.isl,
blorp_surf->aux_addr = (struct blorp_address) {
.buffer = image->bo,
.offset = image->offset + image->aux_surface.offset,
};
blorp_surf->aux_usage = aux_usage;
}
}
void anv_CmdCopyImage(
@@ -232,8 +245,10 @@ void anv_CmdCopyImage(
VkImageAspectFlagBits aspect = (1 << a);
struct blorp_surf src_surf, dst_surf;
get_blorp_surf_for_anv_image(src_image, aspect, &src_surf);
get_blorp_surf_for_anv_image(dst_image, aspect, &dst_surf);
get_blorp_surf_for_anv_image(src_image, aspect, src_image->aux_usage,
&src_surf);
get_blorp_surf_for_anv_image(dst_image, aspect, dst_image->aux_usage,
&dst_surf);
for (unsigned i = 0; i < layer_count; i++) {
blorp_copy(&batch, &src_surf, pRegions[r].srcSubresource.mipLevel,
@@ -281,7 +296,8 @@ copy_buffer_to_image(struct anv_cmd_buffer *cmd_buffer,
for (unsigned r = 0; r < regionCount; r++) {
const VkImageAspectFlags aspect = pRegions[r].imageSubresource.aspectMask;
get_blorp_surf_for_anv_image(anv_image, aspect, &image.surf);
get_blorp_surf_for_anv_image(anv_image, aspect, anv_image->aux_usage,
&image.surf);
image.offset =
anv_sanitize_image_offset(anv_image->type, pRegions[r].imageOffset);
image.level = pRegions[r].imageSubresource.mipLevel;
@@ -425,8 +441,10 @@ void anv_CmdBlitImage(
const VkImageSubresourceLayers *src_res = &pRegions[r].srcSubresource;
const VkImageSubresourceLayers *dst_res = &pRegions[r].dstSubresource;
get_blorp_surf_for_anv_image(src_image, src_res->aspectMask, &src);
get_blorp_surf_for_anv_image(dst_image, dst_res->aspectMask, &dst);
get_blorp_surf_for_anv_image(src_image, src_res->aspectMask,
src_image->aux_usage, &src);
get_blorp_surf_for_anv_image(dst_image, dst_res->aspectMask,
dst_image->aux_usage, &dst);
struct anv_format src_format =
anv_get_format(&cmd_buffer->device->info, src_image->vk_format,
@@ -788,7 +806,8 @@ void anv_CmdClearColorImage(
memcpy(clear_color.u32, pColor->uint32, sizeof(pColor->uint32));
struct blorp_surf surf;
get_blorp_surf_for_anv_image(image, VK_IMAGE_ASPECT_COLOR_BIT, &surf);
get_blorp_surf_for_anv_image(image, VK_IMAGE_ASPECT_COLOR_BIT,
image->aux_usage, &surf);
for (unsigned r = 0; r < rangeCount; r++) {
if (pRanges[r].aspectMask == 0)
@@ -841,14 +860,14 @@ void anv_CmdClearDepthStencilImage(
struct blorp_surf depth, stencil;
if (image->aspects & VK_IMAGE_ASPECT_DEPTH_BIT) {
get_blorp_surf_for_anv_image(image, VK_IMAGE_ASPECT_DEPTH_BIT,
&depth);
image->aux_usage, &depth);
} else {
memset(&depth, 0, sizeof(depth));
}
if (image->aspects & VK_IMAGE_ASPECT_STENCIL_BIT) {
get_blorp_surf_for_anv_image(image, VK_IMAGE_ASPECT_STENCIL_BIT,
&stencil);
ISL_AUX_USAGE_NONE, &stencil);
} else {
memset(&stencil, 0, sizeof(stencil));
}
@@ -1140,8 +1159,10 @@ resolve_image(struct blorp_batch *batch,
VkImageAspectFlagBits aspect = 1 << a;
struct blorp_surf src_surf, dst_surf;
get_blorp_surf_for_anv_image(src_image, aspect, &src_surf);
get_blorp_surf_for_anv_image(dst_image, aspect, &dst_surf);
get_blorp_surf_for_anv_image(src_image, aspect,
src_image->aux_usage, &src_surf);
get_blorp_surf_for_anv_image(dst_image, aspect,
dst_image->aux_usage, &dst_surf);
blorp_blit(batch,
&src_surf, src_level, src_layer,
@@ -1233,13 +1254,8 @@ ccs_resolve_attachment(struct anv_cmd_buffer *cmd_buffer,
assert(image->aspects == VK_IMAGE_ASPECT_COLOR_BIT);
struct blorp_surf surf;
get_blorp_surf_for_anv_image(image, VK_IMAGE_ASPECT_COLOR_BIT, &surf);
surf.aux_surf = &image->aux_surface.isl;
surf.aux_addr = (struct blorp_address) {
.buffer = image->bo,
.offset = image->offset + image->aux_surface.offset,
};
surf.aux_usage = att_state->aux_usage;
get_blorp_surf_for_anv_image(image, VK_IMAGE_ASPECT_COLOR_BIT,
att_state->aux_usage, &surf);
for (uint32_t layer = 0; layer < fb->layers; layer++) {
blorp_ccs_resolve(batch, &surf,

View File

@@ -242,6 +242,7 @@ anv_image_create(VkDevice _device,
image->samples = pCreateInfo->samples;
image->usage = pCreateInfo->usage;
image->tiling = pCreateInfo->tiling;
image->aux_usage = ISL_AUX_USAGE_NONE;
uint32_t b;
for_each_bit(b, image->aspects) {
@@ -507,6 +508,8 @@ anv_CreateImageView(VkDevice _device,
iview->sampler_surface_state.map,
.surf = &surface->isl,
.view = &view,
.aux_surf = &image->aux_surface.isl,
.aux_usage = image->aux_usage,
.mocs = device->default_mocs);
if (!device->info.has_llc)
@@ -529,6 +532,8 @@ anv_CreateImageView(VkDevice _device,
iview->storage_surface_state.map,
.surf = &surface->isl,
.view = &view,
.aux_surf = &image->aux_surface.isl,
.aux_usage = image->aux_usage,
.mocs = device->default_mocs);
} else {
anv_fill_buffer_surface_state(device, iview->storage_surface_state,

View File

@@ -1555,6 +1555,9 @@ struct anv_image {
};
};
/** The aux usage for this surface when outside a render pass */
enum isl_aux_usage aux_usage;
struct anv_surface aux_surface;
};

View File

@@ -946,14 +946,16 @@ emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
surface_state = desc->image_view->sampler_surface_state;
assert(surface_state.alloc_size);
add_image_view_relocs(cmd_buffer, desc->image_view,
ISL_AUX_USAGE_NONE, surface_state);
desc->image_view->image->aux_usage,
surface_state);
break;
case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE: {
surface_state = desc->image_view->storage_surface_state;
assert(surface_state.alloc_size);
add_image_view_relocs(cmd_buffer, desc->image_view,
ISL_AUX_USAGE_NONE, surface_state);
desc->image_view->image->aux_usage,
surface_state);
struct brw_image_param *image_param =
&cmd_buffer->state.push_constants[stage]->images[image++];