dronus
dronus

Reputation: 11272

Implement OpenCL on OpenGL

I have seen OpenCL is widely supported by CPU implementation as well as some GPU implementations.

For the cases there is a GPU, but no GPU implementation available, would it be feasable to implement OpenCL using OpenGL?

Maybe most operations would map quite well to GLSL fragment shader or even compute shaders.

If this is feasable, where to begin? Is there any 'minimal' CPU OpenCL implementation, that one could start off?

Upvotes: 0

Views: 375

Answers (2)

Nicol Bolas
Nicol Bolas

Reputation: 473174

OpenCL has certain very explicit requirements on the precision of floating-point operations. GLSL's requirements are far more lax. So even if you implemented the OpenCL API on top of OpenGL, you would never be able to get the same behavior.

Oh and in case you start thinking otherwise, Vulkan is no better in this regard.

Upvotes: 1

datenwolf
datenwolf

Reputation: 162164

For the cases there is a GPU, but no GPU implementation available, would it be feasable to implement OpenCL using OpenGL?

Possible: Yes, certainly. Every Turing complete machine can emulate any other Turing complete machine.

Feasible: OpenGL implementations' GLSL compilers are already primadonnas, each implementation's compiler behaving a little different. OpenGL itself has tons of heuristics in it to select the codepath. Shoehorning a makeshift OpenCL on top of OpenGL + GLSL will be an exercise in lots of pain.

Required: Absolutely not: For every GPU which has the required capabilities to actually support OpenCL the drivers do support OpenCL anyway, so this is a moot non-issue.

Upvotes: 1

Related Questions