mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 05:08:08 +02:00
r600/sfn: copy-propagate single source texture values
Signed-off-by: Gert Wollny <gert.wollny@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18619>
This commit is contained in:
parent
1fc76aae10
commit
c23604324b
4 changed files with 56 additions and 13 deletions
|
|
@ -357,6 +357,28 @@ bool TexInstr::from_nir(nir_tex_instr *tex, Shader& shader)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TexInstr::replace_source(PRegister old_src, PVirtualValue new_src)
|
||||||
|
{
|
||||||
|
if (old_src->pin() != pin_free)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!new_src->as_register())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
bool success = false;
|
||||||
|
for (int i = 0; i < 4; ++i) {
|
||||||
|
if (m_src[i]->equal_to(*old_src)) {
|
||||||
|
m_src.set_value(i, new_src->as_register());
|
||||||
|
success = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (success) {
|
||||||
|
old_src->del_use(this);
|
||||||
|
new_src->as_register()->add_use(this);
|
||||||
|
}
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
struct SamplerId {
|
struct SamplerId {
|
||||||
int id;
|
int id;
|
||||||
bool indirect;
|
bool indirect;
|
||||||
|
|
|
||||||
|
|
@ -154,6 +154,8 @@ public:
|
||||||
|
|
||||||
auto prepare_instr() const { return m_prepare_instr;}
|
auto prepare_instr() const { return m_prepare_instr;}
|
||||||
|
|
||||||
|
bool replace_source(PRegister old_src, PVirtualValue new_src) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool do_ready() const override;
|
bool do_ready() const override;
|
||||||
|
|
|
||||||
|
|
@ -522,7 +522,20 @@ void SimplifySourceVecVisitor::visit(TexInstr *instr)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (instr->opcode() != TexInstr::get_resinfo) {
|
if (instr->opcode() != TexInstr::get_resinfo) {
|
||||||
replace_src(instr, instr->src());
|
auto& src = instr->src();
|
||||||
|
replace_src(instr, src);
|
||||||
|
int nvals = 0;
|
||||||
|
for (int i = 0; i < 4; ++i)
|
||||||
|
if (src[i]->chan() < 4)
|
||||||
|
++nvals;
|
||||||
|
if (nvals == 1) {
|
||||||
|
for (int i = 0; i < 4; ++i)
|
||||||
|
if (src[i]->chan() < 4)
|
||||||
|
src[i]->set_pin(pin_free);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (auto& prep : instr->prepare_instr()) {
|
||||||
|
prep->accept(*this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -272,21 +272,27 @@ public:
|
||||||
return m_values[i]->value();
|
return m_values[i]->value();
|
||||||
}
|
}
|
||||||
|
|
||||||
PRegister operator [] (int i) {
|
PRegister operator [] (int i) {
|
||||||
return m_values[i]->value();
|
return m_values[i]->value();
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_value(int i, PRegister reg) {
|
void set_value(int i, PRegister reg) {
|
||||||
assert(reg->sel() == m_sel);
|
if (reg->chan() < 4) {
|
||||||
m_swz[i] = reg->chan();
|
for (int k = 0; k < 4; ++k) {
|
||||||
m_values[i]->set_value(reg);
|
assert(i == k || m_values[k]->value()->chan() > 3 ||
|
||||||
}
|
m_values[k]->value()->sel() == reg->sel());
|
||||||
|
}
|
||||||
|
m_sel = reg->sel();
|
||||||
|
}
|
||||||
|
m_swz[i] = reg->chan();
|
||||||
|
m_values[i]->set_value(reg);
|
||||||
|
}
|
||||||
|
|
||||||
bool ready(int block_id, int index) const;
|
bool ready(int block_id, int index) const;
|
||||||
private:
|
private:
|
||||||
int m_sel;
|
int m_sel;
|
||||||
Swizzle m_swz;
|
Swizzle m_swz;
|
||||||
std::array<R600_POINTER_TYPE(Element), 4> m_values;
|
std::array<R600_POINTER_TYPE(Element), 4> m_values;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool operator == (const RegisterVec4& lhs, const RegisterVec4& rhs);
|
bool operator == (const RegisterVec4& lhs, const RegisterVec4& rhs);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue