From 8b46e23ef278701607110c0307afa098c1eba41a Mon Sep 17 00:00:00 2001 From: Emma Anholt Date: Wed, 3 Nov 2021 09:19:42 -0700 Subject: [PATCH] freedreno: Fix gmem invalidating the depth or stencil of packed d/s. The gmem store stores both depth and stencil for z24s8. So, if we're doing a write (clear or draw) to one or the other of the channels, we need the other one restored as well. Cc: mesa-stable Part-of: (cherry picked from commit 29093bc42d20e95288cd306757e7efc928fdb366) --- .pick_status.json | 2 +- src/freedreno/ci/freedreno-a530-fails.txt | 1 - src/freedreno/ci/freedreno-a630-fails.txt | 5 ----- src/gallium/drivers/freedreno/freedreno_draw.c | 10 ++++++++++ 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index d0774519cf6..d37863feb0e 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -2119,7 +2119,7 @@ "description": "freedreno: Fix gmem invalidating the depth or stencil of packed d/s.", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null }, diff --git a/src/freedreno/ci/freedreno-a530-fails.txt b/src/freedreno/ci/freedreno-a530-fails.txt index e746dd66a9f..f493e646de4 100644 --- a/src/freedreno/ci/freedreno-a530-fails.txt +++ b/src/freedreno/ci/freedreno-a530-fails.txt @@ -158,7 +158,6 @@ KHR-GLES3.copy_tex_image_conversions.required.texture3d_texture2d,Fail KHR-GLES3.packed_depth_stencil.blit.depth24_stencil8,Fail KHR-GLES3.packed_depth_stencil.blit.depth32f_stencil8,Fail -KHR-GLES3.packed_depth_stencil.verify_read_pixels.depth24_stencil8,Fail # "Non-integer comparison: 1, 0, 18, 1e-05: 0.142857 == 0: not equal. # Copy stage: Gradient comparison failed during ReadPixels for input = [GL_RG, GL_FLOAT] output = [GL_RED, GL_FLOAT]" diff --git a/src/freedreno/ci/freedreno-a630-fails.txt b/src/freedreno/ci/freedreno-a630-fails.txt index 362e0db3d3f..1ef238e0ff8 100644 --- a/src/freedreno/ci/freedreno-a630-fails.txt +++ b/src/freedreno/ci/freedreno-a630-fails.txt @@ -1,8 +1,6 @@ # New in VK-GL-CTS 1.2.7.0 KHR-GL33.cull_distance.coverage,Fail -KHR-GL33.packed_depth_stencil.verify_get_tex_image.depth24_stencil8,Fail -KHR-GL33.packed_depth_stencil.verify_read_pixels.depth24_stencil8,Fail KHR-GL33.transform_feedback.capture_vertex_interleaved_test,Fail KHR-GL33.transform_feedback.capture_vertex_separate_test,Fail KHR-GL33.transform_feedback.discard_vertex_test,Fail @@ -11,9 +9,6 @@ KHR-GL33.transform_feedback.draw_xfb_stream_instanced_test,Crash KHR-GL33.transform_feedback.query_vertex_interleaved_test,Fail KHR-GL33.transform_feedback.query_vertex_separate_test,Fail -# "*** Color comparison failed" -KHR-GLES3.packed_depth_stencil.verify_read_pixels.depth24_stencil8,Fail - # "The values of resultStd[i] & 0xFFFFFFFE and resultFma[i] & 0xFFFFFFFE and resultCPU[i] & 0xFFFFFFFE are not bitwise equal for i = 0..99 " KHR-GLES31.core.gpu_shader5.fma_precision_float,Fail KHR-GLES31.core.gpu_shader5.fma_precision_vec2,Fail diff --git a/src/gallium/drivers/freedreno/freedreno_draw.c b/src/gallium/drivers/freedreno/freedreno_draw.c index baa5f2e5530..1a7b0580efa 100644 --- a/src/gallium/drivers/freedreno/freedreno_draw.c +++ b/src/gallium/drivers/freedreno/freedreno_draw.c @@ -69,6 +69,11 @@ batch_draw_tracking_for_dirty_bits(struct fd_batch *batch) assert_dt if (fd_depth_enabled(ctx)) { if (fd_resource(pfb->zsbuf->texture)->valid) { restore_buffers |= FD_BUFFER_DEPTH; + /* storing packed d/s depth also stores stencil, so we need + * the stencil restored too to avoid invalidating it. + */ + if (pfb->zsbuf->texture->format == PIPE_FORMAT_Z24_UNORM_S8_UINT) + restore_buffers |= FD_BUFFER_STENCIL; } else { batch->invalidated |= FD_BUFFER_DEPTH; } @@ -84,6 +89,11 @@ batch_draw_tracking_for_dirty_bits(struct fd_batch *batch) assert_dt if (fd_stencil_enabled(ctx)) { if (fd_resource(pfb->zsbuf->texture)->valid) { restore_buffers |= FD_BUFFER_STENCIL; + /* storing packed d/s stencil also stores depth, so we need + * the depth restored too to avoid invalidating it. + */ + if (pfb->zsbuf->texture->format == PIPE_FORMAT_Z24_UNORM_S8_UINT) + restore_buffers |= FD_BUFFER_DEPTH; } else { batch->invalidated |= FD_BUFFER_STENCIL; }