]> git.sesse.net Git - ffmpeg/blobdiff - libavutil/opencl.c
Merge commit '2ec112f71cd03ccab1b6f9a00d29199a57bcc7a5'
[ffmpeg] / libavutil / opencl.c
index 868649321f32678ade8435a8c8e5e180cbd907b4..62706f30941cf5b380b9a0bc4d0c6704b6ecb2fc 100644 (file)
@@ -84,7 +84,7 @@ static const AVOption opencl_options[] = {
 };
 
 static const AVClass openclutils_class = {
-    .class_name                = "OPENCLUTILS",
+    .class_name                = "opencl",
     .option                    = opencl_options,
     .item_name                 = av_default_item_name,
     .version                   = LIBAVUTIL_VERSION_INT,
@@ -449,12 +449,14 @@ end:
 cl_program av_opencl_compile(const char *program_name, const char *build_opts)
 {
     int i;
-    cl_int status;
+    cl_int status, build_status;
     int kernel_code_idx = 0;
     const char *kernel_source;
     size_t kernel_code_len;
     char* ptr = NULL;
     cl_program program = NULL;
+    size_t log_size;
+    char *log = NULL;
 
     LOCK_OPENCL;
     for (i = 0; i < opencl_ctx.kernel_code_count; i++) {
@@ -481,10 +483,36 @@ cl_program av_opencl_compile(const char *program_name, const char *build_opts)
         program = NULL;
         goto end;
     }
-    status = clBuildProgram(program, 1, &(opencl_ctx.device_id), build_opts, NULL, NULL);
+
+    build_status = clBuildProgram(program, 1, &(opencl_ctx.device_id), build_opts, NULL, NULL);
+    status = clGetProgramBuildInfo(program, opencl_ctx.device_id,
+                                   CL_PROGRAM_BUILD_LOG, 0, NULL, &log_size);
     if (status != CL_SUCCESS) {
+        av_log(&opencl_ctx, AV_LOG_WARNING,
+               "Failed to get compilation log: %s\n",
+               av_opencl_errstr(status));
+    } else {
+        log = av_malloc(log_size);
+        if (log) {
+            status = clGetProgramBuildInfo(program, opencl_ctx.device_id,
+                                           CL_PROGRAM_BUILD_LOG, log_size,
+                                           log, NULL);
+            if (status != CL_SUCCESS) {
+                av_log(&opencl_ctx, AV_LOG_WARNING,
+                       "Failed to get compilation log: %s\n",
+                       av_opencl_errstr(status));
+            } else {
+                int level = build_status == CL_SUCCESS ? AV_LOG_DEBUG :
+                                                         AV_LOG_ERROR;
+                av_log(&opencl_ctx, level, "Compilation log:\n%s\n", log);
+            }
+        }
+        av_freep(&log);
+    }
+    if (build_status != CL_SUCCESS) {
         av_log(&opencl_ctx, AV_LOG_ERROR,
-               "Compilation failed with OpenCL program: %s\n", program_name);
+               "Compilation failed with OpenCL program '%s': %s\n",
+               program_name, av_opencl_errstr(build_status));
         program = NULL;
         goto end;
     }