| 29 | // todo: build logs |
| 30 | |
| 31 | OpenCLProgram::OpenCLProgram(const OpenCLDevice& openCL, |
| 32 | const char* source) |
| 33 | { |
| 34 | auto status = CL_SUCCESS; |
| 35 | mProgram = clCreateProgramWithSource(openCL.context(), 1, &source, nullptr, &status); |
| 36 | if (status != CL_SUCCESS) |
| 37 | throw Exception(Status::Initialization); |
| 38 | |
| 39 | auto device = openCL.device(); |
| 40 | status = clBuildProgram(mProgram, 1, &device, nullptr, nullptr, nullptr); |
| 41 | if (status != CL_SUCCESS) |
| 42 | { |
| 43 | size_t buildLogSize = 0; |
| 44 | clGetProgramBuildInfo(mProgram, openCL.device(), CL_PROGRAM_BUILD_LOG, buildLogSize, nullptr, &buildLogSize); |
| 45 | |
| 46 | vector<char> buildLog(buildLogSize); |
| 47 | clGetProgramBuildInfo(mProgram, openCL.device(), CL_PROGRAM_BUILD_LOG, buildLogSize, buildLog.data(), nullptr); |
| 48 | |
| 49 | gLog().message(MessageSeverity::Error, "OpenCL compile failed:\n\n%s", buildLog.data()); |
| 50 | |
| 51 | throw Exception(Status::Initialization); |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | OpenCLProgram::~OpenCLProgram() |
| 56 | { |