Interop Helpers¶
The user can include fg/compute_copy.h header to avoid writing necessary compute backend’s OpenGL interoperation code themselves.
Following defines should be declared prior to inclusion of this header to use respective compute backend helpers.
USE_FORGE_CPU_COPY_HELPERS
USE_FORGE_CUDA_COPY_HELPERS
USE_FORGE_OPENCL_COPY_HELPERS
-
struct
GfxHandle
¶ A tuple object of GfxResourceHandle and BufferType.
-
enum
BufferType
¶ Enum to indicate if OpenCL buffer is a PBO or VBO.
Values:
-
enumerator
FORGE_IMAGE_BUFFER
¶ OpenGL Pixel Buffer Object.
-
enumerator
FORGE_VERTEX_BUFFER
¶ OpenGL Vertex Buffer Object.
-
enumerator
-
typedef void *
ComputeResourceHandle
¶ A backend-agnostic handle to a compute memory resource originating from an OpenGL resource.
cudaGraphicsResource in CUDA
cl_mem in OpenCL
unsigned from standard cpu A backend-agnostic handle to a compute memory resource.
For example: CUDA device pointer, like float*, int* from cudaMalloc. A cl_mem* from OpenCL’s clCreateBuffer
The following are the helper functions defined in this header. Dependending on which USE_FORGE_<compute>_COPY_HELPERS macro is defined, the right set of helpers are chosen at compile time.
void createGLBuffer(GfxHandle** pOut,
const unsigned pResourceId,
const BufferType pTarget);
void releaseGLBuffer(GfxHandle* pHandle);
void copyToGLBuffer(GfxHandle* pGLDestination,
ComputeResourceHandle pSource,
const size_t pSize)
You can find the exact usage details of this header in the examples section.