Skip to content

Conversation

@jeeb
Copy link
Member

@jeeb jeeb commented May 6, 2018

Now more or less brought to a relatively good state.

Enables among other things, the configuration of the PQ color space (BT.2020 primaries, PQ transfer function) for HDR.

  1. Adds the concept of FBO color space into the rendering.
  2. By default utilizes the color space of the desktop on which the swap chain is located.
  3. If a specific value is defined by the user, it will be instead be utilized.
  4. Additionally, signals the swap chain color space to the renderer, so that the render looks correct without having to specify target-trc or target-prim manually.
  5. Due to all of the APIs being Win10+ only, will only work starting with Windows 10.

Initial things to do:

  • Initial PoC.
  • Moving relevant stuff under general d3d11 helpers.
  • Sharing colorspace information (primaries, transfer function, HDR metadata) with the rendering stuff, and the renderer having its own colorimetry state.
  • Checking the screen the window is on, and auto-detecting PQ+BT.2020-configured screens and making an (on/off/auto) option for PQ+BT.2020 swap chains, where auto sets a PQ+BT.2020 swap chain if content is HDR and screen is in PQ mode.
  • Setting the output transfer function to PQ and primaries to BT.2020 if PQ+BT.2020 swap chain is enabled by default, to match render target.

Things to maybe do later:

  • Pass on HDR metadata if available, pass on the calculated HLG value for HLG content.
  • Warn user clearly if the screen connection is set to less than 10 bits with PQ+BT.2020.

Example usage for PQ on a non-PQ desktop: --d3d11-output-csp=pq --fs --fs-screen=N (the full screen stuff really isn't required since the compositor does seem to handle it nicely, but usually you want this).

Relevant example logs:

[vo/gpu/d3d11] Initializing SPIR-V compiler 'shaderc'
[vo/gpu/d3d11] Using Direct3D 11.1 runtime
[vo/gpu/d3d11] Maximum Texture2D size: 16384x16384
[vo/gpu/d3d11] D3DCompiler version: 10.0.18362.1
[vo/gpu/d3d11] Using DXGI 1.2+
[vo/gpu/d3d11] Queried output: \\.\DISPLAY1, 3840x2160 @ 8 bits, colorspace: 0
[vo/gpu/d3d11] Selected swapchain format 28, attempting to utilize it.
[vo/gpu/d3d11] Selected swapchain color space 12, attempting to utilize it.
[vo/gpu/d3d11] Swapchain capabilities for color space 12: normal: yes, overlay: no
[vo/gpu/d3d11] Swapchain successfully configured to color space 12!

Resolves #5237 , #5161

@jeeb jeeb changed the title WIP: Basic HDR support WIP: Basic HDR output support for Windows May 6, 2018
@Doofussy2
Copy link

This would be great to add. Especially now that HDR passthrough can be operated dynamically, when using an Nvidia GPU. Are there plans to further this?

@Doofussy2
Copy link

Doofussy2 commented Aug 12, 2019

I finally got around to using the test build. It works very well. The display switches to HDR10 when in full screen and reverts when windowed. I haven't experienced any issues, so far. Well done @jeeb.

One wrinkle. If I use --scale=ewa_lanczossharp, the picture is distorted. I have to add --scale=bilinear to my HDR auto profile to counteract it, then it plays correctly.

@Doofussy2
Copy link

Doofussy2 commented Sep 19, 2019

What this doesn't do is enable 10 bit, like @rossy has in his test build in this thread.. Is it possible to incorporate that?

[   0.611][v][vo/gpu] Reported display depth: 8
[   0.611][v][vo/gpu] Texture for plane 0: 3840x2160
[   0.612][v][vo/gpu] Texture for plane 1: 1920x1080
[   0.612][v][vo/gpu] Testing FBO format rgba16
[   0.612][d][vo/gpu] Resizing texture: 16x16
[   0.612][v][vo/gpu] Using FBO format rgba16.
[   0.614][v][vo/gpu] Resize: 3840x2160
[   0.614][v][vo/gpu] Window size: 3840x2160
[   0.614][v][vo/gpu] Video source: 3840x2160 (1:1)
[   0.614][v][vo/gpu] Video display: (0, 0) 3840x2160 -> (0, 0) 3840x2160
[   0.614][v][vo/gpu] Video scale: 1.000000/1.000000
[   0.614][v][vo/gpu] OSD borders: l=0 t=0 r=0 b=0
[   0.614][v][vo/gpu] Video borders: l=0 t=0 r=0 b=0
[   0.614][v][vo/gpu] Reported display depth: 8

jeeb mpv log.txt

[   4.607][v][vo/gpu] Reported display depth: 10
[   4.608][v][vo/gpu] Testing FBO format rgba16
[   4.608][d][vo/gpu] Resizing texture: 16x16
[   4.608][v][vo/gpu] Using FBO format rgba16.
[   4.609][v][vo/gpu] Resize: 3656x2057
[   4.609][v][vo/gpu] Window size: 3656x2057
[   4.610][v][vo/gpu] Video source: 3840x2160 (1:1)
[   4.610][v][vo/gpu] Video display: (0, 0) 3840x2160 -> (0, 0) 3656x2057
[   4.610][v][vo/gpu] Video scale: 0.952083/0.952315
[   4.610][v][vo/gpu] OSD borders: l=0 t=0 r=0 b=0
[   4.610][v][vo/gpu] Video borders: l=0 t=0 r=0 b=0
[   4.610][v][vo/gpu] Reported display depth: 10
[   4.610][d][vo/gpu] Resizing texture: 3840x2160

The full log is too big to attach

This is needed for SDR 10 bit.

@ghost
Copy link

ghost commented Sep 23, 2019

@jeeb Maybe merge what you have, since our last change was over a year ago, and the TODO on the top is full of harder things on top of it (like passing through the video HDR info). Or just close it as abandoned if that's the case.

@jeeb jeeb force-pushed the der_hdr_crapola branch from 280efe1 to 8527be3 Compare October 1, 2019 16:49
@jeeb jeeb force-pushed the der_hdr_crapola branch 4 times, most recently from 3deed70 to 8d9c921 Compare October 12, 2019 20:51
@jeeb
Copy link
Member Author

jeeb commented Oct 12, 2019

Just pushed the stuff updated to my current state. Will rebase and make it prettier tomorrow. :)

