Texture share problem between two apps by use of eglExportDMABUFImageQueryMESA and GL_RGBA (the A on end)

Viewed 191

Working on a project to exchange OpenGL textures between two independent applications.

As a first basis I use this example program https://gitlab.com/blaztinn/dma-buf-texture-sharing/-/tree/master

Here is a fork from me for test purposes https://github.com/AlwinEsch/dma-buf-texture-sharing/tree/own-tries
This uses a complete image for testing (not with 4 pixels as in the original).

This also works completely correctly for me when exchanging 24bit texture image (GL_RGB).

However, if I switch to 32bit (GL_RGBA) which is necessary for my project, the child only arrives garbage.

Image where shows on left client and on right server

Questions:

  1. Is this maybe related to OS/Hardware bugs?
  2. Can this vary between different GPUs and if so how can the support be determined in the code?
  3. Something special in code wrong to have RGBA supported?
  4. Other wide supported ways possible to share a texture between two independent apps?

Here a bit in hex Format:

Correct on server:

00000000 38 38 38 FF │ 38 38 38 FF │ 38 38 38 FF │ 38 38 38 FF │ 38 38 38 FF │ 38 38 38 FF │ 38 38 38 FF │ 38 38 38 FF │ 38 38 38 FF │ 38 38 38 FF
00000028 38 38 38 FF │ 38 38 38 FF │ 38 38 38 FF │ 38 38 38 FF │ 38 38 38 FF │ 38 38 38 FF │ 38 38 38 FF │ 38 38 38 FF │ 38 38 38 FF │ 38 38 38 FF
...

If with Alpha given to child (glTexImage2D format with GL_BGRA):

00000000 83 83 8F F3 │ 00 00 0F 00 │ 00 00 00 00 │ 00 00 00 00 │ 00 00 00 00 │ 00 00 00 00 │ 00 00 00 00 │ 00 00 00 00 │ 00 00 00 00 │ 00 00 00 00
00000028 00 00 00 00 │ 00 00 00 00 │ 83 83 8F F3 │ 00 00 0F 00 │ 00 00 00 00 │ 00 00 00 00 │ 00 00 00 00 │ 00 00 00 00 │ 00 00 00 00 │ 00 00 00 00
...

If passed as RGB (glTexImage2D format with GL_BGR, a bit swapped as original source still in RGBA):

00000000 38 38 38 38 │ 38 FF 38 FF │ 38 FF 38 38 │ 38 38 38 38 │ 38 FF 38 FF │ 38 FF 38 38 │ 38 38 38 38 │ 38 FF 38 FF │ 38 FF 38 38 │ 38 38 38 38
00000028 38 FF 38 FF │ 38 FF 38 38 │ 38 38 38 38 │ 38 FF 38 FF │ 38 FF 38 38 │ 38 38 38 38 │ 38 FF 38 FF │ 38 FF 38 38 │ 38 38 38 38 │ 38 FF 38 FF
...

My Hardware:

  • OS: Ubuntu 20.04
  • CPU: Intel(R) Core(TM) i7-9700K CPU @ 3.60GHz
  • GPU: Intel Corporation UHD Graphics 630 (Desktop 9 Series)

Background to me, I am part of the Kodi team and am looking to develop a working web browser add-on for Kodi which CEF / Chromium uses (https://github.com/AlwinEsch/web.browser.chromium). However, since Chromium is a bit thicker, it becomes necessary to have this regardless of the executing app.

2 Answers

Probably found a solution, can't explain exactly how it works with it and also not sure whether it is really correct, but the rendering in the child then worked.

Also had to use "glGenFramebuffers" and "glFramebufferTexture2D", then it worked.

See https://github.com/AlwinEsch/dma-buf-texture-sharing/blob/4e2a4676f9b2dd3029ac2de1efb3f9f196497105/main.cpp#L299-L311

Looks very disgusting there in the code because a second shader is used there.

Will clean it up and see how it could work cleaner.

The error is not related to alpha, only in my tests the alpha value was still available in the test image and then when it was transferred as RGB only, it had almost constantly changing values, so it worked wondrously (even if displayed incorrectly).

Related