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

Rename dispatch -> dispatch_workgroups #2619

Merged
merged 1 commit into from
Apr 21, 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
12 changes: 6 additions & 6 deletions deno_webgpu/01_webgpu.js
Original file line number Diff line number Diff line change
Expand Up @@ -4213,9 +4213,9 @@
* @param {number} workgroupCountY
* @param {number} workgroupCountZ
*/
dispatch(workgroupCountX, workgroupCountY = 1, workgroupCountZ = 1) {
dispatchWorkgroups(workgroupCountX, workgroupCountY = 1, workgroupCountZ = 1) {
webidl.assertBranded(this, GPUComputePassEncoderPrototype);
const prefix = "Failed to execute 'dispatch' on 'GPUComputePassEncoder'";
const prefix = "Failed to execute 'dispatchWorkgroups' on 'GPUComputePassEncoder'";
webidl.requiredArguments(arguments.length, 1, { prefix });
workgroupCountX = webidl.converters.GPUSize32(workgroupCountX, {
prefix,
Expand All @@ -4239,7 +4239,7 @@
});
const computePassRid = assertResource(this, { prefix, context: "this" });
core.opSync(
"op_webgpu_compute_pass_dispatch",
"op_webgpu_compute_pass_dispatch_workgroups",
computePassRid,
workgroupCountX,
workgroupCountY,
Expand All @@ -4251,10 +4251,10 @@
* @param {GPUBuffer} indirectBuffer
* @param {number} indirectOffset
*/
dispatchIndirect(indirectBuffer, indirectOffset) {
dispatchWorkgroupsIndirect(indirectBuffer, indirectOffset) {
webidl.assertBranded(this, GPUComputePassEncoderPrototype);
const prefix =
"Failed to execute 'dispatchIndirect' on 'GPUComputePassEncoder'";
"Failed to execute 'dispatchWorkgroupsIndirect' on 'GPUComputePassEncoder'";
webidl.requiredArguments(arguments.length, 2, { prefix });
indirectBuffer = webidl.converters.GPUBuffer(indirectBuffer, {
prefix,
Expand Down Expand Up @@ -4283,7 +4283,7 @@
selfContext: "this",
});
core.opSync(
"op_webgpu_compute_pass_dispatch_indirect",
"op_webgpu_compute_pass_dispatch_workgroups_indirect",
computePassRid,
indirectBufferRid,
indirectOffset,
Expand Down
8 changes: 4 additions & 4 deletions deno_webgpu/src/compute_pass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub fn op_webgpu_compute_pass_set_pipeline(
}

#[op]
pub fn op_webgpu_compute_pass_dispatch(
pub fn op_webgpu_compute_pass_dispatch_workgroups(
state: &mut OpState,
compute_pass_rid: ResourceId,
x: u32,
Expand All @@ -51,7 +51,7 @@ pub fn op_webgpu_compute_pass_dispatch(
.resource_table
.get::<WebGpuComputePass>(compute_pass_rid)?;

wgpu_core::command::compute_ffi::wgpu_compute_pass_dispatch(
wgpu_core::command::compute_ffi::wgpu_compute_pass_dispatch_workgroups(
&mut compute_pass_resource.0.borrow_mut(),
x,
y,
Expand All @@ -62,7 +62,7 @@ pub fn op_webgpu_compute_pass_dispatch(
}

#[op]
pub fn op_webgpu_compute_pass_dispatch_indirect(
pub fn op_webgpu_compute_pass_dispatch_workgroups_indirect(
state: &mut OpState,
compute_pass_rid: ResourceId,
indirect_buffer: ResourceId,
Expand All @@ -75,7 +75,7 @@ pub fn op_webgpu_compute_pass_dispatch_indirect(
.resource_table
.get::<WebGpuComputePass>(compute_pass_rid)?;

wgpu_core::command::compute_ffi::wgpu_compute_pass_dispatch_indirect(
wgpu_core::command::compute_ffi::wgpu_compute_pass_dispatch_workgroups_indirect(
&mut compute_pass_resource.0.borrow_mut(),
buffer_resource.0,
indirect_offset,
Expand Down
4 changes: 2 additions & 2 deletions deno_webgpu/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -575,8 +575,8 @@ fn declare_webgpu_ops() -> Vec<deno_core::OpDecl> {
render_pass::op_webgpu_render_pass_draw_indexed_indirect::decl(),
// compute_pass
compute_pass::op_webgpu_compute_pass_set_pipeline::decl(),
compute_pass::op_webgpu_compute_pass_dispatch::decl(),
compute_pass::op_webgpu_compute_pass_dispatch_indirect::decl(),
compute_pass::op_webgpu_compute_pass_dispatch_workgroups::decl(),
compute_pass::op_webgpu_compute_pass_dispatch_workgroups_indirect::decl(),
compute_pass::op_webgpu_compute_pass_begin_pipeline_statistics_query::decl(),
compute_pass::op_webgpu_compute_pass_end_pipeline_statistics_query::decl(),
compute_pass::op_webgpu_compute_pass_write_timestamp::decl(),
Expand Down
4 changes: 2 additions & 2 deletions deno_webgpu/webgpu.idl
Original file line number Diff line number Diff line change
Expand Up @@ -846,8 +846,8 @@ interface mixin GPUDebugCommandsMixin {
[Exposed=(Window, DedicatedWorker), SecureContext]
interface GPUComputePassEncoder {
undefined setPipeline(GPUComputePipeline pipeline);
undefined dispatch(GPUSize32 workgroupCountX, optional GPUSize32 workgroupCountY = 1, optional GPUSize32 workgroupCountZ = 1);
undefined dispatchIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset);
undefined dispatchWorkgroups(GPUSize32 workgroupCountX, optional GPUSize32 workgroupCountY = 1, optional GPUSize32 workgroupCountZ = 1);
undefined dispatchWorkgroupsIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset);

undefined beginPipelineStatisticsQuery(GPUQuerySet querySet, GPUSize32 queryIndex);
undefined endPipelineStatisticsQuery();
Expand Down
4 changes: 2 additions & 2 deletions wgpu-core/src/command/compute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ pub mod compute_ffi {
}

#[no_mangle]
pub extern "C" fn wgpu_compute_pass_dispatch(
pub extern "C" fn wgpu_compute_pass_dispatch_workgroups(
pass: &mut ComputePass,
groups_x: u32,
groups_y: u32,
Expand All @@ -824,7 +824,7 @@ pub mod compute_ffi {
}

#[no_mangle]
pub extern "C" fn wgpu_compute_pass_dispatch_indirect(
pub extern "C" fn wgpu_compute_pass_dispatch_workgroups_indirect(
pass: &mut ComputePass,
buffer_id: id::BufferId,
offset: BufferAddress,
Expand Down
2 changes: 1 addition & 1 deletion wgpu/examples/boids/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ impl framework::Example for Example {
command_encoder.begin_compute_pass(&wgpu::ComputePassDescriptor { label: None });
cpass.set_pipeline(&self.compute_pipeline);
cpass.set_bind_group(0, &self.particle_bind_groups[self.frame_num % 2], &[]);
cpass.dispatch(self.work_group_count, 1, 1);
cpass.dispatch_workgroups(self.work_group_count, 1, 1);
}
command_encoder.pop_debug_group();

Expand Down
2 changes: 1 addition & 1 deletion wgpu/examples/hello-compute/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ async fn execute_gpu_inner(
cpass.set_pipeline(&compute_pipeline);
cpass.set_bind_group(0, &bind_group, &[]);
cpass.insert_debug_marker("compute collatz iterations");
cpass.dispatch(numbers.len() as u32, 1, 1); // Number of cells to run, the (x,y,z) size of item being processed
cpass.dispatch_workgroups(numbers.len() as u32, 1, 1); // Number of cells to run, the (x,y,z) size of item being processed
}
// Sets adds copy operation to command encoder.
// Will copy data from storage buffer on GPU to staging buffer on CPU.
Expand Down
12 changes: 8 additions & 4 deletions wgpu/src/backend/direct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,15 +321,19 @@ mod pass_impl {
wgpu_compute_pass_end_pipeline_statistics_query(self)
}

fn dispatch(&mut self, x: u32, y: u32, z: u32) {
wgpu_compute_pass_dispatch(self, x, y, z)
fn dispatch_workgroups(&mut self, x: u32, y: u32, z: u32) {
wgpu_compute_pass_dispatch_workgroups(self, x, y, z)
}
fn dispatch_indirect(
fn dispatch_workgroups_indirect(
&mut self,
indirect_buffer: &super::Buffer,
indirect_offset: wgt::BufferAddress,
) {
wgpu_compute_pass_dispatch_indirect(self, indirect_buffer.id, indirect_offset)
wgpu_compute_pass_dispatch_workgroups_indirect(
self,
indirect_buffer.id,
indirect_offset,
)
}
}

Expand Down
4 changes: 2 additions & 2 deletions wgpu/src/backend/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@ impl crate::ComputePassInner<Context> for ComputePass {
// self.0.pop_debug_group();
}

fn dispatch(&mut self, x: u32, y: u32, z: u32) {
fn dispatch_workgroups(&mut self, x: u32, y: u32, z: u32) {
self.0.dispatch_with_y_and_z(x, y, z);
}
fn dispatch_indirect(
fn dispatch_workgroups_indirect(
&mut self,
indirect_buffer: &Sendable<web_sys::GpuBuffer>,
indirect_offset: wgt::BufferAddress,
Expand Down
16 changes: 10 additions & 6 deletions wgpu/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ trait ComputePassInner<Ctx: Context> {
fn write_timestamp(&mut self, query_set: &Ctx::QuerySetId, query_index: u32);
fn begin_pipeline_statistics_query(&mut self, query_set: &Ctx::QuerySetId, query_index: u32);
fn end_pipeline_statistics_query(&mut self);
fn dispatch(&mut self, x: u32, y: u32, z: u32);
fn dispatch_indirect(
fn dispatch_workgroups(&mut self, x: u32, y: u32, z: u32);
fn dispatch_workgroups_indirect(
&mut self,
indirect_buffer: &Ctx::BufferId,
indirect_offset: BufferAddress,
Expand Down Expand Up @@ -2881,19 +2881,23 @@ impl<'a> ComputePass<'a> {
/// Dispatches compute work operations.
///
/// `x`, `y` and `z` denote the number of work groups to dispatch in each dimension.
pub fn dispatch(&mut self, x: u32, y: u32, z: u32) {
ComputePassInner::dispatch(&mut self.id, x, y, z);
pub fn dispatch_workgroups(&mut self, x: u32, y: u32, z: u32) {
ComputePassInner::dispatch_workgroups(&mut self.id, x, y, z);
}

/// Dispatches compute work operations, based on the contents of the `indirect_buffer`.
///
/// The structure expected in `indirect_buffer` must conform to [`DispatchIndirect`](crate::util::DispatchIndirect).
pub fn dispatch_indirect(
pub fn dispatch_workgroups_indirect(
&mut self,
indirect_buffer: &'a Buffer,
indirect_offset: BufferAddress,
) {
ComputePassInner::dispatch_indirect(&mut self.id, &indirect_buffer.id, indirect_offset);
ComputePassInner::dispatch_workgroups_indirect(
&mut self.id,
&indirect_buffer.id,
indirect_offset,
);
}
}

Expand Down
2 changes: 1 addition & 1 deletion wgpu/src/util/indirect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl DrawIndexedIndirect {
}
}

/// The structure expected in `indirect_buffer` for [`ComputePass::dispatch_indirect`](crate::ComputePass::dispatch_indirect).
/// The structure expected in `indirect_buffer` for [`ComputePass::dispatch_workgroups_indirect`](crate::ComputePass::dispatch_workgroups_indirect).
///
/// x, y and z denote the number of work groups to dispatch in each dimension.
#[repr(C)]
Expand Down