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

deno_webgpu: Don't confuse zero with "to the end of the buffer". #3171

Merged
merged 1 commit into from
Nov 3, 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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ Bottom level categories:

- Fixed WebGL not displaying srgb targets correctly if a non-screen filling viewport was previously set. By @Wumpf in [#3093](https://github.com/gfx-rs/wgpu/pull/3093)

#### deno-webgpu

- Let `setVertexBuffer` and `setIndexBuffer` calls on
`GPURenderBundleEncoder` throw an error if the `size` argument is
zero, rather than treating that as "until the end of the buffer".
By @jimblandy in [#3171](https://github.com/gfx-rs/wgpu/pull/3171)

### Examples
- Log adapter info in hello example on wasm target by @JolifantoBambla in [#2858](https://github.com/gfx-rs/wgpu/pull/2858)

Expand Down
17 changes: 9 additions & 8 deletions deno_webgpu/src/bundle.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.

use deno_core::error::AnyError;
use deno_core::error::{type_error, AnyError};
use deno_core::op;
use deno_core::OpState;
use deno_core::Resource;
Expand Down Expand Up @@ -255,16 +255,14 @@ pub fn op_webgpu_render_bundle_encoder_set_index_buffer(
let render_bundle_encoder_resource = state
.resource_table
.get::<WebGpuRenderBundleEncoder>(render_bundle_encoder_rid)?;
let size = Some(
std::num::NonZeroU64::new(size).ok_or_else(|| type_error("size must be larger than 0"))?,
);

render_bundle_encoder_resource
.0
.borrow_mut()
.set_index_buffer(
buffer_resource.0,
index_format,
offset,
std::num::NonZeroU64::new(size),
);
.set_index_buffer(buffer_resource.0, index_format, offset, size);

Ok(WebGpuResult::empty())
}
Expand All @@ -284,13 +282,16 @@ pub fn op_webgpu_render_bundle_encoder_set_vertex_buffer(
let render_bundle_encoder_resource = state
.resource_table
.get::<WebGpuRenderBundleEncoder>(render_bundle_encoder_rid)?;
let size = Some(
std::num::NonZeroU64::new(size).ok_or_else(|| type_error("size must be larger than 0"))?,
);

wgpu_core::command::bundle_ffi::wgpu_render_bundle_set_vertex_buffer(
&mut render_bundle_encoder_resource.0.borrow_mut(),
slot,
buffer_resource.0,
offset,
std::num::NonZeroU64::new(size),
size,
);

Ok(WebGpuResult::empty())
Expand Down