Kodi Community Forum

Full Version: DXVA2 improvements (HW video decoding) - Merged into master
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
This build has a big DXVA2 improvement for NVIDIA users (HW video decoding). Recently NVIDIA has enabled on their drivers the capability of direct share video decoder surfaces with rendering surfaces. Until now are need (on Kodi at least) a temporal copy surface that may causes some issues on determined cases. Basically green artifacts on some instants when decoding timing is irregular (skip chapters,  playback Blu-Ray UHD menus/ DVD menus, some MPEG2 content, PVR recordings, etc.).

This should be eradicated in this build for NVIDIA at least.

v20 Nexus with DXVA2 improvements:
https://mirrors.kodi.tv/test-builds/wind...nt-x64.exe


NOTES: 
  • Not tested at all on AMD graphics but feature is enabled. This means that can work fine or not work at all (green screen). Feedback is need Smile  Maybe can be tuned to enable only with supported drivers.
  • For Intel this code path is already active in both master/Matrix so nothing to improve here.
  • As this is a new feature, it is not planned to port to Matrix at first.

Since not all NVIDIA graphics drivers supports this (only from version 465.xx) are implemented a driver version detection and is shown on Kodi logs like this:

xml:
2022-01-23 18:04:12.222 T:8064     INFO <general>: DX:Big GrineviceResources::CheckNV12SharedTexturesSupport: extended NV12 shared textures is supported
2022-01-23 18:04:12.237 T:8064     INFO <general>: DX:Big GrineviceResources::CreateDeviceResources: device is created on adapter 'NVIDIA GeForce RTX 2060 SUPER' with D3D_FEATURE_LEVEL_12_1
2022-01-23 18:04:12.238 T:8064     INFO <general>: DX:Big GrineviceResources::GetVideoDriverVersion: video driver version is NVIDIA 511.23 (30.0.15.1123)
2022-01-23 18:04:12.238 T:8064     INFO <general>: DX:Big GrineviceResources::CheckDXVA2SharedDecoderSurfaces: DXVA2 shared decoder surfaces is supported
2022-01-23 18:04:12.243 T:8064     INFO <general>: DX:Big GrineviceResources::ResizeBuffers: 10 bit swapchain is used with 6 flip discard buffers and SDR output

It would be interesting if those of you who try this version copy these lines in the forum to see if everything works well and make adjustments if something is wrong.

Log line "DXVA2 shared decoder surfaces is supported" confirms this feature is enabled if compatible driver is detected on runtime. In addition to fixing green flashes, having this enabled means  less video memory consumption and higher performance for 4K, etc.

Feedback is welcomed!  Wink
Performance comparison playing 4K video:

Before:
Image 

After:
Image


Note that the dedicated GPU memory drops from 1.1 GB to 659 MB
@jogal 

Tested with Nvidia GTX1050 Legion Laptop, windows 11 x64, all working great, in a few menus BDs, no more green effects, thanks.
 
Code:
2022-01-23 21:20:50.613 T:19332    INFO <general>: * Adding remote mapping for device 'Abstract'
2022-01-23 21:20:50.681 T:11084    INFO <general>: DX::DeviceResources::CheckNV12SharedTexturesSupport: extended NV12 shared textures is supported
2022-01-23 21:20:50.681 T:11084    INFO <general>: DX::DeviceResources::CreateDeviceResources: device is created on adapter 'Intel(R) UHD Graphics 630' with D3D_FEATURE_LEVEL_12_1
2022-01-23 21:20:50.689 T:11084    INFO <general>: DX::DeviceResources::GetVideoDriverVersion: video driver version is Intel 30.0.101.1157
2022-01-23 21:20:50.689 T:11084    INFO <general>: DX::DeviceResources::CheckDXVA2SharedDecoderSurfaces: DXVA2 shared decoder surfaces is supported
2022-01-23 21:20:50.742 T:11084    INFO <general>: DX::DeviceResources::ResizeBuffers: 8 bit swapchain is used with 6 flip discard buffers and SDR output
2022-01-23 21:20:50.769 T:11084    INFO <general>: RetroPlayer[PROCESS]: Registering process control for Windows
2022-01-23 21:20:50.769 T:11084    INFO <general>: RetroPlayer[RENDER]: Registering renderer factory for DirectX
@Wanilton is that one of those laptops that has switchable GPU's between the Intel & Nvidia? as the log lines you posted show you're using the Intel GPU and NOT the Nvidia.
@jjd-uk 

