nir: Drop the vs_inputs_dual_locations option
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. Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com> Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
This commit is contained in:
@@ -71,7 +71,6 @@ static const struct nir_shader_compiler_options nir_options = {
|
|||||||
.lower_extract_word = true,
|
.lower_extract_word = true,
|
||||||
.lower_ffma = true,
|
.lower_ffma = true,
|
||||||
.lower_fpow = true,
|
.lower_fpow = true,
|
||||||
.vs_inputs_dual_locations = true,
|
|
||||||
.max_unroll_iterations = 32
|
.max_unroll_iterations = 32
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -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
|
* 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
|
* 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 */
|
* locations/slots 0 and 1, and attr1 will use location/slot 2 */
|
||||||
if (shader->info.stage == MESA_SHADER_VERTEX) {
|
if (shader->info.stage == MESA_SHADER_VERTEX)
|
||||||
sh->Program->DualSlotInputs = nir_get_dual_slot_attributes(shader);
|
nir_remap_dual_slot_attributes(shader, &sh->Program->DualSlotInputs);
|
||||||
if (options->vs_inputs_dual_locations)
|
|
||||||
nir_remap_dual_slot_attributes(shader, sh->Program->DualSlotInputs);
|
|
||||||
}
|
|
||||||
|
|
||||||
shader->info.name = ralloc_asprintf(shader, "GLSL%d", shader_prog->Name);
|
shader->info.name = ralloc_asprintf(shader, "GLSL%d", shader_prog->Name);
|
||||||
if (shader_prog->Label)
|
if (shader_prog->Label)
|
||||||
|
@@ -1854,34 +1854,32 @@ nir_system_value_from_intrinsic(nir_intrinsic_op intrin)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t
|
|
||||||
nir_get_dual_slot_attributes(nir_shader *shader)
|
|
||||||
{
|
|
||||||
assert(shader->info.stage == MESA_SHADER_VERTEX);
|
|
||||||
|
|
||||||
uint64_t 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return dual_slot;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* OpenGL utility method that remaps the location attributes if they are
|
/* OpenGL utility method that remaps the location attributes if they are
|
||||||
* doubles. Not needed for vulkan due the differences on the input location
|
* doubles. Not needed for vulkan due the differences on the input location
|
||||||
* count for doubles on vulkan vs OpenGL
|
* 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
|
void
|
||||||
nir_remap_dual_slot_attributes(nir_shader *shader, uint64_t dual_slot)
|
nir_remap_dual_slot_attributes(nir_shader *shader, uint64_t *dual_slot)
|
||||||
{
|
{
|
||||||
assert(shader->info.stage == MESA_SHADER_VERTEX);
|
assert(shader->info.stage == MESA_SHADER_VERTEX);
|
||||||
|
|
||||||
|
*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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
nir_foreach_variable(var, &shader->inputs) {
|
nir_foreach_variable(var, &shader->inputs) {
|
||||||
var->data.location +=
|
var->data.location +=
|
||||||
_mesa_bitcount_64(dual_slot & BITFIELD64_MASK(var->data.location));
|
_mesa_bitcount_64(*dual_slot & BITFIELD64_MASK(var->data.location));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -2119,12 +2119,6 @@ typedef struct nir_shader_compiler_options {
|
|||||||
*/
|
*/
|
||||||
bool use_interpolated_input_intrinsics;
|
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;
|
unsigned max_unroll_iterations;
|
||||||
} nir_shader_compiler_options;
|
} nir_shader_compiler_options;
|
||||||
|
|
||||||
@@ -3039,9 +3033,8 @@ bool nir_opt_conditional_discard(nir_shader *shader);
|
|||||||
|
|
||||||
void nir_sweep(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,
|
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);
|
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);
|
nir_intrinsic_op nir_intrinsic_from_system_value(gl_system_value val);
|
||||||
|
@@ -88,21 +88,15 @@ static void
|
|||||||
mark_whole_variable(nir_shader *shader, nir_variable *var, bool is_output_read)
|
mark_whole_variable(nir_shader *shader, nir_variable *var, bool is_output_read)
|
||||||
{
|
{
|
||||||
const struct glsl_type *type = var->type;
|
const struct glsl_type *type = var->type;
|
||||||
bool is_vertex_input = false;
|
|
||||||
|
|
||||||
if (nir_is_per_vertex_io(var, shader->info.stage)) {
|
if (nir_is_per_vertex_io(var, shader->info.stage)) {
|
||||||
assert(glsl_type_is_array(type));
|
assert(glsl_type_is_array(type));
|
||||||
type = glsl_get_array_element(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 =
|
const unsigned slots =
|
||||||
var->data.compact ? DIV_ROUND_UP(glsl_get_length(type), 4)
|
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);
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_vertex_input = false;
|
unsigned offset = get_io_offset(deref, 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);
|
|
||||||
if (offset == -1)
|
if (offset == -1)
|
||||||
return false;
|
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 */
|
/* double element width for double types that takes two slots */
|
||||||
if (!is_vertex_input &&
|
if (glsl_type_is_dual_slot(glsl_without_array(type)))
|
||||||
glsl_type_is_dual_slot(glsl_without_array(type))) {
|
|
||||||
elem_width *= 2;
|
elem_width *= 2;
|
||||||
}
|
|
||||||
|
|
||||||
if (offset >= num_elems * elem_width * mat_cols) {
|
if (offset >= num_elems * elem_width * mat_cols) {
|
||||||
/* Constant index outside the bounds of the matrix/array. This could
|
/* Constant index outside the bounds of the matrix/array. This could
|
||||||
|
@@ -501,7 +501,6 @@ static const struct nir_shader_compiler_options nir_options = {
|
|||||||
.lower_extract_word = true,
|
.lower_extract_word = true,
|
||||||
.max_unroll_iterations = 32,
|
.max_unroll_iterations = 32,
|
||||||
.native_integers = true,
|
.native_integers = true,
|
||||||
.vs_inputs_dual_locations = true,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const void *
|
static const void *
|
||||||
|
@@ -59,7 +59,6 @@
|
|||||||
.lower_unpack_snorm_4x8 = true, \
|
.lower_unpack_snorm_4x8 = true, \
|
||||||
.lower_unpack_unorm_2x16 = true, \
|
.lower_unpack_unorm_2x16 = true, \
|
||||||
.lower_unpack_unorm_4x8 = true, \
|
.lower_unpack_unorm_4x8 = true, \
|
||||||
.vs_inputs_dual_locations = true, \
|
|
||||||
.max_unroll_iterations = 32
|
.max_unroll_iterations = 32
|
||||||
|
|
||||||
static const struct nir_shader_compiler_options scalar_nir_options = {
|
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_unpack_unorm_2x16 = true,
|
||||||
.lower_extract_byte = true,
|
.lower_extract_byte = true,
|
||||||
.lower_extract_word = true,
|
.lower_extract_word = true,
|
||||||
.vs_inputs_dual_locations = true,
|
|
||||||
.max_unroll_iterations = 32,
|
.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_unpack_unorm_2x16 = true,
|
||||||
.lower_extract_byte = true,
|
.lower_extract_byte = true,
|
||||||
.lower_extract_word = true,
|
.lower_extract_word = true,
|
||||||
.vs_inputs_dual_locations = true,
|
|
||||||
.max_unroll_iterations = 32,
|
.max_unroll_iterations = 32,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -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_var_copies);
|
||||||
NIR_PASS_V(nir, nir_split_per_member_structs);
|
NIR_PASS_V(nir, nir_split_per_member_structs);
|
||||||
|
|
||||||
if (nir->info.stage == MESA_SHADER_VERTEX) {
|
if (nir->info.stage == MESA_SHADER_VERTEX)
|
||||||
uint64_t dual_slot_inputs = nir_get_dual_slot_attributes(nir);
|
nir_remap_dual_slot_attributes(nir, &linked_shader->Program->DualSlotInputs);
|
||||||
if (options->vs_inputs_dual_locations)
|
|
||||||
nir_remap_dual_slot_attributes(nir, dual_slot_inputs);
|
|
||||||
linked_shader->Program->DualSlotInputs = dual_slot_inputs;
|
|
||||||
}
|
|
||||||
|
|
||||||
return nir;
|
return nir;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user