Opencl: Graphics Interop: The Best of Both Worlds - Graphics and Compute
Opencl: Graphics Interop: The Best of Both Worlds - Graphics and Compute
// Linux + Windows
cl_APPLE_gl_sharing
Code Example:
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
int IsExtensionSupported(
! const char* support_str, const char* ext_string, size_t ext_buffer_size)
{
! size_t offset = 0;
! const char* space_substr = strnstr(ext_string + offset, " ", ext_buffer_size - offset);
! size_t space_pos = space_substr ? space_substr - ext_string : 0;
! while (space_pos < ext_buffer_size)
! {
! ! if( strncmp(support_str, ext_string + offset, space_pos) == 0 )
! ! {
! ! ! // Device supports requested extension!
! ! ! printf("Info: Found extension support %s!\n", support_str);
! ! ! return 1;
! ! }
! ! // Keep searching -- skip to next token string
! ! offset = space_pos + 1;
! ! space_substr = strnstr(ext_string + offset, " ", ext_buffer_size - offset);
! ! space_pos = space_substr ? space_substr - ext_string : 0;
! }
! printf("Warning: Extension not supported %s!\n", support_str);
! return 0;
}
Code Example:
Code Example:
Code Example:
Code Example:
! // Optional: Get the CPU device (we can request this in addition to GPUs in Share Group)
! cl_device_id cpu_device; int count;
! clGetDeviceIds(platform, CL_DEVICE_TYPE_CPU, 1 * sizeof(cl_device_id), &cpu_device, & count);
! // Create a context from a CGL share group (note: only use CPU if software renderer is enabled!)
! cl_context context = clCreateContext(properties, count, cpu_device, NULL, 0, 0);
Code Example:
Sharing Resources
Using GL objects in OpenCL
!
!
Code Example:
GL texture sharing
Code Example:
GL buffer sharing
OpenCL + GL Execution
Intermixing command streams
Code Example:
CL buffer to GL texture
Code Example:
CL buffer to GL texture
K>W/YZW
K>W/YZW
hD>KD'KD'
^&
d
^<
><EKZD>/KKZ^dZh&>^
><Z^^ZWd>DWEKE
><Z^^>DWdK'D/ZZKZZWd
><&/>dZEZ^d><&/>dZ>/EZ
Z'>K
&'>Z
K>K'>
&'>&'>d
K>
K>
'>
&'>d&'>Z
d
dK>hD
&'>
K>K'>^W/
>/K'>Z
K'>
> hD>d
K>
>K'>K
&'>
Z
'>
>DDZtZ/dKE>z>DDZtZ/d
>/K'>d
&'>d
'>
'>'>
^&'>
'>dydhZZdE'>
'>dydhZhDWWK^/d/syz
'>dydhZhDWE'd/syz
'
>
>K'>^K
,
E
Y/
Zt Zt E
E
&'><,Z
''>K/
< E
^
^ '>
^
'>
Zt Z Zt Zt
>'>K:dh&&Z
dK>W
>'>K:ddydhZdydhZ
>'>^
hd
>'>K:dZEZh&&Z
''>/<,Z
''>d/
>'>dydhZdZ'd
>'>D/WDW>s>
>s/^&KZ'>KEdyd<,Z
>hZZEds/&KZ'>KEdyd<,Z
^K
'>K
&'>d
hD>KD'KD'
'>
'>'>
Z'>K
>/K'>Z
K>K'>^W/
^&'>
&'>Z
K>K'>
&'>&'>d
'>dydhZ
&'>d&'>Z
K'>
K>
K>^W/
>K'>K
&'>
'>
&'>
>K'>^K
Y/
&<,Z
K<,Z
&'><,Z
''>K/
'>
'>
'>
K>K'>
>'>K:dh&&Z
/
>DDZtZ/dKE>z>DDZtZ/d
>'>K:ddydhZdydhZ
>'>^
&'>&'>d
>'>K:dZEZh&&Z
''>/<,Z
>DDZtZ/dKE>z>DDZtZ/d
>/K'>d
&'>d&'>Z
''>d/
&'>d
K'>
'>
&d<,Z
'>'>
K>
Questions?
Derek Gerstmann
University of Western Australia
http://local.wasp.uwa.edu.au/~derek