r600/sfn: Unify the handling of resource IDs in instruction

Fetch, GDS, Texture, and RAT instructions all use resources
with a possible offset defined by the index register. Unify
the handling of resource ID and the offset register for these
instruction types.

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19300>
This commit is contained in:
Gert Wollny 2022-10-21 20:43:23 +02:00 committed by Marge Bot
parent da1477a934
commit e8e420568d
12 changed files with 143 additions and 126 deletions

View file

@ -430,8 +430,7 @@ void AssamblerVisitor::visit(const TexInstr& tex_instr)
{
clear_states(sf_vtx | sf_alu);
int sampler_offset = 0;
auto addr = tex_instr.sampler_offset();
auto addr = tex_instr.resource_offset();
EBufferIndexMode index_mode = bim_none;
if (addr)
@ -446,8 +445,8 @@ void AssamblerVisitor::visit(const TexInstr& tex_instr)
r600_bytecode_tex tex;
memset(&tex, 0, sizeof(struct r600_bytecode_tex));
tex.op = tex_instr.opcode();
tex.sampler_id = tex_instr.sampler_id() + sampler_offset;
tex.resource_id = tex_instr.resource_id() + sampler_offset;
tex.sampler_id = tex_instr.resource_base();
tex.resource_id = tex_instr.resource_id();
tex.src_gpr = tex_instr.src().sel();
tex.dst_gpr = tex_instr.dst().sel();
tex.dst_sel_x = tex_instr.dest_swizzle(0);
@ -666,7 +665,7 @@ void AssamblerVisitor::visit(const FetchInstr& fetch_instr)
struct r600_bytecode_vtx vtx;
memset(&vtx, 0, sizeof(vtx));
vtx.op = fetch_instr.opcode();
vtx.buffer_id = fetch_instr.resource_id();
vtx.buffer_id = fetch_instr.resource_base();
vtx.fetch_type = fetch_instr.fetch_type();
vtx.src_gpr = fetch_instr.src().sel();
vtx.src_sel_x = fetch_instr.src().chan();
@ -759,10 +758,10 @@ void AssamblerVisitor::visit(const RatInstr& instr)
if (m_ack_suggested /*&& instr.has_instr_flag(Instr::ack_rat_return_write)*/)
emit_wait_ack();
int rat_idx = instr.rat_id();
int rat_idx = instr.resource_base();
EBufferIndexMode rat_index_mode = bim_none;
auto addr = instr.rat_id_offset();
auto addr = instr.resource_offset();
if (addr)
rat_index_mode = emit_index_reg(*addr, 1);
@ -925,7 +924,7 @@ void AssamblerVisitor::visit(const GDSInstr& instr)
struct r600_bytecode_gds gds;
bool indirect = false;
auto addr = instr.uav_id();
auto addr = instr.resource_offset();
if (addr) {
indirect = true;
@ -936,7 +935,7 @@ void AssamblerVisitor::visit(const GDSInstr& instr)
gds.op = ds_opcode_map.at(instr.opcode());
gds.dst_gpr = instr.dest()->sel();
gds.uav_id = instr.uav_base();
gds.uav_id = instr.resource_base();
gds.uav_index_mode = indirect ? bim_one : bim_none;
gds.src_gpr = instr.src().sel();

View file

@ -188,7 +188,10 @@ void Instr::forward_set_blockid(int id, int index)
}
InstrWithVectorResult::InstrWithVectorResult(const RegisterVec4& dest,
const RegisterVec4::Swizzle& dest_swizzle):
const RegisterVec4::Swizzle& dest_swizzle,
int resource_base,
PRegister resource_offset):
InstrWithResource(resource_base, resource_offset),
m_dest(dest),
m_dest_swizzle(dest_swizzle)
{
@ -425,6 +428,7 @@ void Block::lds_group_end()
}
InstrWithVectorResult::InstrWithVectorResult(const InstrWithVectorResult& orig):
InstrWithResource(orig),
m_dest(orig.m_dest),
m_dest_swizzle(orig.m_dest_swizzle)
{

View file

@ -241,9 +241,76 @@ private:
int m_emitted_rat_instr{0};
};
class InstrWithVectorResult : public Instr {
class InstrWithResource : public Instr {
public:
InstrWithVectorResult(const RegisterVec4& dest, const RegisterVec4::Swizzle& dest_swizzle);
InstrWithResource(int base, PRegister offset) :
m_base(base), m_offset(offset)
{
if (m_offset) {
m_offset->add_use(this);
}
}
bool replace_resource_offset(PRegister old_offset, PRegister new_offset) {
if (m_offset && old_offset->equal_to(*m_offset)) {
m_offset->del_use(this);
m_offset = new_offset;
m_offset->add_use(this);
return true;
}
return false;
}
void set_resource_offset(PRegister offset) {
if (m_offset)
m_offset->del_use(this);
m_offset = offset;
if (m_offset) {
m_offset->add_use(this);
}
}
bool resource_is_equal(const InstrWithResource& other) const {
if (m_base != other.m_base)
return false;
if (m_offset && other.m_offset)
return m_offset->equal_to(*other.m_offset);
return !m_offset && !other.m_offset;
}
auto resource_base() const {return m_base;}
auto resource_offset() const {return m_offset;}
auto buffer_index_mode() const -> EBufferIndexMode {
if (!m_offset)
return bim_none;
switch (m_offset->sel()) {
case 1: return bim_zero;
case 2: return bim_one;
default:
unreachable("Invalid resource offset, scheduler must substitute registers");
}
}
bool resource_ready(int block_id, int index) const {
return !m_offset || m_offset->ready(block_id, index);
}
protected:
void print_resource_offset(std::ostream& os) const {
if (m_offset)
os << " + " << *m_offset;
}
private:
int m_base{0};
PRegister m_offset{nullptr};
};
class InstrWithVectorResult : public InstrWithResource {
public:
InstrWithVectorResult(const RegisterVec4& dest,
const RegisterVec4::Swizzle& dest_swizzle,
int resource_base,
PRegister resource_offset);
void set_dest_swizzle(const RegisterVec4::Swizzle& swz) {m_dest_swizzle = swz;}
int dest_swizzle(int i) const { return m_dest_swizzle[i];}

View file

@ -46,7 +46,7 @@ FetchInstr::FetchInstr(EVFetchInstr opcode,
EVFetchEndianSwap endian_swap,
uint32_t resource_id,
PRegister resource_offset):
InstrWithVectorResult(dst, dest_swizzle),
InstrWithVectorResult(dst, dest_swizzle, resource_id, resource_offset),
m_opcode(opcode),
m_src(src),
m_src_offset(src_offset),
@ -54,8 +54,6 @@ FetchInstr::FetchInstr(EVFetchInstr opcode,
m_data_format(data_format),
m_num_format(num_format),
m_endian_swap(endian_swap),
m_resource_id(resource_id),
m_resource_offset(resource_offset),
m_mega_fetch_count(0),
m_array_base(0),
m_array_size(0),
@ -83,9 +81,6 @@ FetchInstr::FetchInstr(EVFetchInstr opcode,
if (m_src)
m_src->add_use(this);
if (m_resource_offset && m_resource_offset->as_register())
m_resource_offset->as_register()->add_use(this);
}
void FetchInstr::accept(ConstInstrVisitor& visitor) const
@ -115,10 +110,10 @@ bool FetchInstr::is_equal_to(const FetchInstr& rhs) const
if (m_tex_flags != rhs.m_tex_flags)
return false;
if (m_resource_offset && rhs.m_resource_offset) {
if (!m_resource_offset->equal_to(*rhs.m_resource_offset))
if (resource_offset() && rhs.resource_offset()) {
if (!resource_offset()->equal_to(*rhs.resource_offset()))
return false;
} else if (!(!!m_resource_offset == !!rhs.m_resource_offset))
} else if (!(!!resource_offset() == !!rhs.resource_offset()))
return false;
return m_opcode == rhs.m_opcode &&
@ -127,11 +122,11 @@ bool FetchInstr::is_equal_to(const FetchInstr& rhs) const
m_data_format == rhs.m_data_format &&
m_num_format == rhs.m_num_format &&
m_endian_swap == rhs.m_endian_swap &&
m_resource_id == rhs.m_resource_id &&
m_mega_fetch_count == rhs.m_mega_fetch_count &&
m_array_base == rhs.m_array_base &&
m_array_size == rhs.m_array_size &&
m_elm_size == rhs.m_elm_size;
m_elm_size == rhs.m_elm_size &&
resource_base() == rhs.resource_base();
}
bool FetchInstr::propagate_death()
@ -153,12 +148,7 @@ bool FetchInstr::replace_source(PRegister old_src, PVirtualValue new_src)
new_reg->add_use(this);
success = true;
}
if (m_resource_offset && old_src->equal_to(*m_resource_offset)) {
m_resource_offset->del_use(this);
m_resource_offset = new_reg;
new_reg->add_use(this);
success = true;
}
success |= replace_resource_offset(old_src, new_reg);
}
return success;
}
@ -171,11 +161,8 @@ bool FetchInstr::do_ready() const
}
bool result = m_src && m_src->ready(block_id(), index());
if (m_resource_offset) {
auto r = m_resource_offset->as_register();
if (r)
result &= r->ready(block_id(), index());
}
if (resource_offset())
result &= resource_offset()->ready(block_id(), index());
return result;
}
@ -197,12 +184,9 @@ void FetchInstr::do_print(std::ostream& os) const
}
if (m_opcode != vc_read_scratch)
os << " RID:" << m_resource_id;
os << " RID:" << resource_base();
if (m_resource_offset) {
os << " + ";
m_resource_offset->print(os);
}
print_resource_offset(os);
if (!m_skip_print.test(ftype)) {
switch (m_fetch_type) {

View file

@ -78,8 +78,7 @@ public:
const auto& src() const {assert(m_src); return *m_src;}
uint32_t src_offset() const {return m_src_offset;}
uint32_t resource_id() const {return m_resource_id;}
auto resource_offset() const {return m_resource_offset;}
uint32_t resource_id() const __attribute__((deprecated)) {return resource_base();}
EVFetchType fetch_type() const {return m_fetch_type;}
EVTXDataFormat data_format() const {return m_data_format;}
@ -140,9 +139,6 @@ private:
EVFetchNumFormat m_num_format;
EVFetchEndianSwap m_endian_swap;
uint32_t m_resource_id;
PRegister m_resource_offset;
std::bitset<EFlags::unknown> m_tex_flags;
std::bitset<EPrintSkip::count> m_skip_print;

View file

@ -35,19 +35,15 @@ namespace r600 {
GDSInstr::GDSInstr(ESDOp op, Register *dest,
const RegisterVec4& src, int uav_base,
PRegister uav_id):
InstrWithResource(uav_base, uav_id),
m_op(op),
m_dest(dest),
m_src(src),
m_uav_base(uav_base),
m_uav_id(uav_id)
m_src(src)
{
set_always_keep();
m_src.add_use(this);
m_dest->add_parent(this);
if (m_uav_id)
m_uav_id->add_use(this);
}
bool GDSInstr::is_equal_to(const GDSInstr& rhs) const
@ -55,13 +51,12 @@ bool GDSInstr::is_equal_to(const GDSInstr& rhs) const
#define NE(X) (X != rhs. X)
if (NE(m_op) ||
NE(m_src) ||
NE(m_uav_base))
NE(m_src))
return false;
sfn_value_equal(m_dest, rhs.m_dest);
return sfn_value_equal(m_uav_id, rhs.m_uav_id);
return resource_is_equal(rhs);
}
void GDSInstr::accept(ConstInstrVisitor& visitor) const
@ -77,7 +72,7 @@ void GDSInstr::accept(InstrVisitor& visitor)
bool GDSInstr::do_ready() const
{
return m_src.ready(block_id(), index()) &&
(!m_uav_id || m_uav_id->ready(block_id(), index()));
resource_ready(block_id(), index());
}
void GDSInstr::do_print(std::ostream& os) const
@ -85,10 +80,9 @@ void GDSInstr::do_print(std::ostream& os) const
os << "GDS " << lds_ops.at(m_op).name
<< *m_dest;
os << " " << m_src;
os << " BASE:" << m_uav_base;
os << " BASE:" << resource_base();
if (m_uav_id)
os << " UAV:" << *m_uav_id;
print_resource_offset(os);
}
bool GDSInstr::emit_atomic_counter(nir_intrinsic_instr *intr, Shader& shader)
@ -323,22 +317,18 @@ RatInstr::RatInstr(ECFOpCode cf_opcode, ERatOp rat_op,
const RegisterVec4& data, const RegisterVec4& index,
int rat_id, PRegister rat_id_offset,
int burst_count, int comp_mask, int element_size):
InstrWithResource(rat_id, rat_id_offset),
m_cf_opcode(cf_opcode),
m_rat_op(rat_op),
m_data(data),
m_index(index),
m_rat_id_offset(rat_id_offset),
m_rat_id(rat_id),
m_burst_count(burst_count),
m_comp_mask(comp_mask),
m_element_size(element_size)
{
set_always_keep();
m_data.add_use(this);
m_index.add_use(this);
if (m_rat_id_offset)
m_rat_id_offset->add_use(this);
}
@ -375,9 +365,8 @@ bool RatInstr::do_ready() const
void RatInstr::do_print(std::ostream& os) const
{
os << "MEM_RAT RAT " << m_rat_id;
if (m_rat_id_offset)
os << "+" << *m_rat_id_offset;
os << "MEM_RAT RAT " << resource_base();
print_resource_offset(os);
os << " @" << m_index;
os << " OP:" << m_rat_op << " " << m_data;
os << " BC:" << m_burst_count

View file

@ -34,7 +34,7 @@ namespace r600 {
class Shader;
class GDSInstr : public Instr {
class GDSInstr : public InstrWithResource {
public:
GDSInstr(ESDOp op, Register *dest,
@ -54,9 +54,6 @@ public:
const auto& dest() const { return m_dest;}
auto& dest() { return m_dest;}
auto uav_id() const {return m_uav_id;}
auto uav_base() const {return m_uav_base;}
static auto from_string(std::istream& is, ValueFactory& value_factory) -> Pointer;
static bool emit_atomic_counter(nir_intrinsic_instr *intr, Shader& shader);
@ -76,13 +73,11 @@ private:
RegisterVec4 m_src;
int m_uav_base{0};
PRegister m_uav_id{nullptr};
std::bitset<8> m_tex_flags;
};
class RatInstr : public Instr {
class RatInstr : public InstrWithResource {
public:
enum ERatOp {
@ -132,9 +127,6 @@ public:
int rat_id, PRegister rat_id_offset,
int burst_count, int comp_mask, int element_size);
auto rat_id_offset() const { return m_rat_id_offset;}
int rat_id() const { return m_rat_id;}
ERatOp rat_op() const {return m_rat_op;}
const auto& value() const { return m_data;}
@ -186,9 +178,7 @@ private:
RegisterVec4 m_data;
RegisterVec4 m_index;
PRegister m_rat_id_offset{nullptr};
int m_rat_id{0};
int m_burst_count{0};
int m_comp_mask{15};
int m_element_size{3};

View file

@ -39,20 +39,15 @@ using std::string;
TexInstr::TexInstr(Opcode op, const RegisterVec4& dest,
const RegisterVec4::Swizzle& dest_swizzle,
const RegisterVec4& src, unsigned sid, unsigned rid,
PVirtualValue sampler_offs):
InstrWithVectorResult(dest, dest_swizzle),
PRegister sampler_offs):
InstrWithVectorResult(dest, dest_swizzle, sid, sampler_offs),
m_opcode(op),
m_src(src),
m_sampler_offset(sampler_offs),
m_inst_mode(0),
m_sampler_id(sid),
m_resource_id(rid)
{
memset(m_offset, 0, sizeof(m_offset));
m_src.add_use(this);
if (m_sampler_offset && m_sampler_offset->as_register())
m_sampler_offset->as_register()->add_use(this);
}
void TexInstr::accept(ConstInstrVisitor& visitor) const
@ -93,11 +88,11 @@ bool TexInstr::is_equal_to(const TexInstr& lhs) const
if (m_src != lhs.m_src)
return false;
if (m_sampler_offset && lhs.m_sampler_offset) {
if (!m_sampler_offset->equal_to(*lhs.m_sampler_offset))
if (resource_offset() && lhs.resource_offset()) {
if (!resource_offset()->equal_to(*lhs.resource_offset()))
return false;
} else if ((m_sampler_offset && !lhs.m_sampler_offset) ||
(!m_sampler_offset && lhs.m_sampler_offset))
} else if ((resource_offset() && !lhs.resource_offset()) ||
(!resource_offset() && lhs.resource_offset()))
return false;
if (m_tex_flags != lhs.m_tex_flags)
@ -108,7 +103,7 @@ bool TexInstr::is_equal_to(const TexInstr& lhs) const
return false;
}
return m_inst_mode == lhs.m_inst_mode &&
m_sampler_id == lhs.m_sampler_id &&
resource_base() == lhs.resource_base() &&
m_resource_id == lhs.m_resource_id;
}
@ -129,8 +124,7 @@ bool TexInstr::do_ready() const
return false;
}
if (m_sampler_offset && m_sampler_offset->as_register() &&
!m_sampler_offset->as_register()->ready(block_id(), index()))
if (resource_offset() && !resource_offset()->ready(block_id(), index()))
return false;
return m_src.ready(block_id(), index());
}
@ -149,10 +143,10 @@ void TexInstr::do_print(std::ostream& os) const
m_src.print(os);
os << " RID:" << m_resource_id
<< " SID:" << m_sampler_id;
<< " SID:" << resource_base();
if (m_sampler_offset)
os << " SO:" << *m_sampler_offset;
if (resource_offset())
os << " SO:" << *resource_offset();
if (m_offset[0])
os << " OX:" << m_offset[0];
@ -318,7 +312,7 @@ void TexInstr::set_tex_param(const std::string& token)
else if (token.substr(0,5) == "MODE:")
set_inst_mode(int_from_string_with_prefix(token, "MODE:"));
else if (token.substr(0,3) == "SO:")
set_sampler_offset(VirtualValue::from_string(token.substr(3)));
set_resource_offset(VirtualValue::from_string(token.substr(3))->as_register());
else {
std::cerr << "Token '" << token << "': ";
unreachable("Unknown token in tex param");
@ -407,13 +401,13 @@ void TexInstr::emit_set_gradients(nir_tex_instr* tex, int sampler_id,
grad[0] = new TexInstr(set_gradient_h, empty_dst, {7,7,7,7}, src.ddx,
sampler_id,
sampler_id + R600_MAX_CONST_BUFFERS,
src.sampler_offset);
src.resource_offset);
grad[0]->set_rect_coordinate_flags(tex);
grad[0]->set_always_keep();
grad[1] = new TexInstr(set_gradient_v, empty_dst, {7,7,7,7}, src.ddy,
sampler_id, sampler_id + R600_MAX_CONST_BUFFERS,
src.sampler_offset);
src.resource_offset);
grad[1]->set_rect_coordinate_flags(tex);
grad[1]->set_always_keep();
irt->add_prepare_instr(grad[0]);
@ -444,7 +438,7 @@ void TexInstr::emit_set_offsets(nir_tex_instr* tex, int sampler_id,
auto set_ofs = new TexInstr(TexInstr::set_offsets, empty_dst, {7,7,7,7},
ofs, sampler_id,
sampler_id + R600_MAX_CONST_BUFFERS,
src.sampler_offset);
src.resource_offset);
set_ofs->set_always_keep();
irt->add_prepare_instr(set_ofs);
}
@ -485,7 +479,7 @@ bool TexInstr::emit_lowered_tex(nir_tex_instr* tex, Inputs& src, Shader& shader)
}
auto irt = new TexInstr(src.opcode, dst, dst_swz, src_coord, sampler.id,
sampler.id + R600_MAX_CONST_BUFFERS,
src.sampler_offset);
src.resource_offset);
if (tex->op == nir_texop_txd)
emit_set_gradients(tex, sampler.id, src, irt, shader);
@ -514,8 +508,8 @@ bool TexInstr::emit_buf_txf(nir_tex_instr *tex, Inputs& src, Shader& shader)
auto dst = vf.dest_vec4(tex->dest, pin_group);
PRegister tex_offset = nullptr;
if (src.texture_offset)
tex_offset = shader.emit_load_to_register(src.texture_offset);
if (src.resource_offset)
tex_offset = shader.emit_load_to_register(src.resource_offset);
auto *real_dst = &dst;
RegisterVec4 tmp = vf.temp_vec4(pin_group);
@ -559,8 +553,9 @@ bool TexInstr::emit_tex_texture_samples(nir_tex_instr* instr, Inputs& src, Shade
int res_id = R600_MAX_CONST_BUFFERS + instr->sampler_index;
// Fishy: should the zero be instr->sampler_index?
auto ir = new TexInstr(src.opcode, dest, {3, 7, 7, 7}, help,
0, res_id, src.sampler_offset);
0, res_id, src.resource_offset);
shader.emit_instruction(ir);
return true;
}
@ -598,7 +593,7 @@ bool TexInstr::emit_tex_txs(nir_tex_instr *tex, Inputs& src,
auto ir = new TexInstr(get_resinfo, dest, dest_swz, src_coord,
sampler.id,
sampler.id + R600_MAX_CONST_BUFFERS,
src.sampler_offset);
src.resource_offset);
ir->set_dest_swizzle(dest_swz);
shader.emit_instruction(ir);
@ -677,8 +672,8 @@ TexInstr::Inputs::Inputs(const nir_tex_instr& instr, ValueFactory& vf):
offset(nullptr),
gather_comp(nullptr),
ms_index(nullptr),
sampler_offset(nullptr),
texture_offset(nullptr),
resource_offset(nullptr),
backend1(nullptr),
backend2(nullptr),
opcode(ld)
@ -727,7 +722,7 @@ TexInstr::Inputs::Inputs(const nir_tex_instr& instr, ValueFactory& vf):
texture_offset = vf.src(instr.src[i], 0);
break;
case nir_tex_src_sampler_offset:
sampler_offset = vf.src(instr.src[i], 0);
resource_offset = vf.src(instr.src[i], 0)->as_register();
break;
case nir_tex_src_backend1:
backend1 = &instr.src[i].src;

View file

@ -98,8 +98,8 @@ public:
nir_src *offset;
PVirtualValue gather_comp;
PVirtualValue ms_index;
PVirtualValue sampler_offset;
PVirtualValue texture_offset;
PRegister resource_offset;
nir_src *backend1;
nir_src *backend2;
@ -113,7 +113,7 @@ public:
TexInstr(Opcode op, const RegisterVec4& dest,
const RegisterVec4::Swizzle& dest_swizzle,
const RegisterVec4& src, unsigned sid, unsigned rid,
PVirtualValue sampler_offs = nullptr);
PRegister sampler_offs = nullptr);
TexInstr(const TexInstr& orig) = delete;
TexInstr(const TexInstr&& orig) = delete;
@ -127,7 +127,6 @@ public:
auto& src() {return m_src;}
unsigned opcode() const {return m_opcode;}
unsigned sampler_id() const {return m_sampler_id;}
unsigned resource_id() const {return m_resource_id;}
void set_offset(unsigned index, int32_t val);
@ -139,9 +138,6 @@ public:
void set_tex_flag(Flags flag) {m_tex_flags.set(flag);}
bool has_tex_flag(Flags flag) const {return m_tex_flags.test(flag);}
void set_sampler_offset(PVirtualValue ofs) {m_sampler_offset = ofs;}
auto* sampler_offset() const {return m_sampler_offset;}
void set_gather_comp(int cmp);
bool is_equal_to(const TexInstr& lhs) const;
@ -188,11 +184,9 @@ private:
Opcode m_opcode;
RegisterVec4 m_src;
PVirtualValue m_sampler_offset;
std::bitset<num_tex_flag> m_tex_flags;
int m_offset[3];
int m_inst_mode;
unsigned m_sampler_id;
unsigned m_resource_id;
static const std::map<Opcode, std::string> s_opcode_map;

View file

@ -255,9 +255,8 @@ void LiveRangeInstrVisitor::visit(TexInstr *instr)
auto src = instr->src();
record_read(src, LiveRangeEntry::use_unspecified);
if (instr->sampler_offset() && instr->sampler_offset()->as_register())
record_read(instr->sampler_offset()->as_register(), LiveRangeEntry::use_unspecified);
if (instr->resource_offset())
record_read(instr->resource_offset(), LiveRangeEntry::use_unspecified);
}
void LiveRangeInstrVisitor::visit(ExportInstr *instr)
@ -347,8 +346,8 @@ void LiveRangeInstrVisitor::visit(GDSInstr *instr)
{
sfn_log << SfnLog::merge << "Visit " << *instr << "\n";
record_read(instr->src(), LiveRangeEntry::use_unspecified);
if (instr->uav_id())
record_read(instr->uav_id(), LiveRangeEntry::use_unspecified);
if (instr->resource_offset())
record_read(instr->resource_offset(), LiveRangeEntry::use_unspecified);
record_write(instr->dest());
}
@ -358,7 +357,7 @@ void LiveRangeInstrVisitor::visit(RatInstr *instr)
record_read(instr->value(), LiveRangeEntry::use_unspecified);
record_read(instr->addr(), LiveRangeEntry::use_unspecified);
auto idx = instr->rat_id_offset();
auto idx = instr->resource_offset();
if (idx)
record_read(idx, LiveRangeEntry::use_unspecified);
}

View file

@ -409,7 +409,7 @@ TEST_F(InstrTest, test_tex_basic)
EXPECT_EQ(tex.dest_swizzle(i), i);
}
EXPECT_EQ(tex.sampler_id(), 1);
EXPECT_EQ(tex.resource_base(), 1);
EXPECT_EQ(tex.resource_id(), 17);
EXPECT_TRUE(tex.end_group());
@ -443,7 +443,7 @@ TEST_F(InstrTest, test_tex_basic)
EXPECT_EQ(tex.inst_mode(), 0);
EXPECT_FALSE(tex.sampler_offset());
EXPECT_FALSE(tex.resource_offset());
tex.set_dest_swizzle({4, 7, 0, 1});
EXPECT_EQ(tex.dest_swizzle(0), 4);
@ -487,7 +487,7 @@ TEST_F(InstrTest, test_tex_gather4)
EXPECT_EQ(tex.dest_swizzle(i), i);
}
EXPECT_EQ(tex.sampler_id(), 2);
EXPECT_EQ(tex.resource_base(), 2);
EXPECT_EQ(tex.resource_id(), 19);
for (int i = 0; i < 3; ++i)
@ -625,7 +625,7 @@ TEST_F(InstrTest, test_fetch_basic)
EXPECT_EQ(fetch.src(), Register(201, 2, pin_none));
EXPECT_EQ(fetch.src_offset(), 0);
EXPECT_EQ(fetch.resource_id(), 1);
EXPECT_EQ(fetch.resource_base(), 1);
EXPECT_FALSE(fetch.resource_offset());
EXPECT_EQ(fetch.fetch_type(), vertex_data);
@ -758,7 +758,7 @@ TEST_F(InstrTest, test_fetch_basic2)
EXPECT_EQ(fetch.src(), Register(202, 3, pin_none));
EXPECT_EQ(fetch.src_offset(), 1);
EXPECT_EQ(fetch.resource_id(), 3);
EXPECT_EQ(fetch.resource_base(), 3);
EXPECT_EQ(*fetch.resource_offset(), Register(300, 1, pin_none));
EXPECT_EQ(fetch.fetch_type(), no_index_offset);

View file

@ -389,8 +389,8 @@ TEST_F(TestInstrFromString, test_tex_sampler_with_offset)
{
add_dest_vec4_from_string("R2002.xyzw");
auto init = std::string("TEX SAMPLE R1001.xyzw : R2002.xyzw RID:7 SID:27 SO:R200.z NNNN");
TexInstr expect(TexInstr::sample, RegisterVec4(1001), {0,1,2,3}, RegisterVec4(2002), 27, 7);
expect.set_sampler_offset(new Register( 200, 2, pin_none));
TexInstr expect(TexInstr::sample, RegisterVec4(1001), {0,1,2,3},
RegisterVec4(2002), 27, 7, new Register( 200, 2, pin_none));
check(init, expect);
}