Merge pull request #4159 from MarcZX100/codex/fix-sampled-cache-fixture-4141

test(agc): keep sampled cache fixture registrations separate
This commit is contained in:
Dean 2026-10-12 15:47:18 +13:00 committed by GitHub
commit 34a16b7f08
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 3 deletions

View File

@ -42,6 +42,8 @@ constexpr std::uint32_t Type2D = 9;
constexpr std::size_t SurfaceBytes = std::size_t{Side} * Side * 4u;
constexpr std::size_t Surfaces = 12;
constexpr std::size_t BlockBytes = SurfaceBytes * Surfaces;
constexpr std::size_t RegistrationGapBytes = 65536;
constexpr std::size_t AllocationBytes = BlockBytes + RegistrationGapBytes;
constexpr std::uint64_t Budget = 1ull << 20u;
constexpr std::uint64_t Ceiling = Budget + Budget / 4u;
@ -164,9 +166,9 @@ class Block {
public:
explicit Block(const Context& context) : context(context) {
#ifdef _WIN32
memory = VirtualAlloc(nullptr, BlockBytes, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
memory = VirtualAlloc(nullptr, AllocationBytes, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
#else
memory = std::aligned_alloc(65536, BlockBytes);
memory = std::aligned_alloc(65536, AllocationBytes);
#endif
Require(memory != nullptr, "cannot allocate the texture block");
std::memset(memory, 0x5a, BlockBytes);
@ -449,7 +451,9 @@ void viewEvictionTests(const Context& context) {
const std::weak_ptr<Texture> view = Sampled(context, imported.Surface(0));
Require(!view.expired() && TextureCacheUsage().sampledBytes == 0, "the view of a cached storage image did not enter the sampled texture cache at 0 bytes");
Sampled(context, snapshots.Surface(0));
const auto capacity = static_cast<std::size_t>(Budget / TextureCacheUsage().sampledBytes);
const auto snapshotBytes = TextureCacheUsage().sampledBytes;
Require(snapshotBytes != 0, "the snapshot fixture unexpectedly became a view of a cached storage image");
const auto capacity = static_cast<std::size_t>(Budget / snapshotBytes);
for (std::size_t surface = 1; surface <= capacity; ++surface) Sampled(context, snapshots.Surface(surface));
Require(!view.expired(), "the sampled texture cache evicted a view of a cached storage image, which frees no memory");
}