r600/sfn: lower VS IO and drop old deref code
Signed-off-by: Gert Wollny <gert.wollny@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9874>
This commit is contained in:
@@ -303,13 +303,9 @@ bool ShaderFromNir::emit_instruction(nir_instr *instr)
|
|||||||
|
|
||||||
bool ShaderFromNir::process_declaration()
|
bool ShaderFromNir::process_declaration()
|
||||||
{
|
{
|
||||||
// scan declarations
|
|
||||||
nir_foreach_shader_in_variable(variable, sh) {
|
if (!impl->scan_inputs_read(sh))
|
||||||
if (!impl->process_inputs(variable)) {
|
return false;
|
||||||
fprintf(stderr, "R600: error parsing input variable %s\n", variable->name);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// scan declarations
|
// scan declarations
|
||||||
nir_foreach_shader_out_variable(variable, sh) {
|
nir_foreach_shader_out_variable(variable, sh) {
|
||||||
@@ -899,9 +895,7 @@ int r600_shader_from_nir(struct r600_context *rctx,
|
|||||||
|
|
||||||
NIR_PASS_V(sel->nir, r600_nir_lower_pack_unpack_2x16);
|
NIR_PASS_V(sel->nir, r600_nir_lower_pack_unpack_2x16);
|
||||||
|
|
||||||
nir_variable_mode io_modes = nir_var_uniform;
|
nir_variable_mode io_modes = nir_var_uniform | nir_var_shader_in;
|
||||||
if (sel->nir->info.stage != MESA_SHADER_VERTEX)
|
|
||||||
io_modes |= nir_var_shader_in;
|
|
||||||
|
|
||||||
if (sel->nir->info.stage != MESA_SHADER_FRAGMENT)
|
if (sel->nir->info.stage != MESA_SHADER_FRAGMENT)
|
||||||
io_modes |= nir_var_shader_out;
|
io_modes |= nir_var_shader_out;
|
||||||
|
@@ -8,6 +8,7 @@ bool r600_lower_tess_io_filter(const nir_instr *instr, gl_shader_stage stage)
|
|||||||
nir_intrinsic_instr *op = nir_instr_as_intrinsic(instr);
|
nir_intrinsic_instr *op = nir_instr_as_intrinsic(instr);
|
||||||
switch (op->intrinsic) {
|
switch (op->intrinsic) {
|
||||||
case nir_intrinsic_load_input:
|
case nir_intrinsic_load_input:
|
||||||
|
return stage == MESA_SHADER_TESS_CTRL || stage == MESA_SHADER_TESS_EVAL;
|
||||||
case nir_intrinsic_load_output:
|
case nir_intrinsic_load_output:
|
||||||
case nir_intrinsic_load_per_vertex_input:
|
case nir_intrinsic_load_per_vertex_input:
|
||||||
case nir_intrinsic_load_per_vertex_output:
|
case nir_intrinsic_load_per_vertex_output:
|
||||||
|
@@ -292,9 +292,9 @@ bool ShaderFromNirProcessor::process_uniforms(nir_variable *uniform)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ShaderFromNirProcessor::process_inputs(nir_variable *input)
|
bool ShaderFromNirProcessor::scan_inputs_read(const nir_shader *sh)
|
||||||
{
|
{
|
||||||
return do_process_inputs(input);
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ShaderFromNirProcessor::process_outputs(nir_variable *output)
|
bool ShaderFromNirProcessor::process_outputs(nir_variable *output)
|
||||||
|
@@ -92,6 +92,8 @@ public:
|
|||||||
|
|
||||||
void get_array_info(r600_shader& shader) const;
|
void get_array_info(r600_shader& shader) const;
|
||||||
|
|
||||||
|
virtual bool scan_inputs_read(const nir_shader *sh);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void set_var_address(nir_deref_instr *instr);
|
void set_var_address(nir_deref_instr *instr);
|
||||||
@@ -176,7 +178,6 @@ private:
|
|||||||
|
|
||||||
virtual void emit_shader_start();
|
virtual void emit_shader_start();
|
||||||
virtual bool emit_deref_instruction_override(nir_deref_instr* instr);
|
virtual bool emit_deref_instruction_override(nir_deref_instr* instr);
|
||||||
virtual bool do_process_inputs(nir_variable *input) = 0;
|
|
||||||
virtual bool do_process_outputs(nir_variable *output) = 0;
|
virtual bool do_process_outputs(nir_variable *output) = 0;
|
||||||
virtual bool do_emit_load_deref(const nir_variable *in_var, nir_intrinsic_instr* instr) = 0;
|
virtual bool do_emit_load_deref(const nir_variable *in_var, nir_intrinsic_instr* instr) = 0;
|
||||||
virtual bool do_emit_store_deref(const nir_variable *out_var, nir_intrinsic_instr* instr) = 0;
|
virtual bool do_emit_store_deref(const nir_variable *out_var, nir_intrinsic_instr* instr) = 0;
|
||||||
|
@@ -104,11 +104,6 @@ bool ComputeShaderFromNir::emit_load_num_work_groups(nir_intrinsic_instr* instr)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ComputeShaderFromNir::do_process_inputs(UNUSED nir_variable *input)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ComputeShaderFromNir::do_process_outputs(UNUSED nir_variable *output)
|
bool ComputeShaderFromNir::do_process_outputs(UNUSED nir_variable *output)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
@@ -47,7 +47,6 @@ private:
|
|||||||
bool emit_intrinsic_instruction_override(nir_intrinsic_instr* instr) override;
|
bool emit_intrinsic_instruction_override(nir_intrinsic_instr* instr) override;
|
||||||
|
|
||||||
bool do_allocate_reserved_registers() override;
|
bool do_allocate_reserved_registers() override;
|
||||||
bool do_process_inputs(nir_variable *input) override;
|
|
||||||
bool do_process_outputs(nir_variable *output) override;
|
bool do_process_outputs(nir_variable *output) override;
|
||||||
bool do_emit_load_deref(const nir_variable *in_var, nir_intrinsic_instr* instr) override;
|
bool do_emit_load_deref(const nir_variable *in_var, nir_intrinsic_instr* instr) override;
|
||||||
bool do_emit_store_deref(const nir_variable *out_var, nir_intrinsic_instr* instr) override;
|
bool do_emit_store_deref(const nir_variable *out_var, nir_intrinsic_instr* instr) override;
|
||||||
|
@@ -60,12 +60,6 @@ FragmentShaderFromNir::FragmentShaderFromNir(const nir_shader& nir,
|
|||||||
sh_info().atomic_base = key.ps.first_atomic_counter;
|
sh_info().atomic_base = key.ps.first_atomic_counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FragmentShaderFromNir::do_process_inputs(nir_variable *input)
|
|
||||||
{
|
|
||||||
/* inputs have been lowered */
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FragmentShaderFromNir::do_emit_load_deref(const nir_variable *in_var, nir_intrinsic_instr* instr)
|
bool FragmentShaderFromNir::do_emit_load_deref(const nir_variable *in_var, nir_intrinsic_instr* instr)
|
||||||
{
|
{
|
||||||
assert(0 && "all input derefs should have been lowered");
|
assert(0 && "all input derefs should have been lowered");
|
||||||
|
@@ -49,7 +49,6 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
void emit_shader_start() override;
|
void emit_shader_start() override;
|
||||||
bool do_process_inputs(nir_variable *input) override;
|
|
||||||
bool do_allocate_reserved_registers() override;
|
bool do_allocate_reserved_registers() override;
|
||||||
bool do_process_outputs(nir_variable *output) override;
|
bool do_process_outputs(nir_variable *output) override;
|
||||||
bool do_emit_load_deref(const nir_variable *in_var, nir_intrinsic_instr* instr) override;
|
bool do_emit_load_deref(const nir_variable *in_var, nir_intrinsic_instr* instr) override;
|
||||||
|
@@ -193,39 +193,6 @@ bool GeometryShaderFromNir::process_load_input(nir_intrinsic_instr* instr)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GeometryShaderFromNir::do_process_inputs(nir_variable *input)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (input->data.location == VARYING_SLOT_POS ||
|
|
||||||
input->data.location == VARYING_SLOT_PSIZ ||
|
|
||||||
input->data.location == VARYING_SLOT_FOGC ||
|
|
||||||
input->data.location == VARYING_SLOT_CLIP_VERTEX ||
|
|
||||||
input->data.location == VARYING_SLOT_CLIP_DIST0 ||
|
|
||||||
input->data.location == VARYING_SLOT_CLIP_DIST1 ||
|
|
||||||
input->data.location == VARYING_SLOT_COL0 ||
|
|
||||||
input->data.location == VARYING_SLOT_COL1 ||
|
|
||||||
input->data.location == VARYING_SLOT_BFC0 ||
|
|
||||||
input->data.location == VARYING_SLOT_BFC1 ||
|
|
||||||
input->data.location == VARYING_SLOT_PNTC ||
|
|
||||||
(input->data.location >= VARYING_SLOT_VAR0 &&
|
|
||||||
input->data.location <= VARYING_SLOT_VAR31) ||
|
|
||||||
(input->data.location >= VARYING_SLOT_TEX0 &&
|
|
||||||
input->data.location <= VARYING_SLOT_TEX7)) {
|
|
||||||
|
|
||||||
r600_shader_io& io = sh_info().input[input->data.driver_location];
|
|
||||||
auto semantic = r600_get_varying_semantic(input->data.location);
|
|
||||||
io.name = semantic.first;
|
|
||||||
io.sid = semantic.second;
|
|
||||||
|
|
||||||
io.ring_offset = 16 * input->data.driver_location;
|
|
||||||
++sh_info().ninput;
|
|
||||||
m_next_input_ring_offset += 16;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GeometryShaderFromNir::do_process_outputs(nir_variable *output)
|
bool GeometryShaderFromNir::do_process_outputs(nir_variable *output)
|
||||||
{
|
{
|
||||||
if (output->data.location == VARYING_SLOT_COL0 ||
|
if (output->data.location == VARYING_SLOT_COL0 ||
|
||||||
|
@@ -44,7 +44,6 @@ private:
|
|||||||
bool do_emit_load_deref(const nir_variable *in_var, nir_intrinsic_instr* instr) override;
|
bool do_emit_load_deref(const nir_variable *in_var, nir_intrinsic_instr* instr) override;
|
||||||
bool do_emit_store_deref(const nir_variable *out_var, nir_intrinsic_instr* instr) override;
|
bool do_emit_store_deref(const nir_variable *out_var, nir_intrinsic_instr* instr) override;
|
||||||
|
|
||||||
bool do_process_inputs(nir_variable *input) override;
|
|
||||||
bool do_allocate_reserved_registers() override;
|
bool do_allocate_reserved_registers() override;
|
||||||
bool do_process_outputs(nir_variable *output) override;
|
bool do_process_outputs(nir_variable *output) override;
|
||||||
bool emit_intrinsic_instruction_override(nir_intrinsic_instr* instr) override;
|
bool emit_intrinsic_instruction_override(nir_intrinsic_instr* instr) override;
|
||||||
|
@@ -16,7 +16,6 @@ private:
|
|||||||
bool emit_intrinsic_instruction_override(nir_intrinsic_instr* instr) override;
|
bool emit_intrinsic_instruction_override(nir_intrinsic_instr* instr) override;
|
||||||
bool store_tess_factor(nir_intrinsic_instr* instr);
|
bool store_tess_factor(nir_intrinsic_instr* instr);
|
||||||
|
|
||||||
bool do_process_inputs(nir_variable *input) override { return true;}
|
|
||||||
bool do_process_outputs(nir_variable *output) override;
|
bool do_process_outputs(nir_variable *output) override;
|
||||||
bool do_emit_load_deref(const nir_variable *in_var, nir_intrinsic_instr* instr) override { return true;}
|
bool do_emit_load_deref(const nir_variable *in_var, nir_intrinsic_instr* instr) override { return true;}
|
||||||
bool do_emit_store_deref(const nir_variable *out_var, nir_intrinsic_instr* instr) override { return true;}
|
bool do_emit_store_deref(const nir_variable *out_var, nir_intrinsic_instr* instr) override { return true;}
|
||||||
|
@@ -19,30 +19,6 @@ TEvalShaderFromNir::TEvalShaderFromNir(r600_pipe_shader *sh, r600_pipe_shader_se
|
|||||||
m_export_processor.reset(new VertexStageExportForFS(*this, &sel.so, sh, key));
|
m_export_processor.reset(new VertexStageExportForFS(*this, &sel.so, sh, key));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TEvalShaderFromNir::do_process_inputs(nir_variable *input)
|
|
||||||
{
|
|
||||||
if (input->data.location == VARYING_SLOT_POS ||
|
|
||||||
input->data.location == VARYING_SLOT_PSIZ ||
|
|
||||||
input->data.location == VARYING_SLOT_CLIP_DIST0 ||
|
|
||||||
input->data.location == VARYING_SLOT_CLIP_DIST1 ||
|
|
||||||
(input->data.location >= VARYING_SLOT_VAR0 &&
|
|
||||||
input->data.location <= VARYING_SLOT_VAR31) ||
|
|
||||||
(input->data.location >= VARYING_SLOT_TEX0 &&
|
|
||||||
input->data.location <= VARYING_SLOT_TEX7) ||
|
|
||||||
(input->data.location >= VARYING_SLOT_PATCH0 &&
|
|
||||||
input->data.location <= VARYING_SLOT_TESS_MAX)) {
|
|
||||||
|
|
||||||
r600_shader_io& io = sh_info().input[input->data.driver_location];
|
|
||||||
tgsi_get_gl_varying_semantic(static_cast<gl_varying_slot>( input->data.location),
|
|
||||||
true, &io.name, &io.sid);
|
|
||||||
++sh_info().ninput;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TEvalShaderFromNir::scan_sysvalue_access(nir_instr *instr)
|
bool TEvalShaderFromNir::scan_sysvalue_access(nir_instr *instr)
|
||||||
{
|
{
|
||||||
if (instr->type != nir_instr_type_intrinsic)
|
if (instr->type != nir_instr_type_intrinsic)
|
||||||
|
@@ -21,7 +21,6 @@ public:
|
|||||||
bool emit_load_tess_coord(nir_intrinsic_instr* instr);
|
bool emit_load_tess_coord(nir_intrinsic_instr* instr);
|
||||||
bool load_tess_z_coord(nir_intrinsic_instr* instr);
|
bool load_tess_z_coord(nir_intrinsic_instr* instr);
|
||||||
|
|
||||||
bool do_process_inputs(nir_variable *input) override;
|
|
||||||
bool do_process_outputs(nir_variable *output) override;
|
bool do_process_outputs(nir_variable *output) override;
|
||||||
bool do_emit_load_deref(const nir_variable *in_var, nir_intrinsic_instr* instr) override { return true;}
|
bool do_emit_load_deref(const nir_variable *in_var, nir_intrinsic_instr* instr) override { return true;}
|
||||||
bool do_emit_store_deref(const nir_variable *out_var, nir_intrinsic_instr* instr) override;
|
bool do_emit_store_deref(const nir_variable *out_var, nir_intrinsic_instr* instr) override;
|
||||||
|
@@ -72,19 +72,18 @@ VertexShaderFromNir::VertexShaderFromNir(r600_pipe_shader *sh,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VertexShaderFromNir::do_process_inputs(nir_variable *input)
|
bool VertexShaderFromNir::scan_inputs_read(const nir_shader *sh)
|
||||||
{
|
{
|
||||||
++sh_info().ninput;
|
uint64_t inputs = sh->info.inputs_read;
|
||||||
|
|
||||||
if (input->data.location < VERT_ATTRIB_MAX) {
|
while (inputs) {
|
||||||
increment_reserved_registers();
|
unsigned i = u_bit_scan64(&inputs);
|
||||||
if (m_max_attrib < input->data.driver_location)
|
if (i < VERT_ATTRIB_MAX) {
|
||||||
m_max_attrib = input->data.driver_location;
|
++sh_info().ninput;
|
||||||
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
fprintf(stderr, "r600-NIR-VS: Unimplemented process_inputs for %d\n", input->data.location);
|
m_max_attrib = sh_info().ninput;
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VertexShaderFromNir::do_allocate_reserved_registers()
|
bool VertexShaderFromNir::do_allocate_reserved_registers()
|
||||||
@@ -177,11 +176,33 @@ bool VertexShaderFromNir::emit_intrinsic_instruction_override(nir_intrinsic_inst
|
|||||||
return emit_store_local_shared(instr);
|
return emit_store_local_shared(instr);
|
||||||
case nir_intrinsic_store_output:
|
case nir_intrinsic_store_output:
|
||||||
return m_export_processor->store_output(instr);
|
return m_export_processor->store_output(instr);
|
||||||
|
case nir_intrinsic_load_input:
|
||||||
|
return load_input(instr);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool VertexShaderFromNir::load_input(nir_intrinsic_instr* instr)
|
||||||
|
{
|
||||||
|
unsigned location = nir_intrinsic_base(instr);
|
||||||
|
|
||||||
|
if (location < VERT_ATTRIB_MAX) {
|
||||||
|
for (unsigned i = 0; i < nir_dest_num_components(instr->dest); ++i) {
|
||||||
|
auto src = m_attribs[4 * location + i];
|
||||||
|
|
||||||
|
if (i == 0)
|
||||||
|
set_input(location, src);
|
||||||
|
|
||||||
|
load_preloaded_value(instr->dest, i, src, i == (unsigned)(instr->num_components - 1));
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
fprintf(stderr, "r600-NIR: Unimplemented load_deref for %d\n", location);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool VertexShaderFromNir::emit_store_local_shared(nir_intrinsic_instr* instr)
|
bool VertexShaderFromNir::emit_store_local_shared(nir_intrinsic_instr* instr)
|
||||||
{
|
{
|
||||||
unsigned write_mask = nir_intrinsic_write_mask(instr);
|
unsigned write_mask = nir_intrinsic_write_mask(instr);
|
||||||
|
@@ -55,12 +55,16 @@ protected:
|
|||||||
void do_finalize() override;
|
void do_finalize() override;
|
||||||
|
|
||||||
std::map<unsigned, unsigned> m_param_map;
|
std::map<unsigned, unsigned> m_param_map;
|
||||||
|
|
||||||
|
bool scan_inputs_read(const nir_shader *sh) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool load_input(nir_intrinsic_instr* instr);
|
||||||
|
|
||||||
bool do_emit_store_deref(const nir_variable *out_var, nir_intrinsic_instr* instr) override;
|
bool do_emit_store_deref(const nir_variable *out_var, nir_intrinsic_instr* instr) override;
|
||||||
void finalize_exports();
|
void finalize_exports();
|
||||||
|
|
||||||
void emit_shader_start() override;
|
void emit_shader_start() override;
|
||||||
bool do_process_inputs(nir_variable *input) override;
|
|
||||||
bool do_allocate_reserved_registers() override;
|
bool do_allocate_reserved_registers() override;
|
||||||
bool do_process_outputs(nir_variable *output) override;
|
bool do_process_outputs(nir_variable *output) override;
|
||||||
bool emit_intrinsic_instruction_override(nir_intrinsic_instr* instr) override;
|
bool emit_intrinsic_instruction_override(nir_intrinsic_instr* instr) override;
|
||||||
|
Reference in New Issue
Block a user