2024-01-26, 10:20 AM
There is a regression in AMD's OpenCL runtime. Please stick with 23.x.x driver until it's fixed.
I will try to report this to AMD stuffs.
For details:
The error
It returns -60 which is ridiculous. Because -60 (CL_INVALID_GL_OBJECT) is used exclusively in OpenGL/CL sharing, not DX11/CL sharing. According to the OpenCL documentation, this value is also not within the return value range of this function.
After digging deeper into AMD's OpenCL runtime (clr), I found that the return code -60 only used by OpenGL/CL interop does appear on the return path of this DX11/CL sharing function. And they refactored this part of the code not long ago.
https://github.com/ROCm/clr/blame/8ff39a....cpp#L1597
https://github.com/ROCm/clr/blame/8ff39a....cpp#L1583
https://github.com/ROCm/clr/blame/8ff39a....cpp#L1708
https://github.com/ROCm/clr/blame/8ff39a....cpp#L1693
https://github.com/ROCm/clr/blob/8ff39a5...#L388-L395
I will try to report this to AMD stuffs.
For details:
The error
Failed to release texture: -60
happened in clEnqueueReleaseD3D11ObjectsKHR()
, which is used to release the DX11->OpenCL interop texture.It returns -60 which is ridiculous. Because -60 (CL_INVALID_GL_OBJECT) is used exclusively in OpenGL/CL sharing, not DX11/CL sharing. According to the OpenCL documentation, this value is also not within the return value range of this function.
After digging deeper into AMD's OpenCL runtime (clr), I found that the return code -60 only used by OpenGL/CL interop does appear on the return path of this DX11/CL sharing function. And they refactored this part of the code not long ago.
https://github.com/ROCm/clr/blame/8ff39a....cpp#L1597
https://github.com/ROCm/clr/blame/8ff39a....cpp#L1583
https://github.com/ROCm/clr/blame/8ff39a....cpp#L1708
https://github.com/ROCm/clr/blame/8ff39a....cpp#L1693
https://github.com/ROCm/clr/blob/8ff39a5...#L388-L395
Code:
// jellyfin-ffmpeg/libavutil/hwcontext_opencl.c
static void opencl_unmap_from_d3d11(AVHWFramesContext *dst_fc,
HWMapDescriptor *hwmap)
{
AVOpenCLFrameDescriptor *desc = hwmap->priv;
OpenCLDeviceContext *device_priv = dst_fc->device_ctx->internal->priv;
OpenCLFramesContext *frames_priv = dst_fc->internal->priv;
cl_event event;
cl_int cle;
cle = device_priv->clEnqueueReleaseD3D11ObjectsKHR(
frames_priv->command_queue, desc->nb_planes, desc->planes,
0, NULL, &event);
if (cle != CL_SUCCESS) {
av_log(dst_fc, AV_LOG_ERROR, "Failed to release texture "
"handle: %d.\n", cle);
}
opencl_wait_events(dst_fc, &event, 1);
}