MCPcopy Create free account
hub / github.com/defold/defold / init_program

Method init_program

engine/dlib/src/basis/encoder/basisu_opencl.cpp:217–272  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

215 }
216
217 bool init_program(const char* pSrc, size_t src_size)
218 {
219 cl_int ret;
220
221 if (m_program != nullptr)
222 {
223 clReleaseProgram(m_program);
224 m_program = nullptr;
225 }
226
227 m_program = clCreateProgramWithSource(m_context, 1, (const char**)&pSrc, (const size_t*)&src_size, &ret);
228 if (ret != CL_SUCCESS)
229 {
230 ocl_error_printf("ocl::init_program: clCreateProgramWithSource() failed!\n");
231 return false;
232 }
233
234 std::string options;
235 if (m_dev_fp_config & CL_FP_CORRECTLY_ROUNDED_DIVIDE_SQRT)
236 {
237 options += "-cl-fp32-correctly-rounded-divide-sqrt";
238 }
239
240 options += " -cl-std=CL1.2";
241 //options += " -cl-opt-disable";
242 //options += " -cl-mad-enable";
243 //options += " -cl-fast-relaxed-math";
244
245 ret = clBuildProgram(m_program, 1, &m_device_id,
246 options.size() ? options.c_str() : nullptr, // options
247 nullptr, // notify
248 nullptr); // user_data
249
250 if (ret != CL_SUCCESS)
251 {
252 const cl_int build_program_result = ret;
253
254 size_t ret_val_size;
255 ret = clGetProgramBuildInfo(m_program, m_device_id, CL_PROGRAM_BUILD_LOG, 0, NULL, &ret_val_size);
256 if (ret != CL_SUCCESS)
257 {
258 ocl_error_printf("ocl::init_program: clGetProgramBuildInfo() failed!\n");
259 return false;
260 }
261
262 std::vector<char> build_log(ret_val_size + 1);
263
264 ret = clGetProgramBuildInfo(m_program, m_device_id, CL_PROGRAM_BUILD_LOG, ret_val_size, build_log.data(), NULL);
265
266 ocl_error_printf("\nclBuildProgram() failed with error %i:\n%s", build_program_result, build_log.data());
267
268 return false;
269 }
270
271 return true;
272 }
273
274 cl_kernel create_kernel(const char* pName)

Callers 1

opencl_initFunction · 0.80

Calls 5

ocl_error_printfFunction · 0.85
clBuildProgramFunction · 0.85
clGetProgramBuildInfoFunction · 0.85
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected