diff options
author | Eric Anholt <[email protected]> | 2016-09-09 16:26:02 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2016-09-14 06:08:03 +0100 |
commit | 21a27ad9569211e48cfd7ad60ac4025ab9f96a7a (patch) | |
tree | ebee02695592977350ba855b535ab71c28668984 /src/gallium/drivers/vc4/vc4_draw.c | |
parent | 89a49af31ef3ae4adbef54131d65f8a407a83eaa (diff) |
vc4: Fix incorrect clearing of Z/stencil when cleared separately.
The clear of Z or stencil will end up clearing the other as well, instead
of masking. There's no way around this that I know of, so if we are
clearing just one then we need to draw a quad.
Fixes a regression in the job-shuffling code, where the clear values move
to the job and don't just have the last clear's value laying around when
you do glClear(DEPTH) and then glClear(STENCIL) separately
(ext_framebuffer_multisample-clear 4 depth)).
This causes regressions in ext_framebuffer_multisample/multisample-blit
depth and ext_framebuffer_multisample/no-color depth, but these were
formerly false positives due to the reference image also being black. Now
the reference and test images are both being drawn, and it looks like
there's an incorrect resolve of depth during blitting to an MSAA FBO.
Diffstat (limited to 'src/gallium/drivers/vc4/vc4_draw.c')
-rw-r--r-- | src/gallium/drivers/vc4/vc4_draw.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/gallium/drivers/vc4/vc4_draw.c b/src/gallium/drivers/vc4/vc4_draw.c index 773caf785ec..9770abf242d 100644 --- a/src/gallium/drivers/vc4/vc4_draw.c +++ b/src/gallium/drivers/vc4/vc4_draw.c @@ -22,6 +22,7 @@ * IN THE SOFTWARE. */ +#include "util/u_blitter.h" #include "util/u_prim.h" #include "util/u_format.h" #include "util/u_pack_color.h" @@ -468,21 +469,37 @@ vc4_clear(struct pipe_context *pctx, unsigned buffers, vc4_flush(pctx); } + /* Clearing ZS will clear both Z and stencil, so if we're trying to + * clear just one then we need to draw a quad to do it instead. + */ + if ((buffers & PIPE_CLEAR_DEPTHSTENCIL) != 0 && + (buffers & PIPE_CLEAR_DEPTHSTENCIL) != PIPE_CLEAR_DEPTHSTENCIL && + util_format_is_depth_and_stencil(vc4->framebuffer.zsbuf->format)) { + vc4_blitter_save(vc4); + util_blitter_clear(vc4->blitter, + vc4->framebuffer.width, + vc4->framebuffer.height, + 1, + buffers & PIPE_CLEAR_DEPTHSTENCIL, + NULL, depth, stencil); + buffers &= ~PIPE_CLEAR_DEPTHSTENCIL; + if (!buffers) + return; + } + if (buffers & PIPE_CLEAR_COLOR0) { vc4->clear_color[0] = vc4->clear_color[1] = pack_rgba(vc4->framebuffer.cbufs[0]->format, color->f); } - if (buffers & PIPE_CLEAR_DEPTH) { + if (buffers & PIPE_CLEAR_DEPTHSTENCIL) { /* Though the depth buffer is stored with Z in the high 24, * for this field we just need to store it in the low 24. */ vc4->clear_depth = util_pack_z(PIPE_FORMAT_Z24X8_UNORM, depth); - } - - if (buffers & PIPE_CLEAR_STENCIL) vc4->clear_stencil = stencil; + } vc4->draw_min_x = 0; vc4->draw_min_y = 0; |