freedreno: Handle full blit discards by invalidating the resource.
authorEmma Anholt <emma@anholt.net>
Thu, 17 Jun 2021 16:50:15 +0000 (09:50 -0700)
committerMarge Bot <eric+marge@anholt.net>
Mon, 21 Jun 2021 20:48:21 +0000 (20:48 +0000)
commit58f5605124a74eeac6a6156b093c9f098bb99c78
treed1e292bd1370f45c8dff287f2ebfdb718c2db7df
parent74ede4b353bcac7451a56c75712e25151f7c6b63
freedreno: Handle full blit discards by invalidating the resource.

The previous implementation had several issues:

- It wasn't checking all the conditions necessary for "this blit updates
  the whole surface", like PIPE_MASK_Z but not S on a depth/stencil
  buffer.
- It would reset the previous batchbuffer, even if that batch had side
  effects on other buffers.
- The layering was painful to follow and made any recursion extra
  dangerous.

Now, we use a more conservative test (enough for the resource shadowing
case) and just invalidate the buffer up front, which should have the right
logic for discarding drawing to that resource.

I found I had to add fd_bc_flush_writer() to the end of fd_blitter_blit()
-- a flush was happening at fb state restore time when the discard flag
was set, and losing that flush breaks
dEQP-GLES31.functional.stencil_texturing.format.stencil_index8_cube.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11455>
src/freedreno/ci/deqp-freedreno-a530-fails.txt
src/gallium/drivers/freedreno/freedreno_autotune.c
src/gallium/drivers/freedreno/freedreno_batch.h
src/gallium/drivers/freedreno/freedreno_blitter.c
src/gallium/drivers/freedreno/freedreno_context.h
src/gallium/drivers/freedreno/freedreno_draw.c
src/gallium/drivers/freedreno/freedreno_state.c