[Fix] (Remote): a surfaceless make-current's hidden pbuffer no longer latches the session offscreen.

This commit is contained in:
2026-10-02 23:59:54 -04:00
parent 8b5295401f
commit b06c2a9bf2
7 changed files with 122 additions and 11 deletions
+16 -3
View File
@@ -1513,12 +1513,16 @@ namespace MobileGL::MG_Remote::Server {
static_cast<Uint32>(frame.width),
static_cast<Uint32>(frame.height));
return MOBILEGL_OK;
case SurfaceControlOp::CreatePbufferSurface:
case SurfaceControlOp::CreatePbufferSurface: {
// A surfaceless stand-in (kPbufferFlagSurfacelessStandIn) is no rendering path: it is
// admitted whatever the mode and latches none, so a client that binds surfacelessly
// before it creates its server-owned window still gets that window.
const Bool standIn = (frame.contextFlags & kPbufferFlagSurfacelessStandIn) != 0;
// P12 (D4): a pbuffer in a session that went on-screen is the other mode, refused by
// name and not latched - the session and its window surface carry on. P14 S2: the mode
// is the session's own - latched by its first surface, on its own loop - and never
// another session's.
if (!SessionSurfaceModeAdmits(m_surfaceMode, /*serverOwnedWindow=*/false)) {
if (!standIn && !SessionSurfaceModeAdmits(m_surfaceMode, /*serverOwnedWindow=*/false)) {
frame.ok = false;
frame.refusal = static_cast<Uint8>(SurfaceRefusalCode::SurfaceModeMismatch);
MGLOG_E("MG_Remote server: SurfaceModeMismatch - CreatePbufferSurface (seq %llu, %dx%d) in a "
@@ -1535,11 +1539,18 @@ namespace MobileGL::MG_Remote::Server {
// make-current that follows is forwarded and deduped one layer down (ID-54).
if (frame.ok) {
ForgetCurrentTuple();
if (standIn) {
MGLOG_I("MG_Remote server: surface=pbuffer %dx%d (surfaceless stand-in; the session's surface "
"mode stays %s)",
frame.width, frame.height, SessionSurfaceModeName(m_surfaceMode));
return MOBILEGL_OK;
}
if (m_surfaceMode == SessionSurfaceMode::None) m_surfaceMode = SessionSurfaceMode::Offscreen;
// P12: THE ARM PROOF (ID-124), once per surface: which of the two paths ran.
MGLOG_I("MG_Remote server: surface=pbuffer %dx%d", frame.width, frame.height);
}
return MOBILEGL_OK;
}
case SurfaceControlOp::MakeCurrent: {
// C7 / ID-54: the apply thread binds the native context ONCE per context lifetime
// and holds it for life. ApplyMakeCurrent forwards a bind only for a tuple it does
@@ -2133,12 +2144,14 @@ namespace MobileGL::MG_Remote::Server {
return rc == MOBILEGL_OK && frame.ok;
}
Bool ServerCreateEGLPbufferSurface(EGLSurface surface, EGLint width, EGLint height, SurfaceRefusalCode* refusal) {
Bool ServerCreateEGLPbufferSurface(EGLSurface surface, EGLint width, EGLint height, SurfaceRefusalCode* refusal,
Uint32 flags) {
SurfaceControlFrame frame;
frame.kind = SurfaceControlOp::CreatePbufferSurface;
frame.surface = TokenFromHandle(surface);
frame.width = width;
frame.height = height;
frame.contextFlags = flags;
const MobileGLResult rc = ServerLoopInstance().RunSurfaceControlFrame(frame);
if (refusal != nullptr) *refusal = static_cast<SurfaceRefusalCode>(frame.refusal);
return rc == MOBILEGL_OK && frame.ok;
+3 -2
View File
@@ -702,9 +702,10 @@ namespace MobileGL::MG_Remote::Server {
Bool ServerCreateEGLWindowSurface(EGLSurface surface, const MG_Backend::WindowHandle& handle);
Bool ServerResizeEGLWindowSurface(EGLSurface surface, Uint32 width, Uint32 height);
// P12: `refusal`, when given, receives the server's named refusal (SurfaceModeMismatch for a
// pbuffer in an on-screen session), None otherwise.
// pbuffer in an on-screen session), None otherwise. `flags`: kPbufferFlagSurfacelessStandIn
// for the hidden pbuffer of a surfaceless make-current, which takes no surface mode.
Bool ServerCreateEGLPbufferSurface(EGLSurface surface, EGLint width, EGLint height,
SurfaceRefusalCode* refusal = nullptr);
SurfaceRefusalCode* refusal = nullptr, Uint32 flags = 0);
// P12 (on-screen server window), D1/D2. CreateWindowSurface on the SERVER's window: one frame,
// WindowKind::ServerOwned with nativeToken 0 on the wire, no SetWindowHandle. `width`/`height`
// is the size the client asked for (0/0 = the server window's own size); the reply carries the
@@ -99,6 +99,15 @@ namespace MobileGL::MG_Remote::Server {
// substitutes its own window there; no pointer crosses the wire (Rule G/H).
inline constexpr Int kServerOwnedWindowBackend = 0x10000;
// CreatePbufferSurface's flags, in the frame's `contextFlags` word (the wire's SurfaceOp
// contextFlags, 0 on every op but CreateContext before this, so an older server reads none).
// SURFACELESS STAND-IN: the hidden 1x1 pbuffer a client binds the backend to for a surfaceless
// make-current (EGL_KHR_surfaceless_context). It is never presented or read back, so it is no
// rendering path: it neither latches the session's surface mode nor is refused by it (D4).
// Without it, a client that made a context current with no surface before it created its
// server-owned window latched its session offscreen, and the window was refused.
inline constexpr Uint32 kPbufferFlagSurfacelessStandIn = 1u;
// P12. Why the server declined a surface op, carried back in the reply half (`refusal`). The
// values ARE the wire's SurfaceRefusal (protocol.fbs); SurfaceOpCodec pins the agreement with
// static_asserts, the way it pins SurfaceControlOp against SurfaceOpKind. None of them latches
@@ -133,7 +142,8 @@ namespace MobileGL::MG_Remote::Server {
Int swapInterval = 0;
// P14 S1. CreateContext's two values beyond `context` (which is the client context token
// itself): the share group the context was derived into, and the reserved flags word the
// schema carries so a later attribute has a slot. 0 on every other op.
// schema carries so a later attribute has a slot. CreatePbufferSurface carries its own
// flags in the same word (kPbufferFlagSurfacelessStandIn). 0 on every other op.
Uint64 shareGroupToken = 0;
Uint32 contextFlags = 0;
// The reply half: written by the dispatch on the apply thread, read by the poster after