agx: Fix discard with MRT

The exact semantics of sample_mask aren't quite clear to me yet, but executing
multiple sample_mask instructions seems to raise a fault :|

Fixes SuperTuxKart's advanced renderer.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20446>
This commit is contained in:
Alyssa Rosenzweig 2022-12-02 13:46:34 -05:00
parent 2b5519e865
commit ebe40b15ea
2 changed files with 3 additions and 2 deletions

View file

@ -455,13 +455,14 @@ agx_emit_local_store_pixel(agx_builder *b, nir_intrinsic_instr *instr)
agx_writeout(b, 0x000C);
}
if (b->shader->nir->info.fs.uses_discard) {
if (b->shader->nir->info.fs.uses_discard && !b->shader->did_sample_mask) {
/* If the shader uses discard, the sample mask must be written by the
* shader on all exeuction paths. If we've reached the end of the shader,
* we are therefore still active and need to write a full sample mask.
* TODO: interactions with MSAA and gl_SampleMask writes
*/
agx_sample_mask(b, agx_immediate(1));
b->shader->did_sample_mask = true;
}
/* Compact the registers according to the mask */

View file

@ -408,7 +408,7 @@ typedef struct {
unsigned alloc;
/* I don't really understand how writeout ops work yet */
bool did_writeout;
bool did_writeout, did_sample_mask;
/* Has r0l been zeroed yet due to control flow? */
bool any_cf;