Yes, exactly, I have switchable GPUs (Intel & Nvidia) laptop, I tested videos with 2 GPUs, working well. I don´t have one with AMD GPU to test here.
(2022-01-24, 13:15)Wanilton Wrote: [ -> ]@jjd-uk 

Yes, exactly, I have switchable GPUs (Intel & Nvidia) laptop, I tested videos with 2 GPUs, working well. I don´t have one with AMD GPU to test here.

Thanks for confirming you did test both. Since you posted the log details for the Intel I wasn't sure if maybe you'd mistakely thought you were testing the Nvidia but hadn't actually switched to it.
@jjd-uk 

here

Code:
2022-01-24 09:34:20.550 T:18292    INFO <general>: DX::DeviceResources::CheckNV12SharedTexturesSupport: extended NV12 shared textures is supported
2022-01-24 09:34:20.562 T:18292    INFO <general>: DX::DeviceResources::CreateDeviceResources: device is created on adapter 'NVIDIA GeForce GTX 1050' with D3D_FEATURE_LEVEL_12_1
2022-01-24 09:34:20.562 T:18292    INFO <general>: DX::DeviceResources::GetVideoDriverVersion: video driver version is NVIDIA 511.23 (30.0.15.1123)
2022-01-24 09:34:20.562 T:18292    INFO <general>: DX::DeviceResources::CheckDXVA2SharedDecoderSurfaces: DXVA2 shared decoder surfaces is supported
2022-01-24 09:34:20.565 T:18292    INFO <general>: DX::DeviceResources::ResizeBuffers: 8 bit swapchain is used with 6 flip discard buffers and SDR output
2022-01-24 09:34:20.658 T:18292    INFO <general>: RetroPlayer[PROCESS]: Registering process control for Windows
2022-01-24 09:34:20.659 T:18292    INFO <general>: RetroPlayer[RENDER]: Registering renderer factory for DirectX
For AMD drivers is tactically enabled from Adrenalin 21.9.1  (21.30.17.01)  but not knowing if it is supported.... Just because it's first WDDM 3.0 driver
Working great here GTX 1060
 
Code:
2022-01-25 16:43:12.866 T:23236 INFO <general>: DX::DeviceResources::CheckNV12SharedTexturesSupport: extended NV12 shared textures is supported
2022-01-25 16:43:12.866 T:23236 INFO <general>: DX::DeviceResources::CreateDeviceResources: device is created on adapter 'NVIDIA GeForce GTX 1060 6GB' with D3D_FEATURE_LEVEL_12_1
2022-01-25 16:43:12.866 T:23236 INFO <general>: DX::DeviceResources::GetVideoDriverVersion: video driver version is NVIDIA 511.23 (30.0.15.1123)
2022-01-25 16:43:12.866 T:23236 INFO <general>: DX::DeviceResources::CheckDXVA2SharedDecoderSurfaces: DXVA2 shared decoder surfaces is supported

Before I would sometimes get a blank green screen for a couple seconds before video would start playing, videos play right away now
New build that fixes driver detection on AMD systems:

https://mirrors.kodi.tv/test-builds/wind...nt-x64.exe

