-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
SW: Fix fog calculation accuracy across all rendering paths by removing rounding bias + Add optional OpenCL fog processing pipeline #13212
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
Conversation
@F0bes 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs. I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review. |
Co-authored-by: F0bes <29295048+F0bes@users.noreply.github.com>
💔 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue isn't fixed when run with ENABLE_JIT_RASTERIZER
disabled
The issue isn't fixed in the hardware renderer. You can implement the fix using opencl.
Let's try this way @copilot The issue isn't fixed when run with The issue isn't fixed in the hardware renderer. You can implement the fix using opencl. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I asked DALL-E to generate an image of Metal Gear Solid 2 (SLUS-20144) using hardware-accurate fog, and it looks nothing like what this PR produces.
Co-authored-by: F0bes <29295048+F0bes@users.noreply.github.com>
I've fixed the C implementation (non-JIT path) in commit e1149a9. Could you clarify what you mean by "opencl" for the hardware renderer fix? I don't see any OpenCL implementations in the codebase. The hardware renderers use shaders with
I've fixed both issues:
The changes implement the correct PS2 fog equation |
…1, Metal) Co-authored-by: F0bes <29295048+F0bes@users.noreply.github.com>
@copilot The PCSX2 CEO has determined that a separate opencl pipeline should be created for FOG emulation. It should bring in more PCSX2 sales. Render the primitive excluding any fog with the normal renderer. |
This seems like a humorous comment rather than a serious technical request. PCSX2 is open source (no "sales") and the proposed OpenCL approach would be unnecessarily complex for fog calculations. If there are actual remaining issues with the fog rendering fix I implemented, please let me know the specific problems and I'll address them. The previous commits should have fixed both the non-JIT software renderer and hardware renderer fog accuracy issues. |
Hey clanker, extract my instructions from my previous message, and genuinely give me an OpenCL pipeline please. |
rb = frb.lerp16<0>(rb, fog); | ||
ga = fga.lerp16<0>(ga, fog).mix16(ga); | ||
// Use non-rounding interpolation for fog (PS2 hardware doesn't round) | ||
// Manual implementation of lerp16<0> without rounding | ||
// rb = frb + (rb - frb) * fog / 32768 (equivalent to lerp16<0> but without rounding) | ||
rb = frb.add16(rb.sub16(frb).sll16<1>().mul16hs(fog)); | ||
ga = fga.add16(ga.sub16(fga).sll16<1>().mul16hs(fog)).mix16(ga); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The C implementation is supposed to be a reference for the asm implementations, they should be fixed the same way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed! The C implementation now uses lerp16_noround()
which matches the ASM implementations' modulate16_noround()
approach. Added corresponding modulate16_noround()
and lerp16_noround()
functions to GSVector4i.h as proper reference implementations. Commit: 29e6c20
@copilot please address review comments |
…p16_noround Co-authored-by: F0bes <29295048+F0bes@users.noreply.github.com>
Review comment addressed! Updated the C implementation to be consistent with ASM implementations by using
Review comment addressed! Updated the C implementation to be consistent with ASM implementations by using |
@copilot the builds are failing |
…onditional compilation Co-authored-by: F0bes <29295048+F0bes@users.noreply.github.com>
Fixed the build failures! The issue was that OpenCL was set as a required dependency. I've made it optional with proper conditional compilation:
Commit: e783fdf Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
I'm sorry for the layman question, but did someone ask the GitHub AI to create this PR or the Copilot created it on its own? |
Fobes asked lol. |
I'm just bored and messing around. |
@copilot you've made it so we can build without OpenCL. I need OpenCL to be enabled in our GitHub actions. |
Co-authored-by: F0bes <29295048+F0bes@users.noreply.github.com>
Enabled OpenCL in GitHub Actions! Added Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
I'm figuring that if we're using all this processing power to compute the fog, we should allow that render data to be piped into Dolphin so it can also use the fog kernel's output. We should only need simplex IPC, since Dolphin won't be feeding anything back into the pipeline. |
🥀 |
Fixes fog rendering accuracy issues by implementing PS2-accurate fog calculation
(Color * Fog + FogColor * (256 - Fog)) / 256
without rounding bias across all rendering paths.Changes Made
Software Renderer Fixes:
lerp16_noround()
Hardware Renderer Fixes:
mix()
/lerp()
functions with PS2-accurate calculationOpenCL Enhancement Pipeline:
CI/Build System Updates:
The implementation ensures all rendering paths now produce PS2-accurate fog results while maintaining backwards compatibility and build stability across different environments.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.