freedreno/turnip: Update GRAS_LAYER_CNTL to GRAS_MAX_LAYER_INDEX
authorBrian Ho <brian@brkho.com>
Mon, 13 Apr 2020 22:30:31 +0000 (15:30 -0700)
committerMarge Bot <eric+marge@anholt.net>
Wed, 15 Apr 2020 16:19:34 +0000 (16:19 +0000)
After some experimentation, I believe that GRAS_LAYER_CNTL is
actually just a count register storing the number of layers in the
render target. While debugging cube_array geometry tests, I noticed
that the blob was setting an unknown 0x8 to LAYER_CNTL, so I checked
the value of LAYER_CNTL for various layer sizes:

1: LAYER_CNTL=0
2: LAYER_CNTL=1
3: LAYER_CNTL=2
4: LAYER_CNTL=3
9: LAYER_CNTL=8
256: LAYER_CNTL=255
2000: LAYER_CNTL=1999

Seems like this register just stores a count of the largest layer
that can be written to via gl_Layer. This commit updates the reg
docs, freedreno's gs implementation, and turnip's gs implementation.

Fixes dEQP-VK.geometry.layered.cube_array.*

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

src/freedreno/registers/a6xx.xml
src/freedreno/vulkan/tu_cmd_buffer.c
src/gallium/drivers/freedreno/a6xx/fd6_gmem.c

index ad60d5ddfbf1636d5fa0932baa89efd2e4fc7bee..96641adbcdbb01ac8b7df93a39b5862c7daa8d28 100644 (file)
@@ -1848,10 +1848,8 @@ to upconvert to 32b float internally?
          <value value="0x3" name="LAYER_2D_ARRAY"/>
        </enum>
 
-       <reg32 offset="0x8004" name="GRAS_LAYER_CNTL">
-               <bitfield name="LAYERED" pos="0" type="boolean"/>
-               <bitfield name="TYPE" low="1" high="2" type="a6xx_layer_type"/>
-       </reg32>
+       <!-- index of highest layer that can be written to via gl_Layer -->
+       <reg32 offset="0x8004" name="GRAS_MAX_LAYER_INDEX" type="uint"/>
 
        <reg32 offset="0x8005" name="GRAS_CNTL">
                <!-- see also RB_RENDER_CONTROL0 -->
index 557fc857e2791d565a5096ddb4927a69711b3362..454613c9ea0412f672cc7c40ef0b3eb9ad4ef904 100644 (file)
@@ -489,10 +489,7 @@ tu6_emit_mrt(struct tu_cmd_buffer *cmd,
                       .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));
+   tu_cs_emit_regs(cs, A6XX_GRAS_MAX_LAYER_INDEX(fb->layers - 1));
 }
 
 void
index 7722be8d265523905322c354a485908cd65f5a02..f56b3422d556708ea010476229bfccfdf8f68fa2 100644 (file)
@@ -77,8 +77,7 @@ emit_mrt(struct fd_ringbuffer *ring, struct pipe_framebuffer_state *pfb,
        unsigned srgb_cntl = 0;
        unsigned i;
 
-       bool layered = false;
-       unsigned type = 0;
+       unsigned max_layer_index = 0;
 
        for (i = 0; i < pfb->nr_cbufs; i++) {
                enum a6xx_format format = 0;
@@ -117,18 +116,7 @@ emit_mrt(struct fd_ringbuffer *ring, struct pipe_framebuffer_state *pfb,
                swap = fd6_resource_swap(rsc, pformat);
 
                tile_mode = fd_resource_tile_mode(psurf->texture, psurf->u.tex.level);
-
-               if (psurf->u.tex.first_layer < psurf->u.tex.last_layer) {
-                       layered = true;
-                       if (psurf->texture->target == PIPE_TEXTURE_2D_ARRAY && psurf->texture->nr_samples > 0)
-                               type = LAYER_MULTISAMPLE_ARRAY;
-                       else if (psurf->texture->target == PIPE_TEXTURE_2D_ARRAY)
-                               type = LAYER_2D_ARRAY;
-                       else if (psurf->texture->target == PIPE_TEXTURE_CUBE)
-                               type = LAYER_CUBEMAP;
-                       else if (psurf->texture->target == PIPE_TEXTURE_3D)
-                               type = LAYER_3D;
-               }
+               max_layer_index = psurf->u.tex.last_layer - psurf->u.tex.first_layer;
 
                debug_assert((offset + slice->size0) <= fd_bo_size(rsc->bo));
 
@@ -174,7 +162,7 @@ emit_mrt(struct fd_ringbuffer *ring, struct pipe_framebuffer_state *pfb,
                .rt6 = mrt_comp[6],
                .rt7 = mrt_comp[7]));
 
-       OUT_REG(ring, A6XX_GRAS_LAYER_CNTL(.layered = layered, .type = type));
+       OUT_REG(ring, A6XX_GRAS_MAX_LAYER_INDEX(max_layer_index));
 }
 
 static void