UniformStruct
이 페이지에서

UniformStruct

인터페이스, 레이아웃 분류

The handle uniformStruct returns: a struct and its binding declared together.

import type { UniformStruct } from 'typeshade'

시그니처, 설명, 예제는 커밋 c66579bf의 컴파일러 소스에서 그대로 가져온 영어 원문입니다.

구문

interface UniformStruct<F extends Record<string, UniformFieldSpec>> {
readonly struct: StructDecl;
readonly decl: StructDecl;
readonly type: ShaderType;
readonly binding: BindingDecl;
readonly node: Node;
readonly field: { readonly [K in keyof F]: UniformFieldNode<F[K]> };
}

설명

.struct (also spelled .decl) is for module({ structs }), .binding for module({ bindings }), and .field gives typed, read-only field access; uniforms are read-only in WGSL, so .field.x.assign(...) is a tsc error. F may include a fixed-size arrayOf field (a struct-element array or a plain-type array), the one field shape PlainStruct cannot express.

The type is exported so that other code can accept it as a generic constraint and build on the struct’s shape F without re-declaring it: a host can derive a CPU-side std140 buffer writer from u.struct, and a helper can return UniformStruct<{ time: ...; resolution: ... } & F> to compose a base uniform layout with a caller’s extra fields under one type-checked struct.

인스턴스 속성

struct읽기 전용 StructDecl

The struct declaration, for module({ structs }).

decl읽기 전용 StructDecl

The same declaration as struct, under the name every other handle in this module uses, so structs: [U.decl, VsOut.decl] reads uniformly.

type읽기 전용 ShaderType

The struct’s ShaderType.

binding읽기 전용 BindingDecl

The binding declaration, for module({ bindings }).

node읽기 전용 Node

The raw binding access node, for a hand-built member(...) read.

field읽기 전용 { readonly [K in keyof F]: UniformFieldNode<F[K]> }

Typed, read-only field access. A field declared with arrayOf exposes .at(i).

함께 보기

소스

src/core/sot.ts, 690행, 커밋 c66579bf 기준

이 페이지 편집 문제 보고