Skip to content

Implement custom sin/cos approximation#4866

Merged
doitsujin merged 5 commits intomasterfrom
intel-sincos
Apr 29, 2025
Merged

Implement custom sin/cos approximation#4866
doitsujin merged 5 commits intomasterfrom
intel-sincos

Conversation

@doitsujin
Copy link
Copy Markdown
Owner

@doitsujin doitsujin commented Apr 23, 2025

Intel's sin(x) is very inaccurate for |x| ≈ π/2, which leads to issues such as #4861.

This is an attempt to work around the problem by implementing a custom sin/cos implementation using a Taylor approximation within a range of [-π/4,π/4], and doing some magic to map the rest of the curve to that interval. Precision is good enough to meet D3D11 requirements and should fix Thumper, but this is expected to be quite slow.

On systems with good sin/cos, keep using the corresponding SPIR-V instructions.

Needs testing across a reasonably wide range of games including D3D11, this changes code gen in all shaders that use sincos instructions even if the workaround is not used.

@doitsujin doitsujin merged commit 3206a7f into master Apr 29, 2025
8 checks passed
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.

1 participant