WGSL_BUILTIN_TYPES
이 페이지에서

WGSL_BUILTIN_TYPES

상수, 레이아웃 분류

The type each @builtin(<name>) supplies, for every id WGSL gives one fixed type.

import { WGSL_BUILTIN_TYPES } from 'typeshade'

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

구문

const WGSL_BUILTIN_TYPES: { readonly vertex_index: { readonly kind: "scalar"; readonly scalar: "u32"; }; readonly instance_index: { readonly kind: "scalar"; readonly scalar: "u32"; }; readonly position: { readonly kind: "vec"; readonly n: 4; readonly elem: "f32"; }; readonly front_facing: { readonly kind: "scalar"; readonly scalar: "bool"; }; readonly frag_depth: { readonly kind: "scalar"; readonly scalar: "f32"; }; readonly sample_index: { readonly kind: "scalar"; readonly scalar: "u32"; }; readonly sample_mask: { readonly kind: "scalar"; readonly scalar: "u32"; }; readonly primitive_index: { readonly kind: "scalar"; readonly scalar: "u32"; }; readonly local_invocation_id: { readonly kind: "vec"; readonly n: 3; readonly elem: "u32"; }; readonly local_invocation_index: { readonly kind: "scalar"; readonly scalar: "u32"; }; readonly global_invocation_id: { readonly kind: "vec"; readonly n: 3; readonly elem: "u32"; }; readonly workgroup_id: { readonly kind: "vec"; readonly n: 3; readonly elem: "u32"; }; readonly num_workgroups: { readonly kind: "vec"; readonly n: 3; readonly elem: "u32"; }; readonly subgroup_invocation_id: { readonly kind: "scalar"; readonly scalar: "u32"; }; readonly subgroup_size: { readonly kind: "scalar"; readonly scalar: "u32"; }; }

설명

Read it to check a declared field against what the pipeline will actually hand the shader, or to render the vocabulary in a tool. builtin resolves its own token from this table when the call omits one, so the table and the authoring surface cannot disagree.

clip_distances is absent on purpose: it is an array<f32, N> whose N the author picks, so it has no single type and its builtin call still names one.

예제

예제

import { WGSL_BUILTIN_TYPES, typeKey } from 'typeshade'
typeKey(WGSL_BUILTIN_TYPES.global_invocation_id) // 'vec3<u32>'

함께 보기

소스

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

이 페이지 편집 문제 보고