At this point, it's looking pretty good. The ra_fbo warning message is just in a place that will spam warnings. A lot. So that most likely needs a tweak.

@jeeb jeeb force-pushed the der_hdr_crapola branch 2 times, most recently from 2fd0322 to f319552 Compare October 13, 2019 14:26
@jeeb
Copy link
Member Author

jeeb commented Oct 13, 2019

The spam has now been fixed and it warns you once:

[vo/gpu] One or more colorspace value is being overridden by user while the FBO provides colorspace information: transfer function: (dst: hlg, fbo: pq), primaries: (dst: bt.2020, fbo: bt.2020). Rendering can lead to incorrect results!

@jeeb jeeb changed the title WIP: Basic HDR output support for Windows vo_gpu/d3d11: add support for configuring swap chain color space Oct 13, 2019
@jeeb jeeb requested a review from rossy October 13, 2019 14:41
@jeeb jeeb force-pushed the der_hdr_crapola branch 3 times, most recently from 0ba2ad5 to 9805b0a Compare October 13, 2019 21:16
@Doofussy2
Copy link

I'm eagerly awaiting this. Hopefully it gets rolled into the next master.

@jeeb jeeb force-pushed the der_hdr_crapola branch 2 times, most recently from 451905d to bcb8f0a Compare October 20, 2019 21:03
Copy link
Member

@rossy rossy left a comment

Choose a reason for hiding this comment

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

I don't know about colour stuff, but I'm worried this might change the default behaviour for Windows 10 users who don't use HDR/Windows HD Color. Even though Windows specifies the colourspace of each monitor, RGB_FULL_G22_NONE_P709 is likely the value it uses when it doesn't really know, since there's no "unknown" value in the enum. As I understand, this will make pass_colormanage use 2.2 gamma instead of just copying the source gamma, which is what the old "auto" behaviour did. Since the old "auto" behaviour was there for a reason (to match user expectations?) I wonder if we should change it.

Apart from that, this looks good.

jeeb added 2 commits October 28, 2019 23:57
This lets us set primaries, transfer function and the target peak
based on what the presenting layer would want us to have.

Now that this mechanism is available, warn if the user has
overridden values such as primaries or transfer function.
Additionally, define the few enum values that are currently missing
in mingw-w64 headers.
@jeeb jeeb force-pushed the der_hdr_crapola branch 2 times, most recently from e0a14e8 to 61830be Compare October 28, 2019 22:57
Copy link
Member

@rossy rossy left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for the changes.

By default utilizes the color space of the desktop on which the
swap chain is located. If a specific value is defined, it will be
instead be utilized.

Enables configuration of the PQ color space (BT.2020 primaries,
PQ transfer function) for HDR.

Additionally, signals the swap chain color space to the renderer,
so that the render looks correct without having to specify
target-trc or target-prim manually.

Due to all of the APIs being Win10+ only, will only work starting
with Windows 10.
@jeeb jeeb merged commit fc29620 into mpv-player:master Oct 30, 2019
@jeeb jeeb deleted the der_hdr_crapola branch October 30, 2019 00:41
@hooke007 hooke007 mentioned this pull request Sep 6, 2021
@Obegg
Copy link

Obegg commented Sep 7, 2021

If I may ask - when will MPV support HDR Passthrough?
Asking this because MPC-HC with MadVR already supports it,
also asking because the last update on this issue was on 2019

@Doofussy2
Copy link

Doofussy2 commented Sep 7, 2021

If I may ask - when will MPV support HDR Passthrough?

@ObsessedHacker It already does.

@Obegg
Copy link

Obegg commented Sep 7, 2021

If I may ask - when will MPV support HDR Passthrough?

@ObsessedHacker It already does.

Already does?
Um... Let me ask you this - when you play HDR video, does your monitor/TV automatically switches to HDR?
Because on my Windows 10 PC it doesn't, so if it does so on your PC, I would like to copy your settings, please.

@Doofussy2
Copy link

If I may ask - when will MPV support HDR Passthrough?

@ObsessedHacker It already does.

Already does?
Um... Let me ask you this - when you play HDR video, does your monitor/TV automatically switches to HDR?
Because on my Windows 10 PC it doesn't, so if it does so on your PC, I would like to copy your settings, please.

Microsoft has pretty much killed off the 'auto switching'. No, MadVR does not auto switch. It's a workaround that toggles the Windows HDR enable/disable prior to playing. And it's crap. Just turn HDR on, and enjoy.

@Obegg
Copy link

Obegg commented Sep 7, 2021

If I may ask - when will MPV support HDR Passthrough?

@ObsessedHacker It already does.

Already does?
Um... Let me ask you this - when you play HDR video, does your monitor/TV automatically switches to HDR?
Because on my Windows 10 PC it doesn't, so if it does so on your PC, I would like to copy your settings, please.

Microsoft has pretty much killed off the 'auto switching'. No, MadVR does not auto switch. It's a workaround that toggles the Windows HDR enable/disable prior to playing. And it's crap. Just turn HDR on, and enjoy.

Uh, I understand. Thank you!
A bit unrelated - Can you post your HDR config for me? I can't quite figure out the perfect settings, some blacks look grey and in general, colors are inaccurate for me.

@Doofussy2
Copy link

A bit unrelated - Can you post your HDR config for me? I can't quite figure out the perfect settings, some blacks look grey and in general, colors are inaccurate for me.

Sure, but first what GPU are you using?

@Obegg
Copy link

Obegg commented Sep 7, 2021

A bit unrelated - Can you post your HDR config for me? I can't quite figure out the perfect settings, some blacks look grey and in general, colors are inaccurate for me.

Sure, but first what GPU are you using?

GTX 1650

@Doofussy2
Copy link

Ok, so first I recommend configuring your GPU in the Nvidia control panel, to 4:2:0 12bpc (4:2:2 if your display supports it).

Then you can use an mpv.conf like this

target-trc=pq
target-prim=bt.2020
hwdec=auto
opengl-pbo=yes
dither-depth=12

I find that Windows lowers the gamma a little, so if you want to you can raise it a little by adding gamma=5

@Obegg
Copy link

Obegg commented Sep 7, 2021

Ok, so first I recommend configuring your GPU in the Nvidia control panel, to 4:2:0 12bpc (4:2:2 if your display supports it).

Then you can use an mpv.conf like this

target-trc=pq
target-prim=bt.2020
hwdec=auto
opengl-pbo=yes
dither-depth=12

I find that Windows lowers the gamma a little, so if you want to you can raise it a little by adding gamma=5

Thank you! I found it fixed the problem I had.
This is now my config, if you have any comments tell me:

deinterlace=no
vo=gpu
hwdec=auto
framedrop=vo
gpu-api=auto
d3d11-exclusive-fs=yes
d3d11-output-format=rgb10_a2
fbo-format=rgba16hf
video-sync=display-resample
blend-subtitles=no
scaler-resizes-only
scale=ewa_lanczossharp
cscale=ewa_lanczossharp
dscale=ewa_lanczossharp
tscale=lanczos
scale-antiring=0.0
cscale-antiring=0.0
dscale-antiring=0.0
tscale-antiring=0.0
dither=error-diffusion
error-diffusion=sierra-lite
dither-depth=12
correct-downscaling
linear-downscaling=no
deband=no
hdr-compute-peak=no
target-trc=pq
target-prim=bt.2020
gamut-clipping=no
opengl-pbo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

native 10 bit output for MS Windows 10 1709 and above (or possibly Windows 7 and above)

5 participants