mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-20 10:56:58 +02:00
shader: fold constant bit reversal before flat stack classification
Co-authored-by: TheCruZ <thecruzwtf@gmail.com> Co-authored-by: Ali Almohaya <AliAlmohaya@gmail.com>
This commit is contained in:
@@ -503,6 +503,17 @@ void FoldInstruction(Block& block, Block::iterator instruction,
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
case ValueOpcode::BitReverse32: {
|
||||||
|
const auto value = Arg(inst, 0);
|
||||||
|
if (IsImmediate(value, Type::U32)) {
|
||||||
|
uint32_t source = value.U32(), reversed = 0;
|
||||||
|
for (uint32_t bit = 0; bit < 32u; ++bit, source >>= 1u) {
|
||||||
|
reversed = (reversed << 1u) | (source & 1u);
|
||||||
|
}
|
||||||
|
Replace(inst, Value(reversed));
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
case ValueOpcode::BitCount32: {
|
case ValueOpcode::BitCount32: {
|
||||||
const auto value = Arg(inst, 0);
|
const auto value = Arg(inst, 0);
|
||||||
if (IsImmediate(value, Type::U32)) {
|
if (IsImmediate(value, Type::U32)) {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ TestCase FlatStackApertures(u32 wave_size) {
|
|||||||
test.name = wave_size == 32 ? "FlatStackApertures32" : "FlatStackApertures64";
|
test.name = wave_size == 32 ? "FlatStackApertures32" : "FlatStackApertures64";
|
||||||
auto &code = test.code;
|
auto &code = test.code;
|
||||||
code = {EncodeSop1(0x04, 8, 237), // private base
|
code = {EncodeSop1(0x04, 8, 237), // private base
|
||||||
EncodeSop1(0x04, 10, 235), // shared base
|
EncodeSop1(0x0b, 11, InlineU32(1)), // S_BREV_B32 shared aperture, as in GTA.
|
||||||
EncodeVop2(0x1a, 20, InlineU32(2), 0),
|
EncodeVop2(0x1a, 20, InlineU32(2), 0),
|
||||||
EncodeVop2(0x1b, 22, InlineU32(1), 0),
|
EncodeVop2(0x1b, 22, InlineU32(1), 0),
|
||||||
EncodeVop2(0x1a, 22, InlineU32(31), 22)};
|
EncodeVop2(0x1a, 22, InlineU32(31), 22)};
|
||||||
@@ -77,6 +77,8 @@ TestCase FlatStackApertures(u32 wave_size) {
|
|||||||
test.compute_info.scratch_size_dwords = wave_size;
|
test.compute_info.scratch_size_dwords = wave_size;
|
||||||
test.compute_info.lds_size_dwords = wave_size;
|
test.compute_info.lds_size_dwords = wave_size;
|
||||||
test.has_compute_info = true;
|
test.has_compute_info = true;
|
||||||
|
test.decoded_counts = {{"S_BREV_B32", 1}};
|
||||||
|
test.ir_counts = {{" = BitReverse32 ", 0}};
|
||||||
test.forbidden_spirv = {"get_bda_pointer"};
|
test.forbidden_spirv = {"get_bda_pointer"};
|
||||||
return test;
|
return test;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user