v3d,v3dv: stop trying to force 16-bit TMU output for shadow comparisons
authorIago Toral Quiroga <itoral@igalia.com>
Mon, 3 Apr 2023 08:16:16 +0000 (10:16 +0200)
committerMarge Bot <emma+marge@anholt.net>
Wed, 5 Apr 2023 06:52:51 +0000 (06:52 +0000)
commit9217c565b2871ba377f23adc571cbe85b6a90c1f
treeef933107975fbf01fde65c9c52b871bd71120b1c
parent1bbbdbe6663a582150aff05f78f4b7ce36c69ce8
v3d,v3dv: stop trying to force 16-bit TMU output for shadow comparisons

In V3D we were doing this incorrectly by peeking into the sampler state
unconditionally, which is not correct if the TMU operations don't use
sampler state at all (like PBOs). This was causing us to fail the second
test in this sequence when both tests run back back to back in the same
process:

dEQP-GLES3.functional.texture.shadow.2d.linear.greater_or_equal_depth_component32f
dEQP-GLES3.functional.texture.specification.teximage2d_pbo.rg32f_cube

Here, the first test would setup sampler state for shadow comparisons and
the second test would setup a PBO upload, which would incorrectly pick
up the sampler state to decide about the TMU output size for the PBO
operation.

In V3DV we were doing this right looking through each texture/sampler
instruction and checking if they all involved shadow comparisons or had
relaxed precission, defaulting to 32-bit otherwise.

This special-casing for shadow comparisons also leaks from drivers
into the compiler where we are forced to emit some pieces of sampler
state for 32-bit outputs, so we had to special-case shadow instructions
there as well and we also had a fix for CS textures not having correct
sampler state representing shadow operations too. Finally,
we also had  at least a couple of bugs where forcing 32-bit TMU output
through V3D_DEBUG wasn't correctly forcing shadow comparisons to actually
be 32-bit in all the right places, leading to visual bugs with the
option enabled (Sponza being one example of this). This change eliminates
all of these issues.

Finally, the performance improvement observed from special casing shadow
comparison is negligible, and in specific scenarios it can even be
detrimental to performance due to increased register pressure (Sponza with
PCF filtering set to 4 is an example of this again).

Fixes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/8684
Reviewed-by: Alejandro PiƱeiro <apinheiro@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22284>
src/broadcom/compiler/v3d40_tex.c
src/broadcom/compiler/vir.c
src/broadcom/vulkan/v3dv_pipeline.c
src/gallium/drivers/v3d/v3d_context.h
src/gallium/drivers/v3d/v3d_formats.c
src/gallium/drivers/v3d/v3d_program.c
src/gallium/drivers/v3d/v3dx_emit.c
src/gallium/drivers/v3d/v3dx_state.c