This patch series is the first of many that I will be sending out in the next few weeks in an attempt to land SPIR-V support. While the SPIR-V code to test said patches does not exist in mesa yet, they will be piglited and most of said patches have been baking, in one for or another, for quite some time in my SPIR-V branch which is working rather well. This series is a notable exception in that rule; hence the RFC status. I only just cooked it up today but I believe it will solve one of the fundamental problems in my current SPIR-V implementation: that of passing textures into functions. I also think it cleans some things up in NIR rather nicely.
The fundamental idea is to allow for load_var intrinsics to be used on sampler types. The result of the load_var is defined to be the sampler index which is passed directly into the sampler_offset source of the tex innstruction. This also has the advantage of getting rid of all of the special-casing of texture instructions and their sampler parameters. But does it work? What happens if someone tries to do something algebraic with that value? Well, they can't. There's nothing that, following the GLSL rules, will introduce such a thing. If, for instance, we're in the case where someone passes it through a couple of layers of functions then, after function inlining and copy-propagation, the texture instruction will source from the load_var directly again and off we go. As one more side-note, I would eventually like to get rid of the awkward index+offset thing that we're using in texture instructions with just an index field like we have for other loads. Unfortunately, we need the base index for state-based shader recompiles. One of these days, on my very long list of things to do, I'd like to make recompiles safe for indirects on array textures and then, maybe, we can just have an index. Cc: Connor Abbott <cwabbo...@gmail.com> Jason Ekstrand (6): nir: Add a helper for copying a deref_var nir/builder: Add a helper for loading from a deref_var nir/types: Advertise 1 vector component for sampler types i965/nir: Lower samplers before uniforms nir: Replace tex_instr.array_size with max_sampler_index nir: Rework the way texture instructions reference samplers src/compiler/nir/glsl_to_nir.cpp | 35 ++++++++------- src/compiler/nir/nir.c | 13 ++---- src/compiler/nir/nir.h | 7 ++- src/compiler/nir/nir_builder.h | 15 +++++++ src/compiler/nir/nir_clone.c | 4 +- src/compiler/nir/nir_instr_set.c | 19 ++------ src/compiler/nir/nir_lower_samplers.c | 61 +++++++++++++------------- src/compiler/nir/nir_lower_var_copies.c | 4 +- src/compiler/nir/nir_opt_constant_folding.c | 5 +-- src/compiler/nir/nir_print.c | 6 +-- src/compiler/nir/nir_remove_dead_variables.c | 13 ------ src/compiler/nir/nir_validate.c | 7 +-- src/compiler/nir_types.cpp | 5 ++- src/gallium/drivers/vc4/vc4_nir_lower_txf_ms.c | 1 - src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 2 +- src/mesa/drivers/dri/i965/brw_nir.c | 6 +-- src/mesa/drivers/dri/i965/brw_vec4_nir.cpp | 3 +- 17 files changed, 90 insertions(+), 116 deletions(-) -- 2.5.0.400.gff86faf _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev