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

HDR broken on AMD using vulkan #13534

Open
Silver-Fullbuster opened this issue Feb 23, 2024 · 7 comments
Open

HDR broken on AMD using vulkan #13534

Silver-Fullbuster opened this issue Feb 23, 2024 · 7 comments
Labels

Comments

@Silver-Fullbuster
Copy link
Contributor

Silver-Fullbuster commented Feb 23, 2024

Important Information

Provide following Information:

  • mpv version
mpv v0.37.0-337-gbd5b80ba Copyright © 2000-2024 mpv/MPlayer/mplayer2 projects
 built on Feb 18 2024 00:09:08
libplacebo version: v6.338.0-77-g3ba18d5-dirty
FFmpeg version: N-113670-g0895ef0d6
FFmpeg library versions:
   libavutil       58.39.100
   libavcodec      60.39.101
   libavformat     60.21.100
   libswscale      7.6.100
   libavfilter     9.17.100
   libswresample   4.13.100
  • Windows Version - Windows 11 23H2 (OS Build 22631.3155)
  • Source of the mpv binary - Shinchiro weekly builds
  • GPU model, driver and version - AMD RX 7800 XT, WHQL driver 24.1.1 (dxdiag shows driver version as 31.0.24002.92)

Reproduction steps

  1. Use any reference HDR video, say test.webm from a youtube HDR video
  2. mpv --no-config --vo=gpu-next --gpu-api=d3d11 --target-colorspace-hint test.webm (works after going fullscreen)
  3. mpv --no-config --vo=gpu-next --gpu-api=vulkan --target-colorspace-hint test.webm (no HDR here)

Expected behavior

Monitor switches into HDR and video plays with HDR

Actual behavior

mpv starts tonemapping the video instead, on vulkan

Log file

broken.txt
works.txt

@Andarwinux
Copy link
Contributor

[   0.080][v][vo/gpu-next/libplacebo] Available surface configurations:
[   0.080][v][vo/gpu-next/libplacebo]     0: VK_FORMAT_R8G8B8A8_UNORM                 VK_COLOR_SPACE_SRGB_NONLINEAR_KHR
[   0.080][v][vo/gpu-next/libplacebo]     1: VK_FORMAT_B8G8R8A8_UNORM                 VK_COLOR_SPACE_SRGB_NONLINEAR_KHR
[   0.080][v][vo/gpu-next/libplacebo]     2: VK_FORMAT_R8G8B8A8_SRGB                  VK_COLOR_SPACE_SRGB_NONLINEAR_KHR
[   0.080][v][vo/gpu-next/libplacebo]     3: VK_FORMAT_B8G8R8A8_SRGB                  VK_COLOR_SPACE_SRGB_NONLINEAR_KHR
[   0.080][v][vo/gpu-next/libplacebo] Picked surface configuration 0: VK_FORMAT_R8G8B8A8_UNORM + VK_COLOR_SPACE_SRGB_NONLINEAR_KHR

Your log indicates that the driver does not expose any HDR10_ST2084_EXT colorspace surfaces. So it's not a mpv problem.

The possible reason is that you don't have monitor directly connected to dGPU, for CASO, Intel AMD NV Vulkan driver don't support HDR at all, but Direct3D driver doesn't have this problem. The only solution is to use the DXGI swapchain instead of Vulkan WSI, ref #12539. You should stick to d3d11, nowadays winvk and vulkan hwdec don't work well on Windows.

@Silver-Fullbuster
Copy link
Contributor Author

Silver-Fullbuster commented Feb 23, 2024

Okay, my monitor is directly connected to the dGPU but it sounds like a driver issue (?). I've tried using the same monitor through my laptop and with its Nvidia dGPU, vulkan works fine with HDR.

I'm sticking with d3d11 currently, if it's indeed a driver/AMD problem then I don't mind having this issue closed.

@Silver-Fullbuster
Copy link
Contributor Author

Silver-Fullbuster commented Feb 23, 2024

Adding some additional investigation results:

Upon turning on Windows HDR, HDR on vulkan works, but it sometimes doesn't take over the HDR colorspace rendering(?):

Reproduction Steps

  1. Turn on Windows HDR
  2. mpv --no-config --vo=gpu-next --gpu-api=vulkan --target-colorspace-hint test.webm
  3. Fullscreen, otherwise colors are weird

Log file: working_run_logs.txt
Log file: failed_hdr_takeover_run.txt

Going fullscreen is flaky, sometimes the HDR colorspace applies properly, sometimes everything's way too dark. I tested it with a test pattern video and I think it sometime gives up on using an HDR colorspace and keeps tonemapping everything back to SDR.

Also, no matter HDR or not, toggling fullscreen often causes a crash with vulkan. I don't see any errors in the logs, probably due to some internal crash + it's unrelated to this issue so I'll try to recreate the crash with gdb attached later and create a separate issue for that

EDIT: Disabling all overlays does indeed apply HDR correctly

@Andarwinux
Copy link
Contributor

Logs don't seem to be abnormal, mpv selected VK_FORMAT_A2B10G10R10_UNORM_PACK32 + VK_COLOR_SPACE_HDR10_ST2084_EXT. Flaky HDR brightness could be normal, HDR metadata is only sent to monitor if it's full screen and the OSD isn't visible, otherwise it'll use default metadata.

I'll try to recreate the crash with gdb attached later and create a separate issue for that

Shinchiro builds have been changed to distribute pdb debugging symbols so can't use gdb. You need to install Windbg from MS Store to debug mpv.

@kasper93
Copy link
Contributor

I'll try to recreate the crash with gdb attached later and create a separate issue for that

You can just share the crash dump from %LOCALAPPDATA%\CrashDumps and related mpv build. It is enough to diagnose the issue.

@Silver-Fullbuster
Copy link
Contributor Author

Silver-Fullbuster commented Feb 23, 2024

While creating the issue for the crash, I found out that mpv doesn't crash with RivaTunerStatistics OSD disabled. RTS OSD hooks into GPU-rendered apps and it shows some system information as a permanent overlay, and it somehow interfered with mpv when mpv tries to go Fullscreen.

tl;dr: mpv seems fine on that end. Probably a 3rd-party overlay bug

If someone is interested in the dmp files anyway, here they are:
mpv.exe.crash_on_rts_overlay_fullscreen_toggle_dumps.zip

EDIT: and it only crashes on gpu-api=vulkan, gpu-api=d3d11 has no issues with the overlay

EDIT 2: And disabling the RTS OSD also makes HDR apply properly much less flakier on vulkan,

@lextra2
Copy link

lextra2 commented Apr 4, 2024

#13780 (comment)

Also, turn off RTSS

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

No branches or pull requests

4 participants