The only thing still using it is INVOCATION_ID for geometry shaders.
That's easily enough inlined into the nir_intrinsic_load_invocation_id
handling code.
Reviewed-by: Alejandro PiƱeiro <apinheiro@igalia.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
virtual void emit_nir_code();
virtual void nir_setup_uniforms();
- virtual void nir_setup_system_value_intrinsic(nir_intrinsic_instr *instr);
- virtual void nir_setup_system_values();
virtual void nir_emit_impl(nir_function_impl *impl);
virtual void nir_emit_cf_list(exec_list *list);
virtual void nir_emit_if(nir_if *if_stmt);
unsigned num_components = 4);
src_reg get_indirect_offset(nir_intrinsic_instr *instr);
- virtual dst_reg *make_reg_for_system_value(int location) = 0;
-
dst_reg *nir_locals;
dst_reg *nir_ssa_values;
- dst_reg *nir_system_values;
protected:
void emit_vertex();
{
}
-void
-vec4_gs_visitor::nir_setup_system_value_intrinsic(nir_intrinsic_instr *instr)
-{
- dst_reg *reg;
-
- switch (instr->intrinsic) {
- case nir_intrinsic_load_primitive_id:
- /* We'll just read g1 directly; don't create a temporary. */
- break;
-
- case nir_intrinsic_load_invocation_id:
- reg = &this->nir_system_values[SYSTEM_VALUE_INVOCATION_ID];
- if (reg->file == BAD_FILE)
- *reg = *this->make_reg_for_system_value(SYSTEM_VALUE_INVOCATION_ID);
- break;
-
- default:
- vec4_visitor::nir_setup_system_value_intrinsic(instr);
- }
-
-}
-
void
vec4_gs_visitor::nir_emit_intrinsic(nir_intrinsic_instr *instr)
{
break;
case nir_intrinsic_load_invocation_id: {
- src_reg invocation_id =
- src_reg(nir_system_values[SYSTEM_VALUE_INVOCATION_ID]);
- assert(invocation_id.file != BAD_FILE);
- dest = get_nir_dest(instr->dest, invocation_id.type);
- emit(MOV(dest, invocation_id));
+ dest = get_nir_dest(instr->dest, BRW_REGISTER_TYPE_D);
+ if (gs_prog_data->invocations > 1)
+ emit(GS_OPCODE_GET_INSTANCE_ID, dest);
+ else
+ emit(MOV(dest, brw_imm_ud(0)));
break;
}
}
-dst_reg *
-vec4_gs_visitor::make_reg_for_system_value(int location)
-{
- dst_reg *reg = new(mem_ctx) dst_reg(this, glsl_type::int_type);
-
- switch (location) {
- case SYSTEM_VALUE_INVOCATION_ID:
- this->current_annotation = "initialize gl_InvocationID";
- if (gs_prog_data->invocations > 1)
- emit(GS_OPCODE_GET_INSTANCE_ID, *reg);
- else
- emit(MOV(*reg, brw_imm_ud(0)));
- break;
- default:
- unreachable("not reached");
- }
-
- return reg;
-}
-
static inline struct brw_reg
attribute_to_hw_reg(int attr, brw_reg_type type, bool interleaved)
{
int shader_time_index);
virtual void nir_setup_inputs();
- virtual void nir_setup_system_value_intrinsic(nir_intrinsic_instr *instr);
protected:
- virtual dst_reg *make_reg_for_system_value(int location);
virtual void setup_payload();
virtual void emit_prolog();
virtual void emit_thread_end();
if (nir->num_uniforms > 0)
nir_setup_uniforms();
- nir_setup_system_values();
-
/* get the main function and emit it */
nir_foreach_function(function, nir) {
assert(strcmp(function->name, "main") == 0);
}
}
-void
-vec4_visitor::nir_setup_system_value_intrinsic(nir_intrinsic_instr *instr)
-{
-}
-
-static bool
-setup_system_values_block(nir_block *block, vec4_visitor *v)
-{
- nir_foreach_instr(instr, block) {
- if (instr->type != nir_instr_type_intrinsic)
- continue;
-
- nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);
- v->nir_setup_system_value_intrinsic(intrin);
- }
-
- return true;
-}
-
-void
-vec4_visitor::nir_setup_system_values()
-{
- nir_system_values = ralloc_array(mem_ctx, dst_reg, SYSTEM_VALUE_MAX);
- for (unsigned i = 0; i < SYSTEM_VALUE_MAX; i++) {
- nir_system_values[i] = dst_reg();
- }
-
- nir_foreach_function(function, nir) {
- assert(strcmp(function->name, "main") == 0);
- assert(function->impl);
- nir_foreach_block(block, function->impl) {
- setup_system_values_block(block, this);
- }
- }
-}
-
void
vec4_visitor::nir_setup_uniforms()
{
}
-void
-vec4_tcs_visitor::nir_setup_system_value_intrinsic(nir_intrinsic_instr *instr)
-{
-}
-
-dst_reg *
-vec4_tcs_visitor::make_reg_for_system_value(int location)
-{
- return NULL;
-}
-
-
void
vec4_tcs_visitor::setup_payload()
{
const struct brw_vue_map *input_vue_map);
protected:
- virtual dst_reg *make_reg_for_system_value(int location);
- virtual void nir_setup_system_value_intrinsic(nir_intrinsic_instr *instr);
virtual void setup_payload();
virtual void emit_prolog();
virtual void emit_thread_end();
{
}
-
-dst_reg *
-vec4_tes_visitor::make_reg_for_system_value(int location)
-{
- return NULL;
-}
-
-void
-vec4_tes_visitor::nir_setup_system_value_intrinsic(nir_intrinsic_instr *instr)
-{
- switch (instr->intrinsic) {
- case nir_intrinsic_load_tess_level_outer:
- case nir_intrinsic_load_tess_level_inner:
- break;
- default:
- vec4_visitor::nir_setup_system_value_intrinsic(instr);
- }
-}
-
-
void
vec4_tes_visitor::setup_payload()
{
int shader_time_index);
protected:
- virtual dst_reg *make_reg_for_system_value(int location);
- virtual void nir_setup_system_value_intrinsic(nir_intrinsic_instr *instr);
virtual void nir_emit_intrinsic(nir_intrinsic_instr *instr);
virtual void setup_payload();
bool use_legacy_snorm_formula);
protected:
- virtual dst_reg *make_reg_for_system_value(int location);
virtual void setup_payload();
virtual void emit_prolog();
virtual void emit_thread_end();
}
-dst_reg *
-vec4_vs_visitor::make_reg_for_system_value(int location)
-{
- unreachable("not reached");
- return NULL;
-}
-
-
void
vec4_vs_visitor::emit_urb_write_header(int mrf)
{