-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Weird tearing and artifacts in D3D11VA>>OpenCL mapping #243
Comments
I will check on this. Thanks. |
@nyanmisaka Could you please provide the patch with your change so that I can debug with my own? I have added the D3D11_RESOURCE_MISC_SHARED but it seems not enough. Currently the map only can handle nv12 format. Thanks. |
@tong1wu Thanks for look into it! As per the comment in NEO, the P010 format is already supported for years but FFmpeg haven't enabled it yet in the Here's the patch: |
And here's the other patch that enables QSV/D3D11 to OCL mapping:
For comparison this mapping has no issue. So I suspect there's something wrong with the d3d11va hwaccel. |
Weird. I tried on TGL. D3d11dec->opencl->d3d11->qsv->download. It worked fine. Rawvideo->d3d11 upload->opencl->download also worked fine. D3d11dec->qsv->opencl->download had corruption. It doesn't look like something is going wrong with d3d11va because it works for several combinations. It seems the corruption only happens when d3d11dec->opencl then download with opencl. Most probably something went wrong in the driver when doing the synchronization. |
It seems my original issue is specific to Intel discrete GPUs, like the DG1/Xe Max and DG2/Arc. I used to have TGL (i7-1165g7) and it worked fine at that time. Or at least the issue is not obvious but the output is not bitperfect (mismatched checksums). I also think there is a synchronization issue in FFmpeg or the driver. As far as I know, both So my finding is that when decoding other HEVC 4k clips using d3d11va hwaccel with the following params you can also get the same tearing and artifacts.
Currently AV1 hwaccel in ffmpeg does not support threading. |
From what I understand, if you specify -threads 1, there will be only 1 thread right? And from the code it seems -thread_type -slice-frame doesn't affect anything if threads is already set to 1. Just curious why we have this issue when the thread count is 1. And I cannot reproduce this hevc issue on TGL. On DG2 it happens randomly, sometimes it's fine. But for the av1 issue I can reproduce it on TGL. I suspect they are different issues. |
Correct. It's my bad. The Either On my side both issues occur after the IMHO if the corrupted frame has a pattern similar to the screenshot above, they all should be the synchronization issue.
Indeed. It was hard for me to notice, but there is jittering on certain clips from time to time. Increasing the
I never got a normal output using the above command on DG2. I also found that this issue disappears when you manually limit the speed of the pipeline.
e.g. for the 60fps AV1 clip it limits the pipeline speed to ~30fps and the issue disappears but it must be inserted before the |
OpenCL driver should have guaranteed the synchronization as you discussed in the other issue channel. I did a small experiment. Just add following code before
This downloads the data to a useless AVFrame, where D3D11 must provide the synchronization guarantee. And it turns out to be correct for your AV1 command. I think it's OpenCL's responsibility that it indeed does not do the synchronization job properly and deals with the dirty memory. |
That make sense. It invokes This can be a temporary workaround but it still degrades performance and its not the desired behavior. So these should be conclusions:
Can you intel guys help me forward this issue to the OpenCL team? Thanks again! |
Ok I'll try to forward it to OpenCL. Thanks. |
According to OpenCL team, the github issue will be analyzed by the first available engineer. So I guess we need to wait a little bit and keep checking the status of intel/compute-runtime#602. |
Thanks for your update. I'll keep an eye on it. I made some changes to your small experiment to speed up a little bit (GPU->GPU copy). And it's proved that the Do you happen to know is there a similar sync texture function in D3D11 like the
|
Hello here! I have a use case that needs to use OpenCL kernels to process HW decoded frames to make up for some functions that VPP cannot do.
d3d11va hwaccel -> d3d11 tex -> hwmap -> opencl image -> *_opencl filter
But after testing the mapped image will produce tearing as shown in the video. This issue only happens on Intel GPU, I can't reproduce it on AMD GPU with the same KHR extension. I thought it was an OpenCL runtime issue so I also filed an issue with detailed steps in NEO.
FFmpeg was patched with the D3D11_RESOURCE_MISC_SHARED flag to allow interop.
For convenience you can also try our custom ffmpeg builds with DX11/QSV->OCL interop added.
And here's a sample video encoded in AV1 that can trigger this issue. av1_clip.zip
dx11_ocl_interop_tearing.mp4
The text was updated successfully, but these errors were encountered: