Aleksoid1978 / VideoRenderer

Внешний видео-рендерер
GNU General Public License v3.0
983 stars 108 forks source link

Add Support for RTX Video HDR #128

Closed JTGaming closed 4 months ago

JTGaming commented 5 months ago

Just the RTX Video HDR support in this one, as requested by: https://github.com/Aleksoid1978/VideoRenderer/pull/127#issuecomment-1933284863

NOTE: this only touches anything that's needed for RTX Video HDR, therefore it does not include the fixes from the previous PR such as: Better Super Resolution validity checks and better support for HDR screens; using Super Resolution above 1080p; allowing the use of custom scalers when Super Resolution is not active; allowing Super Resolution for HDR videos when viewed in SDR (https://github.com/Aleksoid1978/VideoRenderer/commit/6e7d3d9f6cf7000da6151d0c854a4fdde9180671) Support different aspect ratios for Super Resolution (https://github.com/Aleksoid1978/VideoRenderer/commit/088aca8d18c7925bb84d1e1e4db69732783551a1) Option to disable Super Resolution if window is the same size as the video, issue here https://github.com/Aleksoid1978/VideoRenderer/issues/126 (https://github.com/Aleksoid1978/VideoRenderer/commit/dd46fafd65c82786780e37226cd696c07ee99d3b) Disabling passthrough does not reset the window to SDR (https://github.com/Aleksoid1978/VideoRenderer/commit/8bb15a64bd459ffb7b9ad292384ceea4813ab269) (https://github.com/Aleksoid1978/VideoRenderer/commit/9edf103113b6ad4e24db5c1f690dd11749a9d4c0) Toggling between fullscreen and windowed in certain scenarios makes the renderer think we are on a different monitor (https://github.com/Aleksoid1978/VideoRenderer/commit/7dfd9989e31e801f275f6b2a7bc681f6adbb09ac)

Aleksoid1978 commented 5 months ago

Strange. I downloaded the patch to check locally, the patch does not apply:

git apply 128.patch error: patch failed: Source/DX11VideoProcessor.cpp:1755 error: Source/DX11VideoProcessor.cpp: patch does not apply

JTGaming commented 5 months ago

This one should work: 0001-Add-Support-for-RTX-Video-HDR.patch

Or if you want to fix it yourself: change line 202 start from "-1755,7 +1788,20" to "-1755,8 +1788,21" remove line 218 add at line 219 " auto superRes = (m_bVPScaling && !(m_bHdrPassthroughSupport && m_bHdrPassthrough && SourceIsHDR())) ? m_iVPSuperRes : SUPERRES_Disable; m_bVPUseSuperRes = (m_D3D11VP.SetSuperRes(superRes) == S_OK);"

or, git apply --reject [bad_patch], and then check the .rej files.

There was an issue with my first commit overlapping and editing the same parts of code as you did, which i solved in a second commit, but I'm not too familiar with patches to know why they were having trouble with that.

clsid2 commented 5 months ago

Here is another implementation that you can use for comparison: https://github.com/emoose/VideoRenderer/commits/rtx-hdr/

If SetRTXVideoHDR() fails and !SourceIsHDR() then re-init is needed to disable HDR output.

RTX HDR requires 10bit texture (maybe also works with 16?). So if user has selected 8bit texture, it should disable the option.

User tests in emoose fork has shown that it only work properly with NV12/P010/YUY2 input. So extra checks based on input mediatype are possible.

JTGaming commented 5 months ago

RTX HDR should only be used when passthrough option is enabled?

Personal preference I guess, but to me that's more of a setting for native hdr videos. I prefer not to have nested settings and checkboxes that depend on checkboxes.

If SetRTXVideoHDR() fails and !SourceIsHDR() then re-init is needed to disable HDR output.

There's a check for if this feature is supported, so it realistically shouldn't fail unless something catastrophic happens like a driver crash. But sure, that could be added, though I couldn't figure out a way myself.

RTX HDR requires 10bit texture (maybe also works with 16?). So if user has selected 8bit texture, it should disable the option.

It works in 16bit, and there's a fix if the user has seleted the 'auto 8/10bit' mode. Good idea to disable it if user manually chose to use 8bit though, didn't think of that one.

User tests in emoose fork has shown that it only work properly with NV12/P010/YUY2 input. So extra checks based on input mediatype are possible.

Does anyone have any snippets of files to share which seem to not work? I've read about the whole 'interlaced 10bit files cause massive ram usage', p010 causing high ram usage, etc, but couldn't get any of that to happen on my end, though i do have a more standard '8bit avc, 10bit hevc, some av1' library.

clsid2 commented 5 months ago

Here is commit for the re-init upon failure from the other fork: https://github.com/emoose/VideoRenderer/commit/0194d76f549ae83d4bef02daa4cf1d246b11cbbd And there were real-life situations during testing of the fork where this was really needed. The extension availability check probably isn't very restrictive. All the extra checks such as input colorspaces mentioned below should reduce amount of situations where it fails.

If I remember correctly, the high ram usage bug was fixed in the driver long ago. Initially VSR did not support 10bit.

I would not be surprised if interlaced content is not supported properly. So I would advice to just exclude that.

Here is link to discussion about support input formats: https://github.com/emoose/VideoRenderer/issues/24#issuecomment-1914696808

JTGaming commented 5 months ago

Yeah, that's what I thought it would be - just a blank force-disable. Not a very elegant solution, but since you said it came in use many times, I've added that. I've just tried some interlaced clips, and both Super Resolution and RTX Video HDR seemed to work perfectly fine, so I don't think it's the interlacing alone that causes issues. As for the filtering by formats - I'm not sure if it's an implementation difference or what, but whenever I use a format other that the ones that my gpu supports, which are handily printed in the debug output as "...AYUV, NV12, P010, YUY2...", the videoprocessor switches to using shaders, and InitializeD3D11VP() doesn't get past the InitVideoProcessor() line, thus not even calling Super Resolution nor RTX Video HDR, so there's no blown-out bugs. No filters needed!

Aleksoid1978 commented 5 months ago

RTX HDR not working on P010, in Nvidia panel status - inactive.

Aleksoid1978 commented 4 months ago

I made my own implementation of this functionality.