xml:
2022-01-28 19:06:43.877 T:10676    INFO <general>: DX:Big GrineviceResources::CreateDeviceResources: device is created on adapter 'AMD Radeon RX 6600 XT' with D3D_FEATURE_LEVEL_12_1
2022-01-28 19:06:43.877 T:10676    INFO <general>: DX:Big GrineviceResources::GetVideoDriverVersion: video driver version is AMD 30.0.14023.3004
2022-01-28 19:06:43.877 T:10676    INFO <general>: DX:Big GrineviceResources::CheckDXVA2SharedDecoderSurfaces: DXVA2 shared decoder surfaces is supported

Seems is working fine on AMD graphics too. Also updated link in first post.
Merged into master branch
@jogal 
I wanted to see how your DXVA2 improvements change the video playback on my system and tried your test build as portable-installation*, but sadly for me it does not work as expected: video playback flickers right from the start and the video is scrambled most of the time, it is difficult to even recognize the movie - not sure how to describe it but it is definately not usable.
I'm using a Thinclient (Dell Wyse 7050 ExtendedChassis, Intel Pentium Silver J5005, 16GB RAM, OS on SSD) with a "HP AMD Radeon RX 550X 4GB (P/N: 5LH79AA)" connected to TV via HDMI. Kodi v19.1 and v19.3 run flawless - at least everything I throw at it (H264/H265, 720p/1080p/UHD, SDR/HDR).

*Until now I've tested the following builds as a clean portable installation:
2) (test-build) KodiSetup-20220128-51c20c85-DXVA2-improvement-x64.exe
2) (test-build) KodiSetup-20220129-2ff734d2-master-x64.exe
3) (nightly) KodiSetup-20220216-3ee2707d-master-x64.exe
4) (nightly) KodiSetup-20220124-e60e5c24-master-x64.exe
with "Allow hardware acceleration DXVA2 = on" only the last one works and the others not.

Could you please have a look at the debug log of (3)? Anything I should/could try?
Thank you for providing this useful information.

Now we know that RX550 may not support this feature at least with the drivers and version of Windows you are using.

Please note that Kodi v20 is in pre-Alpha state and for this reason this change is not in the Matrix (nor will it be at the moment). In fact, I was already expecting something like this to happen with AMD. This is not a "Kodi bug" simply the hardware or drivers you are using do not support a "new feature". There are only two solutions:

1) Update the HW / drivers / OS to a version that supports it.

2) Blacklist driver number or HW model so that Kodi knows to use the old method on this HW.

 
(2022-02-18, 19:52)aj84 Wrote: [ -> ]Anything I should/could try?

First you can try to update graphics driver:

INFO <general>: DX::DeviceResources::GetVideoDriverVersion: video driver version is AMD 30.0.13025.5005

This is Adrenalin 21.10.2 according this table https://gpuopen.com/version-table/  and there are about ten more recent versions.

You may try 22.1.2 directly.

Ideally you should also update Windows to a newer version (form current 20H2 to 21H2).

Of course it is not mandatory that you do all this... you can continue to use Kodi v19.3 and later stable versions when released. 

Nor can I give you any guarantee that updating everything will work, it is possible that your hardware simply does not support this at all.
Thanks for looking into it, jogal! Highly appreciated!

Small note regarding graphics driver:
Just before starting the tests I updated the Radeon Graphics driver (from v21.6.1 to v21.10.2) because of your notice in post #8. I did not choose a newer version because I've read in other threads (atm not sure which topic it was) that the Radeon drivers from january/february 2022 lead to other playback problems, which were solved by downgrading the driver. [Also AMD declared all newer drivers as "optional" compared to the older v21.10.2 "Recommended (WHQL)" and I normally prefer stability over "fancy expiremtental stuff".]

Never the less I absolutely understand your conclusions and recommendations (although I feared them).

I don't want to mess up my current installation, so I can't promise to test a) newer Radeon drivers and/or b) newer windows version, but If I find a spare SSD & some time I'll likely run some tests and let you know what happens.
works good with 4650g, driver 21.10.4 and 21h2.
the only error that i see is "chosen scaling method 1 is not supported by renderer" on a clean, portable install using build from 1st post.
Pages: 1 2 3