---
title: "규칙 6.8: 선언과 리소스, TypeShade 셰이더 언어 설계 규칙과 그 근거, 출처, 검증 방식"
description: "TypeShade 언어 설계 규칙 6.8(선언과 리소스)입니다. The byte layout the emitted module assumes for a resource and the layout reflect() reports must agree byte for byte…"
url: https://typeshade.dev/ko/reference/rules/6-8/
language: ko
---

# 규칙 6.8

6장, 선언과 리소스 테스트

The byte layout the emitted module assumes for a resource and the layout `reflect()` reports must agree byte for byte, under WGSL’s uniform and storage layout rules, and so must the layout the manifest carries ([Rule 11.10](https://typeshade.dev/ko/reference/rules/11-10/)); a vertex entry’s vertex buffer is one layout, its `@location` inputs tightly packed in the order written and numbered in that order where no `location<n, T>` states the number ([Rule 6.6](https://typeshade.dev/ko/reference/rules/6-6/)), which `reflect().vertex` and the manifest both report.

규칙 본문과 그 아래 항목은 설계 문서에 적힌 컴파일러 원문이라 한국어 페이지에서도 영어로 둡니다.

## 근거

a buffer the host fills from `reflect()` and the shader reads by its own offsets is a dynamic error nothing detects.

## 출처

[Memory Layout](https://gpuweb.github.io/gpuweb/wgsl/#memory-layouts) (“it is a dynamic error if buffer producers and consumers do not agree on the memory layout”).

## 검증 방식

테스트로 확인합니다. 테스트나 게이트 스크립트, CI 워크플로가 이 규칙을 가리키고, 아래 파일 가운데 하나라도 규칙을 더는 가리키지 않으면 추적 검사가 실패합니다.

컴파일러가 이 규칙을 적용하는 곳을 규칙이 직접 적은 내용입니다.

`examples/emit-reflection-conformance.test.ts` for bindings, locations, and entry points, `src/core/manifest.test.ts`, which holds every example’s manifest to `reflect()`’s slots, struct offsets and vertex layout, and the one layout engine behind `reflect()` in `src/core/reflect.ts` (its code is in the directory `src/core/reflect/`) that the GLSL writer also uses, whose layout checks are the two-row matrix of [Rule 4.8](https://typeshade.dev/ko/reference/rules/4-8/) and the uniform-address-space rules of surface §51 ([#156](https://github.com/typeshade/typeshade/issues/156)): an array in a uniform is padded to a 16-byte stride and `reflect()` agrees; a `bool`, alone or in a vector, in a uniform or storage binding (a struct field, a runtime array’s element or the binding’s whole type, `"U.b" is a vec3b; a uniform binding holds no bool, alone or in a vector (WGSL's host-shareable rule). Use vec3u.`), a runtime-sized array in a uniform, and one that is not a struct’s last field are `TS8051 LAYOUT`; a field `@align` is [`TS8010`](https://typeshade.dev/ko/reference/errors/ts8010/) (`@align on a field is not applied.`) and a field `@size` is [`TS8028`](https://typeshade.dev/ko/reference/errors/ts8028/); pinned by `src/compiler/ts/uniform-layout.test.ts`.

커밋 af54ddad5에서 이 규칙을 확인하는 파일입니다. 파일마다 규칙을 처음 가리키는 줄로 연결했습니다.

- [`examples/emit-reflection-conformance.test.ts:31`](https://github.com/typeshade/typeshade/blob/af54ddad5/examples/emit-reflection-conformance.test.ts#L31)
- [`src/compiler/ts/bare-uniform-glsl.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/bare-uniform-glsl.test.ts#L1)
- [`src/compiler/ts/entry-locations.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/entry-locations.test.ts#L1)
- [`src/compiler/ts/entry-locations.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/entry-locations.ts#L1)
- [`src/compiler/ts/uniform-layout-matrix.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/uniform-layout-matrix.test.ts#L1)
- [`src/compiler/ts/uniform-layout-padded.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/uniform-layout-padded.test.ts#L1)
- [`src/compiler/ts/uniform-layout-refused.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/uniform-layout-refused.test.ts#L1)
- [`src/compiler/ts/uniform-layout.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/uniform-layout.test.ts#L1)
- [`src/core/manifest.test.ts:6`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/manifest.test.ts#L6)
- [`src/core/reflect.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/reflect.ts#L1)

## 설명하는 절

커밋 af54ddad5의 언어 문서에서 이 규칙을 설명하는 절입니다.

- [§3 Entries — stage attributes and explicit builtins](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/use-typeshade-surface.md#3-entries--stage-attributes-and-explicit-builtins)
- [§51 What a uniform lays out: the 16-byte array rule, and the shapes a struct hides](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/use-typeshade-surface.md#51-what-a-uniform-lays-out-the-16-byte-array-rule-and-the-shapes-a-struct-hides)
- [§69 Running a compiled program](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/use-typeshade-surface.md#69-running-a-compiled-program)

## 적용하는 오류 코드

규칙이 Enforced by 항목에서 가리키는 진단 코드와, 레지스트리 설명에서 이 규칙을 가리키는 진단 코드입니다.

**[`TS8010`](https://typeshade.dev/ko/reference/errors/ts8010/) `STRUCT_FIELD`**

구조체 필드나 선언의 모양이 잘못되었습니다. 필드가 없는 클래스는 받아들입니다. 이 코드는 잘못된 필드 선언, 클래스가 아닌 빈 구조체, 적용되지 않는 필드의 `@align`, 사용처마다 location이 둘로 갈리는 사용자 정의 값을 다룹니다([규칙 6.6](https://typeshade.dev/ko/reference/rules/6-6/)).

**[`TS8028`](https://typeshade.dev/ko/reference/errors/ts8028/) `ATTRIBUTE_NAME`**

이 표면이 읽지 않는 데코레이터나 진입점 형태입니다. 속성 어휘(`@vertex`, `@fragment`, `@compute`, `@builtin`, `@location`) 밖의 식별자(`@vertx` 같은 오타), 표면이 다른 방식으로 쓰거나 빌려 오지 않는 WGSL 속성(직접 쓴 `@diagnostic(…)` 같은 것), `vertex(f)`처럼 호출로 쓴 스테이지, `export default`처럼 [규칙 8.1](https://typeshade.dev/ko/reference/rules/8-1/)이 거부하는 형태로 쓴 진입점, 데코레이터를 받지 않는 선언이나 자리에 붙은 데코레이터가 그렇습니다([규칙 6.7](https://typeshade.dev/ko/reference/rules/6-7/)). 이 코드가 없으면 데코레이터를 붙인 함수나 필드가 아무 말 없이 진입점이나 IO 필드가 아니게 됩니다.

**[`TS8051`](https://typeshade.dev/ko/reference/errors/ts8051/) `LAYOUT`**

버퍼 바인딩의 저장 타입이 WGSL의 호스트 공유 규칙 하나를 어깁니다. `uniform`이나 `storage` 바인딩 안의 `bool`(단독이든 벡터든), 구조체의 마지막 멤버가 아닌 런타임 크기 `array<T>`, uniform 안의 런타임 크기 배열, uniform 안의 두 행 행렬(`mat2x2`, `mat3x2`, `mat4x2`)이 그렇습니다. 마지막은 WGSL과 std140이 서로 다른 오프셋에 배치합니다([규칙 4.8](https://typeshade.dev/ko/reference/rules/4-8/)).

## 함께 보기

- [규칙 6.7](https://typeshade.dev/ko/reference/rules/6-7/) 테스트
- [규칙 6.9](https://typeshade.dev/ko/reference/rules/6-9/) 테스트
- [규칙 4.8](https://typeshade.dev/ko/reference/rules/4-8/)
- [규칙 6.6](https://typeshade.dev/ko/reference/rules/6-6/)
- [규칙 11.10](https://typeshade.dev/ko/reference/rules/11-10/)
- [설계 규칙](https://typeshade.dev/ko/reference/rules/)
- [오류 코드](https://typeshade.dev/ko/reference/errors/)

## 소스

커밋 af54ddad5의 규칙 원문:

- [`docs/language-design.md:569`](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/language-design.md#L569) (설계 문서)
- [`reqs/rules/RULE-0608.md`](https://github.com/typeshade/typeshade/blob/af54ddad5/reqs/rules/RULE-0608.md) (추적 항목)
