규칙 6.8
이 페이지에서

규칙 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); 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), 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 (“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 and the uniform-address-space rules of surface §51 (#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 (@align on a field is not applied.) and a field @size is TS8028; pinned by src/compiler/ts/uniform-layout.test.ts.

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

설명하는 절

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

적용하는 오류 코드

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

TS8010 STRUCT_FIELD
구조체 필드나 선언의 모양이 잘못되었습니다. 필드가 없는 클래스는 받아들입니다. 이 코드는 잘못된 필드 선언, 클래스가 아닌 빈 구조체, 적용되지 않는 필드의 @align, 사용처마다 location이 둘로 갈리는 사용자 정의 값을 다룹니다(규칙 6.6).
TS8028 ATTRIBUTE_NAME
이 표면이 읽지 않는 데코레이터나 진입점 형태입니다. 속성 어휘(@vertex, @fragment, @compute, @builtin, @location) 밖의 식별자(@vertx 같은 오타), 표면이 다른 방식으로 쓰거나 빌려 오지 않는 WGSL 속성(직접 쓴 @diagnostic(…) 같은 것), vertex(f)처럼 호출로 쓴 스테이지, export default처럼 규칙 8.1이 거부하는 형태로 쓴 진입점, 데코레이터를 받지 않는 선언이나 자리에 붙은 데코레이터가 그렇습니다(규칙 6.7). 이 코드가 없으면 데코레이터를 붙인 함수나 필드가 아무 말 없이 진입점이나 IO 필드가 아니게 됩니다.
TS8051 LAYOUT
버퍼 바인딩의 저장 타입이 WGSL의 호스트 공유 규칙 하나를 어깁니다. uniform이나 storage 바인딩 안의 bool(단독이든 벡터든), 구조체의 마지막 멤버가 아닌 런타임 크기 array<T>, uniform 안의 런타임 크기 배열, uniform 안의 두 행 행렬(mat2x2, mat3x2, mat4x2)이 그렇습니다. 마지막은 WGSL과 std140이 서로 다른 오프셋에 배치합니다(규칙 4.8).

함께 보기

소스

커밋 af54ddad5의 규칙 원문:

이 페이지 편집 문제 보고