From d9678cda2790ae11ec144be5054a4c06d2043320 Mon Sep 17 00:00:00 2001 From: Nicolas Silva Date: Tue, 7 Jun 2022 11:54:53 +0200 Subject: [PATCH 1/2] Expose the source location in CreateShaderModuleError. --- wgpu-core/src/pipeline.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/wgpu-core/src/pipeline.rs b/wgpu-core/src/pipeline.rs index 21b99b6547..04b241aba7 100644 --- a/wgpu-core/src/pipeline.rs +++ b/wgpu-core/src/pipeline.rs @@ -126,6 +126,16 @@ pub enum CreateShaderModuleError { MissingFeatures(#[from] MissingFeatures), } +impl CreateShaderModuleError { + pub fn location(&self, source: &str) -> Option { + match *self { + CreateShaderModuleError::Parsing(ref err) => err.inner.location(source), + CreateShaderModuleError::Validation(ref err) => err.inner.location(source), + _ => None, + } + } +} + /// Describes a programmable pipeline stage. #[derive(Clone, Debug)] #[cfg_attr(feature = "trace", derive(serde::Serialize))] From 5d4612d04cd3444da501dcb6106a180e64c2931e Mon Sep 17 00:00:00 2001 From: Nicolas Silva Date: Wed, 8 Jun 2022 09:35:33 +0200 Subject: [PATCH 2/2] Bump naga dep to 89bed99. --- Cargo.lock | 2 +- wgpu-core/Cargo.toml | 2 +- wgpu-hal/Cargo.toml | 4 ++-- wgpu-hal/src/gles/device.rs | 18 ++++++++++++++++++ wgpu/Cargo.toml | 6 +++--- 5 files changed, 25 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6fe3304ca6..05d2153d13 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1034,7 +1034,7 @@ dependencies = [ [[package]] name = "naga" version = "0.8.0" -source = "git+https://github.com/gfx-rs/naga?rev=571302e#571302e3ff09cb856f63a3683da308159872b7cc" +source = "git+https://github.com/gfx-rs/naga?rev=89bed99#89bed99bcc995bc5068c9c112fd9b7d7896bb148" dependencies = [ "bit-set", "bitflags", diff --git a/wgpu-core/Cargo.toml b/wgpu-core/Cargo.toml index 3f1ed7e04f..9835466814 100644 --- a/wgpu-core/Cargo.toml +++ b/wgpu-core/Cargo.toml @@ -42,7 +42,7 @@ thiserror = "1" [dependencies.naga] git = "https://github.com/gfx-rs/naga" -rev = "571302e" +rev = "89bed99" #version = "0.8" features = ["span", "validate", "wgsl-in"] diff --git a/wgpu-hal/Cargo.toml b/wgpu-hal/Cargo.toml index 020b39cc9a..843d53e9ba 100644 --- a/wgpu-hal/Cargo.toml +++ b/wgpu-hal/Cargo.toml @@ -95,14 +95,14 @@ android-properties = "0.2" [dependencies.naga] git = "https://github.com/gfx-rs/naga" -rev = "571302e" +rev = "89bed99" #version = "0.8" # DEV dependencies [dev-dependencies.naga] git = "https://github.com/gfx-rs/naga" -rev = "571302e" +rev = "89bed99" #version = "0.8" features = ["wgsl-in"] diff --git a/wgpu-hal/src/gles/device.rs b/wgpu-hal/src/gles/device.rs index 0688abb056..a52e6b5a66 100644 --- a/wgpu-hal/src/gles/device.rs +++ b/wgpu-hal/src/gles/device.rs @@ -144,6 +144,23 @@ impl super::Device { .position(|ep| ep.name.as_str() == stage.entry_point) .ok_or(crate::PipelineError::EntryPoint(naga_stage))?; + use naga::proc::BoundsCheckPolicy; + // The image bounds checks require the TEXTURE_LEVELS feature available in GL core 1.3+. + let version = gl.version(); + let image_check = if !version.is_embedded && (version.major, version.minor) >= (1, 3) { + BoundsCheckPolicy::ReadZeroSkipWrite + } else { + BoundsCheckPolicy::Unchecked + }; + + // Other bounds check are either provided by glsl or not implemented yet. + let policies = naga::proc::BoundsCheckPolicies { + index: BoundsCheckPolicy::Unchecked, + buffer: BoundsCheckPolicy::Unchecked, + image: image_check, + binding_array: BoundsCheckPolicy::Unchecked, + }; + let mut output = String::new(); let mut writer = glsl::Writer::new( &mut output, @@ -151,6 +168,7 @@ impl super::Device { &shader.info, &context.layout.naga_options, &pipeline_options, + policies, ) .map_err(|e| { let msg = format!("{}", e); diff --git a/wgpu/Cargo.toml b/wgpu/Cargo.toml index 237590c5e9..ced6d6352b 100644 --- a/wgpu/Cargo.toml +++ b/wgpu/Cargo.toml @@ -140,20 +140,20 @@ env_logger = "0.9" [dependencies.naga] git = "https://github.com/gfx-rs/naga" -rev = "571302e" +rev = "89bed99" #version = "0.8" optional = true # used to test all the example shaders [dev-dependencies.naga] git = "https://github.com/gfx-rs/naga" -rev = "571302e" +rev = "89bed99" #version = "0.8" features = ["wgsl-in"] [target.'cfg(target_arch = "wasm32")'.dependencies.naga] git = "https://github.com/gfx-rs/naga" -rev = "571302e" +rev = "89bed99" #version = "0.8" features = ["wgsl-out"]