`@SpirvType` — SPIR-V 타입 만들기

@SpirvType — SPIR-V 타입 만들기

인자에 담긴 속성 그대로의 SPIR-V 타입을 만들어 주는 내장 함수예요. GPU 셰이더 쪽 코드를 다룰 때, 지정한 옵션에 해당하는 SPIR-V 타입을 바로 얻고 싶을 때 활용해요.

출처: Zig Documentation

본문

@SpirvType은 인자로 넘긴 옵션들에 적힌 속성을 그대로 가진 SPIR-V 타입을 돌려줘요.

@SpirvType(comptime options: std.lang.Type.Spirv) type

옵션의 Tag 값에 따라 만들어지는 SPIR-V 타입이 달라져요.

Tag SPIR-V Equivalent Description
.sampler OpTypeSampler An opaque sampler
.image OpTypeImage An opaque image
.sampled_image OpTypeSampledImage An opaque image combined with a sampler
.runtime_array OpTypeRuntimeArray An array whose length is determined at runtime. The resulting type supports indexing and exposes a .len field. It may only appear as the last field of an extern struct.

더 알아보기 (Learn more)