.lower_extract_word = true,
.lower_ffma = true,
.lower_fpow = true,
- .vs_inputs_dual_locations = true,
.max_unroll_iterations = 32
};
* 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)
}
}
-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));
}
}
*/
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;
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);
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);
}
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;
}
/* 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
.lower_extract_word = true,
.max_unroll_iterations = 32,
.native_integers = true,
- .vs_inputs_dual_locations = true,
};
static const void *
.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 = {
.lower_unpack_unorm_2x16 = true,
.lower_extract_byte = true,
.lower_extract_word = true,
- .vs_inputs_dual_locations = true,
.max_unroll_iterations = 32,
};
.lower_unpack_unorm_2x16 = true,
.lower_extract_byte = true,
.lower_extract_word = true,
- .vs_inputs_dual_locations = true,
.max_unroll_iterations = 32,
};
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;
}