Implement DRM overlay composition

This allows overlays to work on drivers that only have one usable
overlay plane and when we are using the primary plane (which often
must be exactly CRTC-sized) to overlay on top of a video underlay.
This commit is contained in:
Cameron Gutman
2026-01-10 23:40:12 -06:00
parent a58d3cfe39
commit 7643cc929e
2 changed files with 263 additions and 83 deletions
@@ -649,6 +649,10 @@ private:
bool mapSoftwareFrame(AVFrame* frame, AVDRMFrameDescriptor* mappedFrame);
bool addFbForFrame(AVFrame* frame, uint32_t* newFbId, bool testMode);
bool uploadSurfaceToFb(SDL_Surface *surface, uint32_t* handle, uint32_t* fbId);
bool mapDumbBuffer(uint32_t handle, size_t size, void** mapping);
bool createFbForDumbBuffer(struct drm_mode_create_dumb* createBuf, uint32_t* fbId);
void enterOverlayCompositionMode();
void blitOverlayToCompositionSurface(Overlay::OverlayType type, SDL_Surface* newSurface, SDL_Rect* overlayRect);
static bool drmFormatMatchesVideoFormat(uint32_t drmFormat, int videoFormat);
IFFmpegRenderer* m_BackendRenderer;
@@ -672,6 +676,8 @@ private:
uint64_t m_VideoPlaneZpos;
DrmPropertyMap m_OverlayPlanes[Overlay::OverlayMax];
DrmPropertySetter m_PropSetter;
SDL_Surface* m_OverlayCompositionSurface;
std::mutex m_OverlayLock;
SDL_Rect m_OverlayRects[Overlay::OverlayMax];
drmVersionPtr m_Version;
uint32_t m_HdrOutputMetadataBlobId;