nir: Rework gather_info to entirely use deref instructions
Acked-by: Rob Clark <robdclark@gmail.com> Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl> Acked-by: Dave Airlie <airlied@redhat.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
@@ -113,23 +113,19 @@ mark_whole_variable(nir_shader *shader, nir_variable *var, bool is_output_read)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static unsigned
|
static unsigned
|
||||||
get_io_offset(nir_deref_var *deref, bool is_vertex_input)
|
get_io_offset(nir_deref_instr *deref, bool is_vertex_input)
|
||||||
{
|
{
|
||||||
unsigned offset = 0;
|
unsigned offset = 0;
|
||||||
|
|
||||||
nir_deref *tail = &deref->deref;
|
for (nir_deref_instr *d = deref; d; d = nir_deref_instr_parent(d)) {
|
||||||
while (tail->child != NULL) {
|
if (d->deref_type == nir_deref_type_array) {
|
||||||
tail = tail->child;
|
nir_const_value *const_index = nir_src_as_const_value(d->arr.index);
|
||||||
|
|
||||||
if (tail->deref_type == nir_deref_type_array) {
|
if (!const_index)
|
||||||
nir_deref_array *deref_array = nir_deref_as_array(tail);
|
|
||||||
|
|
||||||
if (deref_array->deref_array_type == nir_deref_array_type_indirect) {
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
offset += glsl_count_attribute_slots(tail->type, is_vertex_input) *
|
offset += glsl_count_attribute_slots(d->type, is_vertex_input) *
|
||||||
deref_array->base_offset;
|
const_index->u32[0];
|
||||||
}
|
}
|
||||||
/* TODO: we can get the offset for structs here see nir_lower_io() */
|
/* TODO: we can get the offset for structs here see nir_lower_io() */
|
||||||
}
|
}
|
||||||
@@ -145,9 +141,9 @@ get_io_offset(nir_deref_var *deref, bool is_vertex_input)
|
|||||||
* occurs, then nothing will be marked and false will be returned.
|
* occurs, then nothing will be marked and false will be returned.
|
||||||
*/
|
*/
|
||||||
static bool
|
static bool
|
||||||
try_mask_partial_io(nir_shader *shader, nir_deref_var *deref, bool is_output_read)
|
try_mask_partial_io(nir_shader *shader, nir_variable *var,
|
||||||
|
nir_deref_instr *deref, bool is_output_read)
|
||||||
{
|
{
|
||||||
nir_variable *var = deref->var;
|
|
||||||
const struct glsl_type *type = var->type;
|
const struct glsl_type *type = var->type;
|
||||||
|
|
||||||
if (nir_is_per_vertex_io(var, shader->info.stage)) {
|
if (nir_is_per_vertex_io(var, shader->info.stage)) {
|
||||||
@@ -232,29 +228,19 @@ gather_intrinsic_info(nir_intrinsic_instr *instr, nir_shader *shader,
|
|||||||
case nir_intrinsic_interp_deref_at_centroid:
|
case nir_intrinsic_interp_deref_at_centroid:
|
||||||
case nir_intrinsic_interp_deref_at_sample:
|
case nir_intrinsic_interp_deref_at_sample:
|
||||||
case nir_intrinsic_interp_deref_at_offset:
|
case nir_intrinsic_interp_deref_at_offset:
|
||||||
case nir_intrinsic_interp_var_at_centroid:
|
|
||||||
case nir_intrinsic_interp_var_at_sample:
|
|
||||||
case nir_intrinsic_interp_var_at_offset:
|
|
||||||
case nir_intrinsic_load_deref:
|
case nir_intrinsic_load_deref:
|
||||||
case nir_intrinsic_load_var:
|
case nir_intrinsic_store_deref:{
|
||||||
case nir_intrinsic_store_deref:
|
nir_deref_instr *deref = nir_src_as_deref(instr->src[0]);
|
||||||
case nir_intrinsic_store_var: {
|
nir_variable *var = nir_deref_instr_get_variable(deref);
|
||||||
nir_deref_var *deref;
|
|
||||||
if (nir_intrinsic_infos[instr->intrinsic].num_variables > 0)
|
|
||||||
deref = instr->variables[0];
|
|
||||||
else
|
|
||||||
deref = nir_deref_instr_to_deref(nir_src_as_deref(instr->src[0]), dead_ctx);
|
|
||||||
nir_variable *var = deref->var;
|
|
||||||
|
|
||||||
if (var->data.mode == nir_var_shader_in ||
|
if (var->data.mode == nir_var_shader_in ||
|
||||||
var->data.mode == nir_var_shader_out) {
|
var->data.mode == nir_var_shader_out) {
|
||||||
bool is_output_read = false;
|
bool is_output_read = false;
|
||||||
if (var->data.mode == nir_var_shader_out &&
|
if (var->data.mode == nir_var_shader_out &&
|
||||||
(instr->intrinsic == nir_intrinsic_load_var ||
|
instr->intrinsic == nir_intrinsic_load_deref)
|
||||||
instr->intrinsic == nir_intrinsic_load_deref))
|
|
||||||
is_output_read = true;
|
is_output_read = true;
|
||||||
|
|
||||||
if (!try_mask_partial_io(shader, deref, is_output_read))
|
if (!try_mask_partial_io(shader, var, deref, is_output_read))
|
||||||
mark_whole_variable(shader, var, is_output_read);
|
mark_whole_variable(shader, var, is_output_read);
|
||||||
|
|
||||||
/* We need to track which input_reads bits correspond to a
|
/* We need to track which input_reads bits correspond to a
|
||||||
|
Reference in New Issue
Block a user