From 43cb730d588a06ae64d91ce98afbef09d5613596 Mon Sep 17 00:00:00 2001 From: ChosenName <69129796+ChosenName@users.noreply.github.com> Date: Tue, 8 Oct 2024 07:00:00 -0600 Subject: [PATCH 01/67] [naga] added DrawID (#6325) --- CHANGELOG.md | 1 + naga/src/back/glsl/features.rs | 2 +- naga/src/back/glsl/mod.rs | 3 ++- naga/src/back/hlsl/conv.rs | 2 +- naga/src/back/msl/mod.rs | 2 +- naga/src/back/spv/writer.rs | 1 + naga/src/back/wgsl/writer.rs | 5 ++--- naga/src/front/glsl/variables.rs | 1 + naga/src/front/spv/convert.rs | 1 + naga/src/lib.rs | 1 + naga/src/valid/interface.rs | 6 +++++- 11 files changed, 17 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fc094bcfb0..a9756151a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -107,6 +107,7 @@ By @bradwerth [#6216](https://github.com/gfx-rs/wgpu/pull/6216). - Fix type parameters to vec/mat type constructors to also support aliases. By @sagudev in [#6189](https://github.com/gfx-rs/wgpu/pull/6189). - Accept global `var`s without explicit type. By @sagudev in [#6199](https://github.com/gfx-rs/wgpu/pull/6199). - Fix handling of phony statements, so they are actually emitted. By @sagudev in [#6328](https://github.com/gfx-rs/wgpu/pull/6328). +- Added `gl_DrawID` to glsl and `DrawIndex` to spv. By @ChosenName in [#6325](https://github.com/gfx-rs/wgpu/pull/6325). #### General diff --git a/naga/src/back/glsl/features.rs b/naga/src/back/glsl/features.rs index 362f4bb4f3..74f48d8bc8 100644 --- a/naga/src/back/glsl/features.rs +++ b/naga/src/back/glsl/features.rs @@ -579,7 +579,7 @@ impl<'a, W> Writer<'a, W> { crate::BuiltIn::ViewIndex => { self.features.request(Features::MULTI_VIEW) } - crate::BuiltIn::InstanceIndex => { + crate::BuiltIn::InstanceIndex | crate::BuiltIn::DrawID => { self.features.request(Features::INSTANCE_INDEX) } _ => {} diff --git a/naga/src/back/glsl/mod.rs b/naga/src/back/glsl/mod.rs index 2ce9f22f27..ed373d00b0 100644 --- a/naga/src/back/glsl/mod.rs +++ b/naga/src/back/glsl/mod.rs @@ -238,7 +238,7 @@ bitflags::bitflags! { /// additional functions on shadows and arrays of shadows. const TEXTURE_SHADOW_LOD = 0x2; /// Supports ARB_shader_draw_parameters on the host, which provides - /// support for `gl_BaseInstanceARB`, `gl_BaseVertexARB`, and `gl_DrawIDARB`. + /// support for `gl_BaseInstanceARB`, `gl_BaseVertexARB`, `gl_DrawIDARB`, and `gl_DrawID`. const DRAW_PARAMETERS = 0x4; /// Include unused global variables, constants and functions. By default the output will exclude /// global variables that are not used in the specified entrypoint (including indirect use), @@ -4719,6 +4719,7 @@ const fn glsl_built_in(built_in: crate::BuiltIn, options: VaryingOptions) -> &'s } Bi::PointSize => "gl_PointSize", Bi::VertexIndex => "uint(gl_VertexID)", + Bi::DrawID => "gl_DrawID", // fragment Bi::FragDepth => "gl_FragDepth", Bi::PointCoord => "gl_PointCoord", diff --git a/naga/src/back/hlsl/conv.rs b/naga/src/back/hlsl/conv.rs index 473fc9476d..5345f0a4d6 100644 --- a/naga/src/back/hlsl/conv.rs +++ b/naga/src/back/hlsl/conv.rs @@ -178,7 +178,7 @@ impl crate::BuiltIn { Self::BaseInstance | Self::BaseVertex | Self::WorkGroupSize => { return Err(Error::Unimplemented(format!("builtin {self:?}"))) } - Self::PointSize | Self::ViewIndex | Self::PointCoord => { + Self::PointSize | Self::ViewIndex | Self::PointCoord | Self::DrawID => { return Err(Error::Custom(format!("Unsupported builtin {self:?}"))) } }) diff --git a/naga/src/back/msl/mod.rs b/naga/src/back/msl/mod.rs index 4bc06469e8..fbeaa4cc8d 100644 --- a/naga/src/back/msl/mod.rs +++ b/naga/src/back/msl/mod.rs @@ -568,7 +568,7 @@ impl ResolvedBinding { Bi::SubgroupId => "simdgroup_index_in_threadgroup", Bi::SubgroupSize => "threads_per_simdgroup", Bi::SubgroupInvocationId => "thread_index_in_simdgroup", - Bi::CullDistance | Bi::ViewIndex => { + Bi::CullDistance | Bi::ViewIndex | Bi::DrawID => { return Err(Error::UnsupportedBuiltIn(built_in)) } }; diff --git a/naga/src/back/spv/writer.rs b/naga/src/back/spv/writer.rs index 14f1fc0027..cd02c22195 100644 --- a/naga/src/back/spv/writer.rs +++ b/naga/src/back/spv/writer.rs @@ -1618,6 +1618,7 @@ impl Writer { Bi::InstanceIndex => BuiltIn::InstanceIndex, Bi::PointSize => BuiltIn::PointSize, Bi::VertexIndex => BuiltIn::VertexIndex, + Bi::DrawID => BuiltIn::DrawIndex, // fragment Bi::FragDepth => BuiltIn::FragDepth, Bi::PointCoord => BuiltIn::PointCoord, diff --git a/naga/src/back/wgsl/writer.rs b/naga/src/back/wgsl/writer.rs index e8b942a62c..f7555df0b0 100644 --- a/naga/src/back/wgsl/writer.rs +++ b/naga/src/back/wgsl/writer.rs @@ -1941,9 +1941,8 @@ fn builtin_str(built_in: crate::BuiltIn) -> Result<&'static str, Error> { | Bi::CullDistance | Bi::PointSize | Bi::PointCoord - | Bi::WorkGroupSize => { - return Err(Error::Custom(format!("Unsupported builtin {built_in:?}"))) - } + | Bi::WorkGroupSize + | Bi::DrawID => return Err(Error::Custom(format!("Unsupported builtin {built_in:?}"))), }) } diff --git a/naga/src/front/glsl/variables.rs b/naga/src/front/glsl/variables.rs index 16c5bb65d6..23a4141e97 100644 --- a/naga/src/front/glsl/variables.rs +++ b/naga/src/front/glsl/variables.rs @@ -202,6 +202,7 @@ impl Frontend { "gl_VertexIndex" => BuiltIn::VertexIndex, "gl_SampleID" => BuiltIn::SampleIndex, "gl_LocalInvocationIndex" => BuiltIn::LocalInvocationIndex, + "gl_DrawID" => BuiltIn::DrawID, _ => return Ok(None), }; diff --git a/naga/src/front/spv/convert.rs b/naga/src/front/spv/convert.rs index f131db616e..68b870fb01 100644 --- a/naga/src/front/spv/convert.rs +++ b/naga/src/front/spv/convert.rs @@ -139,6 +139,7 @@ pub(super) fn map_builtin(word: spirv::Word, invariant: bool) -> Result crate::BuiltIn::InstanceIndex, Some(Bi::PointSize) => crate::BuiltIn::PointSize, Some(Bi::VertexIndex) => crate::BuiltIn::VertexIndex, + Some(Bi::DrawIndex) => crate::BuiltIn::DrawID, // fragment Some(Bi::FragDepth) => crate::BuiltIn::FragDepth, Some(Bi::PointCoord) => crate::BuiltIn::PointCoord, diff --git a/naga/src/lib.rs b/naga/src/lib.rs index 038e215a6a..145b95f667 100644 --- a/naga/src/lib.rs +++ b/naga/src/lib.rs @@ -400,6 +400,7 @@ pub enum BuiltIn { InstanceIndex, PointSize, VertexIndex, + DrawID, // fragment FragDepth, PointCoord, diff --git a/naga/src/valid/interface.rs b/naga/src/valid/interface.rs index 150a1f9df5..ce9bc12a00 100644 --- a/naga/src/valid/interface.rs +++ b/naga/src/valid/interface.rs @@ -194,7 +194,11 @@ impl VaryingContext<'_> { } let (visible, type_good) = match built_in { - Bi::BaseInstance | Bi::BaseVertex | Bi::InstanceIndex | Bi::VertexIndex => ( + Bi::BaseInstance + | Bi::BaseVertex + | Bi::InstanceIndex + | Bi::VertexIndex + | Bi::DrawID => ( self.stage == St::Vertex && !self.output, *ty_inner == Ti::Scalar(crate::Scalar::U32), ), From 58e1946bd63cbc6902d013071e44accace7b06a7 Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Mon, 7 Oct 2024 18:34:41 -0700 Subject: [PATCH 02/67] Document rationale for vendoring WebGPU bindings. This commit is almost entirely autogenerated changes. --- wgpu/src/backend/webgpu/webgpu_sys/gen_Gpu.rs | 14 +++++++++++ .../webgpu/webgpu_sys/gen_GpuAdapter.rs | 14 +++++++++++ .../webgpu/webgpu_sys/gen_GpuAddressMode.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuAutoLayoutMode.rs | 14 +++++++++++ .../webgpu/webgpu_sys/gen_GpuBindGroup.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuBindGroupDescriptor.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuBindGroupEntry.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuBindGroupLayout.rs | 14 +++++++++++ .../gen_GpuBindGroupLayoutDescriptor.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuBindGroupLayoutEntry.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuBlendComponent.rs | 14 +++++++++++ .../webgpu/webgpu_sys/gen_GpuBlendFactor.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuBlendOperation.rs | 14 +++++++++++ .../webgpu/webgpu_sys/gen_GpuBlendState.rs | 14 +++++++++++ .../webgpu/webgpu_sys/gen_GpuBuffer.rs | 14 +++++++++++ .../webgpu/webgpu_sys/gen_GpuBufferBinding.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuBufferBindingLayout.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuBufferBindingType.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuBufferDescriptor.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuBufferMapState.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuCanvasAlphaMode.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuCanvasConfiguration.rs | 14 +++++++++++ .../webgpu/webgpu_sys/gen_GpuCanvasContext.rs | 14 +++++++++++ .../webgpu/webgpu_sys/gen_GpuColorDict.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuColorTargetState.rs | 14 +++++++++++ .../webgpu/webgpu_sys/gen_GpuCommandBuffer.rs | 14 +++++++++++ .../gen_GpuCommandBufferDescriptor.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuCommandEncoder.rs | 14 +++++++++++ .../gen_GpuCommandEncoderDescriptor.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuCompareFunction.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuCompilationInfo.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuCompilationMessage.rs | 14 +++++++++++ .../gen_GpuCompilationMessageType.rs | 14 +++++++++++ .../gen_GpuComputePassDescriptor.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuComputePassEncoder.rs | 14 +++++++++++ .../gen_GpuComputePassTimestampWrites.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuComputePipeline.rs | 14 +++++++++++ .../gen_GpuComputePipelineDescriptor.rs | 14 +++++++++++ .../webgpu/webgpu_sys/gen_GpuCullMode.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuDepthStencilState.rs | 14 +++++++++++ .../webgpu/webgpu_sys/gen_GpuDevice.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuDeviceDescriptor.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuDeviceLostInfo.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuDeviceLostReason.rs | 14 +++++++++++ .../backend/webgpu/webgpu_sys/gen_GpuError.rs | 14 +++++++++++ .../webgpu/webgpu_sys/gen_GpuErrorFilter.rs | 14 +++++++++++ .../webgpu/webgpu_sys/gen_GpuExtent3dDict.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuExternalTexture.rs | 14 +++++++++++ .../gen_GpuExternalTextureBindingLayout.rs | 14 +++++++++++ .../gen_GpuExternalTextureDescriptor.rs | 14 +++++++++++ .../webgpu/webgpu_sys/gen_GpuFeatureName.rs | 14 +++++++++++ .../webgpu/webgpu_sys/gen_GpuFilterMode.rs | 14 +++++++++++ .../webgpu/webgpu_sys/gen_GpuFragmentState.rs | 14 +++++++++++ .../webgpu/webgpu_sys/gen_GpuFrontFace.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuImageCopyBuffer.rs | 14 +++++++++++ .../gen_GpuImageCopyExternalImage.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuImageCopyTexture.rs | 14 +++++++++++ .../gen_GpuImageCopyTextureTagged.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuImageDataLayout.rs | 14 +++++++++++ .../webgpu/webgpu_sys/gen_GpuIndexFormat.rs | 14 +++++++++++ .../webgpu/webgpu_sys/gen_GpuLoadOp.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuMipmapFilterMode.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuMultisampleState.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuObjectDescriptorBase.rs | 14 +++++++++++ .../webgpu/webgpu_sys/gen_GpuOrigin2dDict.rs | 14 +++++++++++ .../webgpu/webgpu_sys/gen_GpuOrigin3dDict.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuOutOfMemoryError.rs | 14 +++++++++++ .../gen_GpuPipelineDescriptorBase.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuPipelineLayout.rs | 14 +++++++++++ .../gen_GpuPipelineLayoutDescriptor.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuPowerPreference.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuPrimitiveState.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuPrimitiveTopology.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuProgrammableStage.rs | 14 +++++++++++ .../webgpu/webgpu_sys/gen_GpuQuerySet.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuQuerySetDescriptor.rs | 14 +++++++++++ .../webgpu/webgpu_sys/gen_GpuQueryType.rs | 14 +++++++++++ .../backend/webgpu/webgpu_sys/gen_GpuQueue.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuQueueDescriptor.rs | 14 +++++++++++ .../webgpu/webgpu_sys/gen_GpuRenderBundle.rs | 14 +++++++++++ .../gen_GpuRenderBundleDescriptor.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuRenderBundleEncoder.rs | 14 +++++++++++ .../gen_GpuRenderBundleEncoderDescriptor.rs | 14 +++++++++++ .../gen_GpuRenderPassColorAttachment.rs | 14 +++++++++++ ...gen_GpuRenderPassDepthStencilAttachment.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuRenderPassDescriptor.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuRenderPassEncoder.rs | 14 +++++++++++ .../gen_GpuRenderPassTimestampWrites.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuRenderPipeline.rs | 14 +++++++++++ .../gen_GpuRenderPipelineDescriptor.rs | 14 +++++++++++ .../gen_GpuRequestAdapterOptions.rs | 14 +++++++++++ .../webgpu/webgpu_sys/gen_GpuSampler.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuSamplerBindingLayout.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuSamplerBindingType.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuSamplerDescriptor.rs | 14 +++++++++++ .../webgpu/webgpu_sys/gen_GpuShaderModule.rs | 14 +++++++++++ .../gen_GpuShaderModuleDescriptor.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuStencilFaceState.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuStencilOperation.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuStorageTextureAccess.rs | 14 +++++++++++ .../gen_GpuStorageTextureBindingLayout.rs | 14 +++++++++++ .../webgpu/webgpu_sys/gen_GpuStoreOp.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuSupportedFeatures.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuSupportedLimits.rs | 25 +++++++++++++++++++ .../webgpu/webgpu_sys/gen_GpuTexture.rs | 14 +++++++++++ .../webgpu/webgpu_sys/gen_GpuTextureAspect.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuTextureBindingLayout.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuTextureDescriptor.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuTextureDimension.rs | 14 +++++++++++ .../webgpu/webgpu_sys/gen_GpuTextureFormat.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuTextureSampleType.rs | 14 +++++++++++ .../webgpu/webgpu_sys/gen_GpuTextureView.rs | 14 +++++++++++ .../gen_GpuTextureViewDescriptor.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuTextureViewDimension.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuUncapturedErrorEvent.rs | 14 +++++++++++ .../gen_GpuUncapturedErrorEventInit.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuValidationError.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuVertexAttribute.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuVertexBufferLayout.rs | 14 +++++++++++ .../webgpu/webgpu_sys/gen_GpuVertexFormat.rs | 14 +++++++++++ .../webgpu/webgpu_sys/gen_GpuVertexState.rs | 14 +++++++++++ .../webgpu_sys/gen_GpuVertexStepMode.rs | 14 +++++++++++ .../webgpu_sys/gen_WgslLanguageFeatures.rs | 14 +++++++++++ .../webgpu/webgpu_sys/gen_gpu_map_mode.rs | 14 +++++++++++ wgpu/src/backend/webgpu/webgpu_sys/mod.rs | 14 +++++++++++ xtask/src/vendor_web_sys.rs | 14 +++++++++++ 126 files changed, 1775 insertions(+) diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_Gpu.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_Gpu.rs index 7c94bd4f46..9e996d7b0a 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_Gpu.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_Gpu.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuAdapter.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuAdapter.rs index 72b375d88c..d97b308a33 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuAdapter.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuAdapter.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuAddressMode.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuAddressMode.rs index 2a4094c1ca..c2143c693b 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuAddressMode.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuAddressMode.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuAutoLayoutMode.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuAutoLayoutMode.rs index 7034a1cb1b..b17f983fc4 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuAutoLayoutMode.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuAutoLayoutMode.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBindGroup.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBindGroup.rs index 80af440da3..70670a1e9a 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBindGroup.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBindGroup.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBindGroupDescriptor.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBindGroupDescriptor.rs index 453d04da8a..76a1296c5f 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBindGroupDescriptor.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBindGroupDescriptor.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBindGroupEntry.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBindGroupEntry.rs index 4ae0f1a6c4..b29899d077 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBindGroupEntry.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBindGroupEntry.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBindGroupLayout.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBindGroupLayout.rs index 36c620611b..7e0a96f09d 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBindGroupLayout.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBindGroupLayout.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBindGroupLayoutDescriptor.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBindGroupLayoutDescriptor.rs index 9e7f3cb54f..bf09137381 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBindGroupLayoutDescriptor.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBindGroupLayoutDescriptor.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBindGroupLayoutEntry.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBindGroupLayoutEntry.rs index 0fada9059d..40fe762a6d 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBindGroupLayoutEntry.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBindGroupLayoutEntry.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBlendComponent.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBlendComponent.rs index 4bb04574dc..3a19570db1 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBlendComponent.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBlendComponent.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBlendFactor.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBlendFactor.rs index 47253d7cdb..778b563b92 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBlendFactor.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBlendFactor.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBlendOperation.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBlendOperation.rs index b65ede6a70..587cf72091 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBlendOperation.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBlendOperation.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBlendState.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBlendState.rs index 4e3426c709..f00d4addae 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBlendState.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBlendState.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBuffer.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBuffer.rs index 6d6c5dca93..3e6c2aca97 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBuffer.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBuffer.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBufferBinding.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBufferBinding.rs index c583c69850..efb03aa711 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBufferBinding.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBufferBinding.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBufferBindingLayout.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBufferBindingLayout.rs index 0fd2488f0e..46e5ed578a 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBufferBindingLayout.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBufferBindingLayout.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBufferBindingType.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBufferBindingType.rs index f3361cccda..b9818aabf5 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBufferBindingType.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBufferBindingType.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBufferDescriptor.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBufferDescriptor.rs index 377e829f3f..72a5c5fc71 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBufferDescriptor.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBufferDescriptor.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBufferMapState.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBufferMapState.rs index 2e0b271e2a..385fe8a4bd 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBufferMapState.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuBufferMapState.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCanvasAlphaMode.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCanvasAlphaMode.rs index 687939ceb6..2149140497 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCanvasAlphaMode.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCanvasAlphaMode.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCanvasConfiguration.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCanvasConfiguration.rs index 5db5747c20..4af8e72202 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCanvasConfiguration.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCanvasConfiguration.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCanvasContext.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCanvasContext.rs index b7734084aa..204a08dd8e 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCanvasContext.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCanvasContext.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuColorDict.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuColorDict.rs index 73ab12a727..4e29fbd199 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuColorDict.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuColorDict.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuColorTargetState.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuColorTargetState.rs index 6a4701f73e..533b2a3fb0 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuColorTargetState.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuColorTargetState.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCommandBuffer.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCommandBuffer.rs index 20aef1d1b3..9d2eacdeb5 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCommandBuffer.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCommandBuffer.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCommandBufferDescriptor.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCommandBufferDescriptor.rs index bedfcb6320..818ac0a6e0 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCommandBufferDescriptor.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCommandBufferDescriptor.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCommandEncoder.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCommandEncoder.rs index b6e705fed9..9b6b7924a3 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCommandEncoder.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCommandEncoder.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCommandEncoderDescriptor.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCommandEncoderDescriptor.rs index 2659ef75ce..39b4c69e61 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCommandEncoderDescriptor.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCommandEncoderDescriptor.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCompareFunction.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCompareFunction.rs index 52bb4b8ebd..0988524d98 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCompareFunction.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCompareFunction.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCompilationInfo.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCompilationInfo.rs index b345013dab..2667758e7d 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCompilationInfo.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCompilationInfo.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCompilationMessage.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCompilationMessage.rs index b93bf6562c..ae60573de9 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCompilationMessage.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCompilationMessage.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCompilationMessageType.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCompilationMessageType.rs index e98f438d68..3fcadd0f03 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCompilationMessageType.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCompilationMessageType.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuComputePassDescriptor.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuComputePassDescriptor.rs index d1eb125f99..d7f30e3e93 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuComputePassDescriptor.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuComputePassDescriptor.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuComputePassEncoder.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuComputePassEncoder.rs index 1643039349..2dd152edce 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuComputePassEncoder.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuComputePassEncoder.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuComputePassTimestampWrites.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuComputePassTimestampWrites.rs index f88a40c0a6..8b2afd73e3 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuComputePassTimestampWrites.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuComputePassTimestampWrites.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuComputePipeline.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuComputePipeline.rs index c2e8db370a..33a28f533b 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuComputePipeline.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuComputePipeline.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuComputePipelineDescriptor.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuComputePipelineDescriptor.rs index 110b4f34ba..1184f400fc 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuComputePipelineDescriptor.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuComputePipelineDescriptor.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCullMode.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCullMode.rs index 8242ff4305..f9889938fe 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCullMode.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCullMode.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuDepthStencilState.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuDepthStencilState.rs index f48c27411b..098d3c4c26 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuDepthStencilState.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuDepthStencilState.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuDevice.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuDevice.rs index 3a3f424736..57f3bda9c1 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuDevice.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuDevice.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuDeviceDescriptor.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuDeviceDescriptor.rs index 98ceb1a2d6..f712d4c514 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuDeviceDescriptor.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuDeviceDescriptor.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuDeviceLostInfo.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuDeviceLostInfo.rs index d2ac3682fe..d2d670a40b 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuDeviceLostInfo.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuDeviceLostInfo.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuDeviceLostReason.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuDeviceLostReason.rs index d40e4dcce0..bbe71dd5e6 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuDeviceLostReason.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuDeviceLostReason.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuError.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuError.rs index b79e34e855..26b9b347df 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuError.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuError.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuErrorFilter.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuErrorFilter.rs index 07b9d9efdd..27ef19258f 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuErrorFilter.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuErrorFilter.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuExtent3dDict.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuExtent3dDict.rs index 6367c27aef..910e2030bb 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuExtent3dDict.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuExtent3dDict.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuExternalTexture.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuExternalTexture.rs index 3ba889d2b3..a620e80d1b 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuExternalTexture.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuExternalTexture.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuExternalTextureBindingLayout.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuExternalTextureBindingLayout.rs index 993e1e8362..68e13a5cf0 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuExternalTextureBindingLayout.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuExternalTextureBindingLayout.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuExternalTextureDescriptor.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuExternalTextureDescriptor.rs index 67a15483ad..086361305d 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuExternalTextureDescriptor.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuExternalTextureDescriptor.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuFeatureName.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuFeatureName.rs index ef2119a88b..353bfcef21 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuFeatureName.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuFeatureName.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuFilterMode.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuFilterMode.rs index 6113531e9d..a2b3122856 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuFilterMode.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuFilterMode.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuFragmentState.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuFragmentState.rs index cd5c794219..1b42597649 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuFragmentState.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuFragmentState.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuFrontFace.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuFrontFace.rs index 5ecadfaaef..3d206ace43 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuFrontFace.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuFrontFace.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuImageCopyBuffer.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuImageCopyBuffer.rs index bb3655b635..b9a8ca5bf3 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuImageCopyBuffer.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuImageCopyBuffer.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuImageCopyExternalImage.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuImageCopyExternalImage.rs index 8e37000dc2..bc301db717 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuImageCopyExternalImage.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuImageCopyExternalImage.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuImageCopyTexture.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuImageCopyTexture.rs index 40e33db1cf..15fe41c2db 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuImageCopyTexture.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuImageCopyTexture.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuImageCopyTextureTagged.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuImageCopyTextureTagged.rs index 0382477852..2928b74e54 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuImageCopyTextureTagged.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuImageCopyTextureTagged.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuImageDataLayout.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuImageDataLayout.rs index aa373814b1..3d19ec8b42 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuImageDataLayout.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuImageDataLayout.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuIndexFormat.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuIndexFormat.rs index e49411bdb0..03ca2d116a 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuIndexFormat.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuIndexFormat.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuLoadOp.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuLoadOp.rs index 2b341815a2..40230f0038 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuLoadOp.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuLoadOp.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuMipmapFilterMode.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuMipmapFilterMode.rs index 9a795f5a32..ecf0eae46a 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuMipmapFilterMode.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuMipmapFilterMode.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuMultisampleState.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuMultisampleState.rs index b6cdc5a849..1b5ecaedd4 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuMultisampleState.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuMultisampleState.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuObjectDescriptorBase.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuObjectDescriptorBase.rs index 072a83a096..ecfdfae7b5 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuObjectDescriptorBase.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuObjectDescriptorBase.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuOrigin2dDict.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuOrigin2dDict.rs index d301235afd..9b02f7d4b7 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuOrigin2dDict.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuOrigin2dDict.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuOrigin3dDict.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuOrigin3dDict.rs index f93fbe4d82..697137c710 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuOrigin3dDict.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuOrigin3dDict.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuOutOfMemoryError.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuOutOfMemoryError.rs index b56ac35cdf..6f1aa56400 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuOutOfMemoryError.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuOutOfMemoryError.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuPipelineDescriptorBase.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuPipelineDescriptorBase.rs index 4afd5f7fbb..8c85565b46 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuPipelineDescriptorBase.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuPipelineDescriptorBase.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuPipelineLayout.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuPipelineLayout.rs index 6e3e1aedbf..b394401cbe 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuPipelineLayout.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuPipelineLayout.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuPipelineLayoutDescriptor.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuPipelineLayoutDescriptor.rs index 6b574cbcf4..37df0d7da1 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuPipelineLayoutDescriptor.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuPipelineLayoutDescriptor.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuPowerPreference.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuPowerPreference.rs index 996db271c4..85ca517aee 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuPowerPreference.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuPowerPreference.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuPrimitiveState.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuPrimitiveState.rs index f347e493b3..13886c3a71 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuPrimitiveState.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuPrimitiveState.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuPrimitiveTopology.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuPrimitiveTopology.rs index 6d7972c331..4e603eb816 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuPrimitiveTopology.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuPrimitiveTopology.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuProgrammableStage.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuProgrammableStage.rs index 761bf6bfbf..b6992f7164 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuProgrammableStage.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuProgrammableStage.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuQuerySet.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuQuerySet.rs index 590ede3451..2ae2993542 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuQuerySet.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuQuerySet.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuQuerySetDescriptor.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuQuerySetDescriptor.rs index 174e9dd2a8..c291f894fb 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuQuerySetDescriptor.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuQuerySetDescriptor.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuQueryType.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuQueryType.rs index 2f7969e352..ed8d7f9cc3 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuQueryType.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuQueryType.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuQueue.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuQueue.rs index ed5647b749..51f1e0e000 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuQueue.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuQueue.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuQueueDescriptor.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuQueueDescriptor.rs index 527ea14638..3224505d4e 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuQueueDescriptor.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuQueueDescriptor.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderBundle.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderBundle.rs index d2eaefa99d..bab9c94107 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderBundle.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderBundle.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderBundleDescriptor.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderBundleDescriptor.rs index 9cf2df9145..0a73f47d04 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderBundleDescriptor.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderBundleDescriptor.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderBundleEncoder.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderBundleEncoder.rs index d73c71330d..0b8d2dde16 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderBundleEncoder.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderBundleEncoder.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderBundleEncoderDescriptor.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderBundleEncoderDescriptor.rs index e2bef72547..95bcc3d039 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderBundleEncoderDescriptor.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderBundleEncoderDescriptor.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderPassColorAttachment.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderPassColorAttachment.rs index dedf8dc8e2..199d1400ec 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderPassColorAttachment.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderPassColorAttachment.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderPassDepthStencilAttachment.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderPassDepthStencilAttachment.rs index cc0f290f4b..bccd742e01 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderPassDepthStencilAttachment.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderPassDepthStencilAttachment.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderPassDescriptor.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderPassDescriptor.rs index 0f74b953a5..3db05ace60 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderPassDescriptor.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderPassDescriptor.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderPassEncoder.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderPassEncoder.rs index 87e735251a..7a7726e21c 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderPassEncoder.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderPassEncoder.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderPassTimestampWrites.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderPassTimestampWrites.rs index ef2c09e4bf..42c1323db9 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderPassTimestampWrites.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderPassTimestampWrites.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderPipeline.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderPipeline.rs index 59a1634421..709377d2ad 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderPipeline.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderPipeline.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderPipelineDescriptor.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderPipelineDescriptor.rs index 06a47432d8..9cede3cf79 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderPipelineDescriptor.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRenderPipelineDescriptor.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRequestAdapterOptions.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRequestAdapterOptions.rs index 947db22a75..5189fd6f4a 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRequestAdapterOptions.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuRequestAdapterOptions.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuSampler.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuSampler.rs index c42656202c..eb00f2534d 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuSampler.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuSampler.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuSamplerBindingLayout.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuSamplerBindingLayout.rs index a1973b9e38..00d8e856b2 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuSamplerBindingLayout.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuSamplerBindingLayout.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuSamplerBindingType.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuSamplerBindingType.rs index 4d49ec529e..7c361589cf 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuSamplerBindingType.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuSamplerBindingType.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuSamplerDescriptor.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuSamplerDescriptor.rs index 3ecc89e195..7c8f0d4381 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuSamplerDescriptor.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuSamplerDescriptor.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuShaderModule.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuShaderModule.rs index 1de5900a0b..9148feb25b 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuShaderModule.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuShaderModule.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuShaderModuleDescriptor.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuShaderModuleDescriptor.rs index 87cb3c0444..3823a3dcf8 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuShaderModuleDescriptor.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuShaderModuleDescriptor.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuStencilFaceState.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuStencilFaceState.rs index 1e0f5509cc..b0f324a0eb 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuStencilFaceState.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuStencilFaceState.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuStencilOperation.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuStencilOperation.rs index 6c6b7fa1c4..72895124f8 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuStencilOperation.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuStencilOperation.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuStorageTextureAccess.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuStorageTextureAccess.rs index 299fde647e..c017b48b19 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuStorageTextureAccess.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuStorageTextureAccess.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuStorageTextureBindingLayout.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuStorageTextureBindingLayout.rs index 2e3bc28023..f9b27b5333 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuStorageTextureBindingLayout.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuStorageTextureBindingLayout.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuStoreOp.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuStoreOp.rs index bdca8cab7c..7af64ec61e 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuStoreOp.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuStoreOp.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuSupportedFeatures.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuSupportedFeatures.rs index 8a22856be2..8304ea9864 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuSupportedFeatures.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuSupportedFeatures.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuSupportedLimits.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuSupportedLimits.rs index 37cbfceda0..0bd278ebea 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuSupportedLimits.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuSupportedLimits.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. @@ -266,6 +280,17 @@ extern "C" { #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] pub fn max_vertex_buffer_array_stride(this: &GpuSupportedLimits) -> u32; + # [wasm_bindgen (structural , method , getter , js_class = "GPUSupportedLimits" , js_name = maxInterStageShaderComponents)] + #[doc = "Getter for the `maxInterStageShaderComponents` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUSupportedLimits/maxInterStageShaderComponents)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSupportedLimits`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn max_inter_stage_shader_components(this: &GpuSupportedLimits) -> u32; + # [wasm_bindgen (structural , method , getter , js_class = "GPUSupportedLimits" , js_name = maxInterStageShaderVariables)] #[doc = "Getter for the `maxInterStageShaderVariables` field of this object."] #[doc = ""] diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTexture.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTexture.rs index 78d7a3714a..231025a65f 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTexture.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTexture.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureAspect.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureAspect.rs index 955890a5ca..fe5bebbef9 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureAspect.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureAspect.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureBindingLayout.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureBindingLayout.rs index fc1917a2eb..385cb2d3ac 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureBindingLayout.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureBindingLayout.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureDescriptor.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureDescriptor.rs index 4b4ee0bcd5..909072d848 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureDescriptor.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureDescriptor.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureDimension.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureDimension.rs index 548fd820bd..4c321802fb 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureDimension.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureDimension.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureFormat.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureFormat.rs index cf07abd384..d554598559 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureFormat.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureFormat.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureSampleType.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureSampleType.rs index 61bc98b468..22ba921800 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureSampleType.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureSampleType.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureView.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureView.rs index 063382d4ee..e4d113d385 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureView.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureView.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureViewDescriptor.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureViewDescriptor.rs index dcc4d48a8e..6d5ae0a47c 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureViewDescriptor.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureViewDescriptor.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureViewDimension.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureViewDimension.rs index c3c62a745e..c6b205ea62 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureViewDimension.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuTextureViewDimension.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuUncapturedErrorEvent.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuUncapturedErrorEvent.rs index e665b8de73..cdc850b539 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuUncapturedErrorEvent.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuUncapturedErrorEvent.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuUncapturedErrorEventInit.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuUncapturedErrorEventInit.rs index 012c910d7a..658dfaa8ad 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuUncapturedErrorEventInit.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuUncapturedErrorEventInit.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuValidationError.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuValidationError.rs index e59e697496..f28d2c420c 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuValidationError.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuValidationError.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuVertexAttribute.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuVertexAttribute.rs index 41588b1bc5..a67d2ea2dd 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuVertexAttribute.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuVertexAttribute.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuVertexBufferLayout.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuVertexBufferLayout.rs index f6d92ef630..ebd1f176d5 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuVertexBufferLayout.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuVertexBufferLayout.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuVertexFormat.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuVertexFormat.rs index 10f294c37e..972be0205f 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuVertexFormat.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuVertexFormat.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuVertexState.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuVertexState.rs index 5869d00978..fe7d2c86a0 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuVertexState.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuVertexState.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuVertexStepMode.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuVertexStepMode.rs index f64c86605c..220df95015 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuVertexStepMode.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuVertexStepMode.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_WgslLanguageFeatures.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_WgslLanguageFeatures.rs index 429c166bb2..571da0a756 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_WgslLanguageFeatures.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_WgslLanguageFeatures.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_gpu_map_mode.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_gpu_map_mode.rs index b3e20113b5..7448085f47 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_gpu_map_mode.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_gpu_map_mode.rs @@ -2,6 +2,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/wgpu/src/backend/webgpu/webgpu_sys/mod.rs b/wgpu/src/backend/webgpu/webgpu_sys/mod.rs index f2b050dd5f..f4e3ddf93d 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/mod.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/mod.rs @@ -5,6 +5,20 @@ // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // +// These bindings are vendored into wgpu for the sole purpose of letting +// us pin the WebGPU backend to a specific version of the bindings, not +// to enable local changes. There are no provisions to preserve changes +// you make here the next time we re-vendor the bindings. +// +// The `web-sys` crate does not treat breaking changes to the WebGPU API +// as semver breaking changes, as WebGPU is "unstable". This means Cargo +// will not let us mix versions of `web-sys`, pinning WebGPU bindings to +// a specific version, while letting other bindings like WebGL get +// updated. Vendoring WebGPU was the workaround we chose. +// +// Vendoring also allows us to avoid building `web-sys` with +// `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. +// // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys --version 0.2.91` command. diff --git a/xtask/src/vendor_web_sys.rs b/xtask/src/vendor_web_sys.rs index afa590fa6a..5f92f430e9 100644 --- a/xtask/src/vendor_web_sys.rs +++ b/xtask/src/vendor_web_sys.rs @@ -221,6 +221,20 @@ pub(crate) fn run_vendor_web_sys(shell: Shell, mut args: Arguments) -> anyhow::R // // This module part of a subset of web-sys that is used by wgpu's webgpu backend. // + // These bindings are vendored into wgpu for the sole purpose of letting + // us pin the WebGPU backend to a specific version of the bindings, not + // to enable local changes. There are no provisions to preserve changes + // you make here the next time we re-vendor the bindings. + // + // The `web-sys` crate does not treat breaking changes to the WebGPU API + // as semver breaking changes, as WebGPU is \"unstable\". This means Cargo + // will not let us mix versions of `web-sys`, pinning WebGPU bindings to + // a specific version, while letting other bindings like WebGL get + // updated. Vendoring WebGPU was the workaround we chose. + // + // Vendoring also allows us to avoid building `web-sys` with + // `--cfg=web_sys_unstable_apis`, needed to get the WebGPU bindings. + // // If you want to improve the generated code, please submit a PR to the https://github.com/rustwasm/wasm-bindgen repository. // // This file was generated by the `cargo xtask vendor-web-sys {argument_description}` command.\n" From 634a97fcb89c377c738e4278f6490d4aeea49e9f Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Mon, 30 Sep 2024 16:15:30 -0700 Subject: [PATCH 03/67] [naga spv-out] Abstract out non-uniform binding array access test. Introduce a new function, `BlockContext::is_nonuniform_binding_array_access`, which determines whether a given array access expression means that the `OpAccessChain` instruction must have a `NonUniform` decoration. --- naga/src/back/spv/block.rs | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/naga/src/back/spv/block.rs b/naga/src/back/spv/block.rs index c6adba85b1..34d474aaf5 100644 --- a/naga/src/back/spv/block.rs +++ b/naga/src/back/spv/block.rs @@ -1828,19 +1828,8 @@ impl<'w> BlockContext<'w> { let root_id = loop { expr_handle = match self.ir_function.expressions[expr_handle] { crate::Expression::Access { base, index } => { - if let crate::Expression::GlobalVariable(var_handle) = - self.ir_function.expressions[base] - { - // The access chain needs to be decorated as NonUniform - // see VUID-RuntimeSpirv-NonUniform-06274 - let gvar = &self.ir_module.global_variables[var_handle]; - if let crate::TypeInner::BindingArray { .. } = - self.ir_module.types[gvar.ty].inner - { - is_non_uniform_binding_array = - self.fun_info[index].uniformity.non_uniform_result.is_some(); - } - } + is_non_uniform_binding_array |= + self.is_nonuniform_binding_array_access(base, index); let index_id = match self.write_bounds_check(base, index, block)? { BoundsCheckResult::KnownInBounds(known_index) => { @@ -1933,6 +1922,26 @@ impl<'w> BlockContext<'w> { Ok(expr_pointer) } + fn is_nonuniform_binding_array_access( + &mut self, + base: Handle, + index: Handle, + ) -> bool { + let crate::Expression::GlobalVariable(var_handle) = self.ir_function.expressions[base] + else { + return false; + }; + + // The access chain needs to be decorated as NonUniform + // see VUID-RuntimeSpirv-NonUniform-06274 + let gvar = &self.ir_module.global_variables[var_handle]; + let crate::TypeInner::BindingArray { .. } = self.ir_module.types[gvar.ty].inner else { + return false; + }; + + self.fun_info[index].uniformity.non_uniform_result.is_some() + } + /// Build the instructions for matrix - matrix column operations #[allow(clippy::too_many_arguments)] fn write_matrix_matrix_column_op( From 21c527a45884b69972ed89cd87342030920f46e5 Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Mon, 30 Sep 2024 16:39:49 -0700 Subject: [PATCH 04/67] [naga spv-out] Doc fix: typo --- naga/src/back/spv/block.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/naga/src/back/spv/block.rs b/naga/src/back/spv/block.rs index 34d474aaf5..abf914c633 100644 --- a/naga/src/back/spv/block.rs +++ b/naga/src/back/spv/block.rs @@ -1833,7 +1833,7 @@ impl<'w> BlockContext<'w> { let index_id = match self.write_bounds_check(base, index, block)? { BoundsCheckResult::KnownInBounds(known_index) => { - // Even if the index is known, `OpAccessIndex` + // Even if the index is known, `OpAccessChain` // requires expression operands, not literals. let scalar = crate::Literal::U32(known_index); self.writer.get_constant_scalar(scalar) From 287ca16b52fe4493a8e205b3a81a7aa2c22f469d Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Mon, 30 Sep 2024 16:53:22 -0700 Subject: [PATCH 05/67] [naga spv-out] Abstract extending a bounds check condition chain. Introduce a new function, `BlockContext::extend_bounds_check_condition_chain`, which adds a new boolean condition to the chain of bounds checks guarding an `OpAccessChain` instruction. --- naga/src/back/spv/block.rs | 76 ++++++++++++++++++++++++++------------ 1 file changed, 52 insertions(+), 24 deletions(-) diff --git a/naga/src/back/spv/block.rs b/naga/src/back/spv/block.rs index abf914c633..c2829231a1 100644 --- a/naga/src/back/spv/block.rs +++ b/naga/src/back/spv/block.rs @@ -1813,14 +1813,11 @@ impl<'w> BlockContext<'w> { }; let result_type_id = self.get_type_id(result_lookup_ty); - // The id of the boolean `and` of all dynamic bounds checks up to this point. If - // `None`, then we haven't done any dynamic bounds checks yet. + // The id of the boolean `and` of all dynamic bounds checks up to this point. // - // When we have a chain of bounds checks, we combine them with `OpLogicalAnd`, not - // a short-circuit branch. This means we might do comparisons we don't need to, - // but we expect these checks to almost always succeed, and keeping branches to a - // minimum is essential. + // See `extend_bounds_check_condition_chain` for a full explanation. let mut accumulated_checks = None; + // Is true if we are accessing into a binding array with a non-uniform index. let mut is_non_uniform_binding_array = false; @@ -1840,25 +1837,13 @@ impl<'w> BlockContext<'w> { } BoundsCheckResult::Computed(computed_index_id) => computed_index_id, BoundsCheckResult::Conditional(comparison_id) => { - match accumulated_checks { - Some(prior_checks) => { - let combined = self.gen_id(); - block.body.push(Instruction::binary( - spirv::Op::LogicalAnd, - self.writer.get_bool_type_id(), - combined, - prior_checks, - comparison_id, - )); - accumulated_checks = Some(combined); - } - None => { - // Start a fresh chain of checks. - accumulated_checks = Some(comparison_id); - } - } + self.extend_bounds_check_condition_chain( + &mut accumulated_checks, + comparison_id, + block, + ); - // Either way, the index to use is unchanged. + // Use the index from the `Access` expression unchanged. self.cached[index] } }; @@ -1942,6 +1927,49 @@ impl<'w> BlockContext<'w> { self.fun_info[index].uniformity.non_uniform_result.is_some() } + /// Add a condition to a chain of bounds checks. + /// + /// As we build an `OpAccessChain` instruction govered by + /// [`BoundsCheckPolicy::ReadZeroSkipWrite`], we accumulate a chain of + /// dynamic bounds checks, one for each index in the chain, which must all + /// be true for that `OpAccessChain`'s execution to be well-defined. This + /// function adds the boolean instruction id `comparison_id` to `chain`. + /// + /// If `chain` is `None`, that means there are no bounds checks in the chain + /// yet. If chain is `Some(id)`, then `id` is the conjunction of all the + /// bounds checks in the chain. + /// + /// When we have multiple bounds checks, we combine them with + /// `OpLogicalAnd`, not a short-circuit branch. This means we might do + /// comparisons we don't need to, but we expect these checks to almost + /// always succeed, and keeping branches to a minimum is essential. + /// + /// [`BoundsCheckPolicy::ReadZeroSkipWrite`]: crate::proc::BoundsCheckPolicy + fn extend_bounds_check_condition_chain( + &mut self, + chain: &mut Option, + comparison_id: Word, + block: &mut Block, + ) { + match *chain { + Some(ref mut prior_checks) => { + let combined = self.gen_id(); + block.body.push(Instruction::binary( + spirv::Op::LogicalAnd, + self.writer.get_bool_type_id(), + combined, + *prior_checks, + comparison_id, + )); + *prior_checks = combined; + } + None => { + // Start a fresh chain of checks. + *chain = Some(comparison_id); + } + } + } + /// Build the instructions for matrix - matrix column operations #[allow(clippy::too_many_arguments)] fn write_matrix_matrix_column_op( From 3d85781f05822dfc443e3c73aeef49eab9a687f5 Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Tue, 1 Oct 2024 10:11:41 -0700 Subject: [PATCH 06/67] [naga spv-out] Consolidate code to find index values. Let the SPIR-V backend use `GuardedIndex::try_resolve_to_constant`, rather than writing out its definition in `write_restricted_index` and `write_index_comparison`. Call `try_resolve_to_constant` in one place, in `write_bounds_check`, and simply pass the `GuardedIndex` into subroutines. Reduce `write_restricted_index` and `write_index_comparison` to case analysis and code generation. Note that this commit does have a benign effect on SPIR-V snapshot output for programs like this: let one_i = 1i; var vec0 = vec3(); vec0[one_i] = 1; The value indexing `vec0` here is an `i32`, but after this commit, the operand to `OpAccessChain` becomes a `u32` constant (with the same value). This is because `write_bounds_check` now calls `try_resolve_to_constant` itself, rather than deferring this work to its callees, so it may return `BoundsCheckResult::KnownInBounds` even when the `Unchecked` policy is in force. This directs the caller, `write_expression_pointer`, to treat the `OpAccessChain` operand as a fresh `u32` constant, rather than simply passing through the original `i32` expression. --- naga/src/back/spv/index.rs | 116 +++++++++++++--------------- naga/src/proc/index.rs | 6 +- naga/tests/out/spv/operators.spvasm | 8 +- 3 files changed, 62 insertions(+), 68 deletions(-) diff --git a/naga/src/back/spv/index.rs b/naga/src/back/spv/index.rs index 1b7cce9978..c02cfe469c 100644 --- a/naga/src/back/spv/index.rs +++ b/naga/src/back/spv/index.rs @@ -7,13 +7,17 @@ use super::{ selection::Selection, Block, BlockContext, Error, IdGenerator, Instruction, Word, }; -use crate::{arena::Handle, proc::BoundsCheckPolicy}; +use crate::{ + arena::Handle, + proc::{index::GuardedIndex, BoundsCheckPolicy}, +}; /// The results of performing a bounds check. /// /// On success, [`write_bounds_check`](BlockContext::write_bounds_check) /// returns a value of this type. The caller can assume that the right /// policy has been applied, and simply do what the variant says. +#[derive(Debug)] pub(super) enum BoundsCheckResult { /// The index is statically known and in bounds, with the given value. KnownInBounds(u32), @@ -40,6 +44,7 @@ pub(super) enum BoundsCheckResult { } /// A value that we either know at translation time, or need to compute at runtime. +#[derive(Copy, Clone)] pub(super) enum MaybeKnown { /// The value is known at shader translation time. Known(T), @@ -329,33 +334,26 @@ impl<'w> BlockContext<'w> { pub(super) fn write_restricted_index( &mut self, sequence: Handle, - index: Handle, + index: GuardedIndex, block: &mut Block, ) -> Result { - let index_id = self.cached[index]; + let max_index = self.write_sequence_max_index(sequence, block)?; - // Get the sequence's maximum valid index. Return early if we've already - // done the bounds check. - let max_index_id = match self.write_sequence_max_index(sequence, block)? { - MaybeKnown::Known(known_max_index) => { - if let Ok(known_index) = self - .ir_module - .to_ctx() - .eval_expr_to_u32_from(index, &self.ir_function.expressions) - { - // Both the index and length are known at compile time. - // - // In strict WGSL compliance mode, out-of-bounds indices cannot be - // reported at shader translation time, and must be replaced with - // in-bounds indices at run time. So we cannot assume that - // validation ensured the index was in bounds. Restrict now. - let restricted = std::cmp::min(known_index, known_max_index); - return Ok(BoundsCheckResult::KnownInBounds(restricted)); - } + // If both are known, we can compute the index to be used + // right now. + if let (GuardedIndex::Known(index), MaybeKnown::Known(max_index)) = (index, max_index) { + let restricted = std::cmp::min(index, max_index); + return Ok(BoundsCheckResult::KnownInBounds(restricted)); + } - self.get_index_constant(known_max_index) - } - MaybeKnown::Computed(max_index_id) => max_index_id, + let index_id = match index { + GuardedIndex::Known(value) => self.get_index_constant(value), + GuardedIndex::Expression(expr) => self.cached[expr], + }; + + let max_index_id = match max_index { + MaybeKnown::Known(value) => self.get_index_constant(value), + MaybeKnown::Computed(id) => id, }; // One or the other of the index or length is dynamic, so emit code for @@ -393,48 +391,33 @@ impl<'w> BlockContext<'w> { fn write_index_comparison( &mut self, sequence: Handle, - index: Handle, + index: GuardedIndex, block: &mut Block, ) -> Result { - let index_id = self.cached[index]; + let length = self.write_sequence_length(sequence, block)?; - // Get the sequence's length. Return early if we've already done the - // bounds check. - let length_id = match self.write_sequence_length(sequence, block)? { - MaybeKnown::Known(known_length) => { - if let Ok(known_index) = self - .ir_module - .to_ctx() - .eval_expr_to_u32_from(index, &self.ir_function.expressions) - { - // Both the index and length are known at compile time. - // - // It would be nice to assume that, since we are using the - // `ReadZeroSkipWrite` policy, we are not in strict WGSL - // compliance mode, and thus we can count on the validator to have - // rejected any programs with known out-of-bounds indices, and - // thus just return `KnownInBounds` here without actually - // checking. - // - // But it's also reasonable to expect that bounds check policies - // and error reporting policies should be able to vary - // independently without introducing security holes. So, we should - // support the case where bad indices do not cause validation - // errors, and are handled via `ReadZeroSkipWrite`. - // - // In theory, when `known_index` is bad, we could return a new - // `KnownOutOfBounds` variant here. But it's simpler just to fall - // through and let the bounds check take place. The shader is - // broken anyway, so it doesn't make sense to invest in emitting - // the ideal code for it. - if known_index < known_length { - return Ok(BoundsCheckResult::KnownInBounds(known_index)); - } - } - - self.get_index_constant(known_length) + // If both are known, we can decide whether the index is in + // bounds right now. + if let (GuardedIndex::Known(index), MaybeKnown::Known(length)) = (index, length) { + if index < length { + return Ok(BoundsCheckResult::KnownInBounds(index)); } - MaybeKnown::Computed(length_id) => length_id, + + // In theory, when `index` is bad, we could return a new + // `KnownOutOfBounds` variant here. But it's simpler just to fall + // through and let the bounds check take place. The shader is broken + // anyway, so it doesn't make sense to invest in emitting the ideal + // code for it. + } + + let index_id = match index { + GuardedIndex::Known(value) => self.get_index_constant(value), + GuardedIndex::Expression(expr) => self.cached[expr], + }; + + let length_id = match length { + MaybeKnown::Known(value) => self.get_index_constant(value), + MaybeKnown::Computed(id) => id, }; // Compare the index against the length. @@ -519,6 +502,10 @@ impl<'w> BlockContext<'w> { index: Handle, block: &mut Block, ) -> Result { + // If the value of `index` is known at compile time, find it now. + let mut index = GuardedIndex::Expression(index); + index.try_resolve_to_constant(self.ir_function, self.ir_module); + let policy = self.writer.bounds_check_policies.choose_policy( base, &self.ir_module.types, @@ -530,7 +517,10 @@ impl<'w> BlockContext<'w> { BoundsCheckPolicy::ReadZeroSkipWrite => { self.write_index_comparison(base, index, block)? } - BoundsCheckPolicy::Unchecked => BoundsCheckResult::Computed(self.cached[index]), + BoundsCheckPolicy::Unchecked => match index { + GuardedIndex::Known(value) => BoundsCheckResult::KnownInBounds(value), + GuardedIndex::Expression(expr) => BoundsCheckResult::Computed(self.cached[expr]), + }, }) } diff --git a/naga/src/proc/index.rs b/naga/src/proc/index.rs index 555b08d2c3..1066eb2388 100644 --- a/naga/src/proc/index.rs +++ b/naga/src/proc/index.rs @@ -334,7 +334,11 @@ impl GuardedIndex { /// Make a `GuardedIndex::Known` from a `GuardedIndex::Expression` if possible. /// /// Return values that are already `Known` unchanged. - fn try_resolve_to_constant(&mut self, function: &crate::Function, module: &crate::Module) { + pub(crate) fn try_resolve_to_constant( + &mut self, + function: &crate::Function, + module: &crate::Module, + ) { if let GuardedIndex::Expression(expr) = *self { if let Ok(value) = module .to_ctx() diff --git a/naga/tests/out/spv/operators.spvasm b/naga/tests/out/spv/operators.spvasm index a59c2e5558..766f45528b 100644 --- a/naga/tests/out/spv/operators.spvasm +++ b/naga/tests/out/spv/operators.spvasm @@ -387,15 +387,15 @@ OpStore %302 %331 %332 = OpLoad %5 %302 %333 = OpISub %5 %332 %23 OpStore %302 %333 -%335 = OpAccessChain %334 %305 %23 +%335 = OpAccessChain %334 %305 %122 %336 = OpLoad %5 %335 %337 = OpIAdd %5 %336 %23 -%338 = OpAccessChain %334 %305 %23 +%338 = OpAccessChain %334 %305 %122 OpStore %338 %337 -%339 = OpAccessChain %334 %305 %23 +%339 = OpAccessChain %334 %305 %122 %340 = OpLoad %5 %339 %341 = OpISub %5 %340 %23 -%342 = OpAccessChain %334 %305 %23 +%342 = OpAccessChain %334 %305 %122 OpStore %342 %341 OpReturn OpFunctionEnd From 69ab63ca34ea247f5777a4cb586d09d38edf5dab Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Tue, 1 Oct 2024 10:39:37 -0700 Subject: [PATCH 07/67] [naga spv-out] Abstract out `OpAccessChain` index production. Abstract the code from `write_expression_pointer` to handle one indexing operation out into its own function, `BlockContext::write_access_chain_index`. --- naga/src/back/spv/block.rs | 55 +++++++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 19 deletions(-) diff --git a/naga/src/back/spv/block.rs b/naga/src/back/spv/block.rs index c2829231a1..5a9ddddd2e 100644 --- a/naga/src/back/spv/block.rs +++ b/naga/src/back/spv/block.rs @@ -1828,26 +1828,10 @@ impl<'w> BlockContext<'w> { is_non_uniform_binding_array |= self.is_nonuniform_binding_array_access(base, index); - let index_id = match self.write_bounds_check(base, index, block)? { - BoundsCheckResult::KnownInBounds(known_index) => { - // Even if the index is known, `OpAccessChain` - // requires expression operands, not literals. - let scalar = crate::Literal::U32(known_index); - self.writer.get_constant_scalar(scalar) - } - BoundsCheckResult::Computed(computed_index_id) => computed_index_id, - BoundsCheckResult::Conditional(comparison_id) => { - self.extend_bounds_check_condition_chain( - &mut accumulated_checks, - comparison_id, - block, - ); - - // Use the index from the `Access` expression unchanged. - self.cached[index] - } - }; + let index_id = + self.write_access_chain_index(base, index, &mut accumulated_checks, block)?; self.temp_list.push(index_id); + base } crate::Expression::AccessIndex { base, index } => { @@ -1927,6 +1911,39 @@ impl<'w> BlockContext<'w> { self.fun_info[index].uniformity.non_uniform_result.is_some() } + /// Compute a single index operand to an `OpAccessChain` instruction. + /// + /// Given that we are indexing `base` with `index`, apply the appropriate + /// bounds check policies, emitting code to `block` to clamp `index` or + /// determine whether it's in bounds. Return the SPIR-V instruction id of + /// the index value we should actually use. + /// + /// Extend `accumulated_checks` to include the results of any needed bounds + /// checks. See [`BlockContext::extend_bounds_check_condition_chain`]. + fn write_access_chain_index( + &mut self, + base: Handle, + index: Handle, + accumulated_checks: &mut Option, + block: &mut Block, + ) -> Result { + match self.write_bounds_check(base, index, block)? { + BoundsCheckResult::KnownInBounds(known_index) => { + // Even if the index is known, `OpAccessChain` + // requires expression operands, not literals. + let scalar = crate::Literal::U32(known_index); + Ok(self.writer.get_constant_scalar(scalar)) + } + BoundsCheckResult::Computed(computed_index_id) => Ok(computed_index_id), + BoundsCheckResult::Conditional(comparison_id) => { + self.extend_bounds_check_condition_chain(accumulated_checks, comparison_id, block); + + // Use the index from the `Access` expression unchanged. + Ok(self.cached[index]) + } + } + } + /// Add a condition to a chain of bounds checks. /// /// As we build an `OpAccessChain` instruction govered by From 5a6b7493359dd0aabe2b103025de6631cf41ae35 Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Tue, 1 Oct 2024 10:59:30 -0700 Subject: [PATCH 08/67] [naga spv-out] Let `BoundsCheckResult` supply the index value. Let `BoundsCheckResult::Conditional` provide both the condition to check before carrying out the access, and the index to use for that access. The `Conditional` variant indicates that we generated a runtime bounds check, which implies we must have had a SPIR-V id for the index to pass to that check, so there's no reason not to provide that to the callers - especially if the bounds check code was able to reduce it to a known constant. At the moment, this is not much of a refactor, but later commits will use `GuardedIndex` in more places, at which point this will avoid a re-matching and assertion. --- naga/src/back/spv/block.rs | 9 ++++++--- naga/src/back/spv/index.rs | 21 ++++++++++++++++----- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/naga/src/back/spv/block.rs b/naga/src/back/spv/block.rs index 5a9ddddd2e..708ef3e02d 100644 --- a/naga/src/back/spv/block.rs +++ b/naga/src/back/spv/block.rs @@ -1935,11 +1935,14 @@ impl<'w> BlockContext<'w> { Ok(self.writer.get_constant_scalar(scalar)) } BoundsCheckResult::Computed(computed_index_id) => Ok(computed_index_id), - BoundsCheckResult::Conditional(comparison_id) => { - self.extend_bounds_check_condition_chain(accumulated_checks, comparison_id, block); + BoundsCheckResult::Conditional { + condition_id: condition, + index_id: index, + } => { + self.extend_bounds_check_condition_chain(accumulated_checks, condition, block); // Use the index from the `Access` expression unchanged. - Ok(self.cached[index]) + Ok(index) } } } diff --git a/naga/src/back/spv/index.rs b/naga/src/back/spv/index.rs index c02cfe469c..27b1a91391 100644 --- a/naga/src/back/spv/index.rs +++ b/naga/src/back/spv/index.rs @@ -40,7 +40,13 @@ pub(super) enum BoundsCheckResult { /// /// This is returned when [`BoundsCheckPolicy::ReadZeroSkipWrite`] /// is in force. - Conditional(Word), + Conditional { + /// The access should only be permitted if this value is true. + condition_id: Word, + + /// The access should use this index value. + index_id: Word, + }, } /// A value that we either know at translation time, or need to compute at runtime. @@ -431,7 +437,10 @@ impl<'w> BlockContext<'w> { )); // Indicate that we did generate the check. - Ok(BoundsCheckResult::Conditional(condition_id)) + Ok(BoundsCheckResult::Conditional { + condition_id, + index_id, + }) } /// Emit a conditional load for `BoundsCheckPolicy::ReadZeroSkipWrite`. @@ -537,7 +546,6 @@ impl<'w> BlockContext<'w> { let result_type_id = self.get_expression_type_id(&self.fun_info[expr_handle].ty); let base_id = self.cached[base]; - let index_id = self.cached[index]; let result_id = match self.write_bounds_check(base, index, block)? { BoundsCheckResult::KnownInBounds(known_index) => { @@ -560,12 +568,15 @@ impl<'w> BlockContext<'w> { )); result_id } - BoundsCheckResult::Conditional(comparison_id) => { + BoundsCheckResult::Conditional { + condition_id, + index_id, + } => { // Run-time bounds checks were required. Emit // conditional load. self.write_conditional_indexed_load( result_type_id, - comparison_id, + condition_id, block, |id_gen, block| { // The in-bounds path. Generate the access. From 72831853053089209fb707132cd0390c0eda83f7 Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Tue, 1 Oct 2024 12:02:24 -0700 Subject: [PATCH 09/67] [naga] Extend snapshot tests for bounds checks. Extend the snapshot tests for bounds checking to cover the case where a runtime-sized array is indexed by a constant. --- naga/tests/in/bounds-check-restrict.wgsl | 8 ++++++++ naga/tests/in/bounds-check-zero-atomic.wgsl | 8 ++++++++ naga/tests/in/bounds-check-zero.wgsl | 8 ++++++++ naga/tests/out/msl/bounds-check-restrict.msl | 17 ++++++++++++++++ .../out/msl/bounds-check-zero-atomic.msl | 16 +++++++++++++++ naga/tests/out/msl/bounds-check-zero.msl | 19 ++++++++++++++++++ .../out/spv/bounds-check-restrict.spvasm | 20 ++++++++++++++++++- naga/tests/out/spv/bounds-check-zero.spvasm | 20 ++++++++++++++++++- 8 files changed, 114 insertions(+), 2 deletions(-) diff --git a/naga/tests/in/bounds-check-restrict.wgsl b/naga/tests/in/bounds-check-restrict.wgsl index 2b7208355c..6690d2feab 100644 --- a/naga/tests/in/bounds-check-restrict.wgsl +++ b/naga/tests/in/bounds-check-restrict.wgsl @@ -70,3 +70,11 @@ fn set_in_bounds(v: f32) { globals.v[3] = v; globals.m[2][3] = v; } + +fn index_dynamic_array_constant_index() -> f32 { + return globals.d[1000]; +} + +fn set_dynamic_array_constant_index(v: f32) { + globals.d[1000] = v; +} diff --git a/naga/tests/in/bounds-check-zero-atomic.wgsl b/naga/tests/in/bounds-check-zero-atomic.wgsl index 004f08a0a5..ed927f518b 100644 --- a/naga/tests/in/bounds-check-zero-atomic.wgsl +++ b/naga/tests/in/bounds-check-zero-atomic.wgsl @@ -36,3 +36,11 @@ fn exchange_atomic_dynamic_sized_array(i: i32) -> u32 { return atomicExchange(&globals.c[i], 1u); } +fn fetch_add_atomic_dynamic_sized_array_static_index() -> u32 { + return atomicAdd(&globals.c[1000], 1u); +} + +fn exchange_atomic_dynamic_sized_array_static_index() -> u32 { + return atomicExchange(&globals.c[1000], 1u); +} + diff --git a/naga/tests/in/bounds-check-zero.wgsl b/naga/tests/in/bounds-check-zero.wgsl index 010f46ec3b..514efc4893 100644 --- a/naga/tests/in/bounds-check-zero.wgsl +++ b/naga/tests/in/bounds-check-zero.wgsl @@ -70,3 +70,11 @@ fn set_in_bounds(v: f32) { globals.v[3] = v; globals.m[2][3] = v; } + +fn index_dynamic_array_constant_index() -> f32 { + return globals.d[1000]; +} + +fn set_dynamic_array_constant_index(v: f32) { + globals.d[1000] = v; +} diff --git a/naga/tests/out/msl/bounds-check-restrict.msl b/naga/tests/out/msl/bounds-check-restrict.msl index 0d41436534..a8bf371555 100644 --- a/naga/tests/out/msl/bounds-check-restrict.msl +++ b/naga/tests/out/msl/bounds-check-restrict.msl @@ -163,3 +163,20 @@ void set_in_bounds( globals.m[2].w = v_7; return; } + +float index_dynamic_array_constant_index( + device Globals const& globals, + constant _mslBufferSizes& _buffer_sizes +) { + float _e3 = globals.d[metal::min(unsigned(1000), (_buffer_sizes.size0 - 112 - 4) / 4)]; + return _e3; +} + +void set_dynamic_array_constant_index( + float v_8, + device Globals& globals, + constant _mslBufferSizes& _buffer_sizes +) { + globals.d[metal::min(unsigned(1000), (_buffer_sizes.size0 - 112 - 4) / 4)] = v_8; + return; +} diff --git a/naga/tests/out/msl/bounds-check-zero-atomic.msl b/naga/tests/out/msl/bounds-check-zero-atomic.msl index 4a2f0b07dc..232ae34c61 100644 --- a/naga/tests/out/msl/bounds-check-zero-atomic.msl +++ b/naga/tests/out/msl/bounds-check-zero-atomic.msl @@ -75,3 +75,19 @@ uint exchange_atomic_dynamic_sized_array( uint _e5 = uint(i_3) < 1 + (_buffer_sizes.size0 - 44 - 4) / 4 ? metal::atomic_exchange_explicit(&globals.c[i_3], 1u, metal::memory_order_relaxed) : DefaultConstructible(); return _e5; } + +uint fetch_add_atomic_dynamic_sized_array_static_index( + device Globals& globals, + constant _mslBufferSizes& _buffer_sizes +) { + uint _e4 = uint(1000) < 1 + (_buffer_sizes.size0 - 44 - 4) / 4 ? metal::atomic_fetch_add_explicit(&globals.c[1000], 1u, metal::memory_order_relaxed) : DefaultConstructible(); + return _e4; +} + +uint exchange_atomic_dynamic_sized_array_static_index( + device Globals& globals, + constant _mslBufferSizes& _buffer_sizes +) { + uint _e4 = uint(1000) < 1 + (_buffer_sizes.size0 - 44 - 4) / 4 ? metal::atomic_exchange_explicit(&globals.c[1000], 1u, metal::memory_order_relaxed) : DefaultConstructible(); + return _e4; +} diff --git a/naga/tests/out/msl/bounds-check-zero.msl b/naga/tests/out/msl/bounds-check-zero.msl index 7bbdd50d1b..8269d4bf70 100644 --- a/naga/tests/out/msl/bounds-check-zero.msl +++ b/naga/tests/out/msl/bounds-check-zero.msl @@ -183,3 +183,22 @@ void set_in_bounds( globals.m[2].w = v_7; return; } + +float index_dynamic_array_constant_index( + device Globals const& globals, + constant _mslBufferSizes& _buffer_sizes +) { + float _e3 = uint(1000) < 1 + (_buffer_sizes.size0 - 112 - 4) / 4 ? globals.d[1000] : DefaultConstructible(); + return _e3; +} + +void set_dynamic_array_constant_index( + float v_8, + device Globals& globals, + constant _mslBufferSizes& _buffer_sizes +) { + if (uint(1000) < 1 + (_buffer_sizes.size0 - 112 - 4) / 4) { + globals.d[1000] = v_8; + } + return; +} diff --git a/naga/tests/out/spv/bounds-check-restrict.spvasm b/naga/tests/out/spv/bounds-check-restrict.spvasm index c7cf675a17..3987ab5217 100644 --- a/naga/tests/out/spv/bounds-check-restrict.spvasm +++ b/naga/tests/out/spv/bounds-check-restrict.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 163 +; Bound: 174 OpCapability Shader OpCapability Linkage OpExtension "SPV_KHR_storage_buffer_storage_class" @@ -52,6 +52,7 @@ OpDecorate %12 Binding 0 %129 = OpTypeFunction %2 %11 %7 %138 = OpTypeFunction %2 %11 %11 %3 %158 = OpTypeFunction %2 %3 +%166 = OpConstant %6 1000 %16 = OpFunction %3 None %17 %15 = OpFunctionParameter %11 %14 = OpLabel @@ -232,4 +233,21 @@ OpStore %161 %156 %162 = OpAccessChain %43 %12 %62 %62 %35 OpStore %162 %156 OpReturn +OpFunctionEnd +%164 = OpFunction %3 None %91 +%163 = OpLabel +OpBranch %165 +%165 = OpLabel +%167 = OpAccessChain %20 %12 %35 %166 +%168 = OpLoad %3 %167 +OpReturnValue %168 +OpFunctionEnd +%171 = OpFunction %2 None %158 +%170 = OpFunctionParameter %3 +%169 = OpLabel +OpBranch %172 +%172 = OpLabel +%173 = OpAccessChain %20 %12 %35 %166 +OpStore %173 %170 +OpReturn OpFunctionEnd \ No newline at end of file diff --git a/naga/tests/out/spv/bounds-check-zero.spvasm b/naga/tests/out/spv/bounds-check-zero.spvasm index 2bb81261e1..fb34f5d814 100644 --- a/naga/tests/out/spv/bounds-check-zero.spvasm +++ b/naga/tests/out/spv/bounds-check-zero.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 200 +; Bound: 211 OpCapability Shader OpCapability Linkage OpExtension "SPV_KHR_storage_buffer_storage_class" @@ -56,6 +56,7 @@ OpDecorate %12 Binding 0 %159 = OpTypeFunction %2 %11 %7 %170 = OpTypeFunction %2 %11 %11 %3 %195 = OpTypeFunction %2 %3 +%203 = OpConstant %6 1000 %16 = OpFunction %3 None %17 %15 = OpFunctionParameter %11 %14 = OpLabel @@ -308,4 +309,21 @@ OpStore %198 %193 %199 = OpAccessChain %48 %12 %76 %76 %37 OpStore %199 %193 OpReturn +OpFunctionEnd +%201 = OpFunction %3 None %115 +%200 = OpLabel +OpBranch %202 +%202 = OpLabel +%204 = OpAccessChain %20 %12 %37 %203 +%205 = OpLoad %3 %204 +OpReturnValue %205 +OpFunctionEnd +%208 = OpFunction %2 None %195 +%207 = OpFunctionParameter %3 +%206 = OpLabel +OpBranch %209 +%209 = OpLabel +%210 = OpAccessChain %20 %12 %37 %203 +OpStore %210 %207 +OpReturn OpFunctionEnd \ No newline at end of file From 3693da27f956681200ed0d64334b05df827546a1 Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Tue, 1 Oct 2024 11:44:44 -0700 Subject: [PATCH 10/67] [naga spv-out] Bounds-check runtime-sized array access correctly. Do not neglect to apply bounds checks to indexing operations on runtime-sized arrays, even when they are accessed via an `AccessIndex` instruction. Before this commit, `BlockContext::write_expression_pointer` would not apply bounds checks to `OpAccessChain` indices provided by an `AccessIndex` instruction, apparently with the rationale that any out-of-bounds accesses should have been reported by constant evaluation. While it is true that the `index` operand of an `AccessIndex` expression is known at compile time, and that the WGSL constant evaluation rules require accesses that can be statically determined to be out-of-bounds to be shader creation or pipeline creation time errors, accesses to runtime-sized arrays don't follow this pattern: even if the index is known, the length with which it must be compared is not. Fixes #4441. --- naga/src/back/spv/block.rs | 29 ++++++++++++-- naga/src/back/spv/index.rs | 4 +- .../out/spv/bounds-check-restrict.spvasm | 30 ++++++++------ naga/tests/out/spv/bounds-check-zero.spvasm | 39 +++++++++++++------ 4 files changed, 73 insertions(+), 29 deletions(-) diff --git a/naga/src/back/spv/block.rs b/naga/src/back/spv/block.rs index 708ef3e02d..496ae4fad8 100644 --- a/naga/src/back/spv/block.rs +++ b/naga/src/back/spv/block.rs @@ -1828,6 +1828,7 @@ impl<'w> BlockContext<'w> { is_non_uniform_binding_array |= self.is_nonuniform_binding_array_access(base, index); + let index = crate::proc::index::GuardedIndex::Expression(index); let index_id = self.write_access_chain_index(base, index, &mut accumulated_checks, block)?; self.temp_list.push(index_id); @@ -1835,8 +1836,30 @@ impl<'w> BlockContext<'w> { base } crate::Expression::AccessIndex { base, index } => { - let const_id = self.get_index_constant(index); - self.temp_list.push(const_id); + // Decide whether we're indexing a struct (bounds checks + // forbidden) or anything else (bounds checks required). + let mut base_ty = self.fun_info[base].ty.inner_with(&self.ir_module.types); + if let crate::TypeInner::Pointer { base, .. } = *base_ty { + base_ty = &self.ir_module.types[base].inner; + } + let index_id = if let crate::TypeInner::Struct { .. } = *base_ty { + self.get_index_constant(index) + } else { + // `index` is constant, so this can't possibly require + // setting `is_nonuniform_binding_array_access`. + + // Even though the index value is statically known, `base` + // may be a runtime-sized array, so we still need to go + // through the bounds check process. + self.write_access_chain_index( + base, + crate::proc::index::GuardedIndex::Known(index), + &mut accumulated_checks, + block, + )? + }; + + self.temp_list.push(index_id); base } crate::Expression::GlobalVariable(handle) => { @@ -1923,7 +1946,7 @@ impl<'w> BlockContext<'w> { fn write_access_chain_index( &mut self, base: Handle, - index: Handle, + index: crate::proc::index::GuardedIndex, accumulated_checks: &mut Option, block: &mut Block, ) -> Result { diff --git a/naga/src/back/spv/index.rs b/naga/src/back/spv/index.rs index 27b1a91391..3ad2e42a8d 100644 --- a/naga/src/back/spv/index.rs +++ b/naga/src/back/spv/index.rs @@ -508,11 +508,10 @@ impl<'w> BlockContext<'w> { pub(super) fn write_bounds_check( &mut self, base: Handle, - index: Handle, + mut index: GuardedIndex, block: &mut Block, ) -> Result { // If the value of `index` is known at compile time, find it now. - let mut index = GuardedIndex::Expression(index); index.try_resolve_to_constant(self.ir_function, self.ir_module); let policy = self.writer.bounds_check_policies.choose_policy( @@ -546,6 +545,7 @@ impl<'w> BlockContext<'w> { let result_type_id = self.get_expression_type_id(&self.fun_info[expr_handle].ty); let base_id = self.cached[base]; + let index = GuardedIndex::Expression(index); let result_id = match self.write_bounds_check(base, index, block)? { BoundsCheckResult::KnownInBounds(known_index) => { diff --git a/naga/tests/out/spv/bounds-check-restrict.spvasm b/naga/tests/out/spv/bounds-check-restrict.spvasm index 3987ab5217..c4ba6dfee8 100644 --- a/naga/tests/out/spv/bounds-check-restrict.spvasm +++ b/naga/tests/out/spv/bounds-check-restrict.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 174 +; Bound: 180 OpCapability Shader OpCapability Linkage OpExtension "SPV_KHR_storage_buffer_storage_class" @@ -52,7 +52,7 @@ OpDecorate %12 Binding 0 %129 = OpTypeFunction %2 %11 %7 %138 = OpTypeFunction %2 %11 %11 %3 %158 = OpTypeFunction %2 %3 -%166 = OpConstant %6 1000 +%168 = OpConstant %6 1000 %16 = OpFunction %3 None %17 %15 = OpFunctionParameter %11 %14 = OpLabel @@ -238,16 +238,22 @@ OpFunctionEnd %163 = OpLabel OpBranch %165 %165 = OpLabel -%167 = OpAccessChain %20 %12 %35 %166 -%168 = OpLoad %3 %167 -OpReturnValue %168 -OpFunctionEnd -%171 = OpFunction %2 None %158 -%170 = OpFunctionParameter %3 -%169 = OpLabel -OpBranch %172 +%166 = OpArrayLength %6 %12 3 +%167 = OpISub %6 %166 %32 +%169 = OpExtInst %6 %1 UMin %168 %167 +%170 = OpAccessChain %20 %12 %35 %169 +%171 = OpLoad %3 %170 +OpReturnValue %171 +OpFunctionEnd +%174 = OpFunction %2 None %158 +%173 = OpFunctionParameter %3 %172 = OpLabel -%173 = OpAccessChain %20 %12 %35 %166 -OpStore %173 %170 +OpBranch %175 +%175 = OpLabel +%176 = OpArrayLength %6 %12 3 +%177 = OpISub %6 %176 %32 +%178 = OpExtInst %6 %1 UMin %168 %177 +%179 = OpAccessChain %20 %12 %35 %178 +OpStore %179 %173 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/naga/tests/out/spv/bounds-check-zero.spvasm b/naga/tests/out/spv/bounds-check-zero.spvasm index fb34f5d814..f1f1bedf3f 100644 --- a/naga/tests/out/spv/bounds-check-zero.spvasm +++ b/naga/tests/out/spv/bounds-check-zero.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 211 +; Bound: 220 OpCapability Shader OpCapability Linkage OpExtension "SPV_KHR_storage_buffer_storage_class" @@ -56,7 +56,7 @@ OpDecorate %12 Binding 0 %159 = OpTypeFunction %2 %11 %7 %170 = OpTypeFunction %2 %11 %11 %3 %195 = OpTypeFunction %2 %3 -%203 = OpConstant %6 1000 +%204 = OpConstant %6 1000 %16 = OpFunction %3 None %17 %15 = OpFunctionParameter %11 %14 = OpLabel @@ -314,16 +314,31 @@ OpFunctionEnd %200 = OpLabel OpBranch %202 %202 = OpLabel -%204 = OpAccessChain %20 %12 %37 %203 -%205 = OpLoad %3 %204 -OpReturnValue %205 +%203 = OpArrayLength %6 %12 3 +%205 = OpULessThan %22 %204 %203 +OpSelectionMerge %207 None +OpBranchConditional %205 %208 %207 +%208 = OpLabel +%206 = OpAccessChain %20 %12 %37 %204 +%209 = OpLoad %3 %206 +OpBranch %207 +%207 = OpLabel +%210 = OpPhi %3 %25 %202 %209 %208 +OpReturnValue %210 OpFunctionEnd -%208 = OpFunction %2 None %195 -%207 = OpFunctionParameter %3 -%206 = OpLabel -OpBranch %209 -%209 = OpLabel -%210 = OpAccessChain %20 %12 %37 %203 -OpStore %210 %207 +%213 = OpFunction %2 None %195 +%212 = OpFunctionParameter %3 +%211 = OpLabel +OpBranch %214 +%214 = OpLabel +%215 = OpArrayLength %6 %12 3 +%216 = OpULessThan %22 %204 %215 +OpSelectionMerge %218 None +OpBranchConditional %216 %219 %218 +%219 = OpLabel +%217 = OpAccessChain %20 %12 %37 %204 +OpStore %217 %212 +OpBranch %218 +%218 = OpLabel OpReturn OpFunctionEnd \ No newline at end of file From d9178a1876cef83a4f58c6d786bbd13db7432bc7 Mon Sep 17 00:00:00 2001 From: Teodor Tanasoaia <28601907+teoxoy@users.noreply.github.com> Date: Wed, 9 Oct 2024 16:21:43 +0200 Subject: [PATCH 11/67] add more changelog items --- CHANGELOG.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a9756151a4..c926d003a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -123,6 +123,9 @@ By @bradwerth [#6216](https://github.com/gfx-rs/wgpu/pull/6216). - Document `wgpu_hal` bounds-checking promises, and adapt `wgpu_core`'s lazy initialization logic to the slightly weaker-than-expected guarantees. By @jimblandy in [#6201](https://github.com/gfx-rs/wgpu/pull/6201) - Raise validation error instead of panicking in `{Render,Compute}Pipeline::get_bind_group_layout` on native / WebGL. By @bgr360 in [#6280](https://github.com/gfx-rs/wgpu/pull/6280). - **BREAKING**: Remove the last exposed C symbols in project, located in `wgpu_core::render::bundle::bundle_ffi`, to allow multiple versions of WGPU to compile together. By @ErichDonGubler in [#6272](https://github.com/gfx-rs/wgpu/pull/6272). +- Call `flush_mapped_ranges` when unmapping write-mapped buffers. By @teoxoy in [#6089](https://github.com/gfx-rs/wgpu/pull/6089). +- When mapping buffers for reading, mark buffers as initialized only when they have `MAP_WRITE` usage. By @teoxoy in [#6178](https://github.com/gfx-rs/wgpu/pull/6178). +- Add a separate pipeline constants error. By @teoxoy in [#6094](https://github.com/gfx-rs/wgpu/pull/6094). #### GLES / OpenGL @@ -143,6 +146,16 @@ By @bradwerth [#6216](https://github.com/gfx-rs/wgpu/pull/6216). - `wgpu_hal::gles::Adapter::new_external` now requires the context to be current when dropping the adapter and related objects. By @Imberflur in [#6114](https://github.com/gfx-rs/wgpu/pull/6114). - Reduce the amount of debug and trace logs emitted by wgpu-core and wgpu-hal. By @nical in [#6065](https://github.com/gfx-rs/wgpu/issues/6065) - `Rg11b10Float` is renamed to `Rg11b10Ufloat`. By @sagudev in [#6108](https://github.com/gfx-rs/wgpu/pull/6108) +- Invalidate the device when we encounter driver-induced device loss or on unexpected errors. By @teoxoy in [#6229](https://github.com/gfx-rs/wgpu/pull/6229). +- Make Vulkan error handling more robust. By @teoxoy in [#6119](https://github.com/gfx-rs/wgpu/pull/6119). + +#### Internal + +- Tracker simplifications. By @teoxoy in [#6073](https://github.com/gfx-rs/wgpu/pull/6073) & [#6088](https://github.com/gfx-rs/wgpu/pull/6088). +- D3D12 cleanup. By @teoxoy in [#6200](https://github.com/gfx-rs/wgpu/pull/6200). +- Use `ManuallyDrop` in remaining places. By @teoxoy in [#6092](https://github.com/gfx-rs/wgpu/pull/6092). +- Move out invalidity from the `Registry`. By @teoxoy in [#6243](https://github.com/gfx-rs/wgpu/pull/6243). +- Remove `backend` from ID. By @teoxoy in [#6263](https://github.com/gfx-rs/wgpu/pull/6263). #### HAL From bf33e481f32f1a656846f9d56e44ae4d3f0414df Mon Sep 17 00:00:00 2001 From: Asher Jingkong Chen <37398747+AsherJingkongChen@users.noreply.github.com> Date: Thu, 10 Oct 2024 18:45:24 +0800 Subject: [PATCH 12/67] [naga msl-out] Implement atomicCompareExchangeWeak for MSL backend (#6265) --- CHANGELOG.md | 4 + naga/src/back/msl/writer.rs | 130 ++++++++------ naga/tests/out/msl/atomicCompareExchange.msl | 161 ++++++++++++++++++ .../overrides-atomicCompareExchangeWeak.msl | 48 ++++++ naga/tests/snapshots.rs | 7 +- 5 files changed, 298 insertions(+), 52 deletions(-) create mode 100644 naga/tests/out/msl/atomicCompareExchange.msl create mode 100644 naga/tests/out/msl/overrides-atomicCompareExchangeWeak.msl diff --git a/CHANGELOG.md b/CHANGELOG.md index c926d003a9..80b811e89d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -93,6 +93,10 @@ By @bradwerth [#6216](https://github.com/gfx-rs/wgpu/pull/6216). - Allow using [VK_GOOGLE_display_timing](https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_GOOGLE_display_timing.html) unsafely with the `VULKAN_GOOGLE_DISPLAY_TIMING` feature. By @DJMcNab in [#6149](https://github.com/gfx-rs/wgpu/pull/6149) +#### Metal + +- Implement `atomicCompareExchangeWeak`. By @AsherJingkongChen in [#6265](https://github.com/gfx-rs/wgpu/pull/6265) + ### Bug Fixes - Fix incorrect hlsl image output type conversion. By @atlv24 in [#6123](https://github.com/gfx-rs/wgpu/pull/6123) diff --git a/naga/src/back/msl/writer.rs b/naga/src/back/msl/writer.rs index 7ab97f491c..7fb30b4f7b 100644 --- a/naga/src/back/msl/writer.rs +++ b/naga/src/back/msl/writer.rs @@ -33,6 +33,7 @@ const RAY_QUERY_FIELD_INTERSECTION: &str = "intersection"; const RAY_QUERY_FIELD_READY: &str = "ready"; const RAY_QUERY_FUN_MAP_INTERSECTION: &str = "_map_intersection_type"; +pub(crate) const ATOMIC_COMP_EXCH_FUNCTION: &str = "naga_atomic_compare_exchange_weak_explicit"; pub(crate) const MODF_FUNCTION: &str = "naga_modf"; pub(crate) const FREXP_FUNCTION: &str = "naga_frexp"; @@ -1279,42 +1280,6 @@ impl Writer { Ok(()) } - fn put_atomic_operation( - &mut self, - pointer: Handle, - key: &str, - value: Handle, - context: &ExpressionContext, - ) -> BackendResult { - // If the pointer we're passing to the atomic operation needs to be conditional - // for `ReadZeroSkipWrite`, the condition needs to *surround* the atomic op, and - // the pointer operand should be unchecked. - let policy = context.choose_bounds_check_policy(pointer); - let checked = policy == index::BoundsCheckPolicy::ReadZeroSkipWrite - && self.put_bounds_checks(pointer, context, back::Level(0), "")?; - - // If requested and successfully put bounds checks, continue the ternary expression. - if checked { - write!(self.out, " ? ")?; - } - - write!( - self.out, - "{NAMESPACE}::atomic_{key}_explicit({ATOMIC_REFERENCE}" - )?; - self.put_access_chain(pointer, policy, context)?; - write!(self.out, ", ")?; - self.put_expression(value, context, true)?; - write!(self.out, ", {NAMESPACE}::memory_order_relaxed)")?; - - // Finish the ternary expression. - if checked { - write!(self.out, " : DefaultConstructible()")?; - } - - Ok(()) - } - /// Emit code for the arithmetic expression of the dot product. /// fn put_dot_product( @@ -3182,24 +3147,65 @@ impl Writer { value, result, } => { + let context = &context.expression; + // This backend supports `SHADER_INT64_ATOMIC_MIN_MAX` but not // `SHADER_INT64_ATOMIC_ALL_OPS`, so we can assume that if `result` is // `Some`, we are not operating on a 64-bit value, and that if we are // operating on a 64-bit value, `result` is `None`. write!(self.out, "{level}")?; - let fun_str = if let Some(result) = result { + let fun_key = if let Some(result) = result { let res_name = Baked(result).to_string(); - self.start_baking_expression(result, &context.expression, &res_name)?; + self.start_baking_expression(result, context, &res_name)?; self.named_expressions.insert(result, res_name); - fun.to_msl()? - } else if context.expression.resolve_type(value).scalar_width() == Some(8) { + fun.to_msl() + } else if context.resolve_type(value).scalar_width() == Some(8) { fun.to_msl_64_bit()? } else { - fun.to_msl()? + fun.to_msl() }; - self.put_atomic_operation(pointer, fun_str, value, &context.expression)?; - // done + // If the pointer we're passing to the atomic operation needs to be conditional + // for `ReadZeroSkipWrite`, the condition needs to *surround* the atomic op, and + // the pointer operand should be unchecked. + let policy = context.choose_bounds_check_policy(pointer); + let checked = policy == index::BoundsCheckPolicy::ReadZeroSkipWrite + && self.put_bounds_checks(pointer, context, back::Level(0), "")?; + + // If requested and successfully put bounds checks, continue the ternary expression. + if checked { + write!(self.out, " ? ")?; + } + + // Put the atomic function invocation. + match *fun { + crate::AtomicFunction::Exchange { compare: Some(cmp) } => { + write!(self.out, "{ATOMIC_COMP_EXCH_FUNCTION}({ATOMIC_REFERENCE}")?; + self.put_access_chain(pointer, policy, context)?; + write!(self.out, ", ")?; + self.put_expression(cmp, context, true)?; + write!(self.out, ", ")?; + self.put_expression(value, context, true)?; + write!(self.out, ")")?; + } + _ => { + write!( + self.out, + "{NAMESPACE}::atomic_{fun_key}_explicit({ATOMIC_REFERENCE}" + )?; + self.put_access_chain(pointer, policy, context)?; + write!(self.out, ", ")?; + self.put_expression(value, context, true)?; + write!(self.out, ", {NAMESPACE}::memory_order_relaxed)")?; + } + } + + // Finish the ternary expression. + if checked { + write!(self.out, " : DefaultConstructible()")?; + } + + // Done writeln!(self.out, ";")?; } crate::Statement::WorkGroupUniformLoad { pointer, result } => { @@ -3827,7 +3833,33 @@ impl Writer { }}" )?; } - &crate::PredeclaredType::AtomicCompareExchangeWeakResult { .. } => {} + &crate::PredeclaredType::AtomicCompareExchangeWeakResult(scalar) => { + let arg_type_name = scalar.to_msl_name(); + let called_func_name = "atomic_compare_exchange_weak_explicit"; + let defined_func_name = ATOMIC_COMP_EXCH_FUNCTION; + let struct_name = &self.names[&NameKey::Type(*struct_ty)]; + + writeln!(self.out)?; + + for address_space_name in ["device", "threadgroup"] { + writeln!( + self.out, + "\ +template +{struct_name} {defined_func_name}( + {address_space_name} A *atomic_ptr, + {arg_type_name} cmp, + {arg_type_name} v +) {{ + bool swapped = {NAMESPACE}::{called_func_name}( + atomic_ptr, &cmp, v, + metal::memory_order_relaxed, metal::memory_order_relaxed + ); + return {struct_name}{{cmp, swapped}}; +}}" + )?; + } + } } } @@ -6065,8 +6097,8 @@ fn test_stack_size() { } impl crate::AtomicFunction { - fn to_msl(self) -> Result<&'static str, Error> { - Ok(match self { + const fn to_msl(self) -> &'static str { + match self { Self::Add => "fetch_add", Self::Subtract => "fetch_sub", Self::And => "fetch_and", @@ -6075,10 +6107,8 @@ impl crate::AtomicFunction { Self::Min => "fetch_min", Self::Max => "fetch_max", Self::Exchange { compare: None } => "exchange", - Self::Exchange { compare: Some(_) } => Err(Error::FeatureNotImplemented( - "atomic CompareExchange".to_string(), - ))?, - }) + Self::Exchange { compare: Some(_) } => ATOMIC_COMP_EXCH_FUNCTION, + } } fn to_msl_64_bit(self) -> Result<&'static str, Error> { diff --git a/naga/tests/out/msl/atomicCompareExchange.msl b/naga/tests/out/msl/atomicCompareExchange.msl new file mode 100644 index 0000000000..800b5b2012 --- /dev/null +++ b/naga/tests/out/msl/atomicCompareExchange.msl @@ -0,0 +1,161 @@ +// language: metal1.0 +#include +#include + +using metal::uint; + +struct type_2 { + metal::atomic_int inner[128]; +}; +struct type_4 { + metal::atomic_uint inner[128]; +}; +struct _atomic_compare_exchange_resultSint4_ { + int old_value; + bool exchanged; +}; +struct _atomic_compare_exchange_resultUint4_ { + uint old_value; + bool exchanged; +}; + +template +_atomic_compare_exchange_resultSint4_ naga_atomic_compare_exchange_weak_explicit( + device A *atomic_ptr, + int cmp, + int v +) { + bool swapped = metal::atomic_compare_exchange_weak_explicit( + atomic_ptr, &cmp, v, + metal::memory_order_relaxed, metal::memory_order_relaxed + ); + return _atomic_compare_exchange_resultSint4_{cmp, swapped}; +} +template +_atomic_compare_exchange_resultSint4_ naga_atomic_compare_exchange_weak_explicit( + threadgroup A *atomic_ptr, + int cmp, + int v +) { + bool swapped = metal::atomic_compare_exchange_weak_explicit( + atomic_ptr, &cmp, v, + metal::memory_order_relaxed, metal::memory_order_relaxed + ); + return _atomic_compare_exchange_resultSint4_{cmp, swapped}; +} + +template +_atomic_compare_exchange_resultUint4_ naga_atomic_compare_exchange_weak_explicit( + device A *atomic_ptr, + uint cmp, + uint v +) { + bool swapped = metal::atomic_compare_exchange_weak_explicit( + atomic_ptr, &cmp, v, + metal::memory_order_relaxed, metal::memory_order_relaxed + ); + return _atomic_compare_exchange_resultUint4_{cmp, swapped}; +} +template +_atomic_compare_exchange_resultUint4_ naga_atomic_compare_exchange_weak_explicit( + threadgroup A *atomic_ptr, + uint cmp, + uint v +) { + bool swapped = metal::atomic_compare_exchange_weak_explicit( + atomic_ptr, &cmp, v, + metal::memory_order_relaxed, metal::memory_order_relaxed + ); + return _atomic_compare_exchange_resultUint4_{cmp, swapped}; +} +constant uint SIZE = 128u; + +kernel void test_atomic_compare_exchange_i32_( + device type_2& arr_i32_ [[user(fake0)]] +) { + uint i = 0u; + int old = {}; + bool exchanged = {}; +#define LOOP_IS_REACHABLE if (volatile bool unpredictable_jump_over_loop = true; unpredictable_jump_over_loop) + bool loop_init = true; + LOOP_IS_REACHABLE while(true) { + if (!loop_init) { + uint _e27 = i; + i = _e27 + 1u; + } + loop_init = false; + uint _e2 = i; + if (_e2 < SIZE) { + } else { + break; + } + { + uint _e6 = i; + int _e8 = metal::atomic_load_explicit(&arr_i32_.inner[_e6], metal::memory_order_relaxed); + old = _e8; + exchanged = false; + LOOP_IS_REACHABLE while(true) { + bool _e12 = exchanged; + if (!(_e12)) { + } else { + break; + } + { + int _e14 = old; + int new_ = as_type(as_type(_e14) + 1.0); + uint _e20 = i; + int _e22 = old; + _atomic_compare_exchange_resultSint4_ _e23 = naga_atomic_compare_exchange_weak_explicit(&arr_i32_.inner[_e20], _e22, new_); + old = _e23.old_value; + exchanged = _e23.exchanged; + } + } + } + } + return; +} + + +kernel void test_atomic_compare_exchange_u32_( + device type_4& arr_u32_ [[user(fake0)]] +) { + uint i_1 = 0u; + uint old_1 = {}; + bool exchanged_1 = {}; + bool loop_init_1 = true; + LOOP_IS_REACHABLE while(true) { + if (!loop_init_1) { + uint _e27 = i_1; + i_1 = _e27 + 1u; + } + loop_init_1 = false; + uint _e2 = i_1; + if (_e2 < SIZE) { + } else { + break; + } + { + uint _e6 = i_1; + uint _e8 = metal::atomic_load_explicit(&arr_u32_.inner[_e6], metal::memory_order_relaxed); + old_1 = _e8; + exchanged_1 = false; + LOOP_IS_REACHABLE while(true) { + bool _e12 = exchanged_1; + if (!(_e12)) { + } else { + break; + } + { + uint _e14 = old_1; + uint new_1 = as_type(as_type(_e14) + 1.0); + uint _e20 = i_1; + uint _e22 = old_1; + _atomic_compare_exchange_resultUint4_ _e23 = naga_atomic_compare_exchange_weak_explicit(&arr_u32_.inner[_e20], _e22, new_1); + old_1 = _e23.old_value; + exchanged_1 = _e23.exchanged; + } + } + } + } + return; +} diff --git a/naga/tests/out/msl/overrides-atomicCompareExchangeWeak.msl b/naga/tests/out/msl/overrides-atomicCompareExchangeWeak.msl new file mode 100644 index 0000000000..d87190c595 --- /dev/null +++ b/naga/tests/out/msl/overrides-atomicCompareExchangeWeak.msl @@ -0,0 +1,48 @@ +// language: metal1.0 +#include +#include + +using metal::uint; + +struct _atomic_compare_exchange_resultUint4_ { + uint old_value; + bool exchanged; +}; + +template +_atomic_compare_exchange_resultUint4_ naga_atomic_compare_exchange_weak_explicit( + device A *atomic_ptr, + uint cmp, + uint v +) { + bool swapped = metal::atomic_compare_exchange_weak_explicit( + atomic_ptr, &cmp, v, + metal::memory_order_relaxed, metal::memory_order_relaxed + ); + return _atomic_compare_exchange_resultUint4_{cmp, swapped}; +} +template +_atomic_compare_exchange_resultUint4_ naga_atomic_compare_exchange_weak_explicit( + threadgroup A *atomic_ptr, + uint cmp, + uint v +) { + bool swapped = metal::atomic_compare_exchange_weak_explicit( + atomic_ptr, &cmp, v, + metal::memory_order_relaxed, metal::memory_order_relaxed + ); + return _atomic_compare_exchange_resultUint4_{cmp, swapped}; +} +constant int o = 2; + +kernel void f( + metal::uint3 __local_invocation_id [[thread_position_in_threadgroup]] +, threadgroup metal::atomic_uint& a +) { + if (metal::all(__local_invocation_id == metal::uint3(0u))) { + metal::atomic_store_explicit(&a, 0, metal::memory_order_relaxed); + } + metal::threadgroup_barrier(metal::mem_flags::mem_threadgroup); + _atomic_compare_exchange_resultUint4_ _e5 = naga_atomic_compare_exchange_weak_explicit(&a, 2u, 1u); + return; +} diff --git a/naga/tests/snapshots.rs b/naga/tests/snapshots.rs index adf67f8333..78b2331dca 100644 --- a/naga/tests/snapshots.rs +++ b/naga/tests/snapshots.rs @@ -773,7 +773,10 @@ fn convert_wgsl() { "atomicOps", Targets::SPIRV | Targets::METAL | Targets::GLSL | Targets::HLSL | Targets::WGSL, ), - ("atomicCompareExchange", Targets::SPIRV | Targets::WGSL), + ( + "atomicCompareExchange", + Targets::SPIRV | Targets::METAL | Targets::WGSL, + ), ( "padding", Targets::SPIRV | Targets::METAL | Targets::GLSL | Targets::HLSL | Targets::WGSL, @@ -917,7 +920,7 @@ fn convert_wgsl() { ), ( "overrides-atomicCompareExchangeWeak", - Targets::IR | Targets::SPIRV, + Targets::IR | Targets::SPIRV | Targets::METAL, ), ( "overrides-ray-query", From 0392cb783d431e9b2dab0210da314fc91af5e84a Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Tue, 8 Oct 2024 13:07:02 -0700 Subject: [PATCH 13/67] [naga spv-out] Rename `make_local` to `LocalType::from_inner`. Change the free function `back::spv::make_local` into an associated function `LocalType::from_inner`. --- naga/src/back/spv/block.rs | 8 +-- naga/src/back/spv/mod.rs | 102 +++++++++++++++++++----------------- naga/src/back/spv/writer.rs | 14 ++--- 3 files changed, 66 insertions(+), 58 deletions(-) diff --git a/naga/src/back/spv/block.rs b/naga/src/back/spv/block.rs index 496ae4fad8..4f203ada84 100644 --- a/naga/src/back/spv/block.rs +++ b/naga/src/back/spv/block.rs @@ -3,8 +3,8 @@ Implementations for `BlockContext` methods. */ use super::{ - helpers, index::BoundsCheckResult, make_local, selection::Selection, Block, BlockContext, - Dimension, Error, Instruction, LocalType, LookupType, ResultMember, Writer, WriterFlags, + helpers, index::BoundsCheckResult, selection::Selection, Block, BlockContext, Dimension, Error, + Instruction, LocalType, LookupType, ResultMember, Writer, WriterFlags, }; use crate::{arena::Handle, proc::TypeResolution, Statement}; use spirv::Word; @@ -1809,7 +1809,9 @@ impl<'w> BlockContext<'w> { Some(ty) => ty, None => LookupType::Handle(ty_handle), }, - TypeResolution::Value(ref inner) => LookupType::Local(make_local(inner).unwrap()), + TypeResolution::Value(ref inner) => { + LookupType::Local(LocalType::from_inner(inner).unwrap()) + } }; let result_type_id = self.get_type_id(result_lookup_ty); diff --git a/naga/src/back/spv/mod.rs b/naga/src/back/spv/mod.rs index e6397017c5..93e9a466c4 100644 --- a/naga/src/back/spv/mod.rs +++ b/naga/src/back/spv/mod.rs @@ -246,9 +246,9 @@ impl LocalImageType { /// never synthesizes new struct types, so `LocalType` has nothing for that. /// /// Each `LocalType` variant should be handled identically to its analogous -/// `TypeInner` variant. You can use the [`make_local`] function to help with -/// this, by converting everything possible to a `LocalType` before inspecting -/// it. +/// `TypeInner` variant. You can use the [`LocalType::from_inner`] function to +/// help with this, by converting everything possible to a `LocalType` before +/// inspecting it. /// /// ## `LocalType` equality and SPIR-V `OpType` uniqueness /// @@ -357,52 +357,56 @@ struct LookupFunctionType { return_type_id: Word, } -fn make_local(inner: &crate::TypeInner) -> Option { - Some(match *inner { - crate::TypeInner::Scalar(scalar) | crate::TypeInner::Atomic(scalar) => LocalType::Value { - vector_size: None, - scalar, - pointer_space: None, - }, - crate::TypeInner::Vector { size, scalar } => LocalType::Value { - vector_size: Some(size), - scalar, - pointer_space: None, - }, - crate::TypeInner::Matrix { - columns, - rows, - scalar, - } => LocalType::Matrix { - columns, - rows, - width: scalar.width, - }, - crate::TypeInner::Pointer { base, space } => LocalType::Pointer { - base, - class: helpers::map_storage_class(space), - }, - crate::TypeInner::ValuePointer { - size, - scalar, - space, - } => LocalType::Value { - vector_size: size, - scalar, - pointer_space: Some(helpers::map_storage_class(space)), - }, - crate::TypeInner::Image { - dim, - arrayed, - class, - } => LocalType::Image(LocalImageType::from_inner(dim, arrayed, class)), - crate::TypeInner::Sampler { comparison: _ } => LocalType::Sampler, - crate::TypeInner::AccelerationStructure => LocalType::AccelerationStructure, - crate::TypeInner::RayQuery => LocalType::RayQuery, - crate::TypeInner::Array { .. } - | crate::TypeInner::Struct { .. } - | crate::TypeInner::BindingArray { .. } => return None, - }) +impl LocalType { + fn from_inner(inner: &crate::TypeInner) -> Option { + Some(match *inner { + crate::TypeInner::Scalar(scalar) | crate::TypeInner::Atomic(scalar) => { + LocalType::Value { + vector_size: None, + scalar, + pointer_space: None, + } + } + crate::TypeInner::Vector { size, scalar } => LocalType::Value { + vector_size: Some(size), + scalar, + pointer_space: None, + }, + crate::TypeInner::Matrix { + columns, + rows, + scalar, + } => LocalType::Matrix { + columns, + rows, + width: scalar.width, + }, + crate::TypeInner::Pointer { base, space } => LocalType::Pointer { + base, + class: helpers::map_storage_class(space), + }, + crate::TypeInner::ValuePointer { + size, + scalar, + space, + } => LocalType::Value { + vector_size: size, + scalar, + pointer_space: Some(helpers::map_storage_class(space)), + }, + crate::TypeInner::Image { + dim, + arrayed, + class, + } => LocalType::Image(LocalImageType::from_inner(dim, arrayed, class)), + crate::TypeInner::Sampler { comparison: _ } => LocalType::Sampler, + crate::TypeInner::AccelerationStructure => LocalType::AccelerationStructure, + crate::TypeInner::RayQuery => LocalType::RayQuery, + crate::TypeInner::Array { .. } + | crate::TypeInner::Struct { .. } + | crate::TypeInner::BindingArray { .. } => return None, + }) + } } #[derive(Debug)] diff --git a/naga/src/back/spv/writer.rs b/naga/src/back/spv/writer.rs index cd02c22195..27f2cbfdb6 100644 --- a/naga/src/back/spv/writer.rs +++ b/naga/src/back/spv/writer.rs @@ -1,10 +1,10 @@ use super::{ block::DebugInfoInner, helpers::{contains_builtin, global_needs_wrapper, map_storage_class}, - make_local, Block, BlockContext, CachedConstant, CachedExpressions, DebugInfo, - EntryPointContext, Error, Function, FunctionArgument, GlobalVariable, IdGenerator, Instruction, - LocalType, LocalVariable, LogicalLayout, LookupFunctionType, LookupType, Options, - PhysicalLayout, PipelineOptions, ResultMember, Writer, WriterFlags, BITS_PER_BYTE, + Block, BlockContext, CachedConstant, CachedExpressions, DebugInfo, EntryPointContext, Error, + Function, FunctionArgument, GlobalVariable, IdGenerator, Instruction, LocalType, LocalVariable, + LogicalLayout, LookupFunctionType, LookupType, Options, PhysicalLayout, PipelineOptions, + ResultMember, Writer, WriterFlags, BITS_PER_BYTE, }; use crate::{ arena::{Handle, HandleVec, UniqueArena}, @@ -254,7 +254,9 @@ impl Writer { pub(super) fn get_expression_lookup_type(&mut self, tr: &TypeResolution) -> LookupType { match *tr { TypeResolution::Handle(ty_handle) => LookupType::Handle(ty_handle), - TypeResolution::Value(ref inner) => LookupType::Local(make_local(inner).unwrap()), + TypeResolution::Value(ref inner) => { + LookupType::Local(LocalType::from_inner(inner).unwrap()) + } } } @@ -1025,7 +1027,7 @@ impl Writer { // because some types which map to the same LocalType have different // capability requirements. See https://github.com/gfx-rs/wgpu/issues/5569 self.request_type_capabilities(&ty.inner)?; - let id = if let Some(local) = make_local(&ty.inner) { + let id = if let Some(local) = LocalType::from_inner(&ty.inner) { // This type can be represented as a `LocalType`, so check if we've // already written an instruction for it. If not, do so now, with // `write_type_declaration_local`. From 908e8353a8a3fdbf0b96913cfc3e08561c7a3ab3 Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Tue, 8 Oct 2024 14:50:24 -0700 Subject: [PATCH 14/67] [naga spv-out] Expand LocalType to permit pointers to matrices. In `back::spv`: - Factor out the numeric variants of `LocalType` into a new enum, `NumericType`. - Split the `Value` variant into `Numeric` and `LocalPointer` variants, and let `LocalPointer` point to any numeric type, including matrices. In subsequent commits, we'll need to spill matrices out into temporary local variables. This means we'll need to generate SPIR-V pointer-to-matrix types, so `LocalType` needs to be able to represent that. --- naga/src/back/spv/block.rs | 181 ++++++++++++---------------------- naga/src/back/spv/image.rs | 97 +++++++++--------- naga/src/back/spv/mod.rs | 68 +++++++------ naga/src/back/spv/ray.rs | 73 ++++++-------- naga/src/back/spv/subgroup.rs | 12 +-- naga/src/back/spv/writer.rs | 169 ++++++++++++------------------- 6 files changed, 251 insertions(+), 349 deletions(-) diff --git a/naga/src/back/spv/block.rs b/naga/src/back/spv/block.rs index 4f203ada84..d7c56d3f4c 100644 --- a/naga/src/back/spv/block.rs +++ b/naga/src/back/spv/block.rs @@ -4,7 +4,7 @@ Implementations for `BlockContext` methods. use super::{ helpers, index::BoundsCheckResult, selection::Selection, Block, BlockContext, Dimension, Error, - Instruction, LocalType, LookupType, ResultMember, Writer, WriterFlags, + Instruction, LocalType, LookupType, NumericType, ResultMember, Writer, WriterFlags, }; use crate::{arena::Handle, proc::TypeResolution, Statement}; use spirv::Word; @@ -105,10 +105,9 @@ impl Writer { position_id: Word, body: &mut Vec, ) -> Result<(), Error> { - let float_ptr_type_id = self.get_type_id(LookupType::Local(LocalType::Value { - vector_size: None, - scalar: crate::Scalar::F32, - pointer_space: Some(spirv::StorageClass::Output), + let float_ptr_type_id = self.get_type_id(LookupType::Local(LocalType::LocalPointer { + base: NumericType::Scalar(crate::Scalar::F32), + class: spirv::StorageClass::Output, })); let index_y_id = self.get_index_constant(1); let access_id = self.id_gen.next(); @@ -119,11 +118,9 @@ impl Writer { &[index_y_id], )); - let float_type_id = self.get_type_id(LookupType::Local(LocalType::Value { - vector_size: None, - scalar: crate::Scalar::F32, - pointer_space: None, - })); + let float_type_id = self.get_type_id(LookupType::Local(LocalType::Numeric( + NumericType::Scalar(crate::Scalar::F32), + ))); let load_id = self.id_gen.next(); body.push(Instruction::load(float_type_id, load_id, access_id, None)); @@ -145,11 +142,9 @@ impl Writer { frag_depth_id: Word, body: &mut Vec, ) -> Result<(), Error> { - let float_type_id = self.get_type_id(LookupType::Local(LocalType::Value { - vector_size: None, - scalar: crate::Scalar::F32, - pointer_space: None, - })); + let float_type_id = self.get_type_id(LookupType::Local(LocalType::Numeric( + NumericType::Scalar(crate::Scalar::F32), + ))); let zero_scalar_id = self.get_constant_scalar(crate::Literal::F32(0.0)); let one_scalar_id = self.get_constant_scalar(crate::Literal::F32(1.0)); @@ -830,12 +825,8 @@ impl<'w> BlockContext<'w> { let mut arg2_id = self.writer.get_constant_scalar_with(1, scalar)?; if let Some(size) = maybe_size { - let ty = LocalType::Value { - vector_size: Some(size), - scalar, - pointer_space: None, - } - .into(); + let ty = + LocalType::Numeric(NumericType::Vector { size, scalar }).into(); self.temp_list.clear(); self.temp_list.resize(size as _, arg1_id); @@ -950,12 +941,9 @@ impl<'w> BlockContext<'w> { &crate::TypeInner::Vector { size, .. }, &crate::TypeInner::Scalar(scalar), ) => { - let selector_type_id = - self.get_type_id(LookupType::Local(LocalType::Value { - vector_size: Some(size), - scalar, - pointer_space: None, - })); + let selector_type_id = self.get_type_id(LookupType::Local( + LocalType::Numeric(NumericType::Vector { size, scalar }), + )); self.temp_list.clear(); self.temp_list.resize(size as usize, arg2_id); @@ -998,12 +986,8 @@ impl<'w> BlockContext<'w> { Mf::CountTrailingZeros => { let uint_id = match *arg_ty { crate::TypeInner::Vector { size, scalar } => { - let ty = LocalType::Value { - vector_size: Some(size), - scalar, - pointer_space: None, - } - .into(); + let ty = + LocalType::Numeric(NumericType::Vector { size, scalar }).into(); self.temp_list.clear(); self.temp_list.resize( @@ -1040,12 +1024,8 @@ impl<'w> BlockContext<'w> { Mf::CountLeadingZeros => { let (int_type_id, int_id, width) = match *arg_ty { crate::TypeInner::Vector { size, scalar } => { - let ty = LocalType::Value { - vector_size: Some(size), - scalar, - pointer_space: None, - } - .into(); + let ty = + LocalType::Numeric(NumericType::Vector { size, scalar }).into(); self.temp_list.clear(); self.temp_list.resize( @@ -1061,11 +1041,9 @@ impl<'w> BlockContext<'w> { ) } crate::TypeInner::Scalar(scalar) => ( - self.get_type_id(LookupType::Local(LocalType::Value { - vector_size: None, - scalar, - pointer_space: None, - })), + self.get_type_id(LookupType::Local(LocalType::Numeric( + NumericType::Scalar(scalar), + ))), self.writer .get_constant_scalar_with(scalar.width * 8 - 1, scalar)?, scalar.width, @@ -1130,14 +1108,9 @@ impl<'w> BlockContext<'w> { .writer .get_constant_scalar(crate::Literal::U32(bit_width as u32)); - let u32_type = self.get_type_id(LookupType::Local(LocalType::Value { - vector_size: None, - scalar: crate::Scalar { - kind: crate::ScalarKind::Uint, - width: 4, - }, - pointer_space: None, - })); + let u32_type = self.get_type_id(LookupType::Local(LocalType::Numeric( + NumericType::Scalar(crate::Scalar::U32), + ))); // o = min(offset, w) let offset_id = self.gen_id(); @@ -1186,14 +1159,9 @@ impl<'w> BlockContext<'w> { .writer .get_constant_scalar(crate::Literal::U32(bit_width as u32)); - let u32_type = self.get_type_id(LookupType::Local(LocalType::Value { - vector_size: None, - scalar: crate::Scalar { - kind: crate::ScalarKind::Uint, - width: 4, - }, - pointer_space: None, - })); + let u32_type = self.get_type_id(LookupType::Local(LocalType::Numeric( + NumericType::Scalar(crate::Scalar::U32), + ))); // o = min(offset, w) let offset_id = self.gen_id(); @@ -1259,23 +1227,16 @@ impl<'w> BlockContext<'w> { Mf::Pack4xU8 => (crate::ScalarKind::Uint, false), _ => unreachable!(), }; - let uint_type_id = self.get_type_id(LookupType::Local(LocalType::Value { - vector_size: None, - scalar: crate::Scalar { - kind: crate::ScalarKind::Uint, - width: 4, - }, - pointer_space: None, - })); + let uint_type_id = self.get_type_id(LookupType::Local(LocalType::Numeric( + NumericType::Scalar(crate::Scalar::U32), + ))); - let int_type_id = self.get_type_id(LookupType::Local(LocalType::Value { - vector_size: None, - scalar: crate::Scalar { + let int_type_id = self.get_type_id(LookupType::Local(LocalType::Numeric( + NumericType::Scalar(crate::Scalar { kind: int_type, width: 4, - }, - pointer_space: None, - })); + }), + ))); let mut last_instruction = Instruction::new(spirv::Op::Nop); @@ -1352,24 +1313,17 @@ impl<'w> BlockContext<'w> { _ => unreachable!(), }; - let sint_type_id = self.get_type_id(LookupType::Local(LocalType::Value { - vector_size: None, - scalar: crate::Scalar { - kind: crate::ScalarKind::Sint, - width: 4, - }, - pointer_space: None, - })); + let sint_type_id = self.get_type_id(LookupType::Local(LocalType::Numeric( + NumericType::Scalar(crate::Scalar::I32), + ))); let eight = self.writer.get_constant_scalar(crate::Literal::U32(8)); - let int_type_id = self.get_type_id(LookupType::Local(LocalType::Value { - vector_size: None, - scalar: crate::Scalar { + let int_type_id = self.get_type_id(LookupType::Local(LocalType::Numeric( + NumericType::Scalar(crate::Scalar { kind: int_type, width: 4, - }, - pointer_space: None, - })); + }), + ))); block .body .reserve(usize::from(VEC_LENGTH) * 2 + usize::from(is_signed)); @@ -1533,11 +1487,10 @@ impl<'w> BlockContext<'w> { self.writer.get_constant_scalar_with(0, src_scalar)?; let zero_id = match src_size { Some(size) => { - let ty = LocalType::Value { - vector_size: Some(size), + let ty = LocalType::Numeric(NumericType::Vector { + size, scalar: src_scalar, - pointer_space: None, - } + }) .into(); self.temp_list.clear(); @@ -1562,11 +1515,10 @@ impl<'w> BlockContext<'w> { self.writer.get_constant_scalar_with(1, dst_scalar)?; let (accept_id, reject_id) = match src_size { Some(size) => { - let ty = LocalType::Value { - vector_size: Some(size), + let ty = LocalType::Numeric(NumericType::Vector { + size, scalar: dst_scalar, - pointer_space: None, - } + }) .into(); self.temp_list.clear(); @@ -1704,12 +1656,12 @@ impl<'w> BlockContext<'w> { self.temp_list.clear(); self.temp_list.resize(size as usize, condition_id); - let bool_vector_type_id = - self.get_type_id(LookupType::Local(LocalType::Value { - vector_size: Some(size), + let bool_vector_type_id = self.get_type_id(LookupType::Local( + LocalType::Numeric(NumericType::Vector { + size, scalar: condition_scalar, - pointer_space: None, - })); + }), + )); let id = self.gen_id(); block.body.push(Instruction::composite_construct( @@ -2031,11 +1983,11 @@ impl<'w> BlockContext<'w> { ) { self.temp_list.clear(); - let vector_type_id = self.get_type_id(LookupType::Local(LocalType::Value { - vector_size: Some(rows), - scalar: crate::Scalar::float(width), - pointer_space: None, - })); + let vector_type_id = + self.get_type_id(LookupType::Local(LocalType::Numeric(NumericType::Vector { + size: rows, + scalar: crate::Scalar::float(width), + }))); for index in 0..columns as u32 { let column_id_left = self.gen_id(); @@ -2737,20 +2689,15 @@ impl<'w> BlockContext<'w> { crate::AtomicFunction::Exchange { compare: Some(cmp) } => { let scalar_type_id = match *value_inner { crate::TypeInner::Scalar(scalar) => { - self.get_type_id(LookupType::Local(LocalType::Value { - vector_size: None, - scalar, - pointer_space: None, - })) + self.get_type_id(LookupType::Local(LocalType::Numeric( + NumericType::Scalar(scalar), + ))) } _ => unimplemented!(), }; - let bool_type_id = - self.get_type_id(LookupType::Local(LocalType::Value { - vector_size: None, - scalar: crate::Scalar::BOOL, - pointer_space: None, - })); + let bool_type_id = self.get_type_id(LookupType::Local( + LocalType::Numeric(NumericType::Scalar(crate::Scalar::BOOL)), + )); let cas_result_id = self.gen_id(); let equality_result_id = self.gen_id(); diff --git a/naga/src/back/spv/image.rs b/naga/src/back/spv/image.rs index 769971d136..a76d015f3f 100644 --- a/naga/src/back/spv/image.rs +++ b/naga/src/back/spv/image.rs @@ -4,7 +4,7 @@ Generating SPIR-V for image operations. use super::{ selection::{MergeTuple, Selection}, - Block, BlockContext, Error, IdGenerator, Instruction, LocalType, LookupType, + Block, BlockContext, Error, IdGenerator, Instruction, LocalType, LookupType, NumericType, }; use crate::arena::Handle; use spirv::Word; @@ -126,11 +126,10 @@ impl Load { // the right SPIR-V type for the access instruction here. let type_id = match image_class { crate::ImageClass::Depth { .. } => { - ctx.get_type_id(LookupType::Local(LocalType::Value { - vector_size: Some(crate::VectorSize::Quad), + ctx.get_type_id(LookupType::Local(LocalType::Numeric(NumericType::Vector { + size: crate::VectorSize::Quad, scalar: crate::Scalar::F32, - pointer_space: None, - })) + }))) } _ => result_type_id, }; @@ -292,15 +291,15 @@ impl<'w> BlockContext<'w> { // Find the component type of `coordinates`, and figure out the size the // combined coordinate vector will have. let (component_scalar, size) = match *inner_ty { - Ti::Scalar(scalar @ crate::Scalar { width: 4, .. }) => (scalar, Some(Vs::Bi)), + Ti::Scalar(scalar @ crate::Scalar { width: 4, .. }) => (scalar, Vs::Bi), Ti::Vector { scalar: scalar @ crate::Scalar { width: 4, .. }, size: Vs::Bi, - } => (scalar, Some(Vs::Tri)), + } => (scalar, Vs::Tri), Ti::Vector { scalar: scalar @ crate::Scalar { width: 4, .. }, size: Vs::Tri, - } => (scalar, Some(Vs::Quad)), + } => (scalar, Vs::Quad), Ti::Vector { size: Vs::Quad, .. } => { return Err(Error::Validation("extending vec4 coordinate")); } @@ -340,11 +339,9 @@ impl<'w> BlockContext<'w> { } }; let reconciled_array_index_id = if let Some(cast) = cast { - let component_ty_id = self.get_type_id(LookupType::Local(LocalType::Value { - vector_size: None, - scalar: component_scalar, - pointer_space: None, - })); + let component_ty_id = self.get_type_id(LookupType::Local(LocalType::Numeric( + NumericType::Scalar(component_scalar), + ))); let reconciled_id = self.gen_id(); block.body.push(Instruction::unary( cast, @@ -358,11 +355,11 @@ impl<'w> BlockContext<'w> { }; // Find the SPIR-V type for the combined coordinates/index vector. - let type_id = self.get_type_id(LookupType::Local(LocalType::Value { - vector_size: size, - scalar: component_scalar, - pointer_space: None, - })); + let type_id = + self.get_type_id(LookupType::Local(LocalType::Numeric(NumericType::Vector { + size, + scalar: component_scalar, + }))); // Schmear the coordinates and index together. let value_id = self.gen_id(); @@ -374,7 +371,7 @@ impl<'w> BlockContext<'w> { Ok(ImageCoordinates { value_id, type_id, - size, + size: Some(size), }) } @@ -529,11 +526,9 @@ impl<'w> BlockContext<'w> { &[spirv::Capability::ImageQuery], )?; - let i32_type_id = self.get_type_id(LookupType::Local(LocalType::Value { - vector_size: None, - scalar: crate::Scalar::I32, - pointer_space: None, - })); + let i32_type_id = self.get_type_id(LookupType::Local(LocalType::Numeric( + NumericType::Scalar(crate::Scalar::I32), + ))); // If `level` is `Some`, clamp it to fall within bounds. This must // happen first, because we'll use it to query the image size for @@ -616,11 +611,9 @@ impl<'w> BlockContext<'w> { )?; let bool_type_id = self.writer.get_bool_type_id(); - let i32_type_id = self.get_type_id(LookupType::Local(LocalType::Value { - vector_size: None, - scalar: crate::Scalar::I32, - pointer_space: None, - })); + let i32_type_id = self.get_type_id(LookupType::Local(LocalType::Numeric( + NumericType::Scalar(crate::Scalar::I32), + ))); let null_id = access.out_of_bounds_value(self); @@ -683,11 +676,15 @@ impl<'w> BlockContext<'w> { ); // Compare the coordinates against the bounds. - let coords_bool_type_id = self.get_type_id(LookupType::Local(LocalType::Value { - vector_size: coordinates.size, - scalar: crate::Scalar::BOOL, - pointer_space: None, - })); + let coords_numeric_type = match coordinates.size { + Some(size) => NumericType::Vector { + size, + scalar: crate::Scalar::BOOL, + }, + None => NumericType::Scalar(crate::Scalar::BOOL), + }; + let coords_bool_type_id = + self.get_type_id(LookupType::Local(LocalType::Numeric(coords_numeric_type))); let coords_conds_id = self.gen_id(); selection.block().body.push(Instruction::binary( spirv::Op::ULessThan, @@ -838,11 +835,10 @@ impl<'w> BlockContext<'w> { _ => false, }; let sample_result_type_id = if needs_sub_access { - self.get_type_id(LookupType::Local(LocalType::Value { - vector_size: Some(crate::VectorSize::Quad), + self.get_type_id(LookupType::Local(LocalType::Numeric(NumericType::Vector { + size: crate::VectorSize::Quad, scalar: crate::Scalar::F32, - pointer_space: None, - })) + }))) } else { result_type_id }; @@ -1038,11 +1034,16 @@ impl<'w> BlockContext<'w> { 4 => Some(crate::VectorSize::Quad), _ => None, }; - let extended_size_type_id = self.get_type_id(LookupType::Local(LocalType::Value { - vector_size, - scalar: crate::Scalar::U32, - pointer_space: None, - })); + let vector_numeric_type = match vector_size { + Some(size) => NumericType::Vector { + size, + scalar: crate::Scalar::U32, + }, + None => NumericType::Scalar(crate::Scalar::U32), + }; + + let extended_size_type_id = + self.get_type_id(LookupType::Local(LocalType::Numeric(vector_numeric_type))); let (query_op, level_id) = match class { Ic::Sampled { multi: true, .. } @@ -1108,11 +1109,11 @@ impl<'w> BlockContext<'w> { Id::D2 | Id::Cube => crate::VectorSize::Tri, Id::D3 => crate::VectorSize::Quad, }; - let extended_size_type_id = self.get_type_id(LookupType::Local(LocalType::Value { - vector_size: Some(vec_size), - scalar: crate::Scalar::U32, - pointer_space: None, - })); + let extended_size_type_id = + self.get_type_id(LookupType::Local(LocalType::Numeric(NumericType::Vector { + size: vec_size, + scalar: crate::Scalar::U32, + }))); let id_extended = self.gen_id(); let mut inst = Instruction::image_query( spirv::Op::ImageQuerySizeLod, diff --git a/naga/src/back/spv/mod.rs b/naga/src/back/spv/mod.rs index 93e9a466c4..aa4de68462 100644 --- a/naga/src/back/spv/mod.rs +++ b/naga/src/back/spv/mod.rs @@ -231,6 +231,21 @@ impl LocalImageType { } } +/// A numeric type, for use in [`LocalType`]. +#[derive(Debug, PartialEq, Hash, Eq, Copy, Clone)] +enum NumericType { + Scalar(crate::Scalar), + Vector { + size: crate::VectorSize, + scalar: crate::Scalar, + }, + Matrix { + columns: crate::VectorSize, + rows: crate::VectorSize, + scalar: crate::Scalar, + }, +} + /// A SPIR-V type constructed during code generation. /// /// This is the variant of [`LookupType`] used to represent types that might not @@ -276,19 +291,11 @@ impl LocalImageType { /// [`TypeInner`]: crate::TypeInner #[derive(Debug, PartialEq, Hash, Eq, Copy, Clone)] enum LocalType { - /// A scalar, vector, or pointer to one of those. - Value { - /// If `None`, this represents a scalar type. If `Some`, this represents - /// a vector type of the given size. - vector_size: Option, - scalar: crate::Scalar, - pointer_space: Option, - }, - /// A matrix of floating-point values. - Matrix { - columns: crate::VectorSize, - rows: crate::VectorSize, - width: crate::Bytes, + /// A numeric type. + Numeric(NumericType), + LocalPointer { + base: NumericType, + class: spirv::StorageClass, }, Pointer { base: Handle, @@ -361,38 +368,39 @@ impl LocalType { fn from_inner(inner: &crate::TypeInner) -> Option { Some(match *inner { crate::TypeInner::Scalar(scalar) | crate::TypeInner::Atomic(scalar) => { - LocalType::Value { - vector_size: None, - scalar, - pointer_space: None, - } + LocalType::Numeric(NumericType::Scalar(scalar)) + } + crate::TypeInner::Vector { size, scalar } => { + LocalType::Numeric(NumericType::Vector { size, scalar }) } - crate::TypeInner::Vector { size, scalar } => LocalType::Value { - vector_size: Some(size), - scalar, - pointer_space: None, - }, crate::TypeInner::Matrix { columns, rows, scalar, - } => LocalType::Matrix { + } => LocalType::Numeric(NumericType::Matrix { columns, rows, - width: scalar.width, - }, + scalar, + }), crate::TypeInner::Pointer { base, space } => LocalType::Pointer { base, class: helpers::map_storage_class(space), }, crate::TypeInner::ValuePointer { - size, + size: Some(size), scalar, space, - } => LocalType::Value { - vector_size: size, + } => LocalType::LocalPointer { + base: NumericType::Vector { size, scalar }, + class: helpers::map_storage_class(space), + }, + crate::TypeInner::ValuePointer { + size: None, scalar, - pointer_space: Some(helpers::map_storage_class(space)), + space, + } => LocalType::LocalPointer { + base: NumericType::Scalar(scalar), + class: helpers::map_storage_class(space), }, crate::TypeInner::Image { dim, diff --git a/naga/src/back/spv/ray.rs b/naga/src/back/spv/ray.rs index bc2c4ce3c6..c2daf4b3f6 100644 --- a/naga/src/back/spv/ray.rs +++ b/naga/src/back/spv/ray.rs @@ -2,7 +2,7 @@ Generating SPIR-V for ray query operations. */ -use super::{Block, BlockContext, Instruction, LocalType, LookupType}; +use super::{Block, BlockContext, Instruction, LocalType, LookupType, NumericType}; use crate::arena::Handle; impl<'w> BlockContext<'w> { @@ -22,11 +22,9 @@ impl<'w> BlockContext<'w> { let desc_id = self.cached[descriptor]; let acc_struct_id = self.get_handle_id(acceleration_structure); - let flag_type_id = self.get_type_id(LookupType::Local(LocalType::Value { - vector_size: None, - scalar: crate::Scalar::U32, - pointer_space: None, - })); + let flag_type_id = self.get_type_id(LookupType::Local(LocalType::Numeric( + NumericType::Scalar(crate::Scalar::U32), + ))); let ray_flags_id = self.gen_id(); block.body.push(Instruction::composite_extract( flag_type_id, @@ -42,11 +40,9 @@ impl<'w> BlockContext<'w> { &[1], )); - let scalar_type_id = self.get_type_id(LookupType::Local(LocalType::Value { - vector_size: None, - scalar: crate::Scalar::F32, - pointer_space: None, - })); + let scalar_type_id = self.get_type_id(LookupType::Local(LocalType::Numeric( + NumericType::Scalar(crate::Scalar::F32), + ))); let tmin_id = self.gen_id(); block.body.push(Instruction::composite_extract( scalar_type_id, @@ -62,11 +58,11 @@ impl<'w> BlockContext<'w> { &[3], )); - let vector_type_id = self.get_type_id(LookupType::Local(LocalType::Value { - vector_size: Some(crate::VectorSize::Tri), - scalar: crate::Scalar::F32, - pointer_space: None, - })); + let vector_type_id = + self.get_type_id(LookupType::Local(LocalType::Numeric(NumericType::Vector { + size: crate::VectorSize::Tri, + scalar: crate::Scalar::F32, + }))); let ray_origin_id = self.gen_id(); block.body.push(Instruction::composite_extract( vector_type_id, @@ -116,11 +112,9 @@ impl<'w> BlockContext<'w> { spirv::RayQueryIntersection::RayQueryCommittedIntersectionKHR as _, )); - let flag_type_id = self.get_type_id(LookupType::Local(LocalType::Value { - vector_size: None, - scalar: crate::Scalar::U32, - pointer_space: None, - })); + let flag_type_id = self.get_type_id(LookupType::Local(LocalType::Numeric( + NumericType::Scalar(crate::Scalar::U32), + ))); let kind_id = self.gen_id(); block.body.push(Instruction::ray_query_get_intersection( spirv::Op::RayQueryGetIntersectionTypeKHR, @@ -170,11 +164,9 @@ impl<'w> BlockContext<'w> { intersection_id, )); - let scalar_type_id = self.get_type_id(LookupType::Local(LocalType::Value { - vector_size: None, - scalar: crate::Scalar::F32, - pointer_space: None, - })); + let scalar_type_id = self.get_type_id(LookupType::Local(LocalType::Numeric( + NumericType::Scalar(crate::Scalar::F32), + ))); let t_id = self.gen_id(); block.body.push(Instruction::ray_query_get_intersection( spirv::Op::RayQueryGetIntersectionTKHR, @@ -184,11 +176,11 @@ impl<'w> BlockContext<'w> { intersection_id, )); - let barycentrics_type_id = self.get_type_id(LookupType::Local(LocalType::Value { - vector_size: Some(crate::VectorSize::Bi), - scalar: crate::Scalar::F32, - pointer_space: None, - })); + let barycentrics_type_id = + self.get_type_id(LookupType::Local(LocalType::Numeric(NumericType::Vector { + size: crate::VectorSize::Bi, + scalar: crate::Scalar::F32, + }))); let barycentrics_id = self.gen_id(); block.body.push(Instruction::ray_query_get_intersection( spirv::Op::RayQueryGetIntersectionBarycentricsKHR, @@ -198,11 +190,9 @@ impl<'w> BlockContext<'w> { intersection_id, )); - let bool_type_id = self.get_type_id(LookupType::Local(LocalType::Value { - vector_size: None, - scalar: crate::Scalar::BOOL, - pointer_space: None, - })); + let bool_type_id = self.get_type_id(LookupType::Local(LocalType::Numeric( + NumericType::Scalar(crate::Scalar::BOOL), + ))); let front_face_id = self.gen_id(); block.body.push(Instruction::ray_query_get_intersection( spirv::Op::RayQueryGetIntersectionFrontFaceKHR, @@ -212,11 +202,12 @@ impl<'w> BlockContext<'w> { intersection_id, )); - let transform_type_id = self.get_type_id(LookupType::Local(LocalType::Matrix { - columns: crate::VectorSize::Quad, - rows: crate::VectorSize::Tri, - width: 4, - })); + let transform_type_id = + self.get_type_id(LookupType::Local(LocalType::Numeric(NumericType::Matrix { + columns: crate::VectorSize::Quad, + rows: crate::VectorSize::Tri, + scalar: crate::Scalar::F32, + }))); let object_to_world_id = self.gen_id(); block.body.push(Instruction::ray_query_get_intersection( spirv::Op::RayQueryGetIntersectionObjectToWorldKHR, diff --git a/naga/src/back/spv/subgroup.rs b/naga/src/back/spv/subgroup.rs index c952cb11a7..eb273f5f19 100644 --- a/naga/src/back/spv/subgroup.rs +++ b/naga/src/back/spv/subgroup.rs @@ -1,4 +1,4 @@ -use super::{Block, BlockContext, Error, Instruction}; +use super::{Block, BlockContext, Error, Instruction, NumericType}; use crate::{ arena::Handle, back::spv::{LocalType, LookupType}, @@ -16,11 +16,11 @@ impl<'w> BlockContext<'w> { "GroupNonUniformBallot", &[spirv::Capability::GroupNonUniformBallot], )?; - let vec4_u32_type_id = self.get_type_id(LookupType::Local(LocalType::Value { - vector_size: Some(crate::VectorSize::Quad), - scalar: crate::Scalar::U32, - pointer_space: None, - })); + let vec4_u32_type_id = + self.get_type_id(LookupType::Local(LocalType::Numeric(NumericType::Vector { + size: crate::VectorSize::Quad, + scalar: crate::Scalar::U32, + }))); let exec_scope_id = self.get_index_constant(spirv::Scope::Subgroup as u32); let predicate = if let Some(predicate) = *predicate { self.cached[predicate] diff --git a/naga/src/back/spv/writer.rs b/naga/src/back/spv/writer.rs index 27f2cbfdb6..cfff00be40 100644 --- a/naga/src/back/spv/writer.rs +++ b/naga/src/back/spv/writer.rs @@ -3,8 +3,8 @@ use super::{ helpers::{contains_builtin, global_needs_wrapper, map_storage_class}, Block, BlockContext, CachedConstant, CachedExpressions, DebugInfo, EntryPointContext, Error, Function, FunctionArgument, GlobalVariable, IdGenerator, Instruction, LocalType, LocalVariable, - LogicalLayout, LookupFunctionType, LookupType, Options, PhysicalLayout, PipelineOptions, - ResultMember, Writer, WriterFlags, BITS_PER_BYTE, + LogicalLayout, LookupFunctionType, LookupType, NumericType, Options, PhysicalLayout, + PipelineOptions, ResultMember, Writer, WriterFlags, BITS_PER_BYTE, }; use crate::{ arena::{Handle, HandleVec, UniqueArena}, @@ -291,83 +291,52 @@ impl Writer { } pub(super) fn get_uint_type_id(&mut self) -> Word { - let local_type = LocalType::Value { - vector_size: None, - scalar: crate::Scalar::U32, - pointer_space: None, - }; + let local_type = LocalType::Numeric(NumericType::Scalar(crate::Scalar::U32)); self.get_type_id(local_type.into()) } pub(super) fn get_float_type_id(&mut self) -> Word { - let local_type = LocalType::Value { - vector_size: None, - scalar: crate::Scalar::F32, - pointer_space: None, - }; + let local_type = LocalType::Numeric(NumericType::Scalar(crate::Scalar::F32)); self.get_type_id(local_type.into()) } pub(super) fn get_uint3_type_id(&mut self) -> Word { - let local_type = LocalType::Value { - vector_size: Some(crate::VectorSize::Tri), + let local_type = LocalType::Numeric(NumericType::Vector { + size: crate::VectorSize::Tri, scalar: crate::Scalar::U32, - pointer_space: None, - }; + }); self.get_type_id(local_type.into()) } pub(super) fn get_float_pointer_type_id(&mut self, class: spirv::StorageClass) -> Word { - let lookup_type = LookupType::Local(LocalType::Value { - vector_size: None, - scalar: crate::Scalar::F32, - pointer_space: Some(class), - }); - if let Some(&id) = self.lookup_type.get(&lookup_type) { - id - } else { - let id = self.id_gen.next(); - let ty_id = self.get_float_type_id(); - let instruction = Instruction::type_pointer(id, class, ty_id); - instruction.to_words(&mut self.logical_layout.declarations); - self.lookup_type.insert(lookup_type, id); - id - } + let local_type = LocalType::LocalPointer { + base: NumericType::Scalar(crate::Scalar::F32), + class, + }; + self.get_type_id(local_type.into()) } pub(super) fn get_uint3_pointer_type_id(&mut self, class: spirv::StorageClass) -> Word { - let lookup_type = LookupType::Local(LocalType::Value { - vector_size: Some(crate::VectorSize::Tri), - scalar: crate::Scalar::U32, - pointer_space: Some(class), - }); - if let Some(&id) = self.lookup_type.get(&lookup_type) { - id - } else { - let id = self.id_gen.next(); - let ty_id = self.get_uint3_type_id(); - let instruction = Instruction::type_pointer(id, class, ty_id); - instruction.to_words(&mut self.logical_layout.declarations); - self.lookup_type.insert(lookup_type, id); - id - } + let local_type = LocalType::LocalPointer { + base: NumericType::Vector { + size: crate::VectorSize::Tri, + scalar: crate::Scalar::U32, + }, + class, + }; + self.get_type_id(local_type.into()) } pub(super) fn get_bool_type_id(&mut self) -> Word { - let local_type = LocalType::Value { - vector_size: None, - scalar: crate::Scalar::BOOL, - pointer_space: None, - }; + let local_type = LocalType::Numeric(NumericType::Scalar(crate::Scalar::BOOL)); self.get_type_id(local_type.into()) } pub(super) fn get_bool3_type_id(&mut self) -> Word { - let local_type = LocalType::Value { - vector_size: Some(crate::VectorSize::Tri), + let local_type = LocalType::Numeric(NumericType::Vector { + size: crate::VectorSize::Tri, scalar: crate::Scalar::BOOL, - pointer_space: None, - }; + }); self.get_type_id(local_type.into()) } @@ -935,62 +904,50 @@ impl Writer { Ok(()) } + fn write_numeric_type_declaration_local(&mut self, id: Word, numeric: NumericType) { + let instruction = + match numeric { + NumericType::Scalar(scalar) => self.make_scalar(id, scalar), + NumericType::Vector { size, scalar } => { + let scalar_id = self.get_type_id(LookupType::Local(LocalType::Numeric( + NumericType::Scalar(scalar), + ))); + Instruction::type_vector(id, scalar_id, size) + } + NumericType::Matrix { + columns, + rows, + scalar, + } => { + let column_id = self.get_type_id(LookupType::Local(LocalType::Numeric( + NumericType::Vector { size: rows, scalar }, + ))); + Instruction::type_matrix(id, column_id, columns) + } + }; + + instruction.to_words(&mut self.logical_layout.declarations); + } + fn write_type_declaration_local(&mut self, id: Word, local_ty: LocalType) { let instruction = match local_ty { - LocalType::Value { - vector_size: None, - scalar, - pointer_space: None, - } => self.make_scalar(id, scalar), - LocalType::Value { - vector_size: Some(size), - scalar, - pointer_space: None, - } => { - let scalar_id = self.get_type_id(LookupType::Local(LocalType::Value { - vector_size: None, - scalar, - pointer_space: None, - })); - Instruction::type_vector(id, scalar_id, size) + LocalType::Numeric(numeric) => { + self.write_numeric_type_declaration_local(id, numeric); + return; } - LocalType::Matrix { - columns, - rows, - width, - } => { - let vector_id = self.get_type_id(LookupType::Local(LocalType::Value { - vector_size: Some(rows), - scalar: crate::Scalar::float(width), - pointer_space: None, - })); - Instruction::type_matrix(id, vector_id, columns) + LocalType::LocalPointer { base, class } => { + let base_id = self.get_type_id(LookupType::Local(LocalType::Numeric(base))); + Instruction::type_pointer(id, class, base_id) } LocalType::Pointer { base, class } => { let type_id = self.get_type_id(LookupType::Handle(base)); Instruction::type_pointer(id, class, type_id) } - LocalType::Value { - vector_size, - scalar, - pointer_space: Some(class), - } => { - let type_id = self.get_type_id(LookupType::Local(LocalType::Value { - vector_size, - scalar, - pointer_space: None, - })); - Instruction::type_pointer(id, class, type_id) - } LocalType::Image(image) => { - let local_type = LocalType::Value { - vector_size: None, - scalar: crate::Scalar { - kind: image.sampled_type, - width: 4, - }, - pointer_space: None, - }; + let local_type = LocalType::Numeric(NumericType::Scalar(crate::Scalar { + kind: image.sampled_type, + width: 4, + })); let type_id = self.get_type_id(LookupType::Local(local_type)); Instruction::type_image(id, type_id, image.dim, image.flags, image.image_format) } @@ -1224,11 +1181,9 @@ impl Writer { self.debugs.push(Instruction::name(id, name)); } } - let type_id = self.get_type_id(LookupType::Local(LocalType::Value { - vector_size: None, - scalar: value.scalar(), - pointer_space: None, - })); + let type_id = self.get_type_id(LookupType::Local(LocalType::Numeric(NumericType::Scalar( + value.scalar(), + )))); let instruction = match *value { crate::Literal::F64(value) => { let bits = value.to_bits(); From 5c6b00886efd15e5fb182228c28a68a790006594 Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Wed, 9 Oct 2024 11:33:46 -0700 Subject: [PATCH 15/67] [naga spv-out] Simplify `Writer::get_pointer_id`. Simplify the definition of `naga::back::spv::Writer::get_pointer_id` by using `get_type_id`'s ability to handle `LocalType::Pointer`. This means that `get_pointer_id` is no longer fallible, and no longer needs a type arena. Simplify callers, as well as the `BlockContext::get_pointer_id` convenience function. --- naga/src/back/spv/block.rs | 1 - naga/src/back/spv/index.rs | 2 +- naga/src/back/spv/mod.rs | 9 ++----- naga/src/back/spv/writer.rs | 47 ++++++++++--------------------------- 4 files changed, 15 insertions(+), 44 deletions(-) diff --git a/naga/src/back/spv/block.rs b/naga/src/back/spv/block.rs index d7c56d3f4c..f9bd22b929 100644 --- a/naga/src/back/spv/block.rs +++ b/naga/src/back/spv/block.rs @@ -381,7 +381,6 @@ impl<'w> BlockContext<'w> { } }; let (id, variable) = self.writer.promote_access_expression_to_variable( - &self.ir_module.types, result_type_id, base_id, base_ty, diff --git a/naga/src/back/spv/index.rs b/naga/src/back/spv/index.rs index 3ad2e42a8d..f1122ee4a4 100644 --- a/naga/src/back/spv/index.rs +++ b/naga/src/back/spv/index.rs @@ -226,7 +226,7 @@ impl<'w> BlockContext<'w> { let element_type_id = match self.ir_module.types[global.ty].inner { crate::TypeInner::BindingArray { base, size: _ } => { let class = map_storage_class(global.space); - self.get_pointer_id(base, class)? + self.get_pointer_id(base, class) } _ => return Err(Error::Validation("array length expression case-5")), }; diff --git a/naga/src/back/spv/mod.rs b/naga/src/back/spv/mod.rs index aa4de68462..58fcf60356 100644 --- a/naga/src/back/spv/mod.rs +++ b/naga/src/back/spv/mod.rs @@ -667,13 +667,8 @@ impl BlockContext<'_> { .get_constant_scalar(crate::Literal::I32(scope as _)) } - fn get_pointer_id( - &mut self, - handle: Handle, - class: spirv::StorageClass, - ) -> Result { - self.writer - .get_pointer_id(&self.ir_module.types, handle, class) + fn get_pointer_id(&mut self, handle: Handle, class: spirv::StorageClass) -> Word { + self.writer.get_pointer_id(handle, class) } } diff --git a/naga/src/back/spv/writer.rs b/naga/src/back/spv/writer.rs index cfff00be40..57beb4535a 100644 --- a/naga/src/back/spv/writer.rs +++ b/naga/src/back/spv/writer.rs @@ -141,7 +141,6 @@ impl Writer { #[allow(clippy::too_many_arguments)] pub(super) fn promote_access_expression_to_variable( &mut self, - ir_types: &UniqueArena, result_type_id: Word, container_id: Word, container_ty: Handle, @@ -149,8 +148,7 @@ impl Writer { element_ty: Handle, block: &mut Block, ) -> Result<(Word, LocalVariable), Error> { - let pointer_type_id = - self.get_pointer_id(ir_types, container_ty, spirv::StorageClass::Function)?; + let pointer_type_id = self.get_pointer_id(container_ty, spirv::StorageClass::Function); let variable = { let id = self.id_gen.next(); @@ -170,7 +168,7 @@ impl Writer { let element_pointer_id = self.id_gen.next(); let element_pointer_type_id = - self.get_pointer_id(ir_types, element_ty, spirv::StorageClass::Function)?; + self.get_pointer_id(element_ty, spirv::StorageClass::Function); block.body.push(Instruction::access_chain( element_pointer_type_id, element_pointer_id, @@ -267,27 +265,13 @@ impl Writer { pub(super) fn get_pointer_id( &mut self, - arena: &UniqueArena, handle: Handle, class: spirv::StorageClass, - ) -> Result { - let ty_id = self.get_type_id(LookupType::Handle(handle)); - if let crate::TypeInner::Pointer { .. } = arena[handle].inner { - return Ok(ty_id); - } - let lookup_type = LookupType::Local(LocalType::Pointer { + ) -> Word { + self.get_type_id(LookupType::Local(LocalType::Pointer { base: handle, class, - }); - Ok(if let Some(&id) = self.lookup_type.get(&lookup_type) { - id - } else { - let id = self.id_gen.next(); - let instruction = Instruction::type_pointer(id, class, ty_id); - instruction.to_words(&mut self.logical_layout.declarations); - self.lookup_type.insert(lookup_type, id); - id - }) + })) } pub(super) fn get_uint_type_id(&mut self) -> Word { @@ -369,11 +353,7 @@ impl Writer { let class = spirv::StorageClass::Input; let handle_ty = ir_module.types[argument.ty].inner.is_handle(); let argument_type_id = match handle_ty { - true => self.get_pointer_id( - &ir_module.types, - argument.ty, - spirv::StorageClass::UniformConstant, - )?, + true => self.get_pointer_id(argument.ty, spirv::StorageClass::UniformConstant), false => self.get_type_id(LookupType::Handle(argument.ty)), }; @@ -604,8 +584,7 @@ impl Writer { gv.handle_id = id; } else if global_needs_wrapper(ir_module, var) { let class = map_storage_class(var.space); - let pointer_type_id = - self.get_pointer_id(&ir_module.types, var.ty, class)?; + let pointer_type_id = self.get_pointer_id(var.ty, class); let index_id = self.get_index_constant(0); let id = self.id_gen.next(); prelude.body.push(Instruction::access_chain( @@ -664,11 +643,9 @@ impl Writer { } let init_word = variable.init.map(|constant| context.cached[constant]); - let pointer_type_id = context.writer.get_pointer_id( - &ir_module.types, - variable.ty, - spirv::StorageClass::Function, - )?; + let pointer_type_id = context + .writer + .get_pointer_id(variable.ty, spirv::StorageClass::Function); let instruction = Instruction::variable( pointer_type_id, id, @@ -1468,7 +1445,7 @@ impl Writer { binding: &crate::Binding, ) -> Result { let id = self.id_gen.next(); - let pointer_type_id = self.get_pointer_id(&ir_module.types, ty, class)?; + let pointer_type_id = self.get_pointer_id(ty, class); Instruction::variable(pointer_type_id, id, class, None) .to_words(&mut self.logical_layout.declarations); @@ -1801,7 +1778,7 @@ impl Writer { if substitute_inner_type_lookup.is_some() { inner_type_id } else { - self.get_pointer_id(&ir_module.types, global_variable.ty, class)? + self.get_pointer_id(global_variable.ty, class) } }; From ae52e5dc96d38101b53e60a1703d85153cd8fa0f Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Wed, 9 Oct 2024 16:36:48 -0700 Subject: [PATCH 16/67] [naga spv-out] Delete `BlockContext::is_intermediate`; use types. Delete the function `BlockContext::is_intermediate`. Instead, have `Access` and `AccessIndex` instructions decide whether to defer code generation based on the type of the base expression: indexing operations on pointers are deferred; anything else is not. --- naga/src/back/spv/block.rs | 55 +++++++++++++------------------------- 1 file changed, 18 insertions(+), 37 deletions(-) diff --git a/naga/src/back/spv/block.rs b/naga/src/back/spv/block.rs index f9bd22b929..6161fa0899 100644 --- a/naga/src/back/spv/block.rs +++ b/naga/src/back/spv/block.rs @@ -212,32 +212,6 @@ impl Writer { } impl<'w> BlockContext<'w> { - /// Decide whether to put off emitting instructions for `expr_handle`. - /// - /// We would like to gather together chains of `Access` and `AccessIndex` - /// Naga expressions into a single `OpAccessChain` SPIR-V instruction. To do - /// this, we don't generate instructions for these exprs when we first - /// encounter them. Their ids in `self.writer.cached.ids` are left as zero. Then, - /// once we encounter a `Load` or `Store` expression that actually needs the - /// chain's value, we call `write_expression_pointer` to handle the whole - /// thing in one fell swoop. - fn is_intermediate(&self, expr_handle: Handle) -> bool { - match self.ir_function.expressions[expr_handle] { - crate::Expression::GlobalVariable(handle) => { - self.ir_module.global_variables[handle].space != crate::AddressSpace::Handle - } - crate::Expression::LocalVariable(_) => true, - crate::Expression::FunctionArgument(index) => { - let arg = &self.ir_function.arguments[index as usize]; - self.ir_module.types[arg.ty].inner.pointer_space().is_some() - } - - // The chain rule: if this `Access...`'s `base` operand was - // previously omitted, then omit this one, too. - _ => self.cached.ids[expr_handle] == 0, - } - } - /// Cache an expression for a value. pub(super) fn cache_expression_value( &mut self, @@ -308,18 +282,22 @@ impl<'w> BlockContext<'w> { id } } - crate::Expression::Access { base, index: _ } if self.is_intermediate(base) => { - // See `is_intermediate`; we'll handle this later in - // `write_expression_pointer`. - 0 - } crate::Expression::Access { base, index } => { let base_ty_inner = self.fun_info[base].ty.inner_with(&self.ir_module.types); match *base_ty_inner { + crate::TypeInner::Pointer { .. } | crate::TypeInner::ValuePointer { .. } => { + // When we have a chain of `Access` and `AccessIndex` expressions + // operating on pointers, we want to generate a single + // `OpAccessChain` instruction for the whole chain. Put off + // generating any code for this until we find the `Expression` + // that actually dereferences the pointer. + 0 + } crate::TypeInner::Vector { .. } => { self.write_vector_access(expr_handle, base, index, block)? } - // Only binding arrays in the Handle address space will take this path (due to `is_intermediate`) + // Only binding arrays in the `Handle` address space will take this + // path, since we handled the `Pointer` case above. crate::TypeInner::BindingArray { base: binding_type, .. } => { @@ -404,13 +382,16 @@ impl<'w> BlockContext<'w> { } } } - crate::Expression::AccessIndex { base, index: _ } if self.is_intermediate(base) => { - // See `is_intermediate`; we'll handle this later in - // `write_expression_pointer`. - 0 - } crate::Expression::AccessIndex { base, index } => { match *self.fun_info[base].ty.inner_with(&self.ir_module.types) { + crate::TypeInner::Pointer { .. } | crate::TypeInner::ValuePointer { .. } => { + // When we have a chain of `Access` and `AccessIndex` expressions + // operating on pointers, we want to generate a single + // `OpAccessChain` instruction for the whole chain. Put off + // generating any code for this until we find the `Expression` + // that actually dereferences the pointer. + 0 + } crate::TypeInner::Vector { .. } | crate::TypeInner::Matrix { .. } | crate::TypeInner::Array { .. } From d70ef62e9e0683789f745c6a4354495f39354c15 Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Thu, 10 Oct 2024 08:24:49 -0700 Subject: [PATCH 17/67] [wgpu] Revert changes to vendored copy of web-sys from #6377. (#6380) Revert the changes to the vendored copy of web-sys's WebGPU bindings made in #6377. The only purpose of vendoring is to pin down our WebGPU JS bindings, not to allow local changes. And as it turns out, removing the `max_inter_stage_shader_components` accessor isn't necessary in order to fix #6290. From 73764fdc6a52e4078a6d5e3429fde1a25c12e059 Mon Sep 17 00:00:00 2001 From: Ronny Chan Date: Fri, 11 Oct 2024 09:56:12 -0400 Subject: [PATCH 18/67] [naga/wgsl-out]: polyfill `inverse` function (#6385) --- CHANGELOG.md | 1 + naga/src/back/wgsl/mod.rs | 1 + .../polyfill/inverse/inverse_2x2_f16.wgsl | 10 ++ .../polyfill/inverse/inverse_2x2_f32.wgsl | 10 ++ .../polyfill/inverse/inverse_3x3_f16.wgsl | 19 +++ .../polyfill/inverse/inverse_3x3_f32.wgsl | 19 +++ .../polyfill/inverse/inverse_4x4_f16.wgsl | 43 +++++++ .../polyfill/inverse/inverse_4x4_f32.wgsl | 43 +++++++ naga/src/back/wgsl/polyfill/mod.rs | 66 +++++++++++ naga/src/back/wgsl/writer.rs | 31 ++++- naga/tests/in/glsl/inverse-polyfill.frag | 17 +++ .../tests/out/wgsl/inverse-polyfill.frag.wgsl | 110 ++++++++++++++++++ 12 files changed, 367 insertions(+), 3 deletions(-) create mode 100644 naga/src/back/wgsl/polyfill/inverse/inverse_2x2_f16.wgsl create mode 100644 naga/src/back/wgsl/polyfill/inverse/inverse_2x2_f32.wgsl create mode 100644 naga/src/back/wgsl/polyfill/inverse/inverse_3x3_f16.wgsl create mode 100644 naga/src/back/wgsl/polyfill/inverse/inverse_3x3_f32.wgsl create mode 100644 naga/src/back/wgsl/polyfill/inverse/inverse_4x4_f16.wgsl create mode 100644 naga/src/back/wgsl/polyfill/inverse/inverse_4x4_f32.wgsl create mode 100644 naga/src/back/wgsl/polyfill/mod.rs create mode 100644 naga/tests/in/glsl/inverse-polyfill.frag create mode 100644 naga/tests/out/wgsl/inverse-polyfill.frag.wgsl diff --git a/CHANGELOG.md b/CHANGELOG.md index 80b811e89d..8572220adf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -84,6 +84,7 @@ By @bradwerth [#6216](https://github.com/gfx-rs/wgpu/pull/6216). - Support for more atomic ops in the SPIR-V frontend. By @schell in [#5824](https://github.com/gfx-rs/wgpu/pull/5824). - Support local `const` declarations in WGSL. By @sagudev in [#6156](https://github.com/gfx-rs/wgpu/pull/6156). - Implemented `const_assert` in WGSL. By @sagudev in [#6198](https://github.com/gfx-rs/wgpu/pull/6198). +- Support polyfilling `inverse` in WGSL. By @chyyran in [#6385](https://github.com/gfx-rs/wgpu/pull/6385). #### General diff --git a/naga/src/back/wgsl/mod.rs b/naga/src/back/wgsl/mod.rs index d731b1ca0c..ecf59698a8 100644 --- a/naga/src/back/wgsl/mod.rs +++ b/naga/src/back/wgsl/mod.rs @@ -4,6 +4,7 @@ Backend for [WGSL][wgsl] (WebGPU Shading Language). [wgsl]: https://gpuweb.github.io/gpuweb/wgsl.html */ +mod polyfill; mod writer; use thiserror::Error; diff --git a/naga/src/back/wgsl/polyfill/inverse/inverse_2x2_f16.wgsl b/naga/src/back/wgsl/polyfill/inverse/inverse_2x2_f16.wgsl new file mode 100644 index 0000000000..33d4c37acf --- /dev/null +++ b/naga/src/back/wgsl/polyfill/inverse/inverse_2x2_f16.wgsl @@ -0,0 +1,10 @@ +fn _naga_inverse_2x2_f16(m: mat2x2) -> mat2x2 { + var adj: mat2x2; + adj[0][0] = m[1][1]; + adj[0][1] = -m[0][1]; + adj[1][0] = -m[1][0]; + adj[1][1] = m[0][0]; + + let det: f16 = m[0][0] * m[1][1] - m[1][0] * m[0][1]; + return adj * (1 / det); +} \ No newline at end of file diff --git a/naga/src/back/wgsl/polyfill/inverse/inverse_2x2_f32.wgsl b/naga/src/back/wgsl/polyfill/inverse/inverse_2x2_f32.wgsl new file mode 100644 index 0000000000..1a2d06e511 --- /dev/null +++ b/naga/src/back/wgsl/polyfill/inverse/inverse_2x2_f32.wgsl @@ -0,0 +1,10 @@ +fn _naga_inverse_2x2_f32(m: mat2x2) -> mat2x2 { + var adj: mat2x2; + adj[0][0] = m[1][1]; + adj[0][1] = -m[0][1]; + adj[1][0] = -m[1][0]; + adj[1][1] = m[0][0]; + + let det: f32 = m[0][0] * m[1][1] - m[1][0] * m[0][1]; + return adj * (1 / det); +} \ No newline at end of file diff --git a/naga/src/back/wgsl/polyfill/inverse/inverse_3x3_f16.wgsl b/naga/src/back/wgsl/polyfill/inverse/inverse_3x3_f16.wgsl new file mode 100644 index 0000000000..ddab745254 --- /dev/null +++ b/naga/src/back/wgsl/polyfill/inverse/inverse_3x3_f16.wgsl @@ -0,0 +1,19 @@ +fn _naga_inverse_3x3_f16(m: mat3x3) -> mat3x3 { + var adj: mat3x3; + + adj[0][0] = (m[1][1] * m[2][2] - m[2][1] * m[1][2]); + adj[1][0] = - (m[1][0] * m[2][2] - m[2][0] * m[1][2]); + adj[2][0] = (m[1][0] * m[2][1] - m[2][0] * m[1][1]); + adj[0][1] = - (m[0][1] * m[2][2] - m[2][1] * m[0][2]); + adj[1][1] = (m[0][0] * m[2][2] - m[2][0] * m[0][2]); + adj[2][1] = - (m[0][0] * m[2][1] - m[2][0] * m[0][1]); + adj[0][2] = (m[0][1] * m[1][2] - m[1][1] * m[0][2]); + adj[1][2] = - (m[0][0] * m[1][2] - m[1][0] * m[0][2]); + adj[2][2] = (m[0][0] * m[1][1] - m[1][0] * m[0][1]); + + let det: f16 = (m[0][0] * (m[1][1] * m[2][2] - m[1][2] * m[2][1]) + - m[0][1] * (m[1][0] * m[2][2] - m[1][2] * m[2][0]) + + m[0][2] * (m[1][0] * m[2][1] - m[1][1] * m[2][0])); + + return adj * (1 / det); +} \ No newline at end of file diff --git a/naga/src/back/wgsl/polyfill/inverse/inverse_3x3_f32.wgsl b/naga/src/back/wgsl/polyfill/inverse/inverse_3x3_f32.wgsl new file mode 100644 index 0000000000..270198e232 --- /dev/null +++ b/naga/src/back/wgsl/polyfill/inverse/inverse_3x3_f32.wgsl @@ -0,0 +1,19 @@ +fn _naga_inverse_3x3_f32(m: mat3x3) -> mat3x3 { + var adj: mat3x3; + + adj[0][0] = (m[1][1] * m[2][2] - m[2][1] * m[1][2]); + adj[1][0] = - (m[1][0] * m[2][2] - m[2][0] * m[1][2]); + adj[2][0] = (m[1][0] * m[2][1] - m[2][0] * m[1][1]); + adj[0][1] = - (m[0][1] * m[2][2] - m[2][1] * m[0][2]); + adj[1][1] = (m[0][0] * m[2][2] - m[2][0] * m[0][2]); + adj[2][1] = - (m[0][0] * m[2][1] - m[2][0] * m[0][1]); + adj[0][2] = (m[0][1] * m[1][2] - m[1][1] * m[0][2]); + adj[1][2] = - (m[0][0] * m[1][2] - m[1][0] * m[0][2]); + adj[2][2] = (m[0][0] * m[1][1] - m[1][0] * m[0][1]); + + let det: f32 = (m[0][0] * (m[1][1] * m[2][2] - m[1][2] * m[2][1]) + - m[0][1] * (m[1][0] * m[2][2] - m[1][2] * m[2][0]) + + m[0][2] * (m[1][0] * m[2][1] - m[1][1] * m[2][0])); + + return adj * (1 / det); +} \ No newline at end of file diff --git a/naga/src/back/wgsl/polyfill/inverse/inverse_4x4_f16.wgsl b/naga/src/back/wgsl/polyfill/inverse/inverse_4x4_f16.wgsl new file mode 100644 index 0000000000..ce88fc2055 --- /dev/null +++ b/naga/src/back/wgsl/polyfill/inverse/inverse_4x4_f16.wgsl @@ -0,0 +1,43 @@ +fn _naga_inverse_4x4_f16(m: mat4x4) -> mat4x4 { + let sub_factor00: f16 = m[2][2] * m[3][3] - m[3][2] * m[2][3]; + let sub_factor01: f16 = m[2][1] * m[3][3] - m[3][1] * m[2][3]; + let sub_factor02: f16 = m[2][1] * m[3][2] - m[3][1] * m[2][2]; + let sub_factor03: f16 = m[2][0] * m[3][3] - m[3][0] * m[2][3]; + let sub_factor04: f16 = m[2][0] * m[3][2] - m[3][0] * m[2][2]; + let sub_factor05: f16 = m[2][0] * m[3][1] - m[3][0] * m[2][1]; + let sub_factor06: f16 = m[1][2] * m[3][3] - m[3][2] * m[1][3]; + let sub_factor07: f16 = m[1][1] * m[3][3] - m[3][1] * m[1][3]; + let sub_factor08: f16 = m[1][1] * m[3][2] - m[3][1] * m[1][2]; + let sub_factor09: f16 = m[1][0] * m[3][3] - m[3][0] * m[1][3]; + let sub_factor10: f16 = m[1][0] * m[3][2] - m[3][0] * m[1][2]; + let sub_factor11: f16 = m[1][1] * m[3][3] - m[3][1] * m[1][3]; + let sub_factor12: f16 = m[1][0] * m[3][1] - m[3][0] * m[1][1]; + let sub_factor13: f16 = m[1][2] * m[2][3] - m[2][2] * m[1][3]; + let sub_factor14: f16 = m[1][1] * m[2][3] - m[2][1] * m[1][3]; + let sub_factor15: f16 = m[1][1] * m[2][2] - m[2][1] * m[1][2]; + let sub_factor16: f16 = m[1][0] * m[2][3] - m[2][0] * m[1][3]; + let sub_factor17: f16 = m[1][0] * m[2][2] - m[2][0] * m[1][2]; + let sub_factor18: f16 = m[1][0] * m[2][1] - m[2][0] * m[1][1]; + + var adj: mat4x4; + adj[0][0] = (m[1][1] * sub_factor00 - m[1][2] * sub_factor01 + m[1][3] * sub_factor02); + adj[1][0] = - (m[1][0] * sub_factor00 - m[1][2] * sub_factor03 + m[1][3] * sub_factor04); + adj[2][0] = (m[1][0] * sub_factor01 - m[1][1] * sub_factor03 + m[1][3] * sub_factor05); + adj[3][0] = - (m[1][0] * sub_factor02 - m[1][1] * sub_factor04 + m[1][2] * sub_factor05); + adj[0][1] = - (m[0][1] * sub_factor00 - m[0][2] * sub_factor01 + m[0][3] * sub_factor02); + adj[1][1] = (m[0][0] * sub_factor00 - m[0][2] * sub_factor03 + m[0][3] * sub_factor04); + adj[2][1] = - (m[0][0] * sub_factor01 - m[0][1] * sub_factor03 + m[0][3] * sub_factor05); + adj[3][1] = (m[0][0] * sub_factor02 - m[0][1] * sub_factor04 + m[0][2] * sub_factor05); + adj[0][2] = (m[0][1] * sub_factor06 - m[0][2] * sub_factor07 + m[0][3] * sub_factor08); + adj[1][2] = - (m[0][0] * sub_factor06 - m[0][2] * sub_factor09 + m[0][3] * sub_factor10); + adj[2][2] = (m[0][0] * sub_factor11 - m[0][1] * sub_factor09 + m[0][3] * sub_factor12); + adj[3][2] = - (m[0][0] * sub_factor08 - m[0][1] * sub_factor10 + m[0][2] * sub_factor12); + adj[0][3] = - (m[0][1] * sub_factor13 - m[0][2] * sub_factor14 + m[0][3] * sub_factor15); + adj[1][3] = (m[0][0] * sub_factor13 - m[0][2] * sub_factor16 + m[0][3] * sub_factor17); + adj[2][3] = - (m[0][0] * sub_factor14 - m[0][1] * sub_factor16 + m[0][3] * sub_factor18); + adj[3][3] = (m[0][0] * sub_factor15 - m[0][1] * sub_factor17 + m[0][2] * sub_factor18); + + let det = (m[0][0] * adj[0][0] + m[0][1] * adj[1][0] + m[0][2] * adj[2][0] + m[0][3] * adj[3][0]); + + return adj * (1 / det); +} \ No newline at end of file diff --git a/naga/src/back/wgsl/polyfill/inverse/inverse_4x4_f32.wgsl b/naga/src/back/wgsl/polyfill/inverse/inverse_4x4_f32.wgsl new file mode 100644 index 0000000000..a1bbca97bb --- /dev/null +++ b/naga/src/back/wgsl/polyfill/inverse/inverse_4x4_f32.wgsl @@ -0,0 +1,43 @@ +fn _naga_inverse_4x4_f32(m: mat4x4) -> mat4x4 { + let sub_factor00: f32 = m[2][2] * m[3][3] - m[3][2] * m[2][3]; + let sub_factor01: f32 = m[2][1] * m[3][3] - m[3][1] * m[2][3]; + let sub_factor02: f32 = m[2][1] * m[3][2] - m[3][1] * m[2][2]; + let sub_factor03: f32 = m[2][0] * m[3][3] - m[3][0] * m[2][3]; + let sub_factor04: f32 = m[2][0] * m[3][2] - m[3][0] * m[2][2]; + let sub_factor05: f32 = m[2][0] * m[3][1] - m[3][0] * m[2][1]; + let sub_factor06: f32 = m[1][2] * m[3][3] - m[3][2] * m[1][3]; + let sub_factor07: f32 = m[1][1] * m[3][3] - m[3][1] * m[1][3]; + let sub_factor08: f32 = m[1][1] * m[3][2] - m[3][1] * m[1][2]; + let sub_factor09: f32 = m[1][0] * m[3][3] - m[3][0] * m[1][3]; + let sub_factor10: f32 = m[1][0] * m[3][2] - m[3][0] * m[1][2]; + let sub_factor11: f32 = m[1][1] * m[3][3] - m[3][1] * m[1][3]; + let sub_factor12: f32 = m[1][0] * m[3][1] - m[3][0] * m[1][1]; + let sub_factor13: f32 = m[1][2] * m[2][3] - m[2][2] * m[1][3]; + let sub_factor14: f32 = m[1][1] * m[2][3] - m[2][1] * m[1][3]; + let sub_factor15: f32 = m[1][1] * m[2][2] - m[2][1] * m[1][2]; + let sub_factor16: f32 = m[1][0] * m[2][3] - m[2][0] * m[1][3]; + let sub_factor17: f32 = m[1][0] * m[2][2] - m[2][0] * m[1][2]; + let sub_factor18: f32 = m[1][0] * m[2][1] - m[2][0] * m[1][1]; + + var adj: mat4x4; + adj[0][0] = (m[1][1] * sub_factor00 - m[1][2] * sub_factor01 + m[1][3] * sub_factor02); + adj[1][0] = - (m[1][0] * sub_factor00 - m[1][2] * sub_factor03 + m[1][3] * sub_factor04); + adj[2][0] = (m[1][0] * sub_factor01 - m[1][1] * sub_factor03 + m[1][3] * sub_factor05); + adj[3][0] = - (m[1][0] * sub_factor02 - m[1][1] * sub_factor04 + m[1][2] * sub_factor05); + adj[0][1] = - (m[0][1] * sub_factor00 - m[0][2] * sub_factor01 + m[0][3] * sub_factor02); + adj[1][1] = (m[0][0] * sub_factor00 - m[0][2] * sub_factor03 + m[0][3] * sub_factor04); + adj[2][1] = - (m[0][0] * sub_factor01 - m[0][1] * sub_factor03 + m[0][3] * sub_factor05); + adj[3][1] = (m[0][0] * sub_factor02 - m[0][1] * sub_factor04 + m[0][2] * sub_factor05); + adj[0][2] = (m[0][1] * sub_factor06 - m[0][2] * sub_factor07 + m[0][3] * sub_factor08); + adj[1][2] = - (m[0][0] * sub_factor06 - m[0][2] * sub_factor09 + m[0][3] * sub_factor10); + adj[2][2] = (m[0][0] * sub_factor11 - m[0][1] * sub_factor09 + m[0][3] * sub_factor12); + adj[3][2] = - (m[0][0] * sub_factor08 - m[0][1] * sub_factor10 + m[0][2] * sub_factor12); + adj[0][3] = - (m[0][1] * sub_factor13 - m[0][2] * sub_factor14 + m[0][3] * sub_factor15); + adj[1][3] = (m[0][0] * sub_factor13 - m[0][2] * sub_factor16 + m[0][3] * sub_factor17); + adj[2][3] = - (m[0][0] * sub_factor14 - m[0][1] * sub_factor16 + m[0][3] * sub_factor18); + adj[3][3] = (m[0][0] * sub_factor15 - m[0][1] * sub_factor17 + m[0][2] * sub_factor18); + + let det = (m[0][0] * adj[0][0] + m[0][1] * adj[1][0] + m[0][2] * adj[2][0] + m[0][3] * adj[3][0]); + + return adj * (1 / det); +} \ No newline at end of file diff --git a/naga/src/back/wgsl/polyfill/mod.rs b/naga/src/back/wgsl/polyfill/mod.rs new file mode 100644 index 0000000000..970a83a53c --- /dev/null +++ b/naga/src/back/wgsl/polyfill/mod.rs @@ -0,0 +1,66 @@ +use crate::{ScalarKind, TypeInner, VectorSize}; + +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub struct InversePolyfill { + pub fun_name: &'static str, + pub source: &'static str, +} + +impl InversePolyfill { + pub fn find_overload(ty: &TypeInner) -> Option { + let &TypeInner::Matrix { + columns, + rows, + scalar, + } = ty + else { + return None; + }; + + if columns != rows || scalar.kind != ScalarKind::Float { + return None; + }; + + Self::polyfill_overload(columns, scalar.width) + } + + const fn polyfill_overload( + dimension: VectorSize, + width: crate::Bytes, + ) -> Option { + const INVERSE_2X2_F32: &str = include_str!("inverse/inverse_2x2_f32.wgsl"); + const INVERSE_3X3_F32: &str = include_str!("inverse/inverse_3x3_f32.wgsl"); + const INVERSE_4X4_F32: &str = include_str!("inverse/inverse_4x4_f32.wgsl"); + const INVERSE_2X2_F16: &str = include_str!("inverse/inverse_2x2_f16.wgsl"); + const INVERSE_3X3_F16: &str = include_str!("inverse/inverse_3x3_f16.wgsl"); + const INVERSE_4X4_F16: &str = include_str!("inverse/inverse_4x4_f16.wgsl"); + + match (dimension, width) { + (VectorSize::Bi, 4) => Some(InversePolyfill { + fun_name: "_naga_inverse_2x2_f32", + source: INVERSE_2X2_F32, + }), + (VectorSize::Tri, 4) => Some(InversePolyfill { + fun_name: "_naga_inverse_3x3_f32", + source: INVERSE_3X3_F32, + }), + (VectorSize::Quad, 4) => Some(InversePolyfill { + fun_name: "_naga_inverse_4x4_f32", + source: INVERSE_4X4_F32, + }), + (VectorSize::Bi, 2) => Some(InversePolyfill { + fun_name: "_naga_inverse_2x2_f16", + source: INVERSE_2X2_F16, + }), + (VectorSize::Tri, 2) => Some(InversePolyfill { + fun_name: "_naga_inverse_3x3_f16", + source: INVERSE_3X3_F16, + }), + (VectorSize::Quad, 2) => Some(InversePolyfill { + fun_name: "_naga_inverse_4x4_f16", + source: INVERSE_4X4_F16, + }), + _ => None, + } + } +} diff --git a/naga/src/back/wgsl/writer.rs b/naga/src/back/wgsl/writer.rs index f7555df0b0..171102f241 100644 --- a/naga/src/back/wgsl/writer.rs +++ b/naga/src/back/wgsl/writer.rs @@ -1,4 +1,5 @@ use super::Error; +use crate::back::wgsl::polyfill::InversePolyfill; use crate::{ back::{self, Baked}, proc::{self, ExpressionKindTracker, NameKey}, @@ -68,6 +69,7 @@ pub struct Writer { namer: proc::Namer, named_expressions: crate::NamedExpressions, ep_results: Vec<(ShaderStage, Handle)>, + required_polyfills: crate::FastIndexSet, } impl Writer { @@ -79,6 +81,7 @@ impl Writer { namer: proc::Namer::default(), named_expressions: crate::NamedExpressions::default(), ep_results: vec![], + required_polyfills: crate::FastIndexSet::default(), } } @@ -90,11 +93,12 @@ impl Writer { // an identifier must not start with two underscore &[], &[], - &["__"], + &["__", "_naga"], &mut self.names, ); self.named_expressions.clear(); self.ep_results.clear(); + self.required_polyfills.clear(); } fn is_builtin_wgsl_struct(&self, module: &Module, handle: Handle) -> bool { @@ -203,6 +207,13 @@ impl Writer { } } + // Write any polyfills that were required. + for polyfill in &self.required_polyfills { + writeln!(self.out)?; + write!(self.out, "{}", polyfill.source)?; + writeln!(self.out)?; + } + Ok(()) } @@ -1653,6 +1664,7 @@ impl Writer { enum Function { Regular(&'static str), + InversePolyfill(InversePolyfill), } let function = match fun { @@ -1736,9 +1748,16 @@ impl Writer { Mf::Unpack2x16float => Function::Regular("unpack2x16float"), Mf::Unpack4xI8 => Function::Regular("unpack4xI8"), Mf::Unpack4xU8 => Function::Regular("unpack4xU8"), - Mf::Inverse | Mf::Outer => { - return Err(Error::UnsupportedMathFunction(fun)); + Mf::Inverse => { + let typ = func_ctx.resolve_type(arg, &module.types); + + let Some(overload) = InversePolyfill::find_overload(typ) else { + return Err(Error::UnsupportedMathFunction(fun)); + }; + + Function::InversePolyfill(overload) } + Mf::Outer => return Err(Error::UnsupportedMathFunction(fun)), }; match function { @@ -1751,6 +1770,12 @@ impl Writer { } write!(self.out, ")")? } + Function::InversePolyfill(inverse) => { + write!(self.out, "{}(", inverse.fun_name)?; + self.write_expr(module, arg, func_ctx)?; + write!(self.out, ")")?; + self.required_polyfills.insert(inverse); + } } } diff --git a/naga/tests/in/glsl/inverse-polyfill.frag b/naga/tests/in/glsl/inverse-polyfill.frag new file mode 100644 index 0000000000..15151ef539 --- /dev/null +++ b/naga/tests/in/glsl/inverse-polyfill.frag @@ -0,0 +1,17 @@ +#version 450 + +void main() { + vec4 a4 = vec4(1.0); + vec4 b4 = vec4(2.0); + mat4 m4 = mat4(a4, b4, a4, b4); + + vec3 a3 = vec3(1.0); + vec3 b3 = vec3(2.0); + mat3 m3 = mat3(a3, b3, a3); + + mat2 m2 = mat2(1.0, 2.0, 3.0, 4.0); + + mat4 m4_inverse = inverse(m4); + mat3 m3_inverse = inverse(m3); + mat2 m2_inverse = inverse(m2); +} \ No newline at end of file diff --git a/naga/tests/out/wgsl/inverse-polyfill.frag.wgsl b/naga/tests/out/wgsl/inverse-polyfill.frag.wgsl new file mode 100644 index 0000000000..d22847c975 --- /dev/null +++ b/naga/tests/out/wgsl/inverse-polyfill.frag.wgsl @@ -0,0 +1,110 @@ +fn main_1() { + var a4_: vec4 = vec4(1f); + var b4_: vec4 = vec4(2f); + var m4_: mat4x4; + var a3_: vec3 = vec3(1f); + var b3_: vec3 = vec3(2f); + var m3_: mat3x3; + var m2_: mat2x2 = mat2x2(vec2(1f, 2f), vec2(3f, 4f)); + var m4_inverse: mat4x4; + var m3_inverse: mat3x3; + var m2_inverse: mat2x2; + + let _e6 = a4_; + let _e7 = b4_; + let _e8 = a4_; + let _e9 = b4_; + m4_ = mat4x4(vec4(_e6.x, _e6.y, _e6.z, _e6.w), vec4(_e7.x, _e7.y, _e7.z, _e7.w), vec4(_e8.x, _e8.y, _e8.z, _e8.w), vec4(_e9.x, _e9.y, _e9.z, _e9.w)); + let _e38 = a3_; + let _e39 = b3_; + let _e40 = a3_; + m3_ = mat3x3(vec3(_e38.x, _e38.y, _e38.z), vec3(_e39.x, _e39.y, _e39.z), vec3(_e40.x, _e40.y, _e40.z)); + let _e64 = m4_; + m4_inverse = _naga_inverse_4x4_f32(_e64); + let _e68 = m3_; + m3_inverse = _naga_inverse_3x3_f32(_e68); + let _e72 = m2_; + m2_inverse = _naga_inverse_2x2_f32(_e72); + return; +} + +@fragment +fn main() { + main_1(); + return; +} + +fn _naga_inverse_4x4_f32(m: mat4x4) -> mat4x4 { + let sub_factor00: f32 = m[2][2] * m[3][3] - m[3][2] * m[2][3]; + let sub_factor01: f32 = m[2][1] * m[3][3] - m[3][1] * m[2][3]; + let sub_factor02: f32 = m[2][1] * m[3][2] - m[3][1] * m[2][2]; + let sub_factor03: f32 = m[2][0] * m[3][3] - m[3][0] * m[2][3]; + let sub_factor04: f32 = m[2][0] * m[3][2] - m[3][0] * m[2][2]; + let sub_factor05: f32 = m[2][0] * m[3][1] - m[3][0] * m[2][1]; + let sub_factor06: f32 = m[1][2] * m[3][3] - m[3][2] * m[1][3]; + let sub_factor07: f32 = m[1][1] * m[3][3] - m[3][1] * m[1][3]; + let sub_factor08: f32 = m[1][1] * m[3][2] - m[3][1] * m[1][2]; + let sub_factor09: f32 = m[1][0] * m[3][3] - m[3][0] * m[1][3]; + let sub_factor10: f32 = m[1][0] * m[3][2] - m[3][0] * m[1][2]; + let sub_factor11: f32 = m[1][1] * m[3][3] - m[3][1] * m[1][3]; + let sub_factor12: f32 = m[1][0] * m[3][1] - m[3][0] * m[1][1]; + let sub_factor13: f32 = m[1][2] * m[2][3] - m[2][2] * m[1][3]; + let sub_factor14: f32 = m[1][1] * m[2][3] - m[2][1] * m[1][3]; + let sub_factor15: f32 = m[1][1] * m[2][2] - m[2][1] * m[1][2]; + let sub_factor16: f32 = m[1][0] * m[2][3] - m[2][0] * m[1][3]; + let sub_factor17: f32 = m[1][0] * m[2][2] - m[2][0] * m[1][2]; + let sub_factor18: f32 = m[1][0] * m[2][1] - m[2][0] * m[1][1]; + + var adj: mat4x4; + adj[0][0] = (m[1][1] * sub_factor00 - m[1][2] * sub_factor01 + m[1][3] * sub_factor02); + adj[1][0] = - (m[1][0] * sub_factor00 - m[1][2] * sub_factor03 + m[1][3] * sub_factor04); + adj[2][0] = (m[1][0] * sub_factor01 - m[1][1] * sub_factor03 + m[1][3] * sub_factor05); + adj[3][0] = - (m[1][0] * sub_factor02 - m[1][1] * sub_factor04 + m[1][2] * sub_factor05); + adj[0][1] = - (m[0][1] * sub_factor00 - m[0][2] * sub_factor01 + m[0][3] * sub_factor02); + adj[1][1] = (m[0][0] * sub_factor00 - m[0][2] * sub_factor03 + m[0][3] * sub_factor04); + adj[2][1] = - (m[0][0] * sub_factor01 - m[0][1] * sub_factor03 + m[0][3] * sub_factor05); + adj[3][1] = (m[0][0] * sub_factor02 - m[0][1] * sub_factor04 + m[0][2] * sub_factor05); + adj[0][2] = (m[0][1] * sub_factor06 - m[0][2] * sub_factor07 + m[0][3] * sub_factor08); + adj[1][2] = - (m[0][0] * sub_factor06 - m[0][2] * sub_factor09 + m[0][3] * sub_factor10); + adj[2][2] = (m[0][0] * sub_factor11 - m[0][1] * sub_factor09 + m[0][3] * sub_factor12); + adj[3][2] = - (m[0][0] * sub_factor08 - m[0][1] * sub_factor10 + m[0][2] * sub_factor12); + adj[0][3] = - (m[0][1] * sub_factor13 - m[0][2] * sub_factor14 + m[0][3] * sub_factor15); + adj[1][3] = (m[0][0] * sub_factor13 - m[0][2] * sub_factor16 + m[0][3] * sub_factor17); + adj[2][3] = - (m[0][0] * sub_factor14 - m[0][1] * sub_factor16 + m[0][3] * sub_factor18); + adj[3][3] = (m[0][0] * sub_factor15 - m[0][1] * sub_factor17 + m[0][2] * sub_factor18); + + let det = (m[0][0] * adj[0][0] + m[0][1] * adj[1][0] + m[0][2] * adj[2][0] + m[0][3] * adj[3][0]); + + return adj * (1 / det); +} + +fn _naga_inverse_3x3_f32(m: mat3x3) -> mat3x3 { + var adj: mat3x3; + + adj[0][0] = (m[1][1] * m[2][2] - m[2][1] * m[1][2]); + adj[1][0] = - (m[1][0] * m[2][2] - m[2][0] * m[1][2]); + adj[2][0] = (m[1][0] * m[2][1] - m[2][0] * m[1][1]); + adj[0][1] = - (m[0][1] * m[2][2] - m[2][1] * m[0][2]); + adj[1][1] = (m[0][0] * m[2][2] - m[2][0] * m[0][2]); + adj[2][1] = - (m[0][0] * m[2][1] - m[2][0] * m[0][1]); + adj[0][2] = (m[0][1] * m[1][2] - m[1][1] * m[0][2]); + adj[1][2] = - (m[0][0] * m[1][2] - m[1][0] * m[0][2]); + adj[2][2] = (m[0][0] * m[1][1] - m[1][0] * m[0][1]); + + let det: f32 = (m[0][0] * (m[1][1] * m[2][2] - m[1][2] * m[2][1]) + - m[0][1] * (m[1][0] * m[2][2] - m[1][2] * m[2][0]) + + m[0][2] * (m[1][0] * m[2][1] - m[1][1] * m[2][0])); + + return adj * (1 / det); +} + +fn _naga_inverse_2x2_f32(m: mat2x2) -> mat2x2 { + var adj: mat2x2; + adj[0][0] = m[1][1]; + adj[0][1] = -m[0][1]; + adj[1][0] = -m[1][0]; + adj[1][1] = m[0][0]; + + let det: f32 = m[0][0] * m[1][1] - m[1][0] * m[0][1]; + return adj * (1 / det); +} From d034c4b4282eab7e44425304a1133117d52918cf Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Wed, 9 Oct 2024 14:08:15 -0700 Subject: [PATCH 19/67] [naga spv-out] Move code to load a pointer into its own function. Introduce a new function, `naga::back::spv::BlockContext::write_checked_load`, that does the work of `Expression::Load`. This change is just code motion, and should have no effect on behavior. The new function will be used in later commits. --- naga/src/back/spv/block.rs | 114 ++++++++++++++++++++----------------- 1 file changed, 62 insertions(+), 52 deletions(-) diff --git a/naga/src/back/spv/block.rs b/naga/src/back/spv/block.rs index 6161fa0899..2e342295e3 100644 --- a/naga/src/back/spv/block.rs +++ b/naga/src/back/spv/block.rs @@ -1355,58 +1355,7 @@ impl<'w> BlockContext<'w> { } crate::Expression::LocalVariable(variable) => self.function.variables[&variable].id, crate::Expression::Load { pointer } => { - match self.write_expression_pointer(pointer, block, None)? { - ExpressionPointer::Ready { pointer_id } => { - let id = self.gen_id(); - let atomic_space = - match *self.fun_info[pointer].ty.inner_with(&self.ir_module.types) { - crate::TypeInner::Pointer { base, space } => { - match self.ir_module.types[base].inner { - crate::TypeInner::Atomic { .. } => Some(space), - _ => None, - } - } - _ => None, - }; - let instruction = if let Some(space) = atomic_space { - let (semantics, scope) = space.to_spirv_semantics_and_scope(); - let scope_constant_id = self.get_scope_constant(scope as u32); - let semantics_id = self.get_index_constant(semantics.bits()); - Instruction::atomic_load( - result_type_id, - id, - pointer_id, - scope_constant_id, - semantics_id, - ) - } else { - Instruction::load(result_type_id, id, pointer_id, None) - }; - block.body.push(instruction); - id - } - ExpressionPointer::Conditional { condition, access } => { - //TODO: support atomics? - self.write_conditional_indexed_load( - result_type_id, - condition, - block, - move |id_gen, block| { - // The in-bounds path. Perform the access and the load. - let pointer_id = access.result_id.unwrap(); - let value_id = id_gen.next(); - block.body.push(access); - block.body.push(Instruction::load( - result_type_id, - value_id, - pointer_id, - None, - )); - value_id - }, - ) - } - } + self.write_checked_load(pointer, block, result_type_id)? } crate::Expression::FunctionArgument(index) => self.function.parameter_id(index), crate::Expression::CallResult(_) @@ -1947,6 +1896,67 @@ impl<'w> BlockContext<'w> { } } + fn write_checked_load( + &mut self, + pointer: Handle, + block: &mut Block, + result_type_id: Word, + ) -> Result { + match self.write_expression_pointer(pointer, block, None)? { + ExpressionPointer::Ready { pointer_id } => { + let id = self.gen_id(); + let atomic_space = + match *self.fun_info[pointer].ty.inner_with(&self.ir_module.types) { + crate::TypeInner::Pointer { base, space } => { + match self.ir_module.types[base].inner { + crate::TypeInner::Atomic { .. } => Some(space), + _ => None, + } + } + _ => None, + }; + let instruction = if let Some(space) = atomic_space { + let (semantics, scope) = space.to_spirv_semantics_and_scope(); + let scope_constant_id = self.get_scope_constant(scope as u32); + let semantics_id = self.get_index_constant(semantics.bits()); + Instruction::atomic_load( + result_type_id, + id, + pointer_id, + scope_constant_id, + semantics_id, + ) + } else { + Instruction::load(result_type_id, id, pointer_id, None) + }; + block.body.push(instruction); + Ok(id) + } + ExpressionPointer::Conditional { condition, access } => { + //TODO: support atomics? + let value = self.write_conditional_indexed_load( + result_type_id, + condition, + block, + move |id_gen, block| { + // The in-bounds path. Perform the access and the load. + let pointer_id = access.result_id.unwrap(); + let value_id = id_gen.next(); + block.body.push(access); + block.body.push(Instruction::load( + result_type_id, + value_id, + pointer_id, + None, + )); + value_id + }, + ); + Ok(value) + } + } + } + /// Build the instructions for matrix - matrix column operations #[allow(clippy::too_many_arguments)] fn write_matrix_matrix_column_op( From b9f1e4a26618c1e347e5fa19a8e4812e64d14225 Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Thu, 10 Oct 2024 12:05:28 -0700 Subject: [PATCH 20/67] [naga spv-out] Clean up `write_expression_pointer` type adjustment. Replace the `return_type_override` argument of `BlockContext::write_expression_pointer` with an enum that says how to derive the return type from `expr_handle`'s type. Introduce a new type, `AccessTypeAdjustment`, that covers possible derivation rules. This simplifies callers and the callee, in part by making the possible alternatives less general, and by giving them explicit names (the variants of the `AccessTypeAdjustment` enum). --- naga/src/back/spv/block.rs | 146 ++++++++++++++++++++++++------------- 1 file changed, 94 insertions(+), 52 deletions(-) diff --git a/naga/src/back/spv/block.rs b/naga/src/back/spv/block.rs index 2e342295e3..72c2778c7d 100644 --- a/naga/src/back/spv/block.rs +++ b/naga/src/back/spv/block.rs @@ -3,7 +3,7 @@ Implementations for `BlockContext` methods. */ use super::{ - helpers, index::BoundsCheckResult, selection::Selection, Block, BlockContext, Dimension, Error, + index::BoundsCheckResult, selection::Selection, Block, BlockContext, Dimension, Error, Instruction, LocalType, LookupType, NumericType, ResultMember, Writer, WriterFlags, }; use crate::{arena::Handle, proc::TypeResolution, Statement}; @@ -18,6 +18,54 @@ fn get_dimension(type_inner: &crate::TypeInner) -> Dimension { } } +/// How to derive the type of `OpAccessChain` instructions from Naga IR. +/// +/// Most of the time, we compile Naga IR to SPIR-V instructions whose result +/// types are simply the direct SPIR-V analog of the Naga IR's. But in some +/// cases, the Naga IR and SPIR-V types need to diverge. +/// +/// This enum specifies how [`BlockContext::write_expression_pointer`] should +/// choose a SPIR-V result type for the `OpAccessChain` it generates, based on +/// the type of the given Naga IR [`Expression`] it's generating code for. +/// +/// [`Expression`]: crate::Expression +enum AccessTypeAdjustment { + /// No adjustment needed: the SPIR-V type should be the direct + /// analog of the Naga IR expression type. + /// + /// For most access chains, this is the right thing: the Naga IR access + /// expression produces a [`Pointer`] to the element / component, and the + /// SPIR-V `OpAccessChain` instruction does the same. + /// + /// [`Pointer`]: crate::TypeInner::Pointer + None, + + /// The SPIR-V type should be an `OpPointer` to the direct analog of the + /// Naga IR expression's type. + /// + /// This is necessary for indexing binding arrays in the [`Handle`] address + /// space: + /// + /// - In Naga IR, referencing a binding array [`GlobalVariable`] in the + /// [`Handle`] address space produces a value of type [`BindingArray`], + /// not a pointer to such. And [`Access`] and [`AccessIndex`] expressions + /// operate on handle binding arrays by value, and produce handle values, + /// not pointers. + /// + /// - In SPIR-V, a binding array `OpVariable` produces a pointer to an + /// array, and `OpAccessChain` instructions operate on pointers, + /// regardless of whether the elements are opaque types or not. + /// + /// See also the documentation for [`BindingArray`]. + /// + /// [`Handle`]: crate::AddressSpace::Handle + /// [`GlobalVariable`]: crate::GlobalVariable + /// [`BindingArray`]: crate::TypeInner::BindingArray + /// [`Access`]: crate::Expression::Access + /// [`AccessIndex`]: crate::Expression::AccessIndex + IntroducePointer(spirv::StorageClass), +} + /// The results of emitting code for a left-hand-side expression. /// /// On success, `write_expression_pointer` returns one of these. @@ -301,21 +349,12 @@ impl<'w> BlockContext<'w> { crate::TypeInner::BindingArray { base: binding_type, .. } => { - let space = match self.ir_function.expressions[base] { - crate::Expression::GlobalVariable(gvar) => { - self.ir_module.global_variables[gvar].space - } - _ => unreachable!(), - }; - let binding_array_false_pointer = LookupType::Local(LocalType::Pointer { - base: binding_type, - class: helpers::map_storage_class(space), - }); - let result_id = match self.write_expression_pointer( expr_handle, block, - Some(binding_array_false_pointer), + AccessTypeAdjustment::IntroducePointer( + spirv::StorageClass::UniformConstant, + ), )? { ExpressionPointer::Ready { pointer_id } => pointer_id, ExpressionPointer::Conditional { .. } => { @@ -414,21 +453,12 @@ impl<'w> BlockContext<'w> { crate::TypeInner::BindingArray { base: binding_type, .. } => { - let space = match self.ir_function.expressions[base] { - crate::Expression::GlobalVariable(gvar) => { - self.ir_module.global_variables[gvar].space - } - _ => unreachable!(), - }; - let binding_array_false_pointer = LookupType::Local(LocalType::Pointer { - base: binding_type, - class: helpers::map_storage_class(space), - }); - let result_id = match self.write_expression_pointer( expr_handle, block, - Some(binding_array_false_pointer), + AccessTypeAdjustment::IntroducePointer( + spirv::StorageClass::UniformConstant, + ), )? { ExpressionPointer::Ready { pointer_id } => pointer_id, ExpressionPointer::Conditional { .. } => { @@ -1670,9 +1700,9 @@ impl<'w> BlockContext<'w> { /// /// Emit any needed bounds-checking expressions to `block`. /// - /// Some cases we need to generate a different return type than what the IR gives us. - /// This is because pointers to binding arrays of handles (such as images or samplers) - /// don't exist in the IR, but we need to create them to create an access chain in SPIRV. + /// Give the `OpAccessChain` a result type based on `expr_handle`, adjusted + /// according to `type_adjustment`; see the documentation for + /// [`AccessTypeAdjustment`] for details. /// /// On success, the return value is an [`ExpressionPointer`] value; see the /// documentation for that type. @@ -1680,21 +1710,22 @@ impl<'w> BlockContext<'w> { &mut self, mut expr_handle: Handle, block: &mut Block, - return_type_override: Option, + type_adjustment: AccessTypeAdjustment, ) -> Result { - let result_lookup_ty = match self.fun_info[expr_handle].ty { - TypeResolution::Handle(ty_handle) => match return_type_override { - // We use the return type override as a special case for handle binding arrays as the OpAccessChain - // needs to return a pointer, but indexing into a handle binding array just gives you the type of - // the binding in the IR. - Some(ty) => ty, - None => LookupType::Handle(ty_handle), - }, - TypeResolution::Value(ref inner) => { - LookupType::Local(LocalType::from_inner(inner).unwrap()) + let result_type_id = { + let resolution = &self.fun_info[expr_handle].ty; + match type_adjustment { + AccessTypeAdjustment::None => self.writer.get_expression_type_id(resolution), + AccessTypeAdjustment::IntroducePointer(class) => match *resolution { + TypeResolution::Handle(handle) => self.writer.get_pointer_id(handle, class), + TypeResolution::Value(_) => { + unreachable!( + "IntroducePointer should only be used with images and samplers" + ); + } + }, } }; - let result_type_id = self.get_type_id(result_lookup_ty); // The id of the boolean `and` of all dynamic bounds checks up to this point. // @@ -1902,7 +1933,7 @@ impl<'w> BlockContext<'w> { block: &mut Block, result_type_id: Word, ) -> Result { - match self.write_expression_pointer(pointer, block, None)? { + match self.write_expression_pointer(pointer, block, AccessTypeAdjustment::None)? { ExpressionPointer::Ready { pointer_id } => { let id = self.gen_id(); let atomic_space = @@ -2458,7 +2489,11 @@ impl<'w> BlockContext<'w> { } Statement::Store { pointer, value } => { let value_id = self.cached[value]; - match self.write_expression_pointer(pointer, &mut block, None)? { + match self.write_expression_pointer( + pointer, + &mut block, + AccessTypeAdjustment::None, + )? { ExpressionPointer::Ready { pointer_id } => { let atomic_space = match *self.fun_info[pointer] .ty @@ -2554,15 +2589,18 @@ impl<'w> BlockContext<'w> { self.cached[result] = id; } - let pointer_id = - match self.write_expression_pointer(pointer, &mut block, None)? { - ExpressionPointer::Ready { pointer_id } => pointer_id, - ExpressionPointer::Conditional { .. } => { - return Err(Error::FeatureNotImplemented( - "Atomics out-of-bounds handling", - )); - } - }; + let pointer_id = match self.write_expression_pointer( + pointer, + &mut block, + AccessTypeAdjustment::None, + )? { + ExpressionPointer::Ready { pointer_id } => pointer_id, + ExpressionPointer::Conditional { .. } => { + return Err(Error::FeatureNotImplemented( + "Atomics out-of-bounds handling", + )); + } + }; let space = self.fun_info[pointer] .ty @@ -2723,7 +2761,11 @@ impl<'w> BlockContext<'w> { .write_barrier(crate::Barrier::WORK_GROUP, &mut block); let result_type_id = self.get_expression_type_id(&self.fun_info[result].ty); // Embed the body of - match self.write_expression_pointer(pointer, &mut block, None)? { + match self.write_expression_pointer( + pointer, + &mut block, + AccessTypeAdjustment::None, + )? { ExpressionPointer::Ready { pointer_id } => { let id = self.gen_id(); block.body.push(Instruction::load( From f9075fc4b84f0bf73322e582f93e8b0d07e1e919 Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Tue, 8 Oct 2024 16:32:36 -0700 Subject: [PATCH 21/67] [naga] Test access to a member/element through a pointer. --- naga/tests/in/access.wgsl | 32 + naga/tests/out/analysis/access.info.ron | 277 ++++++ .../access.assign_through_ptr.Compute.glsl | 23 + ...cess.assign_to_ptr_components.Compute.glsl | 78 ++ naga/tests/out/glsl/access.foo.Vertex.glsl | 23 + .../out/glsl/access.foo_frag.Fragment.glsl | 23 + .../out/glsl/access.foo_vert.Vertex.glsl | 23 + naga/tests/out/hlsl/access.hlsl | 41 + naga/tests/out/hlsl/access.ron | 4 + naga/tests/out/ir/access.compact.ron | 245 +++++ naga/tests/out/ir/access.ron | 245 +++++ naga/tests/out/msl/access.msl | 46 + naga/tests/out/spv/access.spvasm | 847 ++++++++++-------- naga/tests/out/wgsl/access.wgsl | 36 + 14 files changed, 1557 insertions(+), 386 deletions(-) create mode 100644 naga/tests/out/glsl/access.assign_to_ptr_components.Compute.glsl diff --git a/naga/tests/in/access.wgsl b/naga/tests/in/access.wgsl index 3336522fd9..6ff68a13ea 100644 --- a/naga/tests/in/access.wgsl +++ b/naga/tests/in/access.wgsl @@ -178,3 +178,35 @@ fn foo(@builtin(vertex_index) vi: u32) -> @builtin(position) vec4 { fn array_by_value(a: array, i: i32) -> i32 { return a[i]; } + + +struct AssignToMember { + x: u32, +} + +fn fetch_arg_ptr_member(p: ptr) -> u32 { + return (*p).x; +} + +fn assign_to_arg_ptr_member(p: ptr) { + (*p).x = 10u; +} + +fn fetch_arg_ptr_array_element(p: ptr>) -> u32 { + return (*p)[1]; +} + +fn assign_to_arg_ptr_array_element(p: ptr>) { + (*p)[1] = 10u; +} + +@compute @workgroup_size(1) +fn assign_to_ptr_components() { + var s1: AssignToMember; + assign_to_arg_ptr_member(&s1); + fetch_arg_ptr_member(&s1); + + var a1: array; + assign_to_arg_ptr_array_element(&a1); + fetch_arg_ptr_array_element(&a1); +} diff --git a/naga/tests/out/analysis/access.info.ron b/naga/tests/out/analysis/access.info.ron index 830831cb1f..8c87ce6010 100644 --- a/naga/tests/out/analysis/access.info.ron +++ b/naga/tests/out/analysis/access.info.ron @@ -29,6 +29,10 @@ ("SIZED | COPY | ARGUMENT"), ("DATA | SIZED | COPY | HOST_SHAREABLE | ARGUMENT | CONSTRUCTIBLE"), ("SIZED | COPY | ARGUMENT"), + ("DATA | SIZED | COPY | IO_SHAREABLE | HOST_SHAREABLE | ARGUMENT | CONSTRUCTIBLE"), + ("SIZED | COPY | ARGUMENT"), + ("DATA | SIZED | COPY | HOST_SHAREABLE | ARGUMENT | CONSTRUCTIBLE"), + ("SIZED | COPY | ARGUMENT"), ], functions: [ ( @@ -2783,6 +2787,216 @@ sampling: [], dual_source_blending: false, ), + ( + flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), + available_stages: ("VERTEX | FRAGMENT | COMPUTE"), + uniformity: ( + non_uniform_result: Some(0), + requirements: (""), + ), + may_kill: false, + sampling_set: [], + global_uses: [ + (""), + (""), + (""), + (""), + (""), + ], + expressions: [ + ( + uniformity: ( + non_uniform_result: Some(0), + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Handle(30), + ), + ( + uniformity: ( + non_uniform_result: Some(0), + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Pointer( + base: 0, + space: Function, + )), + ), + ( + uniformity: ( + non_uniform_result: Some(0), + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Handle(0), + ), + ], + sampling: [], + dual_source_blending: false, + ), + ( + flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), + available_stages: ("VERTEX | FRAGMENT | COMPUTE"), + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + may_kill: false, + sampling_set: [], + global_uses: [ + (""), + (""), + (""), + (""), + (""), + ], + expressions: [ + ( + uniformity: ( + non_uniform_result: Some(0), + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Handle(30), + ), + ( + uniformity: ( + non_uniform_result: Some(0), + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Pointer( + base: 0, + space: Function, + )), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Scalar(( + kind: Uint, + width: 4, + ))), + ), + ], + sampling: [], + dual_source_blending: false, + ), + ( + flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), + available_stages: ("VERTEX | FRAGMENT | COMPUTE"), + uniformity: ( + non_uniform_result: Some(0), + requirements: (""), + ), + may_kill: false, + sampling_set: [], + global_uses: [ + (""), + (""), + (""), + (""), + (""), + ], + expressions: [ + ( + uniformity: ( + non_uniform_result: Some(0), + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Handle(32), + ), + ( + uniformity: ( + non_uniform_result: Some(0), + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Pointer( + base: 0, + space: Function, + )), + ), + ( + uniformity: ( + non_uniform_result: Some(0), + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Handle(0), + ), + ], + sampling: [], + dual_source_blending: false, + ), + ( + flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), + available_stages: ("VERTEX | FRAGMENT | COMPUTE"), + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + may_kill: false, + sampling_set: [], + global_uses: [ + (""), + (""), + (""), + (""), + (""), + ], + expressions: [ + ( + uniformity: ( + non_uniform_result: Some(0), + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Handle(32), + ), + ( + uniformity: ( + non_uniform_result: Some(0), + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Pointer( + base: 0, + space: Function, + )), + ), + ( + uniformity: ( + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Value(Scalar(( + kind: Uint, + width: 4, + ))), + ), + ], + sampling: [], + dual_source_blending: false, + ), ], entry_points: [ ( @@ -4167,6 +4381,69 @@ sampling: [], dual_source_blending: false, ), + ( + flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), + available_stages: ("VERTEX | FRAGMENT | COMPUTE"), + uniformity: ( + non_uniform_result: Some(0), + requirements: (""), + ), + may_kill: false, + sampling_set: [], + global_uses: [ + (""), + (""), + (""), + (""), + (""), + ], + expressions: [ + ( + uniformity: ( + non_uniform_result: Some(0), + requirements: (""), + ), + ref_count: 2, + assignable_global: None, + ty: Value(Pointer( + base: 29, + space: Function, + )), + ), + ( + uniformity: ( + non_uniform_result: Some(0), + requirements: (""), + ), + ref_count: 0, + assignable_global: None, + ty: Handle(0), + ), + ( + uniformity: ( + non_uniform_result: Some(2), + requirements: (""), + ), + ref_count: 2, + assignable_global: None, + ty: Value(Pointer( + base: 31, + space: Function, + )), + ), + ( + uniformity: ( + non_uniform_result: Some(0), + requirements: (""), + ), + ref_count: 0, + assignable_global: None, + ty: Handle(0), + ), + ], + sampling: [], + dual_source_blending: false, + ), ], const_expression_types: [ Value(Scalar(( diff --git a/naga/tests/out/glsl/access.assign_through_ptr.Compute.glsl b/naga/tests/out/glsl/access.assign_through_ptr.Compute.glsl index 4a4791c994..07f69f749e 100644 --- a/naga/tests/out/glsl/access.assign_through_ptr.Compute.glsl +++ b/naga/tests/out/glsl/access.assign_through_ptr.Compute.glsl @@ -19,6 +19,9 @@ struct Baz { struct MatCx2InArray { mat4x2 am[2]; }; +struct AssignToMember { + uint x; +}; float read_from_private(inout float foo_2) { float _e1 = foo_2; @@ -43,6 +46,26 @@ int array_by_value(int a_1[5], int i) { return a_1[i]; } +uint fetch_arg_ptr_member(inout AssignToMember p_1) { + uint _e2 = p_1.x; + return _e2; +} + +void assign_to_arg_ptr_member(inout AssignToMember p_2) { + p_2.x = 10u; + return; +} + +uint fetch_arg_ptr_array_element(inout uint p_3[4]) { + uint _e2 = p_3[1]; + return _e2; +} + +void assign_to_arg_ptr_array_element(inout uint p_4[4]) { + p_4[1] = 10u; + return; +} + void main() { uint val = 33u; vec4 arr[2] = vec4[2](vec4(6.0), vec4(7.0)); diff --git a/naga/tests/out/glsl/access.assign_to_ptr_components.Compute.glsl b/naga/tests/out/glsl/access.assign_to_ptr_components.Compute.glsl new file mode 100644 index 0000000000..1f072735ea --- /dev/null +++ b/naga/tests/out/glsl/access.assign_to_ptr_components.Compute.glsl @@ -0,0 +1,78 @@ +#version 310 es + +precision highp float; +precision highp int; + +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +struct GlobalConst { + uint a; + uvec3 b; + int c; +}; +struct AlignedWrapper { + int value; +}; +struct Baz { + mat3x2 m; +}; +struct MatCx2InArray { + mat4x2 am[2]; +}; +struct AssignToMember { + uint x; +}; + +float read_from_private(inout float foo_2) { + float _e1 = foo_2; + return _e1; +} + +float test_arr_as_arg(float a[5][10]) { + return a[4][9]; +} + +void assign_through_ptr_fn(inout uint p) { + p = 42u; + return; +} + +void assign_array_through_ptr_fn(inout vec4 foo_3[2]) { + foo_3 = vec4[2](vec4(1.0), vec4(2.0)); + return; +} + +int array_by_value(int a_1[5], int i) { + return a_1[i]; +} + +uint fetch_arg_ptr_member(inout AssignToMember p_1) { + uint _e2 = p_1.x; + return _e2; +} + +void assign_to_arg_ptr_member(inout AssignToMember p_2) { + p_2.x = 10u; + return; +} + +uint fetch_arg_ptr_array_element(inout uint p_3[4]) { + uint _e2 = p_3[1]; + return _e2; +} + +void assign_to_arg_ptr_array_element(inout uint p_4[4]) { + p_4[1] = 10u; + return; +} + +void main() { + AssignToMember s1_ = AssignToMember(0u); + uint a1_[4] = uint[4](0u, 0u, 0u, 0u); + assign_to_arg_ptr_member(s1_); + uint _e1 = fetch_arg_ptr_member(s1_); + assign_to_arg_ptr_array_element(a1_); + uint _e3 = fetch_arg_ptr_array_element(a1_); + return; +} + diff --git a/naga/tests/out/glsl/access.foo.Vertex.glsl b/naga/tests/out/glsl/access.foo.Vertex.glsl index e1f3138403..aa2ce8b837 100644 --- a/naga/tests/out/glsl/access.foo.Vertex.glsl +++ b/naga/tests/out/glsl/access.foo.Vertex.glsl @@ -17,6 +17,9 @@ struct Baz { struct MatCx2InArray { mat4x2 am[2]; }; +struct AssignToMember { + uint x; +}; float read_from_private(inout float foo_2) { float _e1 = foo_2; @@ -41,6 +44,26 @@ int array_by_value(int a_1[5], int i) { return a_1[i]; } +uint fetch_arg_ptr_member(inout AssignToMember p_1) { + uint _e2 = p_1.x; + return _e2; +} + +void assign_to_arg_ptr_member(inout AssignToMember p_2) { + p_2.x = 10u; + return; +} + +uint fetch_arg_ptr_array_element(inout uint p_3[4]) { + uint _e2 = p_3[1]; + return _e2; +} + +void assign_to_arg_ptr_array_element(inout uint p_4[4]) { + p_4[1] = 10u; + return; +} + void main() { uint vi_1 = uint(gl_VertexID); int arr_1[5] = int[5](1, 2, 3, 4, 5); diff --git a/naga/tests/out/glsl/access.foo_frag.Fragment.glsl b/naga/tests/out/glsl/access.foo_frag.Fragment.glsl index eca6bc54c5..9775b903c7 100644 --- a/naga/tests/out/glsl/access.foo_frag.Fragment.glsl +++ b/naga/tests/out/glsl/access.foo_frag.Fragment.glsl @@ -17,6 +17,9 @@ struct Baz { struct MatCx2InArray { mat4x2 am[2]; }; +struct AssignToMember { + uint x; +}; layout(std430) buffer Bar_block_0Fragment { mat4x3 _matrix; mat2x2 matrix_array[2]; @@ -53,6 +56,26 @@ int array_by_value(int a_1[5], int i) { return a_1[i]; } +uint fetch_arg_ptr_member(inout AssignToMember p_1) { + uint _e2 = p_1.x; + return _e2; +} + +void assign_to_arg_ptr_member(inout AssignToMember p_2) { + p_2.x = 10u; + return; +} + +uint fetch_arg_ptr_array_element(inout uint p_3[4]) { + uint _e2 = p_3[1]; + return _e2; +} + +void assign_to_arg_ptr_array_element(inout uint p_4[4]) { + p_4[1] = 10u; + return; +} + void main() { _group_0_binding_0_fs._matrix[1][2] = 1.0; _group_0_binding_0_fs._matrix = mat4x3(vec3(0.0), vec3(1.0), vec3(2.0), vec3(3.0)); diff --git a/naga/tests/out/glsl/access.foo_vert.Vertex.glsl b/naga/tests/out/glsl/access.foo_vert.Vertex.glsl index a926eadf78..d5dc00194a 100644 --- a/naga/tests/out/glsl/access.foo_vert.Vertex.glsl +++ b/naga/tests/out/glsl/access.foo_vert.Vertex.glsl @@ -17,6 +17,9 @@ struct Baz { struct MatCx2InArray { mat4x2 am[2]; }; +struct AssignToMember { + uint x; +}; layout(std430) buffer Bar_block_0Vertex { mat4x3 _matrix; mat2x2 matrix_array[2]; @@ -126,6 +129,26 @@ int array_by_value(int a_1[5], int i) { return a_1[i]; } +uint fetch_arg_ptr_member(inout AssignToMember p_1) { + uint _e2 = p_1.x; + return _e2; +} + +void assign_to_arg_ptr_member(inout AssignToMember p_2) { + p_2.x = 10u; + return; +} + +uint fetch_arg_ptr_array_element(inout uint p_3[4]) { + uint _e2 = p_3[1]; + return _e2; +} + +void assign_to_arg_ptr_array_element(inout uint p_4[4]) { + p_4[1] = 10u; + return; +} + void main() { uint vi = uint(gl_VertexID); float foo = 0.0; diff --git a/naga/tests/out/hlsl/access.hlsl b/naga/tests/out/hlsl/access.hlsl index 543b841967..240b720786 100644 --- a/naga/tests/out/hlsl/access.hlsl +++ b/naga/tests/out/hlsl/access.hlsl @@ -68,6 +68,10 @@ struct MatCx2InArray { __mat4x2 am[2]; }; +struct AssignToMember { + uint x; +}; + GlobalConst ConstructGlobalConst(uint arg0, uint3 arg1, int arg2) { GlobalConst ret = (GlobalConst)0; ret.a = arg0; @@ -235,6 +239,30 @@ int array_by_value(int a_1[5], int i) return a_1[i]; } +uint fetch_arg_ptr_member(inout AssignToMember p_1) +{ + uint _e2 = p_1.x; + return _e2; +} + +void assign_to_arg_ptr_member(inout AssignToMember p_2) +{ + p_2.x = 10u; + return; +} + +uint fetch_arg_ptr_array_element(inout uint p_3[4]) +{ + uint _e2 = p_3[1]; + return _e2; +} + +void assign_to_arg_ptr_array_element(inout uint p_4[4]) +{ + p_4[1] = 10u; + return; +} + typedef int ret_Constructarray5_int_[5]; ret_Constructarray5_int_ Constructarray5_int_(int arg0, int arg1, int arg2, int arg3, int arg4) { int ret[5] = { arg0, arg1, arg2, arg3, arg4 }; @@ -322,3 +350,16 @@ float4 foo_1(uint vi_1 : SV_VertexID) : SV_Position int value_1 = arr_2[vi_1]; return float4((value_1).xxxx); } + +[numthreads(1, 1, 1)] +void assign_to_ptr_components() +{ + AssignToMember s1_ = (AssignToMember)0; + uint a1_[4] = (uint[4])0; + + assign_to_arg_ptr_member(s1_); + const uint _e1 = fetch_arg_ptr_member(s1_); + assign_to_arg_ptr_array_element(a1_); + const uint _e3 = fetch_arg_ptr_array_element(a1_); + return; +} diff --git a/naga/tests/out/hlsl/access.ron b/naga/tests/out/hlsl/access.ron index 8960a612ed..1514e55c55 100644 --- a/naga/tests/out/hlsl/access.ron +++ b/naga/tests/out/hlsl/access.ron @@ -20,5 +20,9 @@ entry_point:"assign_through_ptr", target_profile:"cs_5_1", ), + ( + entry_point:"assign_to_ptr_components", + target_profile:"cs_5_1", + ), ], ) diff --git a/naga/tests/out/ir/access.compact.ron b/naga/tests/out/ir/access.compact.ron index 2d066b8ffa..db108801c0 100644 --- a/naga/tests/out/ir/access.compact.ron +++ b/naga/tests/out/ir/access.compact.ron @@ -317,6 +317,42 @@ space: Function, ), ), + ( + name: Some("AssignToMember"), + inner: Struct( + members: [ + ( + name: Some("x"), + ty: 0, + binding: None, + offset: 0, + ), + ], + span: 4, + ), + ), + ( + name: None, + inner: Pointer( + base: 29, + space: Function, + ), + ), + ( + name: None, + inner: Array( + base: 0, + size: Constant(4), + stride: 4, + ), + ), + ( + name: None, + inner: Pointer( + base: 31, + space: Function, + ), + ), ], special_types: ( ray_desc: None, @@ -1696,6 +1732,152 @@ ), ], ), + ( + name: Some("fetch_arg_ptr_member"), + arguments: [ + ( + name: Some("p"), + ty: 30, + binding: None, + ), + ], + result: Some(( + ty: 0, + binding: None, + )), + local_variables: [], + expressions: [ + FunctionArgument(0), + AccessIndex( + base: 0, + index: 0, + ), + Load( + pointer: 1, + ), + ], + named_expressions: { + 0: "p", + }, + body: [ + Emit(( + start: 1, + end: 3, + )), + Return( + value: Some(2), + ), + ], + ), + ( + name: Some("assign_to_arg_ptr_member"), + arguments: [ + ( + name: Some("p"), + ty: 30, + binding: None, + ), + ], + result: None, + local_variables: [], + expressions: [ + FunctionArgument(0), + AccessIndex( + base: 0, + index: 0, + ), + Literal(U32(10)), + ], + named_expressions: { + 0: "p", + }, + body: [ + Emit(( + start: 1, + end: 2, + )), + Store( + pointer: 1, + value: 2, + ), + Return( + value: None, + ), + ], + ), + ( + name: Some("fetch_arg_ptr_array_element"), + arguments: [ + ( + name: Some("p"), + ty: 32, + binding: None, + ), + ], + result: Some(( + ty: 0, + binding: None, + )), + local_variables: [], + expressions: [ + FunctionArgument(0), + AccessIndex( + base: 0, + index: 1, + ), + Load( + pointer: 1, + ), + ], + named_expressions: { + 0: "p", + }, + body: [ + Emit(( + start: 1, + end: 3, + )), + Return( + value: Some(2), + ), + ], + ), + ( + name: Some("assign_to_arg_ptr_array_element"), + arguments: [ + ( + name: Some("p"), + ty: 32, + binding: None, + ), + ], + result: None, + local_variables: [], + expressions: [ + FunctionArgument(0), + AccessIndex( + base: 0, + index: 1, + ), + Literal(U32(10)), + ], + named_expressions: { + 0: "p", + }, + body: [ + Emit(( + start: 1, + end: 2, + )), + Store( + pointer: 1, + value: 2, + ), + Return( + value: None, + ), + ], + ), ], entry_points: [ ( @@ -2347,5 +2529,68 @@ ], ), ), + ( + name: "assign_to_ptr_components", + stage: Compute, + early_depth_test: None, + workgroup_size: (1, 1, 1), + function: ( + name: Some("assign_to_ptr_components"), + arguments: [], + result: None, + local_variables: [ + ( + name: Some("s1"), + ty: 29, + init: None, + ), + ( + name: Some("a1"), + ty: 31, + init: None, + ), + ], + expressions: [ + LocalVariable(0), + CallResult(7), + LocalVariable(1), + CallResult(9), + ], + named_expressions: {}, + body: [ + Call( + function: 8, + arguments: [ + 0, + ], + result: None, + ), + Call( + function: 7, + arguments: [ + 0, + ], + result: Some(1), + ), + Call( + function: 10, + arguments: [ + 2, + ], + result: None, + ), + Call( + function: 9, + arguments: [ + 2, + ], + result: Some(3), + ), + Return( + value: None, + ), + ], + ), + ), ], ) \ No newline at end of file diff --git a/naga/tests/out/ir/access.ron b/naga/tests/out/ir/access.ron index 2d066b8ffa..db108801c0 100644 --- a/naga/tests/out/ir/access.ron +++ b/naga/tests/out/ir/access.ron @@ -317,6 +317,42 @@ space: Function, ), ), + ( + name: Some("AssignToMember"), + inner: Struct( + members: [ + ( + name: Some("x"), + ty: 0, + binding: None, + offset: 0, + ), + ], + span: 4, + ), + ), + ( + name: None, + inner: Pointer( + base: 29, + space: Function, + ), + ), + ( + name: None, + inner: Array( + base: 0, + size: Constant(4), + stride: 4, + ), + ), + ( + name: None, + inner: Pointer( + base: 31, + space: Function, + ), + ), ], special_types: ( ray_desc: None, @@ -1696,6 +1732,152 @@ ), ], ), + ( + name: Some("fetch_arg_ptr_member"), + arguments: [ + ( + name: Some("p"), + ty: 30, + binding: None, + ), + ], + result: Some(( + ty: 0, + binding: None, + )), + local_variables: [], + expressions: [ + FunctionArgument(0), + AccessIndex( + base: 0, + index: 0, + ), + Load( + pointer: 1, + ), + ], + named_expressions: { + 0: "p", + }, + body: [ + Emit(( + start: 1, + end: 3, + )), + Return( + value: Some(2), + ), + ], + ), + ( + name: Some("assign_to_arg_ptr_member"), + arguments: [ + ( + name: Some("p"), + ty: 30, + binding: None, + ), + ], + result: None, + local_variables: [], + expressions: [ + FunctionArgument(0), + AccessIndex( + base: 0, + index: 0, + ), + Literal(U32(10)), + ], + named_expressions: { + 0: "p", + }, + body: [ + Emit(( + start: 1, + end: 2, + )), + Store( + pointer: 1, + value: 2, + ), + Return( + value: None, + ), + ], + ), + ( + name: Some("fetch_arg_ptr_array_element"), + arguments: [ + ( + name: Some("p"), + ty: 32, + binding: None, + ), + ], + result: Some(( + ty: 0, + binding: None, + )), + local_variables: [], + expressions: [ + FunctionArgument(0), + AccessIndex( + base: 0, + index: 1, + ), + Load( + pointer: 1, + ), + ], + named_expressions: { + 0: "p", + }, + body: [ + Emit(( + start: 1, + end: 3, + )), + Return( + value: Some(2), + ), + ], + ), + ( + name: Some("assign_to_arg_ptr_array_element"), + arguments: [ + ( + name: Some("p"), + ty: 32, + binding: None, + ), + ], + result: None, + local_variables: [], + expressions: [ + FunctionArgument(0), + AccessIndex( + base: 0, + index: 1, + ), + Literal(U32(10)), + ], + named_expressions: { + 0: "p", + }, + body: [ + Emit(( + start: 1, + end: 2, + )), + Store( + pointer: 1, + value: 2, + ), + Return( + value: None, + ), + ], + ), ], entry_points: [ ( @@ -2347,5 +2529,68 @@ ], ), ), + ( + name: "assign_to_ptr_components", + stage: Compute, + early_depth_test: None, + workgroup_size: (1, 1, 1), + function: ( + name: Some("assign_to_ptr_components"), + arguments: [], + result: None, + local_variables: [ + ( + name: Some("s1"), + ty: 29, + init: None, + ), + ( + name: Some("a1"), + ty: 31, + init: None, + ), + ], + expressions: [ + LocalVariable(0), + CallResult(7), + LocalVariable(1), + CallResult(9), + ], + named_expressions: {}, + body: [ + Call( + function: 8, + arguments: [ + 0, + ], + result: None, + ), + Call( + function: 7, + arguments: [ + 0, + ], + result: Some(1), + ), + Call( + function: 10, + arguments: [ + 2, + ], + result: None, + ), + Call( + function: 9, + arguments: [ + 2, + ], + result: Some(3), + ), + Return( + value: None, + ), + ], + ), + ), ], ) \ No newline at end of file diff --git a/naga/tests/out/msl/access.msl b/naga/tests/out/msl/access.msl index 924b604e4c..1c0fb50f41 100644 --- a/naga/tests/out/msl/access.msl +++ b/naga/tests/out/msl/access.msl @@ -57,6 +57,12 @@ struct type_20 { struct type_22 { metal::float4 inner[2]; }; +struct AssignToMember { + uint x; +}; +struct type_25 { + uint inner[4]; +}; void test_matrix_within_struct_accesses( constant Baz& baz @@ -166,6 +172,34 @@ int array_by_value( return a_1.inner[i]; } +uint fetch_arg_ptr_member( + thread AssignToMember& p_1 +) { + uint _e2 = p_1.x; + return _e2; +} + +void assign_to_arg_ptr_member( + thread AssignToMember& p_2 +) { + p_2.x = 10u; + return; +} + +uint fetch_arg_ptr_array_element( + thread type_25& p_3 +) { + uint _e2 = p_3.inner[1]; + return _e2; +} + +void assign_to_arg_ptr_array_element( + thread type_25& p_4 +) { + p_4.inner[1] = 10u; + return; +} + struct foo_vertInput { }; struct foo_vertOutput { @@ -238,3 +272,15 @@ vertex foo_1Output foo_1( int value_1 = arr_2.inner[vi_1]; return foo_1Output { static_cast(metal::int4(value_1)) }; } + + +kernel void assign_to_ptr_components( +) { + AssignToMember s1_ = {}; + type_25 a1_ = {}; + assign_to_arg_ptr_member(s1_); + uint _e1 = fetch_arg_ptr_member(s1_); + assign_to_arg_ptr_array_element(a1_); + uint _e3 = fetch_arg_ptr_array_element(a1_); + return; +} diff --git a/naga/tests/out/spv/access.spvasm b/naga/tests/out/spv/access.spvasm index 6cb87a3b10..d572baa800 100644 --- a/naga/tests/out/spv/access.spvasm +++ b/naga/tests/out/spv/access.spvasm @@ -1,17 +1,19 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 323 +; Bound: 364 OpCapability Shader OpExtension "SPV_KHR_storage_buffer_storage_class" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint Vertex %229 "foo_vert" %224 %227 -OpEntryPoint Fragment %282 "foo_frag" %281 -OpEntryPoint GLCompute %300 "assign_through_ptr" -OpEntryPoint Vertex %314 "foo" %311 %313 -OpExecutionMode %282 OriginUpperLeft -OpExecutionMode %300 LocalSize 1 1 1 +OpEntryPoint Vertex %260 "foo_vert" %255 %258 +OpEntryPoint Fragment %312 "foo_frag" %311 +OpEntryPoint GLCompute %330 "assign_through_ptr" +OpEntryPoint Vertex %344 "foo" %341 %343 +OpEntryPoint GLCompute %354 "assign_to_ptr_components" +OpExecutionMode %312 OriginUpperLeft +OpExecutionMode %330 LocalSize 1 1 1 +OpExecutionMode %354 LocalSize 1 1 1 OpMemberName %6 0 "a" OpMemberName %6 1 "b" OpMemberName %6 2 "c" @@ -29,38 +31,51 @@ OpMemberName %22 0 "m" OpName %22 "Baz" OpMemberName %26 0 "am" OpName %26 "MatCx2InArray" -OpName %40 "global_const" -OpName %42 "bar" -OpName %44 "baz" -OpName %47 "qux" -OpName %50 "nested_mat_cx2" -OpName %54 "test_matrix_within_struct_accesses" -OpName %82 "idx" -OpName %84 "t" -OpName %130 "test_matrix_within_array_within_struct_accesses" -OpName %140 "idx" -OpName %141 "t" -OpName %187 "foo" -OpName %188 "read_from_private" -OpName %193 "a" -OpName %194 "test_arr_as_arg" -OpName %200 "p" -OpName %201 "assign_through_ptr_fn" -OpName %206 "foo" -OpName %207 "assign_array_through_ptr_fn" -OpName %214 "a" -OpName %215 "i" -OpName %216 "array_by_value" -OpName %224 "vi" -OpName %229 "foo_vert" -OpName %241 "foo" -OpName %242 "c2" -OpName %282 "foo_frag" -OpName %300 "assign_through_ptr" -OpName %305 "val" -OpName %306 "arr" -OpName %311 "vi" -OpName %314 "foo" +OpMemberName %36 0 "x" +OpName %36 "AssignToMember" +OpName %45 "global_const" +OpName %47 "bar" +OpName %49 "baz" +OpName %52 "qux" +OpName %55 "nested_mat_cx2" +OpName %59 "test_matrix_within_struct_accesses" +OpName %87 "idx" +OpName %89 "t" +OpName %135 "test_matrix_within_array_within_struct_accesses" +OpName %145 "idx" +OpName %146 "t" +OpName %192 "foo" +OpName %193 "read_from_private" +OpName %198 "a" +OpName %199 "test_arr_as_arg" +OpName %205 "p" +OpName %206 "assign_through_ptr_fn" +OpName %211 "foo" +OpName %212 "assign_array_through_ptr_fn" +OpName %219 "a" +OpName %220 "i" +OpName %221 "array_by_value" +OpName %229 "p" +OpName %230 "fetch_arg_ptr_member" +OpName %236 "p" +OpName %237 "assign_to_arg_ptr_member" +OpName %242 "p" +OpName %243 "fetch_arg_ptr_array_element" +OpName %249 "p" +OpName %250 "assign_to_arg_ptr_array_element" +OpName %255 "vi" +OpName %260 "foo_vert" +OpName %272 "foo" +OpName %273 "c2" +OpName %312 "foo_frag" +OpName %330 "assign_through_ptr" +OpName %335 "val" +OpName %336 "arr" +OpName %341 "vi" +OpName %344 "foo" +OpName %354 "assign_to_ptr_components" +OpName %355 "s1" +OpName %357 "a1" OpMemberDecorate %6 0 Offset 0 OpMemberDecorate %6 1 Offset 16 OpMemberDecorate %6 2 Offset 28 @@ -91,25 +106,27 @@ OpDecorate %28 ArrayStride 4 OpDecorate %29 ArrayStride 40 OpDecorate %32 ArrayStride 4 OpDecorate %34 ArrayStride 16 -OpDecorate %42 DescriptorSet 0 -OpDecorate %42 Binding 0 -OpDecorate %44 DescriptorSet 0 -OpDecorate %44 Binding 1 -OpDecorate %45 Block -OpMemberDecorate %45 0 Offset 0 +OpMemberDecorate %36 0 Offset 0 +OpDecorate %38 ArrayStride 4 OpDecorate %47 DescriptorSet 0 -OpDecorate %47 Binding 2 -OpDecorate %48 Block -OpMemberDecorate %48 0 Offset 0 -OpDecorate %50 DescriptorSet 0 -OpDecorate %50 Binding 3 -OpDecorate %51 Block -OpMemberDecorate %51 0 Offset 0 -OpDecorate %224 BuiltIn VertexIndex -OpDecorate %227 BuiltIn Position -OpDecorate %281 Location 0 -OpDecorate %311 BuiltIn VertexIndex -OpDecorate %313 BuiltIn Position +OpDecorate %47 Binding 0 +OpDecorate %49 DescriptorSet 0 +OpDecorate %49 Binding 1 +OpDecorate %50 Block +OpMemberDecorate %50 0 Offset 0 +OpDecorate %52 DescriptorSet 0 +OpDecorate %52 Binding 2 +OpDecorate %53 Block +OpMemberDecorate %53 0 Offset 0 +OpDecorate %55 DescriptorSet 0 +OpDecorate %55 Binding 3 +OpDecorate %56 Block +OpMemberDecorate %56 0 Offset 0 +OpDecorate %255 BuiltIn VertexIndex +OpDecorate %258 BuiltIn Position +OpDecorate %311 Location 0 +OpDecorate %341 BuiltIn VertexIndex +OpDecorate %343 BuiltIn Position %2 = OpTypeVoid %3 = OpTypeInt 32 0 %4 = OpTypeVector %3 3 @@ -144,357 +161,415 @@ OpDecorate %313 BuiltIn Position %33 = OpTypePointer Function %3 %34 = OpTypeArray %31 %14 %35 = OpTypePointer Function %34 -%36 = OpConstant %3 0 -%37 = OpConstantComposite %4 %36 %36 %36 -%38 = OpConstant %5 0 -%39 = OpConstantComposite %6 %36 %37 %38 -%41 = OpTypePointer Private %6 -%40 = OpVariable %41 Private %39 -%43 = OpTypePointer StorageBuffer %20 -%42 = OpVariable %43 StorageBuffer -%45 = OpTypeStruct %22 -%46 = OpTypePointer Uniform %45 -%44 = OpVariable %46 Uniform -%48 = OpTypeStruct %23 -%49 = OpTypePointer StorageBuffer %48 -%47 = OpVariable %49 StorageBuffer -%51 = OpTypeStruct %26 -%52 = OpTypePointer Uniform %51 -%50 = OpVariable %52 Uniform -%55 = OpTypeFunction %2 -%56 = OpTypePointer Uniform %22 -%58 = OpConstant %5 1 -%59 = OpConstant %8 1.0 -%60 = OpConstantComposite %12 %59 %59 -%61 = OpConstant %8 2.0 -%62 = OpConstantComposite %12 %61 %61 -%63 = OpConstant %8 3.0 -%64 = OpConstantComposite %12 %63 %63 -%65 = OpConstantComposite %21 %60 %62 %64 -%66 = OpConstantComposite %22 %65 -%67 = OpConstant %8 6.0 -%68 = OpConstantComposite %12 %67 %67 -%69 = OpConstant %8 5.0 -%70 = OpConstantComposite %12 %69 %69 -%71 = OpConstant %8 4.0 -%72 = OpConstantComposite %12 %71 %71 -%73 = OpConstantComposite %21 %68 %70 %72 -%74 = OpConstant %8 9.0 +%36 = OpTypeStruct %3 +%37 = OpTypePointer Function %36 +%39 = OpConstant %3 4 +%38 = OpTypeArray %3 %39 +%40 = OpTypePointer Function %38 +%41 = OpConstant %3 0 +%42 = OpConstantComposite %4 %41 %41 %41 +%43 = OpConstant %5 0 +%44 = OpConstantComposite %6 %41 %42 %43 +%46 = OpTypePointer Private %6 +%45 = OpVariable %46 Private %44 +%48 = OpTypePointer StorageBuffer %20 +%47 = OpVariable %48 StorageBuffer +%50 = OpTypeStruct %22 +%51 = OpTypePointer Uniform %50 +%49 = OpVariable %51 Uniform +%53 = OpTypeStruct %23 +%54 = OpTypePointer StorageBuffer %53 +%52 = OpVariable %54 StorageBuffer +%56 = OpTypeStruct %26 +%57 = OpTypePointer Uniform %56 +%55 = OpVariable %57 Uniform +%60 = OpTypeFunction %2 +%61 = OpTypePointer Uniform %22 +%63 = OpConstant %5 1 +%64 = OpConstant %8 1.0 +%65 = OpConstantComposite %12 %64 %64 +%66 = OpConstant %8 2.0 +%67 = OpConstantComposite %12 %66 %66 +%68 = OpConstant %8 3.0 +%69 = OpConstantComposite %12 %68 %68 +%70 = OpConstantComposite %21 %65 %67 %69 +%71 = OpConstantComposite %22 %70 +%72 = OpConstant %8 6.0 +%73 = OpConstantComposite %12 %72 %72 +%74 = OpConstant %8 5.0 %75 = OpConstantComposite %12 %74 %74 -%76 = OpConstant %8 90.0 +%76 = OpConstant %8 4.0 %77 = OpConstantComposite %12 %76 %76 -%78 = OpConstant %8 10.0 -%79 = OpConstant %8 20.0 -%80 = OpConstant %8 30.0 -%81 = OpConstant %8 40.0 -%83 = OpTypePointer Function %5 -%85 = OpTypePointer Function %22 -%89 = OpTypePointer Uniform %21 -%92 = OpTypePointer Uniform %12 -%98 = OpTypePointer Uniform %8 -%99 = OpConstant %3 1 -%114 = OpTypePointer Function %21 -%116 = OpTypePointer Function %12 -%120 = OpTypePointer Function %8 -%131 = OpTypePointer Uniform %26 -%133 = OpConstantNull %25 -%134 = OpConstantComposite %26 %133 -%135 = OpConstant %8 8.0 -%136 = OpConstantComposite %12 %135 %135 -%137 = OpConstant %8 7.0 -%138 = OpConstantComposite %12 %137 %137 -%139 = OpConstantComposite %24 %136 %138 %68 %70 -%142 = OpTypePointer Function %26 -%146 = OpTypePointer Uniform %25 -%149 = OpTypePointer Uniform %24 -%171 = OpTypePointer Function %25 -%173 = OpTypePointer Function %24 -%189 = OpTypeFunction %8 %27 -%195 = OpTypeFunction %8 %29 -%202 = OpTypeFunction %2 %33 -%203 = OpConstant %3 42 -%208 = OpTypeFunction %2 %35 -%209 = OpConstantComposite %31 %59 %59 %59 %59 -%210 = OpConstantComposite %31 %61 %61 %61 %61 -%211 = OpConstantComposite %34 %209 %210 -%217 = OpTypeFunction %5 %32 %5 -%219 = OpTypePointer Function %32 -%225 = OpTypePointer Input %3 -%224 = OpVariable %225 Input -%228 = OpTypePointer Output %31 -%227 = OpVariable %228 Output -%231 = OpTypePointer StorageBuffer %23 -%234 = OpConstant %8 0.0 -%235 = OpConstant %3 3 -%236 = OpConstant %5 3 -%237 = OpConstant %5 4 -%238 = OpConstant %5 5 -%239 = OpConstant %5 42 -%240 = OpConstantNull %29 -%243 = OpConstantNull %32 -%248 = OpTypePointer StorageBuffer %9 -%251 = OpTypePointer StorageBuffer %18 -%252 = OpConstant %3 4 -%255 = OpTypePointer StorageBuffer %10 -%256 = OpTypePointer StorageBuffer %8 -%259 = OpTypePointer StorageBuffer %19 -%262 = OpTypePointer StorageBuffer %7 -%263 = OpTypePointer StorageBuffer %5 -%275 = OpTypeVector %5 4 -%281 = OpVariable %228 Output -%284 = OpConstantComposite %10 %234 %234 %234 -%285 = OpConstantComposite %10 %59 %59 %59 -%286 = OpConstantComposite %10 %61 %61 %61 -%287 = OpConstantComposite %10 %63 %63 %63 -%288 = OpConstantComposite %9 %284 %285 %286 %287 -%289 = OpConstantComposite %17 %36 %36 -%290 = OpConstantComposite %17 %99 %99 -%291 = OpConstantComposite %18 %289 %290 -%292 = OpConstantNull %23 -%293 = OpConstantComposite %31 %234 %234 %234 %234 -%301 = OpConstant %3 33 -%302 = OpConstantComposite %31 %67 %67 %67 %67 -%303 = OpConstantComposite %31 %137 %137 %137 %137 -%304 = OpConstantComposite %34 %302 %303 -%311 = OpVariable %225 Input -%313 = OpVariable %228 Output -%315 = OpConstant %5 2 -%316 = OpConstantComposite %32 %58 %315 %236 %237 %238 -%54 = OpFunction %2 None %55 -%53 = OpLabel -%82 = OpVariable %83 Function %58 -%84 = OpVariable %85 Function %66 -%57 = OpAccessChain %56 %44 %36 -OpBranch %86 -%86 = OpLabel -%87 = OpLoad %5 %82 -%88 = OpISub %5 %87 %58 -OpStore %82 %88 -%90 = OpAccessChain %89 %57 %36 -%91 = OpLoad %21 %90 -%93 = OpAccessChain %92 %57 %36 %36 -%94 = OpLoad %12 %93 -%95 = OpLoad %5 %82 -%96 = OpAccessChain %92 %57 %36 %95 -%97 = OpLoad %12 %96 -%100 = OpAccessChain %98 %57 %36 %36 %99 -%101 = OpLoad %8 %100 -%102 = OpLoad %5 %82 -%103 = OpAccessChain %98 %57 %36 %36 %102 -%104 = OpLoad %8 %103 -%105 = OpLoad %5 %82 -%106 = OpAccessChain %98 %57 %36 %105 %99 -%107 = OpLoad %8 %106 -%108 = OpLoad %5 %82 -%109 = OpLoad %5 %82 -%110 = OpAccessChain %98 %57 %36 %108 %109 -%111 = OpLoad %8 %110 -%112 = OpLoad %5 %82 -%113 = OpIAdd %5 %112 %58 -OpStore %82 %113 -%115 = OpAccessChain %114 %84 %36 -OpStore %115 %73 -%117 = OpAccessChain %116 %84 %36 %36 -OpStore %117 %75 -%118 = OpLoad %5 %82 -%119 = OpAccessChain %116 %84 %36 %118 -OpStore %119 %77 -%121 = OpAccessChain %120 %84 %36 %36 %99 -OpStore %121 %78 -%122 = OpLoad %5 %82 -%123 = OpAccessChain %120 %84 %36 %36 %122 -OpStore %123 %79 -%124 = OpLoad %5 %82 -%125 = OpAccessChain %120 %84 %36 %124 %99 -OpStore %125 %80 -%126 = OpLoad %5 %82 -%127 = OpLoad %5 %82 -%128 = OpAccessChain %120 %84 %36 %126 %127 -OpStore %128 %81 +%78 = OpConstantComposite %21 %73 %75 %77 +%79 = OpConstant %8 9.0 +%80 = OpConstantComposite %12 %79 %79 +%81 = OpConstant %8 90.0 +%82 = OpConstantComposite %12 %81 %81 +%83 = OpConstant %8 10.0 +%84 = OpConstant %8 20.0 +%85 = OpConstant %8 30.0 +%86 = OpConstant %8 40.0 +%88 = OpTypePointer Function %5 +%90 = OpTypePointer Function %22 +%94 = OpTypePointer Uniform %21 +%97 = OpTypePointer Uniform %12 +%103 = OpTypePointer Uniform %8 +%104 = OpConstant %3 1 +%119 = OpTypePointer Function %21 +%121 = OpTypePointer Function %12 +%125 = OpTypePointer Function %8 +%136 = OpTypePointer Uniform %26 +%138 = OpConstantNull %25 +%139 = OpConstantComposite %26 %138 +%140 = OpConstant %8 8.0 +%141 = OpConstantComposite %12 %140 %140 +%142 = OpConstant %8 7.0 +%143 = OpConstantComposite %12 %142 %142 +%144 = OpConstantComposite %24 %141 %143 %73 %75 +%147 = OpTypePointer Function %26 +%151 = OpTypePointer Uniform %25 +%154 = OpTypePointer Uniform %24 +%176 = OpTypePointer Function %25 +%178 = OpTypePointer Function %24 +%194 = OpTypeFunction %8 %27 +%200 = OpTypeFunction %8 %29 +%207 = OpTypeFunction %2 %33 +%208 = OpConstant %3 42 +%213 = OpTypeFunction %2 %35 +%214 = OpConstantComposite %31 %64 %64 %64 %64 +%215 = OpConstantComposite %31 %66 %66 %66 %66 +%216 = OpConstantComposite %34 %214 %215 +%222 = OpTypeFunction %5 %32 %5 +%224 = OpTypePointer Function %32 +%231 = OpTypeFunction %3 %37 +%238 = OpTypeFunction %2 %37 +%244 = OpTypeFunction %3 %40 +%251 = OpTypeFunction %2 %40 +%256 = OpTypePointer Input %3 +%255 = OpVariable %256 Input +%259 = OpTypePointer Output %31 +%258 = OpVariable %259 Output +%262 = OpTypePointer StorageBuffer %23 +%265 = OpConstant %8 0.0 +%266 = OpConstant %3 3 +%267 = OpConstant %5 3 +%268 = OpConstant %5 4 +%269 = OpConstant %5 5 +%270 = OpConstant %5 42 +%271 = OpConstantNull %29 +%274 = OpConstantNull %32 +%279 = OpTypePointer StorageBuffer %9 +%282 = OpTypePointer StorageBuffer %18 +%285 = OpTypePointer StorageBuffer %10 +%286 = OpTypePointer StorageBuffer %8 +%289 = OpTypePointer StorageBuffer %19 +%292 = OpTypePointer StorageBuffer %7 +%293 = OpTypePointer StorageBuffer %5 +%305 = OpTypeVector %5 4 +%311 = OpVariable %259 Output +%314 = OpConstantComposite %10 %265 %265 %265 +%315 = OpConstantComposite %10 %64 %64 %64 +%316 = OpConstantComposite %10 %66 %66 %66 +%317 = OpConstantComposite %10 %68 %68 %68 +%318 = OpConstantComposite %9 %314 %315 %316 %317 +%319 = OpConstantComposite %17 %41 %41 +%320 = OpConstantComposite %17 %104 %104 +%321 = OpConstantComposite %18 %319 %320 +%322 = OpConstantNull %23 +%323 = OpConstantComposite %31 %265 %265 %265 %265 +%331 = OpConstant %3 33 +%332 = OpConstantComposite %31 %72 %72 %72 %72 +%333 = OpConstantComposite %31 %142 %142 %142 %142 +%334 = OpConstantComposite %34 %332 %333 +%341 = OpVariable %256 Input +%343 = OpVariable %259 Output +%345 = OpConstant %5 2 +%346 = OpConstantComposite %32 %63 %345 %267 %268 %269 +%356 = OpConstantNull %36 +%358 = OpConstantNull %38 +%59 = OpFunction %2 None %60 +%58 = OpLabel +%87 = OpVariable %88 Function %63 +%89 = OpVariable %90 Function %71 +%62 = OpAccessChain %61 %49 %41 +OpBranch %91 +%91 = OpLabel +%92 = OpLoad %5 %87 +%93 = OpISub %5 %92 %63 +OpStore %87 %93 +%95 = OpAccessChain %94 %62 %41 +%96 = OpLoad %21 %95 +%98 = OpAccessChain %97 %62 %41 %41 +%99 = OpLoad %12 %98 +%100 = OpLoad %5 %87 +%101 = OpAccessChain %97 %62 %41 %100 +%102 = OpLoad %12 %101 +%105 = OpAccessChain %103 %62 %41 %41 %104 +%106 = OpLoad %8 %105 +%107 = OpLoad %5 %87 +%108 = OpAccessChain %103 %62 %41 %41 %107 +%109 = OpLoad %8 %108 +%110 = OpLoad %5 %87 +%111 = OpAccessChain %103 %62 %41 %110 %104 +%112 = OpLoad %8 %111 +%113 = OpLoad %5 %87 +%114 = OpLoad %5 %87 +%115 = OpAccessChain %103 %62 %41 %113 %114 +%116 = OpLoad %8 %115 +%117 = OpLoad %5 %87 +%118 = OpIAdd %5 %117 %63 +OpStore %87 %118 +%120 = OpAccessChain %119 %89 %41 +OpStore %120 %78 +%122 = OpAccessChain %121 %89 %41 %41 +OpStore %122 %80 +%123 = OpLoad %5 %87 +%124 = OpAccessChain %121 %89 %41 %123 +OpStore %124 %82 +%126 = OpAccessChain %125 %89 %41 %41 %104 +OpStore %126 %83 +%127 = OpLoad %5 %87 +%128 = OpAccessChain %125 %89 %41 %41 %127 +OpStore %128 %84 +%129 = OpLoad %5 %87 +%130 = OpAccessChain %125 %89 %41 %129 %104 +OpStore %130 %85 +%131 = OpLoad %5 %87 +%132 = OpLoad %5 %87 +%133 = OpAccessChain %125 %89 %41 %131 %132 +OpStore %133 %86 OpReturn OpFunctionEnd -%130 = OpFunction %2 None %55 -%129 = OpLabel -%140 = OpVariable %83 Function %58 -%141 = OpVariable %142 Function %134 -%132 = OpAccessChain %131 %50 %36 -OpBranch %143 -%143 = OpLabel -%144 = OpLoad %5 %140 -%145 = OpISub %5 %144 %58 -OpStore %140 %145 -%147 = OpAccessChain %146 %132 %36 -%148 = OpLoad %25 %147 -%150 = OpAccessChain %149 %132 %36 %36 -%151 = OpLoad %24 %150 -%152 = OpAccessChain %92 %132 %36 %36 %36 -%153 = OpLoad %12 %152 -%154 = OpLoad %5 %140 -%155 = OpAccessChain %92 %132 %36 %36 %154 -%156 = OpLoad %12 %155 -%157 = OpAccessChain %98 %132 %36 %36 %36 %99 -%158 = OpLoad %8 %157 -%159 = OpLoad %5 %140 -%160 = OpAccessChain %98 %132 %36 %36 %36 %159 -%161 = OpLoad %8 %160 -%162 = OpLoad %5 %140 -%163 = OpAccessChain %98 %132 %36 %36 %162 %99 -%164 = OpLoad %8 %163 -%165 = OpLoad %5 %140 -%166 = OpLoad %5 %140 -%167 = OpAccessChain %98 %132 %36 %36 %165 %166 -%168 = OpLoad %8 %167 -%169 = OpLoad %5 %140 -%170 = OpIAdd %5 %169 %58 -OpStore %140 %170 -%172 = OpAccessChain %171 %141 %36 -OpStore %172 %133 -%174 = OpAccessChain %173 %141 %36 %36 -OpStore %174 %139 -%175 = OpAccessChain %116 %141 %36 %36 %36 -OpStore %175 %75 -%176 = OpLoad %5 %140 -%177 = OpAccessChain %116 %141 %36 %36 %176 -OpStore %177 %77 -%178 = OpAccessChain %120 %141 %36 %36 %36 %99 -OpStore %178 %78 -%179 = OpLoad %5 %140 -%180 = OpAccessChain %120 %141 %36 %36 %36 %179 -OpStore %180 %79 -%181 = OpLoad %5 %140 -%182 = OpAccessChain %120 %141 %36 %36 %181 %99 -OpStore %182 %80 -%183 = OpLoad %5 %140 -%184 = OpLoad %5 %140 -%185 = OpAccessChain %120 %141 %36 %36 %183 %184 -OpStore %185 %81 +%135 = OpFunction %2 None %60 +%134 = OpLabel +%145 = OpVariable %88 Function %63 +%146 = OpVariable %147 Function %139 +%137 = OpAccessChain %136 %55 %41 +OpBranch %148 +%148 = OpLabel +%149 = OpLoad %5 %145 +%150 = OpISub %5 %149 %63 +OpStore %145 %150 +%152 = OpAccessChain %151 %137 %41 +%153 = OpLoad %25 %152 +%155 = OpAccessChain %154 %137 %41 %41 +%156 = OpLoad %24 %155 +%157 = OpAccessChain %97 %137 %41 %41 %41 +%158 = OpLoad %12 %157 +%159 = OpLoad %5 %145 +%160 = OpAccessChain %97 %137 %41 %41 %159 +%161 = OpLoad %12 %160 +%162 = OpAccessChain %103 %137 %41 %41 %41 %104 +%163 = OpLoad %8 %162 +%164 = OpLoad %5 %145 +%165 = OpAccessChain %103 %137 %41 %41 %41 %164 +%166 = OpLoad %8 %165 +%167 = OpLoad %5 %145 +%168 = OpAccessChain %103 %137 %41 %41 %167 %104 +%169 = OpLoad %8 %168 +%170 = OpLoad %5 %145 +%171 = OpLoad %5 %145 +%172 = OpAccessChain %103 %137 %41 %41 %170 %171 +%173 = OpLoad %8 %172 +%174 = OpLoad %5 %145 +%175 = OpIAdd %5 %174 %63 +OpStore %145 %175 +%177 = OpAccessChain %176 %146 %41 +OpStore %177 %138 +%179 = OpAccessChain %178 %146 %41 %41 +OpStore %179 %144 +%180 = OpAccessChain %121 %146 %41 %41 %41 +OpStore %180 %80 +%181 = OpLoad %5 %145 +%182 = OpAccessChain %121 %146 %41 %41 %181 +OpStore %182 %82 +%183 = OpAccessChain %125 %146 %41 %41 %41 %104 +OpStore %183 %83 +%184 = OpLoad %5 %145 +%185 = OpAccessChain %125 %146 %41 %41 %41 %184 +OpStore %185 %84 +%186 = OpLoad %5 %145 +%187 = OpAccessChain %125 %146 %41 %41 %186 %104 +OpStore %187 %85 +%188 = OpLoad %5 %145 +%189 = OpLoad %5 %145 +%190 = OpAccessChain %125 %146 %41 %41 %188 %189 +OpStore %190 %86 OpReturn OpFunctionEnd -%188 = OpFunction %8 None %189 -%187 = OpFunctionParameter %27 -%186 = OpLabel -OpBranch %190 -%190 = OpLabel -%191 = OpLoad %8 %187 -OpReturnValue %191 +%193 = OpFunction %8 None %194 +%192 = OpFunctionParameter %27 +%191 = OpLabel +OpBranch %195 +%195 = OpLabel +%196 = OpLoad %8 %192 +OpReturnValue %196 OpFunctionEnd -%194 = OpFunction %8 None %195 -%193 = OpFunctionParameter %29 -%192 = OpLabel -OpBranch %196 -%196 = OpLabel -%197 = OpCompositeExtract %28 %193 4 -%198 = OpCompositeExtract %8 %197 9 -OpReturnValue %198 +%199 = OpFunction %8 None %200 +%198 = OpFunctionParameter %29 +%197 = OpLabel +OpBranch %201 +%201 = OpLabel +%202 = OpCompositeExtract %28 %198 4 +%203 = OpCompositeExtract %8 %202 9 +OpReturnValue %203 OpFunctionEnd -%201 = OpFunction %2 None %202 -%200 = OpFunctionParameter %33 -%199 = OpLabel -OpBranch %204 +%206 = OpFunction %2 None %207 +%205 = OpFunctionParameter %33 %204 = OpLabel -OpStore %200 %203 +OpBranch %209 +%209 = OpLabel +OpStore %205 %208 OpReturn OpFunctionEnd -%207 = OpFunction %2 None %208 -%206 = OpFunctionParameter %35 -%205 = OpLabel -OpBranch %212 -%212 = OpLabel -OpStore %206 %211 +%212 = OpFunction %2 None %213 +%211 = OpFunctionParameter %35 +%210 = OpLabel +OpBranch %217 +%217 = OpLabel +OpStore %211 %216 OpReturn OpFunctionEnd -%216 = OpFunction %5 None %217 -%214 = OpFunctionParameter %32 -%215 = OpFunctionParameter %5 -%213 = OpLabel -%220 = OpVariable %219 Function -OpBranch %218 +%221 = OpFunction %5 None %222 +%219 = OpFunctionParameter %32 +%220 = OpFunctionParameter %5 %218 = OpLabel -OpStore %220 %214 -%221 = OpAccessChain %83 %220 %215 -%222 = OpLoad %5 %221 -OpReturnValue %222 -OpFunctionEnd -%229 = OpFunction %2 None %55 +%225 = OpVariable %224 Function +OpBranch %223 %223 = OpLabel -%241 = OpVariable %27 Function %234 -%242 = OpVariable %219 Function %243 -%226 = OpLoad %3 %224 -%230 = OpAccessChain %56 %44 %36 -%232 = OpAccessChain %231 %47 %36 -%233 = OpAccessChain %131 %50 %36 -OpBranch %244 -%244 = OpLabel -%245 = OpLoad %8 %241 -OpStore %241 %59 -%246 = OpFunctionCall %2 %54 -%247 = OpFunctionCall %2 %130 -%249 = OpAccessChain %248 %42 %36 -%250 = OpLoad %9 %249 -%253 = OpAccessChain %251 %42 %252 -%254 = OpLoad %18 %253 -%257 = OpAccessChain %256 %42 %36 %235 %36 -%258 = OpLoad %8 %257 -%260 = OpArrayLength %3 %42 5 -%261 = OpISub %3 %260 %14 -%264 = OpAccessChain %263 %42 %30 %261 %36 -%265 = OpLoad %5 %264 -%266 = OpLoad %23 %232 -%267 = OpFunctionCall %8 %188 %241 -%268 = OpConvertFToS %5 %258 -%269 = OpCompositeConstruct %32 %265 %268 %236 %237 %238 -OpStore %242 %269 -%270 = OpIAdd %3 %226 %99 -%271 = OpAccessChain %83 %242 %270 -OpStore %271 %239 -%272 = OpAccessChain %83 %242 %226 -%273 = OpLoad %5 %272 -%274 = OpFunctionCall %8 %194 %240 -%276 = OpCompositeConstruct %275 %273 %273 %273 %273 -%277 = OpConvertSToF %31 %276 -%278 = OpMatrixTimesVector %10 %250 %277 -%279 = OpCompositeConstruct %31 %278 %61 -OpStore %227 %279 +OpStore %225 %219 +%226 = OpAccessChain %88 %225 %220 +%227 = OpLoad %5 %226 +OpReturnValue %227 +OpFunctionEnd +%230 = OpFunction %3 None %231 +%229 = OpFunctionParameter %37 +%228 = OpLabel +OpBranch %232 +%232 = OpLabel +%233 = OpAccessChain %33 %229 %41 +%234 = OpLoad %3 %233 +OpReturnValue %234 +OpFunctionEnd +%237 = OpFunction %2 None %238 +%236 = OpFunctionParameter %37 +%235 = OpLabel +OpBranch %239 +%239 = OpLabel +%240 = OpAccessChain %33 %236 %41 +OpStore %240 %16 OpReturn OpFunctionEnd -%282 = OpFunction %2 None %55 -%280 = OpLabel -%283 = OpAccessChain %231 %47 %36 -OpBranch %294 -%294 = OpLabel -%295 = OpAccessChain %256 %42 %36 %99 %14 -OpStore %295 %59 -%296 = OpAccessChain %248 %42 %36 -OpStore %296 %288 -%297 = OpAccessChain %251 %42 %252 -OpStore %297 %291 -%298 = OpAccessChain %263 %42 %30 %99 %36 -OpStore %298 %58 -OpStore %283 %292 -OpStore %281 %293 +%243 = OpFunction %3 None %244 +%242 = OpFunctionParameter %40 +%241 = OpLabel +OpBranch %245 +%245 = OpLabel +%246 = OpAccessChain %33 %242 %104 +%247 = OpLoad %3 %246 +OpReturnValue %247 +OpFunctionEnd +%250 = OpFunction %2 None %251 +%249 = OpFunctionParameter %40 +%248 = OpLabel +OpBranch %252 +%252 = OpLabel +%253 = OpAccessChain %33 %249 %104 +OpStore %253 %16 OpReturn OpFunctionEnd -%300 = OpFunction %2 None %55 -%299 = OpLabel -%305 = OpVariable %33 Function %301 -%306 = OpVariable %35 Function %304 -OpBranch %307 -%307 = OpLabel -%308 = OpFunctionCall %2 %201 %305 -%309 = OpFunctionCall %2 %207 %306 +%260 = OpFunction %2 None %60 +%254 = OpLabel +%272 = OpVariable %27 Function %265 +%273 = OpVariable %224 Function %274 +%257 = OpLoad %3 %255 +%261 = OpAccessChain %61 %49 %41 +%263 = OpAccessChain %262 %52 %41 +%264 = OpAccessChain %136 %55 %41 +OpBranch %275 +%275 = OpLabel +%276 = OpLoad %8 %272 +OpStore %272 %64 +%277 = OpFunctionCall %2 %59 +%278 = OpFunctionCall %2 %135 +%280 = OpAccessChain %279 %47 %41 +%281 = OpLoad %9 %280 +%283 = OpAccessChain %282 %47 %39 +%284 = OpLoad %18 %283 +%287 = OpAccessChain %286 %47 %41 %266 %41 +%288 = OpLoad %8 %287 +%290 = OpArrayLength %3 %47 5 +%291 = OpISub %3 %290 %14 +%294 = OpAccessChain %293 %47 %30 %291 %41 +%295 = OpLoad %5 %294 +%296 = OpLoad %23 %263 +%297 = OpFunctionCall %8 %193 %272 +%298 = OpConvertFToS %5 %288 +%299 = OpCompositeConstruct %32 %295 %298 %267 %268 %269 +OpStore %273 %299 +%300 = OpIAdd %3 %257 %104 +%301 = OpAccessChain %88 %273 %300 +OpStore %301 %270 +%302 = OpAccessChain %88 %273 %257 +%303 = OpLoad %5 %302 +%304 = OpFunctionCall %8 %199 %271 +%306 = OpCompositeConstruct %305 %303 %303 %303 %303 +%307 = OpConvertSToF %31 %306 +%308 = OpMatrixTimesVector %10 %281 %307 +%309 = OpCompositeConstruct %31 %308 %66 +OpStore %258 %309 OpReturn OpFunctionEnd -%314 = OpFunction %2 None %55 +%312 = OpFunction %2 None %60 %310 = OpLabel -%318 = OpVariable %219 Function -%312 = OpLoad %3 %311 -OpBranch %317 -%317 = OpLabel -OpStore %318 %316 -%319 = OpAccessChain %83 %318 %312 -%320 = OpLoad %5 %319 -%321 = OpCompositeConstruct %275 %320 %320 %320 %320 -%322 = OpConvertSToF %31 %321 +%313 = OpAccessChain %262 %52 %41 +OpBranch %324 +%324 = OpLabel +%325 = OpAccessChain %286 %47 %41 %104 %14 +OpStore %325 %64 +%326 = OpAccessChain %279 %47 %41 +OpStore %326 %318 +%327 = OpAccessChain %282 %47 %39 +OpStore %327 %321 +%328 = OpAccessChain %293 %47 %30 %104 %41 +OpStore %328 %63 OpStore %313 %322 +OpStore %311 %323 +OpReturn +OpFunctionEnd +%330 = OpFunction %2 None %60 +%329 = OpLabel +%335 = OpVariable %33 Function %331 +%336 = OpVariable %35 Function %334 +OpBranch %337 +%337 = OpLabel +%338 = OpFunctionCall %2 %206 %335 +%339 = OpFunctionCall %2 %212 %336 +OpReturn +OpFunctionEnd +%344 = OpFunction %2 None %60 +%340 = OpLabel +%348 = OpVariable %224 Function +%342 = OpLoad %3 %341 +OpBranch %347 +%347 = OpLabel +OpStore %348 %346 +%349 = OpAccessChain %88 %348 %342 +%350 = OpLoad %5 %349 +%351 = OpCompositeConstruct %305 %350 %350 %350 %350 +%352 = OpConvertSToF %31 %351 +OpStore %343 %352 +OpReturn +OpFunctionEnd +%354 = OpFunction %2 None %60 +%353 = OpLabel +%355 = OpVariable %37 Function %356 +%357 = OpVariable %40 Function %358 +OpBranch %359 +%359 = OpLabel +%360 = OpFunctionCall %2 %237 %355 +%361 = OpFunctionCall %3 %230 %355 +%362 = OpFunctionCall %2 %250 %357 +%363 = OpFunctionCall %3 %243 %357 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/naga/tests/out/wgsl/access.wgsl b/naga/tests/out/wgsl/access.wgsl index 0c29e5d605..c659b21262 100644 --- a/naga/tests/out/wgsl/access.wgsl +++ b/naga/tests/out/wgsl/access.wgsl @@ -25,6 +25,10 @@ struct MatCx2InArray { am: array, 2>, } +struct AssignToMember { + x: u32, +} + var global_const: GlobalConst = GlobalConst(0u, vec3(0u, 0u, 0u), 0i); @group(0) @binding(0) var bar: Bar; @@ -130,6 +134,26 @@ fn array_by_value(a_1: array, i: i32) -> i32 { return a_1[i]; } +fn fetch_arg_ptr_member(p_1: ptr) -> u32 { + let _e2 = (*p_1).x; + return _e2; +} + +fn assign_to_arg_ptr_member(p_2: ptr) { + (*p_2).x = 10u; + return; +} + +fn fetch_arg_ptr_array_element(p_3: ptr>) -> u32 { + let _e2 = (*p_3)[1]; + return _e2; +} + +fn assign_to_arg_ptr_array_element(p_4: ptr>) { + (*p_4)[1] = 10u; + return; +} + @vertex fn foo_vert(@builtin(vertex_index) vi: u32) -> @builtin(position) vec4 { var foo: f32 = 0f; @@ -179,3 +203,15 @@ fn foo_1(@builtin(vertex_index) vi_1: u32) -> @builtin(position) vec4 { let value_1 = arr_2[vi_1]; return vec4(vec4(value_1)); } + +@compute @workgroup_size(1, 1, 1) +fn assign_to_ptr_components() { + var s1_: AssignToMember; + var a1_: array; + + assign_to_arg_ptr_member((&s1_)); + let _e1 = fetch_arg_ptr_member((&s1_)); + assign_to_arg_ptr_array_element((&a1_)); + let _e3 = fetch_arg_ptr_array_element((&a1_)); + return; +} From 57b8858f9609ed448850533f98a9de7c42cdc6ed Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Tue, 8 Oct 2024 15:02:13 -0700 Subject: [PATCH 22/67] [naga spv-out] Gather array, matrix, and vector cases. This commit is just code motion. --- naga/src/back/spv/block.rs | 57 +++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/naga/src/back/spv/block.rs b/naga/src/back/spv/block.rs index 72c2778c7d..c255e63d17 100644 --- a/naga/src/back/spv/block.rs +++ b/naga/src/back/spv/block.rs @@ -344,11 +344,36 @@ impl<'w> BlockContext<'w> { crate::TypeInner::Vector { .. } => { self.write_vector_access(expr_handle, base, index, block)? } - // Only binding arrays in the `Handle` address space will take this - // path, since we handled the `Pointer` case above. + crate::TypeInner::Array { + base: ty_element, .. + } => { + let index_id = self.cached[index]; + let base_id = self.cached[base]; + let base_ty = match self.fun_info[base].ty { + TypeResolution::Handle(handle) => handle, + TypeResolution::Value(_) => { + return Err(Error::Validation( + "Array types should always be in the arena", + )) + } + }; + let (id, variable) = self.writer.promote_access_expression_to_variable( + result_type_id, + base_id, + base_ty, + index_id, + ty_element, + block, + )?; + self.function.internal_variables.push(variable); + id + } + // wgpu#4337: Support `crate::TypeInner::Matrix` crate::TypeInner::BindingArray { base: binding_type, .. } => { + // Only binding arrays in the `Handle` address space will take + // this path, since we handled the `Pointer` case above. let result_id = match self.write_expression_pointer( expr_handle, block, @@ -384,31 +409,6 @@ impl<'w> BlockContext<'w> { load_id } - crate::TypeInner::Array { - base: ty_element, .. - } => { - let index_id = self.cached[index]; - let base_id = self.cached[base]; - let base_ty = match self.fun_info[base].ty { - TypeResolution::Handle(handle) => handle, - TypeResolution::Value(_) => { - return Err(Error::Validation( - "Array types should always be in the arena", - )) - } - }; - let (id, variable) = self.writer.promote_access_expression_to_variable( - result_type_id, - base_id, - base_ty, - index_id, - ty_element, - block, - )?; - self.function.internal_variables.push(variable); - id - } - // wgpu#4337: Support `crate::TypeInner::Matrix` ref other => { log::error!( "Unable to access base {:?} of type {:?}", @@ -449,10 +449,11 @@ impl<'w> BlockContext<'w> { )); id } - // Only binding arrays in the Handle address space will take this path (due to `is_intermediate`) crate::TypeInner::BindingArray { base: binding_type, .. } => { + // Only binding arrays in the `Handle` address space will take + // this path, since we handled the `Pointer` case above. let result_id = match self.write_expression_pointer( expr_handle, block, From 4427ff962276bbcf5ef805a5f58f9236253d79c7 Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Wed, 9 Oct 2024 17:39:23 -0700 Subject: [PATCH 23/67] [naga spv-out] Use `crate::proc::index::GuardedIndex`. Replace qualified paths with a `use` directive. --- naga/src/back/spv/block.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/naga/src/back/spv/block.rs b/naga/src/back/spv/block.rs index c255e63d17..7c0bce20d9 100644 --- a/naga/src/back/spv/block.rs +++ b/naga/src/back/spv/block.rs @@ -6,7 +6,11 @@ use super::{ index::BoundsCheckResult, selection::Selection, Block, BlockContext, Dimension, Error, Instruction, LocalType, LookupType, NumericType, ResultMember, Writer, WriterFlags, }; -use crate::{arena::Handle, proc::TypeResolution, Statement}; +use crate::{ + arena::Handle, + proc::{index::GuardedIndex, TypeResolution}, + Statement, +}; use spirv::Word; fn get_dimension(type_inner: &crate::TypeInner) -> Dimension { @@ -1743,7 +1747,7 @@ impl<'w> BlockContext<'w> { is_non_uniform_binding_array |= self.is_nonuniform_binding_array_access(base, index); - let index = crate::proc::index::GuardedIndex::Expression(index); + let index = GuardedIndex::Expression(index); let index_id = self.write_access_chain_index(base, index, &mut accumulated_checks, block)?; self.temp_list.push(index_id); @@ -1768,7 +1772,7 @@ impl<'w> BlockContext<'w> { // through the bounds check process. self.write_access_chain_index( base, - crate::proc::index::GuardedIndex::Known(index), + GuardedIndex::Known(index), &mut accumulated_checks, block, )? @@ -1861,7 +1865,7 @@ impl<'w> BlockContext<'w> { fn write_access_chain_index( &mut self, base: Handle, - index: crate::proc::index::GuardedIndex, + index: GuardedIndex, accumulated_checks: &mut Option, block: &mut Block, ) -> Result { From 0392613b5a172c3cbb1468bd199d6766d19d217c Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Thu, 10 Oct 2024 12:43:48 -0700 Subject: [PATCH 24/67] [naga spv-out] Abstract out `NumericType::from_inner`. Pull out the code for building a `naga::back::spv::NumericType` from a `TypeInner` into its own function, `NumericType::from_inner`. Use that in `LocalType::from_inner`. --- naga/src/back/spv/mod.rs | 42 ++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/naga/src/back/spv/mod.rs b/naga/src/back/spv/mod.rs index 58fcf60356..d69bfc51ea 100644 --- a/naga/src/back/spv/mod.rs +++ b/naga/src/back/spv/mod.rs @@ -246,6 +246,27 @@ enum NumericType { }, } +impl NumericType { + const fn from_inner(inner: &crate::TypeInner) -> Option { + match *inner { + crate::TypeInner::Scalar(scalar) | crate::TypeInner::Atomic(scalar) => { + Some(NumericType::Scalar(scalar)) + } + crate::TypeInner::Vector { size, scalar } => Some(NumericType::Vector { size, scalar }), + crate::TypeInner::Matrix { + columns, + rows, + scalar, + } => Some(NumericType::Matrix { + columns, + rows, + scalar, + }), + _ => None, + } + } +} + /// A SPIR-V type constructed during code generation. /// /// This is the variant of [`LookupType`] used to represent types that might not @@ -367,21 +388,14 @@ struct LookupFunctionType { impl LocalType { fn from_inner(inner: &crate::TypeInner) -> Option { Some(match *inner { - crate::TypeInner::Scalar(scalar) | crate::TypeInner::Atomic(scalar) => { - LocalType::Numeric(NumericType::Scalar(scalar)) + crate::TypeInner::Scalar(_) + | crate::TypeInner::Atomic(_) + | crate::TypeInner::Vector { .. } + | crate::TypeInner::Matrix { .. } => { + // We expect `NumericType::from_inner` to handle all + // these cases, so unwrap. + LocalType::Numeric(NumericType::from_inner(inner).unwrap()) } - crate::TypeInner::Vector { size, scalar } => { - LocalType::Numeric(NumericType::Vector { size, scalar }) - } - crate::TypeInner::Matrix { - columns, - rows, - scalar, - } => LocalType::Numeric(NumericType::Matrix { - columns, - rows, - scalar, - }), crate::TypeInner::Pointer { base, space } => LocalType::Pointer { base, class: helpers::map_storage_class(space), From 0f17ad64556a42c59dfc065d5e0a33bd0acb856a Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Thu, 10 Oct 2024 12:45:55 -0700 Subject: [PATCH 25/67] [naga] Add new function, `GuardedIndex::from_expression`. Pull out the code to build a `naga::proc::index::GuardedIndex` from a `Handle` into its own function, `GuardedIndex::from_expression`. Use that function in `GuardedIndex::try_resolve_to_constant`. --- naga/src/proc/index.rs | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/naga/src/proc/index.rs b/naga/src/proc/index.rs index 1066eb2388..810f42e418 100644 --- a/naga/src/proc/index.rs +++ b/naga/src/proc/index.rs @@ -340,12 +340,21 @@ impl GuardedIndex { module: &crate::Module, ) { if let GuardedIndex::Expression(expr) = *self { - if let Ok(value) = module - .to_ctx() - .eval_expr_to_u32_from(expr, &function.expressions) - { - *self = GuardedIndex::Known(value); - } + *self = GuardedIndex::from_expression(expr, function, module); + } + } + + pub(crate) fn from_expression( + expr: Handle, + function: &crate::Function, + module: &crate::Module, + ) -> Self { + match module + .to_ctx() + .eval_expr_to_u32_from(expr, &function.expressions) + { + Ok(value) => Self::Known(value), + Err(_) => Self::Expression(expr), } } } From 436ffba77a0cd4c492ea8cb6c367cc35f14b23a6 Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Thu, 10 Oct 2024 12:51:57 -0700 Subject: [PATCH 26/67] [naga spv-out] Introduce `Writer::get_resolution_pointer_id`. Introduce a new helper function, `naga::back::spv::Writer::get_resolution_pointer_id`. Use it in `BlockContext::write_expression_pointer`. --- naga/src/back/spv/block.rs | 11 +++-------- naga/src/back/spv/writer.rs | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/naga/src/back/spv/block.rs b/naga/src/back/spv/block.rs index 7c0bce20d9..5c0b70b1e6 100644 --- a/naga/src/back/spv/block.rs +++ b/naga/src/back/spv/block.rs @@ -1721,14 +1721,9 @@ impl<'w> BlockContext<'w> { let resolution = &self.fun_info[expr_handle].ty; match type_adjustment { AccessTypeAdjustment::None => self.writer.get_expression_type_id(resolution), - AccessTypeAdjustment::IntroducePointer(class) => match *resolution { - TypeResolution::Handle(handle) => self.writer.get_pointer_id(handle, class), - TypeResolution::Value(_) => { - unreachable!( - "IntroducePointer should only be used with images and samplers" - ); - } - }, + AccessTypeAdjustment::IntroducePointer(class) => { + self.writer.get_resolution_pointer_id(resolution, class) + } } }; diff --git a/naga/src/back/spv/writer.rs b/naga/src/back/spv/writer.rs index 57beb4535a..b12e745d33 100644 --- a/naga/src/back/spv/writer.rs +++ b/naga/src/back/spv/writer.rs @@ -274,6 +274,24 @@ impl Writer { })) } + /// Return a SPIR-V type for a pointer to `resolution`. + /// + /// The given `resolution` must be one that we can represent + /// either as a `LocalType::Pointer` or `LocalType::LocalPointer`. + pub(super) fn get_resolution_pointer_id( + &mut self, + resolution: &TypeResolution, + class: spirv::StorageClass, + ) -> Word { + match *resolution { + TypeResolution::Handle(handle) => self.get_pointer_id(handle, class), + TypeResolution::Value(ref inner) => { + let base = NumericType::from_inner(inner).unwrap(); + self.get_type_id(LookupType::Local(LocalType::LocalPointer { base, class })) + } + } + } + pub(super) fn get_uint_type_id(&mut self) -> Word { let local_type = LocalType::Numeric(NumericType::Scalar(crate::Scalar::U32)); self.get_type_id(local_type.into()) From 26a95fd270fb2ff45d3caece68ca47a91f81a735 Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Thu, 10 Oct 2024 12:54:43 -0700 Subject: [PATCH 27/67] [naga spv-out] Add some tracing output to `Writer::write_function`. --- naga/src/back/spv/writer.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/naga/src/back/spv/writer.rs b/naga/src/back/spv/writer.rs index b12e745d33..e9f7fc2007 100644 --- a/naga/src/back/spv/writer.rs +++ b/naga/src/back/spv/writer.rs @@ -355,6 +355,7 @@ impl Writer { mut interface: Option, debug_info: &Option, ) -> Result { + log::trace!("Generating code for {:?}", ir_function.name); let mut function = Function::default(); let prelude_id = self.id_gen.next(); From 475a716822856fff7551c3414c6da3324b5ca380 Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Thu, 10 Oct 2024 15:59:01 -0700 Subject: [PATCH 28/67] [naga spv-out] Let `write_checked_load` take `AccessTypeAdjustment`. Let `BlockContext::write_checked_load` take an `AccessTypeAdjustment` argument, so that the caller can choose what adjustment to apply to `pointer`. --- naga/src/back/spv/block.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/naga/src/back/spv/block.rs b/naga/src/back/spv/block.rs index 5c0b70b1e6..7c775e0af7 100644 --- a/naga/src/back/spv/block.rs +++ b/naga/src/back/spv/block.rs @@ -1390,7 +1390,7 @@ impl<'w> BlockContext<'w> { } crate::Expression::LocalVariable(variable) => self.function.variables[&variable].id, crate::Expression::Load { pointer } => { - self.write_checked_load(pointer, block, result_type_id)? + self.write_checked_load(pointer, block, AccessTypeAdjustment::None, result_type_id)? } crate::Expression::FunctionArgument(index) => self.function.parameter_id(index), crate::Expression::CallResult(_) @@ -1931,9 +1931,10 @@ impl<'w> BlockContext<'w> { &mut self, pointer: Handle, block: &mut Block, + access_type_adjustment: AccessTypeAdjustment, result_type_id: Word, ) -> Result { - match self.write_expression_pointer(pointer, block, AccessTypeAdjustment::None)? { + match self.write_expression_pointer(pointer, block, access_type_adjustment)? { ExpressionPointer::Ready { pointer_id } => { let id = self.gen_id(); let atomic_space = From ed3006ccc6e7ef015d854f6a297195979ebb860f Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Thu, 10 Oct 2024 16:02:35 -0700 Subject: [PATCH 29/67] [naga spv-out] Spill arrays and matrices for runtime indexing. Improve handling of `Access` expressions whose base is an array or matrix (not a pointer to such), and whose index is not known at compile time. SPIR-V does not have instructions that can do this directly, so spill such values to temporary variables, and perform the accesses using `OpAccessChain` instructions applied to the temporaries. When performing chains of accesses like `a[i].x[j]`, do not reify intermediate values; generate a single `OpAccessChain` for the entire thing. Remove special cases for arrays; the same code now handles arrays and matrices. Update validation to permit dynamic indexing of matrices. For details, see the comments on the new tracking structures in `naga::back::spv::Function`. Add snapshot test `index-by-value.wgsl`. Fixes #6358. Fixes #4337. Alternative to #6362. --- CHANGELOG.md | 1 + naga/src/arena/handle_set.rs | 6 + naga/src/back/spv/block.rs | 166 +++++++++-- naga/src/back/spv/mod.rs | 36 ++- naga/src/back/spv/writer.rs | 66 +---- naga/src/valid/expression.rs | 12 +- naga/tests/in/index-by-value.wgsl | 13 + naga/tests/out/ir/index-by-value.compact.ron | 278 +++++++++++++++++++ naga/tests/out/ir/index-by-value.ron | 278 +++++++++++++++++++ naga/tests/out/spv/access.spvasm | 12 +- naga/tests/out/spv/index-by-value.spvasm | 80 ++++++ naga/tests/snapshots.rs | 1 + naga/tests/wgsl_errors.rs | 24 +- 13 files changed, 862 insertions(+), 111 deletions(-) create mode 100644 naga/tests/in/index-by-value.wgsl create mode 100644 naga/tests/out/ir/index-by-value.compact.ron create mode 100644 naga/tests/out/ir/index-by-value.ron create mode 100644 naga/tests/out/spv/index-by-value.spvasm diff --git a/CHANGELOG.md b/CHANGELOG.md index 8572220adf..28392f582f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -113,6 +113,7 @@ By @bradwerth [#6216](https://github.com/gfx-rs/wgpu/pull/6216). - Accept global `var`s without explicit type. By @sagudev in [#6199](https://github.com/gfx-rs/wgpu/pull/6199). - Fix handling of phony statements, so they are actually emitted. By @sagudev in [#6328](https://github.com/gfx-rs/wgpu/pull/6328). - Added `gl_DrawID` to glsl and `DrawIndex` to spv. By @ChosenName in [#6325](https://github.com/gfx-rs/wgpu/pull/6325). +- Matrices can now be indexed by value (#4337), and indexing arrays by value no longer causes excessive spilling (#6358). By @jimblandy in [#6390](https://github.com/gfx-rs/wgpu/pull/6390). #### General diff --git a/naga/src/arena/handle_set.rs b/naga/src/arena/handle_set.rs index 52f3cb62d2..ef2ded2ddb 100644 --- a/naga/src/arena/handle_set.rs +++ b/naga/src/arena/handle_set.rs @@ -83,6 +83,12 @@ impl HandleSet { } } +impl Default for HandleSet { + fn default() -> Self { + Self::new() + } +} + pub trait ArenaType { fn len(&self) -> usize; } diff --git a/naga/src/back/spv/block.rs b/naga/src/back/spv/block.rs index 7c775e0af7..b0e317ac56 100644 --- a/naga/src/back/spv/block.rs +++ b/naga/src/back/spv/block.rs @@ -6,11 +6,7 @@ use super::{ index::BoundsCheckResult, selection::Selection, Block, BlockContext, Dimension, Error, Instruction, LocalType, LookupType, NumericType, ResultMember, Writer, WriterFlags, }; -use crate::{ - arena::Handle, - proc::{index::GuardedIndex, TypeResolution}, - Statement, -}; +use crate::{arena::Handle, proc::index::GuardedIndex, Statement}; use spirv::Word; fn get_dimension(type_inner: &crate::TypeInner) -> Dimension { @@ -345,34 +341,64 @@ impl<'w> BlockContext<'w> { // that actually dereferences the pointer. 0 } + _ if self.function.spilled_accesses.contains(base) => { + // As far as Naga IR is concerned, this expression does not yield + // a pointer (we just checked, above), but this backend spilled it + // to a temporary variable, so SPIR-V thinks we're accessing it + // via a pointer. + + // Since the base expression was spilled, mark this access to it + // as spilled, too. + self.function.spilled_accesses.insert(expr_handle); + self.maybe_access_spilled_composite(expr_handle, block, result_type_id)? + } crate::TypeInner::Vector { .. } => { self.write_vector_access(expr_handle, base, index, block)? } - crate::TypeInner::Array { - base: ty_element, .. - } => { - let index_id = self.cached[index]; - let base_id = self.cached[base]; - let base_ty = match self.fun_info[base].ty { - TypeResolution::Handle(handle) => handle, - TypeResolution::Value(_) => { - return Err(Error::Validation( - "Array types should always be in the arena", - )) + crate::TypeInner::Array { .. } | crate::TypeInner::Matrix { .. } => { + // See if `index` is known at compile time. + match GuardedIndex::from_expression(index, self.ir_function, self.ir_module) + { + GuardedIndex::Known(value) => { + // If `index` is known and in bounds, we can just use + // `OpCompositeExtract`. + // + // At the moment, validation rejects programs if this + // index is out of bounds, so we don't need bounds checks. + // However, that rejection is incorrect, since WGSL says + // that `let` bindings are not constant expressions + // (#6396). So eventually we will need to emulate bounds + // checks here. + let id = self.gen_id(); + let base_id = self.cached[base]; + block.body.push(Instruction::composite_extract( + result_type_id, + id, + base_id, + &[value], + )); + id } - }; - let (id, variable) = self.writer.promote_access_expression_to_variable( - result_type_id, - base_id, - base_ty, - index_id, - ty_element, - block, - )?; - self.function.internal_variables.push(variable); - id + GuardedIndex::Expression(_) => { + // We are subscripting an array or matrix that is not + // behind a pointer, using an index computed at runtime. + // SPIR-V has no instructions that do this, so the best we + // can do is spill the value to a new temporary variable, + // at which point we can get a pointer to that and just + // use `OpAccessChain` in the usual way. + self.spill_to_internal_variable(base, block); + + // Since the base was spilled, mark this access to it as + // spilled, too. + self.function.spilled_accesses.insert(expr_handle); + self.maybe_access_spilled_composite( + expr_handle, + block, + result_type_id, + )? + } + } } - // wgpu#4337: Support `crate::TypeInner::Matrix` crate::TypeInner::BindingArray { base: binding_type, .. } => { @@ -435,6 +461,17 @@ impl<'w> BlockContext<'w> { // that actually dereferences the pointer. 0 } + _ if self.function.spilled_accesses.contains(base) => { + // As far as Naga IR is concerned, this expression does not yield + // a pointer (we just checked, above), but this backend spilled it + // to a temporary variable, so SPIR-V thinks we're accessing it + // via a pointer. + + // Since the base expression was spilled, mark this access to it + // as spilled, too. + self.function.spilled_accesses.insert(expr_handle); + self.maybe_access_spilled_composite(expr_handle, block, result_type_id)? + } crate::TypeInner::Vector { .. } | crate::TypeInner::Matrix { .. } | crate::TypeInner::Array { .. } @@ -1737,6 +1774,14 @@ impl<'w> BlockContext<'w> { self.temp_list.clear(); let root_id = loop { + // If `expr_handle` was spilled, then the temporary variable has exactly + // the value we want to start from. + if let Some(spilled) = self.function.spilled_composites.get(&expr_handle) { + // The root id of the `OpAccessChain` instruction is the temporary + // variable we spilled the composite to. + break spilled.id; + } + expr_handle = match self.ir_function.expressions[expr_handle] { crate::Expression::Access { base, index } => { is_non_uniform_binding_array |= @@ -1989,6 +2034,71 @@ impl<'w> BlockContext<'w> { } } + fn spill_to_internal_variable(&mut self, base: Handle, block: &mut Block) { + // Generate an internal variable of the appropriate type for `base`. + let variable_id = self.writer.id_gen.next(); + let pointer_type_id = self + .writer + .get_resolution_pointer_id(&self.fun_info[base].ty, spirv::StorageClass::Function); + let variable = super::LocalVariable { + id: variable_id, + instruction: Instruction::variable( + pointer_type_id, + variable_id, + spirv::StorageClass::Function, + None, + ), + }; + + let base_id = self.cached[base]; + block + .body + .push(Instruction::store(variable.id, base_id, None)); + self.function.spilled_composites.insert(base, variable); + } + + /// Generate an access to a spilled temporary, if necessary. + /// + /// Given `access`, an [`Access`] or [`AccessIndex`] expression that refers + /// to a component of a composite value that has been spilled to a temporary + /// variable, determine whether other expressions are going to use + /// `access`'s value: + /// + /// - If so, perform the access and cache that as the value of `access`. + /// + /// - Otherwise, generate no code and cache no value for `access`. + /// + /// Return `Ok(0)` if no value was fetched, or `Ok(id)` if we loaded it into + /// the instruction given by `id`. + /// + /// [`Access`]: crate::Expression::Access + /// [`AccessIndex`]: crate::Expression::AccessIndex + fn maybe_access_spilled_composite( + &mut self, + access: Handle, + block: &mut Block, + result_type_id: Word, + ) -> Result { + let access_uses = self.function.access_uses.get(&access).map_or(0, |r| *r); + if access_uses == self.fun_info[access].ref_count { + // This expression is only used by other `Access` and + // `AccessIndex` expressions, so we don't need to cache a + // value for it yet. + Ok(0) + } else { + // There are other expressions that are going to expect this + // expression's value to be cached, not just other `Access` or + // `AccessIndex` expressions. We must actually perform the + // access on the spill variable now. + self.write_checked_load( + access, + block, + AccessTypeAdjustment::IntroducePointer(spirv::StorageClass::Function), + result_type_id, + ) + } + } + /// Build the instructions for matrix - matrix column operations #[allow(clippy::too_many_arguments)] fn write_matrix_matrix_column_op( diff --git a/naga/src/back/spv/mod.rs b/naga/src/back/spv/mod.rs index d69bfc51ea..8a254a3a91 100644 --- a/naga/src/back/spv/mod.rs +++ b/naga/src/back/spv/mod.rs @@ -144,7 +144,41 @@ struct Function { signature: Option, parameters: Vec, variables: crate::FastHashMap, LocalVariable>, - internal_variables: Vec, + + /// A map taking an expression that yields a composite value (array, matrix) + /// to the temporary variables we have spilled it to, if any. Spilling + /// allows us to render an arbitrary chain of [`Access`] and [`AccessIndex`] + /// expressions as an `OpAccessChain` and an `OpLoad` (plus bounds checks). + /// This supports dynamic indexing of by-value arrays and matrices, which + /// SPIR-V does not. + /// + /// [`Access`]: crate::Expression::Access + /// [`AccessIndex`]: crate::Expression::AccessIndex + spilled_composites: crate::FastIndexMap, LocalVariable>, + + /// A set of expressions that are either in [`spilled_composites`] or refer + /// to some component/element of such. + /// + /// [`spilled_composites`]: Function::spilled_composites + spilled_accesses: crate::arena::HandleSet, + + /// A map taking each expression to the number of [`Access`] and + /// [`AccessIndex`] expressions that uses it as a base value. If an + /// expression has no entry, its count is zero: it is never used as a + /// [`Access`] or [`AccessIndex`] base. + /// + /// We use this, together with [`ExpressionInfo::ref_count`], to recognize + /// the tips of chains of [`Access`] and [`AccessIndex`] expressions that + /// access spilled values --- expressions in [`spilled_composites`]. We + /// defer generating code for the chain until we reach its tip, so we can + /// handle it with a single instruction. + /// + /// [`Access`]: crate::Expression::Access + /// [`AccessIndex`]: crate::Expression::AccessIndex + /// [`ExpressionInfo::ref_count`]: crate::valid::ExpressionInfo + /// [`spilled_composites`]: Function::spilled_composites + access_uses: crate::FastHashMap, usize>, + blocks: Vec, entry_point_context: Option, } diff --git a/naga/src/back/spv/writer.rs b/naga/src/back/spv/writer.rs index e9f7fc2007..3e7ef7d376 100644 --- a/naga/src/back/spv/writer.rs +++ b/naga/src/back/spv/writer.rs @@ -32,7 +32,7 @@ impl Function { for local_var in self.variables.values() { local_var.instruction.to_words(sink); } - for internal_var in self.internal_variables.iter() { + for internal_var in self.spilled_composites.values() { internal_var.instruction.to_words(sink); } } @@ -138,54 +138,6 @@ impl Writer { self.capabilities_used.insert(spirv::Capability::Shader); } - #[allow(clippy::too_many_arguments)] - pub(super) fn promote_access_expression_to_variable( - &mut self, - result_type_id: Word, - container_id: Word, - container_ty: Handle, - index_id: Word, - element_ty: Handle, - block: &mut Block, - ) -> Result<(Word, LocalVariable), Error> { - let pointer_type_id = self.get_pointer_id(container_ty, spirv::StorageClass::Function); - - let variable = { - let id = self.id_gen.next(); - LocalVariable { - id, - instruction: Instruction::variable( - pointer_type_id, - id, - spirv::StorageClass::Function, - None, - ), - } - }; - block - .body - .push(Instruction::store(variable.id, container_id, None)); - - let element_pointer_id = self.id_gen.next(); - let element_pointer_type_id = - self.get_pointer_id(element_ty, spirv::StorageClass::Function); - block.body.push(Instruction::access_chain( - element_pointer_type_id, - element_pointer_id, - variable.id, - &[index_id], - )); - let id = self.id_gen.next(); - block.body.push(Instruction::load( - result_type_id, - id, - element_pointer_id, - None, - )); - - Ok((id, variable)) - } - /// Indicate that the code requires any one of the listed capabilities. /// /// If nothing in `capabilities` appears in the available capabilities @@ -683,10 +635,20 @@ impl Writer { .insert(handle, LocalVariable { id, instruction }); } - // cache local variable expressions for (handle, expr) in ir_function.expressions.iter() { - if matches!(*expr, crate::Expression::LocalVariable(_)) { - context.cache_expression_value(handle, &mut prelude)?; + match *expr { + crate::Expression::LocalVariable(_) => { + // Cache the `OpVariable` instruction we generated above as + // the value of this expression. + context.cache_expression_value(handle, &mut prelude)?; + } + crate::Expression::Access { base, .. } + | crate::Expression::AccessIndex { base, .. } => { + // Count references to `base` by `Access` and `AccessIndex` + // instructions. See `access_uses` for details. + *context.function.access_uses.entry(base).or_insert(0) += 1; + } + _ => {} } } diff --git a/naga/src/valid/expression.rs b/naga/src/valid/expression.rs index 2b479d3a73..ccdc501a5c 100644 --- a/naga/src/valid/expression.rs +++ b/naga/src/valid/expression.rs @@ -19,8 +19,6 @@ pub enum ExpressionError { NegativeIndex(Handle), #[error("Accessing index {1} is out of {0:?} bounds")] IndexOutOfBounds(Handle, u32), - #[error("The expression {0:?} may only be indexed by a constant")] - IndexMustBeConstant(Handle), #[error("Function argument {0:?} doesn't exist")] FunctionArgumentDoesntExist(u32), #[error("Loading of {0:?} can't be done")] @@ -238,10 +236,9 @@ impl super::Validator { let stages = match *expression { E::Access { base, index } => { let base_type = &resolver[base]; - // See the documentation for `Expression::Access`. - let dynamic_indexing_restricted = match *base_type { - Ti::Matrix { .. } => true, - Ti::Vector { .. } + match *base_type { + Ti::Matrix { .. } + | Ti::Vector { .. } | Ti::Array { .. } | Ti::Pointer { .. } | Ti::ValuePointer { size: Some(_), .. } @@ -262,9 +259,6 @@ impl super::Validator { return Err(ExpressionError::InvalidIndexType(index)); } } - if dynamic_indexing_restricted && function.expressions[index].is_dynamic_index() { - return Err(ExpressionError::IndexMustBeConstant(base)); - } // If we know both the length and the index, we can do the // bounds check now. diff --git a/naga/tests/in/index-by-value.wgsl b/naga/tests/in/index-by-value.wgsl new file mode 100644 index 0000000000..f84f21ef06 --- /dev/null +++ b/naga/tests/in/index-by-value.wgsl @@ -0,0 +1,13 @@ +fn index_arg_array(a: array, i: i32) -> i32 { + return a[i]; +} + +fn index_let_array(i: i32, j: i32) -> i32 { + let a = array, 2>(array(1, 2), array(3, 4)); + return a[i][j]; +} + +fn index_let_matrix(i: i32, j: i32) -> f32 { + let a = mat2x2(1, 2, 3, 4); + return a[i][j]; +} diff --git a/naga/tests/out/ir/index-by-value.compact.ron b/naga/tests/out/ir/index-by-value.compact.ron new file mode 100644 index 0000000000..d8d8dd67e3 --- /dev/null +++ b/naga/tests/out/ir/index-by-value.compact.ron @@ -0,0 +1,278 @@ +( + types: [ + ( + name: None, + inner: Scalar(( + kind: Sint, + width: 4, + )), + ), + ( + name: None, + inner: Array( + base: 0, + size: Constant(5), + stride: 4, + ), + ), + ( + name: None, + inner: Array( + base: 0, + size: Constant(2), + stride: 4, + ), + ), + ( + name: None, + inner: Array( + base: 2, + size: Constant(2), + stride: 8, + ), + ), + ( + name: None, + inner: Scalar(( + kind: Float, + width: 4, + )), + ), + ( + name: None, + inner: Matrix( + columns: Bi, + rows: Bi, + scalar: ( + kind: Float, + width: 4, + ), + ), + ), + ( + name: None, + inner: Vector( + size: Bi, + scalar: ( + kind: Float, + width: 4, + ), + ), + ), + ], + special_types: ( + ray_desc: None, + ray_intersection: None, + predeclared_types: {}, + ), + constants: [], + overrides: [], + global_variables: [], + global_expressions: [], + functions: [ + ( + name: Some("index_arg_array"), + arguments: [ + ( + name: Some("a"), + ty: 1, + binding: None, + ), + ( + name: Some("i"), + ty: 0, + binding: None, + ), + ], + result: Some(( + ty: 0, + binding: None, + )), + local_variables: [], + expressions: [ + FunctionArgument(0), + FunctionArgument(1), + Access( + base: 0, + index: 1, + ), + ], + named_expressions: { + 0: "a", + 1: "i", + }, + body: [ + Emit(( + start: 2, + end: 3, + )), + Return( + value: Some(2), + ), + ], + ), + ( + name: Some("index_let_array"), + arguments: [ + ( + name: Some("i"), + ty: 0, + binding: None, + ), + ( + name: Some("j"), + ty: 0, + binding: None, + ), + ], + result: Some(( + ty: 0, + binding: None, + )), + local_variables: [], + expressions: [ + FunctionArgument(0), + FunctionArgument(1), + Literal(I32(1)), + Literal(I32(2)), + Compose( + ty: 2, + components: [ + 2, + 3, + ], + ), + Literal(I32(3)), + Literal(I32(4)), + Compose( + ty: 2, + components: [ + 5, + 6, + ], + ), + Compose( + ty: 3, + components: [ + 4, + 7, + ], + ), + Access( + base: 8, + index: 0, + ), + Access( + base: 9, + index: 1, + ), + ], + named_expressions: { + 0: "i", + 1: "j", + 8: "a", + }, + body: [ + Emit(( + start: 0, + end: 0, + )), + Emit(( + start: 0, + end: 0, + )), + Emit(( + start: 4, + end: 5, + )), + Emit(( + start: 7, + end: 9, + )), + Emit(( + start: 9, + end: 11, + )), + Return( + value: Some(10), + ), + ], + ), + ( + name: Some("index_let_matrix"), + arguments: [ + ( + name: Some("i"), + ty: 0, + binding: None, + ), + ( + name: Some("j"), + ty: 0, + binding: None, + ), + ], + result: Some(( + ty: 4, + binding: None, + )), + local_variables: [], + expressions: [ + FunctionArgument(0), + FunctionArgument(1), + Literal(F32(1.0)), + Literal(F32(2.0)), + Literal(F32(3.0)), + Literal(F32(4.0)), + Compose( + ty: 6, + components: [ + 2, + 3, + ], + ), + Compose( + ty: 6, + components: [ + 4, + 5, + ], + ), + Compose( + ty: 5, + components: [ + 6, + 7, + ], + ), + Access( + base: 8, + index: 0, + ), + Access( + base: 9, + index: 1, + ), + ], + named_expressions: { + 0: "i", + 1: "j", + 8: "a", + }, + body: [ + Emit(( + start: 6, + end: 9, + )), + Emit(( + start: 9, + end: 11, + )), + Return( + value: Some(10), + ), + ], + ), + ], + entry_points: [], +) \ No newline at end of file diff --git a/naga/tests/out/ir/index-by-value.ron b/naga/tests/out/ir/index-by-value.ron new file mode 100644 index 0000000000..d8d8dd67e3 --- /dev/null +++ b/naga/tests/out/ir/index-by-value.ron @@ -0,0 +1,278 @@ +( + types: [ + ( + name: None, + inner: Scalar(( + kind: Sint, + width: 4, + )), + ), + ( + name: None, + inner: Array( + base: 0, + size: Constant(5), + stride: 4, + ), + ), + ( + name: None, + inner: Array( + base: 0, + size: Constant(2), + stride: 4, + ), + ), + ( + name: None, + inner: Array( + base: 2, + size: Constant(2), + stride: 8, + ), + ), + ( + name: None, + inner: Scalar(( + kind: Float, + width: 4, + )), + ), + ( + name: None, + inner: Matrix( + columns: Bi, + rows: Bi, + scalar: ( + kind: Float, + width: 4, + ), + ), + ), + ( + name: None, + inner: Vector( + size: Bi, + scalar: ( + kind: Float, + width: 4, + ), + ), + ), + ], + special_types: ( + ray_desc: None, + ray_intersection: None, + predeclared_types: {}, + ), + constants: [], + overrides: [], + global_variables: [], + global_expressions: [], + functions: [ + ( + name: Some("index_arg_array"), + arguments: [ + ( + name: Some("a"), + ty: 1, + binding: None, + ), + ( + name: Some("i"), + ty: 0, + binding: None, + ), + ], + result: Some(( + ty: 0, + binding: None, + )), + local_variables: [], + expressions: [ + FunctionArgument(0), + FunctionArgument(1), + Access( + base: 0, + index: 1, + ), + ], + named_expressions: { + 0: "a", + 1: "i", + }, + body: [ + Emit(( + start: 2, + end: 3, + )), + Return( + value: Some(2), + ), + ], + ), + ( + name: Some("index_let_array"), + arguments: [ + ( + name: Some("i"), + ty: 0, + binding: None, + ), + ( + name: Some("j"), + ty: 0, + binding: None, + ), + ], + result: Some(( + ty: 0, + binding: None, + )), + local_variables: [], + expressions: [ + FunctionArgument(0), + FunctionArgument(1), + Literal(I32(1)), + Literal(I32(2)), + Compose( + ty: 2, + components: [ + 2, + 3, + ], + ), + Literal(I32(3)), + Literal(I32(4)), + Compose( + ty: 2, + components: [ + 5, + 6, + ], + ), + Compose( + ty: 3, + components: [ + 4, + 7, + ], + ), + Access( + base: 8, + index: 0, + ), + Access( + base: 9, + index: 1, + ), + ], + named_expressions: { + 0: "i", + 1: "j", + 8: "a", + }, + body: [ + Emit(( + start: 0, + end: 0, + )), + Emit(( + start: 0, + end: 0, + )), + Emit(( + start: 4, + end: 5, + )), + Emit(( + start: 7, + end: 9, + )), + Emit(( + start: 9, + end: 11, + )), + Return( + value: Some(10), + ), + ], + ), + ( + name: Some("index_let_matrix"), + arguments: [ + ( + name: Some("i"), + ty: 0, + binding: None, + ), + ( + name: Some("j"), + ty: 0, + binding: None, + ), + ], + result: Some(( + ty: 4, + binding: None, + )), + local_variables: [], + expressions: [ + FunctionArgument(0), + FunctionArgument(1), + Literal(F32(1.0)), + Literal(F32(2.0)), + Literal(F32(3.0)), + Literal(F32(4.0)), + Compose( + ty: 6, + components: [ + 2, + 3, + ], + ), + Compose( + ty: 6, + components: [ + 4, + 5, + ], + ), + Compose( + ty: 5, + components: [ + 6, + 7, + ], + ), + Access( + base: 8, + index: 0, + ), + Access( + base: 9, + index: 1, + ), + ], + named_expressions: { + 0: "i", + 1: "j", + 8: "a", + }, + body: [ + Emit(( + start: 6, + end: 9, + )), + Emit(( + start: 9, + end: 11, + )), + Return( + value: Some(10), + ), + ], + ), + ], + entry_points: [], +) \ No newline at end of file diff --git a/naga/tests/out/spv/access.spvasm b/naga/tests/out/spv/access.spvasm index d572baa800..cb5437356e 100644 --- a/naga/tests/out/spv/access.spvasm +++ b/naga/tests/out/spv/access.spvasm @@ -240,7 +240,7 @@ OpDecorate %343 BuiltIn Position %215 = OpConstantComposite %31 %66 %66 %66 %66 %216 = OpConstantComposite %34 %214 %215 %222 = OpTypeFunction %5 %32 %5 -%224 = OpTypePointer Function %32 +%225 = OpTypePointer Function %32 %231 = OpTypeFunction %3 %37 %238 = OpTypeFunction %2 %37 %244 = OpTypeFunction %3 %40 @@ -434,11 +434,11 @@ OpFunctionEnd %219 = OpFunctionParameter %32 %220 = OpFunctionParameter %5 %218 = OpLabel -%225 = OpVariable %224 Function +%224 = OpVariable %225 Function OpBranch %223 %223 = OpLabel -OpStore %225 %219 -%226 = OpAccessChain %88 %225 %220 +OpStore %224 %219 +%226 = OpAccessChain %88 %224 %220 %227 = OpLoad %5 %226 OpReturnValue %227 OpFunctionEnd @@ -481,7 +481,7 @@ OpFunctionEnd %260 = OpFunction %2 None %60 %254 = OpLabel %272 = OpVariable %27 Function %265 -%273 = OpVariable %224 Function %274 +%273 = OpVariable %225 Function %274 %257 = OpLoad %3 %255 %261 = OpAccessChain %61 %49 %41 %263 = OpAccessChain %262 %52 %41 @@ -549,7 +549,7 @@ OpReturn OpFunctionEnd %344 = OpFunction %2 None %60 %340 = OpLabel -%348 = OpVariable %224 Function +%348 = OpVariable %225 Function %342 = OpLoad %3 %341 OpBranch %347 %347 = OpLabel diff --git a/naga/tests/out/spv/index-by-value.spvasm b/naga/tests/out/spv/index-by-value.spvasm new file mode 100644 index 0000000000..62c0893b14 --- /dev/null +++ b/naga/tests/out/spv/index-by-value.spvasm @@ -0,0 +1,80 @@ +; SPIR-V +; Version: 1.1 +; Generator: rspirv +; Bound: 59 +OpCapability Shader +OpCapability Linkage +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpDecorate %4 ArrayStride 4 +OpDecorate %7 ArrayStride 4 +OpDecorate %9 ArrayStride 8 +%2 = OpTypeVoid +%3 = OpTypeInt 32 1 +%6 = OpTypeInt 32 0 +%5 = OpConstant %6 5 +%4 = OpTypeArray %3 %5 +%8 = OpConstant %6 2 +%7 = OpTypeArray %3 %8 +%9 = OpTypeArray %7 %8 +%10 = OpTypeFloat 32 +%12 = OpTypeVector %10 2 +%11 = OpTypeMatrix %12 2 +%17 = OpTypeFunction %3 %4 %3 +%20 = OpTypePointer Function %4 +%21 = OpTypePointer Function %3 +%28 = OpTypeFunction %3 %3 %3 +%29 = OpConstant %3 1 +%30 = OpConstant %3 2 +%31 = OpConstantComposite %7 %29 %30 +%32 = OpConstant %3 3 +%33 = OpConstant %3 4 +%34 = OpConstantComposite %7 %32 %33 +%35 = OpConstantComposite %9 %31 %34 +%38 = OpTypePointer Function %9 +%45 = OpTypeFunction %10 %3 %3 +%46 = OpConstant %10 1.0 +%47 = OpConstant %10 2.0 +%48 = OpConstant %10 3.0 +%49 = OpConstant %10 4.0 +%50 = OpConstantComposite %12 %46 %47 +%51 = OpConstantComposite %12 %48 %49 +%52 = OpConstantComposite %11 %50 %51 +%55 = OpTypePointer Function %11 +%56 = OpTypePointer Function %10 +%16 = OpFunction %3 None %17 +%14 = OpFunctionParameter %4 +%15 = OpFunctionParameter %3 +%13 = OpLabel +%19 = OpVariable %20 Function +OpBranch %18 +%18 = OpLabel +OpStore %19 %14 +%22 = OpAccessChain %21 %19 %15 +%23 = OpLoad %3 %22 +OpReturnValue %23 +OpFunctionEnd +%27 = OpFunction %3 None %28 +%25 = OpFunctionParameter %3 +%26 = OpFunctionParameter %3 +%24 = OpLabel +%37 = OpVariable %38 Function +OpBranch %36 +%36 = OpLabel +OpStore %37 %35 +%39 = OpAccessChain %21 %37 %25 %26 +%40 = OpLoad %3 %39 +OpReturnValue %40 +OpFunctionEnd +%44 = OpFunction %10 None %45 +%42 = OpFunctionParameter %3 +%43 = OpFunctionParameter %3 +%41 = OpLabel +%54 = OpVariable %55 Function +OpBranch %53 +%53 = OpLabel +OpStore %54 %52 +%57 = OpAccessChain %56 %54 %42 %43 +%58 = OpLoad %10 %57 +OpReturnValue %58 +OpFunctionEnd \ No newline at end of file diff --git a/naga/tests/snapshots.rs b/naga/tests/snapshots.rs index 78b2331dca..9b9ff15931 100644 --- a/naga/tests/snapshots.rs +++ b/naga/tests/snapshots.rs @@ -936,6 +936,7 @@ fn convert_wgsl() { Targets::SPIRV | Targets::METAL | Targets::GLSL | Targets::HLSL | Targets::WGSL, ), ("6220-break-from-loop", Targets::SPIRV), + ("index-by-value", Targets::SPIRV | Targets::IR), ]; for &(name, targets) in inputs.iter() { diff --git a/naga/tests/wgsl_errors.rs b/naga/tests/wgsl_errors.rs index e5fb77644d..acc2f32cbf 100644 --- a/naga/tests/wgsl_errors.rs +++ b/naga/tests/wgsl_errors.rs @@ -1358,21 +1358,6 @@ fn missing_bindings2() { #[test] fn invalid_access() { - check_validation! { - " - fn matrix_by_value(m: mat4x4, i: i32) -> vec4 { - return m[i]; - } - ": - Err(naga::valid::ValidationError::Function { - source: naga::valid::FunctionError::Expression { - source: naga::valid::ExpressionError::IndexMustBeConstant(_), - .. - }, - .. - }) - } - check_validation! { r#" fn main() -> f32 { @@ -1415,6 +1400,15 @@ fn valid_access() { ": Ok(_) } + + check_validation! { + " + fn matrix_by_value(m: mat4x4, i: i32) -> vec4 { + return m[i]; + } + ": + Ok(_) + } } #[test] From 1047fa57f017413034be1ed1a5b9c8638f8342c3 Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Fri, 11 Oct 2024 08:12:32 -0700 Subject: [PATCH 30/67] [naga] Move array-by-value snapshot tests to index-by-value.wgsl. --- naga/tests/in/access.wgsl | 12 - naga/tests/in/index-by-value.wgsl | 7 + naga/tests/out/analysis/access.info.ron | 186 --------- .../access.assign_through_ptr.Compute.glsl | 12 +- ...cess.assign_to_ptr_components.Compute.glsl | 12 +- .../out/glsl/access.foo_frag.Fragment.glsl | 12 +- .../out/glsl/access.foo_vert.Vertex.glsl | 16 +- naga/tests/out/hlsl/access.hlsl | 24 +- naga/tests/out/hlsl/access.ron | 4 - naga/tests/out/ir/access.compact.ron | 129 +----- naga/tests/out/ir/access.ron | 129 +----- naga/tests/out/ir/index-by-value.compact.ron | 96 ++++- naga/tests/out/ir/index-by-value.ron | 96 ++++- naga/tests/out/msl/access.msl | 33 +- naga/tests/out/spv/access.spvasm | 387 ++++++++---------- naga/tests/out/spv/index-by-value.spvasm | 135 +++--- naga/tests/out/wgsl/access.wgsl | 23 +- 17 files changed, 499 insertions(+), 814 deletions(-) diff --git a/naga/tests/in/access.wgsl b/naga/tests/in/access.wgsl index 6ff68a13ea..61156172a5 100644 --- a/naga/tests/in/access.wgsl +++ b/naga/tests/in/access.wgsl @@ -168,18 +168,6 @@ fn assign_through_ptr() { assign_array_through_ptr_fn(&arr); } -@vertex -fn foo(@builtin(vertex_index) vi: u32) -> @builtin(position) vec4 { - let arr = array(1, 2, 3, 4, 5); - let value = arr[vi]; - return vec4(vec4(value)); -} - -fn array_by_value(a: array, i: i32) -> i32 { - return a[i]; -} - - struct AssignToMember { x: u32, } diff --git a/naga/tests/in/index-by-value.wgsl b/naga/tests/in/index-by-value.wgsl index f84f21ef06..03dfdc6a1d 100644 --- a/naga/tests/in/index-by-value.wgsl +++ b/naga/tests/in/index-by-value.wgsl @@ -11,3 +11,10 @@ fn index_let_matrix(i: i32, j: i32) -> f32 { let a = mat2x2(1, 2, 3, 4); return a[i][j]; } + +@vertex +fn index_let_array_1d(@builtin(vertex_index) vi: u32) -> @builtin(position) vec4 { + let arr = array(1, 2, 3, 4, 5); + let value = arr[vi]; + return vec4(vec4(value)); +} diff --git a/naga/tests/out/analysis/access.info.ron b/naga/tests/out/analysis/access.info.ron index 8c87ce6010..1a45af466a 100644 --- a/naga/tests/out/analysis/access.info.ron +++ b/naga/tests/out/analysis/access.info.ron @@ -2739,54 +2739,6 @@ sampling: [], dual_source_blending: false, ), - ( - flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), - available_stages: ("VERTEX | FRAGMENT | COMPUTE"), - uniformity: ( - non_uniform_result: Some(0), - requirements: (""), - ), - may_kill: false, - sampling_set: [], - global_uses: [ - (""), - (""), - (""), - (""), - (""), - ], - expressions: [ - ( - uniformity: ( - non_uniform_result: Some(0), - requirements: (""), - ), - ref_count: 1, - assignable_global: None, - ty: Handle(25), - ), - ( - uniformity: ( - non_uniform_result: Some(1), - requirements: (""), - ), - ref_count: 1, - assignable_global: None, - ty: Handle(2), - ), - ( - uniformity: ( - non_uniform_result: Some(0), - requirements: (""), - ), - ref_count: 1, - assignable_global: None, - ty: Handle(2), - ), - ], - sampling: [], - dual_source_blending: false, - ), ( flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), available_stages: ("VERTEX | FRAGMENT | COMPUTE"), @@ -4243,144 +4195,6 @@ sampling: [], dual_source_blending: false, ), - ( - flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), - available_stages: ("VERTEX | FRAGMENT | COMPUTE"), - uniformity: ( - non_uniform_result: Some(0), - requirements: (""), - ), - may_kill: false, - sampling_set: [], - global_uses: [ - (""), - (""), - (""), - (""), - (""), - ], - expressions: [ - ( - uniformity: ( - non_uniform_result: Some(0), - requirements: (""), - ), - ref_count: 1, - assignable_global: None, - ty: Handle(0), - ), - ( - uniformity: ( - non_uniform_result: None, - requirements: (""), - ), - ref_count: 1, - assignable_global: None, - ty: Value(Scalar(( - kind: Sint, - width: 4, - ))), - ), - ( - uniformity: ( - non_uniform_result: None, - requirements: (""), - ), - ref_count: 1, - assignable_global: None, - ty: Value(Scalar(( - kind: Sint, - width: 4, - ))), - ), - ( - uniformity: ( - non_uniform_result: None, - requirements: (""), - ), - ref_count: 1, - assignable_global: None, - ty: Value(Scalar(( - kind: Sint, - width: 4, - ))), - ), - ( - uniformity: ( - non_uniform_result: None, - requirements: (""), - ), - ref_count: 1, - assignable_global: None, - ty: Value(Scalar(( - kind: Sint, - width: 4, - ))), - ), - ( - uniformity: ( - non_uniform_result: None, - requirements: (""), - ), - ref_count: 1, - assignable_global: None, - ty: Value(Scalar(( - kind: Sint, - width: 4, - ))), - ), - ( - uniformity: ( - non_uniform_result: None, - requirements: (""), - ), - ref_count: 1, - assignable_global: None, - ty: Handle(25), - ), - ( - uniformity: ( - non_uniform_result: Some(0), - requirements: (""), - ), - ref_count: 1, - assignable_global: None, - ty: Handle(2), - ), - ( - uniformity: ( - non_uniform_result: Some(0), - requirements: (""), - ), - ref_count: 1, - assignable_global: None, - ty: Value(Vector( - size: Quad, - scalar: ( - kind: Sint, - width: 4, - ), - )), - ), - ( - uniformity: ( - non_uniform_result: Some(0), - requirements: (""), - ), - ref_count: 1, - assignable_global: None, - ty: Value(Vector( - size: Quad, - scalar: ( - kind: Float, - width: 4, - ), - )), - ), - ], - sampling: [], - dual_source_blending: false, - ), ( flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"), available_stages: ("VERTEX | FRAGMENT | COMPUTE"), diff --git a/naga/tests/out/glsl/access.assign_through_ptr.Compute.glsl b/naga/tests/out/glsl/access.assign_through_ptr.Compute.glsl index 07f69f749e..d8b4f8fc16 100644 --- a/naga/tests/out/glsl/access.assign_through_ptr.Compute.glsl +++ b/naga/tests/out/glsl/access.assign_through_ptr.Compute.glsl @@ -23,8 +23,8 @@ struct AssignToMember { uint x; }; -float read_from_private(inout float foo_2) { - float _e1 = foo_2; +float read_from_private(inout float foo_1) { + float _e1 = foo_1; return _e1; } @@ -37,15 +37,11 @@ void assign_through_ptr_fn(inout uint p) { return; } -void assign_array_through_ptr_fn(inout vec4 foo_3[2]) { - foo_3 = vec4[2](vec4(1.0), vec4(2.0)); +void assign_array_through_ptr_fn(inout vec4 foo_2[2]) { + foo_2 = vec4[2](vec4(1.0), vec4(2.0)); return; } -int array_by_value(int a_1[5], int i) { - return a_1[i]; -} - uint fetch_arg_ptr_member(inout AssignToMember p_1) { uint _e2 = p_1.x; return _e2; diff --git a/naga/tests/out/glsl/access.assign_to_ptr_components.Compute.glsl b/naga/tests/out/glsl/access.assign_to_ptr_components.Compute.glsl index 1f072735ea..ec83c8a2ee 100644 --- a/naga/tests/out/glsl/access.assign_to_ptr_components.Compute.glsl +++ b/naga/tests/out/glsl/access.assign_to_ptr_components.Compute.glsl @@ -23,8 +23,8 @@ struct AssignToMember { uint x; }; -float read_from_private(inout float foo_2) { - float _e1 = foo_2; +float read_from_private(inout float foo_1) { + float _e1 = foo_1; return _e1; } @@ -37,15 +37,11 @@ void assign_through_ptr_fn(inout uint p) { return; } -void assign_array_through_ptr_fn(inout vec4 foo_3[2]) { - foo_3 = vec4[2](vec4(1.0), vec4(2.0)); +void assign_array_through_ptr_fn(inout vec4 foo_2[2]) { + foo_2 = vec4[2](vec4(1.0), vec4(2.0)); return; } -int array_by_value(int a_1[5], int i) { - return a_1[i]; -} - uint fetch_arg_ptr_member(inout AssignToMember p_1) { uint _e2 = p_1.x; return _e2; diff --git a/naga/tests/out/glsl/access.foo_frag.Fragment.glsl b/naga/tests/out/glsl/access.foo_frag.Fragment.glsl index 9775b903c7..90092e535e 100644 --- a/naga/tests/out/glsl/access.foo_frag.Fragment.glsl +++ b/naga/tests/out/glsl/access.foo_frag.Fragment.glsl @@ -33,8 +33,8 @@ layout(std430) buffer type_13_block_1Fragment { ivec2 _group_0_binding_2_fs; }; layout(location = 0) out vec4 _fs2p_location0; -float read_from_private(inout float foo_2) { - float _e1 = foo_2; +float read_from_private(inout float foo_1) { + float _e1 = foo_1; return _e1; } @@ -47,15 +47,11 @@ void assign_through_ptr_fn(inout uint p) { return; } -void assign_array_through_ptr_fn(inout vec4 foo_3[2]) { - foo_3 = vec4[2](vec4(1.0), vec4(2.0)); +void assign_array_through_ptr_fn(inout vec4 foo_2[2]) { + foo_2 = vec4[2](vec4(1.0), vec4(2.0)); return; } -int array_by_value(int a_1[5], int i) { - return a_1[i]; -} - uint fetch_arg_ptr_member(inout AssignToMember p_1) { uint _e2 = p_1.x; return _e2; diff --git a/naga/tests/out/glsl/access.foo_vert.Vertex.glsl b/naga/tests/out/glsl/access.foo_vert.Vertex.glsl index d5dc00194a..8e09a39c6a 100644 --- a/naga/tests/out/glsl/access.foo_vert.Vertex.glsl +++ b/naga/tests/out/glsl/access.foo_vert.Vertex.glsl @@ -106,8 +106,8 @@ void test_matrix_within_array_within_struct_accesses() { return; } -float read_from_private(inout float foo_2) { - float _e1 = foo_2; +float read_from_private(inout float foo_1) { + float _e1 = foo_1; return _e1; } @@ -120,15 +120,11 @@ void assign_through_ptr_fn(inout uint p) { return; } -void assign_array_through_ptr_fn(inout vec4 foo_3[2]) { - foo_3 = vec4[2](vec4(1.0), vec4(2.0)); +void assign_array_through_ptr_fn(inout vec4 foo_2[2]) { + foo_2 = vec4[2](vec4(1.0), vec4(2.0)); return; } -int array_by_value(int a_1[5], int i) { - return a_1[i]; -} - uint fetch_arg_ptr_member(inout AssignToMember p_1) { uint _e2 = p_1.x; return _e2; @@ -160,10 +156,10 @@ void main() { mat4x3 _matrix = _group_0_binding_0_vs._matrix; uvec2 arr_1[2] = _group_0_binding_0_vs.arr; float b = _group_0_binding_0_vs._matrix[3u][0]; - int a_2 = _group_0_binding_0_vs.data[(uint(_group_0_binding_0_vs.data.length()) - 2u)].value; + int a_1 = _group_0_binding_0_vs.data[(uint(_group_0_binding_0_vs.data.length()) - 2u)].value; ivec2 c = _group_0_binding_2_vs; float _e33 = read_from_private(foo); - c2_ = int[5](a_2, int(b), 3, 4, 5); + c2_ = int[5](a_1, int(b), 3, 4, 5); c2_[(vi + 1u)] = 42; int value = c2_[vi]; float _e47 = test_arr_as_arg(float[5][10](float[10](0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0), float[10](0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0), float[10](0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0), float[10](0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0), float[10](0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0))); diff --git a/naga/tests/out/hlsl/access.hlsl b/naga/tests/out/hlsl/access.hlsl index 240b720786..178e92b478 100644 --- a/naga/tests/out/hlsl/access.hlsl +++ b/naga/tests/out/hlsl/access.hlsl @@ -205,9 +205,9 @@ void test_matrix_within_array_within_struct_accesses() return; } -float read_from_private(inout float foo_2) +float read_from_private(inout float foo_1) { - float _e1 = foo_2; + float _e1 = foo_1; return _e1; } @@ -228,17 +228,12 @@ ret_Constructarray2_float4_ Constructarray2_float4_(float4 arg0, float4 arg1) { return ret; } -void assign_array_through_ptr_fn(inout float4 foo_3[2]) +void assign_array_through_ptr_fn(inout float4 foo_2[2]) { - foo_3 = Constructarray2_float4_((1.0).xxxx, (2.0).xxxx); + foo_2 = Constructarray2_float4_((1.0).xxxx, (2.0).xxxx); return; } -int array_by_value(int a_1[5], int i) -{ - return a_1[i]; -} - uint fetch_arg_ptr_member(inout AssignToMember p_1) { uint _e2 = p_1.x; @@ -299,10 +294,10 @@ float4 foo_vert(uint vi : SV_VertexID) : SV_Position float4x3 _matrix = float4x3(asfloat(bar.Load3(0+0)), asfloat(bar.Load3(0+16)), asfloat(bar.Load3(0+32)), asfloat(bar.Load3(0+48))); uint2 arr_1[2] = Constructarray2_uint2_(asuint(bar.Load2(144+0)), asuint(bar.Load2(144+8))); float b = asfloat(bar.Load(0+3u*16+0)); - int a_2 = asint(bar.Load(0+(((NagaBufferLengthRW(bar) - 160) / 8) - 2u)*8+160)); + int a_1 = asint(bar.Load(0+(((NagaBufferLengthRW(bar) - 160) / 8) - 2u)*8+160)); int2 c = asint(qux.Load2(0)); const float _e33 = read_from_private(foo); - c2_ = Constructarray5_int_(a_2, int(b), 3, 4, 5); + c2_ = Constructarray5_int_(a_1, int(b), 3, 4, 5); c2_[(vi + 1u)] = 42; int value = c2_[vi]; const float _e47 = test_arr_as_arg(ZeroValuearray5_array10_float__()); @@ -344,13 +339,6 @@ void assign_through_ptr() return; } -float4 foo_1(uint vi_1 : SV_VertexID) : SV_Position -{ - int arr_2[5] = Constructarray5_int_(1, 2, 3, 4, 5); - int value_1 = arr_2[vi_1]; - return float4((value_1).xxxx); -} - [numthreads(1, 1, 1)] void assign_to_ptr_components() { diff --git a/naga/tests/out/hlsl/access.ron b/naga/tests/out/hlsl/access.ron index 1514e55c55..995974ab52 100644 --- a/naga/tests/out/hlsl/access.ron +++ b/naga/tests/out/hlsl/access.ron @@ -4,10 +4,6 @@ entry_point:"foo_vert", target_profile:"vs_5_1", ), - ( - entry_point:"foo_1", - target_profile:"vs_5_1", - ), ], fragment:[ ( diff --git a/naga/tests/out/ir/access.compact.ron b/naga/tests/out/ir/access.compact.ron index db108801c0..2e18f8b357 100644 --- a/naga/tests/out/ir/access.compact.ron +++ b/naga/tests/out/ir/access.compact.ron @@ -1691,47 +1691,6 @@ ), ], ), - ( - name: Some("array_by_value"), - arguments: [ - ( - name: Some("a"), - ty: 25, - binding: None, - ), - ( - name: Some("i"), - ty: 2, - binding: None, - ), - ], - result: Some(( - ty: 2, - binding: None, - )), - local_variables: [], - expressions: [ - FunctionArgument(0), - FunctionArgument(1), - Access( - base: 0, - index: 1, - ), - ], - named_expressions: { - 0: "a", - 1: "i", - }, - body: [ - Emit(( - start: 2, - end: 3, - )), - Return( - value: Some(2), - ), - ], - ), ( name: Some("fetch_arg_ptr_member"), arguments: [ @@ -2453,82 +2412,6 @@ ], ), ), - ( - name: "foo", - stage: Vertex, - early_depth_test: None, - workgroup_size: (0, 0, 0), - function: ( - name: Some("foo"), - arguments: [ - ( - name: Some("vi"), - ty: 0, - binding: Some(BuiltIn(VertexIndex)), - ), - ], - result: Some(( - ty: 24, - binding: Some(BuiltIn(Position( - invariant: false, - ))), - )), - local_variables: [], - expressions: [ - FunctionArgument(0), - Literal(I32(1)), - Literal(I32(2)), - Literal(I32(3)), - Literal(I32(4)), - Literal(I32(5)), - Compose( - ty: 25, - components: [ - 1, - 2, - 3, - 4, - 5, - ], - ), - Access( - base: 6, - index: 0, - ), - Splat( - size: Quad, - value: 7, - ), - As( - expr: 8, - kind: Float, - convert: Some(4), - ), - ], - named_expressions: { - 0: "vi", - 6: "arr", - 7: "value", - }, - body: [ - Emit(( - start: 6, - end: 7, - )), - Emit(( - start: 7, - end: 8, - )), - Emit(( - start: 8, - end: 10, - )), - Return( - value: Some(9), - ), - ], - ), - ), ( name: "assign_to_ptr_components", stage: Compute, @@ -2552,35 +2435,35 @@ ], expressions: [ LocalVariable(0), - CallResult(7), + CallResult(6), LocalVariable(1), - CallResult(9), + CallResult(8), ], named_expressions: {}, body: [ Call( - function: 8, + function: 7, arguments: [ 0, ], result: None, ), Call( - function: 7, + function: 6, arguments: [ 0, ], result: Some(1), ), Call( - function: 10, + function: 9, arguments: [ 2, ], result: None, ), Call( - function: 9, + function: 8, arguments: [ 2, ], diff --git a/naga/tests/out/ir/access.ron b/naga/tests/out/ir/access.ron index db108801c0..2e18f8b357 100644 --- a/naga/tests/out/ir/access.ron +++ b/naga/tests/out/ir/access.ron @@ -1691,47 +1691,6 @@ ), ], ), - ( - name: Some("array_by_value"), - arguments: [ - ( - name: Some("a"), - ty: 25, - binding: None, - ), - ( - name: Some("i"), - ty: 2, - binding: None, - ), - ], - result: Some(( - ty: 2, - binding: None, - )), - local_variables: [], - expressions: [ - FunctionArgument(0), - FunctionArgument(1), - Access( - base: 0, - index: 1, - ), - ], - named_expressions: { - 0: "a", - 1: "i", - }, - body: [ - Emit(( - start: 2, - end: 3, - )), - Return( - value: Some(2), - ), - ], - ), ( name: Some("fetch_arg_ptr_member"), arguments: [ @@ -2453,82 +2412,6 @@ ], ), ), - ( - name: "foo", - stage: Vertex, - early_depth_test: None, - workgroup_size: (0, 0, 0), - function: ( - name: Some("foo"), - arguments: [ - ( - name: Some("vi"), - ty: 0, - binding: Some(BuiltIn(VertexIndex)), - ), - ], - result: Some(( - ty: 24, - binding: Some(BuiltIn(Position( - invariant: false, - ))), - )), - local_variables: [], - expressions: [ - FunctionArgument(0), - Literal(I32(1)), - Literal(I32(2)), - Literal(I32(3)), - Literal(I32(4)), - Literal(I32(5)), - Compose( - ty: 25, - components: [ - 1, - 2, - 3, - 4, - 5, - ], - ), - Access( - base: 6, - index: 0, - ), - Splat( - size: Quad, - value: 7, - ), - As( - expr: 8, - kind: Float, - convert: Some(4), - ), - ], - named_expressions: { - 0: "vi", - 6: "arr", - 7: "value", - }, - body: [ - Emit(( - start: 6, - end: 7, - )), - Emit(( - start: 7, - end: 8, - )), - Emit(( - start: 8, - end: 10, - )), - Return( - value: Some(9), - ), - ], - ), - ), ( name: "assign_to_ptr_components", stage: Compute, @@ -2552,35 +2435,35 @@ ], expressions: [ LocalVariable(0), - CallResult(7), + CallResult(6), LocalVariable(1), - CallResult(9), + CallResult(8), ], named_expressions: {}, body: [ Call( - function: 8, + function: 7, arguments: [ 0, ], result: None, ), Call( - function: 7, + function: 6, arguments: [ 0, ], result: Some(1), ), Call( - function: 10, + function: 9, arguments: [ 2, ], result: None, ), Call( - function: 9, + function: 8, arguments: [ 2, ], diff --git a/naga/tests/out/ir/index-by-value.compact.ron b/naga/tests/out/ir/index-by-value.compact.ron index d8d8dd67e3..9cc07b0776 100644 --- a/naga/tests/out/ir/index-by-value.compact.ron +++ b/naga/tests/out/ir/index-by-value.compact.ron @@ -59,6 +59,23 @@ ), ), ), + ( + name: None, + inner: Scalar(( + kind: Uint, + width: 4, + )), + ), + ( + name: None, + inner: Vector( + size: Quad, + scalar: ( + kind: Float, + width: 4, + ), + ), + ), ], special_types: ( ray_desc: None, @@ -274,5 +291,82 @@ ], ), ], - entry_points: [], + entry_points: [ + ( + name: "index_let_array_1d", + stage: Vertex, + early_depth_test: None, + workgroup_size: (0, 0, 0), + function: ( + name: Some("index_let_array_1d"), + arguments: [ + ( + name: Some("vi"), + ty: 7, + binding: Some(BuiltIn(VertexIndex)), + ), + ], + result: Some(( + ty: 8, + binding: Some(BuiltIn(Position( + invariant: false, + ))), + )), + local_variables: [], + expressions: [ + FunctionArgument(0), + Literal(I32(1)), + Literal(I32(2)), + Literal(I32(3)), + Literal(I32(4)), + Literal(I32(5)), + Compose( + ty: 1, + components: [ + 1, + 2, + 3, + 4, + 5, + ], + ), + Access( + base: 6, + index: 0, + ), + Splat( + size: Quad, + value: 7, + ), + As( + expr: 8, + kind: Float, + convert: Some(4), + ), + ], + named_expressions: { + 0: "vi", + 6: "arr", + 7: "value", + }, + body: [ + Emit(( + start: 6, + end: 7, + )), + Emit(( + start: 7, + end: 8, + )), + Emit(( + start: 8, + end: 10, + )), + Return( + value: Some(9), + ), + ], + ), + ), + ], ) \ No newline at end of file diff --git a/naga/tests/out/ir/index-by-value.ron b/naga/tests/out/ir/index-by-value.ron index d8d8dd67e3..9cc07b0776 100644 --- a/naga/tests/out/ir/index-by-value.ron +++ b/naga/tests/out/ir/index-by-value.ron @@ -59,6 +59,23 @@ ), ), ), + ( + name: None, + inner: Scalar(( + kind: Uint, + width: 4, + )), + ), + ( + name: None, + inner: Vector( + size: Quad, + scalar: ( + kind: Float, + width: 4, + ), + ), + ), ], special_types: ( ray_desc: None, @@ -274,5 +291,82 @@ ], ), ], - entry_points: [], + entry_points: [ + ( + name: "index_let_array_1d", + stage: Vertex, + early_depth_test: None, + workgroup_size: (0, 0, 0), + function: ( + name: Some("index_let_array_1d"), + arguments: [ + ( + name: Some("vi"), + ty: 7, + binding: Some(BuiltIn(VertexIndex)), + ), + ], + result: Some(( + ty: 8, + binding: Some(BuiltIn(Position( + invariant: false, + ))), + )), + local_variables: [], + expressions: [ + FunctionArgument(0), + Literal(I32(1)), + Literal(I32(2)), + Literal(I32(3)), + Literal(I32(4)), + Literal(I32(5)), + Compose( + ty: 1, + components: [ + 1, + 2, + 3, + 4, + 5, + ], + ), + Access( + base: 6, + index: 0, + ), + Splat( + size: Quad, + value: 7, + ), + As( + expr: 8, + kind: Float, + convert: Some(4), + ), + ], + named_expressions: { + 0: "vi", + 6: "arr", + 7: "value", + }, + body: [ + Emit(( + start: 6, + end: 7, + )), + Emit(( + start: 7, + end: 8, + )), + Emit(( + start: 8, + end: 10, + )), + Return( + value: Some(9), + ), + ], + ), + ), + ], ) \ No newline at end of file diff --git a/naga/tests/out/msl/access.msl b/naga/tests/out/msl/access.msl index 1c0fb50f41..2103a8d099 100644 --- a/naga/tests/out/msl/access.msl +++ b/naga/tests/out/msl/access.msl @@ -139,9 +139,9 @@ void test_matrix_within_array_within_struct_accesses( } float read_from_private( - thread float& foo_2 + thread float& foo_1 ) { - float _e1 = foo_2; + float _e1 = foo_1; return _e1; } @@ -159,19 +159,12 @@ void assign_through_ptr_fn( } void assign_array_through_ptr_fn( - thread type_22& foo_3 + thread type_22& foo_2 ) { - foo_3 = type_22 {metal::float4(1.0), metal::float4(2.0)}; + foo_2 = type_22 {metal::float4(1.0), metal::float4(2.0)}; return; } -int array_by_value( - type_20 a_1, - int i -) { - return a_1.inner[i]; -} - uint fetch_arg_ptr_member( thread AssignToMember& p_1 ) { @@ -222,10 +215,10 @@ vertex foo_vertOutput foo_vert( metal::float4x3 _matrix = bar._matrix; type_10 arr_1 = bar.arr; float b = bar._matrix[3u].x; - int a_2 = bar.data[(1 + (_buffer_sizes.size1 - 160 - 8) / 8) - 2u].value; + int a_1 = bar.data[(1 + (_buffer_sizes.size1 - 160 - 8) / 8) - 2u].value; metal::int2 c = qux; float _e33 = read_from_private(foo); - c2_ = type_20 {a_2, static_cast(b), 3, 4, 5}; + c2_ = type_20 {a_1, static_cast(b), 3, 4, 5}; c2_.inner[vi + 1u] = 42; int value = c2_.inner[vi]; float _e47 = test_arr_as_arg(type_18 {}); @@ -260,20 +253,6 @@ kernel void assign_through_ptr( } -struct foo_1Input { -}; -struct foo_1Output { - metal::float4 member_3 [[position]]; -}; -vertex foo_1Output foo_1( - uint vi_1 [[vertex_id]] -) { - type_20 arr_2 = type_20 {1, 2, 3, 4, 5}; - int value_1 = arr_2.inner[vi_1]; - return foo_1Output { static_cast(metal::int4(value_1)) }; -} - - kernel void assign_to_ptr_components( ) { AssignToMember s1_ = {}; diff --git a/naga/tests/out/spv/access.spvasm b/naga/tests/out/spv/access.spvasm index cb5437356e..b2f87bdcee 100644 --- a/naga/tests/out/spv/access.spvasm +++ b/naga/tests/out/spv/access.spvasm @@ -1,19 +1,18 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 364 +; Bound: 342 OpCapability Shader OpExtension "SPV_KHR_storage_buffer_storage_class" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint Vertex %260 "foo_vert" %255 %258 -OpEntryPoint Fragment %312 "foo_frag" %311 -OpEntryPoint GLCompute %330 "assign_through_ptr" -OpEntryPoint Vertex %344 "foo" %341 %343 -OpEntryPoint GLCompute %354 "assign_to_ptr_components" -OpExecutionMode %312 OriginUpperLeft -OpExecutionMode %330 LocalSize 1 1 1 -OpExecutionMode %354 LocalSize 1 1 1 +OpEntryPoint Vertex %250 "foo_vert" %245 %248 +OpEntryPoint Fragment %303 "foo_frag" %302 +OpEntryPoint GLCompute %321 "assign_through_ptr" +OpEntryPoint GLCompute %332 "assign_to_ptr_components" +OpExecutionMode %303 OriginUpperLeft +OpExecutionMode %321 LocalSize 1 1 1 +OpExecutionMode %332 LocalSize 1 1 1 OpMemberName %6 0 "a" OpMemberName %6 1 "b" OpMemberName %6 2 "c" @@ -52,30 +51,25 @@ OpName %205 "p" OpName %206 "assign_through_ptr_fn" OpName %211 "foo" OpName %212 "assign_array_through_ptr_fn" -OpName %219 "a" -OpName %220 "i" -OpName %221 "array_by_value" -OpName %229 "p" -OpName %230 "fetch_arg_ptr_member" -OpName %236 "p" -OpName %237 "assign_to_arg_ptr_member" -OpName %242 "p" -OpName %243 "fetch_arg_ptr_array_element" -OpName %249 "p" -OpName %250 "assign_to_arg_ptr_array_element" -OpName %255 "vi" -OpName %260 "foo_vert" -OpName %272 "foo" -OpName %273 "c2" -OpName %312 "foo_frag" -OpName %330 "assign_through_ptr" -OpName %335 "val" -OpName %336 "arr" -OpName %341 "vi" -OpName %344 "foo" -OpName %354 "assign_to_ptr_components" -OpName %355 "s1" -OpName %357 "a1" +OpName %219 "p" +OpName %220 "fetch_arg_ptr_member" +OpName %226 "p" +OpName %227 "assign_to_arg_ptr_member" +OpName %232 "p" +OpName %233 "fetch_arg_ptr_array_element" +OpName %239 "p" +OpName %240 "assign_to_arg_ptr_array_element" +OpName %245 "vi" +OpName %250 "foo_vert" +OpName %262 "foo" +OpName %263 "c2" +OpName %303 "foo_frag" +OpName %321 "assign_through_ptr" +OpName %326 "val" +OpName %327 "arr" +OpName %332 "assign_to_ptr_components" +OpName %333 "s1" +OpName %335 "a1" OpMemberDecorate %6 0 Offset 0 OpMemberDecorate %6 1 Offset 16 OpMemberDecorate %6 2 Offset 28 @@ -122,11 +116,9 @@ OpDecorate %55 DescriptorSet 0 OpDecorate %55 Binding 3 OpDecorate %56 Block OpMemberDecorate %56 0 Offset 0 -OpDecorate %255 BuiltIn VertexIndex -OpDecorate %258 BuiltIn Position -OpDecorate %311 Location 0 -OpDecorate %341 BuiltIn VertexIndex -OpDecorate %343 BuiltIn Position +OpDecorate %245 BuiltIn VertexIndex +OpDecorate %248 BuiltIn Position +OpDecorate %302 Location 0 %2 = OpTypeVoid %3 = OpTypeInt 32 0 %4 = OpTypeVector %3 3 @@ -239,54 +231,49 @@ OpDecorate %343 BuiltIn Position %214 = OpConstantComposite %31 %64 %64 %64 %64 %215 = OpConstantComposite %31 %66 %66 %66 %66 %216 = OpConstantComposite %34 %214 %215 -%222 = OpTypeFunction %5 %32 %5 -%225 = OpTypePointer Function %32 -%231 = OpTypeFunction %3 %37 -%238 = OpTypeFunction %2 %37 -%244 = OpTypeFunction %3 %40 -%251 = OpTypeFunction %2 %40 -%256 = OpTypePointer Input %3 -%255 = OpVariable %256 Input -%259 = OpTypePointer Output %31 -%258 = OpVariable %259 Output -%262 = OpTypePointer StorageBuffer %23 -%265 = OpConstant %8 0.0 -%266 = OpConstant %3 3 -%267 = OpConstant %5 3 -%268 = OpConstant %5 4 -%269 = OpConstant %5 5 -%270 = OpConstant %5 42 -%271 = OpConstantNull %29 -%274 = OpConstantNull %32 -%279 = OpTypePointer StorageBuffer %9 -%282 = OpTypePointer StorageBuffer %18 -%285 = OpTypePointer StorageBuffer %10 -%286 = OpTypePointer StorageBuffer %8 -%289 = OpTypePointer StorageBuffer %19 -%292 = OpTypePointer StorageBuffer %7 -%293 = OpTypePointer StorageBuffer %5 -%305 = OpTypeVector %5 4 -%311 = OpVariable %259 Output -%314 = OpConstantComposite %10 %265 %265 %265 -%315 = OpConstantComposite %10 %64 %64 %64 -%316 = OpConstantComposite %10 %66 %66 %66 -%317 = OpConstantComposite %10 %68 %68 %68 -%318 = OpConstantComposite %9 %314 %315 %316 %317 -%319 = OpConstantComposite %17 %41 %41 -%320 = OpConstantComposite %17 %104 %104 -%321 = OpConstantComposite %18 %319 %320 -%322 = OpConstantNull %23 -%323 = OpConstantComposite %31 %265 %265 %265 %265 -%331 = OpConstant %3 33 -%332 = OpConstantComposite %31 %72 %72 %72 %72 -%333 = OpConstantComposite %31 %142 %142 %142 %142 -%334 = OpConstantComposite %34 %332 %333 -%341 = OpVariable %256 Input -%343 = OpVariable %259 Output -%345 = OpConstant %5 2 -%346 = OpConstantComposite %32 %63 %345 %267 %268 %269 -%356 = OpConstantNull %36 -%358 = OpConstantNull %38 +%221 = OpTypeFunction %3 %37 +%228 = OpTypeFunction %2 %37 +%234 = OpTypeFunction %3 %40 +%241 = OpTypeFunction %2 %40 +%246 = OpTypePointer Input %3 +%245 = OpVariable %246 Input +%249 = OpTypePointer Output %31 +%248 = OpVariable %249 Output +%252 = OpTypePointer StorageBuffer %23 +%255 = OpConstant %8 0.0 +%256 = OpConstant %3 3 +%257 = OpConstant %5 3 +%258 = OpConstant %5 4 +%259 = OpConstant %5 5 +%260 = OpConstant %5 42 +%261 = OpConstantNull %29 +%264 = OpTypePointer Function %32 +%265 = OpConstantNull %32 +%270 = OpTypePointer StorageBuffer %9 +%273 = OpTypePointer StorageBuffer %18 +%276 = OpTypePointer StorageBuffer %10 +%277 = OpTypePointer StorageBuffer %8 +%280 = OpTypePointer StorageBuffer %19 +%283 = OpTypePointer StorageBuffer %7 +%284 = OpTypePointer StorageBuffer %5 +%296 = OpTypeVector %5 4 +%302 = OpVariable %249 Output +%305 = OpConstantComposite %10 %255 %255 %255 +%306 = OpConstantComposite %10 %64 %64 %64 +%307 = OpConstantComposite %10 %66 %66 %66 +%308 = OpConstantComposite %10 %68 %68 %68 +%309 = OpConstantComposite %9 %305 %306 %307 %308 +%310 = OpConstantComposite %17 %41 %41 +%311 = OpConstantComposite %17 %104 %104 +%312 = OpConstantComposite %18 %310 %311 +%313 = OpConstantNull %23 +%314 = OpConstantComposite %31 %255 %255 %255 %255 +%322 = OpConstant %3 33 +%323 = OpConstantComposite %31 %72 %72 %72 %72 +%324 = OpConstantComposite %31 %142 %142 %142 %142 +%325 = OpConstantComposite %34 %323 %324 +%334 = OpConstantNull %36 +%336 = OpConstantNull %38 %59 = OpFunction %2 None %60 %58 = OpLabel %87 = OpVariable %88 Function %63 @@ -430,146 +417,120 @@ OpBranch %217 OpStore %211 %216 OpReturn OpFunctionEnd -%221 = OpFunction %5 None %222 -%219 = OpFunctionParameter %32 -%220 = OpFunctionParameter %5 +%220 = OpFunction %3 None %221 +%219 = OpFunctionParameter %37 %218 = OpLabel -%224 = OpVariable %225 Function -OpBranch %223 -%223 = OpLabel -OpStore %224 %219 -%226 = OpAccessChain %88 %224 %220 -%227 = OpLoad %5 %226 -OpReturnValue %227 +OpBranch %222 +%222 = OpLabel +%223 = OpAccessChain %33 %219 %41 +%224 = OpLoad %3 %223 +OpReturnValue %224 OpFunctionEnd -%230 = OpFunction %3 None %231 -%229 = OpFunctionParameter %37 -%228 = OpLabel -OpBranch %232 -%232 = OpLabel -%233 = OpAccessChain %33 %229 %41 -%234 = OpLoad %3 %233 -OpReturnValue %234 +%227 = OpFunction %2 None %228 +%226 = OpFunctionParameter %37 +%225 = OpLabel +OpBranch %229 +%229 = OpLabel +%230 = OpAccessChain %33 %226 %41 +OpStore %230 %16 +OpReturn OpFunctionEnd -%237 = OpFunction %2 None %238 -%236 = OpFunctionParameter %37 +%233 = OpFunction %3 None %234 +%232 = OpFunctionParameter %40 +%231 = OpLabel +OpBranch %235 %235 = OpLabel -OpBranch %239 -%239 = OpLabel -%240 = OpAccessChain %33 %236 %41 -OpStore %240 %16 -OpReturn +%236 = OpAccessChain %33 %232 %104 +%237 = OpLoad %3 %236 +OpReturnValue %237 OpFunctionEnd -%243 = OpFunction %3 None %244 -%242 = OpFunctionParameter %40 -%241 = OpLabel -OpBranch %245 -%245 = OpLabel -%246 = OpAccessChain %33 %242 %104 -%247 = OpLoad %3 %246 -OpReturnValue %247 +%240 = OpFunction %2 None %241 +%239 = OpFunctionParameter %40 +%238 = OpLabel +OpBranch %242 +%242 = OpLabel +%243 = OpAccessChain %33 %239 %104 +OpStore %243 %16 +OpReturn OpFunctionEnd -%250 = OpFunction %2 None %251 -%249 = OpFunctionParameter %40 -%248 = OpLabel -OpBranch %252 -%252 = OpLabel -%253 = OpAccessChain %33 %249 %104 -OpStore %253 %16 +%250 = OpFunction %2 None %60 +%244 = OpLabel +%262 = OpVariable %27 Function %255 +%263 = OpVariable %264 Function %265 +%247 = OpLoad %3 %245 +%251 = OpAccessChain %61 %49 %41 +%253 = OpAccessChain %252 %52 %41 +%254 = OpAccessChain %136 %55 %41 +OpBranch %266 +%266 = OpLabel +%267 = OpLoad %8 %262 +OpStore %262 %64 +%268 = OpFunctionCall %2 %59 +%269 = OpFunctionCall %2 %135 +%271 = OpAccessChain %270 %47 %41 +%272 = OpLoad %9 %271 +%274 = OpAccessChain %273 %47 %39 +%275 = OpLoad %18 %274 +%278 = OpAccessChain %277 %47 %41 %256 %41 +%279 = OpLoad %8 %278 +%281 = OpArrayLength %3 %47 5 +%282 = OpISub %3 %281 %14 +%285 = OpAccessChain %284 %47 %30 %282 %41 +%286 = OpLoad %5 %285 +%287 = OpLoad %23 %253 +%288 = OpFunctionCall %8 %193 %262 +%289 = OpConvertFToS %5 %279 +%290 = OpCompositeConstruct %32 %286 %289 %257 %258 %259 +OpStore %263 %290 +%291 = OpIAdd %3 %247 %104 +%292 = OpAccessChain %88 %263 %291 +OpStore %292 %260 +%293 = OpAccessChain %88 %263 %247 +%294 = OpLoad %5 %293 +%295 = OpFunctionCall %8 %199 %261 +%297 = OpCompositeConstruct %296 %294 %294 %294 %294 +%298 = OpConvertSToF %31 %297 +%299 = OpMatrixTimesVector %10 %272 %298 +%300 = OpCompositeConstruct %31 %299 %66 +OpStore %248 %300 OpReturn OpFunctionEnd -%260 = OpFunction %2 None %60 -%254 = OpLabel -%272 = OpVariable %27 Function %265 -%273 = OpVariable %225 Function %274 -%257 = OpLoad %3 %255 -%261 = OpAccessChain %61 %49 %41 -%263 = OpAccessChain %262 %52 %41 -%264 = OpAccessChain %136 %55 %41 -OpBranch %275 -%275 = OpLabel -%276 = OpLoad %8 %272 -OpStore %272 %64 -%277 = OpFunctionCall %2 %59 -%278 = OpFunctionCall %2 %135 -%280 = OpAccessChain %279 %47 %41 -%281 = OpLoad %9 %280 -%283 = OpAccessChain %282 %47 %39 -%284 = OpLoad %18 %283 -%287 = OpAccessChain %286 %47 %41 %266 %41 -%288 = OpLoad %8 %287 -%290 = OpArrayLength %3 %47 5 -%291 = OpISub %3 %290 %14 -%294 = OpAccessChain %293 %47 %30 %291 %41 -%295 = OpLoad %5 %294 -%296 = OpLoad %23 %263 -%297 = OpFunctionCall %8 %193 %272 -%298 = OpConvertFToS %5 %288 -%299 = OpCompositeConstruct %32 %295 %298 %267 %268 %269 -OpStore %273 %299 -%300 = OpIAdd %3 %257 %104 -%301 = OpAccessChain %88 %273 %300 -OpStore %301 %270 -%302 = OpAccessChain %88 %273 %257 -%303 = OpLoad %5 %302 -%304 = OpFunctionCall %8 %199 %271 -%306 = OpCompositeConstruct %305 %303 %303 %303 %303 -%307 = OpConvertSToF %31 %306 -%308 = OpMatrixTimesVector %10 %281 %307 -%309 = OpCompositeConstruct %31 %308 %66 -OpStore %258 %309 +%303 = OpFunction %2 None %60 +%301 = OpLabel +%304 = OpAccessChain %252 %52 %41 +OpBranch %315 +%315 = OpLabel +%316 = OpAccessChain %277 %47 %41 %104 %14 +OpStore %316 %64 +%317 = OpAccessChain %270 %47 %41 +OpStore %317 %309 +%318 = OpAccessChain %273 %47 %39 +OpStore %318 %312 +%319 = OpAccessChain %284 %47 %30 %104 %41 +OpStore %319 %63 +OpStore %304 %313 +OpStore %302 %314 OpReturn OpFunctionEnd -%312 = OpFunction %2 None %60 -%310 = OpLabel -%313 = OpAccessChain %262 %52 %41 -OpBranch %324 -%324 = OpLabel -%325 = OpAccessChain %286 %47 %41 %104 %14 -OpStore %325 %64 -%326 = OpAccessChain %279 %47 %41 -OpStore %326 %318 -%327 = OpAccessChain %282 %47 %39 -OpStore %327 %321 -%328 = OpAccessChain %293 %47 %30 %104 %41 -OpStore %328 %63 -OpStore %313 %322 -OpStore %311 %323 +%321 = OpFunction %2 None %60 +%320 = OpLabel +%326 = OpVariable %33 Function %322 +%327 = OpVariable %35 Function %325 +OpBranch %328 +%328 = OpLabel +%329 = OpFunctionCall %2 %206 %326 +%330 = OpFunctionCall %2 %212 %327 OpReturn OpFunctionEnd -%330 = OpFunction %2 None %60 -%329 = OpLabel -%335 = OpVariable %33 Function %331 -%336 = OpVariable %35 Function %334 +%332 = OpFunction %2 None %60 +%331 = OpLabel +%333 = OpVariable %37 Function %334 +%335 = OpVariable %40 Function %336 OpBranch %337 %337 = OpLabel -%338 = OpFunctionCall %2 %206 %335 -%339 = OpFunctionCall %2 %212 %336 -OpReturn -OpFunctionEnd -%344 = OpFunction %2 None %60 -%340 = OpLabel -%348 = OpVariable %225 Function -%342 = OpLoad %3 %341 -OpBranch %347 -%347 = OpLabel -OpStore %348 %346 -%349 = OpAccessChain %88 %348 %342 -%350 = OpLoad %5 %349 -%351 = OpCompositeConstruct %305 %350 %350 %350 %350 -%352 = OpConvertSToF %31 %351 -OpStore %343 %352 -OpReturn -OpFunctionEnd -%354 = OpFunction %2 None %60 -%353 = OpLabel -%355 = OpVariable %37 Function %356 -%357 = OpVariable %40 Function %358 -OpBranch %359 -%359 = OpLabel -%360 = OpFunctionCall %2 %237 %355 -%361 = OpFunctionCall %3 %230 %355 -%362 = OpFunctionCall %2 %250 %357 -%363 = OpFunctionCall %3 %243 %357 +%338 = OpFunctionCall %2 %227 %333 +%339 = OpFunctionCall %3 %220 %333 +%340 = OpFunctionCall %2 %240 %335 +%341 = OpFunctionCall %3 %233 %335 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/naga/tests/out/spv/index-by-value.spvasm b/naga/tests/out/spv/index-by-value.spvasm index 62c0893b14..94d609d375 100644 --- a/naga/tests/out/spv/index-by-value.spvasm +++ b/naga/tests/out/spv/index-by-value.spvasm @@ -1,14 +1,16 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 59 +; Bound: 77 OpCapability Shader -OpCapability Linkage %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 +OpEntryPoint Vertex %66 "index_let_array_1d" %61 %64 OpDecorate %4 ArrayStride 4 OpDecorate %7 ArrayStride 4 OpDecorate %9 ArrayStride 8 +OpDecorate %61 BuiltIn VertexIndex +OpDecorate %64 BuiltIn Position %2 = OpTypeVoid %3 = OpTypeInt 32 1 %6 = OpTypeInt 32 0 @@ -20,61 +22,84 @@ OpDecorate %9 ArrayStride 8 %10 = OpTypeFloat 32 %12 = OpTypeVector %10 2 %11 = OpTypeMatrix %12 2 -%17 = OpTypeFunction %3 %4 %3 -%20 = OpTypePointer Function %4 -%21 = OpTypePointer Function %3 -%28 = OpTypeFunction %3 %3 %3 -%29 = OpConstant %3 1 -%30 = OpConstant %3 2 -%31 = OpConstantComposite %7 %29 %30 -%32 = OpConstant %3 3 -%33 = OpConstant %3 4 -%34 = OpConstantComposite %7 %32 %33 -%35 = OpConstantComposite %9 %31 %34 -%38 = OpTypePointer Function %9 -%45 = OpTypeFunction %10 %3 %3 -%46 = OpConstant %10 1.0 -%47 = OpConstant %10 2.0 -%48 = OpConstant %10 3.0 -%49 = OpConstant %10 4.0 -%50 = OpConstantComposite %12 %46 %47 -%51 = OpConstantComposite %12 %48 %49 -%52 = OpConstantComposite %11 %50 %51 -%55 = OpTypePointer Function %11 -%56 = OpTypePointer Function %10 -%16 = OpFunction %3 None %17 -%14 = OpFunctionParameter %4 -%15 = OpFunctionParameter %3 -%13 = OpLabel -%19 = OpVariable %20 Function -OpBranch %18 -%18 = OpLabel -OpStore %19 %14 -%22 = OpAccessChain %21 %19 %15 -%23 = OpLoad %3 %22 -OpReturnValue %23 +%13 = OpTypeVector %10 4 +%18 = OpTypeFunction %3 %4 %3 +%21 = OpTypePointer Function %4 +%22 = OpTypePointer Function %3 +%29 = OpTypeFunction %3 %3 %3 +%30 = OpConstant %3 1 +%31 = OpConstant %3 2 +%32 = OpConstantComposite %7 %30 %31 +%33 = OpConstant %3 3 +%34 = OpConstant %3 4 +%35 = OpConstantComposite %7 %33 %34 +%36 = OpConstantComposite %9 %32 %35 +%39 = OpTypePointer Function %9 +%46 = OpTypeFunction %10 %3 %3 +%47 = OpConstant %10 1.0 +%48 = OpConstant %10 2.0 +%49 = OpConstant %10 3.0 +%50 = OpConstant %10 4.0 +%51 = OpConstantComposite %12 %47 %48 +%52 = OpConstantComposite %12 %49 %50 +%53 = OpConstantComposite %11 %51 %52 +%56 = OpTypePointer Function %11 +%57 = OpTypePointer Function %10 +%62 = OpTypePointer Input %6 +%61 = OpVariable %62 Input +%65 = OpTypePointer Output %13 +%64 = OpVariable %65 Output +%67 = OpTypeFunction %2 +%68 = OpConstant %3 5 +%69 = OpConstantComposite %4 %30 %31 %33 %34 %68 +%74 = OpTypeVector %3 4 +%17 = OpFunction %3 None %18 +%15 = OpFunctionParameter %4 +%16 = OpFunctionParameter %3 +%14 = OpLabel +%20 = OpVariable %21 Function +OpBranch %19 +%19 = OpLabel +OpStore %20 %15 +%23 = OpAccessChain %22 %20 %16 +%24 = OpLoad %3 %23 +OpReturnValue %24 OpFunctionEnd -%27 = OpFunction %3 None %28 -%25 = OpFunctionParameter %3 +%28 = OpFunction %3 None %29 %26 = OpFunctionParameter %3 -%24 = OpLabel -%37 = OpVariable %38 Function -OpBranch %36 -%36 = OpLabel -OpStore %37 %35 -%39 = OpAccessChain %21 %37 %25 %26 -%40 = OpLoad %3 %39 -OpReturnValue %40 +%27 = OpFunctionParameter %3 +%25 = OpLabel +%38 = OpVariable %39 Function +OpBranch %37 +%37 = OpLabel +OpStore %38 %36 +%40 = OpAccessChain %22 %38 %26 %27 +%41 = OpLoad %3 %40 +OpReturnValue %41 OpFunctionEnd -%44 = OpFunction %10 None %45 -%42 = OpFunctionParameter %3 +%45 = OpFunction %10 None %46 %43 = OpFunctionParameter %3 -%41 = OpLabel -%54 = OpVariable %55 Function -OpBranch %53 -%53 = OpLabel -OpStore %54 %52 -%57 = OpAccessChain %56 %54 %42 %43 -%58 = OpLoad %10 %57 -OpReturnValue %58 +%44 = OpFunctionParameter %3 +%42 = OpLabel +%55 = OpVariable %56 Function +OpBranch %54 +%54 = OpLabel +OpStore %55 %53 +%58 = OpAccessChain %57 %55 %43 %44 +%59 = OpLoad %10 %58 +OpReturnValue %59 +OpFunctionEnd +%66 = OpFunction %2 None %67 +%60 = OpLabel +%71 = OpVariable %21 Function +%63 = OpLoad %6 %61 +OpBranch %70 +%70 = OpLabel +OpStore %71 %69 +%72 = OpAccessChain %22 %71 %63 +%73 = OpLoad %3 %72 +%75 = OpCompositeConstruct %74 %73 %73 %73 %73 +%76 = OpConvertSToF %13 %75 +OpStore %64 %76 +OpReturn OpFunctionEnd \ No newline at end of file diff --git a/naga/tests/out/wgsl/access.wgsl b/naga/tests/out/wgsl/access.wgsl index c659b21262..4d60beddb7 100644 --- a/naga/tests/out/wgsl/access.wgsl +++ b/naga/tests/out/wgsl/access.wgsl @@ -111,8 +111,8 @@ fn test_matrix_within_array_within_struct_accesses() { return; } -fn read_from_private(foo_2: ptr) -> f32 { - let _e1 = (*foo_2); +fn read_from_private(foo_1: ptr) -> f32 { + let _e1 = (*foo_1); return _e1; } @@ -125,15 +125,11 @@ fn assign_through_ptr_fn(p: ptr) { return; } -fn assign_array_through_ptr_fn(foo_3: ptr, 2>>) { - (*foo_3) = array, 2>(vec4(1f), vec4(2f)); +fn assign_array_through_ptr_fn(foo_2: ptr, 2>>) { + (*foo_2) = array, 2>(vec4(1f), vec4(2f)); return; } -fn array_by_value(a_1: array, i: i32) -> i32 { - return a_1[i]; -} - fn fetch_arg_ptr_member(p_1: ptr) -> u32 { let _e2 = (*p_1).x; return _e2; @@ -166,11 +162,11 @@ fn foo_vert(@builtin(vertex_index) vi: u32) -> @builtin(position) vec4 { let _matrix = bar._matrix; let arr_1 = bar.arr; let b = bar._matrix[3u][0]; - let a_2 = bar.data[(arrayLength((&bar.data)) - 2u)].value; + let a_1 = bar.data[(arrayLength((&bar.data)) - 2u)].value; let c = qux; let data_pointer = (&bar.data[0].value); let _e33 = read_from_private((&foo)); - c2_ = array(a_2, i32(b), 3i, 4i, 5i); + c2_ = array(a_1, i32(b), 3i, 4i, 5i); c2_[(vi + 1u)] = 42i; let value = c2_[vi]; let _e47 = test_arr_as_arg(array, 5>()); @@ -197,13 +193,6 @@ fn assign_through_ptr() { return; } -@vertex -fn foo_1(@builtin(vertex_index) vi_1: u32) -> @builtin(position) vec4 { - const arr_2 = array(1i, 2i, 3i, 4i, 5i); - let value_1 = arr_2[vi_1]; - return vec4(vec4(value_1)); -} - @compute @workgroup_size(1, 1, 1) fn assign_to_ptr_components() { var s1_: AssignToMember; From 76b16050905754bb29d059bb0d6aeaa13c7fa77a Mon Sep 17 00:00:00 2001 From: Schell Carl Scivally Date: Sat, 12 Oct 2024 07:24:16 +1300 Subject: [PATCH 31/67] [spv-in] sampling from depth textures returns a scalar and is splatted (#6384) --- CHANGELOG.md | 1 + naga/src/front/spv/image.rs | 74 ++++-- naga/src/proc/mod.rs | 4 + naga/tests/in/spv/fetch_depth.spv | Bin 0 -> 772 bytes naga/tests/in/spv/fetch_depth.spvasm | 52 +++++ naga/tests/out/hlsl/fetch_depth.hlsl | 25 ++ naga/tests/out/hlsl/fetch_depth.ron | 12 + naga/tests/out/ir/fetch_depth.compact.ron | 195 ++++++++++++++++ naga/tests/out/ir/fetch_depth.ron | 265 ++++++++++++++++++++++ naga/tests/out/msl/fetch_depth.msl | 31 +++ naga/tests/out/spv/fetch_depth.spvasm | 74 ++++++ naga/tests/out/wgsl/fetch_depth.wgsl | 26 +++ naga/tests/snapshots.rs | 6 +- 13 files changed, 744 insertions(+), 21 deletions(-) create mode 100644 naga/tests/in/spv/fetch_depth.spv create mode 100644 naga/tests/in/spv/fetch_depth.spvasm create mode 100644 naga/tests/out/hlsl/fetch_depth.hlsl create mode 100644 naga/tests/out/hlsl/fetch_depth.ron create mode 100644 naga/tests/out/ir/fetch_depth.compact.ron create mode 100644 naga/tests/out/ir/fetch_depth.ron create mode 100644 naga/tests/out/msl/fetch_depth.msl create mode 100644 naga/tests/out/spv/fetch_depth.spvasm create mode 100644 naga/tests/out/wgsl/fetch_depth.wgsl diff --git a/CHANGELOG.md b/CHANGELOG.md index 28392f582f..65ea26072d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -104,6 +104,7 @@ By @bradwerth [#6216](https://github.com/gfx-rs/wgpu/pull/6216). #### Naga +- SPIR-V frontend splats depth texture sample and load results. Fixes [issue #4551](https://github.com/gfx-rs/wgpu/issues/4551). By @schell in [#6384](https://github.com/gfx-rs/wgpu/pull/6384). - Accept only `vec3` (not `vecN`) for the `cross` built-in. By @ErichDonGubler in [#6171](https://github.com/gfx-rs/wgpu/pull/6171). - Configure `SourceLanguage` when enabling debug info in SPV-out. By @kvark in [#6256](https://github.com/gfx-rs/wgpu/pull/6256). - Per-polygon and flat inputs should not be considered subgroup uniform. By @magcius in [#6276](https://github.com/gfx-rs/wgpu/pull/6276). diff --git a/naga/src/front/spv/image.rs b/naga/src/front/spv/image.rs index 284c4cf7fd..71ba79e1e4 100644 --- a/naga/src/front/spv/image.rs +++ b/naga/src/front/spv/image.rs @@ -377,36 +377,61 @@ impl> super::Frontend { let coord_handle = self.get_expr_handle(coordinate_id, coord_lexp, ctx, emitter, block, body_idx); let coord_type_handle = self.lookup_type.lookup(coord_lexp.type_id)?.handle; - let (coordinate, array_index) = match ctx.type_arena[image_ty].inner { + let (coordinate, array_index, is_depth) = match ctx.type_arena[image_ty].inner { crate::TypeInner::Image { dim, arrayed, - class: _, - } => extract_image_coordinates( - dim, - if arrayed { - ExtraCoordinate::ArrayLayer - } else { - ExtraCoordinate::Garbage - }, - coord_handle, - coord_type_handle, - ctx, - ), + class, + } => { + let (coord, array_index) = extract_image_coordinates( + dim, + if arrayed { + ExtraCoordinate::ArrayLayer + } else { + ExtraCoordinate::Garbage + }, + coord_handle, + coord_type_handle, + ctx, + ); + (coord, array_index, class.is_depth()) + } _ => return Err(Error::InvalidImage(image_ty)), }; - let expr = crate::Expression::ImageLoad { + let image_load_expr = crate::Expression::ImageLoad { image: image_lexp.handle, coordinate, array_index, sample, level, }; + let image_load_handle = ctx + .expressions + .append(image_load_expr, self.span_from_with_op(start)); + + let handle = if is_depth { + let result_ty = self.lookup_type.lookup(result_type_id)?; + // The return type of `OpImageRead` can be a scalar or vector. + match ctx.type_arena[result_ty.handle].inner { + crate::TypeInner::Vector { size, .. } => { + let splat_expr = crate::Expression::Splat { + size, + value: image_load_handle, + }; + ctx.expressions + .append(splat_expr, self.span_from_with_op(start)) + } + _ => image_load_handle, + } + } else { + image_load_handle + }; + self.lookup_expression.insert( result_id, LookupExpression { - handle: ctx.expressions.append(expr, self.span_from_with_op(start)), + handle, type_id: result_type_id, block_id, }, @@ -593,11 +618,12 @@ impl> super::Frontend { ref other => return Err(Error::InvalidGlobalVar(other.clone())), } - let ((coordinate, array_index), depth_ref) = match ctx.type_arena[image_ty].inner { + let ((coordinate, array_index), depth_ref, is_depth) = match ctx.type_arena[image_ty].inner + { crate::TypeInner::Image { dim, arrayed, - class: _, + class, } => ( extract_image_coordinates( dim, @@ -642,6 +668,7 @@ impl> super::Frontend { None => None, } }, + class.is_depth(), ), _ => return Err(Error::InvalidImage(image_ty)), }; @@ -656,10 +683,21 @@ impl> super::Frontend { level, depth_ref, }; + let image_sample_handle = ctx.expressions.append(expr, self.span_from_with_op(start)); + let handle = if is_depth && depth_ref.is_none() { + let splat_expr = crate::Expression::Splat { + size: crate::VectorSize::Quad, + value: image_sample_handle, + }; + ctx.expressions + .append(splat_expr, self.span_from_with_op(start)) + } else { + image_sample_handle + }; self.lookup_expression.insert( result_id, LookupExpression { - handle: ctx.expressions.append(expr, self.span_from_with_op(start)), + handle, type_id: result_type_id, block_id, }, diff --git a/naga/src/proc/mod.rs b/naga/src/proc/mod.rs index abbe0c7e46..b7a08bc8ad 100644 --- a/naga/src/proc/mod.rs +++ b/naga/src/proc/mod.rs @@ -622,6 +622,10 @@ impl super::ImageClass { crate::ImageClass::Storage { .. } => false, } } + + pub const fn is_depth(self) -> bool { + matches!(self, crate::ImageClass::Depth { .. }) + } } impl crate::Module { diff --git a/naga/tests/in/spv/fetch_depth.spv b/naga/tests/in/spv/fetch_depth.spv new file mode 100644 index 0000000000000000000000000000000000000000..4b9915618d3f4d629c6d66cba1427190a321f809 GIT binary patch literal 772 zcmYL`%T5A85JiibMj|K!L3wCmdL&`v9tlPlZe;5hus{e47B29E{R=lH-qR1Mq^2IX z`re-EvY584*)X%p7W!g+D~t~D`^v0qW$5#*tYb|@@XgoZuw3r8$IX8IvHd*m)hp!8 zIeE{{5|5cz%^Cbn6KzFiS7IZ_rZEJ(qdeo}*a>$5t7BX9vA+MW%W#LWYB27@Y}AhR zY1W0if}_VgchC5>steU#jt#|jsp#b+VO>RP&J4s*Db||lDUv^=^L^zQd;>) global_2 : register(t2); + +void function() +{ + uint2 _e6 = asuint(global_1.Load2(0)); + float _e7 = global_2.Load(int3(_e6, 0)).x; + global.Store(0, asuint((_e7).xxxx.x)); + return; +} + +[numthreads(32, 1, 1)] +void cullfetch_depth() +{ + function(); +} diff --git a/naga/tests/out/hlsl/fetch_depth.ron b/naga/tests/out/hlsl/fetch_depth.ron new file mode 100644 index 0000000000..cb8a85c5f8 --- /dev/null +++ b/naga/tests/out/hlsl/fetch_depth.ron @@ -0,0 +1,12 @@ +( + vertex:[ + ], + fragment:[ + ], + compute:[ + ( + entry_point:"cullfetch_depth", + target_profile:"cs_5_1", + ), + ], +) diff --git a/naga/tests/out/ir/fetch_depth.compact.ron b/naga/tests/out/ir/fetch_depth.compact.ron new file mode 100644 index 0000000000..dc5ecf08ad --- /dev/null +++ b/naga/tests/out/ir/fetch_depth.compact.ron @@ -0,0 +1,195 @@ +( + types: [ + ( + name: None, + inner: Scalar(( + kind: Float, + width: 4, + )), + ), + ( + name: None, + inner: Scalar(( + kind: Sint, + width: 4, + )), + ), + ( + name: None, + inner: Struct( + members: [ + ( + name: None, + ty: 0, + binding: None, + offset: 0, + ), + ], + span: 4, + ), + ), + ( + name: None, + inner: Vector( + size: Bi, + scalar: ( + kind: Uint, + width: 4, + ), + ), + ), + ( + name: None, + inner: Struct( + members: [ + ( + name: None, + ty: 3, + binding: None, + offset: 0, + ), + ], + span: 8, + ), + ), + ( + name: None, + inner: Image( + dim: D2, + arrayed: false, + class: Depth( + multi: false, + ), + ), + ), + ], + special_types: ( + ray_desc: None, + ray_intersection: None, + predeclared_types: {}, + ), + constants: [ + ( + name: None, + ty: 1, + init: 0, + ), + ], + overrides: [], + global_variables: [ + ( + name: None, + space: Storage( + access: ("LOAD | STORE"), + ), + binding: Some(( + group: 0, + binding: 0, + )), + ty: 2, + init: None, + ), + ( + name: None, + space: Storage( + access: ("LOAD"), + ), + binding: Some(( + group: 0, + binding: 1, + )), + ty: 4, + init: None, + ), + ( + name: None, + space: Handle, + binding: Some(( + group: 0, + binding: 2, + )), + ty: 5, + init: None, + ), + ], + global_expressions: [ + Literal(I32(0)), + ], + functions: [ + ( + name: None, + arguments: [], + result: None, + local_variables: [], + expressions: [ + GlobalVariable(2), + GlobalVariable(0), + GlobalVariable(1), + Constant(0), + AccessIndex( + base: 1, + index: 0, + ), + AccessIndex( + base: 2, + index: 0, + ), + Load( + pointer: 5, + ), + ImageLoad( + image: 0, + coordinate: 6, + array_index: None, + sample: None, + level: Some(3), + ), + Splat( + size: Quad, + value: 7, + ), + AccessIndex( + base: 8, + index: 0, + ), + ], + named_expressions: {}, + body: [ + Emit(( + start: 4, + end: 10, + )), + Store( + pointer: 4, + value: 9, + ), + Return( + value: None, + ), + ], + ), + ], + entry_points: [ + ( + name: "cull::fetch_depth", + stage: Compute, + early_depth_test: None, + workgroup_size: (32, 1, 1), + function: ( + name: Some("cull::fetch_depth_wrap"), + arguments: [], + result: None, + local_variables: [], + expressions: [], + named_expressions: {}, + body: [ + Call( + function: 0, + arguments: [], + result: None, + ), + ], + ), + ), + ], +) \ No newline at end of file diff --git a/naga/tests/out/ir/fetch_depth.ron b/naga/tests/out/ir/fetch_depth.ron new file mode 100644 index 0000000000..210a9ee26f --- /dev/null +++ b/naga/tests/out/ir/fetch_depth.ron @@ -0,0 +1,265 @@ +( + types: [ + ( + name: None, + inner: Scalar(( + kind: Uint, + width: 4, + )), + ), + ( + name: None, + inner: Scalar(( + kind: Float, + width: 4, + )), + ), + ( + name: None, + inner: Vector( + size: Quad, + scalar: ( + kind: Float, + width: 4, + ), + ), + ), + ( + name: None, + inner: Scalar(( + kind: Sint, + width: 4, + )), + ), + ( + name: None, + inner: Struct( + members: [ + ( + name: None, + ty: 1, + binding: None, + offset: 0, + ), + ], + span: 4, + ), + ), + ( + name: None, + inner: Pointer( + base: 4, + space: Storage( + access: ("LOAD | STORE"), + ), + ), + ), + ( + name: None, + inner: Vector( + size: Bi, + scalar: ( + kind: Uint, + width: 4, + ), + ), + ), + ( + name: None, + inner: Struct( + members: [ + ( + name: None, + ty: 6, + binding: None, + offset: 0, + ), + ], + span: 8, + ), + ), + ( + name: None, + inner: Pointer( + base: 7, + space: Storage( + access: ("LOAD | STORE"), + ), + ), + ), + ( + name: None, + inner: Vector( + size: Bi, + scalar: ( + kind: Float, + width: 4, + ), + ), + ), + ( + name: None, + inner: Image( + dim: D2, + arrayed: false, + class: Depth( + multi: false, + ), + ), + ), + ( + name: None, + inner: Pointer( + base: 1, + space: Storage( + access: ("LOAD | STORE"), + ), + ), + ), + ( + name: None, + inner: Pointer( + base: 6, + space: Storage( + access: ("LOAD | STORE"), + ), + ), + ), + ], + special_types: ( + ray_desc: None, + ray_intersection: None, + predeclared_types: {}, + ), + constants: [ + ( + name: None, + ty: 0, + init: 0, + ), + ( + name: None, + ty: 3, + init: 1, + ), + ], + overrides: [], + global_variables: [ + ( + name: None, + space: Storage( + access: ("LOAD | STORE"), + ), + binding: Some(( + group: 0, + binding: 0, + )), + ty: 4, + init: None, + ), + ( + name: None, + space: Storage( + access: ("LOAD"), + ), + binding: Some(( + group: 0, + binding: 1, + )), + ty: 7, + init: None, + ), + ( + name: None, + space: Handle, + binding: Some(( + group: 0, + binding: 2, + )), + ty: 10, + init: None, + ), + ], + global_expressions: [ + Literal(U32(0)), + Literal(I32(0)), + ], + functions: [ + ( + name: None, + arguments: [], + result: None, + local_variables: [], + expressions: [ + GlobalVariable(2), + GlobalVariable(0), + GlobalVariable(1), + Constant(1), + Constant(0), + AccessIndex( + base: 1, + index: 0, + ), + AccessIndex( + base: 2, + index: 0, + ), + Load( + pointer: 6, + ), + ImageLoad( + image: 0, + coordinate: 7, + array_index: None, + sample: None, + level: Some(3), + ), + Splat( + size: Quad, + value: 8, + ), + AccessIndex( + base: 9, + index: 0, + ), + ], + named_expressions: {}, + body: [ + Emit(( + start: 5, + end: 11, + )), + Store( + pointer: 5, + value: 10, + ), + Return( + value: None, + ), + ], + ), + ], + entry_points: [ + ( + name: "cull::fetch_depth", + stage: Compute, + early_depth_test: None, + workgroup_size: (32, 1, 1), + function: ( + name: Some("cull::fetch_depth_wrap"), + arguments: [], + result: None, + local_variables: [], + expressions: [], + named_expressions: {}, + body: [ + Call( + function: 0, + arguments: [], + result: None, + ), + ], + ), + ), + ], +) \ No newline at end of file diff --git a/naga/tests/out/msl/fetch_depth.msl b/naga/tests/out/msl/fetch_depth.msl new file mode 100644 index 0000000000..867a284372 --- /dev/null +++ b/naga/tests/out/msl/fetch_depth.msl @@ -0,0 +1,31 @@ +// language: metal1.0 +#include +#include + +using metal::uint; + +struct type_2 { + float member; +}; +struct type_4 { + metal::uint2 member; +}; + +void function( + device type_2& global, + device type_4 const& global_1, + metal::depth2d global_2 +) { + metal::uint2 _e6 = global_1.member; + float _e7 = global_2.read(metal::uint2(_e6), 0); + global.member = metal::float4(_e7).x; + return; +} + +kernel void cullfetch_depth( + device type_2& global [[user(fake0)]] +, device type_4 const& global_1 [[user(fake0)]] +, metal::depth2d global_2 [[user(fake0)]] +) { + function(global, global_1, global_2); +} diff --git a/naga/tests/out/spv/fetch_depth.spvasm b/naga/tests/out/spv/fetch_depth.spvasm new file mode 100644 index 0000000000..54aa5eb1cd --- /dev/null +++ b/naga/tests/out/spv/fetch_depth.spvasm @@ -0,0 +1,74 @@ +; SPIR-V +; Version: 1.1 +; Generator: rspirv +; Bound: 46 +OpCapability Shader +OpExtension "SPV_KHR_storage_buffer_storage_class" +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %40 "cull::fetch_depth" +OpExecutionMode %40 LocalSize 32 1 1 +OpMemberDecorate %5 0 Offset 0 +OpMemberDecorate %8 0 Offset 0 +OpDecorate %11 DescriptorSet 0 +OpDecorate %11 Binding 0 +OpDecorate %12 Block +OpMemberDecorate %12 0 Offset 0 +OpDecorate %14 NonWritable +OpDecorate %14 DescriptorSet 0 +OpDecorate %14 Binding 1 +OpDecorate %15 Block +OpMemberDecorate %15 0 Offset 0 +OpDecorate %17 DescriptorSet 0 +OpDecorate %17 Binding 2 +%2 = OpTypeVoid +%3 = OpTypeFloat 32 +%4 = OpTypeInt 32 1 +%5 = OpTypeStruct %3 +%7 = OpTypeInt 32 0 +%6 = OpTypeVector %7 2 +%8 = OpTypeStruct %6 +%9 = OpTypeImage %3 2D 1 0 0 1 Unknown +%10 = OpConstant %4 0 +%12 = OpTypeStruct %5 +%13 = OpTypePointer StorageBuffer %12 +%11 = OpVariable %13 StorageBuffer +%15 = OpTypeStruct %8 +%16 = OpTypePointer StorageBuffer %15 +%14 = OpVariable %16 StorageBuffer +%18 = OpTypePointer UniformConstant %9 +%17 = OpVariable %18 UniformConstant +%21 = OpTypeFunction %2 +%22 = OpTypePointer StorageBuffer %5 +%23 = OpConstant %7 0 +%25 = OpTypePointer StorageBuffer %8 +%29 = OpTypePointer StorageBuffer %3 +%30 = OpTypePointer StorageBuffer %6 +%33 = OpTypeVector %3 4 +%20 = OpFunction %2 None %21 +%19 = OpLabel +%24 = OpAccessChain %22 %11 %23 +%26 = OpAccessChain %25 %14 %23 +%27 = OpLoad %9 %17 +OpBranch %28 +%28 = OpLabel +%31 = OpAccessChain %30 %26 %23 +%32 = OpLoad %6 %31 +%34 = OpImageFetch %33 %27 %32 Lod %10 +%35 = OpCompositeExtract %3 %34 0 +%36 = OpCompositeConstruct %33 %35 %35 %35 %35 +%37 = OpCompositeExtract %3 %36 0 +%38 = OpAccessChain %29 %24 %23 +OpStore %38 %37 +OpReturn +OpFunctionEnd +%40 = OpFunction %2 None %21 +%39 = OpLabel +%41 = OpAccessChain %22 %11 %23 +%42 = OpAccessChain %25 %14 %23 +%43 = OpLoad %9 %17 +OpBranch %44 +%44 = OpLabel +%45 = OpFunctionCall %2 %20 +OpReturn +OpFunctionEnd \ No newline at end of file diff --git a/naga/tests/out/wgsl/fetch_depth.wgsl b/naga/tests/out/wgsl/fetch_depth.wgsl new file mode 100644 index 0000000000..3e206bc267 --- /dev/null +++ b/naga/tests/out/wgsl/fetch_depth.wgsl @@ -0,0 +1,26 @@ +struct type_2 { + member: f32, +} + +struct type_4 { + member: vec2, +} + +@group(0) @binding(0) +var global: type_2; +@group(0) @binding(1) +var global_1: type_4; +@group(0) @binding(2) +var global_2: texture_depth_2d; + +fn function() { + let _e6 = global_1.member; + let _e7 = textureLoad(global_2, _e6, 0i); + global.member = vec4(_e7).x; + return; +} + +@compute @workgroup_size(32, 1, 1) +fn cullfetch_depth() { + function(); +} diff --git a/naga/tests/snapshots.rs b/naga/tests/snapshots.rs index 9b9ff15931..244c9f506b 100644 --- a/naga/tests/snapshots.rs +++ b/naga/tests/snapshots.rs @@ -1063,11 +1063,11 @@ fn convert_spv_all() { false, Targets::METAL | Targets::GLSL | Targets::HLSL | Targets::WGSL, ); + convert_spv("atomic_i_increment", false, Targets::IR); convert_spv( - "atomic_i_increment", + "fetch_depth", false, - // TODO(@schell): remove Targets::NO_VALIDATION when OpAtomicIIncrement lands - Targets::IR | Targets::NO_VALIDATION, + Targets::IR | Targets::SPIRV | Targets::METAL | Targets::HLSL | Targets::WGSL, ); } From bc5b24520ae44726daaae4ae489a60f3848b600e Mon Sep 17 00:00:00 2001 From: Erich Gubler Date: Thu, 10 Oct 2024 16:17:24 -0400 Subject: [PATCH 32/67] style: remove trailing whitespace in PR template --- .github/pull_request_template.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 95e8ed603e..898771d8dd 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -7,7 +7,7 @@ _Describe what problem this is solving, and how it's solved._ **Testing** _Explain how this change is tested._ -