Skip to content
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

d3d11vpp: add GPU scale option for intel and nvidia GPUs #14155

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

billxc
Copy link

@billxc billxc commented May 16, 2024

usage:
vf set d3d11vpp=scale=nvidia:scale-target

PS:
The pull requests is has not been rebased to one commit yet, as I still need some changes, and will rebase to one commit once ready for merge.

@billxc
Copy link
Author

billxc commented May 16, 2024

Quate the comment from #11390

@billxc First off, it's great that you're working on this, and thank you for looking at my original feedback. However, after taking an initial look at your tree, it looks like you have written it as a separate filter. For it to be mergeable, the functionality should be added to d3d11vpp. Were you just doing it as a separate filter as an initial development step? I can't tell.
Also, the filter's configuration interface should not hard code the "Super Resolution" concept - as I understand it, it's just a generic scaling function and vendors or anyone can write and plug in a scaling algorithm (I see you have added Intel as a second example), so it should just be a scale configuration. It should also support taking arbitrary width and height for the scaling output, as that is supported in the general case (does RTX Video only work for fixed resolutions?). Thanks!
Feel free to open a PR - it will be easier to discuss there.
Originally posted by @philipl in #11390 (comment)

Also to make it scalable for the future we could extend options of d3d11vpp with arbitrary GUID that user could provide. Would avoid having to recompile mpv for different variant of the same. I think AMD has some sort of super res too, which has to be enabled, because normally this interface just scales without fancy features.
Originally posted by @kasper93 in #11390 (comment)

@billxc
Copy link
Author

billxc commented May 16, 2024

@philipl

I have refacted the code to reuse d3d11vpp, also updatd the option name. There will be another change later to change SuperResolution to Scale to avoid potential copyright issue.

It should also support taking arbitrary width and height for the scaling output, as that is supported in the general case (does RTX Video only work for fixed resolutions?)

RTX video do support any resolution. Idealy, we should take the actual window size, and use them for the target height/width
but I am not quite familiar with MPV code, Would you help provide some examples for getting the actual window height and width?

@kasper93 The GPU API are not quite the same for different venders, as you can see from my code for nvidia and intel, they may be similar, but not the same, it is hard to simplely provide API for user to set the GUID, and it just works. AMD has super res which called FSR, but it is not a GPU API, the usage is not the same as intel/nvidia, there are some glsl shades implemented the FSR for MPV.


Also I have tried to use the intel auto HDR API, but failed, do we have examples for turning a SDR video to HDR video.

@kasper93
Copy link
Contributor

kasper93 commented May 16, 2024

@kasper93 The GPU API are not quite the same for different venders, as you can see from my code for nvidia and intel, they may be similar, but not the same, it is hard to simplely provide API for user to set the GUID, and it just works. AMD has super res which called FSR, but it is not a GPU API, the usage is not the same as intel/nvidia, there are some glsl shades implemented the FSR for MPV.

I don't think they call their video hq scaler FSR in any documentation. Though indeed looking at it they did expose it through own interface, rather than rolling custom video processor in d3d11 video processing interface (to be confirmed if not available through it, not sure what browsers use). It could live in the same mpv filter (d3d11vpp), same as they integrated it in VLC.

See:
https://github.com/GPUOpen-LibrariesAndSDKs/AMF/blob/master/amf/doc/AMF_HQ_Scaler_API.md
https://code.videolan.org/videolan/vlc/-/merge_requests/4953

@ruihe774
Copy link
Contributor

ruihe774 commented May 16, 2024

The AMF doc says it supports

  • DirectX 11
  • DirectX 12
  • Vulkan
  • OpenCL

FWIW I'm curious about whether it is possible to be implemented as a cross-platform filter with both d3d11 and vulkan backends.

@kasper93
Copy link
Contributor

For AMD AMF stuff, it seems to be integrated in ffmpeg https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=11632 so we can skip this part and have it for free once it get merged.

@Jules-A
Copy link

