I am trying to enable the OpenCL extension cl_khr_gl_depth_images to make the following work:
glGenRenderbuffers(1, &gl_depthbuffer);
glBindRenderbuffer(GL_RENDERBUFFER, gl_depthbuffer);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT32F, width, height);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, gl_depthbuffer);
...
cl_depth = clCreateFromGLRenderbuffer(context, CL_MEM_READ_ONLY, gl_depthbuffer, &error);
At the moment I am getting the following error from the clCreateFromGLRenderbuffer call CL_INVALID_IMAGE_FORMAT_DESCRIPTOR.
I added the following lines to the top of my cpp file:
#include <CL/cl.hpp>
#pragma OPENCL EXTENSION cl_khr_gl_sharing : enable
#pragma OPENCL EXTENSION cl_khr_gl_depth_images : enable
But my compiler gives two unknown pragma warnings and I am still getting the CL_INVALID_IMAGE_FORMAT_DESCRIPTOR error.
Am I including the extensions wrong or can one not use depth-renderbuffers in opencl?
Edit: My Device is supporting the extensions in question! The specification!
As doqtor already pointed out, put the lines
#pragma OPENCL EXTENSION cl_khr_gl_sharing : enable
#pragma OPENCL EXTENSION cl_khr_gl_depth_images : enable
at the top of your OpenCL C source code and not in your C++ code.
The C++ part of all available extensions is enabled by default and the required functions of the extension are automatically compiled into the executable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With