Commit e4767795 authored by Karol Herbst's avatar Karol Herbst 🐧
Browse files

nir: rework system values lowering


Signed-off-by: Karol Herbst's avatarKarol Herbst <kherbst@redhat.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> (gallium/nir bits)
parent fd91744b
Pipeline #183955 waiting for manual action with stages
......@@ -50,7 +50,6 @@
#include "util/string_buffer.h"
static const struct nir_shader_compiler_options nir_options_llvm = {
.vertex_id_zero_based = true,
.lower_scmp = true,
.lower_flrp16 = true,
.lower_flrp32 = true,
......@@ -93,7 +92,6 @@ static const struct nir_shader_compiler_options nir_options_llvm = {
};
static const struct nir_shader_compiler_options nir_options_aco = {
.vertex_id_zero_based = true,
.lower_scmp = true,
.lower_flrp16 = true,
.lower_flrp32 = true,
......@@ -472,7 +470,10 @@ radv_shader_compile_to_nir(struct radv_device *device,
NIR_PASS_V(nir, nir_propagate_invariant);
NIR_PASS_V(nir, nir_lower_system_values);
nir_lower_system_values_options system_values_options = {
.vertex_id_zero_based = true,
};
NIR_PASS_V(nir, nir_lower_system_values, &system_values_options);
NIR_PASS_V(nir, nir_lower_clip_cull_distance_arrays);
if (device->instance->debug_flags & RADV_DEBUG_DISCARD_TO_DEMOTE)
......
......@@ -2847,7 +2847,6 @@ const nir_shader_compiler_options v3d_nir_options = {
.lower_bitfield_extract_to_shifts = true,
.lower_bitfield_reverse = true,
.lower_bit_count = true,
.lower_cs_local_id_from_index = true,
.lower_ffract = true,
.lower_fmod = true,
.lower_pack_unorm_2x16 = true,
......
......@@ -585,7 +585,10 @@ v3d_lower_nir(struct v3d_compile *c)
}
NIR_PASS_V(c->s, nir_lower_tex, &tex_options);
NIR_PASS_V(c->s, nir_lower_system_values);
nir_lower_system_values_options system_values_options = {
.lower_cs_local_id_from_index = true,
};
NIR_PASS_V(c->s, nir_lower_system_values, &system_values_options);
NIR_PASS_V(c->s, nir_lower_vars_to_scratch,
nir_var_function_temp,
......
......@@ -3015,29 +3015,6 @@ typedef struct nir_shader_compiler_options {
bool lower_all_io_to_temps;
bool lower_all_io_to_elements;
/* Indicates that the driver only has zero-based vertex id */
bool vertex_id_zero_based;
/**
* If enabled, gl_BaseVertex will be lowered as:
* is_indexed_draw (~0/0) & firstvertex
*/
bool lower_base_vertex;
/**
* If enabled, gl_HelperInvocation will be lowered as:
*
* !((1 << sample_id) & sample_mask_in))
*
* This depends on some possibly hw implementation details, which may
* not be true for all hw. In particular that the FS is only executed
* for covered samples or for helper invocations. So, do not blindly
* enable this option.
*
* Note: See also issue #22 in ARB_shader_image_load_store
*/
bool lower_helper_invocation;
/**
* Convert gl_SampleMaskIn to gl_HelperInvocation as follows:
*
......@@ -3046,9 +3023,6 @@ typedef struct nir_shader_compiler_options {
*/
bool optimize_sample_mask_in;
bool lower_cs_local_index_from_id;
bool lower_cs_local_id_from_index;
bool lower_device_index_to_zero;
/* Set if nir_lower_wpos_ytransform() should also invert gl_PointCoord. */
......@@ -4162,7 +4136,36 @@ typedef struct nir_lower_subgroups_options {
bool nir_lower_subgroups(nir_shader *shader,
const nir_lower_subgroups_options *options);
bool nir_lower_system_values(nir_shader *shader);
typedef struct nir_lower_system_values_options {
/* Indicates that the driver only has zero-based vertex id */
bool vertex_id_zero_based;
/**
* If enabled, gl_BaseVertex will be lowered as:
* is_indexed_draw (~0/0) & firstvertex
*/
bool lower_base_vertex;
/**
* If enabled, gl_HelperInvocation will be lowered as:
*
* !((1 << sample_id) & sample_mask_in))
*
* This depends on some possibly hw implementation details, which may
* not be true for all hw. In particular that the FS is only executed
* for covered samples or for helper invocations. So, do not blindly
* enable this option.
*
* Note: See also issue #22 in ARB_shader_image_load_store
*/
bool lower_helper_invocation;
bool lower_cs_local_id_from_index;
bool lower_cs_local_index_from_id;
} nir_lower_system_values_options;
bool nir_lower_system_values(nir_shader *shader,
const nir_lower_system_values_options *options);
enum PACKED nir_lower_tex_packing {
nir_lower_tex_packing_none = 0,
......
......@@ -28,6 +28,10 @@
#include "nir.h"
#include "nir_builder.h"
typedef struct nir_lower_system_value_state {
const nir_lower_system_values_options *options;
} nir_lower_system_value_state;
static nir_ssa_def *
sanitize_32bit_sysval(nir_builder *b, nir_intrinsic_instr *intrin)
{
......@@ -58,6 +62,7 @@ lower_system_value_filter(const nir_instr *instr, const void *_state)
static nir_ssa_def *
lower_system_value_instr(nir_builder *b, nir_instr *instr, void *_state)
{
nir_lower_system_value_state *state = _state;
nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);
/* All the intrinsics we care about are loads */
......@@ -69,7 +74,7 @@ lower_system_value_instr(nir_builder *b, nir_instr *instr, void *_state)
switch (intrin->intrinsic) {
case nir_intrinsic_load_vertex_id:
if (b->shader->options->vertex_id_zero_based) {
if (state->options->vertex_id_zero_based) {
return nir_iadd(b, nir_load_vertex_id_zero_base(b),
nir_load_first_vertex(b));
} else {
......@@ -85,7 +90,7 @@ lower_system_value_instr(nir_builder *b, nir_instr *instr, void *_state)
* invocation. In the case where the command has no baseVertex
* parameter, the value of gl_BaseVertex is zero."
*/
if (b->shader->options->lower_base_vertex) {
if (state->options->lower_base_vertex) {
return nir_iand(b, nir_load_is_indexed_draw(b),
nir_load_first_vertex(b));
} else {
......@@ -96,7 +101,7 @@ lower_system_value_instr(nir_builder *b, nir_instr *instr, void *_state)
/* If lower_cs_local_id_from_index is true, then we derive the local
* index from the local id.
*/
if (b->shader->options->lower_cs_local_id_from_index) {
if (state->options->lower_cs_local_id_from_index) {
/* We lower gl_LocalInvocationID from gl_LocalInvocationIndex based
* on this formula:
*
......@@ -139,7 +144,7 @@ lower_system_value_instr(nir_builder *b, nir_instr *instr, void *_state)
/* If lower_cs_local_index_from_id is true, then we derive the local
* index from the local id.
*/
if (b->shader->options->lower_cs_local_index_from_id) {
if (state->options->lower_cs_local_index_from_id) {
/* From the GLSL man page for gl_LocalInvocationIndex:
*
* "The value of gl_LocalInvocationIndex is equal to
......@@ -212,7 +217,7 @@ lower_system_value_instr(nir_builder *b, nir_instr *instr, void *_state)
}
case nir_intrinsic_load_helper_invocation:
if (b->shader->options->lower_helper_invocation) {
if (state->options->lower_helper_invocation) {
nir_ssa_def *tmp;
tmp = nir_ishl(b, nir_imm_int(b, 1),
nir_load_sample_id_no_per_sample(b));
......@@ -315,12 +320,16 @@ lower_system_value_instr(nir_builder *b, nir_instr *instr, void *_state)
}
bool
nir_lower_system_values(nir_shader *shader)
nir_lower_system_values(nir_shader *shader,
const nir_lower_system_values_options *options)
{
nir_lower_system_value_state state = {
.options = options,
};
bool progress = nir_shader_lower_instructions(shader,
lower_system_value_filter,
lower_system_value_instr,
NULL);
&state);
/* We're going to delete the variables so we need to clean up all those
* derefs we left lying around.
......
......@@ -32,6 +32,11 @@
#include "ir3_compiler.h"
#include "ir3_shader.h"
static const nir_lower_system_values_options system_value_options = {
.vertex_id_zero_based = true,
.lower_helper_invocation = true,
};
static const nir_shader_compiler_options options = {
.lower_fpow = true,
.lower_scmp = true,
......@@ -48,11 +53,9 @@ static const nir_shader_compiler_options options = {
.lower_mul_high = true,
.lower_mul_2x32_64 = true,
.fuse_ffma = true,
.vertex_id_zero_based = true,
.lower_extract_byte = true,
.lower_extract_word = true,
.lower_all_io_to_elements = true,
.lower_helper_invocation = true,
.lower_bitfield_insert_to_shifts = true,
.lower_bitfield_extract_to_shifts = true,
.lower_pack_half_2x16 = true,
......@@ -74,6 +77,11 @@ static const nir_shader_compiler_options options = {
};
/* we don't want to lower vertex_id to _zero_based on newer gpus: */
static const nir_lower_system_values_options system_value_options_a6xx = {
.vertex_id_zero_based = false,
.lower_helper_invocation = true,
};
static const nir_shader_compiler_options options_a6xx = {
.lower_fpow = true,
.lower_scmp = true,
......@@ -90,11 +98,9 @@ static const nir_shader_compiler_options options_a6xx = {
.lower_mul_high = true,
.lower_mul_2x32_64 = true,
.fuse_ffma = true,
.vertex_id_zero_based = false,
.lower_extract_byte = true,
.lower_extract_word = true,
.lower_all_io_to_elements = true,
.lower_helper_invocation = true,
.lower_bitfield_insert_to_shifts = true,
.lower_bitfield_extract_to_shifts = true,
.lower_pack_half_2x16 = true,
......@@ -125,6 +131,14 @@ ir3_get_compiler_options(struct ir3_compiler *compiler)
return &options;
}
const nir_lower_system_values_options *
ir3_get_system_values_options(struct ir3_compiler *compiler)
{
if (compiler->gpu_id >= 600)
return &system_value_options_a6xx;
return &system_value_options;
}
#define OPT(nir, pass, ...) ({ \
bool this_progress = false; \
NIR_PASS(this_progress, nir, pass, ##__VA_ARGS__); \
......@@ -247,6 +261,7 @@ ir3_finalize_nir(struct ir3_compiler *compiler, nir_shader *s)
OPT_V(s, nir_lower_regs_to_ssa);
OPT_V(s, nir_lower_wrmasks, should_split_wrmask, s);
OPT_V(s, nir_lower_system_values, ir3_get_system_values_options(compiler));
OPT_V(s, nir_lower_tex, &tex_options);
OPT_V(s, nir_lower_load_const_to_scalar);
if (compiler->gpu_id < 500)
......
......@@ -52,6 +52,7 @@ void ir3_nir_lower_tess_eval(nir_shader *shader, unsigned topology);
void ir3_nir_lower_gs(nir_shader *shader);
const nir_shader_compiler_options * ir3_get_compiler_options(struct ir3_compiler *compiler);
const nir_lower_system_values_options * ir3_get_system_values_options(struct ir3_compiler *compiler);
void ir3_finalize_nir(struct ir3_compiler *compiler, nir_shader *s);
void ir3_nir_post_finalize(struct ir3_compiler *compiler, nir_shader *s);
void ir3_nir_lower_variant(struct ir3_shader_variant *so, nir_shader *s);
......
......@@ -767,7 +767,6 @@ tu_shader_create(struct tu_device *dev,
nir_assign_io_var_locations(&nir->inputs, &nir->num_inputs, stage);
nir_assign_io_var_locations(&nir->outputs, &nir->num_outputs, stage);
NIR_PASS_V(nir, nir_lower_system_values);
NIR_PASS_V(nir, nir_lower_frexp);
if (stage == MESA_SHADER_FRAGMENT)
......
......@@ -322,6 +322,8 @@ C_SOURCES := \
util/u_viewport.h
NIR_SOURCES := \
nir/pipe_nir.h \
nir/pipe_nir_lower_system_values.c \
nir/tgsi_to_nir.c \
nir/tgsi_to_nir.h \
nir/nir_draw_helpers.c \
......
......@@ -335,6 +335,8 @@ files_libgallium = files(
'util/u_vbuf.h',
'util/u_video.h',
'util/u_viewport.h',
'nir/pipe_nir.h',
'nir/pipe_nir_lower_system_values.c',
'nir/tgsi_to_nir.c',
'nir/tgsi_to_nir.h',
'nir/nir_draw_helpers.c',
......
/*
* Copyright © 2020 Red Hat
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef GA_NIR_H
#define GA_NIR_H
#ifdef __cplusplus
extern "C" {
#endif
struct nir_shader;
bool pipe_nir_lower_system_values(struct nir_shader *, struct pipe_screen *);
#ifdef __cplusplus
}
#endif
#endif /* GA_NIR_H */
/*
* Copyright © 2020 Red Hat
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include "nir.h"
#include "pipe_nir.h"
#include "pipe/p_screen.h"
bool
pipe_nir_lower_system_values(struct nir_shader *nir, struct pipe_screen *screen)
{
const nir_lower_system_values_options options = {
.vertex_id_zero_based = screen->get_param(screen, PIPE_CAP_VERTEXID_NOBASE),
};
return nir_lower_system_values(nir, &options);
}
......@@ -34,6 +34,8 @@
#include "compiler/nir/nir_serialize.h"
#include "compiler/shader_enums.h"
#include "nir/pipe_nir.h"
#include "tgsi_to_nir.h"
#include "tgsi/tgsi_parse.h"
#include "tgsi/tgsi_dump.h"
......@@ -2562,7 +2564,7 @@ ttn_finalize_nir(struct ttn_compile *c, struct pipe_screen *screen)
NIR_PASS_V(nir, nir_lower_global_vars_to_local);
NIR_PASS_V(nir, nir_split_var_copies);
NIR_PASS_V(nir, nir_lower_var_copies);
NIR_PASS_V(nir, nir_lower_system_values);
NIR_PASS_V(nir, pipe_nir_lower_system_values, screen);
if (c->cap_packed_uniforms)
NIR_PASS_V(nir, nir_lower_uniforms_to_ubo, 16);
......
......@@ -155,6 +155,7 @@ etna_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
case PIPE_CAP_MIXED_FRAMEBUFFER_SIZES:
case PIPE_CAP_STRING_MARKER:
case PIPE_CAP_SHAREABLE_SHADERS:
case PIPE_CAP_VERTEXID_NOBASE:
return 1;
case PIPE_CAP_NATIVE_FENCE_FD:
return screen->drm_version >= ETNA_DRM_VERSION_FENCE_FD;
......@@ -1004,7 +1005,6 @@ etna_screen_create(struct etna_device *dev, struct etna_gpu *gpu,
.fuse_ffma = true,
.lower_bitops = true,
.lower_all_io_to_temps = true,
.vertex_id_zero_based = true,
.lower_flrp32 = true,
.lower_fmod = true,
.lower_vector_cmp = true,
......
......@@ -38,7 +38,6 @@ static const nir_shader_compiler_options options = {
.fuse_ffma = true,
/* .fdot_replicates = true, it is replicated, but it makes things worse */
.lower_all_io_to_temps = true,
.vertex_id_zero_based = true, /* its not implemented anyway */
.lower_bitops = true,
.lower_rotate = true,
.lower_vector_cmp = true,
......
......@@ -220,7 +220,7 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
return screen->has_robustness;
case PIPE_CAP_VERTEXID_NOBASE:
return is_a3xx(screen) || is_a4xx(screen);
return is_a3xx(screen) || is_a4xx(screen) || is_a5xx(screen);
case PIPE_CAP_COMPUTE:
return has_compute(screen);
......
......@@ -181,7 +181,7 @@ load_glsl(unsigned num_files, char* const* files, gl_shader_stage stage)
&nir->num_uniforms,
ir3_glsl_type_size);
NIR_PASS_V(nir, nir_lower_system_values);
NIR_PASS_V(nir, nir_lower_system_values, ir3_get_system_values_options(compiler));
NIR_PASS_V(nir, nir_lower_frexp);
NIR_PASS_V(nir, nir_lower_io,
nir_var_shader_in | nir_var_shader_out,
......@@ -481,7 +481,7 @@ int main(int argc, char **argv)
/* TODO do this somewhere else */
nir_lower_int64(nir, ~0);
nir_lower_system_values(nir);
nir_lower_system_values(nir, ir3_get_system_values_options(compiler));
} else if (num_files > 0) {
nir = load_glsl(num_files, filenames, stage);
} else {
......
......@@ -167,7 +167,8 @@ load_glsl(unsigned num_files, char* const* files, gl_shader_stage stage)
&nir->num_uniforms,
st_glsl_type_size);
NIR_PASS_V(nir, nir_lower_system_values);
nir_lower_system_values_options system_values_options = {};
NIR_PASS_V(nir, nir_lower_system_values, &system_values_options);
NIR_PASS_V(nir, nir_lower_frexp);
NIR_PASS_V(nir, gl_nir_lower_samplers, prog);
......
......@@ -3135,6 +3135,12 @@ Converter::run()
.ballot_bit_size = 32,
};
struct nir_lower_system_values_options system_values_options = {
.lower_cs_local_index_from_id = true,
};
NIR_PASS_V(nir, nir_lower_system_values, &system_values_options);
NIR_PASS_V(nir, nir_lower_io,
(nir_variable_mode)(nir_var_shader_in | nir_var_shader_out),
type_size, (nir_lower_io_options)0);
......@@ -3270,12 +3276,7 @@ nvir_nir_shader_compiler_options(int chipset)
op.lower_extract_word = (chipset < NVISA_GM107_CHIPSET);
op.lower_all_io_to_temps = false;
op.lower_all_io_to_elements = false;
op.vertex_id_zero_based = false;
op.lower_base_vertex = false;
op.lower_helper_invocation = false;
op.optimize_sample_mask_in = false;
op.lower_cs_local_index_from_id = true;
op.lower_cs_local_id_from_index = false;
op.lower_device_index_to_zero = false; // TODO
op.lower_wpos_pntc = false; // TODO
op.lower_hadd = true; // TODO
......
......@@ -944,7 +944,6 @@ static const nir_shader_compiler_options nir_options = {
.lower_extract_byte = true,
.lower_extract_word = true,
.lower_all_io_to_temps = false,
.lower_cs_local_index_from_id = true,
.lower_rotate = true,
.lower_to_scalar = true,
.use_interpolated_input_intrinsics = true,
......
......@@ -142,7 +142,8 @@ module clover::nir::spirv_to_nir(const module &mod, const device &dev,
nir_address_format_64bit_global : nir_address_format_32bit_global;
NIR_PASS_V(nir, nir_lower_explicit_io, modes, format);
NIR_PASS_V(nir, nir_lower_system_values);
const nir_lower_system_values_options system_values_options = {};
NIR_PASS_V(nir, nir_lower_system_values, &system_values_options);
if (compiler_options->lower_int64_options)
NIR_PASS_V(nir, nir_lower_int64,
compiler_options->lower_int64_options);
......
......@@ -46,8 +46,6 @@
.lower_device_index_to_zero = true, \
.vectorize_io = true, \
.use_interpolated_input_intrinsics = true, \
.vertex_id_zero_based = true, \
.lower_base_vertex = true, \
.use_scoped_barrier = true, \
.support_8bit_alu = true, \
.support_16bit_alu = true
......
......@@ -709,7 +709,12 @@ brw_preprocess_nir(const struct brw_compiler *compiler, nir_shader *nir,
OPT(nir_opt_large_constants, NULL, 32);
}
OPT(nir_lower_system_values);
const nir_lower_system_values_options system_values_options = {
.vertex_id_zero_based = true,
.lower_base_vertex = true,
};
OPT(nir_lower_system_values, &system_values_options);
nir_shader_gather_info(nir, nir_shader_get_entrypoint(nir));
const nir_lower_subgroups_options subgroups_options = {
.ballot_bit_size = 32,
......
......@@ -52,6 +52,8 @@
#include "compiler/glsl/ir_optimization.h"
#include "compiler/glsl/string_to_uint_map.h"
#include "nir/pipe_nir.h"
static int
type_size(const struct glsl_type *type)
{
......@@ -777,7 +779,7 @@ st_link_nir(struct gl_context *ctx,
NIR_PASS_V(nir, st_nir_lower_wpos_ytransform, shader->Program,
st->pipe->screen);
NIR_PASS_V(nir, nir_lower_system_values);
NIR_PASS_V(nir, pipe_nir_lower_system_values, st->pipe->screen);
NIR_PASS_V(nir, nir_lower_clip_cull_distance_arrays);
st_shader_gather_info(nir, shader->Program);
......
......@@ -26,6 +26,8 @@
#include "compiler/nir/nir_builder.h"
#include "compiler/glsl/gl_nir.h"
#include "nir/pipe_nir.h"
struct pipe_shader_state *
st_nir_finish_builtin_shader(struct st_context *st,
nir_shader *nir,
......@@ -42,7 +44,7 @@ st_nir_finish_builtin_shader(struct st_context *st,
NIR_PASS_V(nir, nir_lower_global_vars_to_local);
NIR_PASS_V(nir, nir_split_var_copies);
NIR_PASS_V(nir, nir_lower_var_copies);
NIR_PASS_V(nir, nir_lower_system_values);
NIR_PASS_V(nir, pipe_nir_lower_system_values, st->pipe->screen);
if (nir->options->lower_to_scalar) {
nir_variable_mode mask =
......
......@@ -52,6 +52,7 @@
#include "tgsi/tgsi_emulate.h"
#include "tgsi/tgsi_parse.h"
#include "tgsi/tgsi_ureg.h"
#include "nir/pipe_nir.h"
#include "util/u_memory.h"
......@@ -387,7 +388,7 @@ st_translate_prog_to_nir(struct st_context *st, struct gl_program *prog,
nir_validate_shader(nir, "after st/ptn lower_regs_to_ssa");
NIR_PASS_V(nir, st_nir_lower_wpos_ytransform, prog, screen);
NIR_PASS_V(nir, nir_lower_system_values);
NIR_PASS_V(nir, pipe_nir_lower_system_values, st->pipe->screen);
/* Optimise NIR */
NIR_PASS_V(nir, nir_opt_constant_folding);
......