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.
This commit is contained in:
Cameron Gutman 2023-09-26 02:38:46 -05:00
parent fee54a9d76
commit f420dc740a
2 changed files with 8 additions and 6 deletions

View file

@ -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];

View file

@ -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]];