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

Vulkan: Make scaling shaders compatible + fixes #1392

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

goeiecool9999
Copy link
Collaborator

@goeiecool9999 goeiecool9999 commented Oct 25, 2024

Make built-in scaling shaders compatible with vulkan and incorporate the fixes from #879

Changes for graphic pack developers

  • Cemu now prepends a preamble containing all the uniforms so you can just write the shader parts 😄
  • preamble uses GLSL version 430
  • textureSrcResolution is now the actual resolution of the textureSrc sampler.
  • inputResolution has been replaced by nativeResolution and gives the resolution that the game would render at without graphic pack overrides.

Full preamble (as of writing) for reference

return R"(#version 430
#ifdef VULKAN
layout(push_constant) uniform pc {
vec2 textureSrcResolution;
vec2 nativeResolution;
vec2 outputResolution;
};
#else
uniform vec2 textureSrcResolution;
uniform vec2 nativeResolution;
uniform vec2 outputResolution;
#endif
layout(location = 0) in vec2 passUV;
layout(binding = 0) uniform sampler2D textureSrc;
layout(location = 0) out vec4 colorOut0;

@goeiecool9999 goeiecool9999 marked this pull request as draft October 25, 2024 01:14
this makes the shader consistent with hermite and fixes the wrong offset
makes the shader look a lot better and less pixelated
Undoes previous change where it would always use linear, like OpenGL does for DrawBackBuffer.
This allows GetDefaultTextureSampler to remain somewhat generic, even though it's only used for DrawBackBufferQuad right now.
- Make textureSrcResolution the actual resolution of the textureSrc sampler image
  This reflects the expectations of graphic pack creators
- Rename inputResolution to nativeResolution which is the non-overriden size
  Not sure if this is useful, but it's there already so let's not remove it.
- Change SetUniformParameters to use lambda expression
@goeiecool9999 goeiecool9999 changed the title Vulkan: Wire up bicubic and hermite scaling shaders Vulkan: Make scaling shaders compatible + fixes Oct 30, 2024
@goeiecool9999 goeiecool9999 marked this pull request as ready for review October 30, 2024 23:24
@Ammar-Sadaoui
Copy link

Ammar-Sadaoui commented Oct 30, 2024

do you have plan to support spir-v directly ?

@Exzap
Copy link
Member

Exzap commented Nov 12, 2024

After merging this some users might be confused about why their image quality suddenly changed. So I wonder if we should force-reset to bilinear as part of this PR? It would unfortunately also reset the scaling options on OpenGL but that might be the lesser evil.

@goeiecool9999
Copy link
Collaborator Author

some users might be confused about why their image quality suddenly changed

Considering people already convinced themselves that hermite looks better than bilinear when it wasn't even implemented I don't think it's that big of a deal. You have to really pixel peep to tell the difference. I think it would probably be equally or slightly more confusing if a user remembered their settings and saw that they changed on their own.
If you do want to force bilinear after updating how would we go about that? Does Cemu have a mechanism to detect the first launch after updating?

@Exzap
Copy link
Member

Exzap commented Nov 13, 2024

Did some more comparisons and yeah it's probably fine. Hermite starts looking bad for really large upscale factors, but thats beyond what anyone would reasonably run into.

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

Successfully merging this pull request may close these issues.

3 participants