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

[d3d8] Fix up swizzle for all opcodes requiring a replicate swizzle #4653

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

WinterSnowfall
Copy link
Contributor

Fixes #4113.

https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/d3d9types/ne-d3d9types-_d3dshader_instruction_opcode_type

The information in the docs isn't clear or complete, but it is at least clear that RSQ isn't the only opcode which requires the explicit use of a replicate swizzle for its inputs.

If the swizzle on inputs is somehow .xyzw / D3DVS_NOSWIZZLE (although that is technically illegal in the context of the affected opcodes) it appears native d3d8 does indeed impose a replicate swizzle, as @AlpyneDreams has already determined when looking at Indiana Jones And The Emperor's Tomb, and also based on empirical evidence it appears .w is the one that makes things look as expected, and in this case also fixes the missing fog in NFS Hot Pursuit 2.

Needs testing to ensure nothing regresses otherwise, but once that is done, I'll undraft.

@K0bin
Copy link
Collaborator

K0bin commented Jan 28, 2025

The shader bytecode came with the game and wasn't compiled at runtime, right?

@WinterSnowfall
Copy link
Contributor Author

WinterSnowfall commented Jan 28, 2025

The shader bytecode came with the game and wasn't compiled at runtime, right?

Pretty sure that's the case for almost all d3d8 games, if not, in fact, all. Misunderstood your question. I'm not sure why d3d8to9 does the disassembly, but in d8vk we translate the declaration and function directly to a d3d9-style shader declaration and function (don't ask me any of the specifics here :P, what I do know at least is that they're encoded differently).

@WinterSnowfall
Copy link
Contributor Author

Tested on the full complement of ~200 d3d8 games - found no regressions or other types of issues.

@WinterSnowfall WinterSnowfall marked this pull request as ready for review January 28, 2025 17:05
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.

[d3d8] Missing f(r)og in NFS Hot Pursuit 2
2 participants