turnip: Selectively configure GRAS_LAYER_CNTL
authorBrian Ho <brian@brkho.com>
Fri, 3 Apr 2020 14:57:25 +0000 (07:57 -0700)
committerMarge Bot <eric+marge@anholt.net>
Tue, 7 Apr 2020 14:13:20 +0000 (14:13 +0000)
One of the features of geometry shaders is the ability to render to
different layers by assigning to the gl_Layer (Layer in SPIR-V)
builtin.

While have already plumbed the layer regid to the geometry shader,
we also need to GRAS_LAYER_CNTL to actually use layered rendering.
In addition, gmem does not support layered rendering, so we need to
force sysmem.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4436>

src/freedreno/vulkan/tu_cmd_buffer.c
src/freedreno/vulkan/tu_pipeline.c

index 3fe3b17e83baba837282e9d4af4c30a2da794338..4155c0a8a88d1048518c9bd49a267812a8f95c2e 100644 (file)
@@ -127,6 +127,10 @@ force_sysmem(const struct tu_cmd_buffer *cmd,
    bool has_linear_mipmapped_store = false;
    const struct tu_render_pass *pass = cmd->state.pass;
 
+   /* Layered rendering requires sysmem. */
+   if (fb->layers > 1)
+      return true;
+
    /* Iterate over all the places we call tu6_emit_store_attachment() */
    for (unsigned i = 0; i < pass->subpass_count; i++) {
       const struct tu_subpass *subpass = &pass->subpasses[i];
@@ -553,6 +557,11 @@ tu6_emit_mrt(struct tu_cmd_buffer *cmd,
                       .rt5 = mrt_comp[5],
                       .rt6 = mrt_comp[6],
                       .rt7 = mrt_comp[7]));
+
+   // XXX: We probably can't hardcode LAYER_CNTL_TYPE.
+   tu_cs_emit_regs(cs,
+                   A6XX_GRAS_LAYER_CNTL(.layered = fb->layers > 1,
+                                        .type = LAYER_2D_ARRAY));
 }
 
 static void
index 48f08cb5f3a3e7b06c2b0b33c30e20b397671ece..ac02e66590b348d4fde38f1655326705537a68d1 100644 (file)
@@ -1531,8 +1531,6 @@ tu6_emit_gras_unknowns(struct tu_cs *cs)
 {
    tu_cs_emit_pkt4(cs, REG_A6XX_GRAS_UNKNOWN_8001, 1);
    tu_cs_emit(cs, 0x0);
-   tu_cs_emit_pkt4(cs, REG_A6XX_GRAS_LAYER_CNTL, 1);
-   tu_cs_emit(cs, 0x0);
 }
 
 static void