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

nv2a: add new NV_PGRAPH parameters, fix W_param tests, ZMinMaxControl tests, see through and missing shadows #1826

Closed
wants to merge 28 commits into from

Conversation

polymetal0
Copy link

@polymetal0 polymetal0 commented Dec 31, 2024

Happy new year everyone!

I was holding this PR until Vulkan rendering was ready. So here it is, for both Vulkan and OpenGL.

RECAP

  • Added NV_PGRAPH_CONTROL_3_TEXTURE_PERSPECTIVE_ENABLE and NV_PGRAPH_ZCOMPRESSOCCLUDE_CULL_NEAR_FAR_EN
  • Removed vtx_inv_w and vtx_inv_w_flat
  • Implement clipping and [-1, 1] clip volume change for ogl from frag shader
  • Added depth buffer shader variable to store w coordinate
  • Apply zbias to w buffer

Fixes/shows progress (captures taken in Vulkan, 2x)
W_param tests
https://github.com/abaire/nxdk_pgraph_tests_golden_results/tree/main/W_param
PR
w_gaps
xemu-2025-01-11-23-13-46
w_neg_strip
xemu-2025-01-11-23-13-50
w_pos_strip (fixed)
xemu-2025-01-11-23-14-04

ZMinMaxControl tests
https://github.com/abaire/nxdk_pgraph_tests_golden_results/tree/main/ZMinMaxControl
PR
Ctrl_NEARFAR_ZCLAMP
Ctrl_NEARFAR_ZCLAMP_IgnW
Ctrl_NEARFAR_ZCULL
Ctrl_NEARFAR_ZCULL_IgnW
Ctrl_WBuf_NEARFAR_ZCLAMP
Ctrl_WBuf_NEARFAR_ZCLAMP_IgnW
Ctrl_WBuf_NEARFAR_ZCULL
Ctrl_WBuf_NEARFAR_ZCULL_IgnW
Ctrl_WBuf_ZCLAMP
Ctrl_WBuf_ZCLAMP_IgnW
Ctrl_WBuf_ZCULL
Ctrl_WBuf_ZCULL_IgnW
Ctrl_ZCLAMP
Ctrl_ZCLAMP_IgnW
Ctrl_ZCULL
Ctrl_ZCULL_IgnW
CtrlFixed_NEARFAR_ZCLAMP
CtrlFixed_NEARFAR_ZCLAMP_IgnW
CtrlFixed_NEARFAR_ZCULL
CtrlFixed_NEARFAR_ZCULL_IgnW
CtrlFixed_WBuf_NEARFAR_ZCLAMP
CtrlFixed_WBuf_NEARFAR_ZCLAMP_IgnW
CtrlFixed_WBuf_NEARFAR_ZCULL
CtrlFixed_WBuf_NEARFAR_ZCULL_IgnW
CtrlFixed_WBuf_ZCLAMP
CtrlFixed_WBuf_ZCLAMP_IgnW
CtrlFixed_WBuf_ZCULL
CtrlFixed_WBuf_ZCULL_IgnW
CtrlFixed_ZCLAMP
CtrlFixed_ZCLAMP_IgnW
CtrlFixed_ZCULL
CtrlFixed_ZCULL_IgnW

Comments: clipping planes match HW behavior at 1x but are a bit off at higher scales. Near/far custom clipping planes do not entirely match HW behavior. OGL shows erratic behavior when running fixed function tests specifically, as shown here #1826 (comment)

Passing clipRange variable as a uniform and performing perspective divide in fragment shader for z_perspective = true solves the see through issue that affects many games.

Shader code for z_perspective = false is virtually unaltered.
@polymetal0 polymetal0 changed the title See through fix nv2a: perspective divide (see through fix) Dec 31, 2024
@polymetal0 polymetal0 changed the title nv2a: perspective divide (see through fix) nv2a: perspective divide in frag shader (see through fix) Dec 31, 2024
@mborgerson
Copy link
Member

