A WGSL parser and reflection library for JavaScript/TypeScript that analyzes shader structure, bind groups, and resource layouts.
wgsl_reflect is a WebGPU Shading Language (WGSL) parser and reflection library for JavaScript and TypeScript. It parses WGSL shader code to extract detailed information about the shader's structure, including bind groups, resource bindings, uniform buffers, and type definitions. This enables developers to programmatically analyze and manage shader resources at runtime.
WebGPU developers working with WGSL shaders who need to introspect shader structure, generate bind group layouts dynamically, or build tools for shader analysis and debugging.
It provides a comprehensive, type-safe reflection API specifically for WGSL, eliminating the need for manual shader parsing and enabling dynamic resource management and validation in WebGPU applications.
A WebGPU Shading Language parser and reflection library for Javascript.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Parses WGSL shader code to extract the abstract syntax tree and all structural elements, as demonstrated by the detailed WgslReflect class properties for uniforms, storage, structs, and entry points.
Computes bind group layouts directly from shader code using methods like getBindGroups(), simplifying WebGPU API integration by organizing resources by group and binding.
Provides in-depth analysis of structs, arrays, and templates with member offsets, sizes, and alignments, evident in the StructInfo and MemberInfo classes for uniform buffer management.
Analyzes connections between resources, such as linking samplers to textures via the relations property in VariableInfo, aiding in shader debugging and validation.
Only supports WGSL shaders, making it unsuitable for projects that require reflection on other shading languages like GLSL or HLSL, limiting cross-platform compatibility.
Parsing shaders at runtime can introduce performance bottlenecks, especially for complex shaders, which may not be ideal for real-time graphics applications with strict frame budgets.
As WGSL is still under active development, changes in the language specification could necessitate frequent library updates, potentially leading to breaking changes or lagging feature support.