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

vite plugin for WESL #40

Open
mighdoll opened this issue Nov 21, 2024 · 0 comments
Open

vite plugin for WESL #40

mighdoll opened this issue Nov 21, 2024 · 0 comments

Comments

@mighdoll
Copy link
Contributor

We've floated various ideas for what a vite plugin might do. Let's prototype some of them to explore what's possible. Here are a few ideas:

Produce WGSL Reflection info

Use the linker to parse the source code and produce some TypeScript descriptors of the WGSL code. Things like the names of entry points, and the shape of certain struct elements would be useful for to have in TypeScript. Consider whether to imitate wgsl_reflect format in reporting.

Inject Structs into WESL

Convert some TypeScript structs into their equivalent WGSL structs and generate a WGSL file that WESL users can import.

Produce Auto-Layout

Parse WGSL and generate a GPUPipelineLayout as requested by the WebGPU team. See notes and #4957

Collect WGSL Files

Currently the linker expects that the user collect a set of named shader strings into a Record and pass that Record to the linker. But the list of shader files can be found elsewhere, probably wesl.toml will have the same glob search pattern (so language servers can find the files).

For example, the user might do something like this to collect the shader strings in the common case that they're using vite as a bundler:

const wgsl = import.meta.glob("./shaders/*.wgsl", {
  query: "?raw",
  eager: true,
  import: "default",
});

Can a vite plugin read wesl.toml and inject the shader source Record into the .js. That would make this code unnecessary and the programmer wouldn't have to maintain duplicate glob search strings in two locations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Unprioritized
Development

No branches or pull requests

1 participant