shader: preserve concurrent subword buffer stores

Co-authored-by: Senaxx <Senaxx@users.noreply.github.com>
This commit is contained in:
nmzik
2026-08-23 03:45:57 +02:00
parent 4adbf40861
commit bed19e5d8c
2 changed files with 33 additions and 3 deletions
@@ -436,12 +436,12 @@ void StoreSubwordInBounds(ValueEmitContext& ctx, const IR::MemoryInfo& mem,
Unary(ctx.state, OpNot, TypeU32(ctx.state), mask)),
value);
};
if (mem.kind == IR::ResourceKind::Lds || mem.kind == IR::ResourceKind::Gds) {
AtomicUpdate(ctx.state, pointer, mem.kind, merge);
} else {
if (mem.kind == IR::ResourceKind::Scratch) {
const auto old = ctx.state.builder.AllocateId();
ctx.state.builder.AddFunction({OpLoad, TypeU32(ctx.state), old, pointer});
ctx.state.builder.AddFunction({OpStore, pointer, merge(old)});
} else {
AtomicUpdate(ctx.state, pointer, mem.kind, merge);
}
}
+30
View File
@@ -16112,6 +16112,35 @@ TestCase BufferStoreFormatXResource16UintWritesHalfword() {
return test;
}
TestCase BufferStoreFormatXResource16UintPreservesAdjacentLanes() {
using O = ShaderOpcode;
std::vector<u32> code;
code.push_back(EncodeVop2(0x25, 1, InlineU32(1), 0));
code.push_back(EncodeMubuf0(0x04u, 0, true, false));
code.push_back(EncodeMubuf1(1, 0, 0));
AppendEnd(&code);
TestCase test;
test.name = "BufferStoreFormatXResource16UintPreservesAdjacentLanes";
test.code = code;
test.initial = std::vector<u32>(32, 0);
for (u32 index = 0; index < 32; index++) {
test.expected.push_back(((index * 2 + 2) << 16) | (index * 2 + 1));
}
test.opcodes = {O::V_ADD_NC_U32, O::BUFFER_STORE_FORMAT_X, O::S_ENDPGM};
test.compute_info.threads_num[0] = 64;
test.compute_info.threads_num[1] = 1;
test.compute_info.threads_num[2] = 1;
test.compute_info.thread_ids_num = 1;
test.compute_info.wave_size = 64;
test.has_compute_info = true;
test.user_data = MakeStructuredStorageBufferData(2, 64, false, 11);
test.has_user_data = true;
test.required_spirv = {"OpAtomicLoad", "OpAtomicCompareExchange"};
return test;
}
TestCase BufferLoadFormatXyResource88UintExtractsBytes() {
using O = ShaderOpcode;
@@ -19742,6 +19771,7 @@ std::vector<TestCase> MakeCases() {
AddCase(BufferLoadFormatXyzwInactiveExecPreservesOverlappingAddress);
AddCase(BufferFormatStoreVariants);
AddCase(BufferStoreFormatXResource16UintWritesHalfword);
AddCase(BufferStoreFormatXResource16UintPreservesAdjacentLanes);
AddCase(BufferLoadFormatXResource8UintZeroExtendsByte);
AddCase(BufferLoadFormatXyResource88UintExtractsBytes);
AddCase(BufferLoadFormatXyResource8888UnormConvertsFirstTwoComponents);