Skip to content

GS:HW: Reduce primid max value and add primid dumping. - #14824

Open
TJnotJT wants to merge 2 commits into
PCSX2:masterfrom
TJnotJT:gs-primid-max
Open

GS:HW: Reduce primid max value and add primid dumping.#14824
TJnotJT wants to merge 2 commits into
PCSX2:masterfrom
TJnotJT:gs-primid-max

Conversation

@TJnotJT

@TJnotJT TJnotJT commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Description of Changes

Reduce the maximum value of the primid texture to 0xFFFFFF (~ 17 million).

Add dumping of primid texture for debugging when RT dumping is enabled.

Rationale behind Changes

Fixes #14818 on Mesa OpenGL. Although that's the only driver known to have an issue with large primid values, 0xFFFFFF primitives should be large enough for all use cases (we limit draws to roughly 0xFFFF vertices).

Suggested Testing Steps

Follow the steps in the linked issue.

Enable RT dumping in Settings>Debug>GS and run a game/dump that uses primid DATE. The primid textures should be dumped with names like 00045_f00000_primid.png.

Did you use AI to help find, test, or implement this issue or feature?

No.

@TellowKrinkle TellowKrinkle left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What's the use for primid dumping? I would have expected this to be better debugged in renderdoc, since it has nothing to do with what the game is doing and is entirely something the emulator is doing for itself. But if you do include it, I would much prefer dumping raw floats, not floats converted to ints.

Comment thread pcsx2/GS/Renderers/Common/GSShaderEnums.h Outdated
@TJnotJT

TJnotJT commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

What's the use for primid dumping? I would have expected this to be better debugged in renderdoc, since it has nothing to do with what the game is doing and is entirely something the emulator is doing for itself.

OGL renderdoc debugging is a bit limited on my system (e.g. no viewing of textures) so I had to resort to dumping the primid textures. Iirc, the problem draw was failing all fragments incorrectly because the primid texture had all negative values.

But if you do include it, I would much prefer dumping raw floats, not floats converted to ints.

Sure, I can change it to dump the floating point bits.

@TJnotJT
TJnotJT force-pushed the gs-primid-max branch 2 times, most recently from cfac41c to ba6144f Compare August 8, 2026 01:38
TJnotJT added 2 commits August 7, 2026 21:41
Large values may cause errors in primid DATE on Mesa OpenGL.
@TJnotJT

TJnotJT commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

Smoke tested the primid dumping on DX11/12, VK, and GL. It turns out that the Mesa GL primid texture looks fine when dumped even with 0x7fffffff (2^31-1) as the max primid value. It appears to get the wrong value only when it samples the texture in the main draw.

@TJnotJT
TJnotJT marked this pull request as ready for review August 8, 2026 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: OpenGL PrimID regression on mesa llvmpipe

4 participants