asahi: add tib sample setter helper

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31532>
This commit is contained in:
Alyssa Rosenzweig 2024-09-05 19:19:22 -04:00 committed by Marge Bot
parent f3a407344d
commit 2f0935459f
2 changed files with 22 additions and 0 deletions

View file

@ -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)
{

View file

@ -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,