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

Update deno_webgpu #2539

Merged
merged 10 commits into from
Mar 19, 2022
Merged
Show file tree
Hide file tree
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
11 changes: 5 additions & 6 deletions cts_runner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ publish = false
resolver = "2"

[dependencies]
deno_console = "0.35.0"
deno_core = "0.117.0"
deno_timers = "0.33.0"
deno_url = "0.35.0"
deno_web = "0.66.0"
deno_webidl = "0.35.0"
deno_console = "0.42.0"
deno_core = "0.124.0"
deno_url = "0.42.0"
deno_web = "0.73.0"
deno_webidl = "0.42.0"
deno_webgpu = { path = "../deno_webgpu" }
tokio = { version = "1.15.0", features = ["full"] }
termcolor = "1.1.2"
2 changes: 1 addition & 1 deletion cts_runner/examples/hello-compute.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ computePass.setPipeline(computePipeline);
computePass.setBindGroup(0, bindGroup);
computePass.insertDebugMarker("compute collatz iterations");
computePass.dispatch(numbers.length);
computePass.endPass();
computePass.end();

encoder.copyBufferToBuffer(storageBuffer, 0, stagingBuffer, 0, size);

Expand Down
31 changes: 13 additions & 18 deletions cts_runner/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ use std::{
use deno_core::anyhow::anyhow;
use deno_core::error::AnyError;
use deno_core::located_script_name;
use deno_core::op;
use deno_core::resolve_url_or_path;
use deno_core::serde_json;
use deno_core::serde_json::json;
use deno_core::JsRuntime;
use deno_core::OpState;
use deno_core::RuntimeOptions;
use deno_core::ZeroCopyBuf;
use deno_web::BlobStore;
Expand Down Expand Up @@ -40,8 +40,7 @@ async fn run() -> Result<(), AnyError> {
deno_webidl::init(),
deno_console::init(),
deno_url::init(),
deno_web::init(BlobStore::default(), None),
deno_timers::init::<Permissions>(),
deno_web::init::<Permissions>(BlobStore::default(), None),
deno_webgpu::init(true),
extension(),
],
Expand All @@ -53,10 +52,7 @@ async fn run() -> Result<(), AnyError> {
let bootstrap_script = format!("globalThis.bootstrap({})", serde_json::to_string(&cfg)?);
isolate.execute_script(&located_script_name!(), &bootstrap_script)?;

isolate
.op_state()
.borrow_mut()
.put(Permissions{});
isolate.op_state().borrow_mut().put(Permissions {});

let mod_id = isolate.load_main_module(&specifier, None).await?;
let mod_rx = isolate.mod_evaluate(mod_id);
Expand All @@ -77,9 +73,9 @@ async fn run() -> Result<(), AnyError> {
fn extension() -> deno_core::Extension {
deno_core::Extension::builder()
.ops(vec![
("op_exit", deno_core::op_sync(op_exit)),
("op_read_file_sync", deno_core::op_sync(op_read_file_sync)),
("op_write_file_sync", deno_core::op_sync(op_write_file_sync)),
op_exit::decl(),
op_read_file_sync::decl(),
op_write_file_sync::decl(),
])
.js(deno_core::include_js_files!(
prefix "deno:cts_runner",
Expand All @@ -88,23 +84,22 @@ fn extension() -> deno_core::Extension {
.build()
}

fn op_exit(_state: &mut OpState, code: i32, _: ()) -> Result<(), AnyError> {
#[op]
fn op_exit(code: i32) -> Result<(), AnyError> {
std::process::exit(code)
}

fn op_read_file_sync(_state: &mut OpState, path: String, _: ()) -> Result<ZeroCopyBuf, AnyError> {
#[op]
fn op_read_file_sync(path: String) -> Result<ZeroCopyBuf, AnyError> {
let path = std::path::Path::new(&path);
let mut file = std::fs::File::open(path)?;
let mut buf = Vec::new();
file.read_to_end(&mut buf)?;
Ok(ZeroCopyBuf::from(buf))
}

fn op_write_file_sync(
_state: &mut OpState,
path: String,
buf: ZeroCopyBuf,
) -> Result<(), AnyError> {
#[op]
fn op_write_file_sync(path: String, buf: ZeroCopyBuf) -> Result<(), AnyError> {
let path = std::path::Path::new(&path);
let mut file = std::fs::File::create(path)?;
file.write_all(&buf)?;
Expand Down Expand Up @@ -153,7 +148,7 @@ fn red_bold<S: AsRef<str>>(s: S) -> impl fmt::Display {
// NOP permissions
struct Permissions;

impl deno_timers::TimersPermission for Permissions {
impl deno_web::TimersPermission for Permissions {
fn allow_hrtime(&mut self) -> bool {
false
}
Expand Down
Loading