diff --git a/tests/ResourceTrackingTests.cpp b/tests/ResourceTrackingTests.cpp index 9a3d96469..3e3f63102 100644 --- a/tests/ResourceTrackingTests.cpp +++ b/tests/ResourceTrackingTests.cpp @@ -5047,9 +5047,14 @@ void TestSharedAppendSelectorBounds() { Check(MaterializeResources(plan, runtime, snapshot, specialization) && snapshot.images.size() == 2u && snapshot.images.back().dwords[0] == 0x104u, "shared append materialization reused stale selector contents"); + // Record 1 lies past a one-record V#, so its scalar key reads zero instead of key 4. user_data[2] = 1u; - Check(!MaterializeResources(plan, runtime, snapshot, specialization), - "shared append materialization accepted a range outside its V# bounds"); + memory.fail_address = 0x1000u + 144u + 160u; + Check(MaterializeResources(plan, runtime, snapshot, specialization) && + snapshot.images.size() == 2u && snapshot.images[0].dwords[0] == 0x100u && + snapshot.images[1].dwords[0] == 0x101u, + "shared append materialization did not read records past its V# as zero"); + memory.fail_address = UINT64_MAX; user_data[2] = 8u; for (const auto too_large : {65537u, UINT32_MAX}) { for (uint32_t list = 0; list < 2u; ++list) { diff --git a/tests/shaderCfgTests.cpp b/tests/shaderCfgTests.cpp index c773fd8d9..c5ffb57ef 100644 --- a/tests/shaderCfgTests.cpp +++ b/tests/shaderCfgTests.cpp @@ -15160,7 +15160,7 @@ void TestBoundedScalarMaterialImageKeys() { } return true; } - for (const uint32_t key : {5567u, 5582u, 5573u, 5588u}) { + for (const uint32_t key : {0u, 5567u, 5582u, 5573u, 5588u}) { if (address != 0x100000u + key * 32u || words.size() != 8) continue; ++m.images; std::ranges::fill(words, 0u); @@ -15222,9 +15222,17 @@ void TestBoundedScalarMaterialImageKeys() { Check(!MaterializeResources(plan, runtime, snapshot, specialization), "unavailable selected material key was accepted"); } + // Row 1's 0x94 key straddles a 311-byte V#, so it reads zero instead of 5573. memory = {.stride = 1, .records = 311}; - Check(!MaterializeResources(plan, runtime, snapshot, specialization) && memory.key_reads == 0, - "scalar material byte range escaped V# bounds"); + Check(MaterializeResources(plan, runtime, snapshot, specialization), + "scalar material table past its V# was rejected"); + for (uint32_t root = 0; root < plan.info.images.size(); ++root) { + const auto &selector = + *plan.descriptor_sources[plan.info.images[root].source].indirect_descriptor->selector; + const auto offset = specialization.images[root].indirect_mapping_offset; + Check(snapshot.flattened_srt[offset + 1u] == (selector.offset == 0x94u ? 0u : 5567u), + "scalar material key past its V# did not read as zero"); + } memory = {.mixed = true}; Check(MaterializeResources(plan, runtime, snapshot, specialization) && snapshot.images.size() == 4 && specialization.images.size() == 4,