Skip to content
This repository has been archived by the owner on Jan 29, 2025. It is now read-only.

[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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants