From 2f0935459f7fa7312df7a7068df63fcf42ccf590 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Thu, 5 Sep 2024 19:19:22 -0400 Subject: [PATCH] asahi: add tib sample setter helper Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/lib/agx_tilebuffer.c | 19 +++++++++++++++++++ src/asahi/lib/agx_tilebuffer.h | 3 +++ 2 files changed, 22 insertions(+) diff --git a/src/asahi/lib/agx_tilebuffer.c b/src/asahi/lib/agx_tilebuffer.c index 2c7c385e7c8..ecb986765a3 100644 --- a/src/asahi/lib/agx_tilebuffer.c +++ b/src/asahi/lib/agx_tilebuffer.c @@ -137,6 +137,25 @@ agx_build_tilebuffer_layout(const enum pipe_format *formats, uint8_t nr_cbufs, return tib; } +/* + * With attachmentless rendering in Vulkan, the sample count may not known until + * draw-time. It's convenient to construct an agx_tilebuffer_layout anyway when + * beginning rendering, updating the sample count later. This helper allows the + * driver to set the sample count in a partial agx_tilebuffer_layout. + * + * When doing so, we need to rebuild entirely since e.g. tile size might change. + */ +void +agx_tilebuffer_set_samples(struct agx_tilebuffer_layout *tib, + unsigned nr_samples) +{ + assert(tib->nr_samples == 0 && "must not be initialized"); + + *tib = agx_build_tilebuffer_layout(tib->logical_format, + ARRAY_SIZE(tib->logical_format), + nr_samples, tib->layered); +} + enum pipe_format agx_tilebuffer_physical_format(struct agx_tilebuffer_layout *tib, unsigned rt) { diff --git a/src/asahi/lib/agx_tilebuffer.h b/src/asahi/lib/agx_tilebuffer.h index ff2b621976f..ae227483e2d 100644 --- a/src/asahi/lib/agx_tilebuffer.h +++ b/src/asahi/lib/agx_tilebuffer.h @@ -90,6 +90,9 @@ struct agx_tilebuffer_layout agx_build_tilebuffer_layout(const enum pipe_format *formats, uint8_t nr_cbufs, uint8_t nr_samples, bool layered); +void agx_tilebuffer_set_samples(struct agx_tilebuffer_layout *tib, + unsigned nr_samples); + bool agx_nir_lower_tilebuffer(struct nir_shader *shader, struct agx_tilebuffer_layout *tib, uint8_t *colormasks, unsigned *bindless_base,