linkVariants()
함수, 배리언트 분류
Emit, compile and link every variant of a family on a real WebGL2 context.
import { linkVariants } from 'typeshade'
시그니처, 설명, 예제는 커밋 c66579bf의 컴파일러 소스에서 그대로 가져온 영어 원문입니다.
구문
function linkVariants<A extends Record<string, readonly unknown[]>>( gl: GlLinker, family: VariantFamily<A>, opts?: EmitOptions,): readonly VariantLinkResult[]매개변수
glGlLinkera WebGL2 context, or anything satisfying
GlLinker.familyVariantFamily<A>the family to enumerate; every key in
family.keysis attempted.opts선택 사항EmitOptionsemit options, applied to every variant equally. To check the production output, pass the same plugins the production emit uses, for example
{ plugins: obfuscate() }.
반환값
readonly VariantLinkResult[]
one result per key, in family.keys order.
설명
A module type-checks as a whole, but the combination of axis values a host actually selects is only proven when a driver compiles and links it. This function enumerates the family, emits GLSL ES 3.00 for each variant, compiles the vertex and fragment shaders and links them into a program, and reports the outcome per key.
const gl = canvas.getContext('webgl2')!const failed = linkVariants(gl, family).filter((r) => !r.ok)expect(failed, failed.map((r) => `${r.key}: ${r.failedAt} ${r.log}`).join('\n')).toEqual([])Every variant is attempted even after one fails, so the result lists every broken combination in one run.
GL objects are deleted as it goes: a family is a cartesian product, and a matrix with a few axes would otherwise leak hundreds of programs on a context that is usually shared with a live page.
함께 보기
소스
src/core/variant-link.ts, 98행, 커밋 c66579bf 기준