perf(vulkan-buffer): skip flush/invalidate on coherent memory (#60)

FlushDevice/FlushHost called vkFlushMappedMemoryRanges /
vkInvalidateMappedMemoryRanges unconditionally. Record the chosen
memory type's propertyFlags at Create time (via the index GetMemoryType
returns, not the requested flags) and early-return when HOST_COHERENT.

The cmd overload still always emits its pipeline barrier — only the
redundant host-side flush/invalidate is gated.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
catbot 2026-06-16 17:04:26 +00:00 committed by catbot
commit bda21979fd
3 changed files with 136 additions and 1 deletions

View file

@ -414,6 +414,34 @@ extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> a
mc.GetInterfacesAndImplementations(ifaces, memImpls);
cfg.tests.push_back(std::move(memTest));
// Issue #60: VulkanBuffer::FlushDevice / FlushHost now record the chosen
// memory type's propertyFlags at Create time and skip the
// flush/invalidate when the memory is HOST_COHERENT. The gate is pure
// logic over the recorded flags, so this test stamps them directly and
// verifies the coherent path issues no Vulkan call — no GPU device
// needed at runtime.
Test flushTest;
Configuration& fc = flushTest.config;
fc.path = cfg.path;
fc.name = "VulkanBufferFlushGate";
fc.outputName = "VulkanBufferFlushGate";
fc.type = ConfigurationType::Executable;
fc.target = cfg.target;
fc.march = cfg.march;
fc.mtune = cfg.mtune;
fc.debug = cfg.debug;
fc.sysroot = cfg.sysroot;
fc.dependencies = cfg.dependencies;
fc.externalDependencies = cfg.externalDependencies;
fc.compileFlags = cfg.compileFlags;
fc.linkFlags = cfg.linkFlags;
fc.defines = cfg.defines;
fc.cFiles = cfg.cFiles;
std::vector<fs::path> flushImpls(impls.begin(), impls.end());
flushImpls.emplace_back("tests/VulkanBufferFlushGate/main");
fc.GetInterfacesAndImplementations(ifaces, flushImpls);
cfg.tests.push_back(std::move(flushTest));
// Issue #50: uiResolveScreenPixel now gates its per-pixel clip-rect
// compares on the reserved kUIFlagClip bit, which FillHeader sets only
// when the clip rect is narrower than the surface. The decision lives