-
Notifications
You must be signed in to change notification settings - Fork 500
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
[RFC] A port of generation scripts from the mpv-prescalers project #803
Conversation
git-subtree-dir: tools/ravu git-subtree-split: d5d4300948cb98a6803b9c4731c7f1ee60821446
Thank you for your excellent work! To be honest, reviewing this PR is beyond my ability, and I think it would be better to make it a separate project (i.e., a fork of mpv-prescalers), and then contribute the generated effect files to this repository. Please note that the ongoing #643 will change the shader syntax again. #516 is a bug that existed in the original version of RAVU, caused by insufficient sampling area of the original texture. It's very complex to implement effects that support arbitrary scaling factors with compute shaders. |
Considering that this PR is very complex, the review will take a long time, but I am busy implementing #643. If you insist on contributing to this repository, please be patient, and I will come back after 1.0 is released, including adapting to the new syntax and fixing bugs. |
It may indeed be much easier to review and maintain changes to generation scripts in a separate repository as a fork of mpv-prescalers. Generated shaders for Magpie are in the I'll mark this pull request as a draft as this feels more appropriate in this case. Do you have any preferences in how I should format pull requests for generated effects (single commit, separate commits, separate pull requests)? I'll take a look at #643 and will make necessary changes. I'm fine with deferring this to after that gets merged. If you have any requests for other changes I should make to generation scripts to make generated effects more fit to inclusion, I'll happily consider implementing them. I'll investigate the bug in the original RAVU-Zoom further and will try contacting upstream about it. |
Please open a new pull request and copy the generated effect files to the RAVU and NNEDI3 folders. I noticed that the generated effect files are all under LGPL. Is it possible to re-license them as GPL, just like the other effects in Magpie? |
I have switched license of generated shaders to GPL3+ as relicensing from LGPL3+ to GPL3+ is allowed according to the GPL Compatibility Matrix. I'll submit separate pull requests for both v3 and v4 generated shaders. |
Awesome! Let's switch over to the new PRs, I think this one can be closed. |
Sure. |
Could you verify that setting the coefficient to 0.49999 fixes the issue? If so, it can be confirmed as a float rounding issue. AFAICT, it's very difficult to trigger such floating rounding issue. First, it has to be perfect odd integer scaling as a starter, such as 1x or 3x upscaling, to have texel centers somehow matches before and after ravu-zoom. And considering group size is set to Second, the shader compiler has to do some kind of optimization so that the following two statements was handled differently for the same
This is just a quick look so I might made some mistakes. @hauuau Could you confirm that:
|
Setting coefficient in the
Magpie allows applying ravu-zoom and other arbitrary scaling shaders on 1x scaling but 1x doesn't seem to trigger this issue for me. For me it's usually triggered with 3x scaling (1280x720 → 3840x2160). The issue manifests itself either as random noise on a grid of block size or at least with 32x8 block size it's more often a horizontal 1px line of random noise 8px from the top of the screen.
I'm not on NVidia hardware so HLSL has |
@hauuau I tried 3x upscaling with mpv ravu-zoom just now, and somehow I'm still unable to reproduce. Guess it highly depends on shader compiler then. Anyway, thanks for your tests. Able to verify that it's a float rounding issue is great. |
@bjin Should lowering coefficient in the |
Yes, |
@bjin |
While I couldn't reproduce this issue using mpv, it has been observed in the HLSL port of RAVU-Zoom for Magpie. Instead of digging and trying to figure out how different shader compilers handle floats differently, it's always easier just to stay on the safe side. Thanks to @hauuau for report and testing work. ref: Blinue/Magpie#803
While I couldn't reproduce this issue using mpv, it has been observed in the HLSL port of RAVU-Zoom for Magpie. Instead of digging and trying to figure out how different shader compilers handle floats differently, it's always easier just to stay on the safe side. Thanks to @hauuau for report and testing work. ref: Blinue/Magpie#803
I can reliably reproduce this error at odd integer scaling (1x, 3x, 5x, etc.), where the calculation result of |
I was debugging some other issue, but found interesting insight how (gather) sampling location is computed. [1] In short, sampling location is converted to at least 16.8 fixed point and while in this case it is gather specific, the same apply to linear scaling [2]. There is also in [1] interlude about nearest filtering. And sure with linear filtering it shouldn't cause a problem, but I found it interesting detail which can produce strange results, in specific cases. So I felt like sharing it also here, if anything as a curiosity. Maybe for GPU experts this is obvious knowledge, but for me it was interesting :) [1] https://www.reedbeta.com/blog/texture-gathers-and-coordinate-precision/
|
This is a port of scripts by @bjin which are used to generate shaders in the mpv-prescalers repository.
I'd like some comments about viability of this approach.
I tried to keep things as close to the upstream as reasonably possible to make it easier to backport potential upstream changes in the future.
Performance doesn't seem to be different from already included versions but I haven't conducted much performance testing. It seems it could be possible to get some performance gains from playing with the
--compute-shader-block-size
option though but they're probably hardware specific.I have tested generated shaders and they are functional. These include the new versions of RAVU-Zoom and RAVU-Lite with Anti-ringing built in. RGB versions are working too.
RAVU-Zoom generated by these scripts doesn't seem to suffer from the bug #554.
But I have unfortunately encountered something very similar to #516 during development and I'm utterly confused by it.
If I do something like
then the bug manifests itself.
But if I do something like
then the bug goes away for some reason.
That seems like some kind of compiler bug to me but I haven't investigated further.
That bug might be somehow related to either of these lines in RAVU-Zoom:
That's the line affected by difference in definition of HOOKED_size.
Or it might be this one:
As soon as I lower that 0.5 coefficient to something like 0.4 the bug goes away. Might it be a rounding bug? I wonder why the upstream doesn't seem to be affected by it.
It's my first experience dealing with both GLSL and HLSL so I bet there are some mistakes or pitfalls I have fallen into.