mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-11-07 01:53:24 +09:00
A compositor's bring-up is a fixed sequence of questions that all have to be answered by the same library: which devices exist, which display a device serves, what its DRM node is, which platform the display comes from, which configs exist, a context, a surfaceless make-current, the GL entry points for that context, and finally the dma-buf import it draws with. Every missing answer in that list cost a run to find, and each is measured rather than assumed - an unanswered device query was a call through a null pointer, an unanswered GL name left glvnd's dispatch table empty so glGetString answered NULL through libGL while the same context answered through eglGetProcAddress, an unanswered node string produced "couldn't find dev node for drm device", and a rejected GL_TEXTURE_EXTERNAL_OES binding is why the framebuffer over an imported dma-buf was reported incomplete. The EGL side is whole now: the device-query family is published as real entry points with the DRM node named, the dispatch hook answers GL names as well as EGL ones, and the swap-and-sync family the compositor checks between its context and its first surface - EGL_KHR_fence_sync, EGL_KHR_wait_sync, the damage variants, EGL_EXT_buffer_age - is implemented and announced. A surfaceless context is recorded as what it is rather than as a surface that does not exist. These entry points log what they are asked at DEBUG level, because the next bring-up should not need a disassembler. GL_TEXTURE_EXTERNAL_OES is a target of its own (its TextureTarget, its pipe row, the GLenum mapping, and the OES_EGL_image extension named), which is what lets the compositor's bind succeed at all; the texture an imported image backs is marked backed, so a framebuffer built over it is complete. The client half of the import is new beside it: each plane's descriptor is described and shared with the render server over the session transport, which is the change the server side has been waiting for.
44 lines
1.9 KiB
C++
44 lines
1.9 KiB
C++
// MobileGL - MobileGL/MG_Remote/Client/DmaBufImport.cpp
|
|
// SPDX-License-Identifier: LGPL-3.0-only
|
|
// End of Source File Header
|
|
|
|
#include "DmaBufImport.h"
|
|
|
|
#include "ClientSession.h"
|
|
#include "../Protocol/mg_protocol_base.h"
|
|
#include "../Transport/ITransport.h"
|
|
|
|
namespace MobileGL::MG_Remote::Client {
|
|
|
|
Bool ShareImportedDmaBuf(Uint32 target, Uint32 texName, Uint32 width, Uint32 height, Uint32 fourCC,
|
|
Uint32 planeIndex, Uint32 planeCount, Int planeFd, Int stride, Int offset,
|
|
Uint64 modifier, Bool hasModifier) {
|
|
if (planeFd < 0 || planeCount == 0 || planeCount > kDmaBufImportMaxPlanes) return false;
|
|
// The session's control-plane transport is where the descriptor channel lives; no session or
|
|
// no channel (a TCP session whose aux came up without SCM_RIGHTS) is a named refusal here.
|
|
ClientSession* session = ClientSession::Active();
|
|
if (session == nullptr) return false;
|
|
Transport::ITransport* transport = session->Control_Plane();
|
|
if (transport == nullptr) return false;
|
|
|
|
DmaBufImportRequest request{};
|
|
request.Magic = kDmaBufImportRequestMagic;
|
|
request.Version = kDmaBufImportVersion;
|
|
request.Target = target;
|
|
request.TexName = texName;
|
|
request.Width = width;
|
|
request.Height = height;
|
|
request.FourCC = fourCC;
|
|
request.PlaneCount = planeCount;
|
|
request.Stride[planeIndex % kDmaBufImportMaxPlanes] = stride;
|
|
request.Offset[planeIndex % kDmaBufImportMaxPlanes] = offset;
|
|
request.Modifier[planeIndex % kDmaBufImportMaxPlanes] = modifier;
|
|
request.HasModifier[planeIndex % kDmaBufImportMaxPlanes] = hasModifier ? 1u : 0u;
|
|
|
|
MobileGLByteSpan sideband{};
|
|
sideband.data = &request;
|
|
sideband.size = sizeof(request);
|
|
return transport->ShareFd(planeFd, sideband) == MOBILEGL_OK;
|
|
}
|
|
} // namespace MobileGL::MG_Remote::Client
|