summaryrefslogtreecommitdiff
path: root/op_crates/webgpu/shader.rs
diff options
context:
space:
mode:
authorAaron O'Mullan <aaron.omullan@gmail.com>2021-04-02 15:47:57 +0200
committerGitHub <noreply@github.com>2021-04-02 09:47:57 -0400
commit058579da562989ed15c86598053644bbc86c6747 (patch)
tree7f0f2bf30684dcbb350b93d987771f17a4abd250 /op_crates/webgpu/shader.rs
parentadf57610904cb4f4ef25fb077f6e39c9017a4ea9 (diff)
refactor(ops): remove variadic buffers (#9944)
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()),
+ }
})),
};