summaryrefslogtreecommitdiff
path: root/op_crates/webgpu/shader.rs
diff options
context:
space:
mode:
Diffstat (limited to 'op_crates/webgpu/shader.rs')
-rw-r--r--op_crates/webgpu/shader.rs16
1 files changed, 11 insertions, 5 deletions
diff --git a/op_crates/webgpu/shader.rs b/op_crates/webgpu/shader.rs
index 8a0613862..63578ce64 100644
--- a/op_crates/webgpu/shader.rs
+++ b/op_crates/webgpu/shader.rs
@@ -1,6 +1,7 @@
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
use deno_core::error::bad_resource_id;
+use deno_core::error::null_opbuf;
use deno_core::error::AnyError;
use deno_core::serde_json::json;
use deno_core::serde_json::Value;
@@ -31,7 +32,7 @@ pub struct CreateShaderModuleArgs {
pub fn op_webgpu_create_shader_module(
state: &mut OpState,
args: CreateShaderModuleArgs,
- zero_copy: &mut [ZeroCopyBuf],
+ zero_copy: Option<ZeroCopyBuf>,
) -> Result<Value, AnyError> {
let instance = state.borrow::<super::Instance>();
let device_resource = state
@@ -45,10 +46,15 @@ pub fn op_webgpu_create_shader_module(
wgpu_core::pipeline::ShaderModuleSource::Wgsl(Cow::from(code))
}
None => wgpu_core::pipeline::ShaderModuleSource::SpirV(Cow::from(unsafe {
- let (prefix, data, suffix) = zero_copy[0].align_to::<u32>();
- assert!(prefix.is_empty());
- assert!(suffix.is_empty());
- data
+ match &zero_copy {
+ Some(zero_copy) => {
+ let (prefix, data, suffix) = zero_copy.align_to::<u32>();
+ assert!(prefix.is_empty());
+ assert!(suffix.is_empty());
+ data
+ }
+ None => return Err(null_opbuf()),
+ }
})),
};