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

Missing fp const folding for std.450 extended instructions #1390

Closed
zeux opened this issue Mar 8, 2018 · 3 comments · Fixed by #3166
Closed

Missing fp const folding for std.450 extended instructions #1390

zeux opened this issue Mar 8, 2018 · 3 comments · Fixed by #3166

Comments

@zeux
Copy link
Contributor

zeux commented Mar 8, 2018

We have some shaders that have instructions from the extended set that could be folded but aren't, specifically:

  • FMin/FMax
  • Pow/Exp/Log/Log2
  • Sin/Cos

(I won't have time to look into this up until after GDC so filing an issue for now, maybe somebody gets to this first!)

@dneto0 dneto0 added this to Suggested to start in Optimizer Mar 8, 2018
@dneto0
Copy link
Collaborator

dneto0 commented Mar 8, 2018

Thanks for the suggestion. I put it at the top of the "Suggested to start" list.
I can't guarantee we'll get to it soon either. :-)

@Trass3r
Copy link

Trass3r commented Jun 2, 2019

Yes also normalize, cross, mix, smoothstep: http://shader-playground.timjones.io/06d95d58a040a9d589626db8d042a377

@zeux
Copy link
Contributor Author

zeux commented Jan 29, 2020

I guess I have to do it myself 😅 I'm going to implement this for scalar transcendentals and submit a PR to close this - fmin/fmax are already supported, and somebody else can implement vector folding...

s-perron pushed a commit that referenced this issue Feb 3, 2020
* Implement constant folding for many transcendentals

This change adds support for folding of sin/cos/tan/asin/acos/atan,
exp/log/exp2/log2, sqrt, atan2 and pow.

The mechanism allows to use any C function to implement folding in the
future; for now I limited the actual additions to the most commonly used
intrinsics in the shaders.

Unary folder had to be tweaked to work with extended instructions - for
extended instructions, constants.size() == 2 and constants[0] ==
nullptr. This adjustment is similar to the one binary folder already
performs.

Fixes #1390.

* Fix Android build

On old versions of Android NDK, we don't get std::exp2/std::log2
because of partial C++11 support.

We do get ::exp2, but not ::log2 so we need to emulate that.
@s-perron s-perron moved this from Suggested to start to Done in Optimizer Aug 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging a pull request may close this issue.

3 participants