Jules-A commented May 16, 2024

For AMD AMF stuff, it seems to be integrated in ffmpeg https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=11632 so we can skip this part and have it for free once it get merged.

FFMPEG are being difficult again (https://www.phoronix.com/news/AMD-AMF-FFmpeg-Better-2024) so not really sure if it would get merged soon.

@SaberDirewolf
Copy link

@philipl

I have refacted the code to reuse d3d11vpp, also updatd the option name. There will be another change later to change SuperResolution to Scale to avoid potential copyright issue.

It should also support taking arbitrary width and height for the scaling output, as that is supported in the general case (does RTX Video only work for fixed resolutions?)

RTX video do support any resolution. Idealy, we should take the actual window size, and use them for the target height/width but I am not quite familiar with MPV code, Would you help provide some examples for getting the actual window height and width?

@kasper93 The GPU API are not quite the same for different venders, as you can see from my code for nvidia and intel, they may be similar, but not the same, it is hard to simplely provide API for user to set the GUID, and it just works. AMD has super res which called FSR, but it is not a GPU API, the usage is not the same as intel/nvidia, there are some glsl shades implemented the FSR for MPV.

Also I have tried to use the intel auto HDR API, but failed, do we have examples for turning a SDR video to HDR video.

Not sure if this is helpful, but was staring at how Chrome's Auto HDR works and is the original commit (there might be bug fixes after this commit): chromium/chromium@b2fae4c

Here is another example: Aleksoid1978/VideoRenderer#128

video/filter/vf_d3d11vpp.c Outdated Show resolved Hide resolved
video/filter/vf_d3d11vpp.c Outdated Show resolved Hide resolved
video/filter/vf_d3d11vpp.c Outdated Show resolved Hide resolved
video/filter/vf_d3d11vpp.c Outdated Show resolved Hide resolved
video/filter/vf_d3d11vpp.c Outdated Show resolved Hide resolved
video/filter/vf_d3d11vpp.c Outdated Show resolved Hide resolved
video/filter/vf_d3d11vpp.c Outdated Show resolved Hide resolved
video/filter/vf_d3d11vpp.c Outdated Show resolved Hide resolved
video/filter/vf_d3d11vpp.c Outdated Show resolved Hide resolved
video/filter/vf_d3d11vpp.c Outdated Show resolved Hide resolved
@kasper93
Copy link
Contributor

Also needs fixes for gcc compilation and commits should be squashed into logical parts.

@srk24
Copy link

srk24 commented May 17, 2024

@Hrxn
Copy link
Contributor

Hrxn commented May 17, 2024

@srk24 What is this NGX? Is it even supported anymore?

@philipl
Copy link
Member

philipl commented May 17, 2024

@srk24 What is this NGX? Is it even supported anymore?

NGX is off topic for the work in this PR. It's nvidia's umbrella for some AI based image/video processing scalers - none of which are usable via the d3d11 scaling mechanism covered by this PR.

adjust order

FIX: api usage

adjust order

update

log

refactor

fix error

logging

logging

fix error

fix error

update

logging

update

update

update

update

logging

update

update

update

Revert "update"

This reverts commit 2642c41.

update

fixed 2K

hardcode 2k

test size

test size

test

Revert "test"

This reverts commit 596890b.

Revert "test size"

This reverts commit ef2b98a.

Revert "test size"

This reverts commit 38001eb.

GNU GLOBAL

LOGGING TEST

logging

fix logging

Revert "fix logging"

This reverts commit ec4f9c0.

fix error

revert logging

remove logging because POC complete

logging

logging

logging

logging

comment

update

update

try fix

update

fix

fix

fix

fix

fix

fix

fix

fix

use 4K

add option

fix build

more options

fix build

fix

add defaults

add vulkan for build

add d3d11sr

delete code

remove processing

rename

Revert "rename"

This reverts commit 82742d8.

Revert "remove processing"

This reverts commit c5acd59.

Revert "delete code"

This reverts commit 14250fb.

Revert "add d3d11sr"

This reverts commit 6bc9c1e.

add d3d11sr

disable deint

fix blur

fix size

revert change

fix warning

remove logging

add intel code

rename field

remove mode param

remove unused variables

Support SR selection

add shorts

revert d3d11vpp changes

remove unused

optmization

handle SW decoding, dint not included

stop processing if width or height is uneven

cleanup

cleanup

Store SR state

Revert "add vulkan for build"

This reverts commit 0952b9f.

revert unrelated code

migrate back to d3d 11vpp
code format
@billxc
Copy link
Author

billxc commented May 18, 2024

updated the easy parts.
and still some TODOs:

  1. Seeking correct place to do the uploading/downloading
  2. Support any scale ratio
  3. Support getting current VO size for scaling output

update:

Tasks 1, 2, and 3 all require extensive knowledge of MPV, which I currently lack.

Therefore, I will keep the changes small:

  1. Remove support for IMG_FMT_420P, maintaining the same rule as d3d11vpp.
  2. Hard code the scale output window to 1440p. Considering that this feature only supports recent graphics cards, this should strike a balance between performance and quality.

@wadixx
Copy link

wadixx commented May 28, 2024

updated the easy parts. and still some TODOs:

  1. Seeking correct place to do the uploading/downloading
  2. Support any scale ratio
  3. Support getting current VO size for scaling output

Hey any update on TODOs?

@SPiCa-P
Copy link

SPiCa-P commented Jun 6, 2024

Hi, sorry for bothering you.
Thank you for your excellent work!
When I used your build, my mpv crashed using vf=d3d11sr=mode=nvidia after 1-3min. I checked both output-error logs from mpv and windows error logs, the only useful message is in the windows error log, that is:

‘d3d11 crash 0xc0000005'

Is there any other way to detect issues or logs? Thank you so much!

@billxc
Copy link
Author

billxc commented Jun 7, 2024

Hi, sorry for bothering you. Thank you for your excellent work! When I used your build, my mpv crashed using vf=d3d11sr=mode=nvidia after 1-3min. I checked both output-error logs from mpv and windows error logs, the only useful message is in the windows error log, that is:

‘d3d11 crash 0xc0000005'

Is there any other way to detect issues or logs? Thank you so much!

The code has changed a lot since that version, it may be a memory leak or something like that.

@billxc
Copy link
Author

billxc commented Jun 7, 2024

updated the easy parts. and still some TODOs:

  1. Seeking correct place to do the uploading/downloading
  2. Support any scale ratio
  3. Support getting current VO size for scaling output

update:
Tasks 1, 2, and 3 all require extensive knowledge of MPV, which I currently lack.

Therefore, I will keep the changes small:

  1. Remove support for IMG_FMT_420P, maintaining the same rule as d3d11vpp.
  2. Hard code the scale output window to 1440p. Considering that this feature only supports recent graphics cards, this should strike a balance between performance and quality.

@AlawamiAZ
Copy link

using this build gives me this artifact on certain videos using the vf=d3d11sr=mode=nvidia:scale=1440p option
Screenshot 2024-06-07 162628
the videos with this issue can be found using with this bittorrent hash 27fe4e276f5b3d6997d9409ae844b32eeae278f7

Copy link
Author

@billxc billxc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

@billxc
Copy link
Author

billxc commented Jun 12, 2024

using this build gives me this artifact on certain videos using the vf=d3d11sr=mode=nvidia:scale=1440p option Screenshot 2024-06-07 162628 the videos with this issue can be found using with this bittorrent hash 27fe4e276f5b3d6997d9409ae844b32eeae278f7

There is something wrong when converting the YUV420P formt to NV12.
YUV420P is not supported by d3d11vpp before, and I tried to support this. It led to many bugs, and some are beyond my capability. so in the current pr, YUV420P will not be supported by d3d11vpp just like before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet