Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix compilation on wasm32-unknown-unknown without webgl feature #2355

Merged
merged 1 commit into from
Jan 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions wgpu/src/backend/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1272,21 +1272,25 @@ impl crate::Context for Context {
);
let spv_module_info = validator.validate(&spv_module).unwrap();

let wgsl_text = back::wgsl::write_string(&spv_module, &spv_module_info).unwrap();
let writer_flags = naga::back::wgsl::WriterFlags::empty();
let wgsl_text =
back::wgsl::write_string(&spv_module, &spv_module_info, writer_flags).unwrap();
web_sys::GpuShaderModuleDescriptor::new(wgsl_text.as_str())
}
#[cfg(feature = "glsl")]
ShaderSource::Glsl {
crate::ShaderSource::Glsl {
ref shader,
stage,
ref defines,
} => {
use naga::{back, front, valid};

// Parse the given shader code and store its representation.
let options = naga::front::glsl::Options {
let options = front::glsl::Options {
stage,
defines: defines.clone(),
};
let mut parser = naga::front::glsl::Parser::default();
let mut parser = front::glsl::Parser::default();
let glsl_module = parser.parse(&options, shader).unwrap();

let mut validator = valid::Validator::new(
Expand All @@ -1295,7 +1299,10 @@ impl crate::Context for Context {
);
let glsl_module_info = validator.validate(&glsl_module).unwrap();

let wgsl_text = back::wgsl::write_string(&glsl_module, &glsl_module_info).unwrap();
let writer_flags = naga::back::wgsl::WriterFlags::empty();
let wgsl_text =
back::wgsl::write_string(&glsl_module, &glsl_module_info, writer_flags)
.unwrap();
web_sys::GpuShaderModuleDescriptor::new(wgsl_text.as_str())
}
crate::ShaderSource::Wgsl(ref code) => web_sys::GpuShaderModuleDescriptor::new(code),
Expand Down