diff --git a/src/asahi/lib/cmdbuf.xml b/src/asahi/lib/cmdbuf.xml
index 980ae68c3c1..cff6a6c7401 100644
--- a/src/asahi/lib/cmdbuf.xml
+++ b/src/asahi/lib/cmdbuf.xml
@@ -676,8 +676,8 @@
-
-
+
+
diff --git a/src/gallium/drivers/asahi/agx_pipe.c b/src/gallium/drivers/asahi/agx_pipe.c
index 4a35eb57025..6cd80506755 100644
--- a/src/gallium/drivers/asahi/agx_pipe.c
+++ b/src/gallium/drivers/asahi/agx_pipe.c
@@ -542,6 +542,7 @@ agx_flush(struct pipe_context *pctx,
pipeline_reload,
pipeline_store,
clear_pipeline_textures,
+ ctx->batch->clear,
ctx->batch->clear_depth,
ctx->batch->clear_stencil);
diff --git a/src/gallium/drivers/asahi/magic.c b/src/gallium/drivers/asahi/magic.c
index 5b8db485a4c..9683b6bc76a 100644
--- a/src/gallium/drivers/asahi/magic.c
+++ b/src/gallium/drivers/asahi/magic.c
@@ -167,9 +167,13 @@ demo_cmdbuf(uint64_t *buf, size_t size,
uint32_t pipeline_load,
uint32_t pipeline_store,
bool clear_pipeline_textures,
+ unsigned clear_buffers,
double clear_depth,
unsigned clear_stencil)
{
+ bool should_clear_depth = clear_buffers & PIPE_CLEAR_DEPTH;
+ bool should_clear_stencil = clear_buffers & PIPE_CLEAR_STENCIL;
+
uint32_t *map = (uint32_t *) buf;
memset(map, 0, 518 * 4);
@@ -197,25 +201,31 @@ demo_cmdbuf(uint64_t *buf, size_t size,
const struct util_format_description *desc =
util_format_description(zsbuf->texture->format);
- // note: setting 0x4 bit here breaks partial render with depth
- cfg.depth_flags = 0x80000; // no compression, clear
-
cfg.depth_width = framebuffer->width;
cfg.depth_height = framebuffer->height;
if (util_format_has_depth(desc)) {
depth_buffer = agx_map_surface(zsbuf);
+
+ cfg.depth_reload = !should_clear_depth;
+ cfg.depth_flags |= 0x80000;
+ if (!should_clear_depth) cfg.depth_flags |= 0x8000;
} else {
stencil_buffer = agx_map_surface(zsbuf);
+ cfg.depth_flags |= 0x40000;
+ if (!should_clear_stencil) cfg.depth_flags |= 0x4000;
}
if (agx_resource(zsbuf->texture)->separate_stencil) {
stencil_buffer = agx_map_surface_resource(zsbuf,
agx_resource(zsbuf->texture)->separate_stencil);
+
+ cfg.depth_flags |= 0x40000;
+ if (!should_clear_stencil) cfg.depth_flags |= 0x4000;
}
+ cfg.depth_buffer_if_clearing = depth_buffer;
cfg.stencil_buffer = stencil_buffer;
- cfg.stencil_buffer_2 = stencil_buffer;
/* It's unclear how tile size is conveyed for depth/stencil targets,
* which interactions with mipmapping (for example of a 33x33
@@ -225,7 +235,7 @@ demo_cmdbuf(uint64_t *buf, size_t size,
unreachable("todo: mapping other levels");
cfg.depth_buffer = depth_buffer;
- cfg.depth_buffer_if_clearing = depth_buffer;
+ cfg.stencil_buffer_2 = stencil_buffer;
}
}
@@ -236,7 +246,17 @@ demo_cmdbuf(uint64_t *buf, size_t size,
}
agx_pack(map + 292, IOGPU_CLEAR_Z_S, cfg) {
- cfg.set_when_reloading_z_1 = clear_pipeline_textures;
+ cfg.set_when_reloading_z_or_s_1 = clear_pipeline_textures;
+
+ if (depth_buffer && !should_clear_depth) {
+ cfg.set_when_reloading_z_or_s_1 = true;
+ cfg.set_when_reloading_z_or_s_2 = true;
+ }
+
+ if (stencil_buffer && !should_clear_stencil) {
+ cfg.set_when_reloading_z_or_s_1 = true;
+ cfg.set_when_reloading_z_or_s_2 = true;
+ }
cfg.depth_clear_value = fui(clear_depth);
cfg.stencil_clear_value = clear_stencil & 0xff;
diff --git a/src/gallium/drivers/asahi/magic.h b/src/gallium/drivers/asahi/magic.h
index 1fd3184f687..0231afdc291 100644
--- a/src/gallium/drivers/asahi/magic.h
+++ b/src/gallium/drivers/asahi/magic.h
@@ -36,6 +36,7 @@ demo_cmdbuf(uint64_t *buf, size_t size,
uint32_t pipeline_load,
uint32_t pipeline_store,
bool clear_pipeline_textures,
+ unsigned clear_buffers,
double clear_depth,
unsigned clear_stencil);