Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable OpenCL extensions?

Tags:

opencl

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!

like image 865
eclipse Avatar asked Dec 15 '25 02:12

eclipse


1 Answers

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.

like image 91
ProjectPhysX Avatar answered Dec 16 '25 18:12

ProjectPhysX