Program
인터페이스, 런타임 분류
런타임에 올린 프로그램입니다. 매니페스트와 파이프라인을 담습니다.
import type { Program } from 'typeshade/runtime'
설명은 커밋 af54ddad5의 검토된 컴파일러 문서를 번역한 것입니다. 시그니처와 예제 코드는 원문을 따르며, 필요한 경우 설명에 편집상 수정이 반영됩니다.
구문
interface Program<E extends PackBindings = PackBindings> { readonly manifest: Pack<E>; readonly recording: boolean; compute<K extends keyof E & string = keyof E & string>( entry?: K, options?: { readonly constants?: Constants }, ): Promise<ComputePipeline<E[K]>>; render<const S extends RenderState & EntryNames<E> = Record<never, never>>( state?: S, ): Promise<RenderPipeline<RenderBindings<E, S>>>;}설명
E는 각 진입점이 닿는 바인딩입니다. 매니페스트의 타입(변경 0030)에서 가져오며, 타입이 없는 매니페스트는 any를 받습니다.
인스턴스 속성
manifest읽기 전용Pack<E>recording읽기 전용boolean진입점이
console.*호출을 기록하는지 여부입니다.
인스턴스 메서드
compute<K extends keyof E & string = keyof E & string>(entry?: K, options?: { readonly constants?: Constants }): Promise<ComputePipeline<E[K]>>@compute진입점의 파이프라인이며 캐시됩니다.entry를 생략하면 프로그램에 컴퓨트 진입점이 하나뿐일 때 그것을 씁니다.options.constants는 이 파이프라인의 프로그램 오버라이드를 정합니다.RenderState.constants가 렌더 파이프라인에서 하는 일과 같습니다. 빠뜨린 오버라이드는 선언된 기본값을 씁니다. 값의 집합이 둘이면 파이프라인도 둘입니다. 이 파이프라인의 디스패치는 진입점이 닿는 바인딩을 받습니다.render<const S extends RenderState & EntryNames<E> = Record<never, never>>(state?: S): Promise<RenderPipeline<RenderBindings<E, S>>>state를 적용한 버텍스 진입점과 프래그먼트 진입점의 파이프라인이며, 캐시됩니다.state의 기본값은{}입니다. 이때 프로그램의 유일한 버텍스 진입점과 프래그먼트 진입점을 쓰고, 다른 필드는 모두 기본값을 씁니다. 이 파이프라인의 그리기는 두 진입점이 닿는 바인딩을 받습니다. 그리기는 파이프라인이blendConstant를 선언했으면 그 값을 설정합니다. 선언하지 않은 파이프라인의 그리기가 선언한 그리기 뒤에 오면, 런타임은 패스의 값을 다시 설정합니다.depth.stencil이 있는 파이프라인의 그리기는depth.stencil.reference를 선언했으면 그 값을, 아니면setStencilReference로 정한 패스의 값을 씁니다.depth.stencil이 없는 파이프라인의 그리기는 참조 값을 설정하지 않습니다.blendConstant나depth.stencil.reference만 다른 두 상태는 GPU 파이프라인 하나 위의 파이프라인 두 개가 됩니다.
소스
src/runtime/program.ts, 398행, 커밋 af54ddad5 기준