mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
deno_webgpu: Don't confuse zero with "to the end of the buffer".
`RenderBundleEncoder::set_index_buffer` and `set_vertex_buffer` interpret a `size` of `None` to mean "from the given offset to the end of the buffer", but `std::num::NonZeroU64::new` produces `None` when its argument is zero, which is quite different. Fix this similarly to the way it's handled in `op_webgpu_render_pass_set_index_buffer`. The WebGPU spec says this should work; filed as #3170.
This commit is contained in:
@@ -84,6 +84,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)
|
||||
|
||||
|
||||
@@ -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;
|
||||
@@ -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())
|
||||
}
|
||||
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user