emitGlslStages()
Function in Emit
Emit both stages of one module, lowering and optimizing it once.
import { emitGlslStages } from 'typeshade'
The signature, the description and the examples come from the compiler's own source at commit af54ddad5.
Syntax
function emitGlslStages( m: ModuleDecl, opts?: GlslEmitOptions & { vertexEntry?: string; fragmentEntry?: string },): { vertex: string; fragment: string }Parameters
mModuleDeclthe module to emit.
optsoptionalGlslEmitOptions & { vertexEntry?: string; fragmentEntry?: string }the
GlslEmitOptions, plusvertexEntryandfragmentEntry.
Return value
{ vertex: string; fragment: string }
the vertex and fragment sources, each #version 300 es first.
Exceptions
Errorthe same errors as
emitGlslModule.UnsupportedFeatureErrorGLSL allows one main() per stage, so a module with two fragment entries needs fragmentEntry to say which one becomes main(); the other entries are left out of that stage’s source, and with none named such a stage throws UnsupportedFeatureError (SD0030).
SD0030GLSL allows one main() per stage, so a module with two fragment entries needs fragmentEntry to say which one becomes main(); the other entries are left out of that stage’s source, and with none named such a stage throws UnsupportedFeatureError (SD0030).
Description
The result is
the same stage sources as separate emitGlslModule calls, while the optimizer runs once. The pair also checks that one texture uses one sampler across the selected stages:
a linked GLSL program shares each combined texture uniform. Use it from a host that
creates a pipeline, which always needs both.
opts.vertexEntry and opts.fragmentEntry name the entry to emit for each stage, for
a module that declares several entries of one stage. GLSL allows one main() per
stage, so a module with two fragment entries needs fragmentEntry to say which one
becomes main(); the other entries are left out of that stage’s source, and with none
named such a stage throws UnsupportedFeatureError (SD0030). The output
does not depend on which other entries the module carries, because every optimizer
pass works on one function at a time.
Examples
Example
import { emitGlslStages } from 'typeshade'
const { vertex, fragment } = emitGlslStages(MODULE, { fragmentEntry: 'fs_pattern' })Targets
| Target | Support | Notes |
|---|---|---|
| WGSL (WebGPU) | Does not apply | |
| GLSL ES 3.00 (WebGL2) | Supported | Writes GLSL ES 3.00 for WebGL2. |
| CPU oracle | Does not apply |
In the guide
See also
Source
src/core/backends/glsl.ts, line 210, at commit af54ddad5