Enum naga::Statement[][src]

pub enum Statement {
Show 14 variants Emit(Range<Expression>), Block(Block), If { condition: Handle<Expression>, accept: Block, reject: Block, }, Switch { selector: Handle<Expression>, cases: Vec<SwitchCase>, default: Block, }, Loop { body: Block, continuing: Block, }, Break, Continue, Return { value: Option<Handle<Expression>>, }, Kill, Barrier(Barrier), Store { pointer: Handle<Expression>, value: Handle<Expression>, }, ImageStore { image: Handle<Expression>, coordinate: Handle<Expression>, array_index: Option<Handle<Expression>>, value: Handle<Expression>, }, Atomic { pointer: Handle<Expression>, fun: AtomicFunction, value: Handle<Expression>, result: Handle<Expression>, }, Call { function: Handle<Function>, arguments: Vec<Handle<Expression>>, result: Option<Handle<Expression>>, },
}
Expand description

Instructions which make up an executable block.

Variants

Emit a range of expressions, visible to all statements that follow in this block.

See the module-level documentation for details.

Tuple Fields of Emit

0: Range<Expression>
Block(Block)

A block containing more statements, to be executed sequentially.

Tuple Fields of Block

0: Block
If

Conditionally executes one of two blocks, based on the value of the condition.

Fields of If

condition: Handle<Expression>accept: Blockreject: Block
Switch

Conditionally executes one of multiple blocks, based on the value of the selector.

Fields of Switch

selector: Handle<Expression>cases: Vec<SwitchCase>default: Block
Loop

Executes a block repeatedly.

Each iteration of the loop executes the body block, followed by the continuing block.

Executing a Break, Return or Kill statement exits the loop.

A Continue statement in body jumps to the continuing block. The continuing block is meant to be used to represent structures like the third expression of a C-style for loop head, to which continue statements in the loop’s body jump.

The continuing block and its substatements must not contain Return or Kill statements, or any Break or Continue statements targeting this loop. (It may have Break and Continue statements targeting loops or switches nested within the continuing block.)

Fields of Loop

body: Blockcontinuing: Block
Break

Exits the innermost enclosing Loop or Switch.

A Break statement may only appear within a Loop or Switch statement. It may not break out of a Loop from within the loop’s continuing block.

Continue

Skips to the continuing block of the innermost enclosing Loop.

A Continue statement may only appear within the body block of the innermost enclosing Loop statement. It must not appear within that loop’s continuing block.

Return

Returns from the function (possibly with a value).

Return statements are forbidden within the continuing block of a Loop statement.

Fields of Return

value: Option<Handle<Expression>>
Kill

Aborts the current shader execution.

Kill statements are forbidden within the continuing block of a Loop statement.

Barrier(Barrier)

Synchronize invocations within the work group. The Barrier flags control which memory accesses should be synchronized. If empty, this becomes purely an execution barrier.

Tuple Fields of Barrier

0: Barrier
Store

Stores a value at an address.

For TypeInner::Atomic type behind the pointer, the value has to be a corresponding scalar. For other types behind the pointer, the value is T.

This statement is a barrier for any operations on the Expression::LocalVariable or Expression::GlobalVariable that is the destination of an access chain, started from the pointer.

Fields of Store

pointer: Handle<Expression>value: Handle<Expression>
ImageStore

Stores a texel value to an image.

The image, coordinate, and array_index fields have the same meanings as the corresponding operands of an ImageLoad expression; see that documentation for details. Storing into multisampled images or images with mipmaps is not supported, so there is no indexoperand.

This statement is a barrier for any operations on the corresponding Expression::GlobalVariable for this image.

Fields of ImageStore

image: Handle<Expression>coordinate: Handle<Expression>array_index: Option<Handle<Expression>>value: Handle<Expression>
Atomic

Atomic function.

Fields of Atomic

pointer: Handle<Expression>

Pointer to an atomic value.

fun: AtomicFunction

Function to run on the atomic.

value: Handle<Expression>

Value to use in the function.

result: Handle<Expression>

Emitted expression as a result.

Call

Calls a function.

If the result is Some, the corresponding expression has to be Expression::CallResult, and this statement serves as a barrier for any operations on that expression.

Fields of Call

function: Handle<Function>arguments: Vec<Handle<Expression>>result: Option<Handle<Expression>>

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.