From 340c73d4efd6198df077bc0f8b4e670df42f6ec6 Mon Sep 17 00:00:00 2001 From: Connor Abbott Date: Tue, 30 Jun 2020 13:47:22 +0200 Subject: [PATCH] nir/spirv: Add the option to keep ViewIndex as an input This is necessary for fragment shaders on adreno. Part-of: --- src/compiler/spirv/nir_spirv.h | 4 ++++ src/compiler/spirv/vtn_variables.c | 9 +++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/compiler/spirv/nir_spirv.h b/src/compiler/spirv/nir_spirv.h index 3d6f74e43ca..3cbd0269ffe 100644 --- a/src/compiler/spirv/nir_spirv.h +++ b/src/compiler/spirv/nir_spirv.h @@ -64,6 +64,10 @@ struct spirv_to_nir_options { */ bool frag_coord_is_sysval; + /* Whether to keep ViewIndex as an input instead of rewriting to a sysval. + */ + bool view_index_is_input; + struct spirv_supported_capabilities caps; /* Address format for various kinds of pointers. */ diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c index 1cb848a3af8..a7ccafdc8b9 100644 --- a/src/compiler/spirv/vtn_variables.c +++ b/src/compiler/spirv/vtn_variables.c @@ -1436,8 +1436,13 @@ vtn_get_builtin_location(struct vtn_builder *b, set_mode_system_value(b, mode); break; case SpvBuiltInViewIndex: - *location = SYSTEM_VALUE_VIEW_INDEX; - set_mode_system_value(b, mode); + if (b->options && b->options->view_index_is_input) { + *location = VARYING_SLOT_VIEW_INDEX; + vtn_assert(*mode == nir_var_shader_in); + } else { + *location = SYSTEM_VALUE_VIEW_INDEX; + set_mode_system_value(b, mode); + } break; case SpvBuiltInSubgroupEqMask: *location = SYSTEM_VALUE_SUBGROUP_EQ_MASK, -- 2.30.2