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

Initial framework for compute shaders on WebGPU #5757

Merged
merged 2 commits into from Oct 17, 2023
Merged

Conversation

mvaligursky
Copy link
Contributor

@mvaligursky mvaligursky commented Oct 16, 2023

Initial framework, allowing creation and dispatch of WebGPU computer shaders. Note that support for passing data in / out of the compute shader is not yet supported.

All API is currently private, but expected public API:

  • Shader options object passed to constructor accepts compute shader source code
  • Compute - new class wrapping an instance of the compute shader along with its parameters (buffers, textures)

Example of its use:

const shader = new Shader(device, {
    name: 'ComputeShader',
    shaderLanguage: SHADERLANGUAGE_WGSL,
    cshader: `
        @compute @workgroup_size(8, 8)
        fn main(@builtin(global_invocation_id) global_id : vec3u) {
        }
    `
});

const compute = new Compute(device, shader);
compute.dispatch(4);

src/core/constants.js Outdated Show resolved Hide resolved
Co-authored-by: Donovan Hutchence <slimbuck7@gmail.com>
@mvaligursky mvaligursky merged commit b08d517 into main Oct 17, 2023
7 checks passed
@mvaligursky mvaligursky deleted the mv-webgpu-compute branch October 17, 2023 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: graphics Graphics related issue feature request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants