test(agc): explain native clear write-watch skips

This commit is contained in:
JJenkx committed 2026-10-22 16:54:40 -04:00
1 parent 60b379a65f
commit 8ee44075d8
1 file changed
+15 -3
@@ -54,6 +54,7 @@ constexpr std::size_t BlockBytes = 1048576;
struct SharedBacking {
int file;
std::uint64_t offset;
std::size_t resolverReturns = 0;
};
std::map<std::uintptr_t, SharedBacking> sharedBlocks;
@@ -66,7 +67,9 @@ bool ResolveSharedBlock(std::uintptr_t address, std::size_t bytes, int* file, st
if (lead >= BlockBytes || bytes > BlockBytes - lead) return false;
*file = fcntl(entry->second.file, F_DUPFD_CLOEXEC, 0);
*offset = entry->second.offset + lead;
return *file >= 0;
if (*file < 0) return false;
++entry->second.resolverReturns;
return true;
}
struct SharedBackingScope {
@@ -136,6 +139,9 @@ public:
std::uint64_t Address() const { return reinterpret_cast<std::uintptr_t>(block); }
const std::uint8_t* Data() const { return block; }
void FillWith(std::uint8_t value) const { std::memset(block, value, BlockBytes); }
#ifdef __linux__
std::size_t SharedBackingResolverReturns() const { return sharedBlocks.at(Address()).resolverReturns; }
#endif
private:
std::uint8_t* block = nullptr;
@@ -181,8 +187,14 @@ int RunNativeClear(AgcDriver::VulkanDevice& device, ClearConsumer consumer) {
device.Dispatch(compile(), groups, 1u, 1u, {}, reinterpret_cast<std::uintptr_t>(code.data()));
device.WaitIdle();
Require(std::all_of(metadata.Data(), metadata.Data() + BlockBytes, [](auto value) { return value == 0u; }), "the warm-up native clear did not retain zero metadata");
if (!Memory::Watched(depth.Address(), BlockBytes) || !Memory::Watched(metadata.Address(), BlockBytes)) {
std::puts("skipped, the device does not retain guest write watching for native clear imports");
const bool depthWatched = Memory::Watched(depth.Address(), BlockBytes);
const bool metadataWatched = Memory::Watched(metadata.Address(), BlockBytes);
if (!depthWatched || !metadataWatched) {
std::printf("skipped, native clear imports lost guest write watching after warm-up (depth watched=%u, metadata watched=%u", static_cast<unsigned>(depthWatched), static_cast<unsigned>(metadataWatched));
#ifdef __linux__
std::printf(", Linux shared backing present, resolver fd returns: depth=%zu metadata=%zu", depth.SharedBackingResolverReturns(), metadata.SharedBackingResolverReturns());
#endif
std::puts(")");
return VulkanTestSkipped;
}
const auto context = AgcDriver::VulkanDeviceTestAccess::Context(device);