r600/sfn: remove old cube texturing code

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9302>
This commit is contained in:
Gert Wollny
2021-01-04 09:55:40 +01:00
committed by Marge Bot
parent 488c93ac11
commit 23b87b56b6
2 changed files with 1 additions and 363 deletions

View File

@@ -43,30 +43,7 @@ bool EmitTexInstruction::do_emit(nir_instr* instr)
if (!get_inputs(*ir, src))
return false;
if (ir->sampler_dim == GLSL_SAMPLER_DIM_CUBE) {
switch (ir->op) {
case nir_texop_tex:
return emit_cube_tex(ir, src);
case nir_texop_txf:
return emit_cube_txf(ir, src);
case nir_texop_txb:
return emit_cube_txb(ir, src);
case nir_texop_txl:
return emit_cube_txl(ir, src);
case nir_texop_txs:
return emit_tex_txs(ir, src, {0,1,2,3});
case nir_texop_txd:
return emit_cube_txd(ir, src);
case nir_texop_lod:
return emit_cube_lod(ir, src);
case nir_texop_tg4:
return emit_cube_tg4(ir, src);
case nir_texop_query_levels:
return emit_tex_txs(ir, src, {3,7,7,7});
default:
return false;
}
} else if (ir->sampler_dim == GLSL_SAMPLER_DIM_BUF) {
if (ir->sampler_dim == GLSL_SAMPLER_DIM_BUF) {
switch (ir->op) {
case nir_texop_txf:
return emit_buf_txf(ir, src);
@@ -106,290 +83,6 @@ bool EmitTexInstruction::do_emit(nir_instr* instr)
}
}
bool EmitTexInstruction::emit_cube_txf(UNUSED nir_tex_instr* instr, UNUSED TexInputs &src)
{
return false;
}
bool EmitTexInstruction::emit_cube_txd(nir_tex_instr* instr, TexInputs& tex_src)
{
assert(instr->src[0].src.is_ssa);
r600::sfn_log << SfnLog::instr << "emit '"
<< *reinterpret_cast<nir_instr*>(instr)
<< "' (" << __func__ << ")\n";
auto tex_op = TexInstruction::sample_g;
std::array<PValue, 4> v;
for (int i = 0; i < 4; ++i)
v[i] = from_nir(instr->dest, i);
GPRVector cubed(v);
emit_cube_prep(tex_src.coord, cubed, instr->is_array);
std::array<PValue,4> dst_elms;
std::array<PValue,4> src_elms;
const uint16_t lookup[4] = {1, 0, 3, 2};
for (uint16_t i = 0; i < 4; ++i) {
dst_elms[i] = v[i];
src_elms[i] = cubed.reg_i(lookup[i]);
}
GPRVector empty_dst(0, {7,7,7,7});
if (instr->is_shadow) {
emit_instruction(new AluInstruction(op1_mov, src_elms[3], tex_src.comperator,
{alu_last_instr, alu_write}));
tex_op = TexInstruction::sample_c_g;
}
PValue half(new LiteralValue(0.5f));
for (int i = 0; i < 3; ++i) {
emit_instruction(new AluInstruction(op2_mul_ieee, tex_src.ddx.reg_i(i), {tex_src.ddx.reg_i(i), half},
{alu_last_instr, alu_write}));
}
for (int i = 0; i < 3; ++i) {
emit_instruction(new AluInstruction(op2_mul_ieee, tex_src.ddy.reg_i(i), {tex_src.ddy.reg_i(i), half},
{alu_last_instr, alu_write}));
}
auto sampler = get_sampler_id(instr->sampler_index, tex_src.sampler_deref);
assert(!sampler.indirect);
TexInstruction *irgh = new TexInstruction(TexInstruction::set_gradient_h, empty_dst, tex_src.ddx,
sampler.id, sampler.id + R600_MAX_CONST_BUFFERS, tex_src.sampler_offset);
irgh->set_dest_swizzle({7,7,7,7});
TexInstruction *irgv = new TexInstruction(TexInstruction::set_gradient_v, empty_dst, tex_src.ddy,
sampler.id, sampler.id + R600_MAX_CONST_BUFFERS, tex_src.sampler_offset);
irgv->set_dest_swizzle({7,7,7,7});
GPRVector dst(dst_elms);
GPRVector src(src_elms);
TexInstruction *ir = new TexInstruction(tex_op, dst, src, instr->sampler_index,
sampler.id + R600_MAX_CONST_BUFFERS, tex_src.sampler_offset);
set_rect_coordinate_flags(instr, ir);
//set_offsets(ir, tex_src.offset);
emit_instruction(irgh);
emit_instruction(irgv);
emit_instruction(ir);
return true;
}
bool EmitTexInstruction::emit_cube_txl(nir_tex_instr* instr, TexInputs& tex_src)
{
assert(instr->src[0].src.is_ssa);
if (instr->is_shadow)
return false;
r600::sfn_log << SfnLog::instr << "emit '"
<< *reinterpret_cast<nir_instr*>(instr)
<< "' (" << __func__ << ")\n";
std::array<PValue, 4> v;
for (int i = 0; i < 4; ++i)
v[i] = from_nir(instr->dest, i);
GPRVector cubed(v);
emit_cube_prep(tex_src.coord, cubed, instr->is_array);
std::array<PValue,4> dst_elms;
std::array<PValue,4> src_elms;
const uint16_t lookup[4] = {1, 0, 3, 2};
for (uint16_t i = 0; i < 4; ++i) {
dst_elms[i] = v[i];
src_elms[i] = cubed.reg_i(lookup[i]);
}
auto *ir = new AluInstruction(op1_mov, src_elms[3], tex_src.lod,
{alu_last_instr, alu_write});
emit_instruction(ir);
GPRVector src(src_elms);
GPRVector dst(dst_elms);
auto sampler = get_sampler_id(instr->sampler_index, tex_src.sampler_deref);
assert(!sampler.indirect);
auto tir = new TexInstruction(TexInstruction::sample_l, dst, src,
sampler.id,sampler.id + R600_MAX_CONST_BUFFERS,
tex_src.sampler_offset);
if (instr->is_array)
tir->set_flag(TexInstruction::z_unnormalized);
emit_instruction(tir);
return true;
}
bool EmitTexInstruction::emit_cube_lod(nir_tex_instr* instr, TexInputs& src)
{
auto tex_op = TexInstruction::get_tex_lod;
std::array<PValue, 4> v;
for (int i = 0; i < 4; ++i)
v[i] = from_nir(instr->dest, i);
GPRVector cubed(v);
emit_cube_prep(src.coord, cubed, instr->is_array);
auto sampler = get_sampler_id(instr->sampler_index, src.sampler_deref);
assert(!sampler.indirect);
auto dst = make_dest(*instr);
auto irt = new TexInstruction(tex_op, dst, cubed, sampler.id,
sampler.id + R600_MAX_CONST_BUFFERS,
src.sampler_offset);
emit_instruction(irt);
return true;
}
bool EmitTexInstruction::emit_cube_txb(nir_tex_instr* instr, TexInputs& tex_src)
{
assert(instr->src[0].src.is_ssa);
r600::sfn_log << SfnLog::instr << "emit '"
<< *reinterpret_cast<nir_instr*>(instr)
<< "' (" << __func__ << ")\n";
std::array<PValue, 4> v;
for (int i = 0; i < 4; ++i)
v[i] = from_nir(instr->dest, i);
GPRVector cubed(v);
emit_cube_prep(tex_src.coord, cubed, instr->is_array);
std::array<PValue,4> dst_elms;
std::array<PValue,4> src_elms;
const uint16_t lookup[4] = {1, 0, 3, 2};
for (uint16_t i = 0; i < 4; ++i) {
dst_elms[i] = v[i];
src_elms[i] = v[lookup[i]];
}
GPRVector src(src_elms);
GPRVector dst(dst_elms);
auto tex_op = TexInstruction::sample_lb;
if (!instr->is_shadow) {
emit_instruction(new AluInstruction(op1_mov, src_elms[3], tex_src.bias,
{alu_last_instr, alu_write}));
} else {
emit_instruction(new AluInstruction(op1_mov, src_elms[3], tex_src.comperator,
{alu_last_instr, alu_write}));
tex_op = TexInstruction::sample_c_lb;
}
auto sampler = get_sampler_id(instr->sampler_index, tex_src.sampler_deref);
assert(!sampler.indirect && "Indirect sampler selection not yet supported");
auto tir = new TexInstruction(tex_op, dst, src,
sampler.id,
sampler.id + R600_MAX_CONST_BUFFERS, tex_src.sampler_offset);
emit_instruction(tir);
return true;
}
bool EmitTexInstruction::emit_cube_tex(nir_tex_instr* instr, TexInputs& tex_src)
{
std::array<PValue, 4> v;
for (int i = 0; i < 4; ++i)
v[i] = from_nir(instr->dest, i);
auto tex_op = TexInstruction::sample;
GPRVector cubed(v);
emit_cube_prep(tex_src.coord, cubed, instr->is_array);
std::array<PValue,4> dst_elms;
std::array<PValue,4> src_elms;
const uint16_t lookup[4] = {1, 0, 3, 2};
for (uint16_t i = 0; i < 4; ++i) {
dst_elms[i] = v[i];
src_elms[i] = v[lookup[i]];
}
if (instr->is_shadow) {
emit_instruction(new AluInstruction(op1_mov, src_elms[3], tex_src.comperator,
{alu_last_instr, alu_write}));
tex_op = TexInstruction::sample_c;
}
GPRVector dst(dst_elms);
GPRVector src(src_elms);
auto sampler = get_sampler_id(instr->sampler_index, tex_src.sampler_deref);
assert(!sampler.indirect && "Indirect sampler selection not yet supported");
auto tir = new TexInstruction(tex_op, dst, src,
sampler.id,
sampler.id + R600_MAX_CONST_BUFFERS, tex_src.sampler_offset);
if (instr->is_array)
tir->set_flag(TexInstruction::z_unnormalized);
emit_instruction(tir);
return true;
}
bool EmitTexInstruction::emit_cube_prep(const GPRVector& coord, GPRVector& cubed, bool is_array)
{
AluInstruction *ir = nullptr;
const uint16_t src0_chan[4] = {2, 2, 0, 1};
const uint16_t src1_chan[4] = {1, 0, 2, 2};
for (int i = 0; i < 4; ++i) {
ir = new AluInstruction(op2_cube, cubed.reg_i(i), coord.reg_i(src0_chan[i]),
coord.reg_i(src1_chan[i]), {alu_write});
emit_instruction(ir);
}
ir->set_flag(alu_last_instr);
ir = new AluInstruction(op1_recip_ieee, cubed.reg_i(2), cubed.reg_i(2), {alu_write, alu_last_instr});
ir->set_flag(alu_src0_abs);
emit_instruction(ir);
PValue one_p_5(new LiteralValue(1.5f));
for (int i = 0; i < 2; ++i) {
ir = new AluInstruction(op3_muladd, cubed.reg_i(i), cubed.reg_i(i), cubed.reg_i(2),
one_p_5, {alu_write});
emit_instruction(ir);
}
ir->set_flag(alu_last_instr);
if (is_array) {
auto face = cubed.reg_i(3);
PValue array_index = get_temp_register();
ir = new AluInstruction(op1_rndne, array_index, coord.reg_i(3), {alu_write, alu_last_instr});
emit_instruction(ir);
ir = new AluInstruction(op2_max, array_index, {array_index, Value::zero}, {alu_write, alu_last_instr});
emit_instruction(ir);
ir = new AluInstruction(op3_muladd, face, {array_index, PValue (new LiteralValue(8.0f)), face},
{alu_write, alu_last_instr});
emit_instruction(ir);
}
return true;
}
bool EmitTexInstruction::emit_buf_txf(nir_tex_instr* instr, TexInputs &src)
{
auto dst = make_dest(*instr);
@@ -740,51 +433,6 @@ bool EmitTexInstruction::emit_tex_tg4(nir_tex_instr* instr, TexInputs& src)
return true;
}
bool EmitTexInstruction::emit_cube_tg4(nir_tex_instr* instr, TexInputs& tex_src)
{
std::array<PValue, 4> v;
for (int i = 0; i < 4; ++i)
v[i] = from_nir(instr->dest, i);
auto tex_op = TexInstruction::gather4;
GPRVector cubed(v);
emit_cube_prep(tex_src.coord, cubed, instr->is_array);
std::array<PValue,4> dst_elms;
std::array<PValue,4> src_elms;
const uint16_t lookup[4] = {1, 0, 3, 2};
for (uint16_t i = 0; i < 4; ++i) {
dst_elms[i] = v[i];
src_elms[i] = v[lookup[i]];
}
if (instr->is_shadow) {
emit_instruction(new AluInstruction(op1_mov, src_elms[3], tex_src.comperator,
{alu_last_instr, alu_write}));
tex_op = TexInstruction::gather4_c;
}
GPRVector dst(dst_elms);
GPRVector src(src_elms);
auto sampler = get_sampler_id(instr->sampler_index, tex_src.sampler_deref);
assert(!sampler.indirect && "Indirect sampler selection not yet supported");
auto tir = new TexInstruction(tex_op, dst, src, sampler.id,
sampler.id + R600_MAX_CONST_BUFFERS, tex_src.sampler_offset);
tir->set_gather_comp(instr->component);
tir->set_dest_swizzle({1, 2, 0, 3});
if (instr->is_array)
tir->set_flag(TexInstruction::z_unnormalized);
emit_instruction(tir);
return true;
}
bool EmitTexInstruction::emit_tex_txf_ms(nir_tex_instr* instr, TexInputs& src)
{
assert(instr->src[0].src.is_ssa);

View File

@@ -55,16 +55,6 @@ private:
PValue texture_offset;
};
bool emit_cube_tex(nir_tex_instr* instr, TexInputs& src);
bool emit_cube_txf(nir_tex_instr* instr, TexInputs& src);
bool emit_cube_txb(nir_tex_instr* instr, TexInputs& src);
bool emit_cube_txl(nir_tex_instr* instr, TexInputs& src);
bool emit_cube_txd(nir_tex_instr* instr, TexInputs& src);
bool emit_cube_lod(nir_tex_instr* instr, TexInputs& src);
bool emit_cube_tg4(nir_tex_instr* instr, TexInputs& src);
bool emit_cube_prep(const GPRVector& coord, GPRVector& cubed, bool is_array);
bool emit_tex_tex(nir_tex_instr* instr, TexInputs& src);
bool emit_tex_txf(nir_tex_instr* instr, TexInputs &src);