What do you need from me ?
thks
Hi,
Please share us a sample as mentioned in
Zero-copy EGLImage texture upload? - #17 by michelcalifornia
So that we can try on developer kit.
Here is the callback that you need to use.
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <GLES2/gl2ext.h>
#include "nvbufsurface.h" // for NvBufSurface
static void gui_update_video_texture(GstCapture* capture) {
if (!capture || !capture->video_out_appsink) return;
nvtxRangePush("Video Texture Update");
GstSample *videosample = gst_app_sink_try_pull_sample(
GST_APP_SINK(capture->video_out_appsink), 1 * GST_MSECOND);
if (videosample) {
nvtxRangePush("Video Buffer Processing");
GstBuffer *videobuf = gst_sample_get_buffer(videosample);
GstMapInfo map;
if (gst_buffer_map(videobuf, &map, GST_MAP_READ)) {
// Treat buffer as NvBufSurface
NvBufSurface *surface = (NvBufSurface*) map.data;
int dmabuf_fd = surface->surfaceList[0].bufferDesc;
int width = surface->surfaceList[0].width;
int height = surface->surfaceList[0].height;
// Describe how to import the DMA-BUF
EGLint attribs[] = {
EGL_WIDTH, width,
EGL_HEIGHT, height,
EGL_LINUX_DRM_FOURCC_EXT, DRM_FORMAT_NV12, // or RGBA depending on caps!
EGL_DMA_BUF_PLANE0_FD_EXT, dmabuf_fd,
EGL_DMA_BUF_PLANE0_OFFSET_EXT, 0,
EGL_DMA_BUF_PLANE0_PITCH_EXT, surface->surfaceList[0].pitch,
EGL_NONE
};
// Create EGLImage from the dmabuf
EGLDisplay eglDisplay = eglGetCurrentDisplay();
EGLImageKHR eglImage = eglCreateImageKHR(
eglDisplay, EGL_NO_CONTEXT,
EGL_LINUX_DMA_BUF_EXT,
(EGLClientBuffer)NULL,
attribs
);
if (eglImage != EGL_NO_IMAGE_KHR) {
// Bind EGLImage to your texture
glBindTexture(GL_TEXTURE_2D, g_gui_state.videotex);
glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, eglImage);
// Once bound, destroy the EGLImage (texture keeps reference)
eglDestroyImageKHR(eglDisplay, eglImage);
} else {
printf("Failed to create EGLImage from dmabuf\n");
}
gst_buffer_unmap(videobuf, &map);
}
gst_sample_unref(videosample);
nvtxRangePop();
}
nvtxRangePop();
}
This is the one that you have to integrate in your code in place of the new_buufer callback.
Hi,
We are not able to check further with the partial code. Please share a full sample that we can compile and run.