Implement V_READFIRSTLANE_B32

This commit is contained in:
greggameplayer 2024-08-31 00:39:56 +02:00
parent 4182740384
commit c94ce5d700
No known key found for this signature in database
GPG Key ID: DFCB45491D2A00EB
3 changed files with 12 additions and 4 deletions

View File

@ -23,7 +23,7 @@ Id EmitQuadShuffle(EmitContext& ctx, Id value, Id index) {
} }
Id EmitReadFirstLane(EmitContext& ctx, Id value) { Id EmitReadFirstLane(EmitContext& ctx, Id value) {
UNREACHABLE(); return ctx.OpGroupNonUniformBroadcastFirst(ctx.U32[1], SubgroupScope(ctx), value);
} }
Id EmitReadLane(EmitContext& ctx, Id value, u32 lane) { Id EmitReadLane(EmitContext& ctx, Id value, u32 lane) {

View File

@ -167,8 +167,16 @@ void Translator::S_BARRIER() {
} }
void Translator::V_READFIRSTLANE_B32(const GcnInst& inst) { void Translator::V_READFIRSTLANE_B32(const GcnInst& inst) {
ASSERT(info.stage != Stage::Compute); const IR::ScalarReg dst{inst.dst[0].code};
SetDst(inst.dst[0], GetSrc(inst.src[0])); const IR::U32 value{GetSrc(inst.src[0])};
if (ir.GetExec() == ir.Imm1(false)) {
ir.SetScalarReg(dst, value);
} else {
const IR::U32 first_active_value = ir.ReadFirstLane(value);
ir.SetScalarReg(dst, first_active_value);
}
} }
void Translator::V_READLANE_B32(const GcnInst& inst) { void Translator::V_READLANE_B32(const GcnInst& inst) {

View File

@ -340,6 +340,6 @@ OPCODE(ImageAtomicExchange32, U32, Opaq
OPCODE(LaneId, U32, ) OPCODE(LaneId, U32, )
OPCODE(WarpId, U32, ) OPCODE(WarpId, U32, )
OPCODE(QuadShuffle, U32, U32, U32 ) OPCODE(QuadShuffle, U32, U32, U32 )
OPCODE(ReadFirstLane, U32, U32, U32 ) OPCODE(ReadFirstLane, U32, U32, )
OPCODE(ReadLane, U32, U32, U32 ) OPCODE(ReadLane, U32, U32, U32 )
OPCODE(WriteLane, U32, U32, U32, U32 ) OPCODE(WriteLane, U32, U32, U32, U32 )