d3d12: Reuse sampler tables inside of a batch
authorGiancarlo Devich <giancarlodevich@live.com>
Tue, 10 Jan 2023 17:35:39 +0000 (09:35 -0800)
committerMarge Bot <emma+marge@anholt.net>
Wed, 11 Jan 2023 05:22:45 +0000 (05:22 +0000)
commit54088f4bb5276c792794fc98df981c35ffc6815c
treef48aa8f4a2345e213fe6c02e89d46c7693f08e45
parent32b23d8fb21d13ccd84da131070cc6c9bca137d5
d3d12: Reuse sampler tables inside of a batch

If a shader's sampler state is dirty often, the sampler descriptor heap
can get used up quickly, forcing flushing. If that happens quickly, we
run out of batches and have to wait for batches to finish on the GPU.

When this happens, it is often because the sampler state is switching,
not because it's truly unique. This change hashes and saves sampler
descriptor tables that can be reused in subsequent draws in the same
batch, instead of re-copying the same descriptors and consuming the
heap.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20618>
src/gallium/drivers/d3d12/d3d12_batch.cpp
src/gallium/drivers/d3d12/d3d12_batch.h
src/gallium/drivers/d3d12/d3d12_draw.cpp