microsoft/compiler: Make input_mappings immune to driver_location holes
authorBoris Brezillon <boris.brezillon@collabora.com>
Thu, 28 Apr 2022 17:27:17 +0000 (10:27 -0700)
committerMarge Bot <emma+marge@anholt.net>
Wed, 8 Jun 2022 15:17:05 +0000 (15:17 +0000)
commitd3e321c85317646efd14a01f14dba9fd2d92cd20
tree6d634ef84c06ca2f2c742f255c9d85a8a74ce7ab
parente8fd20da90759ebcf9f8837914b14aeab1c640c1
microsoft/compiler: Make input_mappings immune to driver_location holes

Right now, nir_to_dxil() assumes driver_location on inputs will be
contiguous, which is true for GL, and also true for Vulkan shaders
with the current implementation. But we are trying to delegate
the varying linking step to Dozen, and that means the driver will
assign the driver_location field.

For everything except vertex shaders this works fine, because we
are in control of the ID we assign to each variable, and can make
sure no holes exists in this assignment, but vertex inputs expect
the index value (which is directly extracted from the
driver_location field) to match the input index defined at pipeline
creation time. The compiler has a hack to treat Vulkan differently
and extract the index from the var->data.location field instead,
but that's a bit confusing.

Moreover, the input_mappings[] array is already indexed with
the var->data.driver_location field in the input load emission
path, so it makes sense to index it with the same field when
emitting signatures.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16221>
src/microsoft/compiler/dxil_module.h
src/microsoft/compiler/dxil_signature.c