cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

antzrhere
Adept III

Quick Question about cl_khr_gl_sharing

Just coding a program that uses Cl GL sharing.

Now everythings is working (including cl-gl interop), but for some reason if I actually enable the "cl_khr_gl_sharing" extension in my code I get an error from the compiler

 "error: can't enable all
          OpenCL extensions or unrecognized OpenCL extension
  #pragma OPENCL EXTENSION cl_khr_gl_sharing : enable
                                               ^                                         "

I'm using a HD 5870 (Win 7-64bit, catalyst 11.9) which does support sharing and cl_khr_gl_sharing extension is reported as supported. The actual code works fine without the extension enabled (rendering to a GL Renderbuffer object, blitting etc. - i see everything working as expected), but I can't figure why this extension isn't recognised. Is it because AMDs implementation doesn't conform to the spec so it cannot be supported officially, or something else?

I create the context as following (I know I don't check for supported extensions etc., bad code, but it does work):

 

 

 



 

/************************************************************* * * *************************************************************/ int vglInit(vgl_instance *instance, cl_device_type cldevicetype, bool OutputLog) { cl_uint ok = 1; cl_int result; if(OutputLog)std::cout << "VoxSup-OpenCL v0.1" << std::endl << std::endl; result = clGetPlatformIDs(1, NULL, &instance->NumberOfAvailablePlatforms); instance->Platform = new cl_platform_id[instance->NumberOfAvailablePlatforms]; result |= clGetPlatformIDs(instance->NumberOfAvailablePlatforms, instance->Platform, NULL); if (result != CL_SUCCESS) { if(OutputLog)std::cout << "OpenCL>Initialisation: Error getting platform ID (: " << result << ")" << std::endl; return VGL_OPENCL_INIT_FAILURE; } if(OutputLog)std::cout << "OpenCL: Retrieved Platforms ( " << instance->NumberOfAvailablePlatforms << ")" << std::endl; // Device result = clGetDeviceIDs(instance->Platform[instance->clPlatformSelect], cldevicetype, 0, NULL,&instance->NumberOfAvailableDevices); if (result != CL_SUCCESS) { if(OutputLog)std::cout << "OpenCL>Initialisation: Error getting device ID Num (" << result << ")" << std::endl; return VGL_OPENCL_INIT_FAILURE; } instance->Device = new cl_device_id[instance->NumberOfAvailableDevices]; result = clGetDeviceIDs(instance->Platform[instance->clPlatformSelect], cldevicetype, instance->NumberOfAvailableDevices, instance->Device, NULL); if (result != CL_SUCCESS) { if(OutputLog)std::cout << "OpenCL>Initialisation: Error getting device IDs (" << result << ")" << std::endl; return VGL_OPENCL_INIT_FAILURE; } if(OutputLog)std::cout << "OpenCL: Retrieved Device" << std::endl; cl_context_properties cpsGL[] = { CL_CONTEXT_PLATFORM, (cl_context_properties)instance->Platform[instance->clPlatformSelect], CL_WGL_HDC_KHR, (cl_context_properties) wglGetCurrentDC(), CL_GL_CONTEXT_KHR, (cl_context_properties) wglGetCurrentContext(), 0 }; // create the OpenCL from OpenGL context instance->Context = clCreateContext(cpsGL, 1,&instance->Device[instance->clDeviceSelect], NULL, NULL, &result); if (result != CL_SUCCESS) { if(OutputLog)std::cout << "OpenCL>Initialisation: Error creating context(" <<result << ")" << std::endl; return VGL_OPENCL_INIT_FAILURE; } if(OutputLog)std::cout << "OpenCL: Created context" << std::endl; instance->CommandQueue = clCreateCommandQueue(instance->Context, instance->Device[instance->clDeviceSelect], 0, &result); if (result != CL_SUCCESS) { if(OutputLog)std::cout << "OpenCL>Initialisation: Error creating command queue(" << result << ")" << std::endl; return VGL_OPENCL_INIT_FAILURE; } if(OutputLog)std::cout << "OpenCL: Created command queue" << std::endl; fopen_s(&fp,VOGL_MAIN_CL,"r"); if(fp==NULL) { if(OutputLog)std::cout << "OpenCL>Compile: Cannot open " << VOGL_MAIN_CL << std::endl; return VGL_FILE_OPEN_ERROR; } if(OutputLog)std::cout << "CL source file(1) successfully loaded" << std::endl; CHARBUFFER = (char*)malloc((CHARBUFFER_MAX_SIZE+1)*sizeof(char)); if(CHARBUFFER==NULL) { if(OutputLog)std::cout << "Main>LoadSource: Out of memory" << std::endl; return VGL_OUT_OF_MEMORY; } CHARBUFFER_LEN = fread(CHARBUFFER,sizeof(char),CHARBUFFER_MAX_SIZE,fp); fclose(fp); instance->Program = clCreateProgramWithSource(instance->Context, 1, (const char **)&CHARBUFFER, (const size_t *)&CHARBUFFER_LEN, &result); if (result != CL_SUCCESS) { if(OutputLog)std::cout << "OpenCL>CreateProgram: Error creating program 1 [Error:" << result << "]" << std::endl; return VGL_OPENCL_INIT_FAILURE; } if(OutputLog)std::cout << "Program (1) Created from source" << std::endl; result = clBuildProgram(instance->Program, 1, &instance->Device[instance->clDeviceSelect], OPENCL_BUILD_OPTIONS, NULL, NULL); if (result != CL_SUCCESS) { if(OutputLog)std::cout << "OpenCL>BuildProgram: Error Building program 1 [Error:" << result << "]" << std::endl; free(CHARBUFFER); // First call to know the proper size clGetProgramBuildInfo(instance->Program, instance->Device[instance->clDeviceSelect], CL_PROGRAM_BUILD_LOG, 0, NULL, &CHARBUFFER_LEN); CHARBUFFER = (char*)malloc(CHARBUFFER_LEN+1); if(CHARBUFFER==NULL) { std::cout << "Main>LoadSource: Out of memory" << std::endl; return VGL_OUT_OF_MEMORY; } clGetProgramBuildInfo(instance->Program, instance->Device[instance->clDeviceSelect], CL_PROGRAM_BUILD_LOG, CHARBUFFER_LEN, CHARBUFFER, NULL); CHARBUFFER[CHARBUFFER_LEN]=0; if(OutputLog)std::cout << std::endl << "Compiler build log:" <<std::endl << CHARBUFFER << std::endl; free(CHARBUFFER); return VGL_OPENCL_INIT_FAILURE; } // Create the OpenCL kernel instance->Kernel_TraceRays= clCreateKernel(instance->Program, KERNEL_TRACERAYS, &result); if (result != CL_SUCCESS) { if(OutputLog)std::cout << "OpenCL>CreateKernel: Error creating Kernel 1 [Error:" << result << "]" << std::endl; return VGL_OPENCL_INIT_FAILURE; } instance->Kernel_TraceRayPackets= clCreateKernel(instance->Program, KERNEL_TRACERAYPACKETS, &result); if (result != CL_SUCCESS) { if(OutputLog)std::cout << "OpenCL>CreateKernel: Error creating Kernel 2 [Error:" << result << "]" << std::endl; return VGL_OPENCL_INIT_FAILURE; } if(OutputLog)std::cout << "OpenCL: Kernels Successfully created" << std::endl; free(CHARBUFFER); return VGL_SUCCESS; }

0 Likes
3 Replies
genaganna
Journeyman III

Originally posted by: antzrhere Just coding a program that uses Cl GL sharing.

Now everythings is working (including cl-gl interop), but for some reason if I actually enable the "cl_khr_gl_sharing" extension in my code I get an error from the compiler

 "error: can't enable all           OpenCL extensions or unrecognized OpenCL extension   #pragma OPENCL EXTENSION cl_khr_gl_sharing : enable                                                ^                                         "

I'm using a HD 5870 (Win 7-64bit, catalyst 11.9) which does support sharing and cl_khr_gl_sharing extension is reported as supported. The actual code works fine without the extension enabled (rendering to a GL Renderbuffer object, blitting etc. - i see everything working as expected), but I can't figure why this extension isn't recognised. Is it because AMDs implementation doesn't conform to the spec so it cannot be supported officially, or something else?

I create the context as following (I know I don't check for supported extensions etc., bad code, but it does work):

 



Thank you for reporting.  This extension is fully supported. Please remove #pragma presently.

0 Likes

I am still seeing this for the CPU target.

Removing the #pragma isn't really viable when you are targeting other platforms that may require it.

0 Likes

Thank you for reporting.Sorry it was not fixed for so long. I will file a bug for this,  and let you know the status.

0 Likes