From 6a684e5cdf680628ccf7cfacede2ba222cc028e7 Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Mon, 25 Jan 2021 14:13:55 -0500 Subject: [PATCH] Don't build shader interface without the validation flag --- wgpu-core/src/device/mod.rs | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/wgpu-core/src/device/mod.rs b/wgpu-core/src/device/mod.rs index 7399fdc95f..99657d3cde 100644 --- a/wgpu-core/src/device/mod.rs +++ b/wgpu-core/src/device/mod.rs @@ -962,15 +962,16 @@ impl Device { pipeline::ShaderModuleSource::Naga(module) => (None, Some(module)), }; - let interface = module.as_ref().map(|m| validation::Interface::new(m)); - - let naga_result = match module { + let (naga_result, interface) = match module { // If succeeded, then validate it and attempt to give it to gfx-hal directly. Some(module) => { - if desc.flags.contains(wgt::ShaderFlags::VALIDATION) { + let interface = if desc.flags.contains(wgt::ShaderFlags::VALIDATION) { naga::proc::Validator::new().validate(&module)?; - } - if desc + Some(validation::Interface::new(&module)) + } else { + None + }; + let naga_result = if desc .flags .contains(wgt::ShaderFlags::EXPERIMENTAL_TRANSLATION) { @@ -984,9 +985,10 @@ impl Device { } } else { Err(Some(module)) - } + }; + (naga_result, interface) } - None => Err(None), + None => (Err(None), None), }; // Otherwise, fall back to SPIR-V. @@ -1954,7 +1956,10 @@ impl Device { | wgt::VertexFormat::Double3 | wgt::VertexFormat::Double4 = attribute.format { - if !self.features.contains(wgt::Features::VERTEX_ATTRIBUTE_64BIT) { + if !self + .features + .contains(wgt::Features::VERTEX_ATTRIBUTE_64BIT) + { return Err(pipeline::CreateRenderPipelineError::MissingFeature( wgt::Features::VERTEX_ATTRIBUTE_64BIT, ));