mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-22 20:06:54 +02:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b82512be06 | |||
| ba8b0c85b8 | |||
| b6bd9ecae4 |
@@ -27,7 +27,7 @@ void Translator::PackedFloat16(const Decoder::Instruction& inst, IR::ValueOpcode
|
||||
if (quiet_snan) {
|
||||
const auto quiet_snan_lane = [&](const Decoder::Operand& operand, bool high) {
|
||||
const auto bits = ReadU16LaneAsU32(operand, high, false);
|
||||
const auto exponent = ir.BitwiseAnd(bits, IR::U32(IR::Value(0x7c00u)));
|
||||
const auto exponent = ir.BitwiseAnd(bits, IR::U32(IR::Value(0x7e00u)));
|
||||
const auto payload = ir.BitwiseAnd(bits, IR::U32(IR::Value(0x01ffu)));
|
||||
const auto snan = ir.LogicalAnd(ir.IEqual(exponent, IR::U32(IR::Value(0x7c00u))),
|
||||
ir.INotEqual(payload, IR::U32(IR::Value(0u))));
|
||||
|
||||
@@ -233,13 +233,6 @@ IR::Value Translator::ReadOperand(const Decoder::Operand& operand, IR::Type type
|
||||
if (type == IR::Type::F64) {
|
||||
if (operand.kind == Decoder::OperandKind::LiteralConstant) {
|
||||
pair = {IR::U32(IR::Value(0u)), IR::U32(IR::Value(operand.value))};
|
||||
} else if (operand.kind == Decoder::OperandKind::FloatInlineConstant) {
|
||||
const auto bits = operand.value == 0x3e22f983u
|
||||
? 0x3fc45f306dc9c882ull
|
||||
: std::bit_cast<uint64_t>(static_cast<double>(
|
||||
std::bit_cast<float>(operand.value)));
|
||||
pair = {IR::U32(IR::Value(static_cast<uint32_t>(bits))),
|
||||
IR::U32(IR::Value(static_cast<uint32_t>(bits >> 32u)))};
|
||||
}
|
||||
if (operand.absolute) {
|
||||
pair[1] = ir.BitwiseAnd(pair[1], IR::U32(IR::Value(0x7fffffffu)));
|
||||
@@ -488,6 +481,14 @@ std::array<IR::U32, 2> Translator::ReadU32Pair(const Decoder::Operand& operand)
|
||||
if (operand.kind == Decoder::OperandKind::VccLo) {
|
||||
return {ir.GetVccLo(), ir.GetVccHi()};
|
||||
}
|
||||
if (operand.kind == Decoder::OperandKind::FloatInlineConstant) {
|
||||
const auto bits =
|
||||
operand.value == 0x3e22f983u
|
||||
? 0x3fc45f306dc9c882ull
|
||||
: std::bit_cast<uint64_t>(static_cast<double>(std::bit_cast<float>(operand.value)));
|
||||
return {IR::U32(IR::Value(static_cast<uint32_t>(bits))),
|
||||
IR::U32(IR::Value(static_cast<uint32_t>(bits >> 32u)))};
|
||||
}
|
||||
const auto low = ApplyBitSourceModifiers(operand, ReadRawU32(operand));
|
||||
IR::U32 high(IR::Value(0u));
|
||||
if (operand.kind == Decoder::OperandKind::Sgpr || operand.kind == Decoder::OperandKind::Vgpr) {
|
||||
@@ -546,9 +547,11 @@ IR::U32 Translator::Read16LaneBits(const Decoder::Operand& operand, bool high_la
|
||||
auto bits = ReadRawU32(operand);
|
||||
if (operand.kind == Decoder::OperandKind::FloatInlineConstant) {
|
||||
// Inline floats encode the operand's width before SDWA or OP_SEL selects bits.
|
||||
const auto half = IR::F16(ir.Emit(IR::ValueOpcode::ConvertF16F32, {ir.BitCastF32(bits)}));
|
||||
const auto half_bits = IR::U16(ir.Emit(IR::ValueOpcode::BitCastU16F16, {half}));
|
||||
bits = IR::U32(ir.Emit(IR::ValueOpcode::ConvertU32U16, {half_bits}));
|
||||
const auto value = operand.value;
|
||||
bits = IR::U32(IR::Value(value == 0x3e22f983u
|
||||
? 0x3118u
|
||||
: ((value >> 16u) & 0x8000u) |
|
||||
((((value >> 23u) & 0xffu) - 112u) << 10u)));
|
||||
}
|
||||
bits = ApplyBitSourceModifiers(raw_operand, bits);
|
||||
uint32_t offset = (high_lane ? operand.op_sel_hi : operand.op_sel) ? 16u : 0u;
|
||||
|
||||
@@ -25192,6 +25192,34 @@ TestCase VectorCarryAndBitCountOps() {
|
||||
O::S_ENDPGM}};
|
||||
}
|
||||
|
||||
TestCase ScalarVector64BitFloatInlineConstants() {
|
||||
using O = ShaderOpcode;
|
||||
std::vector<u32> code;
|
||||
code.push_back(EncodeSop1(0x04, 40, 242));
|
||||
code.push_back(EncodeSop2(0x11, 42, 240, InlineU32(0)));
|
||||
code.push_back(EncodeSop1(0x04, 44, 248));
|
||||
AppendVop3(&code, 0x300, 2, InlineU32(32), 244);
|
||||
code.push_back(EncodeSMovB32(46, InlineU32(0)));
|
||||
AppendSMovLiteral(&code, 47, 0x3ff00000u);
|
||||
code.push_back(EncodeSopc(0x12, 46, 242));
|
||||
code.push_back(EncodeSMovB32(48, 253));
|
||||
AppendStoreSgprPair(&code, 40, 0);
|
||||
AppendStoreSgprPair(&code, 42, 2);
|
||||
AppendStoreVgpr(&code, 2, 4);
|
||||
AppendStoreVgpr(&code, 3, 5);
|
||||
AppendStoreSgprPair(&code, 44, 6);
|
||||
AppendStoreSgpr(&code, 48, 8);
|
||||
AppendEnd(&code);
|
||||
|
||||
TestCase test;
|
||||
test.name = "ScalarVector64BitFloatInlineConstants";
|
||||
test.code = std::move(code);
|
||||
test.expected = {0u, 0x3ff00000u, 0u, 0x3fe00000u, 0x40000000u, 0u, 0x6dc9c882u, 0x3fc45f30u, 1u};
|
||||
test.opcodes = {O::S_MOV_B64, O::S_OR_B64, O::V_LSHRREV_B64, O::S_MOV_B32, O::S_CMP_EQ_U64,
|
||||
O::V_MOV_B32, O::BUFFER_STORE_DWORD, O::S_ENDPGM};
|
||||
return test;
|
||||
}
|
||||
|
||||
TestCase VectorMbcntUsesThreadMask() {
|
||||
using O = ShaderOpcode;
|
||||
|
||||
@@ -25880,13 +25908,17 @@ TestCase PackedMinMaxF16NanAndSignedZeroEdges() {
|
||||
AppendVMovLiteral(&code, 3, 0x80007e00u);
|
||||
AppendVMovLiteral(&code, 4, 0x40007d01u);
|
||||
AppendVMovLiteral(&code, 5, 0x7d014000u);
|
||||
AppendVMovLiteral(&code, 6, 0x40007e01u);
|
||||
AppendVMovLiteral(&code, 7, 0x7e013c00u);
|
||||
|
||||
AppendVop3p(&code, 0x11, 10, Vgpr(0), Vgpr(1), 0, 0x3);
|
||||
AppendVop3p(&code, 0x12, 11, Vgpr(2), Vgpr(3), 0, 0x3);
|
||||
AppendVop3p(&code, 0x11, 12, Vgpr(4), Vgpr(5), 0, 0x3);
|
||||
AppendVop3p(&code, 0x12, 13, Vgpr(4), Vgpr(5), 0, 0x3);
|
||||
AppendVop3p(&code, 0x11, 14, Vgpr(6), Vgpr(7), 0, 0x3);
|
||||
AppendVop3p(&code, 0x12, 15, Vgpr(6), Vgpr(7), 0, 0x3);
|
||||
|
||||
for (u32 i = 0; i < 4; i++) {
|
||||
for (u32 i = 0; i < 6; i++) {
|
||||
AppendStoreVgpr(&code, 10 + i, i);
|
||||
}
|
||||
AppendEnd(&code);
|
||||
@@ -25894,7 +25926,7 @@ TestCase PackedMinMaxF16NanAndSignedZeroEdges() {
|
||||
return {"PackedMinMaxF16NanAndSignedZeroEdges",
|
||||
code,
|
||||
{},
|
||||
{0x80004000u, 0x00004000u, 0x7f017f01u, 0x7f017f01u},
|
||||
{0x80004000u, 0x00004000u, 0x7f017f01u, 0x7f017f01u, 0x40003c00u, 0x40003c00u},
|
||||
{O::V_MOV_B32, O::V_PK_MIN_F16, O::V_PK_MAX_F16,
|
||||
O::BUFFER_STORE_DWORD, O::S_ENDPGM}};
|
||||
}
|
||||
@@ -42013,6 +42045,7 @@ std::vector<TestCase> MakeCases() {
|
||||
AddCase(VectorBfeI32SignExtendsField);
|
||||
AddCase(VectorAlignByteUsesTwoBitByteOffset);
|
||||
AddCase(VectorCarryAndBitCountOps);
|
||||
AddCase(ScalarVector64BitFloatInlineConstants);
|
||||
AddCase(VectorMbcntUsesThreadMask);
|
||||
AddCase(VectorAddcWritesPerLaneCarryOut);
|
||||
AddCase(VectorAddcUsesPerLaneCarryIn);
|
||||
|
||||
Reference in New Issue
Block a user