{ "keywords": [ "alias", "break", "case", "const", "const_assert", "continue", "continuing", "default", "diagnostic", "discard", "else", "enable", "false", "fn", "for", "if", "let", "loop", "override", "requires", "return", "struct", "switch", "true", "var", "while" ], "attributes": { "align": { "description": "Constrains the placement of a structure member in memory. Must only be applied to a member of a structure type. Note: This attribute influences how a value of the enclosing structure type can appear in memory: at which byte addresses the structure itself and its component members can appear. In particular, the rules in § 13.4 Memory Layout combine to imply the following constraint: If align( n ) is applied to a member of S with type T, and S is the store type or contained in the store type for a variable in address space C, then n must satisfy: n = k × RequiredAlignOf ( T, C ) for some positive integer k.", "description_parameters": "Must be a const-expression that resolves to an i32 or u32. Must be positive. Must be a power of 2." }, "binding": { "description": "Specifies the binding number of the resource in a bind group. See § 12.3.2 Resource Interface. Must only be applied to a resource variable.", "description_parameters": "Must be a const-expression that resolves to an i32 or u32. Must be non-negative." }, "blend_src": { "description": "Specifies a part of the fragment output when the feature dual_source_blending is enabled. See § 12.3.1.3 Input-output Locations. Must only be applied to a member of a structure type with a location attribute. Must only be applied to declarations of objects with numeric scalar or numeric vector type. Must only be used as an output of the fragment shader stage.", "description_parameters": "Must be a const-expression that resolves to an i32 or u32 with value of 0 or 1." }, "builtin": { "description": "Specifies that the associated object is a built-in value, as denoted by the specified token. See § 12.3.1.1 Built-in Inputs and Outputs. Must only be applied to an entry point function parameter, entry point return type, or member of a structure.", "description_parameters": "Must be a built-in value name-token for a built-in value." }, "compute": { "description": "The compute attribute declares the function to be an entry point for the compute shader stage of a compute pipeline.", "description_parameters": null }, "const": { "description": "Specifies that the function can be used as a const-function. This attribute must not be applied to a user-defined function. Must only be applied to function declarations. Note: This attribute is used as a notational convention to describe which built-in functions can be used in const-expressions.", "description_parameters": null }, "diagnostic": { "description": "Specifies a range diagnostic filter. See § 2.3 Diagnostics. More than one diagnostic attribute may be specified on a syntactic form, but they must specify different triggering rules.", "description_parameters": "The first parameter is a severity_control_name. The second parameter is a diagnostic_rule_name token specifying a triggering rule." }, "fragment": { "description": "The fragment attribute declares the function to be an entry point for the fragment shader stage of a render pipeline.", "description_parameters": null }, "group": { "description": "Specifies the binding group of the resource. See § 12.3.2 Resource Interface. Must only be applied to a resource variable.", "description_parameters": "Must be a const-expression that resolves to an i32 or u32. Must be non-negative." }, "id": { "description": "Specifies a numeric identifier as an alternate name for a pipeline-overridable constant. Must only be applied to an override-declaration of scalar type.", "description_parameters": "Must be a const-expression that resolves to an i32 or u32. Must be non-negative." }, "interpolate": { "description": "Specifies how the user-defined IO must be interpolated. The attribute is only significant on user-defined vertex outputs and fragment inputs. See § 12.3.1.4 Interpolation. Must only be applied to a declaration that has a location attribute applied.", "description_parameters": "The first parameter must be an interpolation type name-token for an interpolation type. The second parameter, if present, must be an interpolation sampling name-token for the interpolation sampling." }, "invariant": { "description": "When applied to the position built-in output value of a vertex shader, the computation of the result is invariant across different programs and different invocations of the same entry point. That is, if the data and control flow match for two position outputs in different entry points, then the result values are guaranteed to be the same. There is no effect on a position built-in input value. Must only be applied to the position built-in value. Note: This attribute maps to the precise qualifier in HLSL, and the invariant qualifier in GLSL.", "description_parameters": null }, "location": { "description": "Specifies a part of the user-defined IO of an entry point. See § 12.3.1.3 Input-output Locations. Must only be applied to an entry point function parameter, entry point return type, or member of a structure type. Must only be applied to declarations of objects with numeric scalar or numeric vector type. Must not be used with the compute shader stage.", "description_parameters": "Must be a const-expression that resolves to an i32 or u32. Must be non-negative." }, "must_use": { "description": "Specifies that a call to this function must be used as an expression. That is, a call to this function must not be the entirety of a function call statement. Must only be applied to the declaration of a function with a return type. Note: Many functions return a value and do not have side effects. It is often a programming defect to call such a function as the only thing in a function call statement. Built-in functions with these properties are declared as @must_use. User-defined functions can also have the @must_use attribute. Note: To deliberately work around the @must_use rule, use a phony assignment or declare a value using the function call as the initializer.", "description_parameters": null }, "size": { "description": "Specifies the number of bytes reserved for a structure member. This number must be at least the byte-size of the type of the member: If size( n ) is applied to a member with type T, then SizeOf ( T ) ≤ n. See § 13.4 Memory Layout. Must only be applied to a member of a structure type. The member type must have creation-fixed footprint.", "description_parameters": "Must be a const-expression that resolves to an i32 or u32. Must be positive." }, "vertex": { "description": "The vertex attribute declares the function to be an entry point for the vertex shader stage of a render pipeline.", "description_parameters": null }, "workgroup_size": { "description": "Specifies the x, y, and z dimensions of the workgroup grid for the compute shader. The first parameter specifies the x dimension. The second parameter, if provided, specifies the y dimension, otherwise is assumed to be 1. The third parameter, if provided, specifies the z dimension, otherwise is assumed to be 1. Must only be applied to a compute shader entry point function. Must not be applied to any other object.", "description_parameters": "Takes one, two, or three parameters. Each parameter must be a const-expression or an override-expression. All parameters must be the same type, either i32 or u32. A shader-creation error results if any specified parameter is a const-expression that evaluates to a non-positive value. A pipeline-creation error results if any specified parameter evaluates to a non-positive value or exceeds an upper bound specified by the WebGPU API, or if the product of the parameter values exceeds the upper bound specified by the WebGPU API (see WebGPU § 3.6.2 Limits )." } }, "builtin_values": { "clip_distances": { "stages": { "vertex": { "description": "Each value in the array represents a distance to a user-defined clip plane. A clip distance of 0 means the vertex is on the plane, a positive distance means the vertex is inside the clip half-space, and a negative distance means the vertex is outside the clip half-space. The array size of clip_distances must be ≤ 8. See WebGPU § 23.2.4 Primitive Clipping.", "direction": "Output" } }, "typ": "array" }, "frag_depth": { "stages": { "fragment": { "description": "Updated depth of the fragment, in the viewport depth range. See WebGPU § 3.3 Coordinate Systems.", "direction": "Output" } }, "typ": "f32" }, "front_facing": { "stages": { "fragment": { "description": "True when the current fragment is on a front-facing primitive. False otherwise.", "direction": "Input" } }, "typ": "bool" }, "global_invocation_id": { "stages": { "compute": { "description": "The current invocation’s global invocation ID, i.e. its position in the compute shader grid. The value of global_invocation_id is equal to workgroup_id * workgroup_size + local_invocation_id.", "direction": "Input" } }, "typ": "vec3" }, "instance_index": { "stages": { "vertex": { "description": "Instance index of the current vertex within the current API-level draw command. The first instance has an index equal to the firstInstance argument of the draw, whether provided directly or indirectly. The index is incremented by one for each additional instance in the draw.", "direction": "Input" } }, "typ": "u32" }, "local_invocation_id": { "stages": { "compute": { "description": "The current invocation’s local invocation ID, i.e. its position in the workgroup grid.", "direction": "Input" } }, "typ": "vec3" }, "local_invocation_index": { "stages": { "compute": { "description": "The current invocation’s local invocation index, a linearized index of the invocation’s position within the workgroup grid.", "direction": "Input" } }, "typ": "u32" }, "num_workgroups": { "stages": { "compute": { "description": "The dispatch size, vec3(group_count_x, group_count_y, group_count_z), of the compute shader dispatched by the API.", "direction": "Input" } }, "typ": "vec3" }, "position": { "stages": { "fragment": { "description": "Input position of the current fragment. Let fp be the input position of the fragment. Let rp be the RasterizationPoint for the fragment. Let vp be the [[viewport]] in effect for the draw command. Then schematically: fp .xy = rp. destination. position fp .z = rp. depth fp .w = rp. perspectiveDivisor In more detail: fp .x and fp .y are the interpolated x and y coordinates of the position the current fragment in the framebuffer. The framebuffer is a two-dimensional grid of pixels with the top-left at (0.0,0.0) and the bottom right at ( vp .width, vp .height). Each pixel has an extent of 1.0 unit in each of the x and y dimensions, and pixel centers are at (0.5,0.5) offset from integer coordinates. fp .z is the interpolated depth of the current fragment. For example: depth 0 in normalized device coordinates maps to fp .z = vp .minDepth, depth 1 in normalized device coordinates maps to fp .z = vp .maxDepth. fp .w is the perspective divisor for the fragment, which is the interpolation of 1.0 ÷ vertex_w, where vertex_w is the w component of the position output of the vertex shader. See WebGPU § 3.3 Coordinate Systems and WebGPU § 23.2.5 Rasterization.", "direction": "Input" }, "vertex": { "description": "The clip position of the current vertex, in clip space coordinates. An output value ( x, y, z, w ) will map to ( x / w, y / w, z / w ) in WebGPU normalized device coordinates. See WebGPU § 3.3 Coordinate Systems and WebGPU § 23.2.4 Primitive Clipping.", "direction": "Output" } }, "typ": "vec4" }, "sample_index": { "stages": { "fragment": { "description": "Sample index for the current fragment. The value is least 0 and at most sampleCount -1, where sampleCount is the MSAA sample count specified for the GPU render pipeline. When this attribute is applied, if the effects of the fragment shader would vary based on the value of sample_index, the fragment shader will be invoked once per sample. See WebGPU § 10.3 GPURenderPipeline.", "direction": "Input" } }, "typ": "u32" }, "sample_mask": { "stages": { "fragment": { "description": "Sample coverage mask control for the current fragment. The last value written to this variable becomes the shader-output mask. Zero bits in the written value will cause corresponding samples in the color attachments to be discarded. See WebGPU § 23.2.11 Sample Masking.", "direction": "Output" } }, "typ": "u32" }, "vertex_index": { "stages": { "vertex": { "description": "Index of the current vertex within the current API-level draw command, independent of draw instancing. For a non-indexed draw, the first vertex has an index equal to the firstVertex argument of the draw, whether provided directly or indirectly. The index is incremented by one for each additional vertex in the draw instance. For an indexed draw, the index is equal to the index buffer entry for the vertex, plus the baseVertex argument of the draw, whether provided directly or indirectly.", "direction": "Input" } }, "typ": "u32" }, "workgroup_id": { "stages": { "compute": { "description": "The current invocation’s workgroup ID, i.e. the position of the workgroup in overall compute shader grid. All invocations in the same workgroup have the same workgroup ID. Workgroup IDs span from (0,0,0) to ( group_count_x - 1, group_count_y - 1, group_count_z - 1).", "direction": "Input" } }, "typ": "vec3" } }, "interpolation_type_names": [ "flat", "linear", "perspective" ], "interpolation_sampling_names": [ "center", "centroid", "either", "first", "sample" ], "primitive_types": [ "bool", "f16", "f32", "i32", "sampler", "sampler_comparison", "texture_depth_2d", "texture_depth_2d_array", "texture_depth_cube", "texture_depth_cube_array", "texture_depth_multisampled_2d", "texture_external", "u32" ], "type_generators": [ "array", "atomic", "mat2x2", "mat2x3", "mat2x4", "mat3x2", "mat3x3", "mat3x4", "mat4x2", "mat4x3", "mat4x4", "ptr", "texture_1d", "texture_2d", "texture_2d_array", "texture_3d", "texture_cube", "texture_cube_array", "texture_multisampled_2d", "texture_storage_1d", "texture_storage_2d", "texture_storage_2d_array", "texture_storage_3d", "vec2", "vec3", "vec4" ], "type_aliases": { "mat2x2f": "mat2x2", "mat2x2h": "mat2x2", "mat2x3f": "mat2x3", "mat2x3h": "mat2x3", "mat2x4f": "mat2x4", "mat2x4h": "mat2x4", "mat3x2f": "mat3x2", "mat3x2h": "mat3x2", "mat3x3f": "mat3x3", "mat3x3h": "mat3x3", "mat3x4f": "mat3x4", "mat3x4h": "mat3x4", "mat4x2f": "mat4x2", "mat4x2h": "mat4x2", "mat4x3f": "mat4x3", "mat4x3h": "mat4x3", "mat4x4f": "mat4x4", "mat4x4h": "mat4x4", "vec2f": "vec2", "vec2h": "vec2", "vec2i": "vec2", "vec2u": "vec2", "vec3f": "vec3", "vec3h": "vec3", "vec3i": "vec3", "vec3u": "vec3", "vec4f": "vec4", "vec4h": "vec4", "vec4i": "vec4", "vec4u": "vec4" } }