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

Solving the depth buffer swizzle issue #15885

Open
hrydgard opened this issue Aug 22, 2022 · 2 comments
Open

Solving the depth buffer swizzle issue #15885

hrydgard opened this issue Aug 22, 2022 · 2 comments
Milestone

Comments

@hrydgard
Copy link
Owner

here's just some note to self about removing that annoying compat flag I had to add in the solution to #6105 .

Here's the process in Kuroyou:

Drawing the background to 0000000/0044000 (alternating)
Drawing the depth buffer using RGB565 to 88000 (in four strips)
Texturing from 288000 in 565 format, drawing to 116400 (in four strips). This is black.
Texturing from 116400 in 565 format, drawing to 88000 (same addr is bound as depth buffer, should be ignored).
Finally, drawing the scene to 0000000/0044000, with depth buffer at 88000.
Next, texturing from 00000/44000 in 5551 format, while drawing to CC000. Alpha testing seems to be going on to isolate the chracters?
Then texturing from CC000 (5551) while drawing to 44000, multiple times.
Then texturing with CLUT16 from 88000 (which should now have the real depth buffer) drawing to cc000, then the rest is various bloom nonsense.

The key here I think is "Texturing from 288000 in 565 format". If deswizzle bits are set in the address while texturing from something we know is written in 565 format, effectively that's the same as applying the depth swizzle (since it appears to be reversible). So in that step, we should intervene and swizzle the reads. Then, we can always swizzle when converting color into depth as required by Ratchet And Clank, and we should get the correct result in both games without the flag.

@hrydgard hrydgard added this to the v1.14.0 milestone Aug 22, 2022
@hrydgard
Copy link
Owner Author

Swizzling the color buffer on read could be done in a process similar to depal. There's been previous thoughts of depal just being a special case of dynamically applying a shader to a texture before use, with the TextureShaderApplier and all for example, and we already have a case of that with depth-to-565. So this would be a 565-to-swizzled-565 "depal" shader...

@hrydgard
Copy link
Owner Author

More info about the swizzle here: #15898 (comment)

@hrydgard hrydgard modified the milestones: v1.14.0, Future-Prio Sep 18, 2022
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

No branches or pull requests

1 participant