fix(agc): label the device words that end a dispatch content key

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
AlxcBTWandClaude Opus 5.5 committed 2026-10-13 23:43:32 +02:00
1 parent 5cf0aa48d9
commit e88b5c296f
2 files changed
+29 -1

No files matched your search

@@ -1856,7 +1856,15 @@ bool LabelShaderKey(std::span<const std::uint32_t> key, std::size_t at, std::siz
bool LabelContentKey(std::span<const std::uint32_t> key, bool draw, bool movable, std::vector<std::uint8_t>& labels) {
labels.assign(key.size(), static_cast<std::uint8_t>(Component::Layout));
if (!draw) return LabelShaderKey(key, 0, key.size(), movable, labels);
if (!draw) {
if (LabelShaderKey(key, 0, key.size(), movable, labels)) return true;
if (key.size() < 2) return false;
labels.assign(key.size(), static_cast<std::uint8_t>(Component::Layout));
if (!LabelShaderKey(key, 0, key.size() - 2, movable, labels)) return false;
labels[key.size() - 2] = static_cast<std::uint8_t>(Component::Other);
labels[key.size() - 1] = static_cast<std::uint8_t>(Component::Other);
return true;
}
if (key.size() < 4) return false;
std::fill(labels.begin() + 1, labels.begin() + 3, static_cast<std::uint8_t>(Component::Other));
std::size_t at = 4;
@@ -87,6 +87,25 @@ void testDispatchKey() {
expectOnly(diff, std::nullopt, "data words are not part of the key without dataWords");
}
std::vector<std::uint32_t> withDevice(std::vector<std::uint32_t> key, std::uint32_t device) {
key.push_back(device);
key.push_back(0u);
return key;
}
void testDispatchKeyWithDevice() {
ContentKeyDiff diff;
const auto base = withDevice(shaderKey(false, false, bindings()), 5);
check(ShaderResources::DiffContentKeys(base, base, false, diff), "dispatch key with device words was not comparable");
expectOnly(diff, std::nullopt, "equal dispatch keys with device words reported a difference");
auto buffer = bindings();
buffer[0].words[0] += 1;
check(ShaderResources::DiffContentKeys(base, withDevice(shaderKey(false, false, buffer), 5), false, diff), "dispatch V# word 0 with device words");
expectOnly(diff, ContentKeyComponent::BufferWord0, "dispatch V# word 0 with device words");
check(ShaderResources::DiffContentKeys(base, withDevice(shaderKey(false, false, bindings()), 6), false, diff), "dispatch device change");
expectOnly(diff, ContentKeyComponent::Other, "dispatch device change");
}
void testDrawKey() {
ContentKeyDiff diff;
const auto base = drawKey(5, shaderKey(true, true, bindings()), 0x1000);
@@ -109,6 +128,7 @@ void testDrawKey() {
int main() {
try {
testDispatchKey();
testDispatchKeyWithDevice();
testDrawKey();
std::puts("Key miss attribution passed");
return 0;