void Program::getInfo(cl_program_info paramName, size_t paramValueSize, void *paramValue) const { cl_int err = 0; size_t written = 0; err = clGetProgramInfo(programHandle(), paramName, paramValueSize, paramValue, &written); if(err != CL_SUCCESS) { throw OpenCLException(err); } }
void ThrusterShader::apply() { //call initial apply Shader::apply(); //set shader parameters GLint handle = programHandle(); GLint uniformHandle = glGetUniformLocation(handle, "u_TotalTime"); glUniform1f(uniformHandle, m_TotalTime); }
Kernel Program::createKernel(const Epic::Core::ASCIIString& kernelName) const { cl_int err = 0; cl_kernel kernel = clCreateKernel(programHandle(), kernelName.data(), &err); if(err != CL_SUCCESS) { throw OpenCLException(err); } return Kernel(kernel); }
void Program::getBuildInfo(cl_program_build_info paramName, const Device& device, size_t paramValueSize, void *paramValue) const { cl_int err = 0; size_t written = 0; err = clGetProgramBuildInfo(programHandle(), device.deviceID(), paramName, paramValueSize, paramValue, &written); if(err != CL_SUCCESS) { throw OpenCLException(err); } }
size_t Program::getBuildInfoSize(cl_program_build_info paramName, const Device& device) const { size_t ret; cl_int err = 0; err = clGetProgramBuildInfo(programHandle(), device.deviceID(), paramName, 0, nullptr, &ret); if(err != CL_SUCCESS) { throw OpenCLException(err); } return ret; }
size_t Program::getInfoSize(cl_program_info paramName) const { size_t ret; cl_int err = 0; err = clGetProgramInfo(programHandle(), paramName, 0, nullptr, &ret); if(err != CL_SUCCESS) { throw OpenCLException(err); } return ret; }
bool Program::build(const Epic::Core::Array<Device>& devices, const Epic::Core::ASCIIString& options) const { Array<cl_device_id> deviceArray; size_t numDevices = 0; if(devices.isEmpty()) { numDevices = devices.count(); deviceArray = deviceIDHelper(devices); } cl_int err = clBuildProgram(programHandle(), numDevices, deviceArray.data(), options.data(), nullptr, nullptr); /* Skip CL_BUILD_PROGRAM_FAILURE error, will be handled later in this code. */ if((err != CL_BUILD_PROGRAM_FAILURE) && (err != CL_SUCCESS)) { throw OpenCLException(err); } Epic::Core::Array<Device> devs; bool ret = true; if(devices.isEmpty()) { devs = this->devices(); } else { devs = devices; } for(size_t i = 0; i < devs.count(); i++) { cl_build_status status = buildStatus(devs[i]); cout << "Build log for device " << devs[i].deviceID() << endl; cout << buildLog(devs[i]) << endl; while(status == CL_BUILD_IN_PROGRESS) { status = buildStatus(devs[i]); } if(status == CL_BUILD_SUCCESS) { cout << "Program compilation successful" << endl; } else { cout << "Program compilation failed" << endl; } ret &= (status == CL_BUILD_SUCCESS); } return ret; }