Skip to content

spirv: Rework our handling of composite types

Faith Ekstrand requested to merge gfxstrand/mesa:review/spirv-composites into master

SPIR-V is heavily based on LLVM. As such, allows you to have SSA values which are composite types, i.e. arrays and structs containing other types. NIR, on the other hand, only supports vectors and scalars as SSA values. The way we've handled this mismatch is via vtn_ssa_value which is a tree data structure where each leaf contains a nir_ssa_def. This lets us make composite types of any combination of numeric types but it didn't previously handle pointers, images, samplers, or sampled images.

This MR reworks a bunch of things to slowly move us towards being able to handle more types of SSA values in a more generic way. By the end of this MR, we should be able to handle composites containing pointers, images, samplers, and sampled images. The one type we can't really handle is texel pointers. However, the SPIR-V spec guarantees that each thing which takes a texel pointer must take the exact SPIR-V value which is produced by the OpTexelPointer opcode.

Many of the patches in this MR are fairly simple refactors and clean-ups. Here are the most notable ones:

  • spirv: Simplify our handling of NonUniform
  • spirv: Hand-roll fewer vtn_ssa_value creations
  • spirv: Add better checks for SSA value types
  • spirv: Add a helper for getting the NIR type of a vtn_type
  • spirv: More heavily use vtn_ssa_value in function parameter handling
  • spirv: Rework our handling of images and samplers

Merge request reports