[Mesa-dev] [PATCH 3/3] nir: Drop the vs_inputs_dual_locations option
Jason Ekstrand
jason at jlekstrand.net
Sat Sep 1 03:11:34 UTC 2018
It was very inconsistently handled; the only things that made use of it
were glsl_to_nir, glspirv, and nir_gather_info. In particular,
nir_lower_io completely ignored it so anyone using nir_lower_io on
64-bit vertex attributes was going to be in for a shock. Also, as of
the previous commit, it's set by every driver that supports 64-bit
vertex attributes. There's no longer any reason to have it be an option
so let's just delete it.
---
src/amd/vulkan/radv_shader.c | 1 -
src/compiler/glsl/glsl_to_nir.cpp | 7 ++----
src/compiler/nir/nir.c | 32 +++++++++++++--------------
src/compiler/nir/nir.h | 9 +-------
src/compiler/nir/nir_gather_info.c | 20 +++--------------
src/gallium/drivers/radeonsi/si_get.c | 1 -
src/intel/compiler/brw_compiler.c | 3 ---
src/mesa/main/glspirv.c | 8 ++-----
8 files changed, 23 insertions(+), 58 deletions(-)
diff --git a/src/amd/vulkan/radv_shader.c b/src/amd/vulkan/radv_shader.c
index 207e5b050eb..e05961339ca 100644
--- a/src/amd/vulkan/radv_shader.c
+++ b/src/amd/vulkan/radv_shader.c
@@ -71,7 +71,6 @@ static const struct nir_shader_compiler_options nir_options = {
.lower_extract_word = true,
.lower_ffma = true,
.lower_fpow = true,
- .vs_inputs_dual_locations = true,
.max_unroll_iterations = 32
};
diff --git a/src/compiler/glsl/glsl_to_nir.cpp b/src/compiler/glsl/glsl_to_nir.cpp
index d22f4a58dd4..dc6ffa3599d 100644
--- a/src/compiler/glsl/glsl_to_nir.cpp
+++ b/src/compiler/glsl/glsl_to_nir.cpp
@@ -149,11 +149,8 @@ glsl_to_nir(const struct gl_shader_program *shader_prog,
* two locations. For instance, if we have in the IR code a dvec3 attr0 in
* location 0 and vec4 attr1 in location 1, in NIR attr0 will use
* locations/slots 0 and 1, and attr1 will use location/slot 2 */
- if (shader->info.stage == MESA_SHADER_VERTEX) {
- sh->Program->DualSlotInputs = nir_get_dual_slot_attributes(shader);
- if (options->vs_inputs_dual_locations)
- nir_remap_dual_slot_attributes(shader, sh->Program->DualSlotInputs);
- }
+ if (shader->info.stage == MESA_SHADER_VERTEX)
+ nir_remap_dual_slot_attributes(shader, &sh->Program->DualSlotInputs);
shader->info.name = ralloc_asprintf(shader, "GLSL%d", shader_prog->Name);
if (shader_prog->Label)
diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c
index 0d8a554bd20..a6240c11f2d 100644
--- a/src/compiler/nir/nir.c
+++ b/src/compiler/nir/nir.c
@@ -1854,34 +1854,32 @@ nir_system_value_from_intrinsic(nir_intrinsic_op intrin)
}
}
-uint64_t
-nir_get_dual_slot_attributes(nir_shader *shader)
+/* OpenGL utility method that remaps the location attributes if they are
+ * doubles. Not needed for vulkan due the differences on the input location
+ * count for doubles on vulkan vs OpenGL
+ *
+ * The bitfield returned in dual_slot is one bit for each double input slot in
+ * the original OpenGL single-slot input numbering. The mapping from old
+ * locations to new locations is as follows:
+ *
+ * new_loc = loc + _mesa_bitcount(dual_slot & BITFIELD64_MASK(loc))
+ */
+void
+nir_remap_dual_slot_attributes(nir_shader *shader, uint64_t *dual_slot)
{
assert(shader->info.stage == MESA_SHADER_VERTEX);
- uint64_t dual_slot = 0;
+ *dual_slot = 0;
nir_foreach_variable(var, &shader->inputs) {
if (glsl_type_is_dual_slot(glsl_without_array(var->type))) {
unsigned slots = glsl_count_attribute_slots(var->type, true);
- dual_slot |= BITFIELD64_MASK(slots) << var->data.location;
+ *dual_slot |= BITFIELD64_MASK(slots) << var->data.location;
}
}
- return dual_slot;
-}
-
-/* OpenGL utility method that remaps the location attributes if they are
- * doubles. Not needed for vulkan due the differences on the input location
- * count for doubles on vulkan vs OpenGL
- */
-void
-nir_remap_dual_slot_attributes(nir_shader *shader, uint64_t dual_slot)
-{
- assert(shader->info.stage == MESA_SHADER_VERTEX);
-
nir_foreach_variable(var, &shader->inputs) {
var->data.location +=
- _mesa_bitcount_64(dual_slot & BITFIELD64_MASK(var->data.location));
+ _mesa_bitcount_64(*dual_slot & BITFIELD64_MASK(var->data.location));
}
}
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index b9393702097..bf4bd916d27 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -2119,12 +2119,6 @@ typedef struct nir_shader_compiler_options {
*/
bool use_interpolated_input_intrinsics;
- /**
- * Do vertex shader double inputs use two locations? The Vulkan spec
- * requires two locations to be used, OpenGL allows a single location.
- */
- bool vs_inputs_dual_locations;
-
unsigned max_unroll_iterations;
} nir_shader_compiler_options;
@@ -3039,9 +3033,8 @@ bool nir_opt_conditional_discard(nir_shader *shader);
void nir_sweep(nir_shader *shader);
-uint64_t nir_get_dual_slot_attributes(nir_shader *shader);
void nir_remap_dual_slot_attributes(nir_shader *shader,
- uint64_t dual_slot);
+ uint64_t *dual_slot_inputs);
uint64_t nir_get_single_slot_attribs_mask(uint64_t attribs, uint64_t dual_slot);
nir_intrinsic_op nir_intrinsic_from_system_value(gl_system_value val);
diff --git a/src/compiler/nir/nir_gather_info.c b/src/compiler/nir/nir_gather_info.c
index de18c9bd78e..30f0bc721d4 100644
--- a/src/compiler/nir/nir_gather_info.c
+++ b/src/compiler/nir/nir_gather_info.c
@@ -88,21 +88,15 @@ static void
mark_whole_variable(nir_shader *shader, nir_variable *var, bool is_output_read)
{
const struct glsl_type *type = var->type;
- bool is_vertex_input = false;
if (nir_is_per_vertex_io(var, shader->info.stage)) {
assert(glsl_type_is_array(type));
type = glsl_get_array_element(type);
}
- if (!shader->options->vs_inputs_dual_locations &&
- shader->info.stage == MESA_SHADER_VERTEX &&
- var->data.mode == nir_var_shader_in)
- is_vertex_input = true;
-
const unsigned slots =
var->data.compact ? DIV_ROUND_UP(glsl_get_length(type), 4)
- : glsl_count_attribute_slots(type, is_vertex_input);
+ : glsl_count_attribute_slots(type, false);
set_io_mask(shader, var, 0, slots, is_output_read);
}
@@ -165,13 +159,7 @@ try_mask_partial_io(nir_shader *shader, nir_variable *var,
return false;
}
- bool is_vertex_input = false;
- if (!shader->options->vs_inputs_dual_locations &&
- shader->info.stage == MESA_SHADER_VERTEX &&
- var->data.mode == nir_var_shader_in)
- is_vertex_input = true;
-
- unsigned offset = get_io_offset(deref, is_vertex_input);
+ unsigned offset = get_io_offset(deref, false);
if (offset == -1)
return false;
@@ -187,10 +175,8 @@ try_mask_partial_io(nir_shader *shader, nir_variable *var,
}
/* double element width for double types that takes two slots */
- if (!is_vertex_input &&
- glsl_type_is_dual_slot(glsl_without_array(type))) {
+ if (glsl_type_is_dual_slot(glsl_without_array(type)))
elem_width *= 2;
- }
if (offset >= num_elems * elem_width * mat_cols) {
/* Constant index outside the bounds of the matrix/array. This could
diff --git a/src/gallium/drivers/radeonsi/si_get.c b/src/gallium/drivers/radeonsi/si_get.c
index bc3d559861f..90f62edf470 100644
--- a/src/gallium/drivers/radeonsi/si_get.c
+++ b/src/gallium/drivers/radeonsi/si_get.c
@@ -497,7 +497,6 @@ static const struct nir_shader_compiler_options nir_options = {
.lower_extract_word = true,
.max_unroll_iterations = 32,
.native_integers = true,
- .vs_inputs_dual_locations = true,
};
static const void *
diff --git a/src/intel/compiler/brw_compiler.c b/src/intel/compiler/brw_compiler.c
index 6df9621fe42..e863b08b991 100644
--- a/src/intel/compiler/brw_compiler.c
+++ b/src/intel/compiler/brw_compiler.c
@@ -59,7 +59,6 @@
.lower_unpack_snorm_4x8 = true, \
.lower_unpack_unorm_2x16 = true, \
.lower_unpack_unorm_4x8 = true, \
- .vs_inputs_dual_locations = true, \
.max_unroll_iterations = 32
static const struct nir_shader_compiler_options scalar_nir_options = {
@@ -91,7 +90,6 @@ static const struct nir_shader_compiler_options vector_nir_options = {
.lower_unpack_unorm_2x16 = true,
.lower_extract_byte = true,
.lower_extract_word = true,
- .vs_inputs_dual_locations = true,
.max_unroll_iterations = 32,
};
@@ -110,7 +108,6 @@ static const struct nir_shader_compiler_options vector_nir_options_gen6 = {
.lower_unpack_unorm_2x16 = true,
.lower_extract_byte = true,
.lower_extract_word = true,
- .vs_inputs_dual_locations = true,
.max_unroll_iterations = 32,
};
diff --git a/src/mesa/main/glspirv.c b/src/mesa/main/glspirv.c
index c53fe0bd07c..fecf7384eb3 100644
--- a/src/mesa/main/glspirv.c
+++ b/src/mesa/main/glspirv.c
@@ -263,12 +263,8 @@ _mesa_spirv_to_nir(struct gl_context *ctx,
NIR_PASS_V(nir, nir_split_var_copies);
NIR_PASS_V(nir, nir_split_per_member_structs);
- if (nir->info.stage == MESA_SHADER_VERTEX) {
- uint64_t dual_slot_inputs = nir_get_dual_slot_attributes(nir);
- if (options->vs_inputs_dual_locations)
- nir_remap_dual_slot_attributes(nir, dual_slot_inputs);
- linked_shader->Program->DualSlotInputs = dual_slot_inputs;
- }
+ if (nir->info.stage == MESA_SHADER_VERTEX)
+ nir_remap_dual_slot_attributes(nir, &linked_shader->Program->DualSlotInputs);
return nir;
}
--
2.17.1
More information about the mesa-dev
mailing list