Tool/software: Linux
On the AM5728, I am using the DMABUF import extension for the SGX GPU to upload video textures to the GPU. The OpenGL Version I am using from Arago is "OpenGL ES 2.0 build 1.14@3699939 (MAIN)".
I have used the Arago SDK "display-ksmscube.c" example code as a template and have tried both YUYV and ARGB8888 ( GBM_FORMAT_ARGB8888) DMABUF pixel formats. Both format types work and my HDMI display shows the frames properly. The problem is that there appears to be a memory leak with the ARGB8888 type that occurs after several minutes.
When my application launches and provide ARGB8888 DMABUFs as EGLImageKHRs , it runs successfully for about 5 minutes before I begin to get repeating console message indicating failures to allocate:
PVR:(Error): [ 961-> 964] < CreateDrawable():938|ERROR> Error mapping 0 buffer [0, ]
PVR:(Error): [ 961-> 964] < CreateBuffer():859|ERROR> Couldn't get buffer FD [0, ]
More information is below. Is this an issue with how I am creating the images, or does the DMABUF import function have a bug?
Here is my code to submit the DMABUF to the GPU in RGBA8888 format:
void TestOpenGL::setFrameToProcess(dmabuf_buffer *dmaBuf) {
// Setup the input texture only once
EGLint dfd = dmaBuf->fd[0];
// Setup RGB
struct gbm_import_fd_data gbm_dmabuf = {
.fd = dfd,
.width = dmaBuf->width,
.height = dmaBuf->height,
.stride = dmaBuf->pitches[0],
.format = GBM_FORMAT_ARGB8888
};
#ifdef DEBUG_OGL
qDebug() << "setFrameToProcess Width , Height , DMABUF: " << dmaBuf->width << dmaBuf->height << dmaBuf->fd[0];
#endif
struct gbm_bo *bo = gbm_bo_import(gbmDev, GBM_BO_IMPORT_FD, &gbm_dmabuf,
GBM_BO_USE_SCANOUT);
if(!bo){
qDebug() << "setFrameToProcess gbm_bo_import failed";
return;
}
EGLint attrib_list = EGL_NONE;
eglImage = NULL;
eglImage = eglCreateImageKHR(eglDisplay, EGL_NO_CONTEXT,EGL_NATIVE_PIXMAP_KHR, bo, &attrib_list);
if (eglImage == EGL_NO_IMAGE_KHR) {
#ifdef DEBUG_OGL
qDebug() << "setFrameToProcess eglCreateImageKHR failed!";
#endif
}
else {
#ifdef DEBUG_OGL
qDebug() << "setFrameToProcess EGL Image: " << eglImage << " BO: " << bo;
#endif
}
#ifdef DEBUG_OGL
qDebug() << "setFrameToProcess m_TextureLCD: " << m_TextureLCD;
#endif
glBindTexture(GL_TEXTURE_EXTERNAL_OES, m_TextureLCD);
GLenum enumErr = glGetError();
if (enumErr != GL_NO_ERROR) {
qDebug() << "setFrameToProcess failed to glBindTexture!";
fprintf(stderr, "setFrameToProcess EGLImageTargetTexture2DOES() returned %d\n", enumErr);
// Destroy the DMABUF image
eglDestroyImageKHR( eglDisplay, eglImage );
return;
}
glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
// Update video texture / EGL Image.
glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, eglImage);
#ifdef DEBUG_OGL
qDebug() << "setFrameToProcess Uploaded texture!";
#endif
//printf("setFrameToProcess EGLImageTargetTexture2DOES() returned %d\n", glGetError());
if (glGetError() != GL_NO_ERROR) {
qDebug() << "setFrameToProcess failed to glEGLImageTargetTexture2DOES!";
return;
}
glUniform1i(m_DataUniformLCD, 2);
// Destroy the DMABUF image
eglDestroyImageKHR( eglDisplay, eglImage );
}
The Linux Console begins to repeatedly print the following messages when it fails to allocate:
[ 2491.096394] PVR_K:(Error): DevMemoryAlloc ERROR MMU_Alloc
[ 2491.101857] PVR_K:(Error): WrapMemory: DevMemoryAlloc(0x96000) failed
[ 2491.108390] PVR_K:(Error): BM_Wrap: WrapMemory FAILED
[ 2491.113467] PVR_K:(Error): PVRSRVMapDmaBufKM: Failed to wrap dma-buf
[ 2491.120151] PVR_K:(Error): PVRSRVMapDmaBufBW: Failed to map dma-buf handle
[ 2491.127297] PVR_K:(Error): MMU_Alloc: RA_Alloc of VMArena failed
[ 2491.133367] PVR_K:(Error): MMU_Alloc: Alloc of DevVAddr failed from heap General ID117440512, pid: 915, task: QThread
[ 2491.144093] PVR_K:(Error): DevMemoryAlloc ERROR MMU_Alloc
[ 2491.149537] PVR_K:(Error): WrapMemory: DevMemoryAlloc(0x1c3000) failed
[ 2491.156132] PVR_K:(Error): BM_Wrap: WrapMemory FAILED
[ 2491.161228] PVR_K:(Error): PVRSRVMapDmaBufKM: Failed to wrap dma-buf
[ 2491.167677] PVR_K:(Error): PVRSRVMapDmaBufBW: Failed to map dma-buf handle
[ 2491.212944] PVR_K:(Error): MMU_Alloc: RA_Alloc of VMArena failed
[ 2491.219004] PVR_K:(Error): MMU_Alloc: Alloc of DevVAddr failed from heap General ID117440512, pid: 915, task: QThread
[ 2491.229783] PVR_K:(Error): DevMemoryAlloc ERROR MMU_Alloc
[ 2491.235205] PVR_K:(Error): WrapMemory: DevMemoryAlloc(0x96000) failed
[ 2491.241698] PVR_K:(Error): BM_Wrap: WrapMemory FAILED
[ 2491.246833] PVR_K:(Error): PVRSRVMapDmaBufKM: Failed to wrap dma-buf
[ 2491.253217] PVR_K:(Error): PVRSRVMapDmaBufBW: Failed to map dma-buf handle
[ 2491.260462] PVR_K:(Error): MMU_Alloc: RA_Alloc of VMArena failed
[ 2491.267169] PVR_K:(Error): MMU_Alloc: Alloc of DevVAddr failed from heap General ID117440512, pid: 915, task: QThread
I am using the following commit from omap5-sgx-ddk-um-linux:
commit cf8cd620e96c9741bfcbe7f07c95328fe2d6ece9
Author: Anand Balagopalakrishnan <anandb@ti.com>
Date: Tue Jun 13 11:02:20 2017 +0530
um: gles2: Fix PVR_DBG level in 1RGB FBO completeness check
Signed-off-by: Anand Balagopalakrishnan <anandb@ti.com>
It is several commits newer than the one that reads:
commit d1cb4ea42dbf275e2013aae95ad2d9182f05648c
Author: Anand Balagopalakrishnan <anandb@ti.com>
Date: Thu Feb 23 11:17:40 2017 +0530
um: fix memory leak with EGL Image DMABuf import
Signed-off-by: Anand Balagopalakrishnan <anandb@ti.com>
However, I believe I am still seeing the leak.