nv50/ir: Rework conversions for texture array indices
authorFaith Ekstrand <faith.ekstrand@collabora.com>
Wed, 9 Aug 2023 21:59:00 +0000 (16:59 -0500)
committerMarge Bot <emma+marge@anholt.net>
Fri, 11 Aug 2023 06:02:23 +0000 (06:02 +0000)
commit9f767db1265e2fffb8886d608eba9dd1220547df
treef22672e49096e4cea40301425fe7ee5910a5314c
parent585f0e8b48987d32a40243acec573c5cc5b50dbe
nv50/ir: Rework conversions for texture array indices

Currently, negative array texture indices get saturated to 0 which,
while technically in-bounds, isn't what we want for Vulkan with image
robustness or robustness2.  Vulkan requires that a negative index on a
texelFetch() count as out-of-bounds but a negative index on any other
texture operation gets clamped to 0.  (See the spec section entitled
"(u,v,w,a) to (i,j,k,l,n) Transformation And Array Layer Selection").

Instead of using CVT for TXF, we now take U32 MAX with 0xffff. Because
it's unsigned, this ensures that negative array indices clamp to 0xffff
and will be considered out-of-bounds by the hardware (there are a
maximum of 2048 array indices in an image descriptor).  For everything
other than TXF, we keep using an F32->U16 conversion but add a saturate.
This ensures that negative array indices clamp to 0 as per the Vulkan
spec.  Very large indices will clamp to 0xffff which the hardware will
clamp to the maximum array index.

This fixes 324 tests in the dEQP-VK.robustness.* group, all those for 1D
and 2D array textures

Acked-by: M Henning <drawoc@darkrefraction.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24593>
src/nouveau/codegen/nv50_ir_lowering_nvc0.cpp