summaryrefslogtreecommitdiff
path: root/ext/webgpu/src/command_encoder.rs
diff options
context:
space:
mode:
authorDante Issaias <dante@issaias.com>2022-07-20 01:22:26 +0100
committerGitHub <noreply@github.com>2022-07-20 02:22:26 +0200
commit2b1f145c3e51cf9885c073b78bd5882e80d258e3 (patch)
treeface88f9a6d6d109ebf8f659a59bc74e6f6ae8ee /ext/webgpu/src/command_encoder.rs
parent649536e2669eb496fc2d4dacd92fd1d6dbed50a7 (diff)
chore(ext): update webgpu (#15059)
Diffstat (limited to 'ext/webgpu/src/command_encoder.rs')
-rw-r--r--ext/webgpu/src/command_encoder.rs434
1 files changed, 160 insertions, 274 deletions
diff --git a/ext/webgpu/src/command_encoder.rs b/ext/webgpu/src/command_encoder.rs
index dc777a85d..d09199bbf 100644
--- a/ext/webgpu/src/command_encoder.rs
+++ b/ext/webgpu/src/command_encoder.rs
@@ -2,8 +2,9 @@
use deno_core::error::AnyError;
use deno_core::op;
+use deno_core::OpState;
+use deno_core::Resource;
use deno_core::ResourceId;
-use deno_core::{OpState, Resource};
use serde::Deserialize;
use std::borrow::Cow;
use std::cell::RefCell;
@@ -29,27 +30,20 @@ impl Resource for WebGpuCommandBuffer {
}
}
-#[derive(Deserialize)]
-#[serde(rename_all = "camelCase")]
-pub struct CreateCommandEncoderArgs {
- device_rid: ResourceId,
- label: Option<String>,
- _measure_execution_time: Option<bool>, // not yet implemented
-}
-
#[op]
pub fn op_webgpu_create_command_encoder(
state: &mut OpState,
- args: CreateCommandEncoderArgs,
+ device_rid: ResourceId,
+ label: Option<String>,
) -> Result<WebGpuResult, AnyError> {
let instance = state.borrow::<super::Instance>();
let device_resource = state
.resource_table
- .get::<super::WebGpuDevice>(args.device_rid)?;
+ .get::<super::WebGpuDevice>(device_rid)?;
let device = device_resource.0;
let descriptor = wgpu_types::CommandEncoderDescriptor {
- label: args.label.map(Cow::from),
+ label: label.map(Cow::from),
};
gfx_put!(device => instance.device_create_command_encoder(
@@ -64,134 +58,104 @@ pub fn op_webgpu_create_command_encoder(
pub struct GpuRenderPassColorAttachment {
view: ResourceId,
resolve_target: Option<ResourceId>,
- load_op: GpuLoadOp<wgpu_types::Color>,
+ clear_value: Option<wgpu_types::Color>,
+ load_op: wgpu_core::command::LoadOp,
store_op: wgpu_core::command::StoreOp,
}
#[derive(Deserialize)]
-#[serde(rename_all = "kebab-case")]
-enum GpuLoadOp<T> {
- Load,
- Clear(T),
-}
-
-#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
-struct GpuRenderPassDepthStencilAttachment {
+pub struct GpuRenderPassDepthStencilAttachment {
view: ResourceId,
- depth_load_op: GpuLoadOp<f32>,
+ depth_clear_value: f32,
+ depth_load_op: wgpu_core::command::LoadOp,
depth_store_op: wgpu_core::command::StoreOp,
depth_read_only: bool,
- stencil_load_op: GpuLoadOp<u32>,
+ stencil_clear_value: u32,
+ stencil_load_op: wgpu_core::command::LoadOp,
stencil_store_op: wgpu_core::command::StoreOp,
stencil_read_only: bool,
}
-#[derive(Deserialize)]
-#[serde(rename_all = "camelCase")]
-pub struct CommandEncoderBeginRenderPassArgs {
+#[op]
+pub fn op_webgpu_command_encoder_begin_render_pass(
+ state: &mut OpState,
command_encoder_rid: ResourceId,
label: Option<String>,
- color_attachments: Vec<GpuRenderPassColorAttachment>,
+ color_attachments: Vec<Option<GpuRenderPassColorAttachment>>,
depth_stencil_attachment: Option<GpuRenderPassDepthStencilAttachment>,
_occlusion_query_set: Option<u32>, // not yet implemented
-}
-
-#[op]
-pub fn op_webgpu_command_encoder_begin_render_pass(
- state: &mut OpState,
- args: CommandEncoderBeginRenderPassArgs,
) -> Result<WebGpuResult, AnyError> {
let command_encoder_resource = state
.resource_table
- .get::<WebGpuCommandEncoder>(args.command_encoder_rid)?;
-
- let mut color_attachments = vec![];
-
- for color_attachment in args.color_attachments {
- let texture_view_resource =
- state
- .resource_table
- .get::<super::texture::WebGpuTextureView>(color_attachment.view)?;
-
- let resolve_target = color_attachment
- .resolve_target
- .map(|rid| {
- state
- .resource_table
- .get::<super::texture::WebGpuTextureView>(rid)
- })
- .transpose()?
- .map(|texture| texture.0);
-
- let attachment = wgpu_core::command::RenderPassColorAttachment {
- view: texture_view_resource.0,
- resolve_target,
- channel: match color_attachment.load_op {
- GpuLoadOp::Load => wgpu_core::command::PassChannel {
- load_op: wgpu_core::command::LoadOp::Load,
- store_op: color_attachment.store_op,
- clear_value: Default::default(),
- read_only: false,
- },
- GpuLoadOp::Clear(color) => wgpu_core::command::PassChannel {
- load_op: wgpu_core::command::LoadOp::Clear,
- store_op: color_attachment.store_op,
- clear_value: color,
- read_only: false,
- },
- },
- };
-
- color_attachments.push(attachment)
- }
+ .get::<WebGpuCommandEncoder>(command_encoder_rid)?;
+
+ let color_attachments = color_attachments
+ .into_iter()
+ .map(|color_attachment| {
+ let rp_at = if let Some(at) = color_attachment.as_ref() {
+ let texture_view_resource =
+ state
+ .resource_table
+ .get::<super::texture::WebGpuTextureView>(at.view)?;
+
+ let resolve_target = at
+ .resolve_target
+ .map(|rid| {
+ state
+ .resource_table
+ .get::<super::texture::WebGpuTextureView>(rid)
+ })
+ .transpose()?
+ .map(|texture| texture.0);
+
+ Some(wgpu_core::command::RenderPassColorAttachment {
+ view: texture_view_resource.0,
+ resolve_target,
+ channel: wgpu_core::command::PassChannel {
+ load_op: at.load_op,
+ store_op: at.store_op,
+ clear_value: at.clear_value.unwrap_or_default(),
+ read_only: false,
+ },
+ })
+ } else {
+ None
+ };
+ Ok(rp_at)
+ })
+ .collect::<Result<Vec<_>, AnyError>>()?;
- let mut depth_stencil_attachment = None;
+ let mut processed_depth_stencil_attachment = None;
- if let Some(attachment) = args.depth_stencil_attachment {
+ if let Some(attachment) = depth_stencil_attachment {
let texture_view_resource =
state
.resource_table
.get::<super::texture::WebGpuTextureView>(attachment.view)?;
- depth_stencil_attachment =
+ processed_depth_stencil_attachment =
Some(wgpu_core::command::RenderPassDepthStencilAttachment {
view: texture_view_resource.0,
- depth: match attachment.depth_load_op {
- GpuLoadOp::Load => wgpu_core::command::PassChannel {
- load_op: wgpu_core::command::LoadOp::Load,
- store_op: attachment.depth_store_op,
- clear_value: 0.0,
- read_only: attachment.depth_read_only,
- },
- GpuLoadOp::Clear(value) => wgpu_core::command::PassChannel {
- load_op: wgpu_core::command::LoadOp::Clear,
- store_op: attachment.depth_store_op,
- clear_value: value,
- read_only: attachment.depth_read_only,
- },
+ depth: wgpu_core::command::PassChannel {
+ load_op: attachment.depth_load_op,
+ store_op: attachment.depth_store_op,
+ clear_value: attachment.depth_clear_value,
+ read_only: attachment.depth_read_only,
},
- stencil: match attachment.stencil_load_op {
- GpuLoadOp::Load => wgpu_core::command::PassChannel {
- load_op: wgpu_core::command::LoadOp::Load,
- store_op: attachment.stencil_store_op,
- clear_value: 0,
- read_only: attachment.stencil_read_only,
- },
- GpuLoadOp::Clear(value) => wgpu_core::command::PassChannel {
- load_op: wgpu_core::command::LoadOp::Clear,
- store_op: attachment.stencil_store_op,
- clear_value: value,
- read_only: attachment.stencil_read_only,
- },
+ stencil: wgpu_core::command::PassChannel {
+ load_op: attachment.stencil_load_op,
+ store_op: attachment.stencil_store_op,
+ clear_value: attachment.stencil_clear_value,
+ read_only: attachment.stencil_read_only,
},
});
}
let descriptor = wgpu_core::command::RenderPassDescriptor {
- label: args.label.map(Cow::from),
+ label: label.map(Cow::from),
color_attachments: Cow::from(color_attachments),
- depth_stencil_attachment: depth_stencil_attachment.as_ref(),
+ depth_stencil_attachment: processed_depth_stencil_attachment.as_ref(),
};
let render_pass = wgpu_core::command::RenderPass::new(
@@ -208,24 +172,18 @@ pub fn op_webgpu_command_encoder_begin_render_pass(
Ok(WebGpuResult::rid(rid))
}
-#[derive(Deserialize)]
-#[serde(rename_all = "camelCase")]
-pub struct CommandEncoderBeginComputePassArgs {
- command_encoder_rid: ResourceId,
- label: Option<String>,
-}
-
#[op]
pub fn op_webgpu_command_encoder_begin_compute_pass(
state: &mut OpState,
- args: CommandEncoderBeginComputePassArgs,
+ command_encoder_rid: ResourceId,
+ label: Option<String>,
) -> Result<WebGpuResult, AnyError> {
let command_encoder_resource = state
.resource_table
- .get::<WebGpuCommandEncoder>(args.command_encoder_rid)?;
+ .get::<WebGpuCommandEncoder>(command_encoder_rid)?;
let descriptor = wgpu_core::command::ComputePassDescriptor {
- label: args.label.map(Cow::from),
+ label: label.map(Cow::from),
};
let compute_pass = wgpu_core::command::ComputePass::new(
@@ -242,45 +200,38 @@ pub fn op_webgpu_command_encoder_begin_compute_pass(
Ok(WebGpuResult::rid(rid))
}
-#[derive(Deserialize)]
-#[serde(rename_all = "camelCase")]
-pub struct CommandEncoderCopyBufferToBufferArgs {
+#[op]
+pub fn op_webgpu_command_encoder_copy_buffer_to_buffer(
+ state: &mut OpState,
command_encoder_rid: ResourceId,
source: ResourceId,
source_offset: u64,
destination: ResourceId,
destination_offset: u64,
size: u64,
-}
-
-#[op]
-pub fn op_webgpu_command_encoder_copy_buffer_to_buffer(
- state: &mut OpState,
- args: CommandEncoderCopyBufferToBufferArgs,
) -> Result<WebGpuResult, AnyError> {
let instance = state.borrow::<super::Instance>();
let command_encoder_resource = state
.resource_table
- .get::<WebGpuCommandEncoder>(args.command_encoder_rid)?;
+ .get::<WebGpuCommandEncoder>(command_encoder_rid)?;
let command_encoder = command_encoder_resource.0;
- let source_buffer_resource =
- state
- .resource_table
- .get::<super::buffer::WebGpuBuffer>(args.source)?;
+ let source_buffer_resource = state
+ .resource_table
+ .get::<super::buffer::WebGpuBuffer>(source)?;
let source_buffer = source_buffer_resource.0;
let destination_buffer_resource =
state
.resource_table
- .get::<super::buffer::WebGpuBuffer>(args.destination)?;
+ .get::<super::buffer::WebGpuBuffer>(destination)?;
let destination_buffer = destination_buffer_resource.0;
gfx_ok!(command_encoder => instance.command_encoder_copy_buffer_to_buffer(
command_encoder,
source_buffer,
- args.source_offset,
+ source_offset,
destination_buffer,
- args.destination_offset,
- args.size
+ destination_offset,
+ size
))
}
@@ -302,342 +253,277 @@ pub struct GpuImageCopyTexture {
pub aspect: wgpu_types::TextureAspect,
}
-#[derive(Deserialize)]
-#[serde(rename_all = "camelCase")]
-pub struct CommandEncoderCopyBufferToTextureArgs {
+#[op]
+pub fn op_webgpu_command_encoder_copy_buffer_to_texture(
+ state: &mut OpState,
command_encoder_rid: ResourceId,
source: GpuImageCopyBuffer,
destination: GpuImageCopyTexture,
copy_size: wgpu_types::Extent3d,
-}
-
-#[op]
-pub fn op_webgpu_command_encoder_copy_buffer_to_texture(
- state: &mut OpState,
- args: CommandEncoderCopyBufferToTextureArgs,
) -> Result<WebGpuResult, AnyError> {
let instance = state.borrow::<super::Instance>();
let command_encoder_resource = state
.resource_table
- .get::<WebGpuCommandEncoder>(args.command_encoder_rid)?;
+ .get::<WebGpuCommandEncoder>(command_encoder_rid)?;
let command_encoder = command_encoder_resource.0;
let source_buffer_resource =
state
.resource_table
- .get::<super::buffer::WebGpuBuffer>(args.source.buffer)?;
+ .get::<super::buffer::WebGpuBuffer>(source.buffer)?;
let destination_texture_resource =
state
.resource_table
- .get::<super::texture::WebGpuTexture>(args.destination.texture)?;
+ .get::<super::texture::WebGpuTexture>(destination.texture)?;
let source = wgpu_core::command::ImageCopyBuffer {
buffer: source_buffer_resource.0,
layout: wgpu_types::ImageDataLayout {
- offset: args.source.offset,
- bytes_per_row: NonZeroU32::new(args.source.bytes_per_row.unwrap_or(0)),
- rows_per_image: NonZeroU32::new(args.source.rows_per_image.unwrap_or(0)),
+ offset: source.offset,
+ bytes_per_row: NonZeroU32::new(source.bytes_per_row.unwrap_or(0)),
+ rows_per_image: NonZeroU32::new(source.rows_per_image.unwrap_or(0)),
},
};
let destination = wgpu_core::command::ImageCopyTexture {
texture: destination_texture_resource.0,
- mip_level: args.destination.mip_level,
- origin: args.destination.origin,
- aspect: args.destination.aspect,
+ mip_level: destination.mip_level,
+ origin: destination.origin,
+ aspect: destination.aspect,
};
gfx_ok!(command_encoder => instance.command_encoder_copy_buffer_to_texture(
command_encoder,
&source,
&destination,
- &args.copy_size
+ &copy_size
))
}
-#[derive(Deserialize)]
-#[serde(rename_all = "camelCase")]
-pub struct CommandEncoderCopyTextureToBufferArgs {
+#[op]
+pub fn op_webgpu_command_encoder_copy_texture_to_buffer(
+ state: &mut OpState,
command_encoder_rid: ResourceId,
source: GpuImageCopyTexture,
destination: GpuImageCopyBuffer,
copy_size: wgpu_types::Extent3d,
-}
-
-#[op]
-pub fn op_webgpu_command_encoder_copy_texture_to_buffer(
- state: &mut OpState,
- args: CommandEncoderCopyTextureToBufferArgs,
) -> Result<WebGpuResult, AnyError> {
let instance = state.borrow::<super::Instance>();
let command_encoder_resource = state
.resource_table
- .get::<WebGpuCommandEncoder>(args.command_encoder_rid)?;
+ .get::<WebGpuCommandEncoder>(command_encoder_rid)?;
let command_encoder = command_encoder_resource.0;
let source_texture_resource =
state
.resource_table
- .get::<super::texture::WebGpuTexture>(args.source.texture)?;
+ .get::<super::texture::WebGpuTexture>(source.texture)?;
let destination_buffer_resource =
state
.resource_table
- .get::<super::buffer::WebGpuBuffer>(args.destination.buffer)?;
+ .get::<super::buffer::WebGpuBuffer>(destination.buffer)?;
let source = wgpu_core::command::ImageCopyTexture {
texture: source_texture_resource.0,
- mip_level: args.source.mip_level,
- origin: args.source.origin,
- aspect: args.source.aspect,
+ mip_level: source.mip_level,
+ origin: source.origin,
+ aspect: source.aspect,
};
let destination = wgpu_core::command::ImageCopyBuffer {
buffer: destination_buffer_resource.0,
layout: wgpu_types::ImageDataLayout {
- offset: args.destination.offset,
- bytes_per_row: NonZeroU32::new(
- args.destination.bytes_per_row.unwrap_or(0),
- ),
- rows_per_image: NonZeroU32::new(
- args.destination.rows_per_image.unwrap_or(0),
- ),
+ offset: destination.offset,
+ bytes_per_row: NonZeroU32::new(destination.bytes_per_row.unwrap_or(0)),
+ rows_per_image: NonZeroU32::new(destination.rows_per_image.unwrap_or(0)),
},
};
gfx_ok!(command_encoder => instance.command_encoder_copy_texture_to_buffer(
command_encoder,
&source,
&destination,
- &args.copy_size
+ &copy_size
))
}
-#[derive(Deserialize)]
-#[serde(rename_all = "camelCase")]
-pub struct CommandEncoderCopyTextureToTextureArgs {
+#[op]
+pub fn op_webgpu_command_encoder_copy_texture_to_texture(
+ state: &mut OpState,
command_encoder_rid: ResourceId,
source: GpuImageCopyTexture,
destination: GpuImageCopyTexture,
copy_size: wgpu_types::Extent3d,
-}
-
-#[op]
-pub fn op_webgpu_command_encoder_copy_texture_to_texture(
- state: &mut OpState,
- args: CommandEncoderCopyTextureToTextureArgs,
) -> Result<WebGpuResult, AnyError> {
let instance = state.borrow::<super::Instance>();
let command_encoder_resource = state
.resource_table
- .get::<WebGpuCommandEncoder>(args.command_encoder_rid)?;
+ .get::<WebGpuCommandEncoder>(command_encoder_rid)?;
let command_encoder = command_encoder_resource.0;
let source_texture_resource =
state
.resource_table
- .get::<super::texture::WebGpuTexture>(args.source.texture)?;
+ .get::<super::texture::WebGpuTexture>(source.texture)?;
let destination_texture_resource =
state
.resource_table
- .get::<super::texture::WebGpuTexture>(args.destination.texture)?;
+ .get::<super::texture::WebGpuTexture>(destination.texture)?;
let source = wgpu_core::command::ImageCopyTexture {
texture: source_texture_resource.0,
- mip_level: args.source.mip_level,
- origin: args.source.origin,
- aspect: args.source.aspect,
+ mip_level: source.mip_level,
+ origin: source.origin,
+ aspect: source.aspect,
};
let destination = wgpu_core::command::ImageCopyTexture {
texture: destination_texture_resource.0,
- mip_level: args.destination.mip_level,
- origin: args.destination.origin,
- aspect: args.destination.aspect,
+ mip_level: destination.mip_level,
+ origin: destination.origin,
+ aspect: destination.aspect,
};
gfx_ok!(command_encoder => instance.command_encoder_copy_texture_to_texture(
command_encoder,
&source,
&destination,
- &args.copy_size
+ &copy_size
))
}
-#[derive(Deserialize)]
-#[serde(rename_all = "camelCase")]
-pub struct CommandEncoderClearBufferArgs {
- command_encoder_rid: u32,
- destination_rid: u32,
- destination_offset: u64,
- size: u64,
-}
-
#[op]
pub fn op_webgpu_command_encoder_clear_buffer(
state: &mut OpState,
- args: CommandEncoderClearBufferArgs,
+ command_encoder_rid: u32,
+ buffer_rid: u32,
+ offset: u64,
+ size: u64,
) -> Result<WebGpuResult, AnyError> {
let instance = state.borrow::<super::Instance>();
let command_encoder_resource = state
.resource_table
- .get::<WebGpuCommandEncoder>(args.command_encoder_rid)?;
+ .get::<WebGpuCommandEncoder>(command_encoder_rid)?;
let command_encoder = command_encoder_resource.0;
let destination_resource = state
.resource_table
- .get::<super::buffer::WebGpuBuffer>(args.destination_rid)?;
+ .get::<super::buffer::WebGpuBuffer>(buffer_rid)?;
gfx_ok!(command_encoder => instance.command_encoder_clear_buffer(
command_encoder,
destination_resource.0,
- args.destination_offset,
- std::num::NonZeroU64::new(args.size)
+ offset,
+ std::num::NonZeroU64::new(size)
))
}
-#[derive(Deserialize)]
-#[serde(rename_all = "camelCase")]
-pub struct CommandEncoderPushDebugGroupArgs {
- command_encoder_rid: ResourceId,
- group_label: String,
-}
-
#[op]
pub fn op_webgpu_command_encoder_push_debug_group(
state: &mut OpState,
- args: CommandEncoderPushDebugGroupArgs,
+ command_encoder_rid: ResourceId,
+ group_label: String,
) -> Result<WebGpuResult, AnyError> {
let instance = state.borrow::<super::Instance>();
let command_encoder_resource = state
.resource_table
- .get::<WebGpuCommandEncoder>(args.command_encoder_rid)?;
+ .get::<WebGpuCommandEncoder>(command_encoder_rid)?;
let command_encoder = command_encoder_resource.0;
- gfx_ok!(command_encoder => instance
- .command_encoder_push_debug_group(command_encoder, &args.group_label))
-}
-
-#[derive(Deserialize)]
-#[serde(rename_all = "camelCase")]
-pub struct CommandEncoderPopDebugGroupArgs {
- command_encoder_rid: ResourceId,
+ gfx_ok!(command_encoder => instance.command_encoder_push_debug_group(command_encoder, &group_label))
}
#[op]
pub fn op_webgpu_command_encoder_pop_debug_group(
state: &mut OpState,
- args: CommandEncoderPopDebugGroupArgs,
+ command_encoder_rid: ResourceId,
) -> Result<WebGpuResult, AnyError> {
let instance = state.borrow::<super::Instance>();
let command_encoder_resource = state
.resource_table
- .get::<WebGpuCommandEncoder>(args.command_encoder_rid)?;
+ .get::<WebGpuCommandEncoder>(command_encoder_rid)?;
let command_encoder = command_encoder_resource.0;
gfx_ok!(command_encoder => instance.command_encoder_pop_debug_group(command_encoder))
}
-#[derive(Deserialize)]
-#[serde(rename_all = "camelCase")]
-pub struct CommandEncoderInsertDebugMarkerArgs {
- command_encoder_rid: ResourceId,
- marker_label: String,
-}
-
#[op]
pub fn op_webgpu_command_encoder_insert_debug_marker(
state: &mut OpState,
- args: CommandEncoderInsertDebugMarkerArgs,
+ command_encoder_rid: ResourceId,
+ marker_label: String,
) -> Result<WebGpuResult, AnyError> {
let instance = state.borrow::<super::Instance>();
let command_encoder_resource = state
.resource_table
- .get::<WebGpuCommandEncoder>(args.command_encoder_rid)?;
+ .get::<WebGpuCommandEncoder>(command_encoder_rid)?;
let command_encoder = command_encoder_resource.0;
gfx_ok!(command_encoder => instance.command_encoder_insert_debug_marker(
command_encoder,
- &args.marker_label
+ &marker_label
))
}
-#[derive(Deserialize)]
-#[serde(rename_all = "camelCase")]
-pub struct CommandEncoderWriteTimestampArgs {
- command_encoder_rid: ResourceId,
- query_set: ResourceId,
- query_index: u32,
-}
-
#[op]
pub fn op_webgpu_command_encoder_write_timestamp(
state: &mut OpState,
- args: CommandEncoderWriteTimestampArgs,
+ command_encoder_rid: ResourceId,
+ query_set: ResourceId,
+ query_index: u32,
) -> Result<WebGpuResult, AnyError> {
let instance = state.borrow::<super::Instance>();
let command_encoder_resource = state
.resource_table
- .get::<WebGpuCommandEncoder>(args.command_encoder_rid)?;
+ .get::<WebGpuCommandEncoder>(command_encoder_rid)?;
let command_encoder = command_encoder_resource.0;
let query_set_resource = state
.resource_table
- .get::<super::WebGpuQuerySet>(args.query_set)?;
+ .get::<super::WebGpuQuerySet>(query_set)?;
gfx_ok!(command_encoder => instance.command_encoder_write_timestamp(
command_encoder,
query_set_resource.0,
- args.query_index
+ query_index
))
}
-#[derive(Deserialize)]
-#[serde(rename_all = "camelCase")]
-pub struct CommandEncoderResolveQuerySetArgs {
+#[op]
+pub fn op_webgpu_command_encoder_resolve_query_set(
+ state: &mut OpState,
command_encoder_rid: ResourceId,
query_set: ResourceId,
first_query: u32,
query_count: u32,
destination: ResourceId,
destination_offset: u64,
-}
-
-#[op]
-pub fn op_webgpu_command_encoder_resolve_query_set(
- state: &mut OpState,
- args: CommandEncoderResolveQuerySetArgs,
) -> Result<WebGpuResult, AnyError> {
let instance = state.borrow::<super::Instance>();
let command_encoder_resource = state
.resource_table
- .get::<WebGpuCommandEncoder>(args.command_encoder_rid)?;
+ .get::<WebGpuCommandEncoder>(command_encoder_rid)?;
let command_encoder = command_encoder_resource.0;
let query_set_resource = state
.resource_table
- .get::<super::WebGpuQuerySet>(args.query_set)?;
+ .get::<super::WebGpuQuerySet>(query_set)?;
let destination_resource = state
.resource_table
- .get::<super::buffer::WebGpuBuffer>(args.destination)?;
+ .get::<super::buffer::WebGpuBuffer>(destination)?;
gfx_ok!(command_encoder => instance.command_encoder_resolve_query_set(
command_encoder,
query_set_resource.0,
- args.first_query,
- args.query_count,
+ first_query,
+ query_count,
destination_resource.0,
- args.destination_offset
+ destination_offset
))
}
-#[derive(Deserialize)]
-#[serde(rename_all = "camelCase")]
-pub struct CommandEncoderFinishArgs {
- command_encoder_rid: ResourceId,
- label: Option<String>,
-}
-
#[op]
pub fn op_webgpu_command_encoder_finish(
state: &mut OpState,
- args: CommandEncoderFinishArgs,
+ command_encoder_rid: ResourceId,
+ label: Option<String>,
) -> Result<WebGpuResult, AnyError> {
let command_encoder_resource = state
.resource_table
- .take::<WebGpuCommandEncoder>(args.command_encoder_rid)?;
+ .take::<WebGpuCommandEncoder>(command_encoder_rid)?;
let command_encoder = command_encoder_resource.0;
let instance = state.borrow::<super::Instance>();
let descriptor = wgpu_types::CommandBufferDescriptor {
- label: args.label.map(Cow::from),
+ label: label.map(Cow::from),
};
gfx_put!(command_encoder => instance.command_encoder_finish(