diff --git a/MobileGL/MG_Test/Buffer/SplitBufferTest.cpp b/MobileGL/MG_Test/Buffer/SplitBufferTest.cpp index eb957fab..07581734 100644 --- a/MobileGL/MG_Test/Buffer/SplitBufferTest.cpp +++ b/MobileGL/MG_Test/Buffer/SplitBufferTest.cpp @@ -57,24 +57,26 @@ namespace { return ops; }(); - // The window in which the case is a MONOLITH with that backend registered: the adopted buffer - // is created, mapped and destroyed inside one, so its records are applied synchronously. - struct ScopedMintingMonolith { - ScopedMintingMonolith() - : m_transport(MG_Config::Transport), m_push(MG_Config::Features.PipePush), - m_ops(MG_Pipe::MGPipeGetResourceOps()) { - MG_Config::Transport = MG_Config::TransportMode::Monolith; - MG_Config::Features.PipePush |= MG_Pipe::kMGPipeSubsystemResources; + struct ScopedMintingOps { + ScopedMintingOps() : m_ops(MG_Pipe::MGPipeGetResourceOps()) { MG_Pipe::MGPipeSetResourceOps(&g_mintingResourceOps); } - ~ScopedMintingMonolith() { - MG_Pipe::MGPipeSetResourceOps(m_ops); + ~ScopedMintingOps() { MG_Pipe::MGPipeSetResourceOps(m_ops); } + const MG_Pipe::MGPipeResourceOps* m_ops; + }; + + // Buffer creation, mapping and destruction use synchronous monolith records. + struct ScopedMonolithResources { + ScopedMonolithResources() : m_transport(MG_Config::Transport), m_push(MG_Config::Features.PipePush) { + MG_Config::Transport = MG_Config::TransportMode::Monolith; + MG_Config::Features.PipePush |= MG_Pipe::kMGPipeSubsystemResources; + } + ~ScopedMonolithResources() { MG_Config::Features.PipePush = m_push; MG_Config::Transport = m_transport; } MG_Config::TransportMode m_transport; Uint64 m_push; - const MG_Pipe::MGPipeResourceOps* m_ops; }; // Everything in this package is gated on `Transport != Monolith`, so every case has to @@ -339,11 +341,6 @@ TEST_F(SplitBufferSet, TheAdoptedArmIsNotAMemberAndItIsTheChainRowThatSaysSo) { Vector minted(kSize, static_cast(0)); g_mintedPersistentBase = minted.data(); - SharedPtr adopted; - { - ScopedMintingMonolith minting; - adopted = MakeBuffer(27u, kSize); - } auto declined = MakeBuffer(28u, kSize); // The declined twin first, with no backend ops at all: same flags, same size, same call. @@ -353,8 +350,13 @@ TEST_F(SplitBufferSet, TheAdoptedArmIsNotAMemberAndItIsTheChainRowThatSaysSo) { << "the emulated arm IS a member - if this fails the two halves are not comparable and the " "assertion below proves nothing"; + // Replacing the backend ops revokes resident mappings. Keep the minting ops + // installed until the adopted buffer has been tested and destroyed. + const ScopedMintingOps minting; + SharedPtr adopted; { - ScopedMintingMonolith minting; + const ScopedMonolithResources monolith; + adopted = MakeBuffer(27u, kSize); adopted->AcquireMemoryRange(Range1D{0, kSize}, BufferMappingAccessBit::Write | BufferMappingAccessBit::Persistent); } @@ -396,7 +398,7 @@ TEST_F(SplitBufferSet, TheAdoptedArmIsNotAMemberAndItIsTheChainRowThatSaysSo) { // definition (PipeResource.h:121-127). It is dropped here with the mapping still adopted, // which is also the shape ~BufferObject has to survive. { - ScopedMintingMonolith minting; + const ScopedMonolithResources monolith; adopted.reset(); } g_mintedPersistentBase = nullptr;