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

Post-processing: Add integer scaling shader #10722

Merged
merged 1 commit into from Feb 4, 2023

Conversation

TryTwo
Copy link
Contributor

@TryTwo TryTwo commented Jun 6, 2022

Feature request: https://bugs.dolphin-emu.org/issues/12725

Integer Scaling scales based on xfb * IR and adds black bars on all sides if needed.

There is probably a way to have the shader downscale/upscale so it isn't locked, but I couldn't get it right and I think shader options are broken.

@Pokechu22
Copy link
Contributor

The shader itself looks OK quality-wise now, and seems to work fine ingame. It doesn't behave properly if the internal resolution is set high enough that the window needs to be shrunken, but I don't think that's something you need to handle currently.

For consistency with the other files, it should probably be named integer_scaling.glsl though. It also needs a newline at the end of the file (just press enter once so that the last line is a blank line).

@TryTwo
Copy link
Contributor Author

TryTwo commented Jun 6, 2022

Ok. maybe I'll take a little more time and work on it. Pretty sure I can do automatic downscaling to fit high IR in the window.

@iwubcode
Copy link
Contributor

iwubcode commented Jun 6, 2022

Let me know if you're missing any functionality to make this work as well as you'd like, I'm not wanting to bloat the post processing PR too much but I do want to account for various use cases.

@TryTwo
Copy link
Contributor Author

TryTwo commented Jun 6, 2022

I'm very surprised everything I'm wanting is already accessible. I think we're good for this subject.

Still improving on it.

@TryTwo
Copy link
Contributor Author

TryTwo commented Jun 6, 2022

I figured out how to do options. I didn't want to do too many, and I can't make UI option groups to show checking multiple boxes might be pointless. I can add more options depending on what people think. When the UI system gets reworked it'll get dropdown boxes and stuff.

@iwubcode
Copy link
Contributor

iwubcode commented Jun 9, 2022

The current implementation only does a downsample in the shader. Is that correct? We don't allow scaling of the post processing texture in master (it is supported in my post processing overhaul PR).

I have no idea if the integer logic is correct or even accurate.

I was hoping @phire would review this, as they commented on the original support ticket.

EDIT: also curious if there was any research on other implementations. For my post processing PR, I've been trying to prune our shader list. I really want to adopt shaders that are used in other emulators, reshade, etc and only create new ones if they are better or provide different features.

@TryTwo
Copy link
Contributor Author

TryTwo commented Jun 9, 2022

The current implementation only does a downsample in the shader. Is that correct?

It sets the dimensions to the xfb so the pixels are square, then it can be integer scaled up or down, so the result is square pixels as well. I don't think there is any reason to upscale, but it's just present in the simple logic.

If comparing the result to an xfb dump, they look exactly the same.

We don't allow scaling of the post processing texture in master (it is supported in my post processing overhaul PR).

I'm not sure about this, it seems scalable.

I have no idea if the integer logic is correct or even accurate.

The person who requested this said it does what is needed for his CRT.

EDIT: also curious if there was any research on other implementations. For my post processing PR, I've been trying to prune our shader list. I really want to adopt shaders that are used in other emulators, reshade, etc and only create new ones if they are better or provide different features.

I was just following the basic logic of integer scaling and the result appeared to turn out correctly, which fixed a CRT issue. I think most implementations are through render logic and not a shader, but our PP has the xfb as input and the window size as output, so it works. I felt like it's easier to put in all the requested features as a shader with a load of options.

So this provides a feature not typically added as a PP shader, but the output is the same as my integer scaling rendering PR #10720. It keeps getting requested as a feature on the boards.

@TryTwo TryTwo force-pushed the PR_Integer_Shader branch 2 times, most recently from 1c44b84 to f92322a Compare June 13, 2022 03:27
@TryTwo
Copy link
Contributor Author

TryTwo commented Jun 13, 2022

Cleaned up the options, This is everything I want in it, unless someone asks for more.

I also added a width scale slider for Virtual Console games that have a xfb with a very wide width vs height.

@TryTwo
Copy link
Contributor Author

TryTwo commented Jun 18, 2022

@iwubcode Actually calling it an integer scaler is slightly misleading. The IR setting does the integer upscaling. This shader just outputs the image without any stretching, which is otherwise not possible. It can do a simple integer downscale if needed though.

As a side note: It's rather simple to make a NN integer upscaling shader, but I don't think anyone needs it. For pixel-y games the IR seems to do pretty much that.

@AdmiralCurtiss AdmiralCurtiss merged commit 23b504a into dolphin-emu:master Feb 4, 2023
1 check failed
@TryTwo TryTwo deleted the PR_Integer_Shader branch February 5, 2023 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants