anv: Flip around the way we reason about storage image lowering

There are roughly two cases when it comes to storage images.  In the
easy case, we have full hardware support and we can just emit a typed
read/write message in the shader and we're done.  In the more complex
cases, we may need to fall back to a typed read with a different format
or even to a raw (SSBO) read.

The hardware has always had basically full support for typed writes all
the way back to Ivy Bridge but typed reads have been harder to come by.
Starting with Skylake, we finally have enough that we at least have a
format of the right bit size but not necessarily the right format so we
can use a typed read but may still have to do an int->unorm or similar
cast in the shader.

Previously, in ANV, we treated lowered images as the default and write-
only as a special case that we can optimize.  This flips everything
around and treats the cases where we don't need to do any lowering as
the default "vanilla" case and treats the lowered case as special.
Importantly, this means that read-write access to surfaces where the
native format handles typed writes now use the same surface state as
write-only access and the only thing that uses the lowered surface state
is access read-write access with a format that doesn't support typed
reads.  This has the added benefit that now, if someone does a read
without specifying a format, we can default to the vanilla surface and
it will work as long as it's a format that supports typed reads.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13198>
This commit is contained in:
Jason Ekstrand
2021-10-06 16:37:03 -05:00
parent fa251cf111
commit c0093c4668
5 changed files with 74 additions and 65 deletions

View File

@@ -1360,10 +1360,10 @@ anv_descriptor_set_write_image_view(struct anv_device *device,
assert(!(bind_layout->data & ANV_DESCRIPTOR_IMAGE_PARAM));
assert(image_view->n_planes == 1);
struct anv_storage_image_descriptor desc_data = {
.read_write = anv_surface_state_to_handle(
.vanilla = anv_surface_state_to_handle(
image_view->planes[0].storage_surface_state.state),
.write_only = anv_surface_state_to_handle(
image_view->planes[0].writeonly_storage_surface_state.state),
.lowered = anv_surface_state_to_handle(
image_view->planes[0].lowered_storage_surface_state.state),
};
memcpy(desc_map, &desc_data, sizeof(desc_data));
}
@@ -1372,7 +1372,7 @@ anv_descriptor_set_write_image_view(struct anv_device *device,
/* Storage images can only ever have one plane */
assert(image_view->n_planes == 1);
const struct brw_image_param *image_param =
&image_view->planes[0].storage_image_param;
&image_view->planes[0].lowered_storage_image_param;
anv_descriptor_set_write_image_param(desc_map, image_param);
}
@@ -1437,17 +1437,17 @@ anv_descriptor_set_write_buffer_view(struct anv_device *device,
if (bind_layout->data & ANV_DESCRIPTOR_STORAGE_IMAGE) {
assert(!(bind_layout->data & ANV_DESCRIPTOR_IMAGE_PARAM));
struct anv_storage_image_descriptor desc_data = {
.read_write = anv_surface_state_to_handle(
.vanilla = anv_surface_state_to_handle(
buffer_view->storage_surface_state),
.write_only = anv_surface_state_to_handle(
buffer_view->writeonly_storage_surface_state),
.lowered = anv_surface_state_to_handle(
buffer_view->lowered_storage_surface_state),
};
memcpy(desc_map, &desc_data, sizeof(desc_data));
}
if (bind_layout->data & ANV_DESCRIPTOR_IMAGE_PARAM) {
anv_descriptor_set_write_image_param(desc_map,
&buffer_view->storage_image_param);
&buffer_view->lowered_storage_image_param);
}
}