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-in: Fix the ternary operator to behave like an if #1877

Merged
merged 3 commits into from
May 1, 2022

Conversation

JCapucho
Copy link
Collaborator

Fixes #1854

As pointed out in the issue, the glsl spec defines that only one of the expressions should be evaluated making the ternary operator syntactic sugar to an if.

There are two commits that can be reviewed and tested separately, the first contains the actual fix and is the majority of the work. The seconds introduces a new method to the Context called emit_restart that performs a very common operation on the frontend of flushing the emitter and restarting it.

The GLSL specification defines that only one of the branches should be
evaluated making the ternary operator syntatic sugar for an `if`.
Adds a new method `emit_restart` to perform the common operation of flushing
the `emitter` to the body and starting it again.

Adds documentation to all context emitter related methods
@jimblandy jimblandy self-requested a review April 30, 2022 23:26
Copy link
Member

@jimblandy jimblandy left a comment

Choose a reason for hiding this comment

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

Looks beautiful! Nothing major, just suggestions and nits.

src/front/glsl/context.rs Show resolved Hide resolved
src/front/glsl/context.rs Outdated Show resolved Hide resolved
src/front/glsl/context.rs Show resolved Hide resolved
src/front/glsl/context.rs Outdated Show resolved Hide resolved
src/front/glsl/context.rs Show resolved Hide resolved
src/front/glsl/types.rs Outdated Show resolved Hide resolved
src/front/glsl/types.rs Outdated Show resolved Hide resolved
src/front/glsl/types.rs Outdated Show resolved Hide resolved
tests/in/glsl/expressions.frag Outdated Show resolved Hide resolved
@JCapucho JCapucho requested a review from jimblandy May 1, 2022 16:40
@jimblandy jimblandy merged commit 883a885 into gfx-rs:master May 1, 2022
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.

[glsl-in] True and false branch of conditional expression operands are always evaluated
2 participants