Hi again. I think this is the 4th PR now opened for this. As much as I'd like to see Halo 2 and other games fixed, I still have yet to see the test cases that I've asked for that demonstrate this actually matches hardware behavior. Will you please create the test cases?

@polymetal0
Copy link
Author

Hi. Yes sure, I'm having a look at the nxdk but I need some guidance. How could I build a scene that replicates this unwanted see through effect? could someone give me some specs? With perspective enabled, I'd put two or more 3D objects in a way that one occludes the other(s), but I assume they'd have to be in a specific position and orientation.

Also, I wanted to test the titles in #1016 that are known to suffer from this @Triticum0

And finally, the latest release of nxdk_pgraph_tests has no .xiso image attached, and there's a ZMinMaxControl test that might be helpful for this PR that is not included in the previous release @abaire

@Fabxx
Copy link
Contributor

Fabxx commented Jan 3, 2025

Dunno if i've mentioned in previous issues but just in case, the pr does fix clipping but breaks shadows and lights in splinter cell.

@abaire
Copy link
Contributor

abaire commented Jan 3, 2025

And finally, the latest release of nxdk_pgraph_tests has no .xiso image attached, and there's a ZMinMaxControl test that might be helpful for this PR that is not included in the previous release @abaire

Thanks for the heads up, the workflow should be fixed now and the latest release has an iso artifact.

@polymetal0
Copy link
Author

Dunno if i've mentioned in previous issues but just in case, the pr does fix clipping but breaks shadows and lights in splinter cell.

How so? I haven't tried any Splinter Cell yet. Anyway, this pr is slightly different bc the code was reorganized when Vulkan was implemented. Try it if you like :)

@Triticum0
Copy link
Collaborator

some send my an app image forgot how to build from source.

@Fabxx
Copy link
Contributor

Fabxx commented Jan 3, 2025

Dunno if i've mentioned in previous issues but just in case, the pr does fix clipping but breaks shadows and lights in splinter cell.

How so? I haven't tried any Splinter Cell yet. Anyway, this pr is slightly different bc the code was reorganized when Vulkan was implemented. Try it if you like :)

there is like shadow/light clipping and you can see them behave like a vertex explosion. There might be still a depth conflict.

@Triticum0
Copy link
Collaborator

yeah think I got same issue on splinter cell as well thought comparing both images to xbox might be unrelated as seem dynamic light no even rendered on master build.

Xemu v8.2
xemu-2025-01-03-21-41-18

pr
xemu-2025-01-03-21-41-17

xbox
Screenshot_20250103_214906

Reference: https://www.youtube.com/watch?v=tA26hB0vbGk

@polymetal0
Copy link
Author

polymetal0 commented Jan 3, 2025

yeah think I got same issue on splinter cell as well thought comparing both images to xbox might be unrelated as seem dynamic light no even rendered on master build.

Xemu v8.2 xemu-2025-01-03-21-41-18

pr xemu-2025-01-03-21-41-17

xbox Screenshot_20250103_214906

Reference: https://www.youtube.com/watch?v=tA26hB0vbGk

Now that you mention it, this PR may also fix many of the missing shadows in #577, I could test it on Wallace & Gromit, Conker and Halo CE. It also fixes some clipping issues in Halo 2 cutscenes.

@Triticum0
Copy link
Collaborator

Triticum0 commented Jan 3, 2025

Done some more testing seems to have fixed most of the z-ordering issues. in most of game I tested.

007: Nightfire

Masters
xemu-2025-01-06-01-30-39

Pr
xemu-2025-01-06-01-30-38

Battlefield 2: Modern Combat
Masters
xemu-2025-01-06-01-26-59

Pr
xemu-2025-01-06-01-27-04

Breakdown

Masters
xemu-2025-01-03-21-11-50

Pr
xemu-2025-01-03-21-11-48

Catwoman
Masters
xemu-2025-01-03-21-06-50

Pr
xemu-2025-01-03-21-06-48

Far Cry Instincts
Masters
xemu-2025-01-03-21-16-28

Pr
xemu-2025-01-03-21-16-26

Juiced
Masters
xemu-2025-01-03-21-26-34

Pr
xemu-2025-01-03-21-26-33

Marvel Nemesis: Rise of the Imperfects
Masters
xemu-2025-01-03-22-29-12

Pr
xemu-2025-01-03-22-29-16

Midtown Madness 3 Fixeds the shadows as well
Masters
xemu-2025-01-03-21-37-40

Pr
xemu-2025-01-03-21-38-18

Project Gotham Racing Shadows are broken
Masters
xemu-2025-01-03-23-08-31

Pr
xemu-2025-01-03-23-10-09

Quantum Redshift
Masters
xemu-2025-01-03-21-59-54
Pr
xemu-2025-01-03-22-00-04

V-Rally 3
Masters
xemu-2025-01-03-21-56-10

Pr
xemu-2025-01-03-21-56-06

Games unaffected
007: From Russia with Love
Aggressive Inline
Beyond Good & Evil
Peter Jackson's King Kong: The Official Game of the Movie
Syberia
Terminator 3: The Redemption

Games Untested.
Knight's Apprentice: Memorick's Adventures AMD Only
Splinter Cell Pandora Tomorrow
Tom Clancy's Rainbow Six 3 Black Arrow
Tom Clancy's Rainbow Six 3
Tom Clancy's Ghost Recon: Advanced Warfighter
Games in #1020

will not test any more game on-till a test case has been written.

@polymetal0
Copy link
Author

polymetal0 commented Jan 4, 2025

yeah think I got same issue on splinter cell as well thought comparing both images to xbox might be unrelated as seem dynamic light no even rendered on master build.

Xemu v8.2 xemu-2025-01-03-21-41-18

pr xemu-2025-01-03-21-41-17

xbox Screenshot_20250103_214906

Reference: https://www.youtube.com/watch?v=tA26hB0vbGk

Edit: this one is trickier than expected, probably unrelated. It changes on different scales
3x
xemu-2025-01-04-02-07-18
1x
xemu-2025-01-04-02-37-15

@Triticum0
Copy link
Collaborator

Fixes robots, bionic ingame clipping and ice age 2

@BiatuAutMiahn
Copy link

BiatuAutMiahn commented Jan 7, 2025

Partially fixes Halo 2

master: 956ef0b
image

pr:
image

@BiatuAutMiahn
Copy link

BiatuAutMiahn commented Jan 7, 2025

Halo 2 CoOp
Vulkan X2
image

Vulkan X1
image

OGL X1
image

OGL X2
image

@BiatuAutMiahn
Copy link

Dynamic lights too? (Effect is at any scale)
xemu-2025-01-08-00-51-55
xemu-2025-01-08-00-51-38
xemu-2025-01-08-00-51-13
xemu-2025-01-08-00-37-11

@BiatuAutMiahn
Copy link

Vulkan and oGL, any scale:
xemu-2025-01-08-10-23-20

They are still there, but unused
- z_perspective refactor to PixelShader and texture_perspective var added
- vtx_inv_w and vtx_inv_w_flat vars totally removed
- Fixes warping of textures from previous commit w/o breaking tests
- Also fixes dashboard menu background regression
Copy link
Author

@polymetal0 polymetal0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@polymetal0
Copy link
Author

Fixed function tests work fine on Vulkan but seem erratic in OGL.

ogl.mp4

Notice how the same test works differently depending on the previous test I ran. This only happens in fixed function tests. Other than that, everything works the same in OGL and Vulkan.

@BiatuAutMiahn
Copy link

Don't suppose you'd be willing to drop another release build like previously?

@polymetal0
Copy link
Author

Don't suppose you'd be willing to drop another release build like previously?

Sure
xemu_pr1826.zip

@BiatuAutMiahn
Copy link

All these were tested/noted /w OGL. The lighting around fire is fixed, also with the doorway. Played a bit further, shots in reverse order. These issues may not be related specifically to this PR, but this PR certainly fixes a good deal /w Halo 2.

Cortana is too transparent.
image
Left Elite has clipping through Jaw Armor
image
Z fighting /w Phantoms and Carrier sprites.
image
Shadow on neck of Arbiter is clipping, and bloom is excessive.
image
No mipmapping on grating texture
image
Water is not rendered correctly
image
Water rendering intersects with level geometry
image

@polymetal0
Copy link
Author

polymetal0 commented Jan 27, 2025

All these were tested/noted /w OGL. The lighting around fire is fixed, also with the doorway. Played a bit further, shots in reverse order. These issues may not be related specifically to this PR, but this PR certainly fixes a good deal /w Halo 2.

Cortana is too transparent. image Left Elite has clipping through Jaw Armor image Z fighting /w Phantoms and Carrier sprites. image Shadow on neck of Arbiter is clipping, and bloom is excessive. image No mipmapping on grating texture image Water is not rendered correctly image Water rendering intersects with level geometry image

Thanks for your feedback, but you should check how it runs on OG HW first.
https://www.youtube.com/watch?v=O3CRPO_RkTs

The first three captures appear to match HW behavior.
The fourth and fifth ones are probably unrelated, since they show the same behavior in master.
The water issue is confirmedly unrelated.

@svensvond
Copy link

So whats the status up here if i might ask.
mborgerson wants the testcases fullfilled before merge is allowed. Is there a status?

@polymetal0
Copy link
Author

So whats the status up here if i might ask. mborgerson wants the testcases fullfilled before merge is allowed. Is there a status?

Sorry, I'll convert the PR to draft until I'm finished to avoid confusion. I noticed that some colors in the ZMinMaxControl tests were off, so I'm still making significant progress, although the end result will not be 100% HW accurate.

My next push will most likely be the last one, probably by the end of the day or of this week. I'll give you a heads up and reopen the PR for merge.

@polymetal0 polymetal0 marked this pull request as draft January 30, 2025 12:49
- Added depth buffer variable to shaders to store w coordinate
- They are there just to test behavior and most likely incorrect, but close enough to HW. It's a good starting point for future work
@polymetal0 polymetal0 changed the title nv2a: add NV_PGRAPH_CONTROL_3_TEXTURE_PERSPECTIVE_ENABLE, fix W_param tests, ZMinMaxControl tests and see through nv2a: add new NV_PGRAPH parameters, fix W_param tests, ZMinMaxControl tests, see through and missing shadows Jan 30, 2025
@polymetal0
Copy link
Author

So whats the status up here if i might ask. mborgerson wants the testcases fullfilled before merge is allowed. Is there a status?

@svensvond @mborgerson PR is ready for merge

@polymetal0 polymetal0 marked this pull request as ready for review January 30, 2025 23:22
@Fabxx
Copy link
Contributor

Fabxx commented Jan 31, 2025

So whats the status up here if i might ask. mborgerson wants the testcases fullfilled before merge is allowed. Is there a status?

@svensvond @mborgerson PR is ready for merge

I tested this PR upon master. These are the results with splinter cell
1.webm
2.webm

- Fixed texture perspective issue in fixed function
@polymetal0
Copy link
Author

So whats the status up here if i might ask. mborgerson wants the testcases fullfilled before merge is allowed. Is there a status?

@svensvond @mborgerson PR is ready for merge

I tested this PR upon master. These are the results with splinter cell 1.webm 2.webm

Fixed ;)

@Fabxx
Copy link
Contributor

Fabxx commented Jan 31, 2025

So whats the status up here if i might ask. mborgerson wants the testcases fullfilled before merge is allowed. Is there a status?

@svensvond @mborgerson PR is ready for merge

I tested this PR upon master. These are the results with splinter cell 1.webm 2.webm

Fixed ;)

re-testing now, do you have discord btw? Might be faster to send test results there to you.

Update:
sc fix.webm

@Fabxx
Copy link
Contributor

Fabxx commented Jan 31, 2025

sha.webm

@polymetal0 i still notice some shadow flickering

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.

None yet

8 participants