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

[glsl-out] Polyfill frexp #2504

Merged
merged 1 commit into from
Sep 25, 2023
Merged

[glsl-out] Polyfill frexp #2504

merged 1 commit into from
Sep 25, 2023

Conversation

evahop
Copy link
Contributor

@evahop evahop commented Sep 25, 2023

Implementation derived from https://en.cppreference.com/w/cpp/numeric/math/frexp#Notes.

Produces the following in tests/out/glsl/math-functions.main.Fragment.glsl when targeting < 400 & 310 es.

45   │ __frexp_result_f32_ naga_frexp(float arg) {
46int other = arg == float(0) ? int(0) : int(float(1)   log2(arg));
47float fract = arg * exp2(float(-other));
48return __frexp_result_f32_(fract, other);
49   │ }
5051   │ __frexp_result_vec4_f32_ naga_frexp(vec4 arg) {
52ivec4 other = arg == vec4(0) ? ivec4(0) : ivec4(vec4(1)   log2(arg));
53vec4 fract = arg * exp2(vec4(-other));
54return __frexp_result_vec4_f32_(fract, other);
55   │ }

Copy link
Member

@teoxoy teoxoy left a comment

Choose a reason for hiding this comment

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

LGTM

@teoxoy teoxoy merged commit dc3d2b1 into gfx-rs:master Sep 25, 2023
5 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.

2 participants