[Fix] (Remote): glFinish waits for the GPU, Magma bounds unsubmitted clear objects, ES contexts advertise OES_mapbuffer/rgb8_rgba8/depth24

This commit is contained in:
2026-10-04 04:54:53 -04:00
parent 4722fa38bb
commit 66b47a101b
6 changed files with 54 additions and 7 deletions
+3 -1
View File
@@ -2551,8 +2551,10 @@ namespace MobileGL::MG_Remote::Client {
// glFinish. Nothing goes on the wire - Flush and Finish have no record (ARCHITECTURE
// §11) - and under lockstep there was nothing to do, because the client had already
// waited out every command it issued. Under run-ahead "the commands issued so far have
// completed" is a promise the queue can break, so this is where it is kept.
// completed" is a promise the queue can break, so this is where it is kept - and
// "completed" includes the GPU, so a fence round trip follows the apply.
WaitForApplyToCatchUp("glFinish");
EmitFinishWait();
}
Uint64 ClientSession::AcquirePresentCredit() {
+17
View File
@@ -2085,6 +2085,23 @@ namespace MobileGL::MG_Remote::Client {
} // namespace
// glFinish's GPU half: a server fence created after everything the client issued, waited
// with GL_SYNC_FLUSH_COMMANDS_BIT, then destroyed. Waiting for the apply thread alone left
// the GPU queue unbounded behind a "finished" glFinish.
void EmitFinishWait() {
ClientSession* session = ClientSession::Active();
if (session == nullptr || !session->Started() || session->DeviceLost()) return;
const std::lock_guard<std::mutex> lock(g_fenceMutex);
const MG_Pipe::MGPipeHandle handle = MG_Pipe::MGPipeSlots().Allocate(MG_Pipe::MGPipeKind::Fence);
const MG_Pipe::MGPHandleOnly desc{handle, static_cast<Uint32>(MG_Pipe::MGPipeKind::Fence), 0};
session->EmitAndWait(MG_Pipe::MGPWireOp::FenceCreate, &desc, sizeof(desc), nullptr, 0, nullptr, 0, nullptr);
constexpr GLuint64 kFinishTimeoutNs = 10ull * 1000 * 1000 * 1000;
const MG_Pipe::MGPFenceWait request{handle, kFinishTimeoutNs, GL_SYNC_FLUSH_COMMANDS_BIT, 0};
(void)ReadFenceReply(*session, MG_Pipe::MGPWireOp::FenceWait, &request, sizeof(request));
session->EmitAndWait(MG_Pipe::MGPWireOp::FenceDestroy, &desc, sizeof(desc), nullptr, 0, nullptr, 0, nullptr);
MG_Pipe::MGPipeSlots().Free(MG_Pipe::MGPipeKind::Fence, handle);
}
void NoteFenceSignaledByServer(MG_Pipe::MGPipeHandle fence) {
RememberFenceSignaled(fence);
g_fenceServerReports.fetch_add(1, std::memory_order_relaxed);
+2
View File
@@ -291,6 +291,8 @@ namespace MobileGL::MG_Remote::Client {
//
// The event drain's half: the server reported `fence` signaled (kEventFenceSignaled). Every
// later glClientWaitSync / glGetSynciv(GL_SYNC_STATUS) on it answers without a round trip.
// glFinish's wait for the GPU (a server fence created, waited and destroyed).
void EmitFinishWait();
void NoteFenceSignaledByServer(MG_Pipe::MGPipeHandle fence);
// What the fence polls cost, for the lanes. `LocalAnswers` = polls answered with no record