mirror of
https://gitee.com/openharmony/third_party_mesa3d
synced 2024-11-27 17:40:43 +00:00
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:
parent
65bec7ab0a
commit
3bbc078025
@ -303,13 +303,9 @@ bool ShaderFromNir::emit_instruction(nir_instr *instr)
|
||||
|
||||
bool ShaderFromNir::process_declaration()
|
||||
{
|
||||
// scan declarations
|
||||
nir_foreach_shader_in_variable(variable, sh) {
|
||||
if (!impl->process_inputs(variable)) {
|
||||
fprintf(stderr, "R600: error parsing input variable %s\n", variable->name);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!impl->scan_inputs_read(sh))
|
||||
return false;
|
||||
|
||||
// scan declarations
|
||||
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_variable_mode io_modes = nir_var_uniform;
|
||||
if (sel->nir->info.stage != MESA_SHADER_VERTEX)
|
||||
io_modes |= nir_var_shader_in;
|
||||
nir_variable_mode io_modes = nir_var_uniform | nir_var_shader_in;
|
||||
|
||||
if (sel->nir->info.stage != MESA_SHADER_FRAGMENT)
|
||||
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);
|
||||
switch (op->intrinsic) {
|
||||
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_per_vertex_input:
|
||||
case nir_intrinsic_load_per_vertex_output:
|
||||
|
@ -292,9 +292,9 @@ bool ShaderFromNirProcessor::process_uniforms(nir_variable *uniform)
|
||||
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)
|
||||
|
@ -92,6 +92,8 @@ public:
|
||||
|
||||
void get_array_info(r600_shader& shader) const;
|
||||
|
||||
virtual bool scan_inputs_read(const nir_shader *sh);
|
||||
|
||||
protected:
|
||||
|
||||
void set_var_address(nir_deref_instr *instr);
|
||||
@ -176,7 +178,6 @@ private:
|
||||
|
||||
virtual void emit_shader_start();
|
||||
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_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;
|
||||
|
@ -104,11 +104,6 @@ bool ComputeShaderFromNir::emit_load_num_work_groups(nir_intrinsic_instr* instr)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ComputeShaderFromNir::do_process_inputs(UNUSED nir_variable *input)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ComputeShaderFromNir::do_process_outputs(UNUSED nir_variable *output)
|
||||
{
|
||||
return true;
|
||||
|
@ -47,7 +47,6 @@ private:
|
||||
bool emit_intrinsic_instruction_override(nir_intrinsic_instr* instr) 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_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;
|
||||
|
@ -60,12 +60,6 @@ FragmentShaderFromNir::FragmentShaderFromNir(const nir_shader& nir,
|
||||
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)
|
||||
{
|
||||
assert(0 && "all input derefs should have been lowered");
|
||||
|
@ -49,7 +49,6 @@ private:
|
||||
};
|
||||
|
||||
void emit_shader_start() override;
|
||||
bool do_process_inputs(nir_variable *input) override;
|
||||
bool do_allocate_reserved_registers() override;
|
||||
bool do_process_outputs(nir_variable *output) 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;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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_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_process_outputs(nir_variable *output) 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 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_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;}
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
if (instr->type != nir_instr_type_intrinsic)
|
||||
|
@ -21,7 +21,6 @@ public:
|
||||
bool emit_load_tess_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_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;
|
||||
|
@ -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) {
|
||||
increment_reserved_registers();
|
||||
if (m_max_attrib < input->data.driver_location)
|
||||
m_max_attrib = input->data.driver_location;
|
||||
|
||||
return true;
|
||||
while (inputs) {
|
||||
unsigned i = u_bit_scan64(&inputs);
|
||||
if (i < VERT_ATTRIB_MAX) {
|
||||
++sh_info().ninput;
|
||||
}
|
||||
}
|
||||
fprintf(stderr, "r600-NIR-VS: Unimplemented process_inputs for %d\n", input->data.location);
|
||||
return false;
|
||||
m_max_attrib = sh_info().ninput;
|
||||
return true;
|
||||
}
|
||||
|
||||
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);
|
||||
case nir_intrinsic_store_output:
|
||||
return m_export_processor->store_output(instr);
|
||||
case nir_intrinsic_load_input:
|
||||
return load_input(instr);
|
||||
|
||||
default:
|
||||
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)
|
||||
{
|
||||
unsigned write_mask = nir_intrinsic_write_mask(instr);
|
||||
|
@ -55,12 +55,16 @@ protected:
|
||||
void do_finalize() override;
|
||||
|
||||
std::map<unsigned, unsigned> m_param_map;
|
||||
|
||||
bool scan_inputs_read(const nir_shader *sh) override;
|
||||
|
||||
private:
|
||||
bool load_input(nir_intrinsic_instr* instr);
|
||||
|
||||
bool do_emit_store_deref(const nir_variable *out_var, nir_intrinsic_instr* instr) override;
|
||||
void finalize_exports();
|
||||
|
||||
void emit_shader_start() override;
|
||||
bool do_process_inputs(nir_variable *input) override;
|
||||
bool do_allocate_reserved_registers() override;
|
||||
bool do_process_outputs(nir_variable *output) override;
|
||||
bool emit_intrinsic_instruction_override(nir_intrinsic_instr* instr) override;
|
||||
|
Loading…
Reference in New Issue
Block a user