asahi: Decompress writable images

We can't write to compressed images. Decompress on the fly if needed. mesa/st
doesn't bother to do this for us.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23480>
This commit is contained in:
Alyssa Rosenzweig
2023-05-19 16:00:34 -04:00
committed by Marge Bot
parent 531247cf31
commit d499bf10a3
3 changed files with 26 additions and 0 deletions

View File

@@ -1119,6 +1119,19 @@ transition_resource(struct pipe_context *pctx, struct agx_resource *rsrc,
pipe_resource_reference((struct pipe_resource **)&new_res, NULL);
}
void
agx_decompress(struct agx_context *ctx, struct agx_resource *rsrc,
const char *reason)
{
assert(rsrc->layout.tiling == AIL_TILING_TWIDDLED_COMPRESSED);
perf_debug_ctx(ctx, "Decompressing resource due to %s", reason);
struct pipe_resource templ = rsrc->base;
assert(!(templ.bind & PIPE_BIND_SHADER_IMAGE) && "currently compressed");
templ.bind |= PIPE_BIND_SHADER_IMAGE /* forces off compression */;
transition_resource(&ctx->base, rsrc, &templ);
}
static void
agx_flush_resource(struct pipe_context *pctx, struct pipe_resource *pres)
{

View File

@@ -72,6 +72,16 @@ agx_set_shader_images(struct pipe_context *pctx, enum pipe_shader_type shader,
continue;
}
/* Images writeable with pixel granularity are incompatible with
* compression. Decompress if necessary.
*/
struct agx_resource *rsrc = agx_resource(image->resource);
if (rsrc->layout.tiling == AIL_TILING_TWIDDLED_COMPRESSED &&
(image->shader_access & PIPE_IMAGE_ACCESS_WRITE)) {
agx_decompress(ctx, rsrc, "Shader image");
}
/* FIXME: Decompress here once we have texture compression */
util_copy_image_view(&ctx->stage[shader].images[start_slot + i], image);
}

View File

@@ -634,6 +634,9 @@ agx_map_texture_gpu(struct agx_resource *rsrc, unsigned z)
(uint64_t)ail_get_layer_offset_B(&rsrc->layout, z);
}
void agx_decompress(struct agx_context *ctx, struct agx_resource *rsrc,
const char *reason);
struct agx_transfer {
struct pipe_transfer base;
void *map;