Skip to content

Add compute_workgroups example#801

Merged
almarklein merged 3 commits into
pygfx:mainfrom
mrinalchaturvedi27:workgroup-exp
Apr 13, 2026
Merged

Add compute_workgroups example#801
almarklein merged 3 commits into
pygfx:mainfrom
mrinalchaturvedi27:workgroup-exp

Conversation

@mrinalchaturvedi27

@mrinalchaturvedi27 mrinalchaturvedi27 commented Mar 2, 2026

Copy link
Copy Markdown
Contributor

This PR adds a compute_workgroups.py example demonstrating GPU workgroups and invocation IDs.
While reviewing the WGPU documentation and the Rust hello_workgroups example, I noticed that wgpu-py does not include a focused example for workgroups.
This example provides a minimal compute shader that writes global_invocation_id, local_invocation_id, and workgroup_id into a storage buffer so the relationship between them can be inspected.

Copilot AI review requested due to automatic review settings March 2, 2026 19:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new compute_workgroups.py example to the examples/ suite to help users understand how compute workgroups relate to invocation IDs in wgpu-py, by writing invocation/workgroup identifiers into a storage buffer and printing/verifying the mapping on the CPU.

Changes:

  • Add a minimal WGSL compute shader that records global_invocation_id, local_invocation_id, and workgroup_id (currently x-components) into a storage buffer.
  • Add a Python driver that dispatches workgroups, reads back the buffer, prints a table, and validates the expected ID relationships.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread examples/compute_workgroups.py
Comment thread examples/compute_workgroups.py Outdated
Comment thread examples/compute_workgroups.py
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@mrinalchaturvedi27

Copy link
Copy Markdown
Contributor Author

Hi @Korijn @almarklein, just checking in on this PR. Whenever you get a chance, could you please take a look? Happy to make any changes if needed. Thanks!

@almarklein almarklein left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@almarklein almarklein merged commit f24340d into pygfx:main Apr 13, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants