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

Reified references to WESL elements #51

Open
mighdoll opened this issue Oct 4, 2024 · 0 comments
Open

Reified references to WESL elements #51

mighdoll opened this issue Oct 4, 2024 · 0 comments

Comments

@mighdoll
Copy link
Contributor

mighdoll commented Oct 4, 2024

In order to enable host directed linking in #48, host code needs to refer specific WGSL/WESL elements like fn elements in order to select them for use in linking. e.g. #48 suggested the following TypeScript code:

import { getVertColor } from "./shader/root.wgsl"; // get TypeScript reference to `@link fn` element
import { randomColor } from "./shader/colorUtil.wgsl"; // get TypeScript reference to `fn` element

const linker = new Linker();
linker.link({links: {getVertColor: randomColor}});

The idea is provide TypesScript handles to the fn elements so that the host application can control what to link. A tool would need to parse the WESL code and generate some TypeScript or Rust code. Note that there are three scenarios for generating the reified references: local WESL strings, local WESL files, library WESL files. Some care with issues like conditional compilation will be required.

The generated metadata could include type information about the WESL elements, potentially enabling TypeScript or Rust applications to TypeCheck host directed link() options either with static TypeScript/Rust types or with dynamic validation in the linker.

The operation of parsing shader code and generating TypeScript/Rust metadata is similar to what a shader reflection tool would do, but specialized for the purpose of linking and parsing unlinked WESL modules rather than complete shaders.

Reified references to WESL elements provides a nice DX for #48, but requires signficant tooling. Less elegantly, I suppose we could expect the user to supply strings to identify elements for host controlled linking, rather than reifying references.

linker.link({links: {"./shader/root/getVertColor": "./shader/colorUtil/randomColor"}});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

1 participant