libva icon indicating copy to clipboard operation
libva copied to clipboard

vaCopySurfaceGLX produces corrupt image

Open UnscrewLater opened this issue 4 years ago • 6 comments

I have an app that uses vaCopySurfaceGLX. On some systems it works OK but others it produces a highly contoured magenta & yellow coloured image.

The problem is evident on an i7 8700 (Coffee Lake) system with integrated graphics running Ubuntu 20.04.1 with mesa 20.0.8. However an old i5 661 (Iron Lake) and the same Ubuntu 20.04.1 works fine. The problem persists when using libva built from git master. I've also tried building the latest intel-vaapi-driver but no change.

I believe there is a bug in the function create_tfp_surface() when it creates a framebuffer by calling glXChooseFBConfig. If I add 'GLX_ALPHA_SIZE, 8,' to the attribute list the problem is fixed. This should be included as the GLX_RENDER_TYPE is set to GLX_RGBA_BIT.

I have attached a patch that corrects the problem: 0001-GLX-Specify-an-alpha-size-when-requesting-a-GLX-fram.patch.txt

UnscrewLater avatar Nov 17 '20 10:11 UnscrewLater

I can confirm the problem on Ubuntu 20.04.1 with i5 750 and Radeon RX550. The attached patch fixes the problem.

imbens avatar Nov 19 '20 15:11 imbens

could you help file PR with attached patch?

XinfengZhang avatar Dec 31 '20 03:12 XinfengZhang

I'm happy to help out but have some reservations:

  1. Some GPUs are unaffacted. This indicates to me that the real fault lies outside of libva, possibly with glX (most likely) or in the intel-vaapi-driver or kernel as these have hardware dependent paths.
  2. The patch supplied is insufficient as-is and needs to include more attributes from the target texture. This works around the current undefined behavior in glX and/or driver.
  3. I don't have, nor do I want, a github account to create a working tree to pull from.
  4. I'm happy to provide a git compatible patch incorporating the changes discussed in (2). I have incorporated these changes into my own app which has tested OK over several platforms.

UnscrewLater avatar Dec 31 '20 14:12 UnscrewLater

Since mesa 18.x or higher allow_rgb10_configs is set to true by default ! Can you check with setting it to false ? But still I think your patch is a good solution, or we could iterate over the fbconfig and choose the proper one

ghost avatar Feb 02 '22 11:02 ghost

I have confirmed the problem on Ubuntu 20.04.2 with an i5-7Y57 using integrated Intel HD Graphics 615. The attached patch fixes the issue without causing and I would like to see it pulled into the mainline.

lancezac avatar Feb 02 '22 13:02 lancezac

Here is a PR https://github.com/intel/libva/pull/570

ghost avatar Feb 02 '22 14:02 ghost