emitConst()
Function in Emit
Emit one ConstDecl as a WGSL const line, without the surrounding module.
import { emitConst } from 'typeshade'
The signature, the description and the examples come from the compiler's own source at commit 26de7be8.
Syntax
const emitConst: (c: ConstDecl) => stringParameters
Return value
string
Description
Use it to compose a shader out of separately authored pieces: emit the constants once,
keep the string, and concatenate it with the rest of the source. The line is identical to
the one emitModule writes for the same declaration, so a piece emitted here and a
module emitted there agree, which is what makes concatenation safe.
The declaration is written as given: the passes emitModule runs before writing a
module do not run here, so pass a declaration that needs none of them. The caveat on
emitFuncs applies equally.
Targets
| Target | Support | Notes |
|---|---|---|
| WGSL (WebGPU) | Supported | Writes WGSL for WebGPU. |
| GLSL ES 3.00 (WebGL2) | Does not apply | |
| CPU oracle | Does not apply |
See also
Source
src/core/backends/wgsl.ts, line 503, at commit 26de7be8