shader_recompiler: More image atomics
This commit is contained in:
parent
e8a2cb7474
commit
61f18544c7
|
@ -79,6 +79,7 @@ Id EmitImageFetch(EmitContext& ctx, IR::Inst* inst, u32 handle, Id coords, Id of
|
||||||
Id ms) {
|
Id ms) {
|
||||||
const auto& texture = ctx.images[handle & 0xFFFF];
|
const auto& texture = ctx.images[handle & 0xFFFF];
|
||||||
const Id image = ctx.OpLoad(texture.image_type, texture.id);
|
const Id image = ctx.OpLoad(texture.image_type, texture.id);
|
||||||
|
const Id result_type = texture.data_types->Get(4);
|
||||||
if (Sirit::ValidId(lod)) {
|
if (Sirit::ValidId(lod)) {
|
||||||
return ctx.OpImageFetch(ctx.F32[4], image, coords, spv::ImageOperandsMask::Lod, lod);
|
return ctx.OpImageFetch(ctx.F32[4], image, coords, spv::ImageOperandsMask::Lod, lod);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -322,7 +322,17 @@ Id ImageType(EmitContext& ctx, const ImageResource& desc, Id sampled_type) {
|
||||||
|
|
||||||
void EmitContext::DefineImagesAndSamplers(const Info& info) {
|
void EmitContext::DefineImagesAndSamplers(const Info& info) {
|
||||||
for (const auto& image_desc : info.images) {
|
for (const auto& image_desc : info.images) {
|
||||||
const Id sampled_type{image_desc.nfmt == AmdGpu::NumberFormat::Uint ? U32[1] : F32[1]};
|
const VectorIds* data_types = [&] {
|
||||||
|
switch (image_desc.nfmt) {
|
||||||
|
case AmdGpu::NumberFormat::Uint:
|
||||||
|
return &U32;
|
||||||
|
case AmdGpu::NumberFormat::Sint:
|
||||||
|
return &S32;
|
||||||
|
default:
|
||||||
|
return &F32;
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
const Id sampled_type = data_types->Get(1);
|
||||||
const Id image_type{ImageType(*this, image_desc, sampled_type)};
|
const Id image_type{ImageType(*this, image_desc, sampled_type)};
|
||||||
const Id pointer_type{TypePointer(spv::StorageClass::UniformConstant, image_type)};
|
const Id pointer_type{TypePointer(spv::StorageClass::UniformConstant, image_type)};
|
||||||
const Id id{AddGlobalVariable(pointer_type, spv::StorageClass::UniformConstant)};
|
const Id id{AddGlobalVariable(pointer_type, spv::StorageClass::UniformConstant)};
|
||||||
|
@ -332,6 +342,7 @@ void EmitContext::DefineImagesAndSamplers(const Info& info) {
|
||||||
image_desc.dword_offset));
|
image_desc.dword_offset));
|
||||||
images.push_back({
|
images.push_back({
|
||||||
.id = id,
|
.id = id,
|
||||||
|
.data_types = data_types,
|
||||||
.sampled_type = image_desc.is_storage ? sampled_type : TypeSampledImage(image_type),
|
.sampled_type = image_desc.is_storage ? sampled_type : TypeSampledImage(image_type),
|
||||||
.pointer_type = pointer_type,
|
.pointer_type = pointer_type,
|
||||||
.image_type = image_type,
|
.image_type = image_type,
|
||||||
|
|
|
@ -185,6 +185,7 @@ public:
|
||||||
|
|
||||||
struct TextureDefinition {
|
struct TextureDefinition {
|
||||||
Id id;
|
Id id;
|
||||||
|
const VectorIds* data_types;
|
||||||
Id sampled_type;
|
Id sampled_type;
|
||||||
Id pointer_type;
|
Id pointer_type;
|
||||||
Id image_type;
|
Id image_type;
|
||||||
|
|
|
@ -382,6 +382,33 @@ void Translate(IR::Block* block, std::span<const GcnInst> inst_list, Info& info)
|
||||||
case Opcode::IMAGE_ATOMIC_ADD:
|
case Opcode::IMAGE_ATOMIC_ADD:
|
||||||
translator.IMAGE_ATOMIC(AtomicOp::Add, inst);
|
translator.IMAGE_ATOMIC(AtomicOp::Add, inst);
|
||||||
break;
|
break;
|
||||||
|
case Opcode::IMAGE_ATOMIC_AND:
|
||||||
|
translator.IMAGE_ATOMIC(AtomicOp::And, inst);
|
||||||
|
break;
|
||||||
|
case Opcode::IMAGE_ATOMIC_OR:
|
||||||
|
translator.IMAGE_ATOMIC(AtomicOp::Or, inst);
|
||||||
|
break;
|
||||||
|
case Opcode::IMAGE_ATOMIC_XOR:
|
||||||
|
translator.IMAGE_ATOMIC(AtomicOp::Xor, inst);
|
||||||
|
break;
|
||||||
|
case Opcode::IMAGE_ATOMIC_UMAX:
|
||||||
|
translator.IMAGE_ATOMIC(AtomicOp::Umax, inst);
|
||||||
|
break;
|
||||||
|
case Opcode::IMAGE_ATOMIC_SMAX:
|
||||||
|
translator.IMAGE_ATOMIC(AtomicOp::Smax, inst);
|
||||||
|
break;
|
||||||
|
case Opcode::IMAGE_ATOMIC_UMIN:
|
||||||
|
translator.IMAGE_ATOMIC(AtomicOp::Umin, inst);
|
||||||
|
break;
|
||||||
|
case Opcode::IMAGE_ATOMIC_SMIN:
|
||||||
|
translator.IMAGE_ATOMIC(AtomicOp::Smin, inst);
|
||||||
|
break;
|
||||||
|
case Opcode::IMAGE_ATOMIC_INC:
|
||||||
|
translator.IMAGE_ATOMIC(AtomicOp::Inc, inst);
|
||||||
|
break;
|
||||||
|
case Opcode::IMAGE_ATOMIC_DEC:
|
||||||
|
translator.IMAGE_ATOMIC(AtomicOp::Dec, inst);
|
||||||
|
break;
|
||||||
case Opcode::IMAGE_GET_LOD:
|
case Opcode::IMAGE_GET_LOD:
|
||||||
translator.IMAGE_GET_LOD(inst);
|
translator.IMAGE_GET_LOD(inst);
|
||||||
break;
|
break;
|
||||||
|
@ -590,6 +617,9 @@ void Translate(IR::Block* block, std::span<const GcnInst> inst_list, Info& info)
|
||||||
case Opcode::V_CVT_I32_F32:
|
case Opcode::V_CVT_I32_F32:
|
||||||
translator.V_CVT_I32_F32(inst);
|
translator.V_CVT_I32_F32(inst);
|
||||||
break;
|
break;
|
||||||
|
case Opcode::V_CVT_FLR_I32_F32:
|
||||||
|
translator.V_CVT_FLR_I32_F32(inst);
|
||||||
|
break;
|
||||||
case Opcode::V_SUBREV_F32:
|
case Opcode::V_SUBREV_F32:
|
||||||
translator.V_SUBREV_F32(inst);
|
translator.V_SUBREV_F32(inst);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -153,6 +153,7 @@ public:
|
||||||
void V_CVT_F32_UBYTE(u32 index, const GcnInst& inst);
|
void V_CVT_F32_UBYTE(u32 index, const GcnInst& inst);
|
||||||
void V_BFREV_B32(const GcnInst& inst);
|
void V_BFREV_B32(const GcnInst& inst);
|
||||||
void V_LDEXP_F32(const GcnInst& inst);
|
void V_LDEXP_F32(const GcnInst& inst);
|
||||||
|
void V_CVT_FLR_I32_F32(const GcnInst& inst);
|
||||||
|
|
||||||
// Vector Memory
|
// Vector Memory
|
||||||
void BUFFER_LOAD_FORMAT(u32 num_dwords, bool is_typed, const GcnInst& inst);
|
void BUFFER_LOAD_FORMAT(u32 num_dwords, bool is_typed, const GcnInst& inst);
|
||||||
|
|
|
@ -508,4 +508,9 @@ void Translator::V_LDEXP_F32(const GcnInst& inst) {
|
||||||
SetDst(inst.dst[0], ir.FPLdexp(src0, src1));
|
SetDst(inst.dst[0], ir.FPLdexp(src0, src1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Translator::V_CVT_FLR_I32_F32(const GcnInst& inst) {
|
||||||
|
const IR::F32 src0{GetSrc(inst.src[0], true)};
|
||||||
|
SetDst(inst.dst[0], ir.ConvertFToI(32, true, ir.FPFloor(src0)));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Shader::Gcn
|
} // namespace Shader::Gcn
|
||||||
|
|
Loading…
Reference in New Issue