Update wgpu (#33209)

no gfx_select macro and some minor changes to passes

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
Samson 2024-08-27 22:31:31 +02:00 committed by GitHub
parent 1b48bd18aa
commit 12661c1920
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 222 additions and 205 deletions

40
Cargo.lock generated
View file

@ -1200,16 +1200,6 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96a6ac251f4a2aca6b3f91340350eab87ae57c3f127ffeb585e92bd336717991" checksum = "96a6ac251f4a2aca6b3f91340350eab87ae57c3f127ffeb585e92bd336717991"
[[package]]
name = "d3d12"
version = "22.0.0"
source = "git+https://github.com/gfx-rs/wgpu?rev=781b54a8b9cee1a2cb22bda565662edec52eb70e#781b54a8b9cee1a2cb22bda565662edec52eb70e"
dependencies = [
"bitflags 2.6.0",
"libloading",
"winapi",
]
[[package]] [[package]]
name = "darling" name = "darling"
version = "0.20.10" version = "0.20.10"
@ -2394,6 +2384,18 @@ dependencies = [
"bitflags 2.6.0", "bitflags 2.6.0",
] ]
[[package]]
name = "gpu-allocator"
version = "0.27.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c151a2a5ef800297b4e79efa4f4bec035c5f51d5ae587287c9b952bdf734cacd"
dependencies = [
"log",
"presser",
"thiserror",
"windows 0.58.0",
]
[[package]] [[package]]
name = "gpu-descriptor" name = "gpu-descriptor"
version = "0.3.0" version = "0.3.0"
@ -4373,7 +4375,7 @@ checksum = "956787520e75e9bd233246045d19f42fb73242759cc57fba9611d940ae96d4b0"
[[package]] [[package]]
name = "naga" name = "naga"
version = "22.0.0" version = "22.0.0"
source = "git+https://github.com/gfx-rs/wgpu?rev=781b54a8b9cee1a2cb22bda565662edec52eb70e#781b54a8b9cee1a2cb22bda565662edec52eb70e" source = "git+https://github.com/gfx-rs/wgpu?rev=338678ad5f66b74d1df1daee6afb028f964244b8#338678ad5f66b74d1df1daee6afb028f964244b8"
dependencies = [ dependencies = [
"arrayvec", "arrayvec",
"bit-set", "bit-set",
@ -5123,6 +5125,12 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c"
[[package]]
name = "presser"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8cf8e6a8aa66ce33f63993ffc4ea4271eb5b0530a9002db8455ea6050c77bfa"
[[package]] [[package]]
name = "proc-macro-crate" name = "proc-macro-crate"
version = "3.1.0" version = "3.1.0"
@ -7806,7 +7814,7 @@ checksum = "53a85b86a771b1c87058196170769dd264f66c0782acf1ae6cc51bfd64b39082"
[[package]] [[package]]
name = "wgpu-core" name = "wgpu-core"
version = "22.0.0" version = "22.0.0"
source = "git+https://github.com/gfx-rs/wgpu?rev=781b54a8b9cee1a2cb22bda565662edec52eb70e#781b54a8b9cee1a2cb22bda565662edec52eb70e" source = "git+https://github.com/gfx-rs/wgpu?rev=338678ad5f66b74d1df1daee6afb028f964244b8#338678ad5f66b74d1df1daee6afb028f964244b8"
dependencies = [ dependencies = [
"arrayvec", "arrayvec",
"bit-vec", "bit-vec",
@ -7831,7 +7839,7 @@ dependencies = [
[[package]] [[package]]
name = "wgpu-hal" name = "wgpu-hal"
version = "22.0.0" version = "22.0.0"
source = "git+https://github.com/gfx-rs/wgpu?rev=781b54a8b9cee1a2cb22bda565662edec52eb70e#781b54a8b9cee1a2cb22bda565662edec52eb70e" source = "git+https://github.com/gfx-rs/wgpu?rev=338678ad5f66b74d1df1daee6afb028f964244b8#338678ad5f66b74d1df1daee6afb028f964244b8"
dependencies = [ dependencies = [
"android_system_properties", "android_system_properties",
"arrayvec", "arrayvec",
@ -7841,10 +7849,10 @@ dependencies = [
"block", "block",
"cfg_aliases 0.1.1", "cfg_aliases 0.1.1",
"core-graphics-types", "core-graphics-types",
"d3d12",
"glow 0.14.0", "glow 0.14.0",
"glutin_wgl_sys", "glutin_wgl_sys",
"gpu-alloc", "gpu-alloc",
"gpu-allocator",
"gpu-descriptor", "gpu-descriptor",
"js-sys", "js-sys",
"khronos-egl", "khronos-egl",
@ -7866,14 +7874,14 @@ dependencies = [
"wasm-bindgen", "wasm-bindgen",
"web-sys", "web-sys",
"wgpu-types", "wgpu-types",
"winapi",
"windows 0.58.0", "windows 0.58.0",
"windows-core 0.58.0",
] ]
[[package]] [[package]]
name = "wgpu-types" name = "wgpu-types"
version = "22.0.0" version = "22.0.0"
source = "git+https://github.com/gfx-rs/wgpu?rev=781b54a8b9cee1a2cb22bda565662edec52eb70e#781b54a8b9cee1a2cb22bda565662edec52eb70e" source = "git+https://github.com/gfx-rs/wgpu?rev=338678ad5f66b74d1df1daee6afb028f964244b8#338678ad5f66b74d1df1daee6afb028f964244b8"
dependencies = [ dependencies = [
"bitflags 2.6.0", "bitflags 2.6.0",
"js-sys", "js-sys",

View file

@ -138,8 +138,8 @@ webpki-roots = "0.25"
webrender = { git = "https://github.com/servo/webrender", branch = "0.65", features = ["capture"] } webrender = { git = "https://github.com/servo/webrender", branch = "0.65", features = ["capture"] }
webrender_api = { git = "https://github.com/servo/webrender", branch = "0.65" } webrender_api = { git = "https://github.com/servo/webrender", branch = "0.65" }
webrender_traits = { path = "components/shared/webrender" } webrender_traits = { path = "components/shared/webrender" }
wgpu-core = { git = "https://github.com/gfx-rs/wgpu", rev = "781b54a8b9cee1a2cb22bda565662edec52eb70e" } wgpu-core = { git = "https://github.com/gfx-rs/wgpu", rev = "338678ad5f66b74d1df1daee6afb028f964244b8" }
wgpu-types = { git = "https://github.com/gfx-rs/wgpu", rev = "781b54a8b9cee1a2cb22bda565662edec52eb70e" } wgpu-types = { git = "https://github.com/gfx-rs/wgpu", rev = "338678ad5f66b74d1df1daee6afb028f964244b8" }
windows-sys = "0.59" windows-sys = "0.59"
xi-unicode = "0.1.0" xi-unicode = "0.1.0"
xml5ever = "0.19" xml5ever = "0.19"

View file

@ -70,7 +70,7 @@ pub fn convert_texture_format(format: GPUTextureFormat) -> wgt::TextureFormat {
GPUTextureFormat::Bc6h_rgb_float => wgt::TextureFormat::Bc6hRgbFloat, GPUTextureFormat::Bc6h_rgb_float => wgt::TextureFormat::Bc6hRgbFloat,
GPUTextureFormat::Rgb9e5ufloat => wgt::TextureFormat::Rgb9e5Ufloat, GPUTextureFormat::Rgb9e5ufloat => wgt::TextureFormat::Rgb9e5Ufloat,
GPUTextureFormat::Rgb10a2uint => wgt::TextureFormat::Rgb10a2Uint, GPUTextureFormat::Rgb10a2uint => wgt::TextureFormat::Rgb10a2Uint,
GPUTextureFormat::Rg11b10ufloat => wgt::TextureFormat::Rg11b10Float, GPUTextureFormat::Rg11b10ufloat => wgt::TextureFormat::Rg11b10UFloat,
GPUTextureFormat::Stencil8 => wgt::TextureFormat::Stencil8, GPUTextureFormat::Stencil8 => wgt::TextureFormat::Stencil8,
GPUTextureFormat::Depth16unorm => wgt::TextureFormat::Depth16Unorm, GPUTextureFormat::Depth16unorm => wgt::TextureFormat::Depth16Unorm,
GPUTextureFormat::Depth32float_stencil8 => wgt::TextureFormat::Depth32FloatStencil8, GPUTextureFormat::Depth32float_stencil8 => wgt::TextureFormat::Depth32FloatStencil8,

View file

@ -5,7 +5,7 @@
//! Render pass commands //! Render pass commands
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use wgpu_core::command::{DynRenderPass, RenderPassError}; use wgpu_core::command::{RenderPass, RenderPassError};
use wgpu_core::global::Global; use wgpu_core::global::Global;
use crate::wgc::id; use crate::wgc::id;
@ -73,17 +73,19 @@ pub enum RenderCommand {
} }
pub fn apply_render_command( pub fn apply_render_command(
context: &Global, global: &Global,
pass: &mut Box<dyn DynRenderPass>, pass: &mut RenderPass,
command: RenderCommand, command: RenderCommand,
) -> Result<(), RenderPassError> { ) -> Result<(), RenderPassError> {
match command { match command {
RenderCommand::SetPipeline(pipeline_id) => pass.set_pipeline(context, pipeline_id), RenderCommand::SetPipeline(pipeline_id) => {
global.render_pass_set_pipeline(pass, pipeline_id)
},
RenderCommand::SetBindGroup { RenderCommand::SetBindGroup {
index, index,
bind_group_id, bind_group_id,
offsets, offsets,
} => pass.set_bind_group(context, index, bind_group_id, &offsets), } => global.render_pass_set_bind_group(pass, index, bind_group_id, &offsets),
RenderCommand::SetViewport { RenderCommand::SetViewport {
x, x,
y, y,
@ -91,36 +93,38 @@ pub fn apply_render_command(
height, height,
min_depth, min_depth,
max_depth, max_depth,
} => pass.set_viewport(context, x, y, width, height, min_depth, max_depth), } => global.render_pass_set_viewport(pass, x, y, width, height, min_depth, max_depth),
RenderCommand::SetScissorRect { RenderCommand::SetScissorRect {
x, x,
y, y,
width, width,
height, height,
} => pass.set_scissor_rect(context, x, y, width, height), } => global.render_pass_set_scissor_rect(pass, x, y, width, height),
RenderCommand::SetBlendConstant(color) => pass.set_blend_constant(context, color), RenderCommand::SetBlendConstant(color) => {
global.render_pass_set_blend_constant(pass, color)
},
RenderCommand::SetStencilReference(reference) => { RenderCommand::SetStencilReference(reference) => {
pass.set_stencil_reference(context, reference) global.render_pass_set_stencil_reference(pass, reference)
}, },
RenderCommand::SetIndexBuffer { RenderCommand::SetIndexBuffer {
buffer_id, buffer_id,
index_format, index_format,
offset, offset,
size, size,
} => pass.set_index_buffer(context, buffer_id, index_format, offset, size), } => global.render_pass_set_index_buffer(pass, buffer_id, index_format, offset, size),
RenderCommand::SetVertexBuffer { RenderCommand::SetVertexBuffer {
slot, slot,
buffer_id, buffer_id,
offset, offset,
size, size,
} => pass.set_vertex_buffer(context, slot, buffer_id, offset, size), } => global.render_pass_set_vertex_buffer(pass, slot, buffer_id, offset, size),
RenderCommand::Draw { RenderCommand::Draw {
vertex_count, vertex_count,
instance_count, instance_count,
first_vertex, first_vertex,
first_instance, first_instance,
} => pass.draw( } => global.render_pass_draw(
context, pass,
vertex_count, vertex_count,
instance_count, instance_count,
first_vertex, first_vertex,
@ -132,8 +136,8 @@ pub fn apply_render_command(
first_index, first_index,
base_vertex, base_vertex,
first_instance, first_instance,
} => pass.draw_indexed( } => global.render_pass_draw_indexed(
context, pass,
index_count, index_count,
instance_count, instance_count,
first_index, first_index,
@ -141,11 +145,13 @@ pub fn apply_render_command(
first_instance, first_instance,
), ),
RenderCommand::DrawIndirect { buffer_id, offset } => { RenderCommand::DrawIndirect { buffer_id, offset } => {
pass.draw_indirect(context, buffer_id, offset) global.render_pass_draw_indirect(pass, buffer_id, offset)
}, },
RenderCommand::DrawIndexedIndirect { buffer_id, offset } => { RenderCommand::DrawIndexedIndirect { buffer_id, offset } => {
pass.draw_indexed_indirect(context, buffer_id, offset) global.render_pass_draw_indexed_indirect(pass, buffer_id, offset)
},
RenderCommand::ExecuteBundles(bundles) => {
global.render_pass_execute_bundles(pass, &bundles)
}, },
RenderCommand::ExecuteBundles(bundles) => pass.execute_bundles(context, &bundles),
} }
} }

View file

@ -19,15 +19,15 @@ use webrender::{RenderApi, RenderApiSender, Transaction};
use webrender_api::{DirtyRect, DocumentId}; use webrender_api::{DirtyRect, DocumentId};
use webrender_traits::{WebrenderExternalImageRegistry, WebrenderImageHandlerType}; use webrender_traits::{WebrenderExternalImageRegistry, WebrenderImageHandlerType};
use wgc::command::{ use wgc::command::{
ComputePassDescriptor, DynComputePass, DynRenderPass, ImageCopyBuffer, ImageCopyTexture, ComputePass, ComputePassDescriptor, ImageCopyBuffer, ImageCopyTexture, RenderPass,
}; };
use wgc::device::queue::SubmittedWorkDoneClosure; use wgc::device::queue::SubmittedWorkDoneClosure;
use wgc::device::{DeviceDescriptor, DeviceLostClosure, HostMap, ImplicitPipelineIds}; use wgc::device::{DeviceDescriptor, DeviceLostClosure, HostMap, ImplicitPipelineIds};
use wgc::id;
use wgc::id::DeviceId; use wgc::id::DeviceId;
use wgc::instance::parse_backends_from_comma_list; use wgc::instance::parse_backends_from_comma_list;
use wgc::pipeline::ShaderModuleDescriptor; use wgc::pipeline::ShaderModuleDescriptor;
use wgc::resource::{BufferMapCallback, BufferMapOperation}; use wgc::resource::{BufferMapCallback, BufferMapOperation};
use wgc::{gfx_select, id};
use wgpu_core::command::RenderPassDescriptor; use wgpu_core::command::RenderPassDescriptor;
use wgpu_core::device::DeviceError; use wgpu_core::device::DeviceError;
use wgpu_core::pipeline::{CreateComputePipelineError, CreateRenderPipelineError}; use wgpu_core::pipeline::{CreateComputePipelineError, CreateRenderPipelineError};
@ -73,11 +73,11 @@ impl DeviceScope {
/// This roughly matches <https://www.w3.org/TR/2024/WD-webgpu-20240703/#encoder-state> /// This roughly matches <https://www.w3.org/TR/2024/WD-webgpu-20240703/#encoder-state>
#[derive(Debug, Default, Eq, PartialEq)] #[derive(Debug, Default, Eq, PartialEq)]
enum Pass<P: ?Sized> { enum Pass<P> {
/// Pass is open (not ended) /// Pass is open (not ended)
Open { Open {
/// Actual pass /// Actual pass
pass: Box<P>, pass: P,
/// we need to store valid field /// we need to store valid field
/// because wgpu does not invalidate pass on error /// because wgpu does not invalidate pass on error
valid: bool, valid: bool,
@ -87,9 +87,9 @@ enum Pass<P: ?Sized> {
Ended, Ended,
} }
impl<P: ?Sized> Pass<P> { impl<P> Pass<P> {
/// Creates new open pass /// Creates new open pass
fn new(pass: Box<P>, valid: bool) -> Self { fn new(pass: P, valid: bool) -> Self {
Self::Open { pass, valid } Self::Open { pass, valid }
} }
@ -121,9 +121,9 @@ pub(crate) struct WGPU {
/// Provides access to poller thread /// Provides access to poller thread
poller: Poller, poller: Poller,
/// Store compute passes /// Store compute passes
compute_passes: HashMap<ComputePassId, Pass<dyn DynComputePass>>, compute_passes: HashMap<ComputePassId, Pass<ComputePass>>,
/// Store render passes /// Store render passes
render_passes: HashMap<RenderPassId, Pass<dyn DynRenderPass>>, render_passes: HashMap<RenderPassId, Pass<RenderPass>>,
} }
impl WGPU { impl WGPU {
@ -193,9 +193,8 @@ impl WGPU {
drop(token); drop(token);
let response = result.and_then(|_| { let response = result.and_then(|_| {
let global = &glob; let global = &glob;
let (slice_pointer, range_size) = gfx_select!(buffer_id => let (slice_pointer, range_size) =
global.buffer_get_mapped_range(buffer_id, offset, size)) global.buffer_get_mapped_range(buffer_id, offset, size)?;
?;
// SAFETY: guarantee to be safe from wgpu // SAFETY: guarantee to be safe from wgpu
let data = unsafe { let data = unsafe {
slice::from_raw_parts( slice::from_raw_parts(
@ -223,12 +222,7 @@ impl WGPU {
callback: Some(callback), callback: Some(callback),
}; };
let global = &self.global; let global = &self.global;
let result = gfx_select!(buffer_id => global.buffer_map_async( let result = global.buffer_map_async(buffer_id, offset, size, operation);
buffer_id,
offset,
size,
operation
));
self.poller.wake(); self.poller.wake();
// Per spec we also need to raise validation error here // Per spec we also need to raise validation error here
self.maybe_dispatch_wgpu_error(device_id, result.err()); self.maybe_dispatch_wgpu_error(device_id, result.err());
@ -245,11 +239,11 @@ impl WGPU {
self.error_command_encoders.get(&command_encoder_id) self.error_command_encoders.get(&command_encoder_id)
{ {
Err(Error::Validation(err.clone())) Err(Error::Validation(err.clone()))
} else if let Some(error) = } else if let Some(error) = global
gfx_select!(command_encoder_id => global.command_encoder_finish( .command_encoder_finish(
command_encoder_id, command_encoder_id,
&wgt::CommandBufferDescriptor::default() &wgt::CommandBufferDescriptor::default(),
)) )
.1 .1
{ {
Err(Error::from_error(error)) Err(Error::from_error(error))
@ -271,14 +265,14 @@ impl WGPU {
size, size,
} => { } => {
let global = &self.global; let global = &self.global;
let result = gfx_select!(command_encoder_id => global.command_encoder_copy_buffer_to_buffer( let result = global.command_encoder_copy_buffer_to_buffer(
command_encoder_id, command_encoder_id,
source_id, source_id,
source_offset, source_offset,
destination_id, destination_id,
destination_offset, destination_offset,
size size,
)); );
self.encoder_record_error(command_encoder_id, &result); self.encoder_record_error(command_encoder_id, &result);
}, },
WebGPURequest::CopyBufferToTexture { WebGPURequest::CopyBufferToTexture {
@ -288,12 +282,12 @@ impl WGPU {
copy_size, copy_size,
} => { } => {
let global = &self.global; let global = &self.global;
let result = gfx_select!(command_encoder_id => global.command_encoder_copy_buffer_to_texture( let result = global.command_encoder_copy_buffer_to_texture(
command_encoder_id, command_encoder_id,
&source, &source,
&destination, &destination,
&copy_size &copy_size,
)); );
self.encoder_record_error(command_encoder_id, &result); self.encoder_record_error(command_encoder_id, &result);
}, },
WebGPURequest::CopyTextureToBuffer { WebGPURequest::CopyTextureToBuffer {
@ -303,12 +297,12 @@ impl WGPU {
copy_size, copy_size,
} => { } => {
let global = &self.global; let global = &self.global;
let result = gfx_select!(command_encoder_id => global.command_encoder_copy_texture_to_buffer( let result = global.command_encoder_copy_texture_to_buffer(
command_encoder_id, command_encoder_id,
&source, &source,
&destination, &destination,
&copy_size &copy_size,
)); );
self.encoder_record_error(command_encoder_id, &result); self.encoder_record_error(command_encoder_id, &result);
}, },
WebGPURequest::CopyTextureToTexture { WebGPURequest::CopyTextureToTexture {
@ -318,12 +312,12 @@ impl WGPU {
copy_size, copy_size,
} => { } => {
let global = &self.global; let global = &self.global;
let result = gfx_select!(command_encoder_id => global.command_encoder_copy_texture_to_texture( let result = global.command_encoder_copy_texture_to_texture(
command_encoder_id, command_encoder_id,
&source, &source,
&destination, &destination,
&copy_size &copy_size,
)); );
self.encoder_record_error(command_encoder_id, &result); self.encoder_record_error(command_encoder_id, &result);
}, },
WebGPURequest::CreateBindGroup { WebGPURequest::CreateBindGroup {
@ -332,8 +326,11 @@ impl WGPU {
descriptor, descriptor,
} => { } => {
let global = &self.global; let global = &self.global;
let (_, error) = gfx_select!(bind_group_id => let (_, error) = global.device_create_bind_group(
global.device_create_bind_group(device_id, &descriptor, Some(bind_group_id))); device_id,
&descriptor,
Some(bind_group_id),
);
self.maybe_dispatch_wgpu_error(device_id, error); self.maybe_dispatch_wgpu_error(device_id, error);
}, },
WebGPURequest::CreateBindGroupLayout { WebGPURequest::CreateBindGroupLayout {
@ -343,8 +340,11 @@ impl WGPU {
} => { } => {
let global = &self.global; let global = &self.global;
if let Some(desc) = descriptor { if let Some(desc) = descriptor {
let (_, error) = gfx_select!(bind_group_layout_id => let (_, error) = global.device_create_bind_group_layout(
global.device_create_bind_group_layout(device_id, &desc, Some(bind_group_layout_id))); device_id,
&desc,
Some(bind_group_layout_id),
);
self.maybe_dispatch_wgpu_error(device_id, error); self.maybe_dispatch_wgpu_error(device_id, error);
} }
@ -355,8 +355,8 @@ impl WGPU {
descriptor, descriptor,
} => { } => {
let global = &self.global; let global = &self.global;
let (_, error) = gfx_select!(buffer_id => let (_, error) =
global.device_create_buffer(device_id, &descriptor, Some(buffer_id))); global.device_create_buffer(device_id, &descriptor, Some(buffer_id));
self.maybe_dispatch_wgpu_error(device_id, error); self.maybe_dispatch_wgpu_error(device_id, error);
}, },
@ -367,8 +367,11 @@ impl WGPU {
} => { } => {
let global = &self.global; let global = &self.global;
let desc = wgt::CommandEncoderDescriptor { label }; let desc = wgt::CommandEncoderDescriptor { label };
let (_, error) = gfx_select!(command_encoder_id => let (_, error) = global.device_create_command_encoder(
global.device_create_command_encoder(device_id, &desc, Some(command_encoder_id))); device_id,
&desc,
Some(command_encoder_id),
);
self.maybe_dispatch_wgpu_error(device_id, error); self.maybe_dispatch_wgpu_error(device_id, error);
}, },
@ -392,12 +395,11 @@ impl WGPU {
root_id: *layout, root_id: *layout,
group_ids: bgls.as_slice(), group_ids: bgls.as_slice(),
}); });
let (_, error) = gfx_select!(compute_pipeline_id => global.device_create_compute_pipeline( let (_, error) = global.device_create_compute_pipeline(
device_id, device_id,
&descriptor, &descriptor,
Some(compute_pipeline_id), Some(compute_pipeline_id),
implicit implicit,
)
); );
if let Some(sender) = sender { if let Some(sender) = sender {
let res = match error { let res = match error {
@ -434,8 +436,11 @@ impl WGPU {
descriptor, descriptor,
} => { } => {
let global = &self.global; let global = &self.global;
let (_, error) = gfx_select!(pipeline_layout_id => let (_, error) = global.device_create_pipeline_layout(
global.device_create_pipeline_layout(device_id, &descriptor, Some(pipeline_layout_id))); device_id,
&descriptor,
Some(pipeline_layout_id),
);
self.maybe_dispatch_wgpu_error(device_id, error); self.maybe_dispatch_wgpu_error(device_id, error);
}, },
WebGPURequest::CreateRenderPipeline { WebGPURequest::CreateRenderPipeline {
@ -458,12 +463,11 @@ impl WGPU {
root_id: *layout, root_id: *layout,
group_ids: bgls.as_slice(), group_ids: bgls.as_slice(),
}); });
let (_, error) = gfx_select!(render_pipeline_id => let (_, error) = global.device_create_render_pipeline(
global.device_create_render_pipeline(
device_id, device_id,
&descriptor, &descriptor,
Some(render_pipeline_id), Some(render_pipeline_id),
implicit) implicit,
); );
if let Some(sender) = sender { if let Some(sender) = sender {
@ -491,11 +495,8 @@ impl WGPU {
descriptor, descriptor,
} => { } => {
let global = &self.global; let global = &self.global;
let (_, error) = gfx_select!(sampler_id => global.device_create_sampler( let (_, error) =
device_id, global.device_create_sampler(device_id, &descriptor, Some(sampler_id));
&descriptor,
Some(sampler_id)
));
self.maybe_dispatch_wgpu_error(device_id, error); self.maybe_dispatch_wgpu_error(device_id, error);
}, },
WebGPURequest::CreateShaderModule { WebGPURequest::CreateShaderModule {
@ -512,8 +513,12 @@ impl WGPU {
label: label.map(|s| s.into()), label: label.map(|s| s.into()),
shader_bound_checks: wgt::ShaderBoundChecks::default(), shader_bound_checks: wgt::ShaderBoundChecks::default(),
}; };
let (_, error) = gfx_select!(program_id => let (_, error) = global.device_create_shader_module(
global.device_create_shader_module(device_id, &desc, source, Some(program_id))); device_id,
&desc,
source,
Some(program_id),
);
if let Err(e) = sender.send(WebGPUResponse::CompilationInfo( if let Err(e) = sender.send(WebGPUResponse::CompilationInfo(
error error
.as_ref() .as_ref()
@ -575,12 +580,8 @@ impl WGPU {
} => { } => {
let global = &self.global; let global = &self.global;
if let Some(desc) = descriptor { if let Some(desc) = descriptor {
let (_, error) = gfx_select!(texture_id => global.device_create_texture( let (_, error) =
device_id, global.device_create_texture(device_id, &desc, Some(texture_id));
&desc,
Some(texture_id)
)
);
self.maybe_dispatch_wgpu_error(device_id, error); self.maybe_dispatch_wgpu_error(device_id, error);
} }
}, },
@ -592,11 +593,10 @@ impl WGPU {
} => { } => {
let global = &self.global; let global = &self.global;
if let Some(desc) = descriptor { if let Some(desc) = descriptor {
let (_, error) = gfx_select!(texture_view_id => global.texture_create_view( let (_, error) = global.texture_create_view(
texture_id, texture_id,
&desc, &desc,
Some(texture_view_id) Some(texture_view_id),
)
); );
self.maybe_dispatch_wgpu_error(device_id, error); self.maybe_dispatch_wgpu_error(device_id, error);
@ -604,11 +604,11 @@ impl WGPU {
}, },
WebGPURequest::DestroyBuffer(buffer) => { WebGPURequest::DestroyBuffer(buffer) => {
let global = &self.global; let global = &self.global;
let _result = gfx_select!(buffer => global.buffer_destroy(buffer)); let _result = global.buffer_destroy(buffer);
}, },
WebGPURequest::DestroyDevice(device) => { WebGPURequest::DestroyDevice(device) => {
let global = &self.global; let global = &self.global;
gfx_select!(device => global.device_destroy(device)); global.device_destroy(device);
// Wake poller thread to trigger DeviceLostClosure // Wake poller thread to trigger DeviceLostClosure
self.poller.wake(); self.poller.wake();
}, },
@ -624,10 +624,10 @@ impl WGPU {
.unwrap(); .unwrap();
let global = &self.global; let global = &self.global;
for b_id in data.available_buffer_ids.iter() { for b_id in data.available_buffer_ids.iter() {
gfx_select!(b_id => global.buffer_drop(*b_id)); global.buffer_drop(*b_id);
} }
for b_id in data.queued_buffer_ids.iter() { for b_id in data.queued_buffer_ids.iter() {
gfx_select!(b_id => global.buffer_drop(*b_id)); global.buffer_drop(*b_id);
} }
for b_id in data.unassigned_buffer_ids.iter() { for b_id in data.unassigned_buffer_ids.iter() {
if let Err(e) = self.script_sender.send(WebGPUMsg::FreeBuffer(*b_id)) { if let Err(e) = self.script_sender.send(WebGPUMsg::FreeBuffer(*b_id)) {
@ -646,7 +646,7 @@ impl WGPU {
texture_id, texture_id,
} => { } => {
let global = &self.global; let global = &self.global;
let result = gfx_select!(texture_id => global.texture_destroy(texture_id)); let result = global.texture_destroy(texture_id);
self.maybe_dispatch_wgpu_error(device_id, result.err()); self.maybe_dispatch_wgpu_error(device_id, result.err());
}, },
WebGPURequest::Exit(sender) => { WebGPURequest::Exit(sender) => {
@ -659,14 +659,14 @@ impl WGPU {
self.error_command_encoders self.error_command_encoders
.remove(&id.into_command_encoder_id()); .remove(&id.into_command_encoder_id());
let global = &self.global; let global = &self.global;
gfx_select!(id => global.command_buffer_drop(id)); global.command_buffer_drop(id);
if let Err(e) = self.script_sender.send(WebGPUMsg::FreeCommandBuffer(id)) { if let Err(e) = self.script_sender.send(WebGPUMsg::FreeCommandBuffer(id)) {
warn!("Unable to send FreeCommandBuffer({:?}) ({:?})", id, e); warn!("Unable to send FreeCommandBuffer({:?}) ({:?})", id, e);
}; };
}, },
WebGPURequest::DropDevice(device_id) => { WebGPURequest::DropDevice(device_id) => {
let global = &self.global; let global = &self.global;
gfx_select!(device_id => global.device_drop(device_id)); global.device_drop(device_id);
let device_scope = self let device_scope = self
.devices .devices
.lock() .lock()
@ -687,11 +687,10 @@ impl WGPU {
device_id, device_id,
} => { } => {
let global = &self.global; let global = &self.global;
let (_, error) = gfx_select!(render_bundle_id => global.render_bundle_encoder_finish( let (_, error) = global.render_bundle_encoder_finish(
render_bundle_encoder, render_bundle_encoder,
&descriptor, &descriptor,
Some(render_bundle_id) Some(render_bundle_id),
)
); );
self.maybe_dispatch_wgpu_error(device_id, error); self.maybe_dispatch_wgpu_error(device_id, error);
@ -709,15 +708,9 @@ impl WGPU {
let adapter = WebGPUAdapter(adapter_id); let adapter = WebGPUAdapter(adapter_id);
self.adapters.push(adapter); self.adapters.push(adapter);
// TODO: can we do this lazily // TODO: can we do this lazily
let info = let info = global.adapter_get_info(adapter_id).unwrap();
gfx_select!(adapter_id => global.adapter_get_info(adapter_id)) let limits = global.adapter_limits(adapter_id).unwrap();
.unwrap(); let features = global.adapter_features(adapter_id).unwrap();
let limits =
gfx_select!(adapter_id => global.adapter_limits(adapter_id))
.unwrap();
let features =
gfx_select!(adapter_id => global.adapter_features(adapter_id))
.unwrap();
Adapter { Adapter {
adapter_info: info, adapter_info: info,
adapter_id: adapter, adapter_id: adapter,
@ -749,13 +742,13 @@ impl WGPU {
memory_hints: MemoryHints::MemoryUsage, memory_hints: MemoryHints::MemoryUsage,
}; };
let global = &self.global; let global = &self.global;
let (device_id, queue_id, error) = gfx_select!(device_id => global.adapter_request_device( let (device_id, queue_id, error) = global.adapter_request_device(
adapter_id.0, adapter_id.0,
&desc, &desc,
None, None,
Some(device_id), Some(device_id),
Some(queue_id), Some(queue_id),
)); );
let device = WebGPUDevice(device_id); let device = WebGPUDevice(device_id);
let queue = WebGPUQueue(queue_id); let queue = WebGPUQueue(queue_id);
if let Some(e) = error { if let Some(e) = error {
@ -811,7 +804,7 @@ impl WGPU {
warn!("Failed to send WebGPUMsg::DeviceLost: {e}"); warn!("Failed to send WebGPUMsg::DeviceLost: {e}");
} }
})); }));
gfx_select!(device_id => global.device_set_device_lost_closure(device_id, callback)); global.device_set_device_lost_closure(device_id, callback);
if let Err(e) = if let Err(e) =
sender.send(WebGPUResponse::Device((device, queue, Ok(descriptor)))) sender.send(WebGPUResponse::Device((device, queue, Ok(descriptor))))
{ {
@ -828,11 +821,13 @@ impl WGPU {
device_id: _device_id, device_id: _device_id,
} => { } => {
let global = &self.global; let global = &self.global;
let (pass, error) = gfx_select!( let (pass, error) = global.command_encoder_create_compute_pass(
command_encoder_id => global.command_encoder_create_compute_pass_dyn(
command_encoder_id, command_encoder_id,
&ComputePassDescriptor { label, timestamp_writes: None } &ComputePassDescriptor {
)); label,
timestamp_writes: None,
},
);
assert!( assert!(
self.compute_passes self.compute_passes
.insert(compute_pass_id, Pass::new(pass, error.is_none())) .insert(compute_pass_id, Pass::new(pass, error.is_none()))
@ -852,7 +847,10 @@ impl WGPU {
.get_mut(&compute_pass_id) .get_mut(&compute_pass_id)
.expect("ComputePass should exists"); .expect("ComputePass should exists");
if let Pass::Open { pass, valid } = pass { if let Pass::Open { pass, valid } = pass {
*valid &= pass.set_pipeline(&self.global, pipeline_id).is_ok(); *valid &= self
.global
.compute_pass_set_pipeline(pass, pipeline_id)
.is_ok();
} else { } else {
self.maybe_dispatch_error( self.maybe_dispatch_error(
device_id, device_id,
@ -872,8 +870,9 @@ impl WGPU {
.get_mut(&compute_pass_id) .get_mut(&compute_pass_id)
.expect("ComputePass should exists"); .expect("ComputePass should exists");
if let Pass::Open { pass, valid } = pass { if let Pass::Open { pass, valid } = pass {
*valid &= pass *valid &= self
.set_bind_group(&self.global, index, bind_group_id, &offsets) .global
.compute_pass_set_bind_group(pass, index, bind_group_id, &offsets)
.is_ok(); .is_ok();
} else { } else {
self.maybe_dispatch_error( self.maybe_dispatch_error(
@ -894,7 +893,10 @@ impl WGPU {
.get_mut(&compute_pass_id) .get_mut(&compute_pass_id)
.expect("ComputePass should exists"); .expect("ComputePass should exists");
if let Pass::Open { pass, valid } = pass { if let Pass::Open { pass, valid } = pass {
*valid &= pass.dispatch_workgroups(&self.global, x, y, z).is_ok(); *valid &= self
.global
.compute_pass_dispatch_workgroups(pass, x, y, z)
.is_ok();
} else { } else {
self.maybe_dispatch_error( self.maybe_dispatch_error(
device_id, device_id,
@ -913,8 +915,9 @@ impl WGPU {
.get_mut(&compute_pass_id) .get_mut(&compute_pass_id)
.expect("ComputePass should exists"); .expect("ComputePass should exists");
if let Pass::Open { pass, valid } = pass { if let Pass::Open { pass, valid } = pass {
*valid &= pass *valid &= self
.dispatch_workgroups_indirect(&self.global, buffer_id, offset) .global
.compute_pass_dispatch_workgroups_indirect(pass, buffer_id, offset)
.is_ok(); .is_ok();
} else { } else {
self.maybe_dispatch_error( self.maybe_dispatch_error(
@ -937,7 +940,7 @@ impl WGPU {
if let Pass::Open { mut pass, valid } = pass.take() { if let Pass::Open { mut pass, valid } = pass.take() {
// `pass.end` does step 1-4 // `pass.end` does step 1-4
// and if it returns ok we check the validity of the pass at step 5 // and if it returns ok we check the validity of the pass at step 5
if pass.end(&self.global).is_ok() && !valid { if self.global.compute_pass_end(&mut pass).is_ok() && !valid {
self.encoder_record_error( self.encoder_record_error(
command_encoder_id, command_encoder_id,
&Err::<(), _>("Pass is invalid".to_string()), &Err::<(), _>("Pass is invalid".to_string()),
@ -966,11 +969,8 @@ impl WGPU {
timestamp_writes: None, timestamp_writes: None,
occlusion_query_set: None, occlusion_query_set: None,
}; };
let (pass, error) = gfx_select!( let (pass, error) =
command_encoder_id => global.command_encoder_create_render_pass_dyn( global.command_encoder_create_render_pass(command_encoder_id, desc);
command_encoder_id,
desc,
));
assert!( assert!(
self.render_passes self.render_passes
.insert(render_pass_id, Pass::new(pass, error.is_none())) .insert(render_pass_id, Pass::new(pass, error.is_none()))
@ -1013,7 +1013,7 @@ impl WGPU {
if let Pass::Open { mut pass, valid } = pass.take() { if let Pass::Open { mut pass, valid } = pass.take() {
// `pass.end` does step 1-4 // `pass.end` does step 1-4
// and if it returns ok we check the validity of the pass at step 5 // and if it returns ok we check the validity of the pass at step 5
if pass.end(&self.global).is_ok() && !valid { if self.global.render_pass_end(&mut pass).is_ok() && !valid {
self.encoder_record_error( self.encoder_record_error(
command_encoder_id, command_encoder_id,
&Err::<(), _>("Pass is invalid".to_string()), &Err::<(), _>("Pass is invalid".to_string()),
@ -1042,7 +1042,8 @@ impl WGPU {
))) )))
} else { } else {
let _guard = self.poller.lock(); let _guard = self.poller.lock();
gfx_select!(queue_id => global.queue_submit(queue_id, &command_buffers)) global
.queue_submit(queue_id, &command_buffers)
.map_err(Error::from_error) .map_err(Error::from_error)
}; };
self.maybe_dispatch_error(device_id, result.err()); self.maybe_dispatch_error(device_id, result.err());
@ -1081,11 +1082,11 @@ impl WGPU {
wgt::BufferUsages::COPY_DST, wgt::BufferUsages::COPY_DST,
mapped_at_creation: false, mapped_at_creation: false,
}; };
let _ = gfx_select!(b_id => global.device_create_buffer( let _ = global.device_create_buffer(
device_id, device_id,
&buffer_desc, &buffer_desc,
Some(b_id) Some(b_id),
)); );
b_id b_id
} else { } else {
warn!( warn!(
@ -1104,11 +1105,11 @@ impl WGPU {
let buffer_size = let buffer_size =
(size.height as u32 * buffer_stride) as wgt::BufferAddress; (size.height as u32 * buffer_stride) as wgt::BufferAddress;
let comm_desc = wgt::CommandEncoderDescriptor { label: None }; let comm_desc = wgt::CommandEncoderDescriptor { label: None };
let _ = gfx_select!(encoder_id => global.device_create_command_encoder( let _ = global.device_create_command_encoder(
device_id, device_id,
&comm_desc, &comm_desc,
Some(encoder_id) Some(encoder_id),
)); );
let buffer_cv = ImageCopyBuffer { let buffer_cv = ImageCopyBuffer {
buffer: buffer_id, buffer: buffer_id,
@ -1129,20 +1130,18 @@ impl WGPU {
height: size.height as u32, height: size.height as u32,
depth_or_array_layers: 1, depth_or_array_layers: 1,
}; };
let _ = gfx_select!(encoder_id => global.command_encoder_copy_texture_to_buffer( let _ = global.command_encoder_copy_texture_to_buffer(
encoder_id, encoder_id,
&texture_cv, &texture_cv,
&buffer_cv, &buffer_cv,
&copy_size &copy_size,
)); );
let _ = gfx_select!(encoder_id => global.command_encoder_finish( let _ = global.command_encoder_finish(
encoder_id, encoder_id,
&wgt::CommandBufferDescriptor::default() &wgt::CommandBufferDescriptor::default(),
)); );
let _ = gfx_select!(queue_id => global.queue_submit( let _ =
queue_id, global.queue_submit(queue_id, &[encoder_id.into_command_buffer_id()]);
&[encoder_id.into_command_buffer_id()]
));
let glob = Arc::clone(&self.global); let glob = Arc::clone(&self.global);
let wgpu_image_map = Arc::clone(&self.wgpu_image_map); let wgpu_image_map = Arc::clone(&self.wgpu_image_map);
@ -1154,8 +1153,12 @@ impl WGPU {
match result { match result {
Ok(()) => { Ok(()) => {
let global = &glob; let global = &glob;
let (slice_pointer, range_size) = gfx_select!(buffer_id => let (slice_pointer, range_size) = global
global.buffer_get_mapped_range(buffer_id, 0, Some(buffer_size as u64))) .buffer_get_mapped_range(
buffer_id,
0,
Some(buffer_size as u64),
)
.unwrap(); .unwrap();
let data = unsafe { let data = unsafe {
slice::from_raw_parts( slice::from_raw_parts(
@ -1189,8 +1192,7 @@ impl WGPU {
external_id external_id
); );
} }
let _ = let _ = global.buffer_unmap(buffer_id);
gfx_select!(buffer_id => global.buffer_unmap(buffer_id));
}, },
_ => error!("Could not map buffer({:?})", buffer_id), _ => error!("Could not map buffer({:?})", buffer_id),
} }
@ -1199,8 +1201,7 @@ impl WGPU {
host: HostMap::Read, host: HostMap::Read,
callback: Some(callback), callback: Some(callback),
}; };
let _ = gfx_select!(buffer_id let _ = global.buffer_map_async(buffer_id, 0, Some(buffer_size), map_op);
=> global.buffer_map_async(buffer_id, 0, Some(buffer_size), map_op));
self.poller.wake(); self.poller.wake();
}, },
WebGPURequest::UnmapBuffer { WebGPURequest::UnmapBuffer {
@ -1212,13 +1213,9 @@ impl WGPU {
} => { } => {
let global = &self.global; let global = &self.global;
if write_back { if write_back {
if let Ok((slice_pointer, range_size)) = gfx_select!( if let Ok((slice_pointer, range_size)) =
buffer_id => global.buffer_get_mapped_range( global.buffer_get_mapped_range(buffer_id, offset, Some(size))
buffer_id, {
offset,
Some(size)
)
) {
unsafe { unsafe {
slice::from_raw_parts_mut( slice::from_raw_parts_mut(
slice_pointer.as_ptr(), slice_pointer.as_ptr(),
@ -1229,7 +1226,7 @@ impl WGPU {
} }
} }
// Ignore result because this operation always succeed from user perspective // Ignore result because this operation always succeed from user perspective
let _result = gfx_select!(buffer_id => global.buffer_unmap(buffer_id)); let _result = global.buffer_unmap(buffer_id);
}, },
WebGPURequest::WriteBuffer { WebGPURequest::WriteBuffer {
device_id, device_id,
@ -1239,12 +1236,12 @@ impl WGPU {
data, data,
} => { } => {
let global = &self.global; let global = &self.global;
let result = gfx_select!(queue_id => global.queue_write_buffer( let result = global.queue_write_buffer(
queue_id, queue_id,
buffer_id, buffer_id,
buffer_offset as wgt::BufferAddress, buffer_offset as wgt::BufferAddress,
&data &data,
)); );
self.maybe_dispatch_wgpu_error(device_id, result.err()); self.maybe_dispatch_wgpu_error(device_id, result.err());
}, },
WebGPURequest::WriteTexture { WebGPURequest::WriteTexture {
@ -1258,13 +1255,13 @@ impl WGPU {
let global = &self.global; let global = &self.global;
let _guard = self.poller.lock(); let _guard = self.poller.lock();
//TODO: Report result to content process //TODO: Report result to content process
let result = gfx_select!(queue_id => global.queue_write_texture( let result = global.queue_write_texture(
queue_id, queue_id,
&texture_cv, &texture_cv,
&data, &data,
&data_layout, &data_layout,
&size &size,
)); );
drop(_guard); drop(_guard);
self.maybe_dispatch_wgpu_error(device_id, result.err()); self.maybe_dispatch_wgpu_error(device_id, result.err());
}, },
@ -1281,13 +1278,13 @@ impl WGPU {
warn!("Could not send SubmittedWorkDone Response ({})", e); warn!("Could not send SubmittedWorkDone Response ({})", e);
} }
})); }));
let result = gfx_select!(queue_id => global.queue_on_submitted_work_done(queue_id, callback)); let result = global.queue_on_submitted_work_done(queue_id, callback);
self.poller.wake(); self.poller.wake();
self.maybe_dispatch_wgpu_error(device_id, result.err()); self.maybe_dispatch_wgpu_error(device_id, result.err());
}, },
WebGPURequest::DropTexture(id) => { WebGPURequest::DropTexture(id) => {
let global = &self.global; let global = &self.global;
gfx_select!(id => global.texture_drop(id)); global.texture_drop(id);
self.poller.wake(); self.poller.wake();
if let Err(e) = self.script_sender.send(WebGPUMsg::FreeTexture(id)) { if let Err(e) = self.script_sender.send(WebGPUMsg::FreeTexture(id)) {
warn!("Unable to send FreeTexture({:?}) ({:?})", id, e); warn!("Unable to send FreeTexture({:?}) ({:?})", id, e);
@ -1295,14 +1292,14 @@ impl WGPU {
}, },
WebGPURequest::DropAdapter(id) => { WebGPURequest::DropAdapter(id) => {
let global = &self.global; let global = &self.global;
gfx_select!(id => global.adapter_drop(id)); global.adapter_drop(id);
if let Err(e) = self.script_sender.send(WebGPUMsg::FreeAdapter(id)) { if let Err(e) = self.script_sender.send(WebGPUMsg::FreeAdapter(id)) {
warn!("Unable to send FreeAdapter({:?}) ({:?})", id, e); warn!("Unable to send FreeAdapter({:?}) ({:?})", id, e);
}; };
}, },
WebGPURequest::DropBuffer(id) => { WebGPURequest::DropBuffer(id) => {
let global = &self.global; let global = &self.global;
gfx_select!(id => global.buffer_drop(id)); global.buffer_drop(id);
self.poller.wake(); self.poller.wake();
if let Err(e) = self.script_sender.send(WebGPUMsg::FreeBuffer(id)) { if let Err(e) = self.script_sender.send(WebGPUMsg::FreeBuffer(id)) {
warn!("Unable to send FreeBuffer({:?}) ({:?})", id, e); warn!("Unable to send FreeBuffer({:?}) ({:?})", id, e);
@ -1310,14 +1307,14 @@ impl WGPU {
}, },
WebGPURequest::DropPipelineLayout(id) => { WebGPURequest::DropPipelineLayout(id) => {
let global = &self.global; let global = &self.global;
gfx_select!(id => global.pipeline_layout_drop(id)); global.pipeline_layout_drop(id);
if let Err(e) = self.script_sender.send(WebGPUMsg::FreePipelineLayout(id)) { if let Err(e) = self.script_sender.send(WebGPUMsg::FreePipelineLayout(id)) {
warn!("Unable to send FreePipelineLayout({:?}) ({:?})", id, e); warn!("Unable to send FreePipelineLayout({:?}) ({:?})", id, e);
}; };
}, },
WebGPURequest::DropComputePipeline(id) => { WebGPURequest::DropComputePipeline(id) => {
let global = &self.global; let global = &self.global;
gfx_select!(id => global.compute_pipeline_drop(id)); global.compute_pipeline_drop(id);
if let Err(e) = self.script_sender.send(WebGPUMsg::FreeComputePipeline(id)) if let Err(e) = self.script_sender.send(WebGPUMsg::FreeComputePipeline(id))
{ {
warn!("Unable to send FreeComputePipeline({:?}) ({:?})", id, e); warn!("Unable to send FreeComputePipeline({:?}) ({:?})", id, e);
@ -1340,21 +1337,21 @@ impl WGPU {
}, },
WebGPURequest::DropRenderPipeline(id) => { WebGPURequest::DropRenderPipeline(id) => {
let global = &self.global; let global = &self.global;
gfx_select!(id => global.render_pipeline_drop(id)); global.render_pipeline_drop(id);
if let Err(e) = self.script_sender.send(WebGPUMsg::FreeRenderPipeline(id)) { if let Err(e) = self.script_sender.send(WebGPUMsg::FreeRenderPipeline(id)) {
warn!("Unable to send FreeRenderPipeline({:?}) ({:?})", id, e); warn!("Unable to send FreeRenderPipeline({:?}) ({:?})", id, e);
}; };
}, },
WebGPURequest::DropBindGroup(id) => { WebGPURequest::DropBindGroup(id) => {
let global = &self.global; let global = &self.global;
gfx_select!(id => global.bind_group_drop(id)); global.bind_group_drop(id);
if let Err(e) = self.script_sender.send(WebGPUMsg::FreeBindGroup(id)) { if let Err(e) = self.script_sender.send(WebGPUMsg::FreeBindGroup(id)) {
warn!("Unable to send FreeBindGroup({:?}) ({:?})", id, e); warn!("Unable to send FreeBindGroup({:?}) ({:?})", id, e);
}; };
}, },
WebGPURequest::DropBindGroupLayout(id) => { WebGPURequest::DropBindGroupLayout(id) => {
let global = &self.global; let global = &self.global;
gfx_select!(id => global.bind_group_layout_drop(id)); global.bind_group_layout_drop(id);
if let Err(e) = self.script_sender.send(WebGPUMsg::FreeBindGroupLayout(id)) if let Err(e) = self.script_sender.send(WebGPUMsg::FreeBindGroupLayout(id))
{ {
warn!("Unable to send FreeBindGroupLayout({:?}) ({:?})", id, e); warn!("Unable to send FreeBindGroupLayout({:?}) ({:?})", id, e);
@ -1362,7 +1359,7 @@ impl WGPU {
}, },
WebGPURequest::DropTextureView(id) => { WebGPURequest::DropTextureView(id) => {
let global = &self.global; let global = &self.global;
let _result = gfx_select!(id => global.texture_view_drop(id)); let _result = global.texture_view_drop(id);
self.poller.wake(); self.poller.wake();
if let Err(e) = self.script_sender.send(WebGPUMsg::FreeTextureView(id)) { if let Err(e) = self.script_sender.send(WebGPUMsg::FreeTextureView(id)) {
warn!("Unable to send FreeTextureView({:?}) ({:?})", id, e); warn!("Unable to send FreeTextureView({:?}) ({:?})", id, e);
@ -1370,28 +1367,28 @@ impl WGPU {
}, },
WebGPURequest::DropSampler(id) => { WebGPURequest::DropSampler(id) => {
let global = &self.global; let global = &self.global;
gfx_select!(id => global.sampler_drop(id)); global.sampler_drop(id);
if let Err(e) = self.script_sender.send(WebGPUMsg::FreeSampler(id)) { if let Err(e) = self.script_sender.send(WebGPUMsg::FreeSampler(id)) {
warn!("Unable to send FreeSampler({:?}) ({:?})", id, e); warn!("Unable to send FreeSampler({:?}) ({:?})", id, e);
}; };
}, },
WebGPURequest::DropShaderModule(id) => { WebGPURequest::DropShaderModule(id) => {
let global = &self.global; let global = &self.global;
gfx_select!(id => global.shader_module_drop(id)); global.shader_module_drop(id);
if let Err(e) = self.script_sender.send(WebGPUMsg::FreeShaderModule(id)) { if let Err(e) = self.script_sender.send(WebGPUMsg::FreeShaderModule(id)) {
warn!("Unable to send FreeShaderModule({:?}) ({:?})", id, e); warn!("Unable to send FreeShaderModule({:?}) ({:?})", id, e);
}; };
}, },
WebGPURequest::DropRenderBundle(id) => { WebGPURequest::DropRenderBundle(id) => {
let global = &self.global; let global = &self.global;
gfx_select!(id => global.render_bundle_drop(id)); global.render_bundle_drop(id);
if let Err(e) = self.script_sender.send(WebGPUMsg::FreeRenderBundle(id)) { if let Err(e) = self.script_sender.send(WebGPUMsg::FreeRenderBundle(id)) {
warn!("Unable to send FreeRenderBundle({:?}) ({:?})", id, e); warn!("Unable to send FreeRenderBundle({:?}) ({:?})", id, e);
}; };
}, },
WebGPURequest::DropQuerySet(id) => { WebGPURequest::DropQuerySet(id) => {
let global = &self.global; let global = &self.global;
gfx_select!(id => global.query_set_drop(id)); global.query_set_drop(id);
if let Err(e) = self.script_sender.send(WebGPUMsg::FreeQuerySet(id)) { if let Err(e) = self.script_sender.send(WebGPUMsg::FreeQuerySet(id)) {
warn!("Unable to send FreeQuerySet({:?}) ({:?})", id, e); warn!("Unable to send FreeQuerySet({:?}) ({:?})", id, e);
}; };
@ -1447,8 +1444,11 @@ impl WGPU {
id, id,
} => { } => {
let global = &self.global; let global = &self.global;
let (_, error) = gfx_select!(pipeline_id => let (_, error) = global.compute_pipeline_get_bind_group_layout(
global.compute_pipeline_get_bind_group_layout(pipeline_id, index, Some(id))); pipeline_id,
index,
Some(id),
);
self.maybe_dispatch_wgpu_error(device_id, error); self.maybe_dispatch_wgpu_error(device_id, error);
}, },
WebGPURequest::RenderGetBindGroupLayout { WebGPURequest::RenderGetBindGroupLayout {
@ -1458,8 +1458,11 @@ impl WGPU {
id, id,
} => { } => {
let global = &self.global; let global = &self.global;
let (_, error) = gfx_select!(pipeline_id => let (_, error) = global.render_pipeline_get_bind_group_layout(
global.render_pipeline_get_bind_group_layout(pipeline_id, index, Some(id))); pipeline_id,
index,
Some(id),
);
self.maybe_dispatch_wgpu_error(device_id, error); self.maybe_dispatch_wgpu_error(device_id, error);
}, },
} }