Using glEGLImageTargetTexture2DOES throws GL_INVALID_OPERATION

Hi

Not sure where this issue should go, but I’m having an issue calling glEGLImageTargetTexture2DOES with an EGLImage imported via a DMA-BUF, which in-turn is exported via eglExportDMABUFImageMESA.

Both exporting and importing the image from/to EGL seems to work fine, here’s the output from my test program from the export:
eglExportDMABUFImageQueryMESA: 1 AB24 (34324241) planes:1 mods:0
eglExportDMABUFImageMESA: 1 44
strides: 512 0 0 0
offsets: 0 0 0 0

This is exactly what I would expect from a 128x128 ABGR image.

The import also works fine, returning a seemingly valid EGLImage:
eglCreateImage from DMA-BUF: 0x1c976a1

But then the glEGLImageTargetTexture2DOES call (with a target of GL_TEXTURE_2D) complains with this:
GL_INVALID_OPERATION error generated. and are incompatible

Is there anyway to figure out exactly why they’re not compatible? Is this meant to work?

Thanks & Regards
elFarto

So I think I figured out what the issue is. It seems that you can’t import images that were exported in pitch linear format. They first must be converted to a cuArray. Doing this will let you bind the image correctly.

Did you find a solution? It seems that eglExportDMABUFImageMESA() no longer works in any driver series.

eglExportDMABUFImageMESA continues to work just fine. The original issue is a limitation with the NVIDIA driver, later confirmed by one of the developers, you can’t import pitch-linear textures.

Thank you, this gives me hope. Unfortunately I am still unable to determine why export does not work for me.

If I understand correctly, GL_TEXTURE_2D would include those pitch-linear textures (first time I’ve come across the term)? If not, are there any RGB formats in OpenGL that are not pitch-linear?

If it’s a regular OpenGL texture then it’ll be tiled, not pitch-linear. These should be fine, but there’s only so many formats supported. One of the NVIDIA developers responded here with a list.

Interesting, I am using those formats but apparently they do not work. It could be that GL_TEXTURE_2D is not supported for export. In which case I would have to read the texture back into my own created dma_buf correct?

I found a canonical example and added some logging.

The output:

./dmabufshare server
GL_VERSION=3.3.0 NVIDIA 510.54
eglQueryDmaBufFormatsEXT: AB24 XB24 R8   RG88 UYVY AB4H AR24 AS24 XS24 XR24 RG16 AR30 R101 R100 AB30 B101 B100 YU12 NV12 NV21 NV16 NV24 P010 P210 P012 HD01 UHD0 
eglCreateImage: EGL_SUCCESS image=0x55ca83e69751
eglExportDMABUFImageQueryMESA: EGL_SUCCESS fourcc:XB24 planes:1 modifiers:0x300000000cdb014
eglExportDMABUFImageMESA: EGL_BAD_MATCH, ok=0 fd=-1, stride:-2 offset:-3
dmabufshare: main.c:182: main: Assertion `exported' failed.

That code works for me:

~/t/dma-buf-texture-sharing (master)> ./dmabufshare server
GL_VERSION=3.3.0 NVIDIA 510.60.02
eglQueryDmaBufFormatsEXT: AB24 XB24 R8   RG88 UYVY AB4H AR24 AS24 XS24 XR24 RG16 AR30 R101 R100 AB30 B101 B100 YU12 NV12 NV21 NV16 NV24 P010 P210 P012 HD01 UHD0 
eglCreateImage: EGL_SUCCESS image=0x1965db1
eglExportDMABUFImageQueryMESA: EGL_SUCCESS fourcc:XB24 planes:1 modifiers:0x300000000cdb014
eglExportDMABUFImageMESA: EGL_SUCCESS, ok=1 fd=25, stride:1024 offset:0

Just one thing I did think of, you need to have the modeset module parameter set to 1 for the DMA-BUF stuff to work.

Thank you, modeset was the issue. Why isn’t this the default?