mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-11-29 20:52:16 +09:00
[Test] (MG_Test/Buffer): keep the mapping backend alive through adoption checks
This commit is contained in:
1 parent
bc7e703e23
commit
13d9317aab
1 file changed
+20
-18
@@ -57,24 +57,26 @@ namespace {
|
|||||||
return ops;
|
return ops;
|
||||||
}();
|
}();
|
||||||
|
|
||||||
// The window in which the case is a MONOLITH with that backend registered: the adopted buffer
|
struct ScopedMintingOps {
|
||||||
// is created, mapped and destroyed inside one, so its records are applied synchronously.
|
ScopedMintingOps() : m_ops(MG_Pipe::MGPipeGetResourceOps()) {
|
||||||
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;
|
|
||||||
MG_Pipe::MGPipeSetResourceOps(&g_mintingResourceOps);
|
MG_Pipe::MGPipeSetResourceOps(&g_mintingResourceOps);
|
||||||
}
|
}
|
||||||
~ScopedMintingMonolith() {
|
~ScopedMintingOps() { MG_Pipe::MGPipeSetResourceOps(m_ops); }
|
||||||
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::Features.PipePush = m_push;
|
||||||
MG_Config::Transport = m_transport;
|
MG_Config::Transport = m_transport;
|
||||||
}
|
}
|
||||||
MG_Config::TransportMode m_transport;
|
MG_Config::TransportMode m_transport;
|
||||||
Uint64 m_push;
|
Uint64 m_push;
|
||||||
const MG_Pipe::MGPipeResourceOps* m_ops;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Everything in this package is gated on `Transport != Monolith`, so every case has to
|
// Everything in this package is gated on `Transport != Monolith`, so every case has to
|
||||||
@@ -339,11 +341,6 @@ TEST_F(SplitBufferSet, TheAdoptedArmIsNotAMemberAndItIsTheChainRowThatSaysSo) {
|
|||||||
Vector<Uint8> minted(kSize, static_cast<Uint8>(0));
|
Vector<Uint8> minted(kSize, static_cast<Uint8>(0));
|
||||||
g_mintedPersistentBase = minted.data();
|
g_mintedPersistentBase = minted.data();
|
||||||
|
|
||||||
SharedPtr<BufferObject> adopted;
|
|
||||||
{
|
|
||||||
ScopedMintingMonolith minting;
|
|
||||||
adopted = MakeBuffer(27u, kSize);
|
|
||||||
}
|
|
||||||
auto declined = MakeBuffer(28u, kSize);
|
auto declined = MakeBuffer(28u, kSize);
|
||||||
|
|
||||||
// The declined twin first, with no backend ops at all: same flags, same size, same call.
|
// 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 "
|
<< "the emulated arm IS a member - if this fails the two halves are not comparable and the "
|
||||||
"assertion below proves nothing";
|
"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<BufferObject> adopted;
|
||||||
{
|
{
|
||||||
ScopedMintingMonolith minting;
|
const ScopedMonolithResources monolith;
|
||||||
|
adopted = MakeBuffer(27u, kSize);
|
||||||
adopted->AcquireMemoryRange(Range1D{0, kSize},
|
adopted->AcquireMemoryRange(Range1D{0, kSize},
|
||||||
BufferMappingAccessBit::Write | BufferMappingAccessBit::Persistent);
|
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,
|
// definition (PipeResource.h:121-127). It is dropped here with the mapping still adopted,
|
||||||
// which is also the shape ~BufferObject has to survive.
|
// which is also the shape ~BufferObject has to survive.
|
||||||
{
|
{
|
||||||
ScopedMintingMonolith minting;
|
const ScopedMonolithResources monolith;
|
||||||
adopted.reset();
|
adopted.reset();
|
||||||
}
|
}
|
||||||
g_mintedPersistentBase = nullptr;
|
g_mintedPersistentBase = nullptr;
|
||||||
|
|||||||
Reference in new issue
Block a user