zink: rewrite queue dispatch to use monotonic batch ids instead of hardcoded ones
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Thu, 5 Nov 2020 17:39:50 +0000 (12:39 -0500)
committerMarge Bot <eric+marge@anholt.net>
Fri, 19 Mar 2021 20:16:02 +0000 (20:16 +0000)
commit60ea60ec4deaf42c55bd8367a15cb0ab885d662e
tree98c049f2e3f978e76161f3c7043e95d9f00b3992
parenta06958278f98e69611e7c58d2a89baa842150c42
zink: rewrite queue dispatch to use monotonic batch ids instead of hardcoded ones

historically zink has been bound to 4 gfx batches and then a separate compute batch
was added. this is not ideal for a number of reasons, the primary one being that if
an application performs 5 glFlush commands, the fifth one will force a gpu stall

this patch aims to do the following, all of which are necessarily done in the same patch
because they can't be added incrementally and still have the same function:
* rewrite batch tracking for resources/views/queries/descriptors/...
  |originally this was done with a single uint32_t as a bitmask, but that becomes cumbersome
   to track as batch counts increase, not to mention it becomes doubly-annoying
   when factoring in separate compute batches with their own ids. zink_batch_usage gives
   us separate tracking for gfx and compute batches along with a standardized api for
   managing usage
* flatten batch objects to a gfx batch and a compute batch
  |these are separate queues, so we can use an enum to choose between an array[2] of
   all batch-related objects
* switch to monotonic batch ids with batch "states"
  |with the flattened queues, we can just use monotonic uints to represent batch ids,
   thus freeing us from constantly using bitfield operations here and also enabling
   batch counts to scale dynamically by allocating/caching "states" that represent a batch
   for a given queue

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9547>
14 files changed:
src/gallium/drivers/zink/zink_batch.c
src/gallium/drivers/zink/zink_batch.h
src/gallium/drivers/zink/zink_clear.c
src/gallium/drivers/zink/zink_context.c
src/gallium/drivers/zink/zink_context.h
src/gallium/drivers/zink/zink_descriptors.c
src/gallium/drivers/zink/zink_descriptors.h
src/gallium/drivers/zink/zink_draw.c
src/gallium/drivers/zink/zink_fence.c
src/gallium/drivers/zink/zink_fence.h
src/gallium/drivers/zink/zink_query.c
src/gallium/drivers/zink/zink_resource.c
src/gallium/drivers/zink/zink_resource.h
src/gallium/drivers/zink/zink_surface.h