emitGlslStages()
함수, 출력 분류
Emit both stages of one module, lowering and optimizing it once.
import { emitGlslStages } from 'typeshade'
시그니처, 설명, 예제는 커밋 26de7be8의 컴파일러 소스에서 그대로 가져온 영어 원문입니다.
구문
function emitGlslStages( m: ModuleDecl, opts?: GlslEmitOptions & { vertexEntry?: string; fragmentEntry?: string },): { vertex: string; fragment: string }매개변수
mModuleDeclthe module to emit.
opts선택 사항GlslEmitOptions & { vertexEntry?: string; fragmentEntry?: string }the
GlslEmitOptions, plusvertexEntryandfragmentEntry.
반환값
{ vertex: string; fragment: string }
the vertex and fragment sources, each #version 300 es first.
예외
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).
설명
The result is
identical to calling emitGlslModule(m, 'vertex') and emitGlslModule(m, 'fragment'),
at about half the cost, since the optimizer runs once for both stages. 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.
예제
예제
import { emitGlslStages } from 'typeshade'
const { vertex, fragment } = emitGlslStages(MODULE, { fragmentEntry: 'fs_pattern' })대상별 지원
| 대상 | 지원 | 비고 |
|---|---|---|
| WGSL (WebGPU) | 해당 없음 | |
| GLSL ES 3.00 (WebGL2) | 지원 | Writes GLSL ES 3.00 for WebGL2. |
| CPU 오라클 | 해당 없음 |
관련 가이드
함께 보기
소스
src/core/backends/glsl.ts, 2558행, 커밋 26de7be8 기준