ROCm / ROCm-OpenCL-Runtime

ROCm OpenOpenCL Runtime
170 stars 60 forks source link

Sharing an OpenGL texture created with mipmaps to OpenCL does not seem to work correctly #133

Open 20k opened 3 years ago

20k commented 3 years ago

Hi again! I recently switched from an r9 390 to a 6700xt and I'm reporting OpenCL bugs as I find them. Creating an OpenGL texture and trying to share it to OpenCL does not appear to work if the OpenGL texture has mipmaps. I'm completely unable to make it work in OpenCL by changing any of the parameters for OpenGL texture creation, except by disabling mipmapping. Hopefully this is a simple screwup on my end, but the code this repro is derived from used to work on older GPUs

https://pastebin.com/jrPKQGkL

Built with -lglfw3 -lglew32 -lopengl32 -lopencl, with mingw64's gcc

This example simply printfs the value read in the kernel from the shared image. It should read a 1, but if mipmaps are enabled under the flag REPRODUCE_BUG, it reads and prints 0 instead. This code is derived from two larger projects which both run into the issue in less trivial circumstances

Additionally, swapping the call to glTexImage2D with

    int num_mipmaps = 2;

    glTexStorage2D(GL_TEXTURE_2D, num_mipmaps, GL_RGBA32F, 1024, 1024);
    glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 1024, 1024, GL_RGBA, GL_UNSIGNED_BYTE, cols);

Causes a similar failure regardless of whether or not glGenerateMipmap is called. The failure does not occur with num_mipmaps = 1;, so it seems like OpenCL simply cannot share any GL texture with mipmaps. cl_khr_mipmap_image is reported as a supported extension as is cl_khr_gl_sharing, so this example should hopefully work!

Specs: Windows 10 Pro 21H1, 5800x, 6700xt with driver 21.3.2, 16GB ddr4. Please let me know if you need any more information!

Edit:

This is also an issue on 21.4.1