Expand description
WebGL2 Shader Compiler and Emulator
A complete toolchain for compiling GLSL shaders to WebAssembly with DWARF debugging, including a software rasterizer for shader emulation and TypeScript harness generation.
§Modules
naga_wasm_backend- Compile Naga IR to WASM with DWARF debug informationwasm_gl_emu- Software rasterizer and WASM shader runtimeglsl_introspection- GLSL parser with annotation extractionjs_codegen- TypeScript harness code generator
Re-exports§
pub use glsl_introspection::ResourceManifest;pub use js_codegen::generate_harness;pub use naga_wasm_backend::BackendError;pub use naga_wasm_backend::WasmBackend;pub use naga_wasm_backend::WasmBackendConfig;pub use naga_wasm_backend::WasmModule;pub use wasm_gl_emu::RuntimeError;
Modules§
- glsl_
introspection - GLSL Annotation Parser and Resource Manifest Generator
- js_
codegen - TypeScript/JavaScript Harness Code Generator
- naga_
wasm_ backend - Naga IR to WebAssembly Backend with DWARF Debug Information
- wasm_
gl_ emu - WebGL2 Software Rasterizer and WASM Shader Runtime
- webgl2_
context
Functions§
- js_
execute_ shader - js_log
- js_
print - wasm_
alloc - Allocate memory from WASM linear memory. Returns pointer (0 on failure; sets last_error).
- wasm_
create_ context - Create a new WebGL2 context. Returns context handle (0 on failure; sets last_error).
- wasm_
ctx_ active_ texture - Set the active texture unit.
- wasm_
ctx_ attach_ shader - Attach a shader to a program.
- wasm_
ctx_ bind_ attrib_ location - Bind attribute location.
- wasm_
ctx_ bind_ buffer - Bind a buffer.
- wasm_
ctx_ bind_ framebuffer - Bind a framebuffer. Returns errno.
- wasm_
ctx_ bind_ renderbuffer - wasm_
ctx_ bind_ texture - Bind a texture. Returns errno.
- wasm_
ctx_ bind_ vertex_ array - wasm_
ctx_ buffer_ data - Upload data to the bound buffer.
- wasm_
ctx_ buffer_ sub_ data - Update a subset of the bound buffer’s data.
- wasm_
ctx_ clear - Clear buffers.
- wasm_
ctx_ clear_ color - Set the clear color.
- wasm_
ctx_ compile_ shader - Compile a shader.
- wasm_
ctx_ create_ buffer - Create a buffer.
- wasm_
ctx_ create_ framebuffer - Create a framebuffer in the given context. Returns framebuffer handle (0 on failure).
- wasm_
ctx_ create_ program - Create a program.
- wasm_
ctx_ create_ renderbuffer - wasm_
ctx_ create_ shader - Create a shader.
- wasm_
ctx_ create_ texture - Create a texture in the given context. Returns texture handle (0 on failure).
- wasm_
ctx_ create_ vertex_ array - wasm_
ctx_ delete_ buffer - Delete a buffer.
- wasm_
ctx_ delete_ framebuffer - Delete a framebuffer. Returns errno.
- wasm_
ctx_ delete_ program - Delete a program.
- wasm_
ctx_ delete_ renderbuffer - wasm_
ctx_ delete_ shader - Delete a shader.
- wasm_
ctx_ delete_ texture - Delete a texture. Returns errno.
- wasm_
ctx_ delete_ vertex_ array - wasm_
ctx_ depth_ func - Set the depth function.
- wasm_
ctx_ disable - Disable a capability.
- wasm_
ctx_ disable_ vertex_ attrib_ array - Disable vertex attribute array.
- wasm_
ctx_ draw_ arrays - Draw arrays.
- wasm_
ctx_ draw_ arrays_ instanced - Draw arrays instanced.
- wasm_
ctx_ draw_ elements - Draw elements.
- wasm_
ctx_ draw_ elements_ instanced - Draw elements instanced.
- wasm_
ctx_ enable - Enable a capability.
- wasm_
ctx_ enable_ vertex_ attrib_ array - Enable vertex attribute array.
- wasm_
ctx_ framebuffer_ renderbuffer - wasm_
ctx_ framebuffer_ texture2d - Attach a texture to the bound framebuffer. Returns errno.
- wasm_
ctx_ get_ attrib_ location - Get attribute location.
- wasm_
ctx_ get_ buffer_ parameter - Get buffer parameter.
- wasm_
ctx_ get_ error - Get the last GL error.
- wasm_
ctx_ get_ parameter_ v - Get a parameter (vector version).
- wasm_
ctx_ get_ program_ info_ log - Get program info log.
- wasm_
ctx_ get_ program_ parameter - Get program parameter.
- wasm_
ctx_ get_ program_ wasm - Get the generated WASM for a program’s shader.
- wasm_
ctx_ get_ program_ wasm_ len - Get the length of the generated WASM for a program’s shader.
- wasm_
ctx_ get_ shader_ info_ log - Get shader info log.
- wasm_
ctx_ get_ shader_ parameter - Get shader parameter.
- wasm_
ctx_ get_ uniform_ location - Get uniform location.
- wasm_
ctx_ is_ vertex_ array - wasm_
ctx_ link_ program - Link a program.
- wasm_
ctx_ read_ pixels - Read pixels from the bound framebuffer into dest_ptr. dest_ptr/dest_len point to RGBA u8 buffer in WASM linear memory. Returns errno.
- wasm_
ctx_ renderbuffer_ storage - wasm_
ctx_ scissor - Set the scissor box.
- wasm_
ctx_ set_ verbosity - Set verbosity level.
- wasm_
ctx_ shader_ source - Set shader source.
- wasm_
ctx_ tex_ image_ 2d - Upload pixel data to a texture. ptr/len point to RGBA u8 pixel data in WASM linear memory. Returns errno.
- wasm_
ctx_ tex_ parameter_ i - Set texture parameters. Returns errno.
- wasm_
ctx_ uniform1f - Set uniform 1f.
- wasm_
ctx_ uniform1i - Set uniform 1i.
- wasm_
ctx_ uniform2f - Set uniform 2f.
- wasm_
ctx_ uniform3f - Set uniform 3f.
- wasm_
ctx_ uniform4f - Set uniform 4f.
- wasm_
ctx_ uniform_ matrix_ 4fv - Set uniform matrix 4fv.
- wasm_
ctx_ use_ program - Use a program.
- wasm_
ctx_ vertex_ attrib1f - Set vertex attribute default value (1f).
- wasm_
ctx_ vertex_ attrib2f - Set vertex attribute default value (2f).
- wasm_
ctx_ vertex_ attrib3f - Set vertex attribute default value (3f).
- wasm_
ctx_ vertex_ attrib4f - Set vertex attribute default value (4f).
- wasm_
ctx_ vertex_ attrib_ divisor - Vertex attribute divisor.
- wasm_
ctx_ vertex_ attrib_ pointer - Vertex attribute pointer.
- wasm_
ctx_ viewport - Set the viewport.
- wasm_
destroy_ context - Destroy a WebGL2 context by handle. Returns errno (0 on success).
- wasm_
free - Free memory allocated by wasm_alloc. Returns errno (0 on success).
- wasm_
last_ error_ len - Get length of last error message in bytes.
- wasm_
last_ error_ ptr - Get pointer to last error message (UTF-8).