glsl_type: Add support for explicitly laid out matrices and arrays

Graphics / Mesa 3D Graphics Library / Mesa - Jason Ekstrand [intel.com] - 8 January 2019 00:38 EST

SPIR-V allows for matrix and array types to be decorated with explicit byte stride decorations and matrix types to be decorated row- or column-major. This commit adds support to glsl_type to encode this information. Because this doesn't work nicely with std430 and std140 alignments, we add asserts to ensure that we don't use any of the std430 or std140 layout functions with explicitly laid out types.

In SPIR-V, the layout information for matrices is applied to the parent struct member instead of to the matrix type itself. However, this is gets rather clumsy when you're walking derefs trying to compute offsets because, the moment you hit a matrix, you have to crawl back the deref chain and find the struct. Instead, we take the same path here as we've taken in spirv_to_nir and put the decorations on the matrix type itself.

This also subtly adds support for strided vector types. These don't come up in SPIR-V directly but you can get one as the result of taking a column from a row-major matrix or a row from a column-major matrix.

6cebeb4f71 glsl_type: Add support for explicitly laid out matrices and arrays
src/compiler/glsl/gl_nir_lower_samplers_as_deref.c | 2 +-
src/compiler/glsl_types.cpp | 170 ++++++++++++++++++---
src/compiler/glsl_types.h | 51 +++++--
src/compiler/nir/nir_lower_atomics_to_ssbo.c | 2 +-
.../nir/nir_lower_clip_cull_distance_arrays.c | 4 +-
src/compiler/nir/nir_lower_io_arrays_to_elements.c | 9 +-
src/compiler/nir/nir_split_per_member_structs.c | 3 +-
src/compiler/nir/nir_split_vars.c | 9 +-
src/compiler/nir_types.cpp | 40 ++++-
src/compiler/nir_types.h | 11 +-
src/compiler/spirv/spirv_to_nir.c | 2 +-
src/compiler/spirv/vtn_variables.c | 3 +-
src/gallium/auxiliary/nir/tgsi_to_nir.c | 4 +-
src/intel/vulkan/anv_nir_lower_multiview.c | 2 +-
src/mesa/program/prog_to_nir.c | 2 +-
15 files changed, 258 insertions(+), 56 deletions(-)

Upstream: cgit.freedesktop.org


  • Share