# Problems with clCreateSubBuffer and clCreateFromGLBuffer

**URL:** <https://forums.developer.nvidia.com/t/problems-with-clcreatesubbuffer-and-clcreatefromglbuffer/27827>\
**Category:** CUDA Programming and Performance\
**Created:** [January 3, 2013, 2:06pm UTC](https://forums.developer.nvidia.com/t/problems-with-clcreatesubbuffer-and-clcreatefromglbuffer/27827 "2013-01-03T14:06:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mitridas](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@mitridas](https://forums.developer.nvidia.com/u/mitridas)\
**Post date:** [January 3, 2013, 2:06pm UTC](https://forums.developer.nvidia.com/t/problems-with-clcreatesubbuffer-and-clcreatefromglbuffer/27827/1 "2013-01-03T14:06:21Z")

</div>

Hi to all,  
I’ve recently encountered a problem with the nvidia OpenCL implementation that I can’t solve.  
If I try to use clCreateSubBuffer on a cl\_mem object obtained with clCreateFromGLBuffer, I always obtain athe CL\_INVALID\_VALUE error.  
Are there any known issues with these functions?  
The thing that makes me think that it’s an issue of the driver (instead of my code) is that the same code runs fine on an AMD card.  
Here is a code snippet:

```auto
cl_int error;
  cl_mem mId = clCreateFromGLBuffer(deviceContext, CL_MEM_READ_WRITE, glBufferID, &error);
  if(error) cout << "GL buffer -> CL buffer failed: " << error;
  
  cl_buffer_region region;
  region.origin = 0
  region.size = glBufferCapacity;
  cl_mem mSubId = clCreateSubBuffer(mId, CL_MEM_READ_WRITE, CL_BUFFER_CREATE_TYPE_REGION, &region, &error);
  if(error) cout << "CL buffer -> CL sub buffer failed: " << error;

```
