mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-12-08 21:26:17 +00:00
[deno] Return undefined instead of null from WebGPU APIs (#8266)
See denoland/deno#29603
This commit is contained in:
parent
2b71b1f99d
commit
61e5124eb9
@ -114,6 +114,9 @@ impl GPUBuffer {
|
||||
*self.map_state.borrow()
|
||||
}
|
||||
|
||||
// In the successful case, the promise should resolve to undefined, but
|
||||
// `#[undefined]` does not seem to work here.
|
||||
// https://github.com/denoland/deno/issues/29603
|
||||
#[async_method]
|
||||
async fn map_async(
|
||||
&self,
|
||||
@ -250,6 +253,7 @@ impl GPUBuffer {
|
||||
}
|
||||
|
||||
#[nofast]
|
||||
#[undefined]
|
||||
fn unmap(&self, scope: &mut v8::HandleScope) -> Result<(), BufferError> {
|
||||
for ab in self.mapped_js_buffers.replace(vec![]) {
|
||||
let ab = ab.open(scope);
|
||||
@ -267,6 +271,7 @@ impl GPUBuffer {
|
||||
}
|
||||
|
||||
#[fast]
|
||||
#[undefined]
|
||||
fn destroy(&self) {
|
||||
self.instance.buffer_destroy(self.id);
|
||||
}
|
||||
|
||||
@ -193,6 +193,7 @@ impl GPUCommandEncoder {
|
||||
}
|
||||
|
||||
#[required(2)]
|
||||
#[undefined]
|
||||
fn copy_buffer_to_buffer<'a>(
|
||||
&self,
|
||||
scope: &mut v8::HandleScope<'a>,
|
||||
@ -282,6 +283,7 @@ impl GPUCommandEncoder {
|
||||
}
|
||||
|
||||
#[required(3)]
|
||||
#[undefined]
|
||||
fn copy_buffer_to_texture(
|
||||
&self,
|
||||
#[webidl] source: GPUTexelCopyBufferInfo,
|
||||
@ -317,6 +319,7 @@ impl GPUCommandEncoder {
|
||||
}
|
||||
|
||||
#[required(3)]
|
||||
#[undefined]
|
||||
fn copy_texture_to_buffer(
|
||||
&self,
|
||||
#[webidl] source: GPUTexelCopyTextureInfo,
|
||||
@ -352,6 +355,7 @@ impl GPUCommandEncoder {
|
||||
}
|
||||
|
||||
#[required(3)]
|
||||
#[undefined]
|
||||
fn copy_texture_to_texture(
|
||||
&self,
|
||||
#[webidl] source: GPUTexelCopyTextureInfo,
|
||||
@ -385,6 +389,7 @@ impl GPUCommandEncoder {
|
||||
}
|
||||
|
||||
#[required(1)]
|
||||
#[undefined]
|
||||
fn clear_buffer(
|
||||
&self,
|
||||
#[webidl] buffer: Ptr<GPUBuffer>,
|
||||
@ -399,6 +404,7 @@ impl GPUCommandEncoder {
|
||||
}
|
||||
|
||||
#[required(5)]
|
||||
#[undefined]
|
||||
fn resolve_query_set(
|
||||
&self,
|
||||
#[webidl] query_set: Ptr<super::query_set::GPUQuerySet>,
|
||||
|
||||
@ -49,6 +49,7 @@ impl GPUComputePassEncoder {
|
||||
// TODO(@crowlKats): no-op, needs wpgu to implement changing the label
|
||||
}
|
||||
|
||||
#[undefined]
|
||||
fn set_pipeline(
|
||||
&self,
|
||||
#[webidl] pipeline: Ptr<crate::compute_pipeline::GPUComputePipeline>,
|
||||
@ -63,6 +64,7 @@ impl GPUComputePassEncoder {
|
||||
self.error_handler.push_error(err);
|
||||
}
|
||||
|
||||
#[undefined]
|
||||
fn dispatch_workgroups(
|
||||
&self,
|
||||
#[webidl(options(enforce_range = true))] work_group_count_x: u32,
|
||||
@ -83,6 +85,7 @@ impl GPUComputePassEncoder {
|
||||
self.error_handler.push_error(err);
|
||||
}
|
||||
|
||||
#[undefined]
|
||||
fn dispatch_workgroups_indirect(
|
||||
&self,
|
||||
#[webidl] indirect_buffer: Ptr<crate::buffer::GPUBuffer>,
|
||||
@ -100,6 +103,7 @@ impl GPUComputePassEncoder {
|
||||
}
|
||||
|
||||
#[fast]
|
||||
#[undefined]
|
||||
fn end(&self) {
|
||||
let err = self
|
||||
.instance
|
||||
@ -108,6 +112,7 @@ impl GPUComputePassEncoder {
|
||||
self.error_handler.push_error(err);
|
||||
}
|
||||
|
||||
#[undefined]
|
||||
fn push_debug_group(&self, #[webidl] group_label: String) {
|
||||
let err = self
|
||||
.instance
|
||||
@ -121,6 +126,7 @@ impl GPUComputePassEncoder {
|
||||
}
|
||||
|
||||
#[fast]
|
||||
#[undefined]
|
||||
fn pop_debug_group(&self) {
|
||||
let err = self
|
||||
.instance
|
||||
@ -129,6 +135,7 @@ impl GPUComputePassEncoder {
|
||||
self.error_handler.push_error(err);
|
||||
}
|
||||
|
||||
#[undefined]
|
||||
fn insert_debug_marker(&self, #[webidl] marker_label: String) {
|
||||
let err = self
|
||||
.instance
|
||||
@ -141,6 +148,7 @@ impl GPUComputePassEncoder {
|
||||
self.error_handler.push_error(err);
|
||||
}
|
||||
|
||||
#[undefined]
|
||||
fn set_bind_group<'a>(
|
||||
&self,
|
||||
scope: &mut v8::HandleScope<'a>,
|
||||
|
||||
@ -142,6 +142,7 @@ impl GPUDevice {
|
||||
}
|
||||
|
||||
#[fast]
|
||||
#[undefined]
|
||||
fn destroy(&self) {
|
||||
self.instance.device_destroy(self.id);
|
||||
self
|
||||
@ -634,6 +635,7 @@ impl GPUDevice {
|
||||
}
|
||||
|
||||
#[required(1)]
|
||||
#[undefined]
|
||||
fn push_error_scope(&self, #[webidl] filter: super::error::GPUErrorFilter) {
|
||||
self
|
||||
.error_handler
|
||||
|
||||
@ -53,6 +53,7 @@ impl GPUQuerySet {
|
||||
}
|
||||
|
||||
#[fast]
|
||||
#[undefined]
|
||||
fn destroy(&self) -> Result<(), JsErrorBox> {
|
||||
// TODO(https://github.com/gfx-rs/wgpu/issues/6495): Destroy the query
|
||||
// set. Until that is supported, it is okay to do nothing here, the
|
||||
|
||||
@ -7,7 +7,6 @@ use std::time::Duration;
|
||||
use deno_core::cppgc::Ptr;
|
||||
use deno_core::futures::channel::oneshot;
|
||||
use deno_core::op2;
|
||||
use deno_core::v8;
|
||||
use deno_core::GarbageCollected;
|
||||
use deno_core::WebIDL;
|
||||
use deno_error::JsErrorBox;
|
||||
@ -63,11 +62,11 @@ impl GPUQueue {
|
||||
}
|
||||
|
||||
#[required(1)]
|
||||
#[undefined]
|
||||
fn submit(
|
||||
&self,
|
||||
scope: &mut v8::HandleScope,
|
||||
#[webidl] command_buffers: Vec<Ptr<GPUCommandBuffer>>,
|
||||
) -> Result<v8::Local<v8::Value>, JsErrorBox> {
|
||||
) -> Result<(), JsErrorBox> {
|
||||
let ids = command_buffers
|
||||
.into_iter()
|
||||
.map(|cb| cb.id)
|
||||
@ -79,9 +78,12 @@ impl GPUQueue {
|
||||
self.error_handler.push_error(Some(err));
|
||||
}
|
||||
|
||||
Ok(v8::undefined(scope).into())
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// In the successful case, the promise should resolve to undefined, but
|
||||
// `#[undefined]` does not seem to work here.
|
||||
// https://github.com/denoland/deno/issues/29603
|
||||
#[async_method]
|
||||
async fn on_submitted_work_done(&self) -> Result<(), JsErrorBox> {
|
||||
let (sender, receiver) = oneshot::channel::<()>();
|
||||
@ -124,6 +126,7 @@ impl GPUQueue {
|
||||
}
|
||||
|
||||
#[required(3)]
|
||||
#[undefined]
|
||||
fn write_buffer(
|
||||
&self,
|
||||
#[webidl] buffer: Ptr<GPUBuffer>,
|
||||
@ -148,6 +151,7 @@ impl GPUQueue {
|
||||
}
|
||||
|
||||
#[required(4)]
|
||||
#[undefined]
|
||||
fn write_texture(
|
||||
&self,
|
||||
#[webidl] destination: GPUTexelCopyTextureInfo,
|
||||
|
||||
@ -87,6 +87,7 @@ impl GPURenderBundleEncoder {
|
||||
}
|
||||
}
|
||||
|
||||
#[undefined]
|
||||
fn push_debug_group(
|
||||
&self,
|
||||
#[webidl] group_label: String,
|
||||
@ -110,6 +111,7 @@ impl GPURenderBundleEncoder {
|
||||
}
|
||||
|
||||
#[fast]
|
||||
#[undefined]
|
||||
fn pop_debug_group(&self) -> Result<(), JsErrorBox> {
|
||||
let mut encoder = self.encoder.borrow_mut();
|
||||
let encoder = encoder.as_mut().ok_or_else(|| {
|
||||
@ -119,6 +121,7 @@ impl GPURenderBundleEncoder {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[undefined]
|
||||
fn insert_debug_marker(
|
||||
&self,
|
||||
#[webidl] marker_label: String,
|
||||
@ -140,6 +143,7 @@ impl GPURenderBundleEncoder {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[undefined]
|
||||
fn set_bind_group<'a>(
|
||||
&self,
|
||||
scope: &mut v8::HandleScope<'a>,
|
||||
@ -226,6 +230,7 @@ impl GPURenderBundleEncoder {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[undefined]
|
||||
fn set_pipeline(
|
||||
&self,
|
||||
#[webidl] pipeline: Ptr<crate::render_pipeline::GPURenderPipeline>,
|
||||
@ -243,6 +248,7 @@ impl GPURenderBundleEncoder {
|
||||
}
|
||||
|
||||
#[required(2)]
|
||||
#[undefined]
|
||||
fn set_index_buffer(
|
||||
&self,
|
||||
#[webidl] buffer: Ptr<GPUBuffer>,
|
||||
@ -265,6 +271,7 @@ impl GPURenderBundleEncoder {
|
||||
}
|
||||
|
||||
#[required(2)]
|
||||
#[undefined]
|
||||
fn set_vertex_buffer(
|
||||
&self,
|
||||
#[webidl(options(enforce_range = true))] slot: u32,
|
||||
@ -288,6 +295,7 @@ impl GPURenderBundleEncoder {
|
||||
}
|
||||
|
||||
#[required(1)]
|
||||
#[undefined]
|
||||
fn draw(
|
||||
&self,
|
||||
#[webidl(options(enforce_range = true))] vertex_count: u32,
|
||||
@ -311,6 +319,7 @@ impl GPURenderBundleEncoder {
|
||||
}
|
||||
|
||||
#[required(1)]
|
||||
#[undefined]
|
||||
fn draw_indexed(
|
||||
&self,
|
||||
#[webidl(options(enforce_range = true))] index_count: u32,
|
||||
@ -336,6 +345,7 @@ impl GPURenderBundleEncoder {
|
||||
}
|
||||
|
||||
#[required(2)]
|
||||
#[undefined]
|
||||
fn draw_indirect(
|
||||
&self,
|
||||
#[webidl] indirect_buffer: Ptr<GPUBuffer>,
|
||||
@ -355,6 +365,7 @@ impl GPURenderBundleEncoder {
|
||||
}
|
||||
|
||||
#[required(2)]
|
||||
#[undefined]
|
||||
fn draw_indexed_indirect(
|
||||
&self,
|
||||
#[webidl] indirect_buffer: Ptr<GPUBuffer>,
|
||||
|
||||
@ -60,6 +60,7 @@ impl GPURenderPassEncoder {
|
||||
}
|
||||
|
||||
#[required(6)]
|
||||
#[undefined]
|
||||
fn set_viewport(
|
||||
&self,
|
||||
#[webidl] x: f32,
|
||||
@ -85,6 +86,7 @@ impl GPURenderPassEncoder {
|
||||
}
|
||||
|
||||
#[required(4)]
|
||||
#[undefined]
|
||||
fn set_scissor_rect(
|
||||
&self,
|
||||
#[webidl(options(enforce_range = true))] x: u32,
|
||||
@ -106,6 +108,7 @@ impl GPURenderPassEncoder {
|
||||
}
|
||||
|
||||
#[required(1)]
|
||||
#[undefined]
|
||||
fn set_blend_constant(&self, #[webidl] color: GPUColor) {
|
||||
let err = self
|
||||
.instance
|
||||
@ -118,6 +121,7 @@ impl GPURenderPassEncoder {
|
||||
}
|
||||
|
||||
#[required(1)]
|
||||
#[undefined]
|
||||
fn set_stencil_reference(
|
||||
&self,
|
||||
#[webidl(options(enforce_range = true))] reference: u32,
|
||||
@ -133,6 +137,7 @@ impl GPURenderPassEncoder {
|
||||
}
|
||||
|
||||
#[required(1)]
|
||||
#[undefined]
|
||||
fn begin_occlusion_query(
|
||||
&self,
|
||||
#[webidl(options(enforce_range = true))] query_index: u32,
|
||||
@ -148,6 +153,7 @@ impl GPURenderPassEncoder {
|
||||
}
|
||||
|
||||
#[fast]
|
||||
#[undefined]
|
||||
fn end_occlusion_query(&self) {
|
||||
let err = self
|
||||
.instance
|
||||
@ -157,6 +163,7 @@ impl GPURenderPassEncoder {
|
||||
}
|
||||
|
||||
#[required(1)]
|
||||
#[undefined]
|
||||
fn execute_bundles(&self, #[webidl] bundles: Vec<Ptr<GPURenderBundle>>) {
|
||||
let err = self
|
||||
.instance
|
||||
@ -172,6 +179,7 @@ impl GPURenderPassEncoder {
|
||||
}
|
||||
|
||||
#[fast]
|
||||
#[undefined]
|
||||
fn end(&self) {
|
||||
let err = self
|
||||
.instance
|
||||
@ -180,6 +188,7 @@ impl GPURenderPassEncoder {
|
||||
self.error_handler.push_error(err);
|
||||
}
|
||||
|
||||
#[undefined]
|
||||
fn push_debug_group(&self, #[webidl] group_label: String) {
|
||||
let err = self
|
||||
.instance
|
||||
@ -193,6 +202,7 @@ impl GPURenderPassEncoder {
|
||||
}
|
||||
|
||||
#[fast]
|
||||
#[undefined]
|
||||
fn pop_debug_group(&self) {
|
||||
let err = self
|
||||
.instance
|
||||
@ -201,6 +211,7 @@ impl GPURenderPassEncoder {
|
||||
self.error_handler.push_error(err);
|
||||
}
|
||||
|
||||
#[undefined]
|
||||
fn insert_debug_marker(&self, #[webidl] marker_label: String) {
|
||||
let err = self
|
||||
.instance
|
||||
@ -213,6 +224,7 @@ impl GPURenderPassEncoder {
|
||||
self.error_handler.push_error(err);
|
||||
}
|
||||
|
||||
#[undefined]
|
||||
fn set_bind_group<'a>(
|
||||
&self,
|
||||
scope: &mut v8::HandleScope<'a>,
|
||||
@ -296,6 +308,7 @@ impl GPURenderPassEncoder {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[undefined]
|
||||
fn set_pipeline(
|
||||
&self,
|
||||
#[webidl] pipeline: Ptr<crate::render_pipeline::GPURenderPipeline>,
|
||||
@ -308,6 +321,7 @@ impl GPURenderPassEncoder {
|
||||
}
|
||||
|
||||
#[required(2)]
|
||||
#[undefined]
|
||||
fn set_index_buffer(
|
||||
&self,
|
||||
#[webidl] buffer: Ptr<GPUBuffer>,
|
||||
@ -329,6 +343,7 @@ impl GPURenderPassEncoder {
|
||||
}
|
||||
|
||||
#[required(2)]
|
||||
#[undefined]
|
||||
fn set_vertex_buffer(
|
||||
&self,
|
||||
#[webidl(options(enforce_range = true))] slot: u32,
|
||||
@ -350,6 +365,7 @@ impl GPURenderPassEncoder {
|
||||
}
|
||||
|
||||
#[required(1)]
|
||||
#[undefined]
|
||||
fn draw(
|
||||
&self,
|
||||
#[webidl(options(enforce_range = true))] vertex_count: u32,
|
||||
@ -371,6 +387,7 @@ impl GPURenderPassEncoder {
|
||||
}
|
||||
|
||||
#[required(1)]
|
||||
#[undefined]
|
||||
fn draw_indexed(
|
||||
&self,
|
||||
#[webidl(options(enforce_range = true))] index_count: u32,
|
||||
@ -394,6 +411,7 @@ impl GPURenderPassEncoder {
|
||||
}
|
||||
|
||||
#[required(2)]
|
||||
#[undefined]
|
||||
fn draw_indirect(
|
||||
&self,
|
||||
#[webidl] indirect_buffer: Ptr<GPUBuffer>,
|
||||
@ -411,6 +429,7 @@ impl GPURenderPassEncoder {
|
||||
}
|
||||
|
||||
#[required(2)]
|
||||
#[undefined]
|
||||
fn draw_indexed_indirect(
|
||||
&self,
|
||||
#[webidl] indirect_buffer: Ptr<GPUBuffer>,
|
||||
|
||||
@ -68,6 +68,7 @@ impl GPUCanvasContext {
|
||||
self.canvas.clone()
|
||||
}
|
||||
|
||||
#[undefined]
|
||||
fn configure(
|
||||
&self,
|
||||
#[webidl] configuration: GPUCanvasConfiguration,
|
||||
@ -113,6 +114,7 @@ impl GPUCanvasContext {
|
||||
}
|
||||
|
||||
#[fast]
|
||||
#[undefined]
|
||||
fn unconfigure(&self) {
|
||||
*self.config.borrow_mut() = None;
|
||||
}
|
||||
|
||||
@ -154,6 +154,7 @@ impl GPUTexture {
|
||||
self.usage
|
||||
}
|
||||
#[fast]
|
||||
#[undefined]
|
||||
fn destroy(&self) {
|
||||
self.instance.texture_destroy(self.id);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user