You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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` elementimport{randomColor}from"./shader/colorUtil.wgsl";// get TypeScript reference to `fn` elementconstlinker=newLinker();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.
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: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.
The text was updated successfully, but these errors were encountered: