Adapting the circle struct for use with Boost Compute

The first thing we have to do is to make Boost Compute know what the Circle struct looks like, in order to be able to use it on the GPU. This is achieved by using a macro where the first two parameters are the C++ name and the GPU name of the struct, and the third parameter is the list of members in the struct.

Only the members of the struct are exposed, member functions of the struct cannot be accessed from within Boost Compute.

Below is how we adapt the Circle for use with Boost Compute using the BOOST_COMPUTE_ADAPT_STRUCT_MACRO. The first parameter is the name of the C++ struct, and the second parameter is the name when accessed from inside Boost Compute.

BOOST_COMPUTE_ADAPT_STRUCT(Circle, ...

Get C++ High Performance now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.