@@ -235,7 +235,7 @@ void CameraViewWidget::paintGL() {
235
235
236
236
#ifdef QCOM2
237
237
glActiveTexture (GL_TEXTURE0);
238
- glEGLImageTargetTexture2DOES (GL_TEXTURE_EXTERNAL_OES, egl_images[frame->fd ]);
238
+ glEGLImageTargetTexture2DOES (GL_TEXTURE_EXTERNAL_OES, egl_images[frame->idx ]);
239
239
assert (glGetError () == GL_NO_ERROR);
240
240
#else
241
241
glPixelStorei (GL_UNPACK_ROW_LENGTH, stream_stride);
@@ -270,10 +270,15 @@ void CameraViewWidget::vipcConnected(VisionIpcClient *vipc_client) {
270
270
stream_stride = vipc_client->buffers [0 ].stride ;
271
271
272
272
#ifdef QCOM2
273
- EGLDisplay display = eglGetCurrentDisplay ();
273
+ egl_display = eglGetCurrentDisplay ();
274
+
275
+ for (auto &pair : egl_images) {
276
+ eglDestroyImageKHR (egl_display, pair.second );
277
+ }
274
278
egl_images.clear ();
279
+
275
280
for (int i = 0 ; i < vipc_client->num_buffers ; i++) { // import buffers into OpenGL
276
- int fd = vipc_client->buffers [i].fd ;
281
+ int fd = dup ( vipc_client->buffers [i].fd ); // eglDestroyImageKHR will close, so duplicate
277
282
EGLint img_attrs[] = {
278
283
EGL_WIDTH, (int )vipc_client->buffers [i].width ,
279
284
EGL_HEIGHT, (int )vipc_client->buffers [i].height ,
@@ -286,7 +291,7 @@ void CameraViewWidget::vipcConnected(VisionIpcClient *vipc_client) {
286
291
EGL_DMA_BUF_PLANE1_PITCH_EXT, (int )vipc_client->buffers [i].stride ,
287
292
EGL_NONE
288
293
};
289
- egl_images[fd ] = eglCreateImageKHR (display , EGL_NO_CONTEXT, EGL_LINUX_DMA_BUF_EXT, 0 , img_attrs);
294
+ egl_images[i ] = eglCreateImageKHR (egl_display , EGL_NO_CONTEXT, EGL_LINUX_DMA_BUF_EXT, 0 , img_attrs);
290
295
assert (eglGetError () == EGL_SUCCESS);
291
296
}
292
297
#else
@@ -341,4 +346,11 @@ void CameraViewWidget::vipcThread() {
341
346
emit vipcThreadFrameReceived (buf, meta_main.frame_id );
342
347
}
343
348
}
349
+
350
+ #ifdef QCOM2
351
+ for (auto &pair : egl_images) {
352
+ eglDestroyImageKHR (egl_display, pair.second );
353
+ }
354
+ egl_images.clear ();
355
+ #endif
344
356
}
0 commit comments