CompileResult
인터페이스, 작성 분류
What compile() returns.
import type { CompileResult } from 'typeshade'
시그니처, 설명, 예제는 커밋 c66579bf의 컴파일러 소스에서 그대로 가져온 영어 원문입니다.
구문
interface CompileResult { readonly diagnostics: readonly TsCompilerDiagnostic[]; readonly module: ModuleDecl; readonly wgsl?: string; readonly glsl?: { readonly vertex: string; readonly fragment: string }; readonly determinism: readonly DeterminismEntry[]; readonly eval: (name: string, args?: readonly unknown[]) => unknown; readonly console?: ConsoleLog;}설명
The one rule behind every optional field: shader text and a
runnable oracle exist only for a program that compiled with no error diagnostic. A caller
that reads wgsl without checking diagnostics gets undefined, never text for a program
that did not compile.
인스턴스 속성
diagnostics읽기 전용readonly TsCompilerDiagnostic[]Every diagnostic the front end and the backends produced, in the order they were found. A
"use typeshade"-less file has exactly one,TS8001(MISSING_DIRECTIVE); a parse error has onlyTS8030(SYNTAX) entries; a backend that threw on a program the front end accepted adds oneTS8015(BACKEND) entry anchored on the file’s first statement: anerrorwhen the WGSL emitter threw, awarningwhen only the GLSL emitter threw on a vertex+fragment module (a compute entry next to the render pair, a storage binding the GLSL emulation cannot spell). A program with noerrorentry compiled.module읽기 전용ModuleDeclThe lowered IR module: the consts, structs, bindings and functions the front end built. Always present. When
diagnosticshas an error the module is partial (the front end stops lowering a declaration at its first error and may drop it), so it is for inspection and diagnostics tooling, not for emitting.wgsl선택 사항읽기 전용stringThe module’s WGSL.
undefinedwhen any diagnostic has categoryerror, including aBACKENDerror from a WGSL emitter that threw. Present otherwise, even for a module with no functions (a file of consts or structs emits their declarations), and kept when only the GLSL emitter failed: the WGSL is the program, GLSL a second target of it.glsl선택 사항읽기 전용{ readonly vertex: string; readonly fragment: string }The module’s GLSL ES 3.00 vertex and fragment programs. Present when no diagnostic has category
errorand the GLSL emitter took the module; a module with only one render stage still gets both programs (the missing stage is a header-only program). A module the GLSL backend refuses getsundefinedhere whilewgslis still present: silently for a compute-only module, which GLSL ES 3.00 has no stage for, and with the throw recorded as aBACKENDwarning for a module with a@vertexor@fragmententry.determinism읽기 전용readonly DeterminismEntry[]The operations in
modulewhose result may differ by driver: a builtin WGSL §15.7.4 gives a ULP or absolute bound (sin,exp,atan2,/), one inherited from a formula the driver may reassociate or fuse (pow,mix,fma,fract, the matrix products), a derivative, a filtered texture read or gather, an operation the GLSL ES 3.00 spelling may answer differently (ldexp, thepackbuiltins), and every emulatedf64arithmetic operator and bounded builtin, each with the spec’s bound in words, its count and where it occurs. Empty when every operation has one answer, so a GPU result and the CPU oracle can differ only by the oracle’s own rounding. Computed on the front end’s IR even whendiagnosticshas an error, since a partial module still says what it uses. SeedeterminismReport.eval읽기 전용(name: string, args?: readonly unknown[]) => unknownRun one function of the module on the CPU oracle:
eval('fs')calls the fragment entry with no arguments,eval('add', [1, 2])a helper with two. Whendiagnosticshas an error, every call throws anErrornaming the first error diagnostic (file, line and message), so a host that ignoresdiagnosticscannot run a broken shader on the oracle. It also throws for a function name the module does not have.console선택 사항읽기 전용ConsoleLogWhere the WGSL records its
consolecalls and what each entry of the buffer means, underconsole: 'gpu': the slot of the_consolestorage buffer and the site tabledecodeConsolereads.undefinedwhen the option is'cpu', when the module did not compile, or when no call is recorded. Surface §66.
함께 보기
소스
src/compiler/ts/compile.ts, 20행, 커밋 c66579bf 기준