asahi,agx: Select layered rendering outputs
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>
Mon, 28 Aug 2023 12:17:19 +0000 (08:17 -0400)
committerAlyssa Rosenzweig <alyssa@rosenzweig.io>
Sun, 1 Oct 2023 16:32:12 +0000 (12:32 -0400)
These 2 are together

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
src/asahi/compiler/agx_compile.c
src/asahi/compiler/agx_compile.h
src/gallium/drivers/asahi/agx_state.c

index 04d8251..c6f36a5 100644 (file)
@@ -2893,6 +2893,10 @@ agx_compile_shader_nir(nir_shader *nir, struct agx_shader_key *key,
    if (nir->info.stage == MESA_SHADER_VERTEX) {
       out->writes_psiz =
          nir->info.outputs_written & BITFIELD_BIT(VARYING_SLOT_PSIZ);
+
+      out->writes_layer_viewport =
+         nir->info.outputs_written & (VARYING_BIT_LAYER | VARYING_BIT_VIEWPORT);
+
    } else if (nir->info.stage == MESA_SHADER_FRAGMENT) {
       out->disable_tri_merging = nir->info.fs.needs_all_helper_invocations ||
                                  nir->info.fs.needs_quad_helper_invocations ||
index a376bd0..91ec198 100644 (file)
@@ -116,6 +116,9 @@ struct agx_shader_info {
    /* Does the shader write point size? */
    bool writes_psiz;
 
+   /* Does the shader write layer and/or viewport index? Written together */
+   bool writes_layer_viewport;
+
    /* Does the shader control the sample mask? */
    bool writes_sample_mask;
 
index 52b99d6..18b22a2 100644 (file)
@@ -2848,6 +2848,8 @@ agx_encode_state(struct agx_batch *batch, uint8_t *out, bool is_lines,
       agx_ppp_push(&ppp, OUTPUT_SELECT, cfg) {
          cfg.varyings = !!fs->info.varyings.fs.nr_bindings;
          cfg.point_size = vs->info.writes_psiz;
+         cfg.viewport_target = vs->info.writes_layer_viewport;
+         cfg.render_target = vs->info.writes_layer_viewport;
          cfg.frag_coord_z = fs->info.varyings.fs.reads_z;
       }
    }