├── rustfmt.toml ├── wgpu └── src │ ├── macros │ ├── be-aligned.spv │ └── le-aligned.spv │ ├── util │ └── panicking.rs │ └── backend │ └── mod.rs ├── naga ├── tests │ ├── in │ │ ├── spv │ │ │ ├── degrees.toml │ │ │ ├── f16-spv.toml │ │ │ ├── quad-vert.toml │ │ │ ├── fetch_depth.toml │ │ │ ├── gather.toml │ │ │ ├── gather-cmp.toml │ │ │ ├── load-ms-texture.toml │ │ │ ├── builtin-accessed-outside-entrypoint.toml │ │ │ ├── shadow.toml │ │ │ ├── spec-constants.toml │ │ │ ├── barrier.toml │ │ │ ├── spec-constants-issue-5598.toml │ │ │ ├── do-while.toml │ │ │ ├── empty-global-name.toml │ │ │ ├── inv-hyperbolic-trig-functions.toml │ │ │ ├── unnamed-gl-per-vertex.toml │ │ │ ├── binding-arrays.dynamic.toml │ │ │ ├── binding-arrays.static.toml │ │ │ ├── subgroup-barrier.toml │ │ │ ├── binding-arrays.runtime.toml │ │ │ └── subgroup-operations-s.toml │ │ ├── wgsl │ │ │ ├── must-use.toml │ │ │ ├── hlsl-keyword.toml │ │ │ ├── hlsl_mat_cx2.toml │ │ │ ├── hlsl_mat_cx3.toml │ │ │ ├── module-scope.toml │ │ │ ├── msl-varyings.toml │ │ │ ├── template-list-ge.toml │ │ │ ├── type-alias.toml │ │ │ ├── const_assert.toml │ │ │ ├── cubeArrayShadow.toml │ │ │ ├── diagnostic-filter.toml │ │ │ ├── empty-if.toml │ │ │ ├── lexical-scopes.toml │ │ │ ├── local-const.toml │ │ │ ├── 6220-break-from-loop.toml │ │ │ ├── abstract-types-atomic.toml │ │ │ ├── index-by-value.toml │ │ │ ├── 7048-multiple-dynamic-1.toml │ │ │ ├── 7048-multiple-dynamic-2.toml │ │ │ ├── 7048-multiple-dynamic-3.toml │ │ │ ├── control-flow.toml │ │ │ ├── template-list-trailing-comma.toml │ │ │ ├── empty.wgsl │ │ │ ├── unconsumed_vertex_outputs_frag.toml │ │ │ ├── abstract-types-const.toml │ │ │ ├── abstract-types-let.toml │ │ │ ├── abstract-types-var.toml │ │ │ ├── math-functions.toml │ │ │ ├── pointer-function-arg.toml │ │ │ ├── sprite.toml │ │ │ ├── abstract-types-builtins.toml │ │ │ ├── abstract-types-operators.toml │ │ │ ├── storage-textures.toml │ │ │ ├── abstract-types-function-calls.toml │ │ │ ├── atomicCompareExchange.toml │ │ │ ├── bits_downlevel.toml │ │ │ ├── multiview.wgsl │ │ │ ├── multiview_webgl.wgsl │ │ │ ├── types_with_comments.toml │ │ │ ├── abstract-types-texture.toml │ │ │ ├── early-depth-test-force.toml │ │ │ ├── shadow.toml │ │ │ ├── texture-arg.toml │ │ │ ├── pointer-function-arg-restrict.toml │ │ │ ├── pointer-function-arg-rzsw.toml │ │ │ ├── bits_downlevel_webgl.toml │ │ │ ├── separate-entry-points.toml │ │ │ ├── collatz.toml │ │ │ ├── bits-optimized-msl.toml │ │ │ ├── clip-distances.toml │ │ │ ├── bounds-check-restrict.toml │ │ │ ├── debug-symbol-simple.toml │ │ │ ├── debug-symbol-terrain.toml │ │ │ ├── debug-symbol-large-source.toml │ │ │ ├── early-depth-test-conservative.toml │ │ │ ├── bounds-check-zero-atomic.toml │ │ │ ├── barycentrics.wgsl │ │ │ ├── bounds-check-zero.toml │ │ │ ├── mesh-shader.toml │ │ │ ├── multiview.toml │ │ │ ├── unconsumed_vertex_outputs_vert.toml │ │ │ ├── early-depth-test-force.wgsl │ │ │ ├── mesh-shader-empty.toml │ │ │ ├── mesh-shader-lines.toml │ │ │ ├── functions-webgl.toml │ │ │ ├── pointers.toml │ │ │ ├── 6772-unpack-expr-accesses.wgsl │ │ │ ├── invariant.toml │ │ │ ├── overrides-atomicCompareExchangeWeak.toml │ │ │ ├── early-depth-test-conservative.wgsl │ │ │ ├── mesh-shader-points.toml │ │ │ ├── barycentrics.toml │ │ │ ├── hlsl-keyword.wgsl │ │ │ ├── invariant.wgsl │ │ │ ├── overrides-atomicCompareExchangeWeak.wgsl │ │ │ ├── overrides.toml │ │ │ ├── conversion-float-to-int-no-f64.toml │ │ │ ├── cross.wgsl │ │ │ ├── dualsource.toml │ │ │ ├── f64.toml │ │ │ ├── multiview_webgl.toml │ │ │ ├── sample-cube-array-depth-lod.toml │ │ │ ├── array-in-ctor.wgsl │ │ │ ├── force_point_size_vertex_shader_webgl.toml │ │ │ ├── policy-mix.toml │ │ │ ├── 7048-multiple-dynamic-1.wgsl │ │ │ ├── use-gl-ext-over-grad-workaround-if-instructed.toml │ │ │ ├── empty-if.wgsl │ │ │ ├── interpolate_compat.toml │ │ │ ├── atomicOps-float32.toml │ │ │ ├── sprite.wgsl │ │ │ ├── interpolate.toml │ │ │ ├── diagnostic-filter.wgsl │ │ │ ├── functions-webgl.wgsl │ │ │ ├── template-list-ge.wgsl │ │ │ ├── image.toml │ │ │ ├── quad.toml │ │ │ ├── f64.wgsl │ │ │ ├── clip-distances.wgsl │ │ │ ├── f16-native.toml │ │ │ ├── f16-polyfill.toml │ │ │ ├── dualsource.wgsl │ │ │ ├── 7048-multiple-dynamic-2.wgsl │ │ │ ├── bounds-check-image-restrict-depth.toml │ │ │ ├── conversion-float-to-int.toml │ │ │ ├── overrides-ray-query.toml │ │ │ ├── atomicTexture-int64.wgsl │ │ │ ├── extra.toml │ │ │ ├── 7995-unicode-idents.wgsl │ │ │ ├── workgroup-var-init.wgsl │ │ │ ├── workgroup-uniform-load.wgsl │ │ │ ├── bits.toml │ │ │ ├── functions-optimized-by-capability.toml │ │ │ ├── ray-query.toml │ │ │ ├── aliased-ray-query.toml │ │ │ ├── f16.toml │ │ │ ├── texture-arg.wgsl │ │ │ ├── array-in-function-return-type.wgsl │ │ │ ├── atomicOps-int64.toml │ │ │ ├── phony_assignment.wgsl │ │ │ ├── unconsumed_vertex_outputs_vert.wgsl │ │ │ ├── atomicCompareExchange-int64.toml │ │ │ ├── bounds-check-image-restrict.toml │ │ │ ├── bounds-check-image-rzsw-depth.toml │ │ │ ├── bounds-check-image-rzsw.toml │ │ │ ├── push-constants.toml │ │ │ ├── 6438-conflicting-idents.wgsl │ │ │ ├── cubeArrayShadow.wgsl │ │ │ ├── sample-cube-array-depth-lod.wgsl │ │ │ ├── unconsumed_vertex_outputs_frag.wgsl │ │ │ ├── use-gl-ext-over-grad-workaround-if-instructed.wgsl │ │ │ ├── workgroup-var-init.toml │ │ │ ├── functions-unoptimized.toml │ │ │ ├── binding-buffer-arrays.toml │ │ │ ├── subgroup-operations.toml │ │ │ ├── extra.wgsl │ │ │ ├── template-list-trailing-comma.wgsl │ │ │ ├── ray-query-no-init-tracking.toml │ │ │ ├── must-use.wgsl │ │ │ ├── force_point_size_vertex_shader_webgl.wgsl │ │ │ ├── functions-optimized-by-version.toml │ │ │ ├── int64.toml │ │ │ ├── msl-varyings.wgsl │ │ │ ├── separate-entry-points.wgsl │ │ │ ├── 7048-multiple-dynamic-3.wgsl │ │ │ ├── functions-unoptimized.wgsl │ │ │ ├── overrides-ray-query.wgsl │ │ │ ├── type-alias.wgsl │ │ │ ├── functions-optimized-by-version.wgsl │ │ │ ├── atomicTexture.toml │ │ │ └── functions-optimized-by-capability.wgsl │ │ └── glsl │ │ │ ├── spec-constant.toml │ │ │ ├── variations.toml │ │ │ ├── f16-glsl.toml │ │ │ ├── 896-push-constant.toml │ │ │ ├── vector-functions.toml │ │ │ ├── bits.toml │ │ │ ├── double-math-functions.toml │ │ │ ├── 800-out-of-bounds-panic.toml │ │ │ ├── global-constant-array.frag │ │ │ ├── 277-casting.frag │ │ │ ├── 280-matrix-cast.frag │ │ │ ├── clamp-splat.vert │ │ │ ├── dual-source-blending.toml │ │ │ ├── local-var-init-in-loop.comp │ │ │ ├── 932-for-loop-if.frag │ │ │ ├── 901-lhs-field-select.frag │ │ │ ├── anonymous-entry-point-type.frag │ │ │ ├── 896-push-constant.frag │ │ │ ├── 484-preprocessor-if.frag │ │ │ ├── 931-constant-emitting.frag │ │ │ ├── dual-source-blending.frag │ │ │ ├── quad_glsl.vert │ │ │ ├── variations.frag │ │ │ ├── 5246-dual-iteration.frag │ │ │ ├── const-global-swizzle.frag │ │ │ ├── constant-array-size.frag │ │ │ ├── prepostfix.frag │ │ │ ├── buffer.frag │ │ │ ├── bool-select.frag │ │ │ ├── inverse-polyfill.frag │ │ │ ├── quad_glsl.frag │ │ │ └── fma.frag │ ├── out │ │ ├── hlsl │ │ │ ├── wgsl-empty.hlsl │ │ │ ├── wgsl-cross.hlsl │ │ │ ├── wgsl-empty-if.hlsl │ │ │ ├── wgsl-hlsl-keyword.hlsl │ │ │ ├── spv-barrier.ron │ │ │ ├── wgsl-bits.ron │ │ │ ├── wgsl-boids.ron │ │ │ ├── wgsl-cross.ron │ │ │ ├── wgsl-empty.ron │ │ │ ├── wgsl-f16.ron │ │ │ ├── wgsl-f64.ron │ │ │ ├── wgsl-int64.ron │ │ │ ├── wgsl-select.ron │ │ │ ├── spv-do-while.ron │ │ │ ├── spv-quad-vert.ron │ │ │ ├── wgsl-bitcast.ron │ │ │ ├── wgsl-break-if.ron │ │ │ ├── wgsl-collatz.ron │ │ │ ├── wgsl-const-exprs.ron │ │ │ ├── wgsl-conversions.ron │ │ │ ├── wgsl-dualsource.ron │ │ │ ├── wgsl-empty-if.ron │ │ │ ├── wgsl-functions.ron │ │ │ ├── wgsl-globals.ron │ │ │ ├── wgsl-multiview.ron │ │ │ ├── wgsl-operators.ron │ │ │ ├── wgsl-overrides.ron │ │ │ ├── wgsl-padding.ron │ │ │ ├── wgsl-texture-arg.ron │ │ │ ├── spv-empty-global-name.ron │ │ │ ├── wgsl-array-in-ctor.ron │ │ │ ├── wgsl-atomicOps.ron │ │ │ ├── wgsl-atomicTexture.ron │ │ │ ├── wgsl-barycentrics.ron │ │ │ ├── wgsl-binding-arrays.ron │ │ │ ├── wgsl-constructors.ron │ │ │ ├── wgsl-control-flow.ron │ │ │ ├── wgsl-conversions.hlsl │ │ │ ├── wgsl-hlsl-keyword.ron │ │ │ ├── wgsl-hlsl_mat_cx2.ron │ │ │ ├── wgsl-hlsl_mat_cx3.ron │ │ │ ├── wgsl-math-functions.ron │ │ │ ├── wgsl-phony_assignment.ron │ │ │ ├── wgsl-standard.ron │ │ │ ├── wgsl-type-inference.ron │ │ │ ├── spv-subgroup-operations-s.ron │ │ │ ├── spv-unnamed-gl-per-vertex.ron │ │ │ ├── wgsl-7995-unicode-idents.ron │ │ │ ├── wgsl-abstract-types-return.ron │ │ │ ├── wgsl-atomicOps-int64.ron │ │ │ ├── wgsl-functions-unoptimized.ron │ │ │ ├── wgsl-pointer-function-arg.ron │ │ │ ├── wgsl-subgroup-operations.ron │ │ │ ├── wgsl-workgroup-var-init.ron │ │ │ ├── spv-fetch_depth.ron │ │ │ ├── wgsl-6772-unpack-expr-accesses.ron │ │ │ ├── wgsl-atomicOps-int64-min-max.ron │ │ │ ├── wgsl-atomicTexture-int64.ron │ │ │ ├── wgsl-conversion-float-to-int.ron │ │ │ ├── wgsl-multiview.hlsl │ │ │ ├── spv-inv-hyperbolic-trig-functions.ron │ │ │ ├── wgsl-aliased-ray-query.ron │ │ │ ├── wgsl-array-in-function-return-type.ron │ │ │ ├── wgsl-bounds-check-dynamic-buffer.ron │ │ │ ├── wgsl-functions-optimized-by-version.ron │ │ │ ├── wgsl-unconsumed_vertex_outputs_frag.ron │ │ │ ├── wgsl-unconsumed_vertex_outputs_vert.ron │ │ │ ├── wgsl-6772-unpack-expr-accesses.hlsl │ │ │ ├── wgsl-workgroup-uniform-load.ron │ │ │ ├── wgsl-barycentrics.hlsl │ │ │ ├── wgsl-select.hlsl │ │ │ ├── wgsl-7995-unicode-idents.hlsl │ │ │ ├── wgsl-skybox.ron │ │ │ ├── wgsl-6438-conflicting-idents.ron │ │ │ ├── wgsl-interpolate.ron │ │ │ ├── wgsl-push-constants.ron │ │ │ ├── wgsl-ray-query.ron │ │ │ ├── wgsl-storage-textures.ron │ │ │ ├── wgsl-interpolate_compat.ron │ │ │ ├── wgsl-fragment-output.ron │ │ │ ├── wgsl-ray-query-no-init-tracking.ron │ │ │ ├── spv-empty-global-name.hlsl │ │ │ ├── wgsl-atomicCompareExchange.ron │ │ │ ├── wgsl-atomicCompareExchange-int64.ron │ │ │ ├── wgsl-phony_assignment.hlsl │ │ │ ├── wgsl-f64.hlsl │ │ │ ├── wgsl-access.ron │ │ │ ├── wgsl-quad.ron │ │ │ ├── wgsl-shadow.ron │ │ │ ├── wgsl-texture-external.ron │ │ │ ├── spv-inv-hyperbolic-trig-functions.hlsl │ │ │ ├── wgsl-atomicTexture-int64.hlsl │ │ │ └── wgsl-dualsource.hlsl │ │ ├── wgsl │ │ │ ├── wgsl-empty.wgsl │ │ │ ├── wgsl-multiview.wgsl │ │ │ ├── wgsl-cross.wgsl │ │ │ ├── wgsl-const_assert.wgsl │ │ │ ├── glsl-896-push-constant.frag.wgsl │ │ │ ├── glsl-484-preprocessor-if.frag.wgsl │ │ │ ├── wgsl-barycentrics.wgsl │ │ │ ├── wgsl-empty-if.wgsl │ │ │ ├── glsl-277-casting.frag.wgsl │ │ │ ├── wgsl-6772-unpack-expr-accesses.wgsl │ │ │ ├── spv-subgroup-barrier.wgsl │ │ │ ├── glsl-901-lhs-field-select.frag.wgsl │ │ │ ├── wgsl-array-in-ctor.wgsl │ │ │ ├── wgsl-conversions.wgsl │ │ │ ├── wgsl-local-const.wgsl │ │ │ ├── glsl-global-constant-array.frag.wgsl │ │ │ ├── glsl-931-constant-emitting.frag.wgsl │ │ │ ├── glsl-280-matrix-cast.frag.wgsl │ │ │ ├── wgsl-select.wgsl │ │ │ ├── wgsl-7995-unicode-idents.wgsl │ │ │ ├── spv-empty-global-name.wgsl │ │ │ ├── wgsl-dualsource.wgsl │ │ │ ├── wgsl-atomicTexture-int64.wgsl │ │ │ ├── spv-inv-hyperbolic-trig-functions.wgsl │ │ │ ├── wgsl-clip-distances.wgsl │ │ │ ├── wgsl-type-alias.wgsl │ │ │ ├── glsl-anonymous-entry-point-type.frag.wgsl │ │ │ ├── wgsl-f64.wgsl │ │ │ ├── wgsl-phony_assignment.wgsl │ │ │ ├── wgsl-workgroup-var-init.wgsl │ │ │ ├── glsl-932-for-loop-if.frag.wgsl │ │ │ ├── spv-do-while.wgsl │ │ │ ├── wgsl-workgroup-uniform-load.wgsl │ │ │ ├── glsl-quad_glsl.frag.wgsl │ │ │ ├── wgsl-texture-arg.wgsl │ │ │ ├── spv-barrier.wgsl │ │ │ ├── wgsl-array-in-function-return-type.wgsl │ │ │ ├── spv-binding-arrays.dynamic.wgsl │ │ │ ├── wgsl-6438-conflicting-idents.wgsl │ │ │ ├── spv-binding-arrays.static.wgsl │ │ │ ├── wgsl-extra.wgsl │ │ │ ├── glsl-900-implicit-conversions.frag.wgsl │ │ │ └── glsl-clamp-splat.vert.wgsl │ │ ├── msl │ │ │ ├── wgsl-empty.msl │ │ │ ├── wgsl-cross.msl │ │ │ ├── wgsl-multiview.msl │ │ │ ├── wgsl-empty-if.msl │ │ │ ├── wgsl-conversions.msl │ │ │ ├── wgsl-array-in-ctor.msl │ │ │ ├── wgsl-6772-unpack-expr-accesses.msl │ │ │ ├── spv-subgroup-barrier.msl │ │ │ ├── wgsl-select.msl │ │ │ ├── wgsl-barycentrics.msl │ │ │ ├── wgsl-7995-unicode-idents.msl │ │ │ ├── spv-empty-global-name.msl │ │ │ ├── wgsl-phony_assignment.msl │ │ │ └── wgsl-atomicTexture-int64.msl │ │ ├── glsl │ │ │ ├── wgsl-invariant.fs.Fragment.glsl │ │ │ ├── wgsl-invariant.vs.Vertex.glsl │ │ │ ├── wgsl-empty.main.Compute.glsl │ │ │ ├── wgsl-early-depth-test-conservative.main.Fragment.glsl │ │ │ ├── wgsl-multiview.main.Fragment.glsl │ │ │ ├── wgsl-multiview_webgl.main.Fragment.glsl │ │ │ ├── wgsl-cross.main.Compute.glsl │ │ │ ├── wgsl-barycentrics.fs_main.Fragment.glsl │ │ │ ├── wgsl-force_point_size_vertex_shader_webgl.fs_main.Fragment.glsl │ │ │ ├── wgsl-early-depth-test-force.main.Fragment.glsl │ │ │ ├── wgsl-empty-if.comp.Compute.glsl │ │ │ ├── wgsl-conversions.main.Compute.glsl │ │ │ ├── wgsl-functions-webgl.main.Fragment.glsl │ │ │ ├── wgsl-6438-conflicting-idents.fs.Fragment.glsl │ │ │ ├── wgsl-quad.fs_extra.Fragment.glsl │ │ │ ├── spv-subgroup-barrier.main.Compute.glsl │ │ │ ├── wgsl-select.main.Compute.glsl │ │ │ ├── wgsl-array-in-ctor.cs_main.Compute.glsl │ │ │ ├── glsl-variations.frag.main.Fragment.glsl │ │ │ ├── wgsl-force_point_size_vertex_shader_webgl.vs_main.Vertex.glsl │ │ │ ├── wgsl-separate-entry-points.fragment.Fragment.glsl │ │ │ ├── wgsl-separate-entry-points.compute.Compute.glsl │ │ │ ├── wgsl-texture-arg.main.Fragment.glsl │ │ │ ├── wgsl-use-gl-ext-over-grad-workaround-if-instructed.main.Fragment.glsl │ │ │ ├── wgsl-7995-unicode-idents.main.Compute.glsl │ │ │ ├── wgsl-cubeArrayShadow.fragment.Fragment.glsl │ │ │ ├── wgsl-f64.main.Compute.glsl │ │ │ ├── wgsl-clip-distances.main.Vertex.glsl │ │ │ ├── wgsl-sample-cube-array-depth-lod.main.Fragment.glsl │ │ │ └── wgsl-6772-unpack-expr-accesses.main.Compute.glsl │ │ └── spv │ │ │ └── wgsl-empty.spvasm │ └── naga │ │ └── main.rs ├── xtask │ ├── .gitignore │ ├── src │ │ ├── fs.rs │ │ └── path.rs │ └── Cargo.toml ├── .gitattributes ├── fuzz │ ├── .gitignore │ ├── build.rs │ └── fuzz_targets │ │ ├── wgsl_parser.rs │ │ └── spv_parser.rs ├── .cargo │ └── config.toml ├── src │ ├── keywords │ │ └── mod.rs │ ├── common │ │ ├── wgsl │ │ │ └── mod.rs │ │ └── mod.rs │ └── back │ │ └── wgsl │ │ └── polyfill │ │ └── inverse │ │ ├── inverse_2x2_f16.wgsl │ │ └── inverse_2x2_f32.wgsl ├── .gitignore └── hlsl-snapshots │ └── Cargo.toml ├── taplo.toml ├── examples ├── standalone │ ├── 01_hello_compute │ │ ├── cargo-generate.toml │ │ └── Cargo.toml │ ├── 02_hello_window │ │ └── Cargo.toml │ └── custom_backend │ │ └── Cargo.toml └── features │ └── src │ ├── boids │ ├── screenshot.png │ └── README.md │ ├── cube │ ├── screenshot.png │ ├── screenshot-lines.png │ └── README.md │ ├── mipmap │ ├── screenshot.png │ ├── screenshot-query.png │ ├── screenshot_query.png │ └── README.md │ ├── shadow │ ├── screenshot.png │ └── README.md │ ├── skybox │ ├── screenshot.png │ ├── images │ │ ├── astc.ktx2 │ │ ├── bc7.ktx2 │ │ ├── etc2.ktx2 │ │ └── rgba8.ktx2 │ ├── screenshot_astc.png │ ├── screenshot_bc7.png │ ├── screenshot_etc2.png │ └── README.md │ ├── water │ └── screenshot.png │ ├── bunnymark │ ├── screenshot.png │ └── README.md │ ├── mesh_shader │ ├── screenshot.png │ └── README.md │ ├── msaa_line │ ├── screenshot.png │ ├── README.md │ └── shader.wgsl │ ├── ray_scene │ ├── screenshot.png │ ├── screenshot-vulkan.png │ └── cube.mtl │ ├── ray_shadows │ ├── screenshot.png │ └── README.md │ ├── hello_windows │ ├── screenshot.png │ └── README.md │ ├── storage_texture │ ├── example.png │ └── README.md │ ├── hello_triangle │ ├── screenshot.png │ ├── README.md │ └── shader.wgsl │ ├── ray_cube_compute │ ├── screenshot.png │ └── README.md │ ├── ray_cube_normals │ ├── screenshot.png │ └── README.md │ ├── srgb_blend │ ├── screenshot-srgb.png │ ├── screenshot-linear.png │ └── README.md │ ├── texture_arrays │ ├── screenshot.png │ └── README.md │ ├── uniform_values │ ├── screenshot1.png │ ├── screenshot2.png │ └── screenshot3.png │ ├── ray_cube_fragment │ ├── screenshot.png │ └── README.md │ ├── stencil_triangles │ ├── screenshot.png │ └── shader.wgsl │ ├── conservative_raster │ └── screenshot.png │ ├── ray_traced_triangle │ ├── screenshot.png │ └── README.md │ ├── multiple_render_targets │ └── screenshot.png │ ├── timestamp_queries │ └── README.md │ ├── render_to_texture │ ├── README.md │ └── shader.wgsl │ └── multiview │ └── shader.wgsl ├── logo.png ├── cts_runner └── revision.txt ├── .prettierignore ├── deno_webgpu ├── rustfmt.toml └── 00_init.js ├── docs ├── big-picture.png ├── render_coordinates.png └── texture_coordinates.png ├── player └── tests │ └── player │ └── data │ ├── empty.wgsl │ ├── quad.bin │ ├── data1.bin │ ├── zero-init-texture-binding.wgsl │ ├── zero-init-buffer-for-binding.wgsl │ ├── all.ron │ └── quad.wgsl ├── .gitattributes ├── tests ├── tests │ ├── wgpu-gpu │ │ ├── 3x3_colors.png │ │ ├── shader │ │ │ ├── compilation_messages │ │ │ │ └── error_shader.wgsl │ │ │ └── shader_test.wgsl │ │ ├── timestamp_normalization │ │ │ └── mod.rs │ │ ├── texture_binding │ │ │ ├── shader.wgsl │ │ │ └── single_scalar.wgsl │ │ ├── occlusion_query │ │ │ └── shader.wgsl │ │ ├── external_texture │ │ │ ├── dimensions.wgsl │ │ │ ├── load.wgsl │ │ │ └── sample.wgsl │ │ ├── shader_barycentric │ │ │ └── barycentric.wgsl │ │ ├── binding_array │ │ │ └── mod.rs │ │ ├── instance.rs │ │ ├── multiview │ │ │ └── shader.wgsl │ │ ├── shader_primitive_index │ │ │ └── primitive_index.wgsl │ │ ├── image_atomics │ │ │ ├── image_32_atomics.wgsl │ │ │ └── image_64_atomics.wgsl │ │ └── shader_view_format │ │ │ └── view_format.wgsl │ ├── wgpu-validation │ │ ├── main.rs │ │ └── api │ │ │ └── mod.rs │ └── wgpu-compile │ │ └── main.rs └── src │ └── poll.rs ├── rust-toolchain.toml ├── wgpu-hal ├── src │ ├── auxil │ │ └── dxgi │ │ │ └── mod.rs │ └── gles │ │ └── shaders │ │ ├── clear.frag │ │ ├── clear.vert │ │ └── srgb_present.vert └── examples │ └── raw-gles.em.html ├── .github ├── ISSUE_TEMPLATE │ ├── other.md │ └── config.yml └── actions │ └── install-warp │ └── action.yml ├── .cargo └── config.toml ├── wgpu-core ├── platform-deps │ ├── apple │ │ ├── README.md │ │ └── src │ │ │ └── lib.rs │ ├── wasm │ │ ├── README.md │ │ └── src │ │ │ └── lib.rs │ ├── emscripten │ │ ├── README.md │ │ └── src │ │ │ └── lib.rs │ └── windows-linux-android │ │ ├── README.md │ │ └── src │ │ └── lib.rs └── src │ └── command │ └── ffi.rs ├── wgpu-info └── src │ └── main.rs ├── clippy.toml ├── codecov.yml ├── wgpu-types └── src │ └── env.rs ├── lock-analyzer └── Cargo.toml └── wgpu-macros └── Cargo.toml /rustfmt.toml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /wgpu/src/macros/be-aligned.spv: -------------------------------------------------------------------------------- 1 | #"3D -------------------------------------------------------------------------------- /wgpu/src/macros/le-aligned.spv: -------------------------------------------------------------------------------- 1 | #D3" -------------------------------------------------------------------------------- /naga/tests/in/spv/degrees.toml: -------------------------------------------------------------------------------- 1 | targets = "" 2 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/must-use.toml: -------------------------------------------------------------------------------- 1 | targets = "IR" 2 | -------------------------------------------------------------------------------- /naga/xtask/.gitignore: -------------------------------------------------------------------------------- 1 | !Cargo.lock 2 | target/ 3 | -------------------------------------------------------------------------------- /naga/.gitattributes: -------------------------------------------------------------------------------- 1 | tests/naga/out/**/* text eol=lf 2 | -------------------------------------------------------------------------------- /naga/fuzz/.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | corpus 3 | artifacts 4 | -------------------------------------------------------------------------------- /naga/tests/in/glsl/spec-constant.toml: -------------------------------------------------------------------------------- 1 | targets = "WGSL" 2 | -------------------------------------------------------------------------------- /naga/tests/in/glsl/variations.toml: -------------------------------------------------------------------------------- 1 | targets = "GLSL" 2 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/hlsl-keyword.toml: -------------------------------------------------------------------------------- 1 | targets = "HLSL" 2 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/hlsl_mat_cx2.toml: -------------------------------------------------------------------------------- 1 | targets = "HLSL" 2 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/hlsl_mat_cx3.toml: -------------------------------------------------------------------------------- 1 | targets = "HLSL" 2 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/module-scope.toml: -------------------------------------------------------------------------------- 1 | targets = "WGSL" 2 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/msl-varyings.toml: -------------------------------------------------------------------------------- 1 | targets = "METAL" 2 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/template-list-ge.toml: -------------------------------------------------------------------------------- 1 | targets = "" 2 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/type-alias.toml: -------------------------------------------------------------------------------- 1 | targets = "WGSL" 2 | -------------------------------------------------------------------------------- /taplo.toml: -------------------------------------------------------------------------------- 1 | [formatting] 2 | indent_string = " " 3 | -------------------------------------------------------------------------------- /examples/standalone/01_hello_compute/cargo-generate.toml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gfx-rs/wgpu/HEAD/logo.png -------------------------------------------------------------------------------- /naga/tests/in/wgsl/const_assert.toml: -------------------------------------------------------------------------------- 1 | targets = "WGSL | IR" 2 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/cubeArrayShadow.toml: -------------------------------------------------------------------------------- 1 | targets = "GLSL" 2 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/diagnostic-filter.toml: -------------------------------------------------------------------------------- 1 | targets = "IR" 2 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/empty-if.toml: -------------------------------------------------------------------------------- 1 | [spv] 2 | version = [1, 6] 3 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/lexical-scopes.toml: -------------------------------------------------------------------------------- 1 | targets = "WGSL" 2 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/local-const.toml: -------------------------------------------------------------------------------- 1 | targets = "IR | WGSL" 2 | -------------------------------------------------------------------------------- /cts_runner/revision.txt: -------------------------------------------------------------------------------- 1 | 4a2a5384f318ef11dca7a3156b988dab1281b86d 2 | -------------------------------------------------------------------------------- /naga/tests/in/glsl/f16-glsl.toml: -------------------------------------------------------------------------------- 1 | capabilities = "SHADER_FLOAT16" 2 | -------------------------------------------------------------------------------- /naga/tests/in/spv/f16-spv.toml: -------------------------------------------------------------------------------- 1 | capabilities = "SHADER_FLOAT16" 2 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/6220-break-from-loop.toml: -------------------------------------------------------------------------------- 1 | targets = "SPIRV" 2 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/abstract-types-atomic.toml: -------------------------------------------------------------------------------- 1 | targets = "WGSL" 2 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/index-by-value.toml: -------------------------------------------------------------------------------- 1 | targets = "SPIRV | IR" 2 | -------------------------------------------------------------------------------- /naga/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [alias] 2 | xtask = "run -p naga-xtask --" 3 | -------------------------------------------------------------------------------- /naga/tests/in/glsl/896-push-constant.toml: -------------------------------------------------------------------------------- 1 | capabilities = "IMMEDIATES" 2 | -------------------------------------------------------------------------------- /naga/tests/in/glsl/vector-functions.toml: -------------------------------------------------------------------------------- 1 | capabilities = "FLOAT64" 2 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/7048-multiple-dynamic-1.toml: -------------------------------------------------------------------------------- 1 | targets = "SPIRV" 2 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/7048-multiple-dynamic-2.toml: -------------------------------------------------------------------------------- 1 | targets = "SPIRV" 2 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/7048-multiple-dynamic-3.toml: -------------------------------------------------------------------------------- 1 | targets = "SPIRV" 2 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/control-flow.toml: -------------------------------------------------------------------------------- 1 | [msl] 2 | lang_version = [1, 2] 3 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/template-list-trailing-comma.toml: -------------------------------------------------------------------------------- 1 | targets = "IR" 2 | -------------------------------------------------------------------------------- /naga/tests/in/glsl/bits.toml: -------------------------------------------------------------------------------- 1 | capabilities = "SHADER_FLOAT16_IN_FLOAT32" 2 | -------------------------------------------------------------------------------- /naga/tests/in/glsl/double-math-functions.toml: -------------------------------------------------------------------------------- 1 | capabilities = "FLOAT64" 2 | -------------------------------------------------------------------------------- /naga/tests/in/spv/quad-vert.toml: -------------------------------------------------------------------------------- 1 | targets = "METAL | GLSL | HLSL | WGSL" 2 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/empty.wgsl: -------------------------------------------------------------------------------- 1 | @compute @workgroup_size(1) 2 | fn main() {} 3 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/unconsumed_vertex_outputs_frag.toml: -------------------------------------------------------------------------------- 1 | targets = "HLSL" 2 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | **/*.frag 2 | **/*.vert 3 | naga/tests/in/ 4 | naga/tests/out/ 5 | -------------------------------------------------------------------------------- /deno_webgpu/rustfmt.toml: -------------------------------------------------------------------------------- 1 | max_width = 80 2 | tab_spaces = 2 3 | edition = "2021" 4 | -------------------------------------------------------------------------------- /naga/tests/in/glsl/800-out-of-bounds-panic.toml: -------------------------------------------------------------------------------- 1 | capabilities = "IMMEDIATES" 2 | -------------------------------------------------------------------------------- /naga/tests/in/spv/fetch_depth.toml: -------------------------------------------------------------------------------- 1 | targets = "IR | SPIRV | METAL | HLSL | WGSL" 2 | -------------------------------------------------------------------------------- /naga/tests/in/spv/gather.toml: -------------------------------------------------------------------------------- 1 | 2 | [spv-in] 3 | adjust_coordinate_space = true 4 | -------------------------------------------------------------------------------- /docs/big-picture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gfx-rs/wgpu/HEAD/docs/big-picture.png -------------------------------------------------------------------------------- /naga/tests/in/spv/gather-cmp.toml: -------------------------------------------------------------------------------- 1 | 2 | [spv-in] 3 | adjust_coordinate_space = true 4 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/abstract-types-const.toml: -------------------------------------------------------------------------------- 1 | targets = "SPIRV | METAL | GLSL | WGSL" 2 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/abstract-types-let.toml: -------------------------------------------------------------------------------- 1 | targets = "SPIRV | METAL | GLSL | WGSL" 2 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/abstract-types-var.toml: -------------------------------------------------------------------------------- 1 | targets = "SPIRV | METAL | GLSL | WGSL" 2 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/math-functions.toml: -------------------------------------------------------------------------------- 1 | capabilities = "SHADER_FLOAT16_IN_FLOAT32" 2 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/pointer-function-arg.toml: -------------------------------------------------------------------------------- 1 | targets = "METAL | GLSL | HLSL | WGSL" 2 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/sprite.toml: -------------------------------------------------------------------------------- 1 | targets = "SPIRV" 2 | 3 | [spv] 4 | version = [1, 4] 5 | -------------------------------------------------------------------------------- /naga/tests/in/spv/load-ms-texture.toml: -------------------------------------------------------------------------------- 1 | 2 | [spv-in] 3 | adjust_coordinate_space = true 4 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/abstract-types-builtins.toml: -------------------------------------------------------------------------------- 1 | targets = "SPIRV | METAL | GLSL | WGSL" 2 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/abstract-types-operators.toml: -------------------------------------------------------------------------------- 1 | targets = "SPIRV | METAL | GLSL | WGSL" 2 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/storage-textures.toml: -------------------------------------------------------------------------------- 1 | targets = "IR | ANALYSIS | SPIRV | METAL | HLSL" 2 | -------------------------------------------------------------------------------- /player/tests/player/data/empty.wgsl: -------------------------------------------------------------------------------- 1 | @compute 2 | @workgroup_size(1) 3 | fn main() { 4 | } 5 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/abstract-types-function-calls.toml: -------------------------------------------------------------------------------- 1 | targets = "SPIRV | METAL | GLSL | WGSL" 2 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/atomicCompareExchange.toml: -------------------------------------------------------------------------------- 1 | targets = "SPIRV | METAL | GLSL | HLSL | WGSL" 2 | -------------------------------------------------------------------------------- /docs/render_coordinates.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gfx-rs/wgpu/HEAD/docs/render_coordinates.png -------------------------------------------------------------------------------- /docs/texture_coordinates.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gfx-rs/wgpu/HEAD/docs/texture_coordinates.png -------------------------------------------------------------------------------- /naga/tests/in/wgsl/bits_downlevel.toml: -------------------------------------------------------------------------------- 1 | targets = "GLSL" 2 | 3 | [glsl] 4 | version.Desktop = 330 5 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/multiview.wgsl: -------------------------------------------------------------------------------- 1 | @fragment 2 | fn main(@builtin(view_index) view_index: u32) {} 3 | -------------------------------------------------------------------------------- /naga/tests/in/spv/builtin-accessed-outside-entrypoint.toml: -------------------------------------------------------------------------------- 1 | [spv-in] 2 | adjust_coordinate_space = true 3 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/multiview_webgl.wgsl: -------------------------------------------------------------------------------- 1 | @fragment 2 | fn main(@builtin(view_index) view_index: u32) {} 3 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/types_with_comments.toml: -------------------------------------------------------------------------------- 1 | targets = "IR" 2 | wgsl-in = { parse_doc_comments = true } 3 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-empty.hlsl: -------------------------------------------------------------------------------- 1 | [numthreads(1, 1, 1)] 2 | void main() 3 | { 4 | return; 5 | } 6 | -------------------------------------------------------------------------------- /naga/tests/in/spv/shadow.toml: -------------------------------------------------------------------------------- 1 | targets = "IR | ANALYSIS" 2 | 3 | [spv-in] 4 | adjust_coordinate_space = true 5 | -------------------------------------------------------------------------------- /naga/tests/in/spv/spec-constants.toml: -------------------------------------------------------------------------------- 1 | targets = "IR" 2 | 3 | [spv-in] 4 | adjust_coordinate_space = true 5 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/abstract-types-texture.toml: -------------------------------------------------------------------------------- 1 | targets = "METAL" 2 | 3 | [msl] 4 | lang_version = [1, 2] 5 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/early-depth-test-force.toml: -------------------------------------------------------------------------------- 1 | capabilities = "EARLY_DEPTH_TEST" 2 | targets = "SPIRV | GLSL" 3 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/shadow.toml: -------------------------------------------------------------------------------- 1 | [spv] 2 | adjust_coordinate_space = true 3 | debug = true 4 | version = [1, 2] 5 | -------------------------------------------------------------------------------- /naga/tests/out/wgsl/wgsl-empty.wgsl: -------------------------------------------------------------------------------- 1 | @compute @workgroup_size(1, 1, 1) 2 | fn main() { 3 | return; 4 | } 5 | -------------------------------------------------------------------------------- /player/tests/player/data/quad.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gfx-rs/wgpu/HEAD/player/tests/player/data/quad.bin -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.mtl binary 2 | *.obj binary 3 | wgpu/src/backend/webgpu/webgpu_sys/** linguist-generated=true 4 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/texture-arg.toml: -------------------------------------------------------------------------------- 1 | [spv] 2 | adjust_coordinate_space = true 3 | debug = true 4 | version = [1, 0] 5 | -------------------------------------------------------------------------------- /player/tests/player/data/data1.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gfx-rs/wgpu/HEAD/player/tests/player/data/data1.bin -------------------------------------------------------------------------------- /tests/tests/wgpu-gpu/3x3_colors.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gfx-rs/wgpu/HEAD/tests/tests/wgpu-gpu/3x3_colors.png -------------------------------------------------------------------------------- /naga/tests/in/spv/barrier.toml: -------------------------------------------------------------------------------- 1 | targets = "WGSL | SPIRV | GLSL | HLSL | METAL" 2 | 3 | [msl] 4 | lang_version = [2, 0] 5 | -------------------------------------------------------------------------------- /naga/tests/in/spv/spec-constants-issue-5598.toml: -------------------------------------------------------------------------------- 1 | targets = "GLSL" 2 | 3 | [spv-in] 4 | adjust_coordinate_space = true 5 | -------------------------------------------------------------------------------- /naga/tests/in/spv/do-while.toml: -------------------------------------------------------------------------------- 1 | targets = "METAL | GLSL | HLSL | WGSL" 2 | 3 | [spv-in] 4 | adjust_coordinate_space = true 5 | -------------------------------------------------------------------------------- /naga/tests/out/wgsl/wgsl-multiview.wgsl: -------------------------------------------------------------------------------- 1 | @fragment 2 | fn main(@builtin(view_index) view_index: u32) { 3 | return; 4 | } 5 | -------------------------------------------------------------------------------- /examples/features/src/boids/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gfx-rs/wgpu/HEAD/examples/features/src/boids/screenshot.png -------------------------------------------------------------------------------- /examples/features/src/cube/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gfx-rs/wgpu/HEAD/examples/features/src/cube/screenshot.png -------------------------------------------------------------------------------- /examples/features/src/mipmap/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gfx-rs/wgpu/HEAD/examples/features/src/mipmap/screenshot.png -------------------------------------------------------------------------------- /examples/features/src/shadow/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gfx-rs/wgpu/HEAD/examples/features/src/shadow/screenshot.png -------------------------------------------------------------------------------- /examples/features/src/skybox/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gfx-rs/wgpu/HEAD/examples/features/src/skybox/screenshot.png -------------------------------------------------------------------------------- /examples/features/src/water/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gfx-rs/wgpu/HEAD/examples/features/src/water/screenshot.png -------------------------------------------------------------------------------- /naga/tests/in/spv/empty-global-name.toml: -------------------------------------------------------------------------------- 1 | targets = "HLSL | WGSL | METAL" 2 | 3 | [spv-in] 4 | adjust_coordinate_space = true 5 | -------------------------------------------------------------------------------- /naga/tests/in/spv/inv-hyperbolic-trig-functions.toml: -------------------------------------------------------------------------------- 1 | targets = "HLSL | WGSL" 2 | 3 | [spv-in] 4 | adjust_coordinate_space = true 5 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/pointer-function-arg-restrict.toml: -------------------------------------------------------------------------------- 1 | targets = "METAL" 2 | 3 | [bounds_check_policies] 4 | index = "Restrict" 5 | -------------------------------------------------------------------------------- /naga/tests/naga/main.rs: -------------------------------------------------------------------------------- 1 | mod example_wgsl; 2 | mod snapshots; 3 | mod spirv_capabilities; 4 | mod validation; 5 | mod wgsl_errors; 6 | -------------------------------------------------------------------------------- /tests/tests/wgpu-gpu/shader/compilation_messages/error_shader.wgsl: -------------------------------------------------------------------------------- 1 | /*🐈🐈🐈🐈🐈🐈🐈*/? 2 | // Expected Error: invalid character found -------------------------------------------------------------------------------- /examples/features/src/skybox/images/astc.ktx2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gfx-rs/wgpu/HEAD/examples/features/src/skybox/images/astc.ktx2 -------------------------------------------------------------------------------- /examples/features/src/skybox/images/bc7.ktx2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gfx-rs/wgpu/HEAD/examples/features/src/skybox/images/bc7.ktx2 -------------------------------------------------------------------------------- /examples/features/src/skybox/images/etc2.ktx2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gfx-rs/wgpu/HEAD/examples/features/src/skybox/images/etc2.ktx2 -------------------------------------------------------------------------------- /naga/tests/in/wgsl/pointer-function-arg-rzsw.toml: -------------------------------------------------------------------------------- 1 | targets = "METAL" 2 | 3 | [bounds_check_policies] 4 | index = "ReadZeroSkipWrite" 5 | -------------------------------------------------------------------------------- /rust-toolchain.toml: -------------------------------------------------------------------------------- 1 | [toolchain] 2 | channel = "1.92" 3 | components = ["rustfmt", "clippy"] 4 | targets = ["wasm32-unknown-unknown"] 5 | -------------------------------------------------------------------------------- /examples/features/src/bunnymark/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gfx-rs/wgpu/HEAD/examples/features/src/bunnymark/screenshot.png -------------------------------------------------------------------------------- /examples/features/src/cube/screenshot-lines.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gfx-rs/wgpu/HEAD/examples/features/src/cube/screenshot-lines.png -------------------------------------------------------------------------------- /examples/features/src/mesh_shader/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gfx-rs/wgpu/HEAD/examples/features/src/mesh_shader/screenshot.png -------------------------------------------------------------------------------- /examples/features/src/msaa_line/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gfx-rs/wgpu/HEAD/examples/features/src/msaa_line/screenshot.png -------------------------------------------------------------------------------- /examples/features/src/ray_scene/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gfx-rs/wgpu/HEAD/examples/features/src/ray_scene/screenshot.png -------------------------------------------------------------------------------- /examples/features/src/ray_shadows/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gfx-rs/wgpu/HEAD/examples/features/src/ray_shadows/screenshot.png -------------------------------------------------------------------------------- /examples/features/src/skybox/images/rgba8.ktx2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gfx-rs/wgpu/HEAD/examples/features/src/skybox/images/rgba8.ktx2 -------------------------------------------------------------------------------- /examples/features/src/skybox/screenshot_astc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gfx-rs/wgpu/HEAD/examples/features/src/skybox/screenshot_astc.png -------------------------------------------------------------------------------- /examples/features/src/skybox/screenshot_bc7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gfx-rs/wgpu/HEAD/examples/features/src/skybox/screenshot_bc7.png -------------------------------------------------------------------------------- /examples/features/src/skybox/screenshot_etc2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gfx-rs/wgpu/HEAD/examples/features/src/skybox/screenshot_etc2.png -------------------------------------------------------------------------------- /naga/tests/in/spv/unnamed-gl-per-vertex.toml: -------------------------------------------------------------------------------- 1 | targets = "METAL | GLSL | HLSL | WGSL" 2 | 3 | [spv-in] 4 | adjust_coordinate_space = true 5 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/bits_downlevel_webgl.toml: -------------------------------------------------------------------------------- 1 | targets = "GLSL" 2 | 3 | [glsl] 4 | version.Embedded = { is_webgl = true, version = 300 } 5 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/separate-entry-points.toml: -------------------------------------------------------------------------------- 1 | targets = "SPIRV | GLSL" 2 | 3 | [spv] 4 | separate_entry_points = true 5 | version = [1, 0] 6 | -------------------------------------------------------------------------------- /examples/features/src/hello_windows/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gfx-rs/wgpu/HEAD/examples/features/src/hello_windows/screenshot.png -------------------------------------------------------------------------------- /examples/features/src/mipmap/screenshot-query.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gfx-rs/wgpu/HEAD/examples/features/src/mipmap/screenshot-query.png -------------------------------------------------------------------------------- /examples/features/src/mipmap/screenshot_query.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gfx-rs/wgpu/HEAD/examples/features/src/mipmap/screenshot_query.png -------------------------------------------------------------------------------- /examples/features/src/storage_texture/example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gfx-rs/wgpu/HEAD/examples/features/src/storage_texture/example.png -------------------------------------------------------------------------------- /naga/tests/in/wgsl/collatz.toml: -------------------------------------------------------------------------------- 1 | targets = "SPIRV | METAL | IR | ANALYSIS | HLSL | WGSL" 2 | 3 | [spv] 4 | debug = true 5 | version = [1, 0] 6 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-cross.hlsl: -------------------------------------------------------------------------------- 1 | [numthreads(1, 1, 1)] 2 | void main() 3 | { 4 | float3 a = float3(0.0, 0.0, 1.0); 5 | return; 6 | } 7 | -------------------------------------------------------------------------------- /wgpu-hal/src/auxil/dxgi/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod conv; 2 | pub mod exception; 3 | pub mod factory; 4 | pub mod name; 5 | pub mod result; 6 | pub mod time; 7 | -------------------------------------------------------------------------------- /examples/features/src/hello_triangle/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gfx-rs/wgpu/HEAD/examples/features/src/hello_triangle/screenshot.png -------------------------------------------------------------------------------- /examples/features/src/ray_cube_compute/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gfx-rs/wgpu/HEAD/examples/features/src/ray_cube_compute/screenshot.png -------------------------------------------------------------------------------- /examples/features/src/ray_cube_normals/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gfx-rs/wgpu/HEAD/examples/features/src/ray_cube_normals/screenshot.png -------------------------------------------------------------------------------- /examples/features/src/ray_scene/screenshot-vulkan.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gfx-rs/wgpu/HEAD/examples/features/src/ray_scene/screenshot-vulkan.png -------------------------------------------------------------------------------- /examples/features/src/srgb_blend/screenshot-srgb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gfx-rs/wgpu/HEAD/examples/features/src/srgb_blend/screenshot-srgb.png -------------------------------------------------------------------------------- /examples/features/src/texture_arrays/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gfx-rs/wgpu/HEAD/examples/features/src/texture_arrays/screenshot.png -------------------------------------------------------------------------------- /examples/features/src/uniform_values/screenshot1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gfx-rs/wgpu/HEAD/examples/features/src/uniform_values/screenshot1.png -------------------------------------------------------------------------------- /examples/features/src/uniform_values/screenshot2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gfx-rs/wgpu/HEAD/examples/features/src/uniform_values/screenshot2.png -------------------------------------------------------------------------------- /examples/features/src/uniform_values/screenshot3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gfx-rs/wgpu/HEAD/examples/features/src/uniform_values/screenshot3.png -------------------------------------------------------------------------------- /naga/tests/in/spv/binding-arrays.dynamic.toml: -------------------------------------------------------------------------------- 1 | capabilities = "TEXTURE_AND_SAMPLER_BINDING_ARRAY" 2 | 3 | [spv-in] 4 | adjust_coordinate_space = true 5 | -------------------------------------------------------------------------------- /naga/tests/in/spv/binding-arrays.static.toml: -------------------------------------------------------------------------------- 1 | capabilities = "TEXTURE_AND_SAMPLER_BINDING_ARRAY" 2 | 3 | [spv-in] 4 | adjust_coordinate_space = true 5 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/bits-optimized-msl.toml: -------------------------------------------------------------------------------- 1 | capabilities = "SHADER_FLOAT16_IN_FLOAT32" 2 | targets = "METAL" 3 | 4 | [msl] 5 | lang_version = [2, 1] 6 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/clip-distances.toml: -------------------------------------------------------------------------------- 1 | capabilities = "CLIP_DISTANCE" 2 | targets = "SPIRV | GLSL | WGSL" 3 | 4 | [glsl] 5 | version.Desktop = 330 6 | -------------------------------------------------------------------------------- /naga/tests/out/wgsl/wgsl-cross.wgsl: -------------------------------------------------------------------------------- 1 | @compute @workgroup_size(1, 1, 1) 2 | fn main() { 3 | let a = vec3(0f, 0f, 1f); 4 | return; 5 | } 6 | -------------------------------------------------------------------------------- /examples/features/src/ray_cube_fragment/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gfx-rs/wgpu/HEAD/examples/features/src/ray_cube_fragment/screenshot.png -------------------------------------------------------------------------------- /examples/features/src/srgb_blend/screenshot-linear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gfx-rs/wgpu/HEAD/examples/features/src/srgb_blend/screenshot-linear.png -------------------------------------------------------------------------------- /examples/features/src/stencil_triangles/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gfx-rs/wgpu/HEAD/examples/features/src/stencil_triangles/screenshot.png -------------------------------------------------------------------------------- /naga/tests/in/wgsl/bounds-check-restrict.toml: -------------------------------------------------------------------------------- 1 | targets = "SPIRV | METAL" 2 | 3 | [bounds_check_policies] 4 | index = "Restrict" 5 | buffer = "Restrict" 6 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/debug-symbol-simple.toml: -------------------------------------------------------------------------------- 1 | targets = "SPIRV" 2 | 3 | [spv] 4 | adjust_coordinate_space = false 5 | debug = true 6 | version = [1, 1] 7 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/debug-symbol-terrain.toml: -------------------------------------------------------------------------------- 1 | targets = "SPIRV" 2 | 3 | [spv] 4 | adjust_coordinate_space = false 5 | debug = true 6 | version = [1, 1] 7 | -------------------------------------------------------------------------------- /naga/tests/out/wgsl/wgsl-const_assert.wgsl: -------------------------------------------------------------------------------- 1 | const g_false: bool = false; 2 | 3 | @compute @workgroup_size(1, 1, 1) 4 | fn foo() { 5 | return; 6 | } 7 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/other.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Other 3 | about: Strange things you want to tell us 4 | title: '' 5 | labels: question 6 | assignees: '' 7 | --- 8 | -------------------------------------------------------------------------------- /examples/features/src/conservative_raster/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gfx-rs/wgpu/HEAD/examples/features/src/conservative_raster/screenshot.png -------------------------------------------------------------------------------- /examples/features/src/ray_traced_triangle/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gfx-rs/wgpu/HEAD/examples/features/src/ray_traced_triangle/screenshot.png -------------------------------------------------------------------------------- /naga/tests/in/glsl/global-constant-array.frag: -------------------------------------------------------------------------------- 1 | #version 450 core 2 | 3 | uint i; 4 | const float[2] array = { 1.0, 2.0 }; 5 | 6 | void main() { array[i]; } 7 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/debug-symbol-large-source.toml: -------------------------------------------------------------------------------- 1 | targets = "SPIRV" 2 | 3 | [spv] 4 | adjust_coordinate_space = false 5 | debug = true 6 | version = [1, 1] 7 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/early-depth-test-conservative.toml: -------------------------------------------------------------------------------- 1 | capabilities = "EARLY_DEPTH_TEST" 2 | targets = "SPIRV | GLSL" 3 | 4 | [glsl] 5 | version.Desktop = 420 6 | -------------------------------------------------------------------------------- /examples/features/src/multiple_render_targets/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gfx-rs/wgpu/HEAD/examples/features/src/multiple_render_targets/screenshot.png -------------------------------------------------------------------------------- /naga/tests/in/glsl/277-casting.frag: -------------------------------------------------------------------------------- 1 | // AUTHOR: Napokue 2 | // ISSUE: #277 3 | // FIX: #278 4 | #version 450 5 | 6 | void main() { 7 | float a = float(1); 8 | } 9 | -------------------------------------------------------------------------------- /naga/tests/in/glsl/280-matrix-cast.frag: -------------------------------------------------------------------------------- 1 | // AUTHOR: pjoe 2 | // ISSUE: #280 3 | // FIX: #898 4 | #version 450 5 | 6 | void main() { 7 | mat4 a = mat4(1); 8 | } 9 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/bounds-check-zero-atomic.toml: -------------------------------------------------------------------------------- 1 | targets = "METAL" 2 | 3 | [bounds_check_policies] 4 | index = "ReadZeroSkipWrite" 5 | buffer = "ReadZeroSkipWrite" 6 | -------------------------------------------------------------------------------- /tests/tests/wgpu-validation/main.rs: -------------------------------------------------------------------------------- 1 | //! Tests of the [`wgpu`] library API that are not run against a particular GPU. 2 | 3 | mod api; 4 | mod noop; 5 | mod util; 6 | -------------------------------------------------------------------------------- /naga/tests/in/spv/subgroup-barrier.toml: -------------------------------------------------------------------------------- 1 | capabilities = "SUBGROUP | SUBGROUP_BARRIER" 2 | targets = "WGSL | SPIRV | GLSL | METAL" 3 | 4 | [msl] 5 | lang_version = [2, 0] 6 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/barycentrics.wgsl: -------------------------------------------------------------------------------- 1 | @fragment 2 | fn fs_main(@builtin(barycentric) bary: vec3) -> @location(0) vec4 { 3 | return vec4(bary, 1.0); 4 | } 5 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/bounds-check-zero.toml: -------------------------------------------------------------------------------- 1 | targets = "SPIRV | METAL" 2 | 3 | [bounds_check_policies] 4 | index = "ReadZeroSkipWrite" 5 | buffer = "ReadZeroSkipWrite" 6 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/mesh-shader.toml: -------------------------------------------------------------------------------- 1 | capabilities = "MESH_SHADER" 2 | targets = "WGSL | SPIRV" 3 | 4 | [spv] 5 | version = [1, 4] 6 | capabilities = ["MeshShadingEXT"] 7 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/multiview.toml: -------------------------------------------------------------------------------- 1 | glsl_multiview = 2 2 | capabilities = "MULTIVIEW" 3 | 4 | [msl] 5 | lang_version = [2, 3] 6 | 7 | [hlsl] 8 | shader_model = "V6_1" 9 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/unconsumed_vertex_outputs_vert.toml: -------------------------------------------------------------------------------- 1 | fragment_module = { entry_point = "fs_main", path = "unconsumed_vertex_outputs_frag.wgsl" } 2 | targets = "HLSL" 3 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/early-depth-test-force.wgsl: -------------------------------------------------------------------------------- 1 | @fragment 2 | @early_depth_test(force) 3 | fn main() -> @location(0) vec4 { 4 | return vec4(0.4, 0.3, 0.2, 0.1); 5 | } -------------------------------------------------------------------------------- /naga/tests/in/wgsl/mesh-shader-empty.toml: -------------------------------------------------------------------------------- 1 | capabilities = "MESH_SHADER" 2 | targets = "WGSL | SPIRV" 3 | 4 | [spv] 5 | version = [1, 4] 6 | capabilities = ["MeshShadingEXT"] 7 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/mesh-shader-lines.toml: -------------------------------------------------------------------------------- 1 | capabilities = "MESH_SHADER" 2 | targets = "WGSL | SPIRV" 3 | 4 | [spv] 5 | version = [1, 4] 6 | capabilities = ["MeshShadingEXT"] 7 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-empty-if.hlsl: -------------------------------------------------------------------------------- 1 | [numthreads(1, 1, 1)] 2 | void comp(uint3 id : SV_DispatchThreadID) 3 | { 4 | if ((id.x == 0u)) { 5 | } 6 | return; 7 | } 8 | -------------------------------------------------------------------------------- /naga/tests/out/wgsl/glsl-896-push-constant.frag.wgsl: -------------------------------------------------------------------------------- 1 | fn main_1() { 2 | return; 3 | } 4 | 5 | @fragment 6 | fn main() { 7 | main_1(); 8 | return; 9 | } 10 | -------------------------------------------------------------------------------- /naga/tests/in/glsl/clamp-splat.vert: -------------------------------------------------------------------------------- 1 | #version 450 2 | layout(location = 0) in vec2 a_pos; 3 | 4 | void main() { 5 | gl_Position = vec4(clamp(a_pos, 0.0, 1.0), 0.0, 1.0); 6 | } 7 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/functions-webgl.toml: -------------------------------------------------------------------------------- 1 | targets = "GLSL" 2 | 3 | [glsl] 4 | version.Embedded = { is_webgl = false, version = 320 } 5 | zero_initialize_workgroup_memory = true 6 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/pointers.toml: -------------------------------------------------------------------------------- 1 | bounds_check_policies = [] 2 | targets = "SPIRV | WGSL" 3 | 4 | [spv] 5 | adjust_coordinate_space = false 6 | debug = true 7 | version = [1, 2] 8 | -------------------------------------------------------------------------------- /naga/tests/out/wgsl/glsl-484-preprocessor-if.frag.wgsl: -------------------------------------------------------------------------------- 1 | fn main_1() { 2 | return; 3 | } 4 | 5 | @fragment 6 | fn main() { 7 | main_1(); 8 | return; 9 | } 10 | -------------------------------------------------------------------------------- /naga/tests/out/wgsl/wgsl-barycentrics.wgsl: -------------------------------------------------------------------------------- 1 | @fragment 2 | fn fs_main(@builtin(barycentric) bary: vec3) -> @location(0) vec4 { 3 | return vec4(bary, 1f); 4 | } 5 | -------------------------------------------------------------------------------- /tests/tests/wgpu-gpu/timestamp_normalization/mod.rs: -------------------------------------------------------------------------------- 1 | mod utils; 2 | 3 | pub fn all_tests(tests: &mut Vec) { 4 | utils::all_tests(tests); 5 | } 6 | -------------------------------------------------------------------------------- /naga/tests/in/glsl/dual-source-blending.toml: -------------------------------------------------------------------------------- 1 | # TODO(https://github.com/gfx-rs/wgpu/issues/8154): enable only `DUAL_SOURCE_BLENDING` capability 2 | capabilities = "DUAL_SOURCE_BLENDING" 3 | -------------------------------------------------------------------------------- /naga/tests/in/glsl/local-var-init-in-loop.comp: -------------------------------------------------------------------------------- 1 | void main() { 2 | vec4 sum = vec4(0); 3 | for (int i = 0; i < 4; i++) { 4 | vec4 a = vec4(1); 5 | sum += a; 6 | } 7 | } -------------------------------------------------------------------------------- /naga/tests/in/wgsl/6772-unpack-expr-accesses.wgsl: -------------------------------------------------------------------------------- 1 | @compute @workgroup_size(1, 1) 2 | fn main() { 3 | let idx = 2; 4 | _ = unpack4xI8(12u)[idx]; 5 | _ = unpack4xU8(12u)[1]; 6 | } 7 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-hlsl-keyword.hlsl: -------------------------------------------------------------------------------- 1 | float4 fs_main() : SV_Target0 2 | { 3 | float4 Pass_ = float4(1.0, 1.0, 1.0, 1.0); 4 | 5 | float4 _e6 = Pass_; 6 | return _e6; 7 | } 8 | -------------------------------------------------------------------------------- /naga/tests/in/glsl/932-for-loop-if.frag: -------------------------------------------------------------------------------- 1 | // AUTHOR: jakobhellermann 2 | // ISSUE: #932 3 | // FIX: #935 4 | #version 450 5 | 6 | void main() { 7 | for (int i = 0; i < 1; i += 1) {} 8 | } 9 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/invariant.toml: -------------------------------------------------------------------------------- 1 | targets = "GLSL" 2 | 3 | [glsl] 4 | version.Embedded = { is_webgl = true, version = 300 } 5 | writer_flags = "" 6 | zero_initialize_workgroup_memory = true 7 | -------------------------------------------------------------------------------- /naga/tests/out/wgsl/wgsl-empty-if.wgsl: -------------------------------------------------------------------------------- 1 | @compute @workgroup_size(1, 1, 1) 2 | fn comp(@builtin(global_invocation_id) id: vec3) { 3 | if (id.x == 0u) { 4 | } 5 | return; 6 | } 7 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/overrides-atomicCompareExchangeWeak.toml: -------------------------------------------------------------------------------- 1 | pipeline_constants = { o = 2.0 } 2 | targets = "IR | SPIRV | METAL" 3 | 4 | [spv] 5 | separate_entry_points = true 6 | version = [1, 0] 7 | -------------------------------------------------------------------------------- /naga/tests/in/glsl/901-lhs-field-select.frag: -------------------------------------------------------------------------------- 1 | // AUTHOR: JCapucho 2 | // ISSUE: #901 3 | // FIX: #948 4 | #version 450 5 | 6 | void main() { 7 | vec4 a = vec4(1.0); 8 | a.x = 2.0; 9 | } 10 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/early-depth-test-conservative.wgsl: -------------------------------------------------------------------------------- 1 | @fragment 2 | @early_depth_test(less_equal) 3 | fn main(@builtin(position) pos: vec4) -> @builtin(frag_depth) f32 { 4 | return pos.z - 0.1; 5 | } -------------------------------------------------------------------------------- /naga/tests/in/wgsl/mesh-shader-points.toml: -------------------------------------------------------------------------------- 1 | capabilities = "MESH_SHADER | MESH_SHADER_POINT_TOPOLOGY" 2 | targets = "WGSL | SPIRV" 3 | 4 | [spv] 5 | version = [1, 4] 6 | capabilities = ["MeshShadingEXT"] 7 | -------------------------------------------------------------------------------- /naga/tests/out/wgsl/glsl-277-casting.frag.wgsl: -------------------------------------------------------------------------------- 1 | fn main_1() { 2 | var a: f32 = 1f; 3 | 4 | return; 5 | } 6 | 7 | @fragment 8 | fn main() { 9 | main_1(); 10 | return; 11 | } 12 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/barycentrics.toml: -------------------------------------------------------------------------------- 1 | capabilities = "SHADER_BARYCENTRICS" 2 | 3 | [msl] 4 | lang_version = [2, 3] 5 | 6 | [hlsl] 7 | shader_model = "V6_1" 8 | 9 | [glsl] 10 | version.Desktop = 450 11 | -------------------------------------------------------------------------------- /naga/tests/in/glsl/anonymous-entry-point-type.frag: -------------------------------------------------------------------------------- 1 | layout(location = 0) out vec4 o_Target; 2 | 3 | struct FragmentOutput { 4 | float x; 5 | }; 6 | 7 | void main() { 8 | o_Target = vec4(0.0); 9 | } 10 | -------------------------------------------------------------------------------- /naga/tests/out/msl/wgsl-empty.msl: -------------------------------------------------------------------------------- 1 | // language: metal1.0 2 | #include 3 | #include 4 | 5 | using metal::uint; 6 | 7 | 8 | kernel void main_( 9 | ) { 10 | return; 11 | } 12 | -------------------------------------------------------------------------------- /naga/tests/out/wgsl/wgsl-6772-unpack-expr-accesses.wgsl: -------------------------------------------------------------------------------- 1 | @compute @workgroup_size(1, 1, 1) 2 | fn main() { 3 | let phony = unpack4xI8(12u)[2i]; 4 | let phony_1 = unpack4xU8(12u).y; 5 | return; 6 | } 7 | -------------------------------------------------------------------------------- /tests/tests/wgpu-gpu/texture_binding/shader.wgsl: -------------------------------------------------------------------------------- 1 | @group(0) @binding(0) 2 | var tex: texture_storage_2d; 3 | 4 | @compute @workgroup_size(1) fn csStore() { 5 | _ = textureLoad(tex, vec2u(0)); 6 | } -------------------------------------------------------------------------------- /naga/tests/in/wgsl/hlsl-keyword.wgsl: -------------------------------------------------------------------------------- 1 | @fragment 2 | fn fs_main() -> @location(0) vec4f { 3 | // Make sure case-insensitive keywords are escaped in HLSL. 4 | var Pass = vec4(1.0,1.0,1.0,1.0); 5 | return Pass; 6 | } -------------------------------------------------------------------------------- /naga/tests/in/wgsl/invariant.wgsl: -------------------------------------------------------------------------------- 1 | @vertex 2 | fn vs() -> @builtin(position) @invariant vec4 { 3 | return vec4(0.0); 4 | } 5 | 6 | @fragment 7 | fn fs(@builtin(position) @invariant position: vec4) { } 8 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/overrides-atomicCompareExchangeWeak.wgsl: -------------------------------------------------------------------------------- 1 | override o: i32; 2 | var a: atomic; 3 | 4 | @compute @workgroup_size(1) 5 | fn f() { 6 | atomicCompareExchangeWeak(&a, u32(o), 1u); 7 | } 8 | -------------------------------------------------------------------------------- /naga/src/keywords/mod.rs: -------------------------------------------------------------------------------- 1 | /*! 2 | Lists of reserved keywords for each shading language with a [frontend][crate::front] or [backend][crate::back]. 3 | */ 4 | 5 | #[cfg(any(feature = "wgsl-in", wgsl_out))] 6 | pub mod wgsl; 7 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/overrides.toml: -------------------------------------------------------------------------------- 1 | pipeline_constants = { 0 = nan, 1300 = 1.1, depth = 2.3 } 2 | targets = "IR | ANALYSIS | SPIRV | METAL | HLSL | GLSL" 3 | 4 | [spv] 5 | separate_entry_points = true 6 | version = [1, 0] 7 | -------------------------------------------------------------------------------- /examples/features/src/bunnymark/README.md: -------------------------------------------------------------------------------- 1 | # bunnymark 2 | 3 | 4 | ## To Run 5 | 6 | ``` 7 | cargo run --bin wgpu-examples bunnymark 8 | ``` 9 | 10 | ## Example output 11 | 12 | ![Example output](./screenshot.png) 13 | -------------------------------------------------------------------------------- /naga/tests/in/spv/binding-arrays.runtime.toml: -------------------------------------------------------------------------------- 1 | capabilities = """ 2 | TEXTURE_AND_SAMPLER_BINDING_ARRAY 3 | | TEXTURE_AND_SAMPLER_BINDING_ARRAY_NON_UNIFORM_INDEXING 4 | """ 5 | 6 | [spv-in] 7 | adjust_coordinate_space = true 8 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/conversion-float-to-int-no-f64.toml: -------------------------------------------------------------------------------- 1 | # Other backends are tested by conversion-float-to-int.wgsl which is a 2 | # superset of this test. 3 | targets = "METAL" 4 | capabilities = "SHADER_FLOAT16 | SHADER_INT64" 5 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/cross.wgsl: -------------------------------------------------------------------------------- 1 | // NOTE: invalid combinations are tested in the `validation::bad_cross_builtin_args` test. 2 | @compute @workgroup_size(1) fn main() { 3 | let a = cross(vec3(1., 0., 0.), vec3(0., 1., 0.)); 4 | } 5 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/dualsource.toml: -------------------------------------------------------------------------------- 1 | capabilities = "DUAL_SOURCE_BLENDING" 2 | 3 | [msl] 4 | fake_missing_bindings = false 5 | lang_version = [1, 2] 6 | spirv_cross_compatibility = false 7 | zero_initialize_workgroup_memory = true 8 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/f64.toml: -------------------------------------------------------------------------------- 1 | capabilities = "FLOAT64" 2 | targets = "SPIRV | GLSL | HLSL | WGSL" 3 | 4 | [glsl] 5 | version.Desktop = 420 6 | zero_initialize_workgroup_memory = true 7 | 8 | [spv] 9 | version = [1, 0] 10 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/multiview_webgl.toml: -------------------------------------------------------------------------------- 1 | glsl_multiview = 2 2 | capabilities = "MULTIVIEW" 3 | targets = "GLSL" 4 | 5 | [glsl] 6 | version.Embedded = { is_webgl = true, version = 300 } 7 | zero_initialize_workgroup_memory = true 8 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/sample-cube-array-depth-lod.toml: -------------------------------------------------------------------------------- 1 | targets = "GLSL" 2 | 3 | [glsl] 4 | version.Embedded = { is_webgl = false, version = 320 } 5 | writer_flags = "TEXTURE_SHADOW_LOD" 6 | zero_initialize_workgroup_memory = true 7 | -------------------------------------------------------------------------------- /naga/tests/out/glsl/wgsl-invariant.fs.Fragment.glsl: -------------------------------------------------------------------------------- 1 | #version 300 es 2 | 3 | precision highp float; 4 | precision highp int; 5 | 6 | 7 | void main() { 8 | vec4 position = gl_FragCoord; 9 | return; 10 | } 11 | 12 | -------------------------------------------------------------------------------- /wgpu/src/util/panicking.rs: -------------------------------------------------------------------------------- 1 | #[cfg(feature = "std")] 2 | pub fn is_panicking() -> bool { 3 | std::thread::panicking() 4 | } 5 | 6 | #[cfg(not(feature = "std"))] 7 | pub fn is_panicking() -> bool { 8 | false 9 | } 10 | -------------------------------------------------------------------------------- /examples/features/src/texture_arrays/README.md: -------------------------------------------------------------------------------- 1 | # texture_arrays 2 | 3 | ## To Run 4 | 5 | ``` 6 | cargo run --bin wgpu-examples texture_arrays 7 | ``` 8 | 9 | ## Example Output 10 | 11 | ![Example output](./screenshot.png) -------------------------------------------------------------------------------- /naga/tests/in/glsl/896-push-constant.frag: -------------------------------------------------------------------------------- 1 | // AUTHOR: Foltik 2 | // ISSUE: #896 3 | // FIX: #897 4 | #version 450 5 | 6 | layout(push_constant) uniform PushConstants { 7 | float example; 8 | } c; 9 | 10 | void main() {} 11 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/array-in-ctor.wgsl: -------------------------------------------------------------------------------- 1 | struct Ah { 2 | inner: array, 3 | }; 4 | @group(0) @binding(0) 5 | var ah: Ah; 6 | 7 | @compute @workgroup_size(1) 8 | fn cs_main() { 9 | let ah = ah; 10 | } 11 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/force_point_size_vertex_shader_webgl.toml: -------------------------------------------------------------------------------- 1 | targets = "GLSL" 2 | 3 | [glsl] 4 | version.Embedded = { is_webgl = true, version = 300 } 5 | writer_flags = "FORCE_POINT_SIZE" 6 | zero_initialize_workgroup_memory = true 7 | -------------------------------------------------------------------------------- /naga/tests/out/wgsl/spv-subgroup-barrier.wgsl: -------------------------------------------------------------------------------- 1 | fn function() { 2 | subgroupBarrier(); 3 | subgroupBarrier(); 4 | return; 5 | } 6 | 7 | @compute @workgroup_size(64, 1, 1) 8 | fn main() { 9 | function(); 10 | } 11 | -------------------------------------------------------------------------------- /deno_webgpu/00_init.js: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2025 the Deno authors. MIT license. 2 | 3 | import { core } from "ext:core/mod.js"; 4 | 5 | const loadWebGPU = core.createLazyLoader("ext:deno_webgpu/01_webgpu.js"); 6 | 7 | export { loadWebGPU }; 8 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/policy-mix.toml: -------------------------------------------------------------------------------- 1 | targets = "SPIRV | METAL" 2 | 3 | [bounds_check_policies] 4 | index = "Restrict" 5 | buffer = "Unchecked" 6 | image_load = "ReadZeroSkipWrite" 7 | 8 | [spv] 9 | debug = true 10 | version = [1, 1] 11 | -------------------------------------------------------------------------------- /naga/tests/out/wgsl/glsl-901-lhs-field-select.frag.wgsl: -------------------------------------------------------------------------------- 1 | fn main_1() { 2 | var a: vec4 = vec4(1f); 3 | 4 | a.x = 2f; 5 | return; 6 | } 7 | 8 | @fragment 9 | fn main() { 10 | main_1(); 11 | return; 12 | } 13 | -------------------------------------------------------------------------------- /wgpu-hal/src/gles/shaders/clear.frag: -------------------------------------------------------------------------------- 1 | uniform vec4 color; 2 | //Hack: Some WebGL implementations don't find "color" otherwise. 3 | uniform vec4 color_workaround; 4 | out vec4 frag; 5 | void main() { 6 | frag = color + color_workaround; 7 | } 8 | -------------------------------------------------------------------------------- /.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [alias] 2 | xtask = "run -p wgpu-xtask --" 3 | 4 | # Needed until https://github.com/rust-random/getrandom/issues/675 is resolved. 5 | [target.wasm32-unknown-unknown] 6 | rustflags = ["--cfg", "getrandom_backend=\"wasm_js\""] 7 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: Question about wgpu 4 | url: https://github.com/gfx-rs/wgpu/discussions/new/choose 5 | about: Any questions about how to use wgpu should go here. 6 | -------------------------------------------------------------------------------- /examples/features/src/timestamp_queries/README.md: -------------------------------------------------------------------------------- 1 | # timestamp_queries 2 | 3 | This example shows various ways of querying time when supported. 4 | 5 | ## To Run 6 | 7 | ``` 8 | cargo run --bin wgpu-examples timestamp_queries 9 | ``` 10 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/7048-multiple-dynamic-1.wgsl: -------------------------------------------------------------------------------- 1 | @compute @workgroup_size(1) 2 | fn f() { 3 | let b = array(); 4 | var poly = vec4f(0); 5 | var k = 0; 6 | var j = 0; 7 | 8 | poly.x += b[j].y * b[k].z; 9 | } 10 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/use-gl-ext-over-grad-workaround-if-instructed.toml: -------------------------------------------------------------------------------- 1 | targets = "GLSL" 2 | 3 | [glsl] 4 | version.Embedded = { is_webgl = false, version = 320 } 5 | writer_flags = "TEXTURE_SHADOW_LOD" 6 | zero_initialize_workgroup_memory = true 7 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/spv-barrier.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ], 6 | compute:[ 7 | ( 8 | entry_point:"main", 9 | target_profile:"cs_5_1", 10 | ), 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-bits.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ], 6 | compute:[ 7 | ( 8 | entry_point:"main", 9 | target_profile:"cs_5_1", 10 | ), 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-boids.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ], 6 | compute:[ 7 | ( 8 | entry_point:"main", 9 | target_profile:"cs_5_1", 10 | ), 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-cross.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ], 6 | compute:[ 7 | ( 8 | entry_point:"main", 9 | target_profile:"cs_5_1", 10 | ), 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-empty.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ], 6 | compute:[ 7 | ( 8 | entry_point:"main", 9 | target_profile:"cs_5_1", 10 | ), 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-f16.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ], 6 | compute:[ 7 | ( 8 | entry_point:"main", 9 | target_profile:"cs_6_2", 10 | ), 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-f64.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ], 6 | compute:[ 7 | ( 8 | entry_point:"main", 9 | target_profile:"cs_5_1", 10 | ), 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-int64.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ], 6 | compute:[ 7 | ( 8 | entry_point:"main", 9 | target_profile:"cs_6_0", 10 | ), 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-select.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ], 6 | compute:[ 7 | ( 8 | entry_point:"main", 9 | target_profile:"cs_5_1", 10 | ), 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /examples/features/src/cube/README.md: -------------------------------------------------------------------------------- 1 | # cube 2 | 3 | This example renders a textured cube. 4 | 5 | ## To Run 6 | 7 | ``` 8 | cargo run --bin wgpu-examples cube 9 | ``` 10 | 11 | ## Screenshots 12 | 13 | ![Cube example](./screenshot.png) 14 | -------------------------------------------------------------------------------- /naga/tests/out/glsl/wgsl-invariant.vs.Vertex.glsl: -------------------------------------------------------------------------------- 1 | #version 300 es 2 | 3 | precision highp float; 4 | precision highp int; 5 | 6 | invariant gl_Position; 7 | 8 | void main() { 9 | gl_Position = vec4(0.0); 10 | return; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/spv-do-while.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ( 6 | entry_point:"main", 7 | target_profile:"ps_5_1", 8 | ), 9 | ], 10 | compute:[ 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/spv-quad-vert.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ( 4 | entry_point:"main", 5 | target_profile:"vs_5_1", 6 | ), 7 | ], 8 | fragment:[ 9 | ], 10 | compute:[ 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-bitcast.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ], 6 | compute:[ 7 | ( 8 | entry_point:"main", 9 | target_profile:"cs_5_1", 10 | ), 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-break-if.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ], 6 | compute:[ 7 | ( 8 | entry_point:"main", 9 | target_profile:"cs_5_1", 10 | ), 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-collatz.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ], 6 | compute:[ 7 | ( 8 | entry_point:"main", 9 | target_profile:"cs_5_1", 10 | ), 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-const-exprs.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ], 6 | compute:[ 7 | ( 8 | entry_point:"main", 9 | target_profile:"cs_5_1", 10 | ), 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-conversions.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ], 6 | compute:[ 7 | ( 8 | entry_point:"main", 9 | target_profile:"cs_5_1", 10 | ), 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-dualsource.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ( 6 | entry_point:"main", 7 | target_profile:"ps_5_1", 8 | ), 9 | ], 10 | compute:[ 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-empty-if.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ], 6 | compute:[ 7 | ( 8 | entry_point:"comp", 9 | target_profile:"cs_5_1", 10 | ), 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-functions.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ], 6 | compute:[ 7 | ( 8 | entry_point:"main", 9 | target_profile:"cs_5_1", 10 | ), 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-globals.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ], 6 | compute:[ 7 | ( 8 | entry_point:"main", 9 | target_profile:"cs_5_1", 10 | ), 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-multiview.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ( 6 | entry_point:"main", 7 | target_profile:"ps_6_1", 8 | ), 9 | ], 10 | compute:[ 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-operators.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ], 6 | compute:[ 7 | ( 8 | entry_point:"main", 9 | target_profile:"cs_5_1", 10 | ), 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-overrides.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ], 6 | compute:[ 7 | ( 8 | entry_point:"main", 9 | target_profile:"cs_5_1", 10 | ), 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-padding.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ( 4 | entry_point:"vertex", 5 | target_profile:"vs_5_1", 6 | ), 7 | ], 8 | fragment:[ 9 | ], 10 | compute:[ 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-texture-arg.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ( 6 | entry_point:"main", 7 | target_profile:"ps_5_1", 8 | ), 9 | ], 10 | compute:[ 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/empty-if.wgsl: -------------------------------------------------------------------------------- 1 | @workgroup_size(1) 2 | @compute 3 | fn comp(@builtin(global_invocation_id) id: vec3) { 4 | if (id.x == 0) { 5 | 6 | } 7 | _ = 1+1; // otherwise, naga generates returns in the if statement. 8 | return; 9 | } -------------------------------------------------------------------------------- /naga/tests/out/hlsl/spv-empty-global-name.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ], 6 | compute:[ 7 | ( 8 | entry_point:"main", 9 | target_profile:"cs_5_1", 10 | ), 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-array-in-ctor.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ], 6 | compute:[ 7 | ( 8 | entry_point:"cs_main", 9 | target_profile:"cs_5_1", 10 | ), 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-atomicOps.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ], 6 | compute:[ 7 | ( 8 | entry_point:"cs_main", 9 | target_profile:"cs_5_1", 10 | ), 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-atomicTexture.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ], 6 | compute:[ 7 | ( 8 | entry_point:"cs_main", 9 | target_profile:"cs_5_1", 10 | ), 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-barycentrics.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ( 6 | entry_point:"fs_main", 7 | target_profile:"ps_6_1", 8 | ), 9 | ], 10 | compute:[ 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-binding-arrays.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ( 6 | entry_point:"main", 7 | target_profile:"ps_5_1", 8 | ), 9 | ], 10 | compute:[ 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-constructors.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ], 6 | compute:[ 7 | ( 8 | entry_point:"main", 9 | target_profile:"cs_5_1", 10 | ), 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-control-flow.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ], 6 | compute:[ 7 | ( 8 | entry_point:"main", 9 | target_profile:"cs_5_1", 10 | ), 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-conversions.hlsl: -------------------------------------------------------------------------------- 1 | static const float2 ic0_ = float2(2.0, 2.0); 2 | 3 | [numthreads(1, 1, 1)] 4 | void main() 5 | { 6 | float2 vc0_ = float2(2.0, 2.0); 7 | 8 | float2 lc0_ = float2(2.0, 2.0); 9 | return; 10 | } 11 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-hlsl-keyword.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ( 6 | entry_point:"fs_main", 7 | target_profile:"ps_5_1", 8 | ), 9 | ], 10 | compute:[ 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-hlsl_mat_cx2.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ], 6 | compute:[ 7 | ( 8 | entry_point:"main", 9 | target_profile:"cs_5_1", 10 | ), 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-hlsl_mat_cx3.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ], 6 | compute:[ 7 | ( 8 | entry_point:"main", 9 | target_profile:"cs_5_1", 10 | ), 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-math-functions.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ( 6 | entry_point:"main", 7 | target_profile:"ps_5_1", 8 | ), 9 | ], 10 | compute:[ 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-phony_assignment.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ], 6 | compute:[ 7 | ( 8 | entry_point:"main", 9 | target_profile:"cs_5_1", 10 | ), 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-standard.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ( 6 | entry_point:"derivatives", 7 | target_profile:"ps_5_1", 8 | ), 9 | ], 10 | compute:[ 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-type-inference.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ], 6 | compute:[ 7 | ( 8 | entry_point:"main", 9 | target_profile:"cs_5_1", 10 | ), 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/glsl/wgsl-empty.main.Compute.glsl: -------------------------------------------------------------------------------- 1 | #version 310 es 2 | 3 | precision highp float; 4 | precision highp int; 5 | 6 | layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; 7 | 8 | 9 | void main() { 10 | return; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/spv-subgroup-operations-s.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ], 6 | compute:[ 7 | ( 8 | entry_point:"main", 9 | target_profile:"cs_6_0", 10 | ), 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/spv-unnamed-gl-per-vertex.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ( 4 | entry_point:"main", 5 | target_profile:"vs_5_1", 6 | ), 7 | ], 8 | fragment:[ 9 | ], 10 | compute:[ 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-7995-unicode-idents.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ], 6 | compute:[ 7 | ( 8 | entry_point:"main", 9 | target_profile:"cs_5_1", 10 | ), 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-abstract-types-return.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ], 6 | compute:[ 7 | ( 8 | entry_point:"main", 9 | target_profile:"cs_5_1", 10 | ), 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-atomicOps-int64.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ], 6 | compute:[ 7 | ( 8 | entry_point:"cs_main", 9 | target_profile:"cs_6_6", 10 | ), 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-functions-unoptimized.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ], 6 | compute:[ 7 | ( 8 | entry_point:"main", 9 | target_profile:"cs_6_3", 10 | ), 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-pointer-function-arg.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ], 6 | compute:[ 7 | ( 8 | entry_point:"main", 9 | target_profile:"cs_5_1", 10 | ), 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-subgroup-operations.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ], 6 | compute:[ 7 | ( 8 | entry_point:"main", 9 | target_profile:"cs_6_0", 10 | ), 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-workgroup-var-init.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ], 6 | compute:[ 7 | ( 8 | entry_point:"main", 9 | target_profile:"cs_5_1", 10 | ), 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /examples/features/src/boids/README.md: -------------------------------------------------------------------------------- 1 | # boids 2 | 3 | Flocking boids example with gpu compute update pass 4 | 5 | ## To Run 6 | 7 | ``` 8 | cargo run --bin wgpu-examples boids 9 | ``` 10 | 11 | ## Screenshots 12 | 13 | ![Boids example](./screenshot.png) 14 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/interpolate_compat.toml: -------------------------------------------------------------------------------- 1 | [glsl] 2 | version.Desktop = 400 3 | writer_flags = "" 4 | zero_initialize_workgroup_memory = true 5 | 6 | [spv] 7 | adjust_coordinate_space = true 8 | debug = true 9 | force_point_size = true 10 | version = [1, 0] 11 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/spv-fetch_depth.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ], 6 | compute:[ 7 | ( 8 | entry_point:"cull_fetch_depth", 9 | target_profile:"cs_5_1", 10 | ), 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-6772-unpack-expr-accesses.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ], 6 | compute:[ 7 | ( 8 | entry_point:"main", 9 | target_profile:"cs_5_1", 10 | ), 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-atomicOps-int64-min-max.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ], 6 | compute:[ 7 | ( 8 | entry_point:"cs_main", 9 | target_profile:"cs_6_6", 10 | ), 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-atomicTexture-int64.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ], 6 | compute:[ 7 | ( 8 | entry_point:"cs_main", 9 | target_profile:"cs_6_6", 10 | ), 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-conversion-float-to-int.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ], 6 | compute:[ 7 | ( 8 | entry_point:"main", 9 | target_profile:"cs_6_0", 10 | ), 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-multiview.hlsl: -------------------------------------------------------------------------------- 1 | struct FragmentInput_main { 2 | uint view_index_1 : SV_ViewID; 3 | }; 4 | 5 | void main(FragmentInput_main fragmentinput_main) 6 | { 7 | uint view_index = fragmentinput_main.view_index_1; 8 | return; 9 | } 10 | -------------------------------------------------------------------------------- /naga/tests/out/wgsl/wgsl-array-in-ctor.wgsl: -------------------------------------------------------------------------------- 1 | struct Ah { 2 | inner: array, 3 | } 4 | 5 | @group(0) @binding(0) 6 | var ah: Ah; 7 | 8 | @compute @workgroup_size(1, 1, 1) 9 | fn cs_main() { 10 | let ah_1 = ah; 11 | return; 12 | } 13 | -------------------------------------------------------------------------------- /naga/tests/out/wgsl/wgsl-conversions.wgsl: -------------------------------------------------------------------------------- 1 | const ic0_: vec2 = vec2(2f, 2f); 2 | 3 | @compute @workgroup_size(1, 1, 1) 4 | fn main() { 5 | var vc0_: vec2 = vec2(2f, 2f); 6 | 7 | let lc0_ = vec2(2f, 2f); 8 | return; 9 | } 10 | -------------------------------------------------------------------------------- /wgpu-core/platform-deps/apple/README.md: -------------------------------------------------------------------------------- 1 | This crate exists to allow platform and feature specific features work correctly. The features 2 | enabled on this crate are only enabled on `target_vendor = "apple"` platforms. See wgpu-hal's `Cargo.toml` 3 | for more information. -------------------------------------------------------------------------------- /wgpu-core/platform-deps/wasm/README.md: -------------------------------------------------------------------------------- 1 | This crate exists to allow platform and feature specific features work correctly. The features 2 | enabled on this crate are only enabled on `target_arch = "wasm32"` platforms. See wgpu-hal's `Cargo.toml` 3 | for more information. 4 | -------------------------------------------------------------------------------- /examples/features/src/mipmap/README.md: -------------------------------------------------------------------------------- 1 | # mipmap 2 | 3 | This example shows how to generate and make use of mipmaps. 4 | 5 | ## To Run 6 | 7 | ``` 8 | cargo run --bin wgpu-examples mipmap 9 | ``` 10 | 11 | ## Screenshots 12 | 13 | ![Mip maps](./screenshot.png) 14 | -------------------------------------------------------------------------------- /examples/features/src/shadow/README.md: -------------------------------------------------------------------------------- 1 | # shadow 2 | 3 | This animated example demonstrates shadow mapping. 4 | 5 | ## To Run 6 | 7 | ``` 8 | cargo run --bin wgpu-examples shadow 9 | ``` 10 | 11 | ## Screenshots 12 | 13 | ![Shadow mapping](./screenshot.png) 14 | -------------------------------------------------------------------------------- /naga/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | **/*.rs.bk 3 | Cargo.lock 4 | .DS_Store 5 | .fuse_hidden* 6 | .idea 7 | .vscode 8 | *.swp 9 | /*.dot 10 | /*.metal 11 | /*.metallib 12 | /*.ron 13 | /*.spv 14 | /*.vert 15 | /*.frag 16 | /*.comp 17 | /*.wgsl 18 | /*.hlsl 19 | /*.txt 20 | -------------------------------------------------------------------------------- /naga/tests/in/glsl/484-preprocessor-if.frag: -------------------------------------------------------------------------------- 1 | // AUTHOR: fintelia 2 | // ISSUE: #484 3 | // FIX: https://github.com/Kangz/glslpp-rs/pull/30 4 | // NOTE: Shader altered to use correct syntax 5 | #version 450 core 6 | 7 | #if 0 8 | #endif 9 | 10 | void main() { } 11 | -------------------------------------------------------------------------------- /naga/tests/out/glsl/wgsl-early-depth-test-conservative.main.Fragment.glsl: -------------------------------------------------------------------------------- 1 | #version 420 core 2 | layout (depth_less) out float gl_FragDepth; 3 | 4 | void main() { 5 | vec4 pos = gl_FragCoord; 6 | gl_FragDepth = (pos.z - 0.1); 7 | return; 8 | } 9 | 10 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/spv-inv-hyperbolic-trig-functions.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ( 6 | entry_point:"main", 7 | target_profile:"ps_5_1", 8 | ), 9 | ], 10 | compute:[ 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-aliased-ray-query.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ], 6 | compute:[ 7 | ( 8 | entry_point:"main_candidate", 9 | target_profile:"cs_6_5", 10 | ), 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-array-in-function-return-type.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ( 6 | entry_point:"main", 7 | target_profile:"ps_5_1", 8 | ), 9 | ], 10 | compute:[ 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-bounds-check-dynamic-buffer.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ], 6 | compute:[ 7 | ( 8 | entry_point:"main", 9 | target_profile:"cs_5_1", 10 | ), 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-functions-optimized-by-version.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ], 6 | compute:[ 7 | ( 8 | entry_point:"main", 9 | target_profile:"cs_6_4", 10 | ), 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/msl/wgsl-cross.msl: -------------------------------------------------------------------------------- 1 | // language: metal1.0 2 | #include 3 | #include 4 | 5 | using metal::uint; 6 | 7 | 8 | kernel void main_( 9 | ) { 10 | metal::float3 a = metal::float3(0.0, 0.0, 1.0); 11 | return; 12 | } 13 | -------------------------------------------------------------------------------- /wgpu-hal/src/gles/shaders/clear.vert: -------------------------------------------------------------------------------- 1 | // A triangle that fills the whole screen 2 | vec2[3] TRIANGLE_POS = vec2[]( 3 | vec2( 0.0, -3.0), 4 | vec2(-3.0, 1.0), 5 | vec2( 3.0, 1.0) 6 | ); 7 | void main() { 8 | gl_Position = vec4(TRIANGLE_POS[gl_VertexID], 0.0, 1.0); 9 | } -------------------------------------------------------------------------------- /examples/features/src/msaa_line/README.md: -------------------------------------------------------------------------------- 1 | # msaa_line 2 | 3 | This example shows how to render lines using MSAA. 4 | 5 | ## To Run 6 | 7 | ``` 8 | cargo run --bin wgpu-examples msaa_line 9 | ``` 10 | 11 | ## Screenshots 12 | 13 | ![MSAA line](./screenshot.png) 14 | -------------------------------------------------------------------------------- /naga/tests/in/glsl/931-constant-emitting.frag: -------------------------------------------------------------------------------- 1 | // AUTHOR: jakobhellermann 2 | // ISSUE: #931 3 | // FIX: #933 4 | #version 450 5 | 6 | const int constant = 10; 7 | 8 | float function() { 9 | return 0.0; 10 | } 11 | 12 | void main() { 13 | function(); 14 | } 15 | -------------------------------------------------------------------------------- /naga/tests/in/glsl/dual-source-blending.frag: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(location = 0, index = 0) out vec4 output0; 4 | layout(location = 0, index = 1) out vec4 output1; 5 | 6 | void main() { 7 | output0 = vec4(1.0, 0.0, 1.0, 0.0); 8 | output1 = vec4(0.0, 1.0, 0.0, 1.0); 9 | } -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-unconsumed_vertex_outputs_frag.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ( 6 | entry_point:"fs_main", 7 | target_profile:"ps_5_1", 8 | ), 9 | ], 10 | compute:[ 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-unconsumed_vertex_outputs_vert.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ( 4 | entry_point:"vs_main", 5 | target_profile:"vs_5_1", 6 | ), 7 | ], 8 | fragment:[ 9 | ], 10 | compute:[ 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/tests/out/wgsl/wgsl-local-const.wgsl: -------------------------------------------------------------------------------- 1 | const gb: i32 = 4i; 2 | const gc: u32 = 4u; 3 | const gd: f32 = 4f; 4 | 5 | fn const_in_fn() { 6 | return; 7 | } 8 | 9 | @compute @workgroup_size(1, 1, 1) 10 | fn main() { 11 | const_in_fn(); 12 | return; 13 | } 14 | -------------------------------------------------------------------------------- /wgpu-core/platform-deps/emscripten/README.md: -------------------------------------------------------------------------------- 1 | This crate exists to allow platform and feature specific features work correctly. The features 2 | enabled on this crate are only enabled on `target_os = "emscripten"` platforms. 3 | See wgpu-hal's `Cargo.toml` for more information. 4 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/atomicOps-float32.toml: -------------------------------------------------------------------------------- 1 | capabilities = "SHADER_FLOAT32_ATOMIC" 2 | targets = "SPIRV | METAL | WGSL" 3 | 4 | [msl] 5 | fake_missing_bindings = true 6 | lang_version = [3, 0] 7 | zero_initialize_workgroup_memory = false 8 | 9 | [spv] 10 | version = [1, 1] 11 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/sprite.wgsl: -------------------------------------------------------------------------------- 1 | @group(0) @binding(0) var u_texture : texture_2d; 2 | @group(0) @binding(1) var u_sampler : sampler; 3 | 4 | @fragment 5 | fn main(@location(0) uv : vec2) -> @location(0) vec4 { 6 | return textureSample(u_texture, u_sampler, uv); 7 | } 8 | -------------------------------------------------------------------------------- /naga/tests/out/glsl/wgsl-multiview.main.Fragment.glsl: -------------------------------------------------------------------------------- 1 | #version 310 es 2 | #extension GL_EXT_multiview : require 3 | 4 | precision highp float; 5 | precision highp int; 6 | 7 | 8 | void main() { 9 | uint view_index = uint(gl_ViewIndex); 10 | return; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /naga/tests/out/glsl/wgsl-multiview_webgl.main.Fragment.glsl: -------------------------------------------------------------------------------- 1 | #version 300 es 2 | #extension GL_OVR_multiview2 : require 3 | 4 | precision highp float; 5 | precision highp int; 6 | 7 | 8 | void main() { 9 | uint view_index = gl_ViewID_OVR; 10 | return; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /naga/xtask/src/fs.rs: -------------------------------------------------------------------------------- 1 | use std::{fs::File, path::Path}; 2 | 3 | use anyhow::Context; 4 | 5 | pub(crate) fn open_file(path: impl AsRef) -> anyhow::Result { 6 | let path = path.as_ref(); 7 | File::open(path).with_context(|| format!("failed to open {path:?}")) 8 | } 9 | -------------------------------------------------------------------------------- /wgpu-core/platform-deps/apple/src/lib.rs: -------------------------------------------------------------------------------- 1 | //! This crate exists to allow platform and feature specific features work correctly. The features 2 | //! enabled on this crate are only enabled on `target_vendor = "apple"` platforms. See wgpu-hal's `Cargo.toml` 3 | //! for more information. 4 | -------------------------------------------------------------------------------- /wgpu-core/platform-deps/wasm/src/lib.rs: -------------------------------------------------------------------------------- 1 | //! This crate exists to allow platform and feature specific features work correctly. The features 2 | //! enabled on this crate are only enabled on `target_arch = "wasm32"` platforms. See wgpu-hal's `Cargo.toml` 3 | //! for more information. 4 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/interpolate.toml: -------------------------------------------------------------------------------- 1 | targets = "SPIRV | METAL | HLSL | WGSL" 2 | 3 | [glsl] 4 | version.Desktop = 400 5 | zero_initialize_workgroup_memory = true 6 | 7 | [spv] 8 | adjust_coordinate_space = true 9 | debug = true 10 | force_point_size = true 11 | version = [1, 0] 12 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-6772-unpack-expr-accesses.hlsl: -------------------------------------------------------------------------------- 1 | [numthreads(1, 1, 1)] 2 | void main() 3 | { 4 | int phony = (int4(12u, 12u >> 8, 12u >> 16, 12u >> 24) << 24 >> 24)[int(2)]; 5 | uint phony_1 = (uint4(12u, 12u >> 8, 12u >> 16, 12u >> 24) << 24 >> 24).y; 6 | return; 7 | } 8 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-workgroup-uniform-load.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ], 6 | compute:[ 7 | ( 8 | entry_point:"test_workgroupUniformLoad", 9 | target_profile:"cs_5_1", 10 | ), 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /naga/xtask/src/path.rs: -------------------------------------------------------------------------------- 1 | use std::path::{Path, PathBuf}; 2 | 3 | pub(crate) fn join_path(iter: I) -> PathBuf 4 | where 5 | P: AsRef, 6 | I: IntoIterator, 7 | { 8 | let mut path = PathBuf::new(); 9 | path.extend(iter); 10 | path 11 | } 12 | -------------------------------------------------------------------------------- /wgpu-info/src/main.rs: -------------------------------------------------------------------------------- 1 | #![cfg_attr(target_arch = "wasm32", no_main)] 2 | #![cfg(not(target_arch = "wasm32"))] 3 | 4 | mod cli; 5 | mod human; 6 | mod report; 7 | #[cfg(test)] 8 | mod tests; 9 | mod texture; 10 | 11 | fn main() -> anyhow::Result<()> { 12 | cli::main() 13 | } 14 | -------------------------------------------------------------------------------- /clippy.toml: -------------------------------------------------------------------------------- 1 | # NOTE: Other global Clippy config is in top-level Cargo.toml. 2 | 3 | disallowed-types = [ 4 | { path = "std::collections::HashMap", reason = "use hashbrown::HashMap instead" }, 5 | { path = "std::collections::HashSet", reason = "use hashbrown::HashSet instead" }, 6 | ] 7 | -------------------------------------------------------------------------------- /examples/features/src/hello_triangle/README.md: -------------------------------------------------------------------------------- 1 | # hello_triangle 2 | 3 | This example renders a triangle to a window. 4 | 5 | ## To Run 6 | 7 | ``` 8 | cargo run --bin wgpu-examples hello_triangle 9 | ``` 10 | 11 | ## Screenshots 12 | 13 | ![Triangle window](./screenshot.png) 14 | -------------------------------------------------------------------------------- /examples/standalone/01_hello_compute/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "wgpu-example-01-hello-compute" 3 | edition = "2021" 4 | rust-version = "1.92" 5 | publish = false 6 | 7 | [dependencies] 8 | bytemuck = "1.22.0" 9 | env_logger = "0.11" 10 | pollster = "0.4" 11 | wgpu = "28.0.0" 12 | -------------------------------------------------------------------------------- /naga/tests/out/wgsl/glsl-global-constant-array.frag.wgsl: -------------------------------------------------------------------------------- 1 | const array_: array = array(1f, 2f); 2 | 3 | fn main_1() { 4 | var local: array = array_; 5 | 6 | return; 7 | } 8 | 9 | @fragment 10 | fn main() { 11 | main_1(); 12 | return; 13 | } 14 | -------------------------------------------------------------------------------- /wgpu-core/platform-deps/emscripten/src/lib.rs: -------------------------------------------------------------------------------- 1 | //! This crate exists to allow platform and feature specific features work correctly. The features 2 | //! enabled on this crate are only enabled on `target_os = "emscripten"` platforms. 3 | //! See wgpu-hal's `Cargo.toml` for more information. 4 | -------------------------------------------------------------------------------- /naga/tests/out/msl/wgsl-multiview.msl: -------------------------------------------------------------------------------- 1 | // language: metal2.3 2 | #include 3 | #include 4 | 5 | using metal::uint; 6 | 7 | 8 | struct main_Input { 9 | }; 10 | fragment void main_( 11 | uint view_index [[amplification_id]] 12 | ) { 13 | return; 14 | } 15 | -------------------------------------------------------------------------------- /player/tests/player/data/zero-init-texture-binding.wgsl: -------------------------------------------------------------------------------- 1 | @group(0) @binding(0) var tex: texture_2d; 2 | @group(0) @binding(1) var tex_storage: texture_storage_2d; 3 | 4 | @compute 5 | @workgroup_size(1) 6 | fn main(@builtin(global_invocation_id) global_id: vec3) { 7 | } 8 | -------------------------------------------------------------------------------- /examples/features/src/ray_shadows/README.md: -------------------------------------------------------------------------------- 1 | # ray-shadows 2 | 3 | This example renders a ray traced shadow with hardware acceleration. 4 | 5 | ## To Run 6 | 7 | ``` 8 | cargo run --bin wgpu-examples ray_shadows 9 | ``` 10 | 11 | ## Screenshots 12 | 13 | ![Shadow example](screenshot.png) 14 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/diagnostic-filter.wgsl: -------------------------------------------------------------------------------- 1 | diagnostic(off, derivative_uniformity); 2 | 3 | fn thing() {} 4 | 5 | @diagnostic(warning, derivative_uniformity) 6 | fn with_diagnostic() {} 7 | 8 | @compute @workgroup_size(1) 9 | fn main() { 10 | thing(); 11 | with_diagnostic(); 12 | } 13 | -------------------------------------------------------------------------------- /naga/tests/out/glsl/wgsl-cross.main.Compute.glsl: -------------------------------------------------------------------------------- 1 | #version 310 es 2 | 3 | precision highp float; 4 | precision highp int; 5 | 6 | layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; 7 | 8 | 9 | void main() { 10 | vec3 a = vec3(0.0, 0.0, 1.0); 11 | return; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /examples/features/src/mesh_shader/README.md: -------------------------------------------------------------------------------- 1 | # mesh_shader 2 | 3 | This example renders a triangle to a window with mesh shaders, while showcasing most mesh shader related features(task shaders, payloads, per primitive data). 4 | 5 | ## To Run 6 | 7 | ``` 8 | cargo run --bin wgpu-examples mesh_shader 9 | ``` -------------------------------------------------------------------------------- /examples/features/src/ray_cube_fragment/README.md: -------------------------------------------------------------------------------- 1 | # ray-cube 2 | 3 | This example renders a ray traced cube with hardware acceleration. 4 | 5 | ## To Run 6 | 7 | ``` 8 | cargo run --bin wgpu-examples ray_cube_fragment 9 | ``` 10 | 11 | ## Screenshots 12 | 13 | ![Cube example](screenshot.png) 14 | -------------------------------------------------------------------------------- /naga/fuzz/build.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | cfg_aliases::cfg_aliases! { 3 | fuzzable_platform: { not(any(target_arch = "wasm32", target_os = "ios", all(windows, target_arch = "aarch64"))) }, 4 | } 5 | // This cfg provided by cargo-fuzz 6 | println!("cargo::rustc-check-cfg=cfg(fuzzing)"); 7 | } 8 | -------------------------------------------------------------------------------- /naga/src/common/wgsl/mod.rs: -------------------------------------------------------------------------------- 1 | //! Code shared between the WGSL front and back ends. 2 | 3 | mod diagnostics; 4 | mod to_wgsl; 5 | mod types; 6 | 7 | pub use diagnostics::DisplayFilterableTriggeringRule; 8 | pub use to_wgsl::{address_space_str, ToWgsl, TryToWgsl}; 9 | pub use types::TypeContext; 10 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/functions-webgl.wgsl: -------------------------------------------------------------------------------- 1 | fn test_fma() -> vec2 { 2 | let a = vec2(2.0, 2.0); 3 | let b = vec2(0.5, 0.5); 4 | let c = vec2(0.5, 0.5); 5 | 6 | return fma(a, b, c); 7 | } 8 | 9 | 10 | @fragment 11 | fn main() { 12 | let a = test_fma(); 13 | } 14 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/template-list-ge.wgsl: -------------------------------------------------------------------------------- 1 | @group(0) @binding(0) 2 | var out: array; 3 | 4 | @compute @workgroup_size(1) 5 | fn main() { 6 | var tmp: array=array(1, 2); 7 | for (var i = 0; i < 2; i++) { 8 | out[i] = tmp[i]; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /naga/tests/out/wgsl/glsl-931-constant-emitting.frag.wgsl: -------------------------------------------------------------------------------- 1 | const constant: i32 = 10i; 2 | 3 | fn function() -> f32 { 4 | return 0f; 5 | } 6 | 7 | fn main_1() { 8 | let _e0 = function(); 9 | return; 10 | } 11 | 12 | @fragment 13 | fn main() { 14 | main_1(); 15 | return; 16 | } 17 | -------------------------------------------------------------------------------- /naga/tests/in/glsl/quad_glsl.vert: -------------------------------------------------------------------------------- 1 | #version 450 2 | const float c_scale = 1.2; 3 | 4 | layout(location = 0) in vec2 a_pos; 5 | layout(location = 1) in vec2 a_uv; 6 | layout(location = 0) out vec2 v_uv; 7 | 8 | void main() { 9 | v_uv = a_uv; 10 | gl_Position = vec4(c_scale * a_pos, 0.0, 1.0); 11 | } 12 | -------------------------------------------------------------------------------- /naga/tests/in/glsl/variations.frag: -------------------------------------------------------------------------------- 1 | #version 460 core 2 | 3 | layout(set = 0, binding = 0) uniform textureCube texCube; 4 | layout(set = 0, binding = 1) uniform sampler samp; 5 | 6 | void main() { 7 | ivec2 sizeCube = textureSize(samplerCube(texCube, samp), 0); 8 | float a = ceil(1.0); 9 | } 10 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/image.toml: -------------------------------------------------------------------------------- 1 | glsl_exclude_list = ["depth_load", "depth_no_comparison"] 2 | targets = "SPIRV | METAL | HLSL | WGSL | GLSL" 3 | 4 | [glsl] 5 | version.Desktop = 430 6 | writer_flags = "" 7 | zero_initialize_workgroup_memory = true 8 | 9 | [spv] 10 | debug = true 11 | version = [1, 1] 12 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-barycentrics.hlsl: -------------------------------------------------------------------------------- 1 | struct FragmentInput_fs_main { 2 | float3 bary_1 : SV_Barycentrics; 3 | }; 4 | 5 | float4 fs_main(FragmentInput_fs_main fragmentinput_fs_main) : SV_Target0 6 | { 7 | float3 bary = fragmentinput_fs_main.bary_1; 8 | return float4(bary, 1.0); 9 | } 10 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-select.hlsl: -------------------------------------------------------------------------------- 1 | [numthreads(1, 1, 1)] 2 | void main() 3 | { 4 | int2 x0_ = int2(int(1), int(2)); 5 | float2 i1_ = (float2)0; 6 | 7 | int _e12 = x0_.x; 8 | int _e14 = x0_.y; 9 | i1_ = ((_e12 < _e14) ? float2(0.0, 1.0) : float2(1.0, 0.0)); 10 | return; 11 | } 12 | -------------------------------------------------------------------------------- /player/tests/player/data/zero-init-buffer-for-binding.wgsl: -------------------------------------------------------------------------------- 1 | @group(0) 2 | @binding(0) 3 | var buf: array; 4 | 5 | @compute 6 | @workgroup_size(1) 7 | fn main(@builtin(global_invocation_id) global_id: vec3) { 8 | buf[global_id.x] = buf[global_id.x] + global_id.x; 9 | } 10 | -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | coverage: 2 | status: 3 | project: 4 | default: 5 | informational: true 6 | if_ci_failed: success 7 | patch: 8 | default: 9 | informational: true 10 | if_ci_failed: success 11 | comment: false 12 | github_checks: 13 | annotations: false 14 | -------------------------------------------------------------------------------- /examples/features/src/hello_windows/README.md: -------------------------------------------------------------------------------- 1 | # hello_windows 2 | 3 | This example renders a set of 16 windows, with a differently colored background 4 | 5 | ## To Run 6 | 7 | ``` 8 | cargo run --bin wgpu-examples hello_windows 9 | ``` 10 | 11 | ## Screenshots 12 | 13 | ![16 windows](./screenshot.png) 14 | -------------------------------------------------------------------------------- /naga/tests/in/glsl/5246-dual-iteration.frag: -------------------------------------------------------------------------------- 1 | // AUTHOR: cwfitzgerald 2 | // ISSUE: #5246 3 | 4 | void main() { 5 | for (int x = 0; x < 10; x++) { 6 | for (int y = 0; y < 10; y++) { 7 | for (int z = 0; z < 10; z++) { 8 | ; 9 | } 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /naga/tests/in/wgsl/quad.toml: -------------------------------------------------------------------------------- 1 | targets = "SPIRV | METAL | GLSL | DOT | HLSL | WGSL" 2 | 3 | [glsl] 4 | version.Embedded = { is_webgl = false, version = 300 } 5 | writer_flags = "" 6 | zero_initialize_workgroup_memory = true 7 | 8 | [spv] 9 | adjust_coordinate_space = true 10 | debug = true 11 | version = [1, 0] 12 | -------------------------------------------------------------------------------- /tests/tests/wgpu-compile/main.rs: -------------------------------------------------------------------------------- 1 | #![cfg(not(miri))] 2 | // Tests that ensure that various constructs that should not compile do not compile. 3 | 4 | #[cfg_attr(miri, ignore)] 5 | #[test] 6 | fn compile_fail() { 7 | let t = trybuild::TestCases::new(); 8 | t.compile_fail("compile_tests/fail/*.rs"); 9 | } 10 | -------------------------------------------------------------------------------- /wgpu-core/platform-deps/windows-linux-android/README.md: -------------------------------------------------------------------------------- 1 | This crate exists to allow platform and feature specific features work correctly. The features 2 | enabled on this crate are only enabled on `windows`, `target_os = "linux"`, and `target_os = "android"` 3 | platforms. See wgpu-hal's `Cargo.toml` for more information. 4 | -------------------------------------------------------------------------------- /naga/tests/out/glsl/wgsl-barycentrics.fs_main.Fragment.glsl: -------------------------------------------------------------------------------- 1 | #version 450 core 2 | #extension GL_EXT_fragment_shader_barycentric : require 3 | layout(location = 0) out vec4 _fs2p_location0; 4 | 5 | void main() { 6 | vec3 bary = gl_BaryCoordEXT; 7 | _fs2p_location0 = vec4(bary, 1.0); 8 | return; 9 | } 10 | 11 | -------------------------------------------------------------------------------- /naga/tests/out/glsl/wgsl-force_point_size_vertex_shader_webgl.fs_main.Fragment.glsl: -------------------------------------------------------------------------------- 1 | #version 300 es 2 | 3 | precision highp float; 4 | precision highp int; 5 | 6 | layout(location = 0) out vec4 _fs2p_location0; 7 | 8 | void main() { 9 | _fs2p_location0 = vec4(1.0, 0.0, 0.0, 1.0); 10 | return; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /naga/tests/out/wgsl/glsl-280-matrix-cast.frag.wgsl: -------------------------------------------------------------------------------- 1 | fn main_1() { 2 | var a: mat4x4 = mat4x4(vec4(1f, 0f, 0f, 0f), vec4(0f, 1f, 0f, 0f), vec4(0f, 0f, 1f, 0f), vec4(0f, 0f, 0f, 1f)); 3 | 4 | return; 5 | } 6 | 7 | @fragment 8 | fn main() { 9 | main_1(); 10 | return; 11 | } 12 | -------------------------------------------------------------------------------- /naga/tests/out/wgsl/wgsl-select.wgsl: -------------------------------------------------------------------------------- 1 | @compute @workgroup_size(1, 1, 1) 2 | fn main() { 3 | var x0_: vec2 = vec2(1i, 2i); 4 | var i1_: vec2; 5 | 6 | let _e12 = x0_.x; 7 | let _e14 = x0_.y; 8 | i1_ = select(vec2(1f, 0f), vec2(0f, 1f), (_e12 < _e14)); 9 | return; 10 | } 11 | -------------------------------------------------------------------------------- /wgpu/src/backend/mod.rs: -------------------------------------------------------------------------------- 1 | #[cfg(webgpu)] 2 | pub mod webgpu; 3 | #[cfg(webgpu)] 4 | pub(crate) use webgpu::{get_browser_gpu_property, ContextWebGpu}; 5 | 6 | #[cfg(wgpu_core)] 7 | pub mod wgpu_core; 8 | 9 | #[cfg(wgpu_core)] 10 | pub(crate) use wgpu_core::ContextWgpuCore; 11 | 12 | #[cfg(custom)] 13 | pub mod custom; 14 | -------------------------------------------------------------------------------- /tests/tests/wgpu-gpu/texture_binding/single_scalar.wgsl: -------------------------------------------------------------------------------- 1 | @group(0) @binding(0) 2 | var tex_w: texture_storage_2d; 3 | @group(0) @binding(1) 4 | var tex_r: texture_storage_2d; 5 | 6 | @compute @workgroup_size(1) fn csStore() { 7 | textureStore(tex_w, vec2u(0), textureLoad(tex_r, vec2u(0))); 8 | } -------------------------------------------------------------------------------- /tests/tests/wgpu-validation/api/mod.rs: -------------------------------------------------------------------------------- 1 | mod binding_arrays; 2 | mod buffer; 3 | mod buffer_mapping; 4 | mod buffer_slice; 5 | mod command_buffer_actions; 6 | mod device; 7 | mod encoding; 8 | mod error_scopes; 9 | mod experimental; 10 | mod external_texture; 11 | mod instance; 12 | mod render_pipeline; 13 | mod texture; 14 | -------------------------------------------------------------------------------- /naga/tests/out/msl/wgsl-empty-if.msl: -------------------------------------------------------------------------------- 1 | // language: metal1.0 2 | #include 3 | #include 4 | 5 | using metal::uint; 6 | 7 | 8 | struct compInput { 9 | }; 10 | kernel void comp( 11 | metal::uint3 id [[thread_position_in_grid]] 12 | ) { 13 | if (id.x == 0u) { 14 | } 15 | return; 16 | } 17 | -------------------------------------------------------------------------------- /tests/tests/wgpu-gpu/occlusion_query/shader.wgsl: -------------------------------------------------------------------------------- 1 | @vertex 2 | fn vs_main(@builtin(vertex_index) in_vertex_index: u32) -> @builtin(position) vec4 { 3 | let x = f32(i32(in_vertex_index & 3u) - 1); 4 | let y = f32(i32(in_vertex_index & 1u) * 2 - 1); 5 | 6 | return vec4(x, y, f32(in_vertex_index & 4u) / 8.0, 1.0); 7 | } 8 | -------------------------------------------------------------------------------- /wgpu-core/platform-deps/windows-linux-android/src/lib.rs: -------------------------------------------------------------------------------- 1 | //! This crate exists to allow platform and feature specific features work correctly. The features 2 | //! enabled on this crate are only enabled on `windows`, `target_os = "linux"`, and `target_os = "android"` 3 | //! platforms. See wgpu-hal's `Cargo.toml` for more information. 4 | -------------------------------------------------------------------------------- /examples/standalone/02_hello_window/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "wgpu-example-02-hello-window" 3 | edition = "2021" 4 | rust-version = "1.92" 5 | publish = false 6 | 7 | [dependencies] 8 | env_logger = "0.11" 9 | pollster = "0.4" 10 | wgpu = "28.0.0" 11 | winit = { version = "0.30.8", features = ["android-native-activity"] } 12 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/f64.wgsl: -------------------------------------------------------------------------------- 1 | var v: f64 = 1lf; 2 | const k: f64 = 2.0lf; 3 | 4 | fn f(x: f64) -> f64 { 5 | _ = v; 6 | let y: f64 = 3e1lf + 4.0e2lf; 7 | var z = y + f64(5); 8 | var w = -1.0lf; 9 | return x + y + k + 5.0lf; 10 | } 11 | 12 | @compute @workgroup_size(1) 13 | fn main() { 14 | f(6.0lf); 15 | } 16 | -------------------------------------------------------------------------------- /naga/tests/out/glsl/wgsl-early-depth-test-force.main.Fragment.glsl: -------------------------------------------------------------------------------- 1 | #version 310 es 2 | 3 | precision highp float; 4 | precision highp int; 5 | 6 | layout(early_fragment_tests) in; 7 | layout(location = 0) out vec4 _fs2p_location0; 8 | 9 | void main() { 10 | _fs2p_location0 = vec4(0.4, 0.3, 0.2, 0.1); 11 | return; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /naga/tests/out/glsl/wgsl-empty-if.comp.Compute.glsl: -------------------------------------------------------------------------------- 1 | #version 310 es 2 | 3 | precision highp float; 4 | precision highp int; 5 | 6 | layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; 7 | 8 | 9 | void main() { 10 | uvec3 id = gl_GlobalInvocationID; 11 | if ((id.x == 0u)) { 12 | } 13 | return; 14 | } 15 | 16 | -------------------------------------------------------------------------------- /tests/src/poll.rs: -------------------------------------------------------------------------------- 1 | use crate::TestingContext; 2 | 3 | impl TestingContext { 4 | /// Utility to allow future asynchronous polling. 5 | pub async fn async_poll( 6 | &self, 7 | poll_type: wgpu::PollType, 8 | ) -> Result { 9 | self.device.poll(poll_type) 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /tests/tests/wgpu-gpu/external_texture/dimensions.wgsl: -------------------------------------------------------------------------------- 1 | @group(0) @binding(0) 2 | var tex: texture_external; 3 | 4 | @group(0) @binding(1) 5 | var output: vec2; 6 | 7 | @compute @workgroup_size(1) 8 | fn main(@builtin(global_invocation_id) global_id: vec3) { 9 | output = textureDimensions(tex); 10 | } 11 | -------------------------------------------------------------------------------- /naga/tests/out/wgsl/wgsl-7995-unicode-idents.wgsl: -------------------------------------------------------------------------------- 1 | @group(0) @binding(0) 2 | var asdf: f32; 3 | 4 | fn compute() -> f32 { 5 | let _e1 = asdf; 6 | let u03b8_2_ = (_e1 + 9001f); 7 | return u03b8_2_; 8 | } 9 | 10 | @compute @workgroup_size(1, 1, 1) 11 | fn main() { 12 | let _e0 = compute(); 13 | return; 14 | } 15 | -------------------------------------------------------------------------------- /tests/tests/wgpu-gpu/shader_barycentric/barycentric.wgsl: -------------------------------------------------------------------------------- 1 | @vertex 2 | fn vs_main(@location(0) xy: vec2) -> @builtin(position) vec4 { 3 | return vec4(xy, 0.0, 1.0); 4 | } 5 | 6 | @fragment 7 | fn fs_main(@builtin(barycentric) bary: vec3) -> @location(0) vec4 { 8 | return vec4(bary * 1.1 - 0.05, 1.0); 9 | } 10 | -------------------------------------------------------------------------------- /naga/hlsl-snapshots/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "hlsl-snapshots" 3 | version.workspace = true 4 | edition.workspace = true 5 | publish = false 6 | license.workspace = true 7 | 8 | [lib] 9 | name = "hlsl_snapshots" 10 | path = "src/lib.rs" 11 | test = false 12 | 13 | [dependencies] 14 | anyhow.workspace = true 15 | nanoserde.workspace = true 16 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/clip-distances.wgsl: -------------------------------------------------------------------------------- 1 | enable clip_distances; 2 | struct VertexOutput { 3 | @builtin(position) position: vec4, 4 | @builtin(clip_distances) clip_distances: array, 5 | } 6 | 7 | @vertex 8 | fn main() -> VertexOutput { 9 | var out: VertexOutput; 10 | out.clip_distances[0] = 0.5; 11 | return out; 12 | } -------------------------------------------------------------------------------- /naga/tests/in/wgsl/f16-native.toml: -------------------------------------------------------------------------------- 1 | targets = "SPIRV" 2 | capabilities = "SHADER_FLOAT16" 3 | 4 | [spv] 5 | debug = true 6 | version = [1, 1] 7 | use_storage_input_output_16 = true 8 | capabilities = ["Float16"] 9 | 10 | [bounds_check_policies] 11 | index = "ReadZeroSkipWrite" 12 | buffer = "ReadZeroSkipWrite" 13 | image = "ReadZeroSkipWrite" 14 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/f16-polyfill.toml: -------------------------------------------------------------------------------- 1 | targets = "SPIRV" 2 | capabilities = "SHADER_FLOAT16" 3 | 4 | [spv] 5 | debug = true 6 | version = [1, 1] 7 | use_storage_input_output_16 = false 8 | capabilities = ["Float16"] 9 | 10 | [bounds_check_policies] 11 | index = "ReadZeroSkipWrite" 12 | buffer = "ReadZeroSkipWrite" 13 | image = "ReadZeroSkipWrite" 14 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/dualsource.wgsl: -------------------------------------------------------------------------------- 1 | enable dual_source_blending; 2 | 3 | struct FragmentOutput { 4 | @location(0) @blend_src(0) output0: vec4, 5 | @location(0) @blend_src(1) output1: vec4, 6 | } 7 | 8 | @fragment 9 | fn main() -> FragmentOutput { 10 | return FragmentOutput(vec4(0.4,0.3,0.2,0.1), vec4(0.9,0.8,0.7,0.6)); 11 | } 12 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-7995-unicode-idents.hlsl: -------------------------------------------------------------------------------- 1 | ByteAddressBuffer asdf : register(t0); 2 | 3 | float compute() 4 | { 5 | float _e1 = asfloat(asdf.Load(0)); 6 | float u03b8_2_ = (_e1 + 9001.0); 7 | return u03b8_2_; 8 | } 9 | 10 | [numthreads(1, 1, 1)] 11 | void main() 12 | { 13 | const float _e0 = compute(); 14 | return; 15 | } 16 | -------------------------------------------------------------------------------- /naga/tests/in/glsl/const-global-swizzle.frag: -------------------------------------------------------------------------------- 1 | // ISSUE: #4773 2 | #version 450 3 | 4 | #define MIX2(c) c.xy 5 | 6 | layout(location = 0) in vec2 v_Uv; 7 | 8 | layout(location = 0) out vec4 o_Target; 9 | 10 | const vec2 blank = MIX2(vec2(0.0, 1.0)); 11 | 12 | void main() { 13 | vec2 col = MIX2(v_Uv) * blank; 14 | o_Target = vec4(col, 0.0, 1.0); 15 | } -------------------------------------------------------------------------------- /naga/tests/in/wgsl/7048-multiple-dynamic-2.wgsl: -------------------------------------------------------------------------------- 1 | @fragment 2 | fn fs_main() -> @location(0) vec4f { 3 | let my_array = array( 4 | vec2f(0.0, 0.0), 5 | vec2f(0.0, 0.0), 6 | ); 7 | var index_0 = 0; 8 | 9 | let val_0 = my_array[index_0]; 10 | let val_1 = my_array[index_0]; 11 | 12 | return (val_0 * val_1).xxyy; 13 | } 14 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/bounds-check-image-restrict-depth.toml: -------------------------------------------------------------------------------- 1 | targets = "SPIRV | METAL" 2 | 3 | [bounds_check_policies] 4 | image_load = "Restrict" 5 | 6 | [msl] 7 | fake_missing_bindings = true 8 | lang_version = [1, 2] 9 | spirv_cross_compatibility = false 10 | zero_initialize_workgroup_memory = true 11 | 12 | [spv] 13 | debug = true 14 | version = [1, 1] 15 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-skybox.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ( 4 | entry_point:"vs_main", 5 | target_profile:"vs_5_1", 6 | ), 7 | ], 8 | fragment:[ 9 | ( 10 | entry_point:"fs_main", 11 | target_profile:"ps_5_1", 12 | ), 13 | ], 14 | compute:[ 15 | ], 16 | ) 17 | -------------------------------------------------------------------------------- /examples/features/src/ray_cube_compute/README.md: -------------------------------------------------------------------------------- 1 | # ray-cube 2 | 3 | This example renders a ray traced cube with hardware acceleration. 4 | A separate compute shader is used to perform the ray queries. 5 | 6 | ## To Run 7 | 8 | ``` 9 | cargo run --bin wgpu-examples ray_cube_compute 10 | ``` 11 | 12 | ## Screenshots 13 | 14 | ![Cube example](screenshot.png) 15 | -------------------------------------------------------------------------------- /examples/features/src/ray_cube_normals/README.md: -------------------------------------------------------------------------------- 1 | # ray-cube 2 | 3 | This example renders a ray traced cube with hardware acceleration. 4 | A separate compute shader is used to perform the ray queries. 5 | 6 | ## To Run 7 | 8 | ``` 9 | cargo run --bin wgpu-examples ray_cube_normals 10 | ``` 11 | 12 | ## Screenshots 13 | 14 | ![Cube example](screenshot.png) 15 | -------------------------------------------------------------------------------- /naga/src/back/wgsl/polyfill/inverse/inverse_2x2_f16.wgsl: -------------------------------------------------------------------------------- 1 | fn _naga_inverse_2x2_f16(m: mat2x2) -> mat2x2 { 2 | var adj: mat2x2; 3 | adj[0][0] = m[1][1]; 4 | adj[0][1] = -m[0][1]; 5 | adj[1][0] = -m[1][0]; 6 | adj[1][1] = m[0][0]; 7 | 8 | let det: f16 = m[0][0] * m[1][1] - m[1][0] * m[0][1]; 9 | return adj * (1 / det); 10 | } -------------------------------------------------------------------------------- /naga/src/back/wgsl/polyfill/inverse/inverse_2x2_f32.wgsl: -------------------------------------------------------------------------------- 1 | fn _naga_inverse_2x2_f32(m: mat2x2) -> mat2x2 { 2 | var adj: mat2x2; 3 | adj[0][0] = m[1][1]; 4 | adj[0][1] = -m[0][1]; 5 | adj[1][0] = -m[1][0]; 6 | adj[1][1] = m[0][0]; 7 | 8 | let det: f32 = m[0][0] * m[1][1] - m[1][0] * m[0][1]; 9 | return adj * (1 / det); 10 | } -------------------------------------------------------------------------------- /naga/tests/in/wgsl/conversion-float-to-int.toml: -------------------------------------------------------------------------------- 1 | # GLSL does not support i64 or f16, but we don't handle float to integer 2 | # conversion specially there anyway. 3 | # MSL does not support f64. See conversion-float-to-int-no-f64.wgsl. 4 | targets = "SPIRV | HLSL | WGSL" 5 | capabilities = "SHADER_FLOAT16 | FLOAT64 | SHADER_INT64" 6 | 7 | [hlsl] 8 | shader_model = "V6_0" 9 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-6438-conflicting-idents.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ( 4 | entry_point:"vs", 5 | target_profile:"vs_5_1", 6 | ), 7 | ], 8 | fragment:[ 9 | ( 10 | entry_point:"fs", 11 | target_profile:"ps_5_1", 12 | ), 13 | ], 14 | compute:[ 15 | ], 16 | ) 17 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-interpolate.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ( 4 | entry_point:"vert_main", 5 | target_profile:"vs_5_1", 6 | ), 7 | ], 8 | fragment:[ 9 | ( 10 | entry_point:"frag_main", 11 | target_profile:"ps_5_1", 12 | ), 13 | ], 14 | compute:[ 15 | ], 16 | ) 17 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-push-constants.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ( 4 | entry_point:"vert_main", 5 | target_profile:"vs_5_1", 6 | ), 7 | ], 8 | fragment:[ 9 | ( 10 | entry_point:"main", 11 | target_profile:"ps_5_1", 12 | ), 13 | ], 14 | compute:[ 15 | ], 16 | ) 17 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-ray-query.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ], 6 | compute:[ 7 | ( 8 | entry_point:"main", 9 | target_profile:"cs_6_5", 10 | ), 11 | ( 12 | entry_point:"main_candidate", 13 | target_profile:"cs_6_5", 14 | ), 15 | ], 16 | ) 17 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-storage-textures.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ], 6 | compute:[ 7 | ( 8 | entry_point:"csLoad", 9 | target_profile:"cs_5_1", 10 | ), 11 | ( 12 | entry_point:"csStore", 13 | target_profile:"cs_5_1", 14 | ), 15 | ], 16 | ) 17 | -------------------------------------------------------------------------------- /tests/tests/wgpu-gpu/binding_array/mod.rs: -------------------------------------------------------------------------------- 1 | mod buffers; 2 | mod sampled_textures; 3 | mod samplers; 4 | mod storage_textures; 5 | 6 | pub fn all_tests(tests: &mut Vec) { 7 | buffers::all_tests(tests); 8 | sampled_textures::all_tests(tests); 9 | samplers::all_tests(tests); 10 | storage_textures::all_tests(tests); 11 | } 12 | -------------------------------------------------------------------------------- /tests/tests/wgpu-gpu/shader/shader_test.wgsl: -------------------------------------------------------------------------------- 1 | {{header}} 2 | 3 | struct CustomStruct { 4 | {{input_members}} 5 | } 6 | 7 | {{input_bindings}} 8 | var<{{storage_type}}> input: {{input_type}}; 9 | 10 | @group(0) @binding(1) 11 | var output: {{output_type}}; 12 | 13 | @compute @workgroup_size(1) 14 | fn cs_main() { 15 | {{body}} 16 | } 17 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/overrides-ray-query.toml: -------------------------------------------------------------------------------- 1 | capabilities = "RAY_QUERY" 2 | pipeline_constants = { o = 2.0 } 3 | targets = "IR | SPIRV | METAL" 4 | 5 | [msl] 6 | fake_missing_bindings = true 7 | lang_version = [2, 4] 8 | spirv_cross_compatibility = false 9 | zero_initialize_workgroup_memory = false 10 | 11 | [spv] 12 | separate_entry_points = true 13 | version = [1, 4] 14 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-interpolate_compat.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ( 4 | entry_point:"vert_main", 5 | target_profile:"vs_5_1", 6 | ), 7 | ], 8 | fragment:[ 9 | ( 10 | entry_point:"frag_main", 11 | target_profile:"ps_5_1", 12 | ), 13 | ], 14 | compute:[ 15 | ], 16 | ) 17 | -------------------------------------------------------------------------------- /examples/features/src/ray_traced_triangle/README.md: -------------------------------------------------------------------------------- 1 | # ray-traced-triangle 2 | 3 | This example renders three triangles with hardware acceleration. 4 | This is the same scene set-up as hal ray-traced triangle 5 | 6 | ## To Run 7 | 8 | ``` 9 | cargo run --bin wgpu-examples ray_traced_triangle 10 | ``` 11 | 12 | ## Screenshots 13 | 14 | ![Triangle example](screenshot.png) 15 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/atomicTexture-int64.wgsl: -------------------------------------------------------------------------------- 1 | @group(0) @binding(0) 2 | var image: texture_storage_2d; 3 | 4 | @compute 5 | @workgroup_size(2) 6 | fn cs_main(@builtin(local_invocation_id) id: vec3) { 7 | textureAtomicMax(image, vec2(0, 0), 1lu); 8 | 9 | workgroupBarrier(); 10 | 11 | textureAtomicMin(image, vec2(0, 0), 1lu); 12 | } 13 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/extra.toml: -------------------------------------------------------------------------------- 1 | capabilities = "IMMEDIATES | PRIMITIVE_INDEX" 2 | targets = "SPIRV | METAL | WGSL" 3 | 4 | [msl] 5 | fake_missing_bindings = false 6 | lang_version = [2, 3] 7 | spirv_cross_compatibility = false 8 | zero_initialize_workgroup_memory = true 9 | 10 | [msl.per_entry_point_map.main] 11 | immediates_buffer = 1 12 | 13 | [spv] 14 | version = [1, 2] 15 | -------------------------------------------------------------------------------- /naga/tests/out/glsl/wgsl-conversions.main.Compute.glsl: -------------------------------------------------------------------------------- 1 | #version 310 es 2 | 3 | precision highp float; 4 | precision highp int; 5 | 6 | layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; 7 | 8 | const vec2 ic0_ = vec2(2.0, 2.0); 9 | 10 | 11 | void main() { 12 | vec2 vc0_ = vec2(2.0, 2.0); 13 | vec2 lc0_ = vec2(2.0, 2.0); 14 | return; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-fragment-output.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ( 6 | entry_point:"main_vec4vec3_", 7 | target_profile:"ps_5_1", 8 | ), 9 | ( 10 | entry_point:"main_vec2scalar", 11 | target_profile:"ps_5_1", 12 | ), 13 | ], 14 | compute:[ 15 | ], 16 | ) 17 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-ray-query-no-init-tracking.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ], 6 | compute:[ 7 | ( 8 | entry_point:"main", 9 | target_profile:"cs_6_5", 10 | ), 11 | ( 12 | entry_point:"main_candidate", 13 | target_profile:"cs_6_5", 14 | ), 15 | ], 16 | ) 17 | -------------------------------------------------------------------------------- /naga/tests/out/msl/wgsl-conversions.msl: -------------------------------------------------------------------------------- 1 | // language: metal1.0 2 | #include 3 | #include 4 | 5 | using metal::uint; 6 | 7 | constant metal::float2 ic0_ = metal::float2(2.0, 2.0); 8 | 9 | kernel void main_( 10 | ) { 11 | metal::float2 vc0_ = metal::float2(2.0, 2.0); 12 | metal::float2 lc0_ = metal::float2(2.0, 2.0); 13 | return; 14 | } 15 | -------------------------------------------------------------------------------- /naga/tests/out/wgsl/spv-empty-global-name.wgsl: -------------------------------------------------------------------------------- 1 | struct type_1 { 2 | member: i32, 3 | } 4 | 5 | @group(0) @binding(0) 6 | var unnamed: type_1; 7 | 8 | fn function() { 9 | let _e3 = unnamed.member; 10 | unnamed.member = (_e3 + 1i); 11 | return; 12 | } 13 | 14 | @compute @workgroup_size(1, 1, 1) 15 | fn main() { 16 | function(); 17 | } 18 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/7995-unicode-idents.wgsl: -------------------------------------------------------------------------------- 1 | // NOTE: This allows us to suppress compaction below, to force the handling of identifiers 2 | // containing Unicode. 3 | @group(0) @binding(0) 4 | var asdf: f32; 5 | 6 | fn compute() -> f32 { 7 | let θ2 = asdf + 9001.0; 8 | return θ2; 9 | } 10 | 11 | @compute @workgroup_size(1, 1) 12 | fn main() { 13 | compute(); 14 | } 15 | -------------------------------------------------------------------------------- /naga/tests/out/msl/wgsl-array-in-ctor.msl: -------------------------------------------------------------------------------- 1 | // language: metal1.0 2 | #include 3 | #include 4 | 5 | using metal::uint; 6 | 7 | struct type_1 { 8 | float inner[2]; 9 | }; 10 | struct Ah { 11 | type_1 inner; 12 | }; 13 | 14 | kernel void cs_main( 15 | device Ah const& ah [[user(fake0)]] 16 | ) { 17 | Ah ah_1 = ah; 18 | return; 19 | } 20 | -------------------------------------------------------------------------------- /naga/tests/out/wgsl/wgsl-dualsource.wgsl: -------------------------------------------------------------------------------- 1 | enable dual_source_blending; 2 | 3 | struct FragmentOutput { 4 | @location(0) @blend_src(0) output0_: vec4, 5 | @location(0) @blend_src(1) output1_: vec4, 6 | } 7 | 8 | @fragment 9 | fn main() -> FragmentOutput { 10 | return FragmentOutput(vec4(0.4f, 0.3f, 0.2f, 0.1f), vec4(0.9f, 0.8f, 0.7f, 0.6f)); 11 | } 12 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/workgroup-var-init.wgsl: -------------------------------------------------------------------------------- 1 | struct WStruct { 2 | arr: array, 3 | atom: atomic, 4 | atom_arr: array, 8>, 8>, 5 | } 6 | 7 | var w_mem: WStruct; 8 | 9 | @group(0) @binding(0) 10 | var output: array; 11 | 12 | @compute @workgroup_size(1) 13 | fn main() { 14 | output = w_mem.arr; 15 | } -------------------------------------------------------------------------------- /naga/tests/out/glsl/wgsl-functions-webgl.main.Fragment.glsl: -------------------------------------------------------------------------------- 1 | #version 320 es 2 | 3 | precision highp float; 4 | precision highp int; 5 | 6 | 7 | vec2 test_fma() { 8 | vec2 a = vec2(2.0, 2.0); 9 | vec2 b = vec2(0.5, 0.5); 10 | vec2 c = vec2(0.5, 0.5); 11 | return fma(a, b, c); 12 | } 13 | 14 | void main() { 15 | vec2 _e0 = test_fma(); 16 | return; 17 | } 18 | 19 | -------------------------------------------------------------------------------- /naga/tests/out/msl/wgsl-6772-unpack-expr-accesses.msl: -------------------------------------------------------------------------------- 1 | // language: metal1.0 2 | #include 3 | #include 4 | 5 | using metal::uint; 6 | 7 | 8 | kernel void main_( 9 | ) { 10 | int phony = (int4(12u, 12u >> 8, 12u >> 16, 12u >> 24) << 24 >> 24)[2]; 11 | uint phony_1 = (uint4(12u, 12u >> 8, 12u >> 16, 12u >> 24) << 24 >> 24).y; 12 | return; 13 | } 14 | -------------------------------------------------------------------------------- /wgpu-types/src/env.rs: -------------------------------------------------------------------------------- 1 | use alloc::string::String; 2 | 3 | /// No-std friendly version of `std::env::var`. Returns `None` if the environment variable is not set 4 | /// or we are in a no-std context. 5 | pub fn var(_key: &str) -> Option { 6 | #[cfg(feature = "std")] 7 | return std::env::var(_key).ok(); 8 | 9 | #[cfg(not(feature = "std"))] 10 | return None; 11 | } 12 | -------------------------------------------------------------------------------- /naga/tests/out/glsl/wgsl-6438-conflicting-idents.fs.Fragment.glsl: -------------------------------------------------------------------------------- 1 | #version 310 es 2 | 3 | precision highp float; 4 | precision highp int; 5 | 6 | struct OurVertexShaderOutput { 7 | vec4 position; 8 | vec2 texcoord; 9 | }; 10 | layout(location = 0) out vec4 _fs2p_location0; 11 | 12 | void main() { 13 | _fs2p_location0 = vec4(1.0, 0.0, 0.0, 1.0); 14 | return; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /naga/tests/out/wgsl/wgsl-atomicTexture-int64.wgsl: -------------------------------------------------------------------------------- 1 | @group(0) @binding(0) 2 | var image: texture_storage_2d; 3 | 4 | @compute @workgroup_size(2, 1, 1) 5 | fn cs_main(@builtin(local_invocation_id) id: vec3) { 6 | textureAtomicMax(image, vec2(0i, 0i), 1lu); 7 | workgroupBarrier(); 8 | textureAtomicMin(image, vec2(0i, 0i), 1lu); 9 | return; 10 | } 11 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/workgroup-uniform-load.wgsl: -------------------------------------------------------------------------------- 1 | const SIZE: u32 = 128u; 2 | 3 | var arr_i32: array; 4 | 5 | @compute @workgroup_size(4) 6 | fn test_workgroupUniformLoad(@builtin(workgroup_id) workgroup_id: vec3) { 7 | let x = &arr_i32[workgroup_id.x]; 8 | let val = workgroupUniformLoad(x); 9 | if val > 10 { 10 | workgroupBarrier(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/spv-empty-global-name.hlsl: -------------------------------------------------------------------------------- 1 | struct type_1 { 2 | int member; 3 | }; 4 | 5 | RWByteAddressBuffer unnamed : register(u0); 6 | 7 | void function() 8 | { 9 | int _e3 = asint(unnamed.Load(0)); 10 | unnamed.Store(0, asuint(asint(asuint(_e3) + asuint(int(1))))); 11 | return; 12 | } 13 | 14 | [numthreads(1, 1, 1)] 15 | void main() 16 | { 17 | function(); 18 | } 19 | -------------------------------------------------------------------------------- /naga/tests/out/wgsl/spv-inv-hyperbolic-trig-functions.wgsl: -------------------------------------------------------------------------------- 1 | var a: f32; 2 | 3 | fn main_1() { 4 | var b: f32; 5 | var c: f32; 6 | var d: f32; 7 | 8 | let _e4 = a; 9 | b = asinh(_e4); 10 | let _e6 = a; 11 | c = acosh(_e6); 12 | let _e8 = a; 13 | d = atanh(_e8); 14 | return; 15 | } 16 | 17 | @fragment 18 | fn main() { 19 | main_1(); 20 | } 21 | -------------------------------------------------------------------------------- /naga/tests/out/wgsl/wgsl-clip-distances.wgsl: -------------------------------------------------------------------------------- 1 | enable clip_distances; 2 | 3 | struct VertexOutput { 4 | @builtin(position) position: vec4, 5 | @builtin(clip_distances) clip_distances: array, 6 | } 7 | 8 | @vertex 9 | fn main() -> VertexOutput { 10 | var out: VertexOutput; 11 | 12 | out.clip_distances[0] = 0.5f; 13 | let _e4 = out; 14 | return _e4; 15 | } 16 | -------------------------------------------------------------------------------- /naga/tests/out/wgsl/wgsl-type-alias.wgsl: -------------------------------------------------------------------------------- 1 | @compute @workgroup_size(1, 1, 1) 2 | fn main() { 3 | let a = vec3(0f, 0f, 0f); 4 | let c = vec3(0f); 5 | let b = vec3(vec2(0f), 0f); 6 | let d = vec3(vec2(0f), 0f); 7 | let e = vec3(d); 8 | let f = mat2x2(vec2(1f, 2f), vec2(3f, 4f)); 9 | let g = mat3x3(a, a, a); 10 | return; 11 | } 12 | -------------------------------------------------------------------------------- /naga/tests/in/glsl/constant-array-size.frag: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | const int NUM_VECS = 42; 4 | layout(std140, set = 1, binding = 0) uniform Data { 5 | vec4 vecs[NUM_VECS]; 6 | }; 7 | 8 | vec4 function() { 9 | vec4 sum = vec4(0); 10 | for (int i = 0; i < NUM_VECS; i++) { 11 | sum += vecs[i]; 12 | } 13 | return sum; 14 | } 15 | 16 | void main() { 17 | function(); 18 | } 19 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/bits.toml: -------------------------------------------------------------------------------- 1 | # TODO(https://github.com/gfx-rs/wgpu/issues/8154): enable only `F16_IN_F32` capability 2 | capabilities = "SHADER_FLOAT16_IN_FLOAT32" 3 | 4 | [msl] 5 | fake_missing_bindings = false 6 | lang_version = [1, 2] 7 | spirv_cross_compatibility = false 8 | zero_initialize_workgroup_memory = true 9 | 10 | [msl.per_entry_point_map.main] 11 | resources = [] 12 | sizes_buffer = 0 13 | -------------------------------------------------------------------------------- /naga/tests/out/glsl/wgsl-quad.fs_extra.Fragment.glsl: -------------------------------------------------------------------------------- 1 | #version 300 es 2 | 3 | precision highp float; 4 | precision highp int; 5 | 6 | struct VertexOutput { 7 | vec2 uv; 8 | vec4 position; 9 | }; 10 | const float c_scale = 1.2; 11 | 12 | layout(location = 0) out vec4 _fs2p_location0; 13 | 14 | void main() { 15 | _fs2p_location0 = vec4(0.0, 0.5, 0.0, 0.5); 16 | return; 17 | } 18 | 19 | -------------------------------------------------------------------------------- /naga/tests/out/wgsl/glsl-anonymous-entry-point-type.frag.wgsl: -------------------------------------------------------------------------------- 1 | struct FragmentOutput { 2 | @location(0) o_Target: vec4, 3 | } 4 | 5 | var o_Target: vec4; 6 | 7 | fn main_1() { 8 | o_Target = vec4(0f); 9 | return; 10 | } 11 | 12 | @fragment 13 | fn main() -> FragmentOutput { 14 | main_1(); 15 | let _e1 = o_Target; 16 | return FragmentOutput(_e1); 17 | } 18 | -------------------------------------------------------------------------------- /tests/tests/wgpu-gpu/instance.rs: -------------------------------------------------------------------------------- 1 | use wgpu_test::{gpu_test, GpuTestConfiguration, GpuTestInitializer, TestParameters}; 2 | 3 | pub fn all_tests(vec: &mut Vec) { 4 | vec.push(INITIALIZE); 5 | } 6 | 7 | #[gpu_test] 8 | static INITIALIZE: GpuTestConfiguration = GpuTestConfiguration::new() 9 | .parameters(TestParameters::default().enable_noop()) 10 | .run_sync(|_ctx| {}); 11 | -------------------------------------------------------------------------------- /.github/actions/install-warp/action.yml: -------------------------------------------------------------------------------- 1 | name: "Install WARP" 2 | description: "Install WARP" 3 | inputs: 4 | target-dir: 5 | description: "The directory into which to install the WARP DLL." 6 | required: true 7 | runs: 8 | using: "composite" 9 | steps: 10 | - shell: bash 11 | run: | 12 | set -e 13 | 14 | cargo xtask install-warp --target-dir ${{ inputs.target-dir }} 15 | -------------------------------------------------------------------------------- /naga/tests/out/glsl/spv-subgroup-barrier.main.Compute.glsl: -------------------------------------------------------------------------------- 1 | #version 310 es 2 | 3 | precision highp float; 4 | precision highp int; 5 | 6 | layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in; 7 | 8 | 9 | void function() { 10 | subgroupMemoryBarrier(); 11 | subgroupMemoryBarrier(); 12 | barrier(); 13 | return; 14 | } 15 | 16 | void main() { 17 | function(); 18 | } 19 | 20 | -------------------------------------------------------------------------------- /examples/features/src/skybox/README.md: -------------------------------------------------------------------------------- 1 | # skybox 2 | 3 | This animated example demonstrates loading a Wavefront OBJ model, and rendering it with skybox and simple reflections. 4 | It hooks up `winit` mouse controls for camera rotation around the model at the center. 5 | 6 | ## To Run 7 | 8 | ``` 9 | cargo run --bin wgpu-examples skybox 10 | ``` 11 | 12 | ## Screenshots 13 | 14 | ![Skybox](./screenshot.png) 15 | -------------------------------------------------------------------------------- /naga/tests/in/glsl/prepostfix.frag: -------------------------------------------------------------------------------- 1 | #version 450 core 2 | 3 | void main() { 4 | int scalar_target; 5 | int scalar = 1; 6 | scalar_target = scalar++; 7 | scalar_target = --scalar; 8 | 9 | uvec2 vec_target; 10 | uvec2 vec = uvec2(1); 11 | vec_target = vec--; 12 | vec_target = ++vec; 13 | 14 | mat4x3 mat_target; 15 | mat4x3 mat = mat4x3(1); 16 | mat_target = mat++; 17 | mat_target = --mat; 18 | } 19 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/functions-optimized-by-capability.toml: -------------------------------------------------------------------------------- 1 | # Turn on optimizations for `dot4I8Packed` and `dot4U8Packed` by enabling the 2 | # required capabilities on a SPIR-V version where these capabilities are only 3 | # available via the extension "SPV_KHR_integer_dot_product". 4 | 5 | targets = "SPIRV" 6 | 7 | [spv] 8 | capabilities = ["DotProduct", "DotProductInput4x8BitPacked"] 9 | version = [1, 0] 10 | -------------------------------------------------------------------------------- /examples/features/src/hello_triangle/shader.wgsl: -------------------------------------------------------------------------------- 1 | @vertex 2 | fn vs_main(@builtin(vertex_index) in_vertex_index: u32) -> @builtin(position) vec4 { 3 | let x = f32(i32(in_vertex_index) - 1); 4 | let y = f32(i32(in_vertex_index & 1u) * 2 - 1); 5 | return vec4(x, y, 0.0, 1.0); 6 | } 7 | 8 | @fragment 9 | fn fs_main() -> @location(0) vec4 { 10 | return vec4(1.0, 0.0, 0.0, 1.0); 11 | } 12 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/ray-query.toml: -------------------------------------------------------------------------------- 1 | capabilities = "RAY_QUERY" 2 | targets = "SPIRV | METAL | HLSL" 3 | 4 | [msl] 5 | fake_missing_bindings = true 6 | lang_version = [2, 4] 7 | spirv_cross_compatibility = false 8 | zero_initialize_workgroup_memory = false 9 | 10 | [hlsl] 11 | shader_model = "V6_5" 12 | fake_missing_bindings = true 13 | zero_initialize_workgroup_memory = true 14 | 15 | [spv] 16 | version = [1, 4] 17 | -------------------------------------------------------------------------------- /naga/tests/out/msl/spv-subgroup-barrier.msl: -------------------------------------------------------------------------------- 1 | // language: metal2.0 2 | #include 3 | #include 4 | 5 | using metal::uint; 6 | 7 | 8 | void function( 9 | ) { 10 | metal::simdgroup_barrier(metal::mem_flags::mem_threadgroup); 11 | metal::simdgroup_barrier(metal::mem_flags::mem_threadgroup); 12 | return; 13 | } 14 | 15 | kernel void main_( 16 | ) { 17 | function(); 18 | } 19 | -------------------------------------------------------------------------------- /naga/tests/out/msl/wgsl-select.msl: -------------------------------------------------------------------------------- 1 | // language: metal1.0 2 | #include 3 | #include 4 | 5 | using metal::uint; 6 | 7 | 8 | kernel void main_( 9 | ) { 10 | metal::int2 x0_ = metal::int2(1, 2); 11 | metal::float2 i1_ = {}; 12 | int _e12 = x0_.x; 13 | int _e14 = x0_.y; 14 | i1_ = (_e12 < _e14) ? metal::float2(0.0, 1.0) : metal::float2(1.0, 0.0); 15 | return; 16 | } 17 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/aliased-ray-query.toml: -------------------------------------------------------------------------------- 1 | capabilities = "RAY_QUERY" 2 | targets = "SPIRV | METAL | HLSL" 3 | 4 | [msl] 5 | fake_missing_bindings = true 6 | lang_version = [2, 4] 7 | spirv_cross_compatibility = false 8 | zero_initialize_workgroup_memory = false 9 | 10 | [hlsl] 11 | shader_model = "V6_5" 12 | fake_missing_bindings = true 13 | zero_initialize_workgroup_memory = true 14 | 15 | [spv] 16 | version = [1, 4] 17 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-atomicCompareExchange.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ], 6 | compute:[ 7 | ( 8 | entry_point:"test_atomic_compare_exchange_i32_", 9 | target_profile:"cs_5_1", 10 | ), 11 | ( 12 | entry_point:"test_atomic_compare_exchange_u32_", 13 | target_profile:"cs_5_1", 14 | ), 15 | ], 16 | ) 17 | -------------------------------------------------------------------------------- /player/tests/player/data/all.ron: -------------------------------------------------------------------------------- 1 | ( 2 | backends: "VULKAN | GL | METAL | DX12 | BROWSER_WEBGPU", 3 | tests: [ 4 | "bind-group.ron", 5 | "buffer-copy.ron", 6 | "clear-buffer-texture.ron", 7 | "pipeline-statistics-query.ron", 8 | "quad.ron", 9 | "zero-init-buffer.ron", 10 | "zero-init-texture-binding.ron", 11 | "zero-init-texture-copytobuffer.ron", 12 | "zero-init-texture-rendertarget.ron", 13 | ], 14 | ) -------------------------------------------------------------------------------- /tests/tests/wgpu-gpu/external_texture/load.wgsl: -------------------------------------------------------------------------------- 1 | @group(0) @binding(0) 2 | var tex: texture_external; 3 | 4 | @group(0) @binding(1) 5 | var coords: array>; 6 | @group(0) @binding(2) 7 | var output: array>; 8 | 9 | @compute @workgroup_size(1) 10 | fn main(@builtin(global_invocation_id) id: vec3) { 11 | output[id.x] = textureLoad(tex, coords[id.x]); 12 | } 13 | -------------------------------------------------------------------------------- /naga/src/common/mod.rs: -------------------------------------------------------------------------------- 1 | //! Code common to the front and backends for specific languages. 2 | 3 | mod diagnostic_debug; 4 | mod diagnostic_display; 5 | pub mod predeclared; 6 | pub mod wgsl; 7 | 8 | pub use diagnostic_debug::{DiagnosticDebug, ForDebug, ForDebugWithTypes}; 9 | pub use diagnostic_display::DiagnosticDisplay; 10 | 11 | // Re-exported here for backwards compatibility 12 | pub use super::proc::vector_size_str; 13 | -------------------------------------------------------------------------------- /naga/tests/in/glsl/buffer.frag: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(set = 0, binding = 0) buffer testBufferBlock { 4 | uint[] data; 5 | } testBuffer; 6 | 7 | layout(set = 0, binding = 2) readonly buffer testBufferReadOnlyBlock { 8 | uint[] data; 9 | } testBufferReadOnly; 10 | 11 | void main() { 12 | uint a = testBuffer.data[0]; 13 | testBuffer.data[1] = 2; 14 | 15 | uint b = testBufferReadOnly.data[0]; 16 | } 17 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-atomicCompareExchange-int64.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ], 4 | fragment:[ 5 | ], 6 | compute:[ 7 | ( 8 | entry_point:"test_atomic_compare_exchange_i64_", 9 | target_profile:"cs_6_6", 10 | ), 11 | ( 12 | entry_point:"test_atomic_compare_exchange_u64_", 13 | target_profile:"cs_6_6", 14 | ), 15 | ], 16 | ) 17 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-phony_assignment.hlsl: -------------------------------------------------------------------------------- 1 | cbuffer binding : register(b0) { float binding; } 2 | 3 | int five() 4 | { 5 | return int(5); 6 | } 7 | 8 | [numthreads(1, 1, 1)] 9 | void main(uint3 id : SV_DispatchThreadID) 10 | { 11 | float phony = binding; 12 | float phony_1 = binding; 13 | const int _e6 = five(); 14 | const int _e7 = five(); 15 | float phony_2 = binding; 16 | return; 17 | } 18 | -------------------------------------------------------------------------------- /naga/tests/out/msl/wgsl-barycentrics.msl: -------------------------------------------------------------------------------- 1 | // language: metal2.3 2 | #include 3 | #include 4 | 5 | using metal::uint; 6 | 7 | 8 | struct fs_mainInput { 9 | }; 10 | struct fs_mainOutput { 11 | metal::float4 member [[color(0)]]; 12 | }; 13 | fragment fs_mainOutput fs_main( 14 | metal::float3 bary [[barycentric_coord]] 15 | ) { 16 | return fs_mainOutput { metal::float4(bary, 1.0) }; 17 | } 18 | -------------------------------------------------------------------------------- /naga/tests/out/wgsl/wgsl-f64.wgsl: -------------------------------------------------------------------------------- 1 | const k: f64 = 2.0lf; 2 | 3 | var v: f64 = 1.0lf; 4 | 5 | fn f(x: f64) -> f64 { 6 | var z: f64; 7 | var w: f64 = -1.0lf; 8 | 9 | let phony = v; 10 | let y = (30.0lf + 400.0lf); 11 | z = (y + 5.0lf); 12 | return (((x + y) + k) + 5.0lf); 13 | } 14 | 15 | @compute @workgroup_size(1, 1, 1) 16 | fn main() { 17 | let _e1 = f(6.0lf); 18 | return; 19 | } 20 | -------------------------------------------------------------------------------- /naga/tests/out/wgsl/wgsl-phony_assignment.wgsl: -------------------------------------------------------------------------------- 1 | @group(0) @binding(0) 2 | var binding: f32; 3 | 4 | fn five() -> i32 { 5 | return 5i; 6 | } 7 | 8 | @compute @workgroup_size(1, 1, 1) 9 | fn main(@builtin(global_invocation_id) id: vec3) { 10 | let phony = binding; 11 | let phony_1 = binding; 12 | let _e6 = five(); 13 | let _e7 = five(); 14 | let phony_2 = binding; 15 | return; 16 | } 17 | -------------------------------------------------------------------------------- /examples/features/src/ray_scene/cube.mtl: -------------------------------------------------------------------------------- 1 | # Blender MTL File: 'None' 2 | # Material Count: 2 3 | 4 | newmtl Material 5 | Ns 250.000000 6 | Ka 1.000000 1.000000 1.000000 7 | Kd 0.000000 0.009087 0.800000 8 | Ks 0.500000 0.500000 0.500000 9 | Ke 0.000000 0.000000 0.000000 10 | Ni 1.450000 11 | d 1.000000 12 | illum 2 13 | 14 | newmtl None 15 | Ns 500 16 | Ka 0.8 0.8 0.8 17 | Kd 0.8 0.8 0.8 18 | Ks 0.8 0.8 0.8 19 | d 1 20 | illum 2 21 | -------------------------------------------------------------------------------- /examples/standalone/custom_backend/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "wgpu-example-custom-backend" 3 | edition = "2021" 4 | rust-version = "1.92" 5 | publish = false 6 | 7 | [features] 8 | default = ["web"] 9 | web = ["wgpu/web"] 10 | 11 | [dependencies] 12 | wgpu = { version = "28.0.0", features = [ 13 | "custom", 14 | "wgsl", 15 | ], default-features = false } 16 | pollster = { version = "0.4", features = ["macro"] } 17 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/f16.toml: -------------------------------------------------------------------------------- 1 | # No GLSL support for f16 2 | targets = "SPIRV | METAL | HLSL | WGSL" 3 | capabilities = "SHADER_FLOAT16" 4 | 5 | [spv] 6 | version = [1, 0] 7 | 8 | [hlsl] 9 | shader_model = "V6_2" 10 | special_constants_binding = { space = 1, register = 0 } 11 | immediates_target = { space = 0, register = 0 } 12 | 13 | lang_version = [1, 0] 14 | per_entry_point_map = {} 15 | zero_initialize_workgroup_memory = true 16 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/texture-arg.wgsl: -------------------------------------------------------------------------------- 1 | @group(0) @binding(0) 2 | var Texture: texture_2d; 3 | @group(0) @binding(1) 4 | var Sampler: sampler; 5 | 6 | fn test(Passed_Texture: texture_2d, Passed_Sampler: sampler) -> vec4 { 7 | return textureSample(Passed_Texture, Passed_Sampler, vec2(0.0, 0.0)); 8 | } 9 | 10 | @fragment 11 | fn main() -> @location(0) vec4 { 12 | return test(Texture, Sampler); 13 | } 14 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/array-in-function-return-type.wgsl: -------------------------------------------------------------------------------- 1 | fn ret_array() -> array { 2 | return array(1.0, 2.0); 3 | } 4 | 5 | fn ret_array_array() -> array, 3> { 6 | return array, 3>(ret_array(), ret_array(), ret_array()); 7 | } 8 | 9 | @fragment 10 | fn main() -> @location(0) vec4 { 11 | let a = ret_array_array(); 12 | return vec4(a[0][0], a[0][1], 0.0, 1.0); 13 | } 14 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/atomicOps-int64.toml: -------------------------------------------------------------------------------- 1 | capabilities = "SHADER_INT64 | SHADER_INT64_ATOMIC_ALL_OPS" 2 | targets = "SPIRV | HLSL | WGSL" 3 | 4 | [hlsl] 5 | shader_model = "V6_6" 6 | fake_missing_bindings = true 7 | immediates_target = { register = 0, space = 0 } 8 | restrict_indexing = true 9 | special_constants_binding = { register = 0, space = 1 } 10 | zero_initialize_workgroup_memory = true 11 | 12 | [spv] 13 | version = [1, 0] 14 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/phony_assignment.wgsl: -------------------------------------------------------------------------------- 1 | @group(0) @binding(0) var binding: f32; 2 | 3 | fn five() -> i32 { 4 | return 5; 5 | } 6 | 7 | @compute @workgroup_size(1) fn main( 8 | @builtin(global_invocation_id) id: vec3 9 | ) { 10 | _ = binding; 11 | _ = binding; 12 | let a = 5; 13 | _ = a; 14 | _ = five(); 15 | let b = five(); 16 | // check for name collision 17 | let phony = binding; 18 | } -------------------------------------------------------------------------------- /naga/tests/out/glsl/wgsl-select.main.Compute.glsl: -------------------------------------------------------------------------------- 1 | #version 310 es 2 | 3 | precision highp float; 4 | precision highp int; 5 | 6 | layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; 7 | 8 | 9 | void main() { 10 | ivec2 x0_ = ivec2(1, 2); 11 | vec2 i1_ = vec2(0.0); 12 | int _e12 = x0_.x; 13 | int _e14 = x0_.y; 14 | i1_ = ((_e12 < _e14) ? vec2(0.0, 1.0) : vec2(1.0, 0.0)); 15 | return; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /wgpu-core/src/command/ffi.rs: -------------------------------------------------------------------------------- 1 | //! Types that are useful for FFI bindings to `wgpu`. 2 | 3 | use crate::{command::IdReferences, id}; 4 | 5 | pub type TexelCopyBufferInfo = wgt::TexelCopyBufferInfo; 6 | pub type TexelCopyTextureInfo = wgt::TexelCopyTextureInfo; 7 | pub type CopyExternalImageDestInfo = wgt::CopyExternalImageDestInfo; 8 | 9 | pub type Command = super::Command; 10 | -------------------------------------------------------------------------------- /naga/tests/in/glsl/bool-select.frag: -------------------------------------------------------------------------------- 1 | #version 440 core 2 | precision highp float; 3 | 4 | layout(location = 0) out vec4 o_color; 5 | 6 | float TevPerCompGT(float a, float b) { 7 | return float(a > b); 8 | } 9 | 10 | vec3 TevPerCompGT(vec3 a, vec3 b) { 11 | return vec3(greaterThan(a, b)); 12 | } 13 | 14 | void main() { 15 | o_color.rgb = TevPerCompGT(vec3(3.0), vec3(5.0)); 16 | o_color.a = TevPerCompGT(3.0, 5.0); 17 | } 18 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/unconsumed_vertex_outputs_vert.wgsl: -------------------------------------------------------------------------------- 1 | // Out of order to test sorting. 2 | struct VertexOut { 3 | @builtin(position) position: vec4, 4 | @location(1) value: f32, 5 | @location(2) unused_value2: vec4, 6 | @location(0) unused_value: f32, 7 | @location(3) value2: f32, 8 | } 9 | 10 | @vertex 11 | fn vs_main() -> VertexOut { 12 | return VertexOut(vec4(1.0), 1.0, vec4(2.0), 1.0, 0.5); 13 | } 14 | -------------------------------------------------------------------------------- /naga/tests/out/spv/wgsl-empty.spvasm: -------------------------------------------------------------------------------- 1 | ; SPIR-V 2 | ; Version: 1.1 3 | ; Generator: rspirv 4 | ; Bound: 7 5 | OpCapability Shader 6 | %1 = OpExtInstImport "GLSL.std.450" 7 | OpMemoryModel Logical GLSL450 8 | OpEntryPoint GLCompute %4 "main" 9 | OpExecutionMode %4 LocalSize 1 1 1 10 | %2 = OpTypeVoid 11 | %5 = OpTypeFunction %2 12 | %4 = OpFunction %2 None %5 13 | %3 = OpLabel 14 | OpBranch %6 15 | %6 = OpLabel 16 | OpReturn 17 | OpFunctionEnd -------------------------------------------------------------------------------- /naga/tests/out/wgsl/wgsl-workgroup-var-init.wgsl: -------------------------------------------------------------------------------- 1 | struct WStruct { 2 | arr: array, 3 | atom: atomic, 4 | atom_arr: array, 8>, 8>, 5 | } 6 | 7 | var w_mem: WStruct; 8 | @group(0) @binding(0) 9 | var output: array; 10 | 11 | @compute @workgroup_size(1, 1, 1) 12 | fn main() { 13 | let _e3 = w_mem.arr; 14 | output = _e3; 15 | return; 16 | } 17 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/atomicCompareExchange-int64.toml: -------------------------------------------------------------------------------- 1 | capabilities = "SHADER_INT64 | SHADER_INT64_ATOMIC_ALL_OPS" 2 | targets = "SPIRV | HLSL | WGSL" 3 | 4 | [hlsl] 5 | shader_model = "V6_6" 6 | fake_missing_bindings = true 7 | immediates_target = { register = 0, space = 0 } 8 | restrict_indexing = true 9 | special_constants_binding = { register = 0, space = 1 } 10 | zero_initialize_workgroup_memory = true 11 | 12 | [spv] 13 | version = [1, 0] 14 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/bounds-check-image-restrict.toml: -------------------------------------------------------------------------------- 1 | targets = "SPIRV | METAL | GLSL" 2 | 3 | [bounds_check_policies] 4 | image_load = "Restrict" 5 | 6 | [msl] 7 | fake_missing_bindings = true 8 | lang_version = [1, 2] 9 | spirv_cross_compatibility = false 10 | zero_initialize_workgroup_memory = true 11 | 12 | [glsl] 13 | version.Desktop = 430 14 | zero_initialize_workgroup_memory = true 15 | 16 | [spv] 17 | debug = true 18 | version = [1, 1] 19 | -------------------------------------------------------------------------------- /naga/tests/out/glsl/wgsl-array-in-ctor.cs_main.Compute.glsl: -------------------------------------------------------------------------------- 1 | #version 310 es 2 | 3 | precision highp float; 4 | precision highp int; 5 | 6 | layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; 7 | 8 | struct Ah { 9 | float inner[2]; 10 | }; 11 | layout(std430) readonly buffer Ah_block_0Compute { Ah _group_0_binding_0_cs; }; 12 | 13 | 14 | void main() { 15 | Ah ah_1 = _group_0_binding_0_cs; 16 | return; 17 | } 18 | 19 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-f64.hlsl: -------------------------------------------------------------------------------- 1 | static const double k = 2.0L; 2 | 3 | static double v = 1.0L; 4 | 5 | double f(double x) 6 | { 7 | double z = (double)0; 8 | double w = -1.0L; 9 | 10 | double phony = v; 11 | double y = (30.0L + 400.0L); 12 | z = (y + 5.0L); 13 | return (((x + y) + k) + 5.0L); 14 | } 15 | 16 | [numthreads(1, 1, 1)] 17 | void main() 18 | { 19 | const double _e1 = f(6.0L); 20 | return; 21 | } 22 | -------------------------------------------------------------------------------- /naga/tests/in/glsl/inverse-polyfill.frag: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | void main() { 4 | vec4 a4 = vec4(1.0); 5 | vec4 b4 = vec4(2.0); 6 | mat4 m4 = mat4(a4, b4, a4, b4); 7 | 8 | vec3 a3 = vec3(1.0); 9 | vec3 b3 = vec3(2.0); 10 | mat3 m3 = mat3(a3, b3, a3); 11 | 12 | mat2 m2 = mat2(1.0, 2.0, 3.0, 4.0); 13 | 14 | mat4 m4_inverse = inverse(m4); 15 | mat3 m3_inverse = inverse(m3); 16 | mat2 m2_inverse = inverse(m2); 17 | } -------------------------------------------------------------------------------- /naga/tests/in/wgsl/bounds-check-image-rzsw-depth.toml: -------------------------------------------------------------------------------- 1 | targets = "SPIRV | METAL" 2 | 3 | [bounds_check_policies] 4 | image_load = "ReadZeroSkipWrite" 5 | 6 | [msl] 7 | fake_missing_bindings = true 8 | lang_version = [1, 2] 9 | spirv_cross_compatibility = false 10 | zero_initialize_workgroup_memory = true 11 | 12 | [glsl] 13 | version.Desktop = 430 14 | zero_initialize_workgroup_memory = true 15 | 16 | [spv] 17 | debug = true 18 | version = [1, 1] 19 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/bounds-check-image-rzsw.toml: -------------------------------------------------------------------------------- 1 | targets = "SPIRV | METAL | GLSL" 2 | 3 | [bounds_check_policies] 4 | image_load = "ReadZeroSkipWrite" 5 | 6 | [msl] 7 | fake_missing_bindings = true 8 | lang_version = [1, 2] 9 | spirv_cross_compatibility = false 10 | zero_initialize_workgroup_memory = true 11 | 12 | [glsl] 13 | version.Desktop = 430 14 | zero_initialize_workgroup_memory = true 15 | 16 | [spv] 17 | debug = true 18 | version = [1, 1] 19 | -------------------------------------------------------------------------------- /naga/tests/out/glsl/glsl-variations.frag.main.Fragment.glsl: -------------------------------------------------------------------------------- 1 | #version 310 es 2 | 3 | precision highp float; 4 | precision highp int; 5 | 6 | uniform highp samplerCube _group_0_binding_0_fs; 7 | 8 | 9 | void main_1() { 10 | ivec2 sizeCube = ivec2(0); 11 | float a = 1.0; 12 | sizeCube = ivec2(uvec2(textureSize(_group_0_binding_0_fs, 0).xy)); 13 | return; 14 | } 15 | 16 | void main() { 17 | main_1(); 18 | return; 19 | } 20 | 21 | -------------------------------------------------------------------------------- /naga/tests/out/wgsl/glsl-932-for-loop-if.frag.wgsl: -------------------------------------------------------------------------------- 1 | fn main_1() { 2 | var i: i32 = 0i; 3 | 4 | loop { 5 | let _e2 = i; 6 | if !((_e2 < 1i)) { 7 | break; 8 | } 9 | { 10 | } 11 | continuing { 12 | let _e6 = i; 13 | i = (_e6 + 1i); 14 | } 15 | } 16 | return; 17 | } 18 | 19 | @fragment 20 | fn main() { 21 | main_1(); 22 | return; 23 | } 24 | -------------------------------------------------------------------------------- /tests/tests/wgpu-gpu/multiview/shader.wgsl: -------------------------------------------------------------------------------- 1 | const triangles = array(vec2f(-1.0, -1.0), vec2f(3.0, -1.0), vec2f(-1.0, 3.0)); 2 | 3 | @vertex 4 | fn vs_main(@builtin(vertex_index) vertex_index: u32) -> @builtin(position) vec4f { 5 | return vec4f(triangles[vertex_index], 0.0, 1.0); 6 | } 7 | 8 | @fragment 9 | fn fs_main(@builtin(view_index) view_index: u32) -> @location(0) vec4f { 10 | return vec4f(f32(view_index) * 0.25 + 0.125); 11 | } -------------------------------------------------------------------------------- /examples/features/src/stencil_triangles/shader.wgsl: -------------------------------------------------------------------------------- 1 | struct VertexOutput { 2 | @builtin(position) position: vec4, 3 | }; 4 | 5 | @vertex 6 | fn vs_main(@location(0) position: vec4) -> VertexOutput { 7 | var result: VertexOutput; 8 | result.position = position; 9 | return result; 10 | } 11 | 12 | @fragment 13 | fn fs_main(vertex: VertexOutput) -> @location(0) vec4 { 14 | return vec4(0.97, 0.88, 0.21, 1.0); 15 | } 16 | -------------------------------------------------------------------------------- /naga/tests/out/glsl/wgsl-force_point_size_vertex_shader_webgl.vs_main.Vertex.glsl: -------------------------------------------------------------------------------- 1 | #version 300 es 2 | 3 | precision highp float; 4 | precision highp int; 5 | 6 | 7 | void main() { 8 | uint in_vertex_index = uint(gl_VertexID); 9 | float x = float((int(in_vertex_index) - 1)); 10 | float y = float(((int((in_vertex_index & 1u)) * 2) - 1)); 11 | gl_Position = vec4(x, y, 0.0, 1.0); 12 | gl_PointSize = 1.0; 13 | return; 14 | } 15 | 16 | -------------------------------------------------------------------------------- /examples/features/src/render_to_texture/README.md: -------------------------------------------------------------------------------- 1 | # render_to_texture 2 | 3 | Similar to hello-triangle but instead of rendering to a window or canvas, renders to a texture that is then output as an image like the storage-texture example. 4 | 5 | If all goes well, the end result should look familiarly like hello-triangle with its red triangle on a green background. 6 | 7 | ## To Run 8 | 9 | ``` 10 | cargo run --bin wgpu-examples render_to_texture 11 | ``` 12 | -------------------------------------------------------------------------------- /naga/tests/in/glsl/quad_glsl.frag: -------------------------------------------------------------------------------- 1 | #version 450 2 | layout(location = 0) in vec2 v_uv; 3 | #ifdef TEXTURE 4 | layout(set = 0, binding = 0) uniform texture2D u_texture; 5 | layout(set = 0, binding = 1) uniform sampler u_sampler; 6 | #endif 7 | layout(location = 0) out vec4 o_color; 8 | 9 | void main() { 10 | #ifdef TEXTURE 11 | o_color = texture(sampler2D(u_texture, u_sampler), v_uv); 12 | #else 13 | o_color = vec4(1.0, 1.0, 1.0, 1.0); 14 | #endif 15 | } 16 | -------------------------------------------------------------------------------- /naga/tests/out/glsl/wgsl-separate-entry-points.fragment.Fragment.glsl: -------------------------------------------------------------------------------- 1 | #version 310 es 2 | 3 | precision highp float; 4 | precision highp int; 5 | 6 | layout(location = 0) out vec4 _fs2p_location0; 7 | 8 | void derivatives() { 9 | float x = dFdx(0.0); 10 | float y = dFdy(0.0); 11 | float width = fwidth(0.0); 12 | return; 13 | } 14 | 15 | void main() { 16 | derivatives(); 17 | _fs2p_location0 = vec4(0.0); 18 | return; 19 | } 20 | 21 | -------------------------------------------------------------------------------- /tests/tests/wgpu-gpu/shader_primitive_index/primitive_index.wgsl: -------------------------------------------------------------------------------- 1 | @vertex 2 | fn vs_main(@location(0) xy: vec2) -> @builtin(position) vec4 { 3 | return vec4(xy, 0.0, 1.0); 4 | } 5 | 6 | @fragment 7 | fn fs_main(@builtin(primitive_index) index: u32) -> @location(0) vec4 { 8 | if ((index % 2u) == 0u) { 9 | return vec4(1.0, 0.0, 0.0, 1.0); 10 | } else { 11 | return vec4(0.0, 0.0, 1.0, 1.0); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/push-constants.toml: -------------------------------------------------------------------------------- 1 | capabilities = "IMMEDIATES" 2 | targets = "GLSL | HLSL" 3 | 4 | [hlsl] 5 | fake_missing_bindings = true 6 | immediates_target = { register = 0, space = 0 } 7 | restrict_indexing = true 8 | special_constants_binding = { register = 0, space = 1 } 9 | zero_initialize_workgroup_memory = true 10 | 11 | [glsl] 12 | version.Embedded = { is_webgl = false, version = 320 } 13 | writer_flags = "" 14 | zero_initialize_workgroup_memory = true 15 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-access.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ( 4 | entry_point:"foo_vert", 5 | target_profile:"vs_5_1", 6 | ), 7 | ], 8 | fragment:[ 9 | ( 10 | entry_point:"foo_frag", 11 | target_profile:"ps_5_1", 12 | ), 13 | ], 14 | compute:[ 15 | ( 16 | entry_point:"foo_compute", 17 | target_profile:"cs_5_1", 18 | ), 19 | ], 20 | ) 21 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-quad.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ( 4 | entry_point:"vert_main", 5 | target_profile:"vs_5_1", 6 | ), 7 | ], 8 | fragment:[ 9 | ( 10 | entry_point:"frag_main", 11 | target_profile:"ps_5_1", 12 | ), 13 | ( 14 | entry_point:"fs_extra", 15 | target_profile:"ps_5_1", 16 | ), 17 | ], 18 | compute:[ 19 | ], 20 | ) 21 | -------------------------------------------------------------------------------- /naga/tests/out/msl/wgsl-7995-unicode-idents.msl: -------------------------------------------------------------------------------- 1 | // language: metal1.0 2 | #include 3 | #include 4 | 5 | using metal::uint; 6 | 7 | 8 | float compute( 9 | device float const& asdf 10 | ) { 11 | float _e1 = asdf; 12 | float u03b8_2_ = _e1 + 9001.0; 13 | return u03b8_2_; 14 | } 15 | 16 | kernel void main_( 17 | device float const& asdf [[user(fake0)]] 18 | ) { 19 | float _e0 = compute(asdf); 20 | return; 21 | } 22 | -------------------------------------------------------------------------------- /naga/tests/out/wgsl/spv-do-while.wgsl: -------------------------------------------------------------------------------- 1 | fn f_u0028_b1_u003b(cond: ptr) { 2 | loop { 3 | continue; 4 | continuing { 5 | let _e1 = (*cond); 6 | break if !(_e1); 7 | } 8 | } 9 | return; 10 | } 11 | 12 | fn main_1() { 13 | var param: bool; 14 | 15 | param = false; 16 | f_u0028_b1_u003b((¶m)); 17 | return; 18 | } 19 | 20 | @fragment 21 | fn main() { 22 | main_1(); 23 | } 24 | -------------------------------------------------------------------------------- /naga/tests/out/wgsl/wgsl-workgroup-uniform-load.wgsl: -------------------------------------------------------------------------------- 1 | const SIZE: u32 = 128u; 2 | 3 | var arr_i32_: array; 4 | 5 | @compute @workgroup_size(4, 1, 1) 6 | fn test_workgroupUniformLoad(@builtin(workgroup_id) workgroup_id: vec3) { 7 | let x = (&arr_i32_[workgroup_id.x]); 8 | let _e4 = workgroupUniformLoad(x); 9 | if (_e4 > 10i) { 10 | workgroupBarrier(); 11 | return; 12 | } else { 13 | return; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/tests/wgpu-gpu/image_atomics/image_32_atomics.wgsl: -------------------------------------------------------------------------------- 1 | @group(0) @binding(0) 2 | var image: texture_storage_2d; 3 | 4 | @compute 5 | @workgroup_size(4, 4, 1) 6 | fn cs_main(@builtin(local_invocation_id) id: vec3, @builtin(workgroup_id) group_id: vec3) { 7 | let pixel = id + group_id * 4; 8 | textureAtomicMax(image, pixel.xy, u32(pixel.x)); 9 | 10 | storageBarrier(); 11 | 12 | textureAtomicMin(image, pixel.xy, u32(pixel.y)); 13 | } -------------------------------------------------------------------------------- /tests/tests/wgpu-gpu/image_atomics/image_64_atomics.wgsl: -------------------------------------------------------------------------------- 1 | @group(0) @binding(0) 2 | var image: texture_storage_2d; 3 | 4 | @compute 5 | @workgroup_size(4, 4, 1) 6 | fn cs_main(@builtin(local_invocation_id) id: vec3, @builtin(workgroup_id) group_id: vec3) { 7 | let pixel = id + group_id * 4; 8 | textureAtomicMax(image, pixel.xy, u64(pixel.x)); 9 | 10 | storageBarrier(); 11 | 12 | textureAtomicMin(image, pixel.xy, u64(pixel.y)); 13 | } -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-shadow.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ( 4 | entry_point:"vs_main", 5 | target_profile:"vs_5_1", 6 | ), 7 | ], 8 | fragment:[ 9 | ( 10 | entry_point:"fs_main", 11 | target_profile:"ps_5_1", 12 | ), 13 | ( 14 | entry_point:"fs_main_without_storage", 15 | target_profile:"ps_5_1", 16 | ), 17 | ], 18 | compute:[ 19 | ], 20 | ) 21 | -------------------------------------------------------------------------------- /examples/features/src/storage_texture/README.md: -------------------------------------------------------------------------------- 1 | # storage_texture 2 | 3 | A simple example that uses a storage texture to compute an image of the Mandelbrot set (https://en.wikipedia.org/wiki/Mandelbrot_set) and either saves it as an image or presents it to the browser screen in such a way that it can be saved as an image. 4 | 5 | ## To Run 6 | 7 | ``` 8 | cargo run --bin wgpu-examples storage_texture 9 | ``` 10 | 11 | 12 | ## Example Output 13 | 14 | ![Example output](./example.png) -------------------------------------------------------------------------------- /naga/tests/in/wgsl/6438-conflicting-idents.wgsl: -------------------------------------------------------------------------------- 1 | struct OurVertexShaderOutput { 2 | @builtin(position) position: vec4f, 3 | @location(0) texcoord: vec2f, 4 | }; 5 | 6 | @vertex fn vs( 7 | @location(0) xy: vec2f 8 | ) -> OurVertexShaderOutput { 9 | var vsOutput: OurVertexShaderOutput; 10 | vsOutput.position = vec4f(xy, 0.0, 1.0); 11 | return vsOutput; 12 | } 13 | 14 | @fragment fn fs() -> @location(0) vec4f { 15 | return vec4f(1.0, 0.0, 0.0, 1.0); 16 | } 17 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/cubeArrayShadow.wgsl: -------------------------------------------------------------------------------- 1 | @group(0) @binding(4) 2 | var point_shadow_textures: texture_depth_cube_array; 3 | @group(0) @binding(5) 4 | var point_shadow_textures_sampler: sampler_comparison; 5 | 6 | @fragment 7 | fn fragment() -> @location(0) vec4 { 8 | let frag_ls = vec4(1., 1., 2., 1.).xyz; 9 | let a = textureSampleCompare(point_shadow_textures, point_shadow_textures_sampler, frag_ls, i32(1), 1.); 10 | 11 | return vec4(a, 1., 1., 1.); 12 | } 13 | -------------------------------------------------------------------------------- /naga/tests/out/wgsl/glsl-quad_glsl.frag.wgsl: -------------------------------------------------------------------------------- 1 | struct FragmentOutput { 2 | @location(0) o_color: vec4, 3 | } 4 | 5 | var v_uv_1: vec2; 6 | var o_color: vec4; 7 | 8 | fn main_1() { 9 | o_color = vec4(1f, 1f, 1f, 1f); 10 | return; 11 | } 12 | 13 | @fragment 14 | fn main(@location(0) v_uv: vec2) -> FragmentOutput { 15 | v_uv_1 = v_uv; 16 | main_1(); 17 | let _e3 = o_color; 18 | return FragmentOutput(_e3); 19 | } 20 | -------------------------------------------------------------------------------- /naga/tests/out/wgsl/wgsl-texture-arg.wgsl: -------------------------------------------------------------------------------- 1 | @group(0) @binding(0) 2 | var Texture: texture_2d; 3 | @group(0) @binding(1) 4 | var Sampler: sampler; 5 | 6 | fn test(Passed_Texture: texture_2d, Passed_Sampler: sampler) -> vec4 { 7 | let _e5 = textureSample(Passed_Texture, Passed_Sampler, vec2(0f, 0f)); 8 | return _e5; 9 | } 10 | 11 | @fragment 12 | fn main() -> @location(0) vec4 { 13 | let _e2 = test(Texture, Sampler); 14 | return _e2; 15 | } 16 | -------------------------------------------------------------------------------- /examples/features/src/srgb_blend/README.md: -------------------------------------------------------------------------------- 1 | # srgb_blend 2 | 3 | This example shows blending in sRGB or linear space. 4 | 5 | ## To Run 6 | 7 | ``` 8 | cargo run --bin wgpu-examples srgb_blend linear 9 | ``` 10 | 11 | ``` 12 | cargo run --bin wgpu-examples srgb_blend 13 | ``` 14 | 15 | ## Screenshots 16 | 17 | Blending in linear space: 18 | 19 | ![sRGB blend example](./screenshot-linear.png) 20 | 21 | Blending in sRGB space: 22 | 23 | ![sRGB blend example](./screenshot-srgb.png) 24 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/sample-cube-array-depth-lod.wgsl: -------------------------------------------------------------------------------- 1 | // see https://github.com/gfx-rs/wgpu/issues/4455 2 | 3 | @group(0) @binding(0) var texture: texture_depth_cube_array; 4 | @group(0) @binding(1) var texture_sampler: sampler_comparison; 5 | 6 | @fragment 7 | fn main() -> @location(0) f32 { 8 | let pos = vec3(0.0); 9 | let array_index: i32 = 0; 10 | let depth: f32 = 0.0; 11 | return textureSampleCompareLevel(texture, texture_sampler, pos, array_index, depth); 12 | } 13 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-texture-external.ron: -------------------------------------------------------------------------------- 1 | ( 2 | vertex:[ 3 | ( 4 | entry_point:"vertex_main", 5 | target_profile:"vs_5_1", 6 | ), 7 | ], 8 | fragment:[ 9 | ( 10 | entry_point:"fragment_main", 11 | target_profile:"ps_5_1", 12 | ), 13 | ], 14 | compute:[ 15 | ( 16 | entry_point:"compute_main", 17 | target_profile:"cs_5_1", 18 | ), 19 | ], 20 | ) 21 | -------------------------------------------------------------------------------- /naga/tests/out/wgsl/spv-barrier.wgsl: -------------------------------------------------------------------------------- 1 | fn function() { 2 | workgroupBarrier(); 3 | workgroupBarrier(); 4 | storageBarrier(); 5 | textureBarrier(); 6 | storageBarrier(); 7 | textureBarrier(); 8 | storageBarrier(); 9 | workgroupBarrier(); 10 | textureBarrier(); 11 | storageBarrier(); 12 | workgroupBarrier(); 13 | textureBarrier(); 14 | return; 15 | } 16 | 17 | @compute @workgroup_size(64, 1, 1) 18 | fn main() { 19 | function(); 20 | } 21 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/unconsumed_vertex_outputs_frag.wgsl: -------------------------------------------------------------------------------- 1 | // Out of order to test sorting. 2 | struct FragmentIn { 3 | @location(1) value: f32, 4 | @location(3) value2: f32, 5 | @builtin(position) position: vec4, 6 | // @location(0) unused_value: f32, 7 | // @location(2) unused_value2: vec4, 8 | } 9 | 10 | @fragment 11 | fn fs_main(v_out: FragmentIn) -> @location(0) vec4 { 12 | return vec4(v_out.value, v_out.value, v_out.value2, v_out.value2); 13 | } 14 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/spv-inv-hyperbolic-trig-functions.hlsl: -------------------------------------------------------------------------------- 1 | static float a = (float)0; 2 | 3 | void main_1() 4 | { 5 | float b = (float)0; 6 | float c = (float)0; 7 | float d = (float)0; 8 | 9 | float _e4 = a; 10 | b = log(_e4 + sqrt(_e4 * _e4 + 1.0)); 11 | float _e6 = a; 12 | c = log(_e6 + sqrt(_e6 * _e6 - 1.0)); 13 | float _e8 = a; 14 | d = 0.5 * log((1.0 + _e8) / (1.0 - _e8)); 15 | return; 16 | } 17 | 18 | void main() 19 | { 20 | main_1(); 21 | } 22 | -------------------------------------------------------------------------------- /tests/tests/wgpu-gpu/external_texture/sample.wgsl: -------------------------------------------------------------------------------- 1 | @group(0) @binding(0) 2 | var tex: texture_external; 3 | @group(0) @binding(1) 4 | var samp: sampler; 5 | 6 | @group(0) @binding(2) 7 | var coords: array>; 8 | @group(0) @binding(3) 9 | var output: array>; 10 | 11 | @compute @workgroup_size(1) 12 | fn main(@builtin(global_invocation_id) id: vec3) { 13 | output[id.x] = textureSampleBaseClampToEdge(tex, samp, coords[id.x]); 14 | } 15 | -------------------------------------------------------------------------------- /naga/tests/out/glsl/wgsl-separate-entry-points.compute.Compute.glsl: -------------------------------------------------------------------------------- 1 | #version 310 es 2 | 3 | precision highp float; 4 | precision highp int; 5 | 6 | layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; 7 | 8 | 9 | void barriers() { 10 | memoryBarrierBuffer(); 11 | barrier(); 12 | memoryBarrierShared(); 13 | barrier(); 14 | memoryBarrierImage(); 15 | barrier(); 16 | return; 17 | } 18 | 19 | void main() { 20 | barriers(); 21 | return; 22 | } 23 | 24 | -------------------------------------------------------------------------------- /examples/features/src/render_to_texture/shader.wgsl: -------------------------------------------------------------------------------- 1 | @vertex 2 | fn vs_main(@builtin(vertex_index) in_vertex_index: u32) -> @builtin(position) vec4 { 3 | var vertices = array, 3>( 4 | vec4(0.0, 1.0, 0.0, 1.0), 5 | vec4(-1.0, -1.0, 0.0, 1.0), 6 | vec4(1.0, -1.0, 0.0, 1.0) 7 | ); 8 | return vertices[in_vertex_index]; 9 | } 10 | 11 | @fragment 12 | fn fs_main() -> @location(0) vec4 { 13 | return vec4(1.0, 0.0, 0.0, 1.0); 14 | } 15 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/use-gl-ext-over-grad-workaround-if-instructed.wgsl: -------------------------------------------------------------------------------- 1 | // see https://github.com/gfx-rs/wgpu/pull/5171 2 | 3 | @group(0) @binding(0) var texture: texture_depth_2d_array; 4 | @group(0) @binding(1) var texture_sampler: sampler_comparison; 5 | 6 | @fragment 7 | fn main() -> @location(0) f32 { 8 | let pos = vec2(0.0); 9 | let array_index: i32 = 0; 10 | let depth: f32 = 0.0; 11 | return textureSampleCompareLevel(texture, texture_sampler, pos, array_index, depth); 12 | } 13 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/workgroup-var-init.toml: -------------------------------------------------------------------------------- 1 | targets = "WGSL | GLSL | SPIRV | HLSL | METAL" 2 | 3 | [msl] 4 | fake_missing_bindings = false 5 | lang_version = [1, 0] 6 | spirv_cross_compatibility = false 7 | zero_initialize_workgroup_memory = true 8 | 9 | [msl.per_entry_point_map.main] 10 | resources = [ 11 | { bind_target = { buffer = 0, mutable = true }, resource_binding = { group = 0, binding = 0 } }, 12 | ] 13 | 14 | [spv] 15 | adjust_coordinate_space = false 16 | debug = true 17 | version = [1, 1] 18 | -------------------------------------------------------------------------------- /examples/features/src/multiview/shader.wgsl: -------------------------------------------------------------------------------- 1 | const triangles = array(vec2f(-1.0, -1.0), vec2f(3.0, -1.0), vec2f(-1.0, 3.0)); 2 | 3 | @vertex 4 | fn vs_main(@builtin(vertex_index) vertex_index: u32) -> @builtin(position) vec4f { 5 | return vec4f(triangles[vertex_index], 0.0, 1.0); 6 | } 7 | 8 | @fragment 9 | fn fs_main(@builtin(view_index) view_index: u32) -> @location(0) vec4f { 10 | return vec4f(f32(view_index) * 0.25 + 0.125, 1.0 - f32(view_index) * 0.25, 1.0 - 0.5 * f32(view_index), 1.0); 11 | } -------------------------------------------------------------------------------- /naga/tests/in/wgsl/functions-unoptimized.toml: -------------------------------------------------------------------------------- 1 | # Explicitly turn off optimizations for `dot4I8Packed` and `dot4U8Packed` 2 | # on SPIRV, HLSL, and Metal. 3 | 4 | targets = "SPIRV | HLSL | METAL" 5 | 6 | [spv] 7 | # Provide some unrelated capability because an empty list of capabilities would 8 | # get mapped to `None`, which would then be interpreted as "all capabilities 9 | # are available". 10 | capabilities = ["Matrix"] 11 | 12 | [hlsl] 13 | shader_model = "V6_3" 14 | 15 | [msl] 16 | lang_version = [2, 0] 17 | -------------------------------------------------------------------------------- /naga/tests/out/wgsl/wgsl-array-in-function-return-type.wgsl: -------------------------------------------------------------------------------- 1 | fn ret_array() -> array { 2 | return array(1f, 2f); 3 | } 4 | 5 | fn ret_array_array() -> array, 3> { 6 | let _e0 = ret_array(); 7 | let _e1 = ret_array(); 8 | let _e2 = ret_array(); 9 | return array, 3>(_e0, _e1, _e2); 10 | } 11 | 12 | @fragment 13 | fn main() -> @location(0) vec4 { 14 | let _e0 = ret_array_array(); 15 | return vec4(_e0[0][0], _e0[0][1], 0f, 1f); 16 | } 17 | -------------------------------------------------------------------------------- /wgpu-hal/src/gles/shaders/srgb_present.vert: -------------------------------------------------------------------------------- 1 | #version 300 es 2 | precision mediump float; 3 | // A triangle that fills the whole screen 4 | const vec2[3] TRIANGLE_POS = vec2[]( 5 | vec2( 0.0, -3.0), 6 | vec2(-3.0, 1.0), 7 | vec2( 3.0, 1.0) 8 | ); 9 | const vec2[3] TRIANGLE_UV = vec2[]( 10 | vec2( 0.5, 1.), 11 | vec2( -1.0, -1.0), 12 | vec2( 2.0, -1.0) 13 | ); 14 | out vec2 uv; 15 | void main() { 16 | uv = TRIANGLE_UV[gl_VertexID]; 17 | gl_Position = vec4(TRIANGLE_POS[gl_VertexID], 0.0, 1.0); 18 | } -------------------------------------------------------------------------------- /naga/fuzz/fuzz_targets/wgsl_parser.rs: -------------------------------------------------------------------------------- 1 | #![cfg_attr(all(fuzzable_platform, fuzzing), no_main)] 2 | 3 | #[cfg(all(fuzzable_platform, fuzzing))] 4 | mod fuzz { 5 | use libfuzzer_sys::fuzz_target; 6 | use naga::front::wgsl::Frontend; 7 | 8 | fuzz_target!(|data: String| { 9 | // Ensure the parser can handle potentially malformed strings without crashing. 10 | let _result = Frontend::new().parse(&data); 11 | }); 12 | } 13 | 14 | #[cfg(not(all(fuzzable_platform, fuzzing)))] 15 | fn main() {} 16 | -------------------------------------------------------------------------------- /tests/tests/wgpu-gpu/shader_view_format/view_format.wgsl: -------------------------------------------------------------------------------- 1 | @vertex 2 | fn vs_main(@builtin(vertex_index) vertexIndex: u32) -> @builtin(position) vec4 { 3 | let uv: vec2 = vec2(f32((vertexIndex << 1u) & 2u), f32(vertexIndex & 2u)); 4 | return vec4(uv * 2.0 - 1.0, 0.0, 1.0); 5 | } 6 | 7 | @group(0) @binding(0) var tex: texture_2d; 8 | 9 | @fragment 10 | fn fs_main(@builtin(position) coord: vec4) -> @location(0) vec4 { 11 | return textureLoad(tex, vec2(coord.xy), 0); 12 | } -------------------------------------------------------------------------------- /naga/tests/in/glsl/fma.frag: -------------------------------------------------------------------------------- 1 | #version 440 core 2 | 3 | struct Mat4x3 { vec4 mx; vec4 my; vec4 mz; }; 4 | void Fma(inout Mat4x3 d, Mat4x3 m, float s) { d.mx += m.mx * s; d.my += m.my * s; d.mz += m.mz * s; } 5 | 6 | out vec4 o_color; 7 | void main() { 8 | Mat4x3 m1 = { 9 | vec4(0), 10 | vec4(1), 11 | vec4(2), 12 | }; 13 | Mat4x3 m2 = { 14 | vec4(0), 15 | vec4(1), 16 | vec4(2), 17 | }; 18 | 19 | Fma(m1, m2, 2.0); 20 | o_color.rgba = vec4(1.0); 21 | } 22 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/binding-buffer-arrays.toml: -------------------------------------------------------------------------------- 1 | targets = "WGSL | SPIRV" 2 | capabilities = """ 3 | STORAGE_BUFFER_BINDING_ARRAY 4 | | STORAGE_BUFFER_BINDING_ARRAY_NON_UNIFORM_INDEXING 5 | """ 6 | 7 | [bounds_check_policies] 8 | index = "ReadZeroSkipWrite" 9 | buffer = "ReadZeroSkipWrite" 10 | image = "ReadZeroSkipWrite" 11 | 12 | [spv] 13 | version = [1, 1] 14 | 15 | [[spv.binding_map]] 16 | bind_target = { descriptor_set = 0, binding = 0, binding_array_size = 10 } 17 | resource_binding = { group = 0, binding = 0 } 18 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/subgroup-operations.toml: -------------------------------------------------------------------------------- 1 | capabilities = "SUBGROUP | SUBGROUP_BARRIER" 2 | 3 | [msl] 4 | fake_missing_bindings = false 5 | lang_version = [2, 4] 6 | spirv_cross_compatibility = false 7 | zero_initialize_workgroup_memory = true 8 | 9 | [hlsl] 10 | shader_model = "V6_0" 11 | fake_missing_bindings = true 12 | restrict_indexing = true 13 | zero_initialize_workgroup_memory = true 14 | 15 | [glsl] 16 | version.Desktop = 430 17 | zero_initialize_workgroup_memory = true 18 | 19 | [spv] 20 | version = [1, 3] 21 | -------------------------------------------------------------------------------- /naga/tests/out/glsl/wgsl-texture-arg.main.Fragment.glsl: -------------------------------------------------------------------------------- 1 | #version 310 es 2 | 3 | precision highp float; 4 | precision highp int; 5 | 6 | uniform highp sampler2D _group_0_binding_0_fs; 7 | 8 | layout(location = 0) out vec4 _fs2p_location0; 9 | 10 | vec4 test(highp sampler2D Passed_Texture) { 11 | vec4 _e5 = texture(Passed_Texture, vec2(vec2(0.0, 0.0))); 12 | return _e5; 13 | } 14 | 15 | void main() { 16 | vec4 _e2 = test(_group_0_binding_0_fs); 17 | _fs2p_location0 = _e2; 18 | return; 19 | } 20 | 21 | -------------------------------------------------------------------------------- /naga/tests/out/msl/spv-empty-global-name.msl: -------------------------------------------------------------------------------- 1 | // language: metal1.0 2 | #include 3 | #include 4 | 5 | using metal::uint; 6 | 7 | struct type_1 { 8 | int member; 9 | }; 10 | 11 | void function( 12 | device type_1& unnamed 13 | ) { 14 | int _e3 = unnamed.member; 15 | unnamed.member = as_type(as_type(_e3) + as_type(1)); 16 | return; 17 | } 18 | 19 | kernel void main_( 20 | device type_1& unnamed [[user(fake0)]] 21 | ) { 22 | function(unnamed); 23 | } 24 | -------------------------------------------------------------------------------- /wgpu-hal/examples/raw-gles.em.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/extra.wgsl: -------------------------------------------------------------------------------- 1 | struct ImmediateData { 2 | index: u32, 3 | double: vec2, 4 | } 5 | var im: ImmediateData; 6 | 7 | struct FragmentIn { 8 | @location(0) color: vec4, 9 | @builtin(primitive_index) primitive_index: u32, 10 | } 11 | 12 | @fragment 13 | fn main(in: FragmentIn) -> @location(0) vec4 { 14 | if in.primitive_index == im.index { 15 | return in.color; 16 | } else { 17 | return vec4(vec3(1.0) - in.color.rgb, in.color.a); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /naga/tests/out/glsl/wgsl-use-gl-ext-over-grad-workaround-if-instructed.main.Fragment.glsl: -------------------------------------------------------------------------------- 1 | #version 320 es 2 | #extension GL_EXT_texture_shadow_lod : require 3 | 4 | precision highp float; 5 | precision highp int; 6 | 7 | uniform highp sampler2DArrayShadow _group_0_binding_0_fs; 8 | 9 | layout(location = 0) out float _fs2p_location0; 10 | 11 | void main() { 12 | vec2 pos = vec2(0.0); 13 | float _e6 = textureLod(_group_0_binding_0_fs, vec4(pos, 0, 0.0), 0.0); 14 | _fs2p_location0 = _e6; 15 | return; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /naga/tests/out/wgsl/spv-binding-arrays.dynamic.wgsl: -------------------------------------------------------------------------------- 1 | @group(0) @binding(0) 2 | var global: binding_array>; 3 | @group(0) @binding(1) 4 | var global_1: binding_array; 5 | var global_2: vec4; 6 | 7 | fn function() { 8 | let _e8 = textureSampleLevel(global[1i], global_1[1i], vec2(0.5f, 0.5f), 0f); 9 | global_2 = _e8; 10 | return; 11 | } 12 | 13 | @fragment 14 | fn main() -> @location(0) vec4 { 15 | function(); 16 | let _e1 = global_2; 17 | return _e1; 18 | } 19 | -------------------------------------------------------------------------------- /naga/tests/out/wgsl/wgsl-6438-conflicting-idents.wgsl: -------------------------------------------------------------------------------- 1 | struct OurVertexShaderOutput { 2 | @builtin(position) position: vec4, 3 | @location(0) texcoord: vec2, 4 | } 5 | 6 | @vertex 7 | fn vs(@location(0) xy: vec2) -> OurVertexShaderOutput { 8 | var vsOutput: OurVertexShaderOutput; 9 | 10 | vsOutput.position = vec4(xy, 0f, 1f); 11 | let _e6 = vsOutput; 12 | return _e6; 13 | } 14 | 15 | @fragment 16 | fn fs() -> @location(0) vec4 { 17 | return vec4(1f, 0f, 0f, 1f); 18 | } 19 | -------------------------------------------------------------------------------- /naga/tests/out/glsl/wgsl-7995-unicode-idents.main.Compute.glsl: -------------------------------------------------------------------------------- 1 | #version 310 es 2 | 3 | precision highp float; 4 | precision highp int; 5 | 6 | layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; 7 | 8 | layout(std430) readonly buffer type_block_0Compute { float _group_0_binding_0_cs; }; 9 | 10 | 11 | float compute() { 12 | float _e1 = _group_0_binding_0_cs; 13 | float u03b8_2_ = (_e1 + 9001.0); 14 | return u03b8_2_; 15 | } 16 | 17 | void main() { 18 | float _e0 = compute(); 19 | return; 20 | } 21 | 22 | -------------------------------------------------------------------------------- /naga/tests/out/glsl/wgsl-cubeArrayShadow.fragment.Fragment.glsl: -------------------------------------------------------------------------------- 1 | #version 310 es 2 | #extension GL_EXT_texture_cube_map_array : require 3 | 4 | precision highp float; 5 | precision highp int; 6 | 7 | uniform highp samplerCubeArrayShadow _group_0_binding_4_fs; 8 | 9 | layout(location = 0) out vec4 _fs2p_location0; 10 | 11 | void main() { 12 | vec3 frag_ls = vec3(1.0, 1.0, 2.0); 13 | float a = texture(_group_0_binding_4_fs, vec4(frag_ls, 1), 1.0); 14 | _fs2p_location0 = vec4(a, 1.0, 1.0, 1.0); 15 | return; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /player/tests/player/data/quad.wgsl: -------------------------------------------------------------------------------- 1 | @vertex 2 | fn vs_main(@builtin(vertex_index) vertex_index: u32) -> @builtin(position) vec4 { 3 | // hacky way to draw a large triangle 4 | let tmp1 = i32(vertex_index) / 2; 5 | let tmp2 = i32(vertex_index) & 1; 6 | let pos = vec2( 7 | f32(tmp1) * 4.0 - 1.0, 8 | f32(tmp2) * 4.0 - 1.0 9 | ); 10 | return vec4(pos, 0.0, 1.0); 11 | } 12 | 13 | @fragment 14 | fn fs_main() -> @location(0) vec4 { 15 | return vec4(1.0, 1.0, 1.0, 1.0); 16 | } 17 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/template-list-trailing-comma.wgsl: -------------------------------------------------------------------------------- 1 | var sized_comma: array; 2 | var sized_no_comma: array; 3 | 4 | @group(0) @binding(0) 5 | var unsized_comma: array; 6 | 7 | @group(0) @binding(1) 8 | var unsized_no_comma: array; 9 | 10 | @compute @workgroup_size(1) 11 | fn main() { 12 | sized_comma[0] = unsized_comma[0]; 13 | sized_no_comma[0] = unsized_no_comma[0]; 14 | unsized_no_comma[0] = sized_comma[0] + sized_no_comma[0]; 15 | } 16 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-atomicTexture-int64.hlsl: -------------------------------------------------------------------------------- 1 | struct NagaConstants { 2 | int first_vertex; 3 | int first_instance; 4 | uint other; 5 | }; 6 | ConstantBuffer _NagaConstants: register(b0, space1); 7 | 8 | RWTexture2D image : register(u0); 9 | 10 | [numthreads(2, 1, 1)] 11 | void cs_main(uint3 id : SV_GroupThreadID) 12 | { 13 | InterlockedMax(image[int2(int(0), int(0))],1uL); 14 | GroupMemoryBarrierWithGroupSync(); 15 | InterlockedMin(image[int2(int(0), int(0))],1uL); 16 | return; 17 | } 18 | -------------------------------------------------------------------------------- /naga/tests/out/wgsl/spv-binding-arrays.static.wgsl: -------------------------------------------------------------------------------- 1 | @group(0) @binding(0) 2 | var global: binding_array, 256>; 3 | @group(0) @binding(1) 4 | var global_1: binding_array; 5 | var global_2: vec4; 6 | 7 | fn function() { 8 | let _e8 = textureSampleLevel(global[1i], global_1[1i], vec2(0.5f, 0.5f), 0f); 9 | global_2 = _e8; 10 | return; 11 | } 12 | 13 | @fragment 14 | fn main() -> @location(0) vec4 { 15 | function(); 16 | let _e1 = global_2; 17 | return _e1; 18 | } 19 | -------------------------------------------------------------------------------- /naga/tests/in/spv/subgroup-operations-s.toml: -------------------------------------------------------------------------------- 1 | capabilities = "SUBGROUP" 2 | targets = "METAL | GLSL | HLSL | WGSL" 3 | 4 | [msl] 5 | fake_missing_bindings = false 6 | lang_version = [2, 4] 7 | spirv_cross_compatibility = false 8 | zero_initialize_workgroup_memory = true 9 | 10 | [hlsl] 11 | shader_model = "V6_0" 12 | fake_missing_bindings = true 13 | restrict_indexing = true 14 | zero_initialize_workgroup_memory = true 15 | 16 | [glsl] 17 | version.Desktop = 430 18 | zero_initialize_workgroup_memory = true 19 | 20 | [spv] 21 | version = [1, 3] 22 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/ray-query-no-init-tracking.toml: -------------------------------------------------------------------------------- 1 | capabilities = "RAY_QUERY" 2 | targets = "SPIRV | METAL | HLSL" 3 | 4 | [msl] 5 | fake_missing_bindings = true 6 | lang_version = [2, 4] 7 | spirv_cross_compatibility = false 8 | zero_initialize_workgroup_memory = false 9 | 10 | [hlsl] 11 | shader_model = "V6_5" 12 | fake_missing_bindings = true 13 | zero_initialize_workgroup_memory = true 14 | # Not yet implemented 15 | # ray_query_initialization_tracking = false 16 | 17 | [spv] 18 | version = [1, 4] 19 | ray_query_initialization_tracking = false 20 | -------------------------------------------------------------------------------- /naga/tests/out/glsl/wgsl-f64.main.Compute.glsl: -------------------------------------------------------------------------------- 1 | #version 420 core 2 | #extension GL_ARB_compute_shader : require 3 | layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; 4 | 5 | const double k = 2.0LF; 6 | 7 | double v = 1.0LF; 8 | 9 | 10 | double f(double x) { 11 | double z = 0.0; 12 | double w = -1.0LF; 13 | double phony = v; 14 | double y = (30.0LF + 400.0LF); 15 | z = (y + 5.0LF); 16 | return (((x + y) + k) + 5.0LF); 17 | } 18 | 19 | void main() { 20 | double _e1 = f(6.0LF); 21 | return; 22 | } 23 | 24 | -------------------------------------------------------------------------------- /naga/tests/out/msl/wgsl-phony_assignment.msl: -------------------------------------------------------------------------------- 1 | // language: metal1.0 2 | #include 3 | #include 4 | 5 | using metal::uint; 6 | 7 | 8 | int five( 9 | ) { 10 | return 5; 11 | } 12 | 13 | struct main_Input { 14 | }; 15 | kernel void main_( 16 | metal::uint3 id [[thread_position_in_grid]] 17 | , constant float& binding [[user(fake0)]] 18 | ) { 19 | float phony = binding; 20 | float phony_1 = binding; 21 | int _e6 = five(); 22 | int _e7 = five(); 23 | float phony_2 = binding; 24 | return; 25 | } 26 | -------------------------------------------------------------------------------- /lock-analyzer/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "lock-analyzer" 3 | edition.workspace = true 4 | rust-version.workspace = true 5 | keywords.workspace = true 6 | license.workspace = true 7 | homepage.workspace = true 8 | repository.workspace = true 9 | version.workspace = true 10 | authors.workspace = true 11 | publish = false 12 | 13 | [dependencies] 14 | ron.workspace = true 15 | anyhow.workspace = true 16 | 17 | [dependencies.serde] 18 | workspace = true 19 | features = ["default", "serde_derive"] 20 | 21 | [lints.clippy] 22 | disallowed_types = "allow" 23 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/must-use.wgsl: -------------------------------------------------------------------------------- 1 | @must_use 2 | fn use_me() -> i32 { return 10; } 3 | 4 | fn use_return() -> i32 { 5 | return use_me(); 6 | } 7 | 8 | fn use_assign_var() -> i32 { 9 | var q = use_me(); 10 | return q; 11 | } 12 | 13 | fn use_assign_let() -> i32 { 14 | let q = use_me(); 15 | return q; 16 | } 17 | 18 | fn use_phony_assign() { 19 | _ = use_me(); 20 | } 21 | 22 | @compute @workgroup_size(1) 23 | fn main() { 24 | use_return(); 25 | use_assign_var(); 26 | use_assign_let(); 27 | use_phony_assign(); 28 | } 29 | -------------------------------------------------------------------------------- /naga/tests/out/glsl/wgsl-clip-distances.main.Vertex.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | struct VertexOutput { 3 | vec4 position; 4 | float clip_distances[1]; 5 | }; 6 | out float gl_ClipDistance[1]; 7 | 8 | void main() { 9 | VertexOutput out_ = VertexOutput(vec4(0.0), float[1](0.0)); 10 | out_.clip_distances[0] = 0.5; 11 | VertexOutput _e4 = out_; 12 | gl_Position = _e4.position; 13 | gl_ClipDistance = _e4.clip_distances; 14 | gl_Position.yz = vec2(-gl_Position.y, gl_Position.z * 2.0 - gl_Position.w); 15 | return; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /naga/tests/out/hlsl/wgsl-dualsource.hlsl: -------------------------------------------------------------------------------- 1 | struct FragmentOutput { 2 | float4 output0_ : SV_Target0; 3 | float4 output1_ : SV_Target1; 4 | }; 5 | 6 | FragmentOutput ConstructFragmentOutput(float4 arg0, float4 arg1) { 7 | FragmentOutput ret = (FragmentOutput)0; 8 | ret.output0_ = arg0; 9 | ret.output1_ = arg1; 10 | return ret; 11 | } 12 | 13 | FragmentOutput main() 14 | { 15 | const FragmentOutput fragmentoutput = ConstructFragmentOutput(float4(0.4, 0.3, 0.2, 0.1), float4(0.9, 0.8, 0.7, 0.6)); 16 | return fragmentoutput; 17 | } 18 | -------------------------------------------------------------------------------- /wgpu-macros/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "wgpu-macros" 3 | version.workspace = true 4 | authors.workspace = true 5 | edition.workspace = true 6 | description = "Macros for wgpu" 7 | homepage.workspace = true 8 | repository.workspace = true 9 | keywords.workspace = true 10 | license.workspace = true 11 | rust-version.workspace = true 12 | exclude = ["Cargo.lock"] 13 | publish = false 14 | 15 | [lib] 16 | proc-macro = true 17 | 18 | [dependencies] 19 | heck.workspace = true 20 | quote.workspace = true 21 | syn = { workspace = true, features = ["full"] } 22 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/force_point_size_vertex_shader_webgl.wgsl: -------------------------------------------------------------------------------- 1 | // AUTHOR: REASY 2 | // ISSUE: https://github.com/gfx-rs/wgpu/issues/3179 3 | // FIX: https://github.com/gfx-rs/wgpu/pull/3440 4 | @vertex 5 | fn vs_main(@builtin(vertex_index) in_vertex_index: u32) -> @builtin(position) vec4 { 6 | let x = f32(i32(in_vertex_index) - 1); 7 | let y = f32(i32(in_vertex_index & 1u) * 2 - 1); 8 | return vec4(x, y, 0.0, 1.0); 9 | } 10 | 11 | @fragment 12 | fn fs_main() -> @location(0) vec4 { 13 | return vec4(1.0, 0.0, 0.0, 1.0); 14 | } 15 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/functions-optimized-by-version.toml: -------------------------------------------------------------------------------- 1 | # Turn on optimizations for `dot4I8Packed` and `dot4U8Packed` on SPIR-V, HLSL, and Metal 2 | # by using a language version / shader model that supports these (without any extensions). 3 | 4 | targets = "SPIRV | HLSL | METAL" 5 | 6 | [spv] 7 | # We also need to provide the corresponding capabilities (which are part of SPIR-V >= 1.6). 8 | capabilities = ["DotProduct", "DotProductInput4x8BitPacked"] 9 | version = [1, 6] 10 | 11 | [hlsl] 12 | shader_model = "V6_4" 13 | 14 | [msl] 15 | lang_version = [2, 1] 16 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/int64.toml: -------------------------------------------------------------------------------- 1 | capabilities = "SHADER_INT64" 2 | targets = "SPIRV | HLSL | WGSL | METAL" 3 | 4 | [msl] 5 | fake_missing_bindings = true 6 | lang_version = [2, 3] 7 | spirv_cross_compatibility = false 8 | zero_initialize_workgroup_memory = true 9 | 10 | [hlsl] 11 | shader_model = "V6_0" 12 | fake_missing_bindings = true 13 | immediates_target = { register = 0, space = 0 } 14 | restrict_indexing = true 15 | special_constants_binding = { register = 0, space = 1 } 16 | zero_initialize_workgroup_memory = true 17 | 18 | [spv] 19 | version = [1, 0] 20 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/msl-varyings.wgsl: -------------------------------------------------------------------------------- 1 | struct Vertex { 2 | @location(0) position: vec2f 3 | } 4 | 5 | struct NoteInstance { 6 | @location(1) position: vec2f 7 | } 8 | 9 | struct VertexOutput { 10 | @builtin(position) position: vec4f 11 | } 12 | 13 | @vertex 14 | fn vs_main(vertex: Vertex, note: NoteInstance) -> VertexOutput { 15 | var out: VertexOutput; 16 | return out; 17 | } 18 | 19 | @fragment 20 | fn fs_main(in: VertexOutput, note: NoteInstance) -> @location(0) vec4f { 21 | let position = vec3(1f); 22 | return in.position; 23 | } 24 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/separate-entry-points.wgsl: -------------------------------------------------------------------------------- 1 | // only available in the fragment stage 2 | fn derivatives() { 3 | let x = dpdx(0.0); 4 | let y = dpdy(0.0); 5 | let width = fwidth(0.0); 6 | } 7 | 8 | // only available in the compute stage 9 | fn barriers() { 10 | storageBarrier(); 11 | workgroupBarrier(); 12 | textureBarrier(); 13 | } 14 | 15 | @fragment 16 | fn fragment() -> @location(0) vec4 { 17 | derivatives(); 18 | return vec4(); 19 | } 20 | 21 | @compute @workgroup_size(1) 22 | fn compute() { 23 | barriers(); 24 | } -------------------------------------------------------------------------------- /naga/tests/in/wgsl/7048-multiple-dynamic-3.wgsl: -------------------------------------------------------------------------------- 1 | struct QEFResult { 2 | a: f32, 3 | b: vec3, 4 | } 5 | 6 | fn foobar(normals: array, count: u32) -> QEFResult { 7 | for (var i = 0u; i < count; i++) { 8 | var n0 = normals[i]; 9 | } 10 | 11 | for (var j = 0u; j < count; j++) { 12 | var n1 = normals[j]; 13 | } 14 | 15 | return QEFResult(0.0, vec3(0.0)); 16 | } 17 | 18 | @fragment 19 | fn main() { 20 | var arr: array; 21 | foobar(arr, 1); 22 | } 23 | -------------------------------------------------------------------------------- /naga/tests/out/wgsl/wgsl-extra.wgsl: -------------------------------------------------------------------------------- 1 | struct ImmediateData { 2 | index: u32, 3 | double: vec2, 4 | } 5 | 6 | struct FragmentIn { 7 | @location(0) color: vec4, 8 | @builtin(primitive_index) primitive_index: u32, 9 | } 10 | 11 | var im: ImmediateData; 12 | 13 | @fragment 14 | fn main(in: FragmentIn) -> @location(0) vec4 { 15 | let _e4 = im.index; 16 | if (in.primitive_index == _e4) { 17 | return in.color; 18 | } else { 19 | return vec4((vec3(1f) - in.color.xyz), in.color.w); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /examples/features/src/msaa_line/shader.wgsl: -------------------------------------------------------------------------------- 1 | struct VertexOutput { 2 | @location(0) color: vec4, 3 | @builtin(position) position: vec4, 4 | }; 5 | 6 | @vertex 7 | fn vs_main( 8 | @location(0) position: vec2, 9 | @location(1) color: vec4, 10 | ) -> VertexOutput { 11 | var result: VertexOutput; 12 | result.position = vec4(position, 0.0, 1.0); 13 | result.color = color; 14 | return result; 15 | } 16 | 17 | @fragment 18 | fn fs_main(vertex: VertexOutput) -> @location(0) vec4 { 19 | return vertex.color; 20 | } 21 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/functions-unoptimized.wgsl: -------------------------------------------------------------------------------- 1 | fn test_packed_integer_dot_product() -> u32 { 2 | let a_5 = 1u; 3 | let b_5 = 2u; 4 | let c_5: i32 = dot4I8Packed(a_5, b_5); 5 | 6 | let a_6 = 3u; 7 | let b_6 = 4u; 8 | let c_6: u32 = dot4U8Packed(a_6, b_6); 9 | 10 | // test baking of arguments 11 | let c_7: i32 = dot4I8Packed(5u + c_6, 6u + c_6); 12 | let c_8: u32 = dot4U8Packed(7u + c_6, 8u + c_6); 13 | return c_8; 14 | } 15 | 16 | @compute @workgroup_size(1) 17 | fn main() { 18 | let c = test_packed_integer_dot_product(); 19 | } 20 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/overrides-ray-query.wgsl: -------------------------------------------------------------------------------- 1 | enable wgpu_ray_query; 2 | 3 | override o: f32; 4 | 5 | @group(0) @binding(0) 6 | var acc_struct: acceleration_structure; 7 | 8 | @compute @workgroup_size(1) 9 | fn main() { 10 | var rq: ray_query; 11 | 12 | let desc = RayDesc( 13 | RAY_FLAG_TERMINATE_ON_FIRST_HIT, 14 | 0xFFu, 15 | o * 17.0, 16 | o * 19.0, 17 | vec3(o * 23.0), 18 | vec3(o * 29.0, o * 31.0, o * 37.0), 19 | ); 20 | rayQueryInitialize(&rq, acc_struct, desc); 21 | 22 | while (rayQueryProceed(&rq)) {} 23 | } 24 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/type-alias.wgsl: -------------------------------------------------------------------------------- 1 | alias FVec3 = vec3; 2 | alias IVec3 = vec3i; 3 | alias Mat2 = mat2x2; 4 | alias Mat3 = mat3x3f; 5 | alias I32 = i32; 6 | alias F32 = f32; 7 | 8 | @compute @workgroup_size(1) 9 | fn main() { 10 | let a = FVec3(0.0, 0.0, 0.0); 11 | let c = FVec3(0.0); 12 | let b = FVec3(vec2(0.0), 0.0); 13 | let d = FVec3(vec2(0.0), 0.0); 14 | let e = IVec3(d); 15 | 16 | let f = Mat2(1.0, 2.0, 3.0, 4.0); 17 | let g = Mat3(a, a, a); 18 | 19 | let h = vec2(); 20 | let i = mat2x2(); 21 | } 22 | -------------------------------------------------------------------------------- /naga/tests/out/glsl/wgsl-sample-cube-array-depth-lod.main.Fragment.glsl: -------------------------------------------------------------------------------- 1 | #version 320 es 2 | #extension GL_EXT_texture_cube_map_array : require 3 | #extension GL_EXT_texture_shadow_lod : require 4 | 5 | precision highp float; 6 | precision highp int; 7 | 8 | uniform highp samplerCubeArrayShadow _group_0_binding_0_fs; 9 | 10 | layout(location = 0) out float _fs2p_location0; 11 | 12 | void main() { 13 | vec3 pos = vec3(0.0); 14 | float _e6 = textureLod(_group_0_binding_0_fs, vec4(pos, 0), 0.0, 0.0); 15 | _fs2p_location0 = _e6; 16 | return; 17 | } 18 | 19 | -------------------------------------------------------------------------------- /naga/tests/out/wgsl/glsl-900-implicit-conversions.frag.wgsl: -------------------------------------------------------------------------------- 1 | fn exact(a: i32) { 2 | var a_1: i32; 3 | 4 | a_1 = a; 5 | return; 6 | } 7 | 8 | fn implicit(a_2: f32) { 9 | var a_3: f32; 10 | 11 | a_3 = a_2; 12 | return; 13 | } 14 | 15 | fn implicit_dims(v: vec3) { 16 | var v_1: vec3; 17 | 18 | v_1 = v; 19 | return; 20 | } 21 | 22 | fn main_1() { 23 | exact(1i); 24 | implicit(1f); 25 | implicit_dims(vec3(1f)); 26 | return; 27 | } 28 | 29 | @fragment 30 | fn main() { 31 | main_1(); 32 | return; 33 | } 34 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/functions-optimized-by-version.wgsl: -------------------------------------------------------------------------------- 1 | fn test_packed_integer_dot_product() -> u32 { 2 | let a_5 = 1u; 3 | let b_5 = 2u; 4 | let c_5: i32 = dot4I8Packed(a_5, b_5); 5 | 6 | let a_6 = 3u; 7 | let b_6 = 4u; 8 | let c_6: u32 = dot4U8Packed(a_6, b_6); 9 | 10 | // test baking of arguments 11 | let c_7: i32 = dot4I8Packed(5u + c_6, 6u + c_6); 12 | let c_8: u32 = dot4U8Packed(7u + c_6, 8u + c_6); 13 | return c_8; 14 | } 15 | 16 | @compute @workgroup_size(1) 17 | fn main() { 18 | let c = test_packed_integer_dot_product(); 19 | } 20 | -------------------------------------------------------------------------------- /naga/tests/out/glsl/wgsl-6772-unpack-expr-accesses.main.Compute.glsl: -------------------------------------------------------------------------------- 1 | #version 310 es 2 | 3 | precision highp float; 4 | precision highp int; 5 | 6 | layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; 7 | 8 | 9 | void main() { 10 | int phony = ivec4(bitfieldExtract(int(12u), 0, 8), bitfieldExtract(int(12u), 8, 8), bitfieldExtract(int(12u), 16, 8), bitfieldExtract(int(12u), 24, 8))[2]; 11 | uint phony_1 = uvec4(bitfieldExtract(12u, 0, 8), bitfieldExtract(12u, 8, 8), bitfieldExtract(12u, 16, 8), bitfieldExtract(12u, 24, 8)).y; 12 | return; 13 | } 14 | 15 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/atomicTexture.toml: -------------------------------------------------------------------------------- 1 | capabilities = "TEXTURE_ATOMIC" 2 | 3 | [msl] 4 | fake_missing_bindings = true 5 | lang_version = [3, 1] 6 | spirv_cross_compatibility = false 7 | zero_initialize_workgroup_memory = true 8 | 9 | [hlsl] 10 | fake_missing_bindings = true 11 | immediates_target = { register = 0, space = 0 } 12 | restrict_indexing = true 13 | special_constants_binding = { register = 0, space = 1 } 14 | zero_initialize_workgroup_memory = true 15 | 16 | [glsl] 17 | version.Desktop = 420 18 | zero_initialize_workgroup_memory = true 19 | 20 | [spv] 21 | version = [1, 0] 22 | -------------------------------------------------------------------------------- /naga/tests/in/wgsl/functions-optimized-by-capability.wgsl: -------------------------------------------------------------------------------- 1 | fn test_packed_integer_dot_product() -> u32 { 2 | let a_5 = 1u; 3 | let b_5 = 2u; 4 | let c_5: i32 = dot4I8Packed(a_5, b_5); 5 | 6 | let a_6 = 3u; 7 | let b_6 = 4u; 8 | let c_6: u32 = dot4U8Packed(a_6, b_6); 9 | 10 | // test baking of arguments 11 | let c_7: i32 = dot4I8Packed(5u + c_6, 6u + c_6); 12 | let c_8: u32 = dot4U8Packed(7u + c_6, 8u + c_6); 13 | return c_8; 14 | } 15 | 16 | @compute @workgroup_size(1) 17 | fn main() { 18 | let c = test_packed_integer_dot_product(); 19 | } 20 | -------------------------------------------------------------------------------- /naga/tests/out/msl/wgsl-atomicTexture-int64.msl: -------------------------------------------------------------------------------- 1 | // language: metal3.1 2 | #include 3 | #include 4 | 5 | using metal::uint; 6 | 7 | 8 | struct cs_mainInput { 9 | }; 10 | kernel void cs_main( 11 | metal::uint3 id [[thread_position_in_threadgroup]] 12 | , metal::texture2d image [[user(fake0)]] 13 | ) { 14 | image.atomic_max(metal::uint2(metal::int2(0, 0)), 1uL); 15 | metal::threadgroup_barrier(metal::mem_flags::mem_threadgroup); 16 | image.atomic_min(metal::uint2(metal::int2(0, 0)), 1uL); 17 | return; 18 | } 19 | -------------------------------------------------------------------------------- /naga/tests/out/wgsl/glsl-clamp-splat.vert.wgsl: -------------------------------------------------------------------------------- 1 | struct VertexOutput { 2 | @builtin(position) gl_Position: vec4, 3 | } 4 | 5 | var a_pos_1: vec2; 6 | var gl_Position: vec4; 7 | 8 | fn main_1() { 9 | let _e2 = a_pos_1; 10 | let _e7 = clamp(_e2, vec2(0f), vec2(1f)); 11 | gl_Position = vec4(_e7.x, _e7.y, 0f, 1f); 12 | return; 13 | } 14 | 15 | @vertex 16 | fn main(@location(0) a_pos: vec2) -> VertexOutput { 17 | a_pos_1 = a_pos; 18 | main_1(); 19 | let _e3 = gl_Position; 20 | return VertexOutput(_e3); 21 | } 22 | -------------------------------------------------------------------------------- /naga/xtask/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "naga-xtask" 3 | version = "0.1.0" 4 | edition = "2021" 5 | publish = false 6 | rust-version.workspace = true 7 | 8 | [target.'cfg(not(target_arch = "wasm32"))'.dependencies] 9 | anyhow.workspace = true 10 | env_logger = { workspace = true, default-features = false } 11 | glob.workspace = true 12 | hlsl-snapshots.workspace = true 13 | indicatif.workspace = true 14 | jobserver.workspace = true 15 | log.workspace = true 16 | num_cpus.workspace = true 17 | pico-args.workspace = true 18 | shell-words.workspace = true 19 | which.workspace = true 20 | -------------------------------------------------------------------------------- /naga/fuzz/fuzz_targets/spv_parser.rs: -------------------------------------------------------------------------------- 1 | #![cfg_attr(all(fuzzable_platform, fuzzing), no_main)] 2 | 3 | #[cfg(all(fuzzable_platform, fuzzing))] 4 | mod fuzz { 5 | use libfuzzer_sys::fuzz_target; 6 | use naga::front::spv::{Frontend, Options}; 7 | 8 | fuzz_target!(|data: Vec| { 9 | // Ensure the parser can handle potentially malformed data without crashing. 10 | let options = Options::default(); 11 | let _result = Frontend::new(data.into_iter(), &options).parse(); 12 | }); 13 | } 14 | 15 | #[cfg(not(all(fuzzable_platform, fuzzing)))] 16 | fn main() {} 17 | --------------------------------------------------------------------------------