webcl and webgl won't work at the same time

793 Views Asked by At

Hello Stack Overflow users!

I've been searching all over with little (actually none) out there about my problem. I try hard not to ask questions that have already been asked but it seems like I'm the first to have this problem.

I have installed the WebCL extension on Firefox. (I've tried it on version 31, 32, and 33 aurora)

I also have WebGL enabled on Chrome and Firefox.

I've written basic OpenGL programs that render boxes and stuff on my local machine. I've successfully compiled, linked and ran an example OpenCL program that uses the GPU to generate the string "Hello world" in a buffer and print it on my local machine.

I've even been able to run WebGL examples in both Chrome and Firefox. I can also run WebCL examples that don't require WebGL.

Now just to clarify beforehand, I'm only concerned about Firefox. My Chrome browser currently does not have WebCL functionality and Firefox was much easier to set up with WebCL. I only referred to Chrome to imply that WebGL does work as expected on more than one browser on my machine.

The problem is, oddly enough, if I run a WebCL example before WebGL, WebGL will think there is no graphics driver until Firefox is restarted.

Similarly, if I run a WebGL example before WebCL, WebCL will not be able to find an OpenCL driver on my machine until Firefox is restarted.

I only have the WebCL extension installed in Firefox and nothing else. The terminal does not complain when any of these services are used.

Currently running

Distro: Arch Linux x86_64
Kernel version: Linux 3.16.1-1-ARCH
GPU: AMD Radeon HD 7850

If anyone has any experience with this problem I'd greatly appreciate the assistance. If I somehow missed a Stack Overflow question with this problem I'd greatly appreciate the redirection.

2

There are 2 best solutions below

1
On BEST ANSWER

I have used WebGL and WebCL at the same time, albeit on Windows, so it is definitely possible in general. It sounds like a problem with your specific platform or system. Sorry for not being entirely helpful, but at least I can testify that it works somewhere.

As for KHR_gl_sharing, that is to share a memory buffer between WebGL and WebCL when both are working. For instance, imagine that you use WebCL to modify a texture that you then want WebGL to draw. Rather than queuing a copy from the GPU via WebCL to JavaScript only to copy it right back to the GPU for WebGL, you can just tell WebCL to operate on a WebGL buffer. No thrashing of your PCIe bus.

That doesn't help your problem -- it assumes both WebGL and WebCL are functioning. Also, Mozilla (developers of Firefox) does not allow extensions to access WebGL buffers, so Nokia's WebCL add-on cannot do KHR_gl_sharing anyway. That is a spec for browsers that natively integrate WebCL, which unfortunately no vendor is currently interested in (mostly due to lack of OpenCL adoption by developers). They definitely want GPU compute though, so we'll see what they choose. WebCL 2.0? WebGL compute shaders in 2.1/3.0/2.0 + ARB extension? Or maybe they'll revert on their decision and support WebCL given enough developer pressure? Who knows!

Hope this helps!

1
On

look at (Windows + Firefox) http://www.ibiblio.org/e-notes/webcl/webcl.htm may be you need WebCL KHR_gl_sharing Extension for Linux?