asahi: Pass depth/stencil clear values to firmware
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>
Tue, 22 Mar 2022 01:21:48 +0000 (21:21 -0400)
committerAlyssa Rosenzweig <alyssa@rosenzweig.io>
Sun, 22 May 2022 02:01:32 +0000 (22:01 -0400)
These need to be format-packed, but as we only support Z32F_S8 right
now, that's trivial.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16512>

src/gallium/drivers/asahi/agx_pipe.c
src/gallium/drivers/asahi/agx_state.h
src/gallium/drivers/asahi/magic.c
src/gallium/drivers/asahi/magic.h

index 6018704..38626fe 100644 (file)
@@ -392,6 +392,12 @@ agx_clear(struct pipe_context *pctx, unsigned buffers, const struct pipe_scissor
 
    if (buffers & PIPE_CLEAR_COLOR0)
       memcpy(ctx->batch->clear_color, color->f, sizeof(color->f));
+
+   if (buffers & PIPE_CLEAR_DEPTH)
+      ctx->batch->clear_depth = depth;
+
+   if (buffers & PIPE_CLEAR_STENCIL)
+      ctx->batch->clear_stencil = stencil;
 }
 
 
@@ -544,7 +550,9 @@ agx_flush(struct pipe_context *pctx,
                pipeline_null.gpu,
                pipeline_clear,
                pipeline_store,
-               clear_pipeline_textures);
+               clear_pipeline_textures,
+               ctx->batch->clear_depth,
+               ctx->batch->clear_stencil);
 
    /* Generate the mapping table from the BO list */
    demo_mem_map(dev->memmap.ptr.cpu, dev->memmap.size, handles, handle_count,
index cc0a187..2de160b 100644 (file)
@@ -103,6 +103,8 @@ struct agx_batch {
    uint32_t clear, draw;
 
    float clear_color[4];
+   double clear_depth;
+   unsigned clear_stencil;
 
    /* Resource list requirements, represented as a bit set indexed by BO
     * handles (GEM handles on Linux, or IOGPU's equivalent on macOS) */
index 049d2b3..c05c9a0 100644 (file)
@@ -165,7 +165,9 @@ demo_cmdbuf(uint64_t *buf, size_t size,
             uint32_t pipeline_null,
             uint32_t pipeline_clear,
             uint32_t pipeline_store,
-            bool clear_pipeline_textures)
+            bool clear_pipeline_textures,
+            double clear_depth,
+            unsigned clear_stencil)
 {
    uint32_t *map = (uint32_t *) buf;
    memset(map, 0, 518 * 4);
@@ -233,8 +235,8 @@ demo_cmdbuf(uint64_t *buf, size_t size,
    }
 
    agx_pack(map + 292, IOGPU_CLEAR_Z_S, cfg) {
-      cfg.depth_clear_value = fui(1.0); // TODO
-      cfg.stencil_clear_value = 0;
+      cfg.depth_clear_value = fui(clear_depth);
+      cfg.stencil_clear_value = clear_stencil;
    }
 
    map[312] = 0xffff8212;
index 506784b..c405cbe 100644 (file)
@@ -34,7 +34,9 @@ demo_cmdbuf(uint64_t *buf, size_t size,
             uint32_t pipeline_null,
             uint32_t pipeline_clear,
             uint32_t pipeline_store,
-            bool clear_pipeline_textures);
+            bool clear_pipeline_textures,
+            double clear_depth,
+            unsigned clear_stencil);
 
 void
 demo_mem_map(void *map, size_t size, unsigned *handles,