From f420dc740ae5877ec00b16dba8c7eb5723fe89b9 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Tue, 26 Sep 2023 02:38:46 -0500 Subject: [PATCH] Set EGL_IMAGE_PRESERVED_KHR=EGL_TRUE on our EGLImages They're mapped read-only and may be saved internally as reference frames, so they must not be modified by the EGL implementation. --- app/streaming/video/ffmpeg-renderers/drm.cpp | 7 ++++--- app/streaming/video/ffmpeg-renderers/vaapi.cpp | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/streaming/video/ffmpeg-renderers/drm.cpp b/app/streaming/video/ffmpeg-renderers/drm.cpp index 431e5e6f..e32977a0 100644 --- a/app/streaming/video/ffmpeg-renderers/drm.cpp +++ b/app/streaming/video/ffmpeg-renderers/drm.cpp @@ -1188,14 +1188,15 @@ ssize_t DrmRenderer::exportEGLImages(AVFrame *frame, EGLDisplay dpy, // DRM requires composed layers rather than separate layers per plane SDL_assert(drmFrame->nb_layers == 1); - // Max 32 attributes (1 key + 1 value for each) - const int MAX_ATTRIB_COUNT = 32 * 2; + // Max 33 attributes (1 key + 1 value for each) + const int MAX_ATTRIB_COUNT = 33 * 2; EGLAttrib attribs[MAX_ATTRIB_COUNT] = { EGL_LINUX_DRM_FOURCC_EXT, (EGLAttrib)drmFrame->layers[0].format, EGL_WIDTH, frame->width, EGL_HEIGHT, frame->height, + EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, }; - int attribIndex = 6; + int attribIndex = 8; for (int i = 0; i < drmFrame->layers[0].nb_planes; ++i) { const auto &plane = drmFrame->layers[0].planes[i]; diff --git a/app/streaming/video/ffmpeg-renderers/vaapi.cpp b/app/streaming/video/ffmpeg-renderers/vaapi.cpp index 3a453fe6..880fc531 100644 --- a/app/streaming/video/ffmpeg-renderers/vaapi.cpp +++ b/app/streaming/video/ffmpeg-renderers/vaapi.cpp @@ -943,15 +943,16 @@ VAAPIRenderer::exportEGLImages(AVFrame *frame, EGLDisplay dpy, for (size_t i = 0; i < m_PrimeDescriptor.num_layers; ++i) { const auto &layer = m_PrimeDescriptor.layers[i]; - // Max 30 attributes (1 key + 1 value for each) - const int EGL_ATTRIB_COUNT = 30 * 2; + // Max 31 attributes (1 key + 1 value for each) + const int EGL_ATTRIB_COUNT = 31 * 2; EGLAttrib attribs[EGL_ATTRIB_COUNT] = { EGL_LINUX_DRM_FOURCC_EXT, layer.drm_format, EGL_WIDTH, i == 0 ? frame->width : frame->width / 2, EGL_HEIGHT, i == 0 ? frame->height : frame->height / 2, + EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, }; - int attribIndex = 6; + int attribIndex = 8; for (size_t j = 0; j < layer.num_planes; j++) { const auto &object = m_PrimeDescriptor.objects[layer.object_index[j]];