mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-20 19:07:01 +02:00
shader: fix missing homogeneous semantics
This commit is contained in:
@@ -575,6 +575,42 @@ void TestAddressMaterializationAndSpecialization() {
|
||||
"typed address specialization was not applied");
|
||||
}
|
||||
|
||||
void TestBufferSwizzleSpecialization() {
|
||||
Fixture fixture;
|
||||
const auto handle = fixture.Buffer(
|
||||
{fixture.UserData(0), fixture.UserData(1), fixture.UserData(2),
|
||||
fixture.UserData(3)},
|
||||
4);
|
||||
MemoryInfo memory;
|
||||
memory.kind = ResourceKind::Buffer;
|
||||
memory.formatted = true;
|
||||
fixture.Emit(ValueOpcode::LoadBufferU32,
|
||||
{handle, Value(0u), Value(0u), Value(0u), Value(true)},
|
||||
fixture.AddMemory(memory, 4));
|
||||
fixture.PlanAndTrack();
|
||||
|
||||
constexpr auto swizzle = Libs::Graphics::DstSel(4, 5, 0, 1);
|
||||
std::array<uint32_t, 4> user_data{
|
||||
0, 16u << 16u, 1,
|
||||
swizzle |
|
||||
(static_cast<uint32_t>(
|
||||
Libs::Graphics::Prospero::BufferFormat::k32_32Float)
|
||||
<< 12u) |
|
||||
(1u << 24u)};
|
||||
SrtRuntime runtime{.user_data = user_data};
|
||||
ResourceSnapshot snapshot;
|
||||
std::string error;
|
||||
Check(MaterializeResources(fixture.program, runtime, snapshot, &error) &&
|
||||
SpecializeResources(fixture.program, snapshot, &error) &&
|
||||
fixture.program.info.buffers[0].descriptor_swizzle == swizzle &&
|
||||
ValidateResourceSpecialization(fixture.program, snapshot, &error),
|
||||
"buffer destination selectors were not specialized");
|
||||
|
||||
snapshot.buffers[0].dwords[3] ^= 1u << 9u;
|
||||
Check(!ValidateResourceSpecialization(fixture.program, snapshot, &error),
|
||||
"buffer swizzle change did not invalidate specialization");
|
||||
}
|
||||
|
||||
void TestShaderInfoAndBindingLayout() {
|
||||
Fixture fixture;
|
||||
const auto handle = fixture.Buffer(
|
||||
@@ -667,6 +703,7 @@ int main() {
|
||||
Run("runtime-rooted loop", TestLoopCycleEnteredThroughRuntimeValue);
|
||||
Run("invariant loop phi", TestInvariantLoopPhi);
|
||||
Run("address materialization", TestAddressMaterializationAndSpecialization);
|
||||
Run("buffer swizzle specialization", TestBufferSwizzleSpecialization);
|
||||
Run("shader info and bindings", TestShaderInfoAndBindingLayout);
|
||||
Run("resource limit", TestResourceLimitIsTransactional);
|
||||
} catch (const std::exception &exception) {
|
||||
|
||||
@@ -1144,7 +1144,7 @@ std::array<u32, 64> MakeStructuredStorageBufferData(u32 stride_bytes,
|
||||
std::array<u32, 64> data{};
|
||||
data[1] = (stride_bytes & 0x3fffu) << 16u;
|
||||
data[2] = num_records;
|
||||
data[3] = 1u << 24u;
|
||||
data[3] = DstSel(4, 5, 6, 7) | (1u << 24u);
|
||||
if (add_tid) {
|
||||
data[3] |= 1u << 23u;
|
||||
}
|
||||
@@ -14278,6 +14278,56 @@ TestCase BufferLoadFormatXyzwSnapshotsOverlappingAddress() {
|
||||
return test;
|
||||
}
|
||||
|
||||
TestCase BufferLoadFormatXyzwResource32_32FloatAppliesXy01() {
|
||||
using O = ShaderOpcode;
|
||||
|
||||
std::vector<u32> code;
|
||||
AppendVMovU32(&code, 20, 0);
|
||||
AppendBufferLoadOpcode(&code, 0x03, 0, 20);
|
||||
for (u32 i = 0; i < 4; i++) {
|
||||
AppendStoreVgpr(&code, i, i);
|
||||
}
|
||||
AppendEnd(&code);
|
||||
|
||||
TestCase test;
|
||||
test.name = "BufferLoadFormatXyzwResource32_32FloatAppliesXy01";
|
||||
test.code = std::move(code);
|
||||
test.initial = {0x3f800000u, 0x40000000u, 0, 0};
|
||||
test.expected = {0x3f800000u, 0x40000000u, 0, 0x3f800000u};
|
||||
test.opcodes = {O::VMovB32, O::BufferLoadFormatXyzw,
|
||||
O::BufferStoreDword, O::SEndpgm};
|
||||
test.user_data = MakeStructuredStorageBufferData(
|
||||
16, 1, false, BufferFormat(Prospero::BufferFormat::k32_32Float));
|
||||
test.user_data[3] = (test.user_data[3] & ~0xfffu) | DstSel(4, 5, 0, 1);
|
||||
test.has_user_data = true;
|
||||
return test;
|
||||
}
|
||||
|
||||
TestCase BufferLoadFormatXyzwResource8_8_8_8UintAppliesWzy1() {
|
||||
using O = ShaderOpcode;
|
||||
|
||||
std::vector<u32> code;
|
||||
AppendVMovU32(&code, 20, 0);
|
||||
AppendBufferLoadOpcode(&code, 0x03, 0, 20);
|
||||
for (u32 i = 0; i < 4; i++) {
|
||||
AppendStoreVgpr(&code, i, i);
|
||||
}
|
||||
AppendEnd(&code);
|
||||
|
||||
TestCase test;
|
||||
test.name = "BufferLoadFormatXyzwResource8_8_8_8UintAppliesWzy1";
|
||||
test.code = std::move(code);
|
||||
test.initial = {0x11223344u, 0x55667788u, 0x99aabbccu, 0xddeeff00u};
|
||||
test.expected = {0x11u, 0x22u, 0x33u, 1u};
|
||||
test.opcodes = {O::VMovB32, O::BufferLoadFormatXyzw,
|
||||
O::BufferStoreDword, O::SEndpgm};
|
||||
test.user_data = MakeStructuredStorageBufferData(
|
||||
16, 1, false, BufferFormat(Prospero::BufferFormat::k8_8_8_8UInt));
|
||||
test.user_data[3] = (test.user_data[3] & ~0xfffu) | DstSel(7, 6, 5, 1);
|
||||
test.has_user_data = true;
|
||||
return test;
|
||||
}
|
||||
|
||||
TestCase BufferLoadFormatXyzwInactiveExecPreservesOverlappingAddress() {
|
||||
using O = ShaderOpcode;
|
||||
|
||||
@@ -17264,6 +17314,8 @@ std::vector<TestCase> MakeCases() {
|
||||
AddCase(BufferStoreVariants);
|
||||
AddCase(BufferFormatVariants);
|
||||
AddCase(BufferLoadFormatXyzwSnapshotsOverlappingAddress);
|
||||
AddCase(BufferLoadFormatXyzwResource32_32FloatAppliesXy01);
|
||||
AddCase(BufferLoadFormatXyzwResource8_8_8_8UintAppliesWzy1);
|
||||
AddCase(BufferLoadFormatXyzwInactiveExecPreservesOverlappingAddress);
|
||||
AddCase(BufferFormatStoreVariants);
|
||||
AddCase(BufferStoreFormatXResource16UintWritesHalfword);
|
||||
|
||||
Reference in New Issue
Block a user