mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-24 04:30:10 +01:00
i965/nir: Use nir_system_value_from_intrinsic to reduce duplication.
This code is all pretty much identical. We just needed the translation from one enum value to the other. Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
This commit is contained in:
parent
d5d74d0b86
commit
0cc331dddd
2 changed files with 17 additions and 60 deletions
|
|
@ -1444,35 +1444,16 @@ fs_visitor::nir_emit_intrinsic(const fs_builder &bld, nir_intrinsic_instr *instr
|
|||
case nir_intrinsic_load_vertex_id:
|
||||
unreachable("should be lowered by lower_vertex_id()");
|
||||
|
||||
case nir_intrinsic_load_vertex_id_zero_base: {
|
||||
fs_reg vertex_id = nir_system_values[SYSTEM_VALUE_VERTEX_ID_ZERO_BASE];
|
||||
assert(vertex_id.file != BAD_FILE);
|
||||
dest.type = vertex_id.type;
|
||||
bld.MOV(dest, vertex_id);
|
||||
break;
|
||||
}
|
||||
|
||||
case nir_intrinsic_load_base_vertex: {
|
||||
fs_reg base_vertex = nir_system_values[SYSTEM_VALUE_BASE_VERTEX];
|
||||
assert(base_vertex.file != BAD_FILE);
|
||||
dest.type = base_vertex.type;
|
||||
bld.MOV(dest, base_vertex);
|
||||
break;
|
||||
}
|
||||
|
||||
case nir_intrinsic_load_instance_id: {
|
||||
fs_reg instance_id = nir_system_values[SYSTEM_VALUE_INSTANCE_ID];
|
||||
assert(instance_id.file != BAD_FILE);
|
||||
dest.type = instance_id.type;
|
||||
bld.MOV(dest, instance_id);
|
||||
break;
|
||||
}
|
||||
|
||||
case nir_intrinsic_load_sample_mask_in: {
|
||||
fs_reg sample_mask_in = nir_system_values[SYSTEM_VALUE_SAMPLE_MASK_IN];
|
||||
assert(sample_mask_in.file != BAD_FILE);
|
||||
dest.type = sample_mask_in.type;
|
||||
bld.MOV(dest, sample_mask_in);
|
||||
case nir_intrinsic_load_vertex_id_zero_base:
|
||||
case nir_intrinsic_load_base_vertex:
|
||||
case nir_intrinsic_load_instance_id:
|
||||
case nir_intrinsic_load_sample_mask_in:
|
||||
case nir_intrinsic_load_sample_id: {
|
||||
gl_system_value sv = nir_system_value_from_intrinsic(instr->intrinsic);
|
||||
fs_reg val = nir_system_values[sv];
|
||||
assert(val.file != BAD_FILE);
|
||||
dest.type = val.type;
|
||||
bld.MOV(dest, val);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -1485,14 +1466,6 @@ fs_visitor::nir_emit_intrinsic(const fs_builder &bld, nir_intrinsic_instr *instr
|
|||
break;
|
||||
}
|
||||
|
||||
case nir_intrinsic_load_sample_id: {
|
||||
fs_reg sample_id = nir_system_values[SYSTEM_VALUE_SAMPLE_ID];
|
||||
assert(sample_id.file != BAD_FILE);
|
||||
dest.type = sample_id.type;
|
||||
bld.MOV(dest, sample_id);
|
||||
break;
|
||||
}
|
||||
|
||||
case nir_intrinsic_load_uniform_indirect:
|
||||
has_indirect = true;
|
||||
/* fallthrough */
|
||||
|
|
|
|||
|
|
@ -533,30 +533,14 @@ vec4_visitor::nir_emit_intrinsic(nir_intrinsic_instr *instr)
|
|||
case nir_intrinsic_load_vertex_id:
|
||||
unreachable("should be lowered by lower_vertex_id()");
|
||||
|
||||
case nir_intrinsic_load_vertex_id_zero_base: {
|
||||
src_reg vertex_id =
|
||||
src_reg(nir_system_values[SYSTEM_VALUE_VERTEX_ID_ZERO_BASE]);
|
||||
assert(vertex_id.file != BAD_FILE);
|
||||
dest = get_nir_dest(instr->dest, vertex_id.type);
|
||||
emit(MOV(dest, vertex_id));
|
||||
break;
|
||||
}
|
||||
|
||||
case nir_intrinsic_load_base_vertex: {
|
||||
src_reg base_vertex =
|
||||
src_reg(nir_system_values[SYSTEM_VALUE_BASE_VERTEX]);
|
||||
assert(base_vertex.file != BAD_FILE);
|
||||
dest = get_nir_dest(instr->dest, base_vertex.type);
|
||||
emit(MOV(dest, base_vertex));
|
||||
break;
|
||||
}
|
||||
|
||||
case nir_intrinsic_load_vertex_id_zero_base:
|
||||
case nir_intrinsic_load_base_vertex:
|
||||
case nir_intrinsic_load_instance_id: {
|
||||
src_reg instance_id =
|
||||
src_reg(nir_system_values[SYSTEM_VALUE_INSTANCE_ID]);
|
||||
assert(instance_id.file != BAD_FILE);
|
||||
dest = get_nir_dest(instr->dest, instance_id.type);
|
||||
emit(MOV(dest, instance_id));
|
||||
gl_system_value sv = nir_system_value_from_intrinsic(instr->intrinsic);
|
||||
src_reg val = src_reg(nir_system_values[sv]);
|
||||
assert(val.file != BAD_FILE);
|
||||
dest = get_nir_dest(instr->dest, val.type);
|
||||
emit(MOV(dest, val));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue