mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-11-20 16:31:57 +09:00
Merge branch 'p5c-hd' into feat/disaggregated (P5c hd: handle-keyed resolution)
Conflict: VulkanRenderer.cpp's disaggregated include block took both halves.
Merge coordination (integrator, with the evidence inline):
- hd's Fatal{RoleViolation, MGPipeSlots} guard as landed was kind-blind: it fired on the
G6 frontend-keyed twin registry (texture/VAO/program/sampler resolver probes - P3b/P4b's
to rekey) and on the families whose handle-carrying records the client does not emit
until P4b (the buffer binding-point ensures, the GPU-written announcement). Integration-
split went 104/107 red at the first Clear. Two NAMED, scoped exemptions keep the guard's
teeth for every other caller (SlotAllocator.{h,cpp}): MGPipeReverseAnnouncementScope
(buffer ensure + announcement family, P4b/P7) and MGPipeFrontendKeyedRegistryScope
(the G6 registry family, P3b/P4b; also the mailbox death switch until ct's object_death
record retires it). ~30 resolver sites wrapped, each naming its debt in the comment.
- ScopedRestartIndexSubstitution needed NO exemption: the EBO resolves from the record's
IndexBuffer.Res and the bytes read from the server staged shadow - CONTRACT-P5B d1's
own sentence, implemented.
- Magma's named blit takes a G6 consume arm (frontend FBOs resolved by lifetime id inside
the scope, VerbBlitNamedConsumed set, loud refusal kept for a failed resolution), so the
two DirectVulkan.Split.NamedBlit correctness cases stay green; Magma's hidden blit and
depth-mipmap resources' teardown probes are wrapped and named (P7: give them non-frontend
storage).
- MG_State gains GLContext::FindFramebufferObjectByLifetimeId (behaviour-neutral accessor
for the arm above).
Gates on the merged tree: unit 2166/2166; integration-split 107/107 (2 design skips);
hd's RemoteGuards death tests still abort the unwrapped paths by name; PrimitiveRestart
7/7; the two Magma named-blit cases render. CONTRACT-P5C sections 3, 5.4.
This commit is contained in:
@@ -29,6 +29,28 @@ namespace MobileGL::MG_State::GLState {
|
||||
const BufferBackendOps* g_bufferBackendOps = nullptr;
|
||||
// Starts at 1 so a zero-initialized cache slot can never carry a live buffer's id.
|
||||
std::atomic<Uint64> g_nextBufferLifetimeId{1};
|
||||
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
// P5c (hd, CONTRACT-P5C §3.8 / §6 layer 1): the frontend BufferObject's legacy
|
||||
// accessors are a layer-1 surface. With an active transport, the pre-handle buffer
|
||||
// arm that reads them (Managers.cpp's RespecifyStorageNow / UploadRangeNow /
|
||||
// IsBufferDrawClean / the old EnsureBufferResource body) stays compiled but may not
|
||||
// run: the apply thread calling one is Fatal{RoleViolation, "buffer-legacy-arm"} -
|
||||
// the same shape as Fatal{PipeLegacyMemosDisabled} - so a cleared subsystem bit 7 no
|
||||
// longer leaves the arm silently readable. Client-thread callers (the GL thread's
|
||||
// own state) are unaffected.
|
||||
void RefuseLegacyBufferArmFromApplyThread(const char* accessor) {
|
||||
if (!MG_Remote::Client::PersistentMapTracker::PushIsArmed()) return;
|
||||
if (!MG_Remote::Client::PersistentMapTracker::OnServerRole()) return;
|
||||
MGLOG_F("MGPipe: Fatal{RoleViolation, \"buffer-legacy-arm\"} - the apply thread "
|
||||
"called BufferObject::%s on a frontend object. With an active transport "
|
||||
"the server reads the applier's resource record and its own staged shadow; "
|
||||
"a frontend object is client memory (rule E) and the pre-handle buffer arm "
|
||||
"is monolith-only",
|
||||
accessor);
|
||||
std::abort();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
Uint64 BufferObject::AllocateLifetimeId() {
|
||||
@@ -378,6 +400,9 @@ namespace MobileGL::MG_State::GLState {
|
||||
|
||||
void BufferObject::SyncPersistentMappedRange() {
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
// P5c (hd): the named refusal comes FIRST - the silent return below used to let a
|
||||
// server-side caller slip through with one MGLOG_D's worth of evidence (B3).
|
||||
RefuseLegacyBufferArmFromApplyThread("SyncPersistentMappedRange");
|
||||
// Split's client pre-verb hook publishes these bytes. The retained backend sync
|
||||
// sites must do nothing on the apply thread: re-entering this producer there would
|
||||
// overwrite the server shadow through the monolith adapter without crossing the wire.
|
||||
@@ -914,6 +939,9 @@ namespace MobileGL::MG_State::GLState {
|
||||
}
|
||||
|
||||
const Uint8* BufferObject::MappedData() const {
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
RefuseLegacyBufferArmFromApplyThread("MappedData");
|
||||
#endif
|
||||
return m_resource.Bytes();
|
||||
}
|
||||
|
||||
@@ -934,10 +962,18 @@ namespace MobileGL::MG_State::GLState {
|
||||
}
|
||||
|
||||
Uint64 BufferObject::GetChangeSerial() const {
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
RefuseLegacyBufferArmFromApplyThread("GetChangeSerial");
|
||||
#endif
|
||||
return m_changeSerial;
|
||||
}
|
||||
|
||||
Bool BufferObject::HasDefinedContent() const {
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
// §3.6's surface as well as §3.8's: the descriptor's bit and the staged coverage
|
||||
// answer on this side; the frontend flag is client memory.
|
||||
RefuseLegacyBufferArmFromApplyThread("HasDefinedContent");
|
||||
#endif
|
||||
return m_hasDefinedContent;
|
||||
}
|
||||
|
||||
@@ -950,6 +986,9 @@ namespace MobileGL::MG_State::GLState {
|
||||
}
|
||||
|
||||
Bool BufferObject::IsMapped() const {
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
RefuseLegacyBufferArmFromApplyThread("IsMapped");
|
||||
#endif
|
||||
return m_isMapped;
|
||||
}
|
||||
|
||||
|
||||
@@ -1212,6 +1212,12 @@ namespace MobileGL::MG_State {
|
||||
return m_framebufferState.ValidateFramebufferObject(index);
|
||||
}
|
||||
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
SharedPtr<FramebufferObject> GLContext::FindFramebufferObjectByLifetimeId(Uint64 lifetimeId) const {
|
||||
return m_framebufferState.FindFramebufferObjectByLifetimeId(lifetimeId);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Sampler
|
||||
void GLContext::GenSamplerNames(Uint number, Vector<Uint>& samplers) {
|
||||
m_samplerState.GenerateNames(number, samplers);
|
||||
|
||||
@@ -544,6 +544,11 @@ namespace MobileGL {
|
||||
// Framebuffer
|
||||
void GenFramebufferNames(Uint number, Vector<Uint>& framebuffers);
|
||||
const SharedPtr<FramebufferObject>& GetFramebufferObject(Uint index);
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
// See FramebufferState::FindFramebufferObjectByLifetimeId - the named-blit
|
||||
// consumer's handle-to-frontend resolution on a backend with no FBO twins.
|
||||
SharedPtr<FramebufferObject> FindFramebufferObjectByLifetimeId(Uint64 lifetimeId) const;
|
||||
#endif
|
||||
BindingSlot<FramebufferObject>& GetFramebufferBindingSlot(FramebufferTarget target);
|
||||
const SharedPtr<FramebufferObject>& CreateFramebufferObject(Uint index);
|
||||
void MarkFramebufferObjectForDeletion(Uint index);
|
||||
|
||||
@@ -78,4 +78,15 @@ namespace MobileGL::MG_State::GLState {
|
||||
Bool FramebufferState::ValidateFramebufferObject(Uint index) const {
|
||||
return m_framebufferObjects.find(index) != m_framebufferObjects.end();
|
||||
}
|
||||
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
SharedPtr<FramebufferObject> FramebufferState::FindFramebufferObjectByLifetimeId(Uint64 lifetimeId) const {
|
||||
for (const auto& [index, framebufferObject] : m_framebufferObjects) {
|
||||
if (framebufferObject && framebufferObject->GetLifetimeId() == lifetimeId) {
|
||||
return framebufferObject;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
} // namespace MobileGL::MG_State::GLState
|
||||
|
||||
@@ -25,6 +25,16 @@ namespace MobileGL::MG_State::GLState {
|
||||
Bool ValidateName(Uint index) const;
|
||||
Bool ValidateFramebufferObject(Uint index) const;
|
||||
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
// P5c (G6, CONTRACT-P5C §3.3/§5.4): the reverse of HandleFor() for a server that holds
|
||||
// only the handle - the named-blit consumer on a backend with no FBO twin registry
|
||||
// (Magma) resolves the verb's ReadFbo/DrawFbo to the frontend object by the lifetime
|
||||
// id the handle was minted over. Named debt, reached inside
|
||||
// MGPipeFrontendKeyedRegistryScope; P3b/P4b retire it by carrying the object identity
|
||||
// in the record. nullptr when no live framebuffer owns the id.
|
||||
SharedPtr<FramebufferObject> FindFramebufferObjectByLifetimeId(Uint64 lifetimeId) const;
|
||||
#endif
|
||||
|
||||
#if MOBILEGL_PIPE_PUSH
|
||||
// P2 brief D4: "did the attachment set or the default geometry of ANY framebuffer
|
||||
// move". It does NOT cover a BIND - a bind writes a BindingSlot, not the object - so
|
||||
|
||||
Reference in New Issue
Block a user