|
| 1 | +From d2fb6879a2934de03323b9c72b2f4987b2bc38d9 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Alyssa Rosenzweig <alyssa@collabora.com> |
| 3 | +Date: Sat, 15 Jan 2022 10:29:11 -0500 |
| 4 | +Subject: [PATCH] panfrost: Process scissor state earlier |
| 5 | + |
| 6 | +Otherwise, if batch->scissor_culls_everything is set for a single draw, |
| 7 | +every draw after it in the batch will be skipped because the new |
| 8 | +scissor/viewport state will never be processed. Process scissor state |
| 9 | +early in draw_vbo to fix this interaction. |
| 10 | + |
| 11 | +We do need to be careful: setting something on the batch can only happen when |
| 12 | +we've decided on a batch. If we have to select a fresh batch due to too many |
| 13 | +draws, that must happen first. This is pretty clear in the code but worth noting |
| 14 | +for the diff. |
| 15 | + |
| 16 | +Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com> |
| 17 | +Reported-by: Icecream95 <ixn@disroot.org> |
| 18 | +Reviewed-by: Icecream95 <ixn@disroot.org> |
| 19 | +Fixes: 79356b2e ("panfrost: Skip rasterizer discard draws without side effects") |
| 20 | +Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5839 |
| 21 | +Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6136 |
| 22 | +Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15365> |
| 23 | +--- |
| 24 | + src/gallium/drivers/panfrost/pan_cmdstream.c | 22 ++++++++++++-------- |
| 25 | + src/panfrost/ci/panfrost-g52-fails.txt | 1 - |
| 26 | + 2 files changed, 13 insertions(+), 10 deletions(-) |
| 27 | + |
| 28 | +diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c |
| 29 | +index 8af81f4b9f5..0f23da2b12e 100644 |
| 30 | +--- a/src/gallium/drivers/panfrost/pan_cmdstream.c |
| 31 | ++++ b/src/gallium/drivers/panfrost/pan_cmdstream.c |
| 32 | +@@ -2642,9 +2642,6 @@ panfrost_update_state_3d(struct panfrost_batch *batch) |
| 33 | + { |
| 34 | + unsigned dirty = batch->ctx->dirty; |
| 35 | + |
| 36 | +- if (dirty & (PAN_DIRTY_VIEWPORT | PAN_DIRTY_SCISSOR)) |
| 37 | +- batch->viewport = panfrost_emit_viewport(batch); |
| 38 | +- |
| 39 | + if (dirty & PAN_DIRTY_TLS_SIZE) |
| 40 | + panfrost_batch_adjust_stack_size(batch); |
| 41 | + } |
| 42 | +@@ -3144,6 +3141,19 @@ panfrost_draw_vbo(struct pipe_context *pipe, |
| 43 | + /* Do some common setup */ |
| 44 | + struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx); |
| 45 | + |
| 46 | ++ /* Don't add too many jobs to a single batch. Hardware has a hard limit |
| 47 | ++ * of 65536 jobs, but we choose a smaller soft limit (arbitrary) to |
| 48 | ++ * avoid the risk of timeouts. This might not be a good idea. */ |
| 49 | ++ if (unlikely(batch->scoreboard.job_index > 10000)) |
| 50 | ++ batch = panfrost_get_fresh_batch_for_fbo(ctx, "Too many draws"); |
| 51 | ++ |
| 52 | ++ /* panfrost_batch_skip_rasterization reads |
| 53 | ++ * batch->scissor_culls_everything, which is set by |
| 54 | ++ * panfrost_emit_viewport, so call that first. |
| 55 | ++ */ |
| 56 | ++ if (ctx->dirty & (PAN_DIRTY_VIEWPORT | PAN_DIRTY_SCISSOR)) |
| 57 | ++ batch->viewport = panfrost_emit_viewport(batch); |
| 58 | ++ |
| 59 | + /* If rasterization discard is enabled but the vertex shader does not |
| 60 | + * have side effects (including transform feedback), skip the draw |
| 61 | + * altogether. This is always an optimization. Additionally, this is |
| 62 | +@@ -3160,12 +3170,6 @@ panfrost_draw_vbo(struct pipe_context *pipe, |
| 63 | + return; |
| 64 | + } |
| 65 | + |
| 66 | +- /* Don't add too many jobs to a single batch. Hardware has a hard limit |
| 67 | +- * of 65536 jobs, but we choose a smaller soft limit (arbitrary) to |
| 68 | +- * avoid the risk of timeouts. This might not be a good idea. */ |
| 69 | +- if (unlikely(batch->scoreboard.job_index > 10000)) |
| 70 | +- batch = panfrost_get_fresh_batch_for_fbo(ctx, "Too many draws"); |
| 71 | +- |
| 72 | + unsigned zs_draws = ctx->depth_stencil->draws; |
| 73 | + batch->draws |= zs_draws; |
| 74 | + batch->resolve |= zs_draws; |
| 75 | +diff --git a/src/panfrost/ci/panfrost-g52-fails.txt b/src/panfrost/ci/panfrost-g52-fails.txt |
| 76 | +index 07be170f72e..68a2d677df8 100644 |
| 77 | +--- a/src/panfrost/ci/panfrost-g52-fails.txt |
| 78 | ++++ b/src/panfrost/ci/panfrost-g52-fails.txt |
| 79 | +@@ -583,7 +583,6 @@ spec@!opengl 2.1@pbo@test_polygon_stip,Fail |
| 80 | + spec@!opengl 2.1@polygon-stipple-fs,Fail |
| 81 | + spec@!opengl 3.0@gl-3.0-vertexattribipointer,Fail |
| 82 | + spec@!opengl 3.0@required-texture-attachment-formats,Fail |
| 83 | +-spec@!opengl 3.0@viewport-clamp,Crash |
| 84 | + spec@!opengl 3.1@primitive-restart-xfb flush,Fail |
| 85 | + spec@!opengl 3.1@primitive-restart-xfb generated,Fail |
| 86 | + spec@!opengl 3.1@primitive-restart-xfb written,Fail |
0 commit comments