opencl: retry D3D11 device enumeration on transient CL_DEVICE_NOT_FOUND#745
opencl: retry D3D11 device enumeration on transient CL_DEVICE_NOT_FOUND#745jsphgei-dot wants to merge 1 commit into
Conversation
clGetDeviceIDsFromD3D11KHR() has been observed to spuriously return CL_DEVICE_NOT_FOUND on some AMD driver/OpenCL ICD combinations when another process is concurrently acquiring the same D3D11 device for its own OpenCL interop setup (e.g. a second overlapping transcode). This previously propagated all the way up as an unrecoverable "No matching devices found" device-creation failure (ENODEV), breaking hardware-accelerated transcodes that use OpenCL filters (e.g. subtitle burn-in) alongside AMF encoding. Retry the enumeration call a few times with a short delay before treating CL_DEVICE_NOT_FOUND as a genuine "no devices support this" answer.
|
I'm not against adding workarounds for gpu drivers but I want to limit scope as much as possible. Can you make this change to be optionally opt-in instead, and change the jellyfin server implementation so that it opt-in this retry behavior, for amd on windows? Also, please submit your change in a quilt patch like this: https://github.com/jellyfin/jellyfin-ffmpeg/tree/jellyfin/debian/patches Instead of directly changing upstream code. |
|
I haven't encountered this issue on GCN or RDNA cards over the past few years, and the |
|
Here's the source code of AMD's clGetDeviceIDsFromD3D11KHR implementation. I didn't even see the need to add Lock and Unlock. |
|
Marking this as draft while I keep digging. This one was frustratingly persistent for the evening, happening frequently enough that I was troubleshooting it for hours the night before, but now that I've got proper debug logging in place to actually catch it, it's stopped reproducing, so I don't have a clean root cause yet and don't want to close this out prematurely. Where things stand: the one real-world case that seemed to support this fix (a previously-failing episode working after deploying the patch) turned out to be inconclusive on closer look, not something I can actually attribute to this change. And nyanmisaka's pushback was fair, there's no confirmed mechanism for why this would help, and nothing I've found since supports treating CL_DEVICE_NOT_FOUND here as a genuine transient condition worth retrying on. Still working the actual root cause. Will update this PR once I have something more solid. |
|
It is known that the way OpenCL interop functions can conflict with Windows service installations and Remote Desktop usage. Such scenarios fall outside the scope of what we can fix. |
Summary
clGetDeviceIDsFromD3D11KHR()can occasionally returnCL_DEVICE_NOT_FOUNDon some AMD driver/OpenCL ICD combinations when another process is using the same D3D11 device at the same time (e.g. a second overlapping transcode). Right now that results in a hardDevice creation failed: -19/ "No matching devices found", which breaks any hardware transcode combining an OpenCL filter (subtitle burn-in, tonemap, etc.) with AMF encoding when this happens.clGetDeviceIDsFromD3D11KHR()calls before treatingCL_DEVICE_NOT_FOUNDas a genuine "no devices support this" answer. If the issue doesn't come up, behavior is unchanged; on the rare path where it does, this just adds up to ~100ms.Testing
Device creation failed: -19on subtitle-burn-in + AMF transcodes.