diff --git a/src/asahi/layout/layout.c b/src/asahi/layout/layout.c index 1d55d7b4a98..7829f18e7a2 100644 --- a/src/asahi/layout/layout.c +++ b/src/asahi/layout/layout.c @@ -160,15 +160,17 @@ ail_initialize_twiddled(struct ail_layout *layout) layout->page_aligned_layers = layout->levels != 1 && offset_B > AIL_PAGESIZE; /* Single-layer images are not padded unless they are Z/S */ - if (layout->depth_px == 1 && - !util_format_is_depth_or_stencil(layout->format)) + bool zs = util_format_is_depth_or_stencil(layout->format); + if (layout->depth_px == 1 && !zs) layout->page_aligned_layers = false; /* For writable images, we require page-aligned layers. This appears to be - * required for PBE stores. + * required for PBE stores, including block stores for colour rendering. + * Likewise, we specify the ZLS layer stride in pages, so we need + * page-aligned layers for renderable depth/stencil targets. */ - if (layout->writeable_image) - layout->page_aligned_layers = true; + layout->page_aligned_layers |= layout->writeable_image; + layout->page_aligned_layers |= layout->renderable && layout->depth_px > 1; if (layout->page_aligned_layers) layout->layer_stride_B = ALIGN_POT(offset_B, AIL_PAGESIZE); diff --git a/src/asahi/layout/layout.h b/src/asahi/layout/layout.h index 9d7f81ae7a8..7a54215e211 100644 --- a/src/asahi/layout/layout.h +++ b/src/asahi/layout/layout.h @@ -123,6 +123,11 @@ struct ail_layout { * used as a writeable image (either PBE or image atomics). */ bool writeable_image; + + /* Must the layout support rendering? If false, the layout MUST NOT be used + * for rendering, either PBE or ZLS. + */ + bool renderable; }; static inline uint32_t diff --git a/src/gallium/drivers/asahi/agx_pipe.c b/src/gallium/drivers/asahi/agx_pipe.c index 87db9186f1a..84e7b87a18b 100644 --- a/src/gallium/drivers/asahi/agx_pipe.c +++ b/src/gallium/drivers/asahi/agx_pipe.c @@ -181,6 +181,13 @@ agx_resource_setup(struct agx_device *dev, struct agx_resource *nresource) .sample_count_sa = MAX2(templ->nr_samples, 1), .levels = templ->last_level + 1, .writeable_image = templ->bind & PIPE_BIND_SHADER_IMAGE, + + /* Ostensibly this should be based on the bind, but Gallium bind flags are + * notoriously unreliable. The only cost of setting this excessively is a + * bit of extra memory use for layered textures, which isn't worth trying + * to optimize. + */ + .renderable = true, }; }