Crate naga[][src]

Expand description

Universal shader translator.

The central structure of the crate is Module.

To improve performance and reduce memory usage, most structures are stored in an Arena, and can be retrieved using the corresponding Handle.

Functions are described in terms of statement trees. A statement may have branching control flow, and it may be mutating. Statements refer to expressions.

Expressions form a DAG, without any side effects. Expressions need to be emitted in order to take effect. This happens in one of the following ways:

  1. Constants and function arguments are implicitly emitted at function start. This corresponds to expression.needs_pre_emit() condition.
  2. Local and global variables are implicitly emitted. However, in order to use parts of them in right-hand-side expressions, the Expression::Load must be explicitly emitted, with an exception of StorageClass::Handle global variables.
  3. Result of Statement::Call is automatically emitted.
  4. Statement::Emit range is explicitly emitted.

Modules

back

Functions which export shader modules into binary and text formats.

front

Parsers which load shaders into memory.

proc

Module processing functionality.

valid

Structs

Arena

An arena holding some kind of component (e.g., type, constant, instruction, etc.) that can be referenced.

Constant

Constant value.

EarlyDepthTest

Early fragment tests. In a standard situation if a driver determines that it is possible to switch on early depth test it will. Typical situations when early depth test is switched off:

EntryPoint

Exported function, to be run at a certain stage in the pipeline.

Function

A function defined in the module.

FunctionArgument

A function argument.

FunctionResult
GlobalVariable

Variable defined at module level.

Handle

A strongly typed reference to an arena item.

LocalVariable

Variable defined at function level.

Module

Shader module.

Range

A strongly typed range of handles.

ResourceBinding

Pipeline binding information for global resources.

StorageAccess

Flags describing an image.

StructMember

Member of a user-defined structure.

SwitchCase

A case for a switch statement.

Type

A data type declared in the module.

Enums

ArraySize

Size of an array.

BinaryOperator

Operation that can be applied on two values.

Binding

Describes how an input/output variable is to be bound.

BuiltIn

Built-in inputs and outputs.

ConservativeDepth

Enables adjusting depth without disabling early Z.

ConstantInner

Additional information, dependent on the kind of constant.

DerivativeAxis

Axis on which to compute a derivative.

Expression

An expression that can be evaluated to obtain a value.

ImageClass

Sub-class of the image type.

ImageDimension

The number of dimensions an image has.

ImageQuery

Type of an image query.

Interpolation

The interpolation qualifier of a binding or struct field.

MathFunction

Built-in shader function for math.

RelationalFunction

Built-in shader function for testing relation between values.

SampleLevel

Sampling modifier to control the level of detail.

Sampling

The sampling qualifiers of a binding or struct field.

ScalarKind

Primitive type for a scalar.

ScalarValue

A literal scalar value, used in constants.

ShaderStage

Stage of the programmable pipeline.

Statement

Instructions which make up an executable block.

StorageClass

Class of storage for variables.

StorageFormat
StructLevel

Qualifier of the type level, at which a struct can be used.

SwizzleComponent

Component selection for a vector swizzle.

TypeInner

Enum with additional information, depending on the kind of type.

UnaryOperator

Operation that can be applied on a single value.

VectorSize

Number of components in a vector.

Constants

BOOL_WIDTH

Width of a boolean type, in bytes.

Type Definitions

Alignment
Block

A code block is just a vector of statements.

Bytes

Number of bytes per scalar.

FastHashMap

Hash map that is faster but not resilient to DoS attacks.

FastHashSet

Hash set that is faster but not resilient to DoS attacks.