Support direct KMSDRM output for platforms with slow GL implementations

This commit is contained in:
Cameron Gutman
2023-03-26 19:46:22 -05:00
parent ba507d8046
commit 90f26dfa45
3 changed files with 345 additions and 60 deletions
+17 -1
View File
@@ -1,6 +1,7 @@
#pragma once
#include "renderer.h"
#include "swframemapper.h"
#include <xf86drm.h>
#include <xf86drmMode.h>
@@ -43,7 +44,7 @@ namespace DrmDefs
class DrmRenderer : public IFFmpegRenderer {
public:
DrmRenderer(IFFmpegRenderer *backendRenderer = nullptr);
DrmRenderer(bool hwaccel = false, IFFmpegRenderer *backendRenderer = nullptr);
virtual ~DrmRenderer() override;
virtual bool initialize(PDECODER_PARAMETERS params) override;
virtual bool prepareDecoderContext(AVCodecContext* context, AVDictionary** options) override;
@@ -66,8 +67,12 @@ public:
private:
const char* getDrmColorEncodingValue(AVFrame* frame);
const char* getDrmColorRangeValue(AVFrame* frame);
bool mapSoftwareFrame(AVFrame* frame, AVDRMFrameDescriptor* mappedFrame);
bool addFbForFrame(AVFrame* frame, uint32_t* newFbId);
IFFmpegRenderer* m_BackendRenderer;
bool m_DrmPrimeBackend;
bool m_HwAccelBackend;
AVBufferRef* m_HwContext;
int m_DrmFd;
bool m_SdlOwnsDrmFd;
@@ -86,6 +91,17 @@ private:
uint32_t m_HdrOutputMetadataBlobId;
SDL_Rect m_OutputRect;
static constexpr int k_SwFrameCount = 2;
SwFrameMapper m_SwFrameMapper;
int m_CurrentSwFrameIdx;
struct {
uint32_t handle;
uint32_t pitch;
uint64_t size;
uint8_t* mapping;
int primeFd;
} m_SwFrame[k_SwFrameCount];
#ifdef HAVE_EGL
bool m_EGLExtDmaBuf;
PFNEGLCREATEIMAGEPROC m_eglCreateImage;