Using #include to load OpenCL code

后端 未结 2 1357
刺人心
刺人心 2021-01-03 00:43

I\'ve seen this done long ago with hlsl/glsl shader code -- using an #include on the source code file that pastes the code into a char* so that no

2条回答
  •  [愿得一人]
    2021-01-03 01:17

    See the bullet physics engines use of OpenCL for how to do this to a kernel.

    In C++ / C source

    #define MSTRINGIFY(A) #A
    char* stringifiedSourceCL = 
    #include "VectorAddKernels.cl"
    

    In the OpenCL source

    MSTRINGIFY(
       __kernel void VectorAdd(__global float8* c)
       {
        // snipped out OpenCL code...
        return;
       }
    );
    

提交回复
热议问题