---
title: "규칙 11.10: 대상과 오라클, TypeShade 셰이더 언어 설계 규칙과 그 근거, 출처, 검증 방식"
description: "TypeShade 언어 설계 규칙 11.10(대상과 오라클)입니다. A compiled program's manifest, what packModule() returns and what the default export of a module's host import is…"
url: https://typeshade.dev/ko/reference/rules/11-10/
language: ko
---

# 규칙 11.10

11장, 대상과 오라클 테스트

A compiled program’s manifest, what `packModule()` returns and what the default export of a module’s host import is, must be one JSON object that carries its schema (`schema`, 3) and the package version that wrote it (`compiler`); each binding, struct, field, override, entry and vertex or varying name the host uses with its authored name and its emitted name (`emitted`, the WGSL spelling; a binding and an override also carry `emittedGlsl`, the GLSL spelling, which equals `emitted` where the two agree, changes 0070 and 0151); each binding with its group and slot, its resource in `reflect()`’s vocabulary, the stages that reach it, and a buffer’s byte layout with every offset, size and stride under the rule of its space ([Rule 6.8](https://typeshade.dev/ko/reference/rules/6-8/)), the `_fp64` guard the emit adds among them; each entry with its stage, its default workgroup size and optional axis override names, its inputs and outputs with their locations, builtins and interpolation, the bindings it reaches and which it writes, a vertex entry’s vertex buffer, and its line; the overrides and the WebGPU features; with `console`, the recorded variant, its WGSL, its log table and its bindings; with `ir`, the program as portable IR and the package version that wrote it, which emitted again gives every other field byte for byte; and what the WebGL2 tier uses, each full-screen fragment entry’s GLSL ES 3.00 program, block names and texture-sampler pairs, and each storage array’s data texture. A reader of schema 1 refuses a schema-2 manifest, since it would bind by the authored name where the emitted one differs. A sampled texture’s resource must carry its `sampleType`, the word its bind group layout takes, from its element and the calls that read it: `depth` for a depth texture, `uint` or `sint` for an integer one, `float` for an `f32` texture that a call of an entry, or of a function an entry calls, pairs with a `sampler` (a `textureSample` of any form or a `textureGather`, through a helper’s parameters or a `const` of the texture as well), and `unfilterable-float` for every other `f32` texture: one the entries only load, measure or count, one no entry reaches, and a multisampled one, which no sampler reads. The optional field `variants.console` (since schema 2) carries an available recorded variant with the same WGSL, log and bindings shape as `console`, but enables nothing by its presence. `console` retains its enabled-by-default meaning. A normal build uses `variants.console` for reachable, recordable calls; `PackOptions.console: true` uses `console`, `false` retains the disabled optional variant, and `'never'` omits both (change 0085). No IR is added implicitly. A module with no entry is read whole, since a host writes its entries over it, and one with a `raw` statement in what its entries reach, whose text no analysis reads, has each `f32` texture but a multisampled one `float`; `reflect()` reports the same word, and the WebGL2 tier’s texture-sampler pairs are read from the same calls. A manifest packed under emit options (`packModule(m, { emit })`: an optimization `level`, `parens`, `fp64Flavor` and `plugins`) must hold the WGSL, the recorded variant’s WGSL, the GLSL (each WebGL2 draw’s program among it) and the bindings those options emit, the `_fp64` guard of a module that emulates `f64` among the bindings under the `float` flavor and none under the `integer` one; the GLSL writer has no level, so `level` is the WGSL’s alone. It must record the level and the two named options, `emit`, so that the IR emitted again is emitted under them and gives every other field byte for byte. A plugin is a function, which a manifest cannot record: `ir` with a plugin must be a `TypeError` that says the load-time emitter could not emit the program again, and a word an option does not take, which a writer reads as another, must be a `TypeError` that names what the option takes. It is built from the IR alone, with no TypeScript, so every producer builds the same one; a reader must refuse a schema it does not know, naming both.

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

## 근거

a host that runs a program needed `reflect()` for its offsets, parsed type strings for its resources, and re-derived what the call layer computed privately; a stored program with no version cannot say which runtime reads it, which an engine’s shader cache needs; a texture’s sample type follows from the calls that read it, which only the compiler has, and a wrong one is a pipeline WebGPU refuses: `float` for an `r32float` texture the program only loads ([#404](https://github.com/typeshade/typeshade/issues/404)), `unfilterable-float` for one a filtering sampler reads; a host that shows or ships a program under other emit options (an application’s WGSL tab) must run that program and not the default one, whose bindings the flavor changes (the guard), and a manifest that did not record how it was emitted could not be emitted again to agree with itself.

## 출처

changes `0025` (section 1) and `0028` (sections 2 and 4) in `changes/`; issues [#335](https://github.com/typeshade/typeshade/issues/335) (principle 4) and [#404](https://github.com/typeshade/typeshade/issues/404); [Rule 6.8](https://typeshade.dev/ko/reference/rules/6-8/); measured on Dawn (Chromium 153 on SwiftShader): a texture laid out `unfilterable-float` beside a `filtering` sampler is refused when a `textureSample`, a `textureSampleLevel`, a `textureGather`, a helper’s parameters or a `let` pair them, and accepted when the texture is only loaded.

## 검증 방식

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

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

`buildManifest` in `src/core/manifest.ts`, which `packModule` in `src/compiler/ts/pack.ts` and `hostFace` in `src/compiler/ts/host-face.ts` call, and which checks the emit options and hands the writers theirs, the level to `emitModule` in `src/core/emit.ts`; the sample type by `reflect()` in `src/core/reflect.ts` over the pairs `texturePairs` in `src/core/passes/texture-pairs.ts` reads; pinned by `src/core/manifest.test.ts`, over every example (schema, version, JSON round trip, slots, entries, offsets, vertex layout, the recorded variant, a data texture’s format against the GLSL, the call layer’s layouts, each texture’s sample type against the calls in its WGSL, and for each level and flavor the WGSL, the GLSL, the bindings, the recorded variant and the WebGL2 draws those options emit and `repack` giving the manifest back byte for byte, with each refusal’s sentence), by `src/core/passes/texture-pairs.test.ts` (each way a call pairs a texture with a sampler, and each it does not), and by `src/vite.test.ts`, which imports a module’s default export through the plugin and bundles it alone with no CPU tier.

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

- [`scripts/sampler-pair-cases.ts:3`](https://github.com/typeshade/typeshade/blob/af54ddad5/scripts/sampler-pair-cases.ts#L3)
- [`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/console-variants.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/console-variants.test.ts#L1)
- [`src/compiler/ts/host-face.ts:5`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/host-face.ts#L5)
- [`src/compiler/ts/host-glsl-name.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/host-glsl-name.test.ts#L1)
- [`src/compiler/ts/pack.ts:21`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/pack.ts#L21)
- [`src/compiler/ts/texture-multiple-samplers.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/texture-multiple-samplers.test.ts#L1)
- [`src/core/emit.ts:797`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/emit.ts#L797)
- [`src/core/emitted-record.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/emitted-record.test.ts#L1)
- [`src/core/glsl-name-written.test.ts:2`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/glsl-name-written.test.ts#L2)
- [`src/core/ir/portable.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/ir/portable.test.ts#L1)
- [`src/core/manifest-gl-names.test.ts:6`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/manifest-gl-names.test.ts#L6)
- [`src/core/manifest.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/manifest.test.ts#L1)
- [`src/core/manifest.ts:575`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/manifest.ts#L575)
- [`src/core/passes/texture-pairs.test.ts:2`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/passes/texture-pairs.test.ts#L2)
- [`src/core/passes/texture-pairs.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/passes/texture-pairs.ts#L1)
- [`src/core/reflect.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/reflect.ts#L1)
- [`src/runtime/console-variants.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/runtime/console-variants.test.ts#L1)
- [`src/runtime/gl-draw.test.ts:252`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/runtime/gl-draw.test.ts#L252)
- [`src/runtime/gl-names.test.ts:6`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/runtime/gl-names.test.ts#L6)
- [`src/vite-console-variants.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/vite-console-variants.test.ts#L1)
- [`src/vite.test.ts:202`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/vite.test.ts#L202)

## 설명하는 절

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

- [§69 Running a compiled program](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/use-typeshade-surface.md#69-running-a-compiled-program)

## 함께 보기

- [규칙 11.9](https://typeshade.dev/ko/reference/rules/11-9/) 테스트
- [규칙 11.11](https://typeshade.dev/ko/reference/rules/11-11/) 테스트
- [규칙 6.8](https://typeshade.dev/ko/reference/rules/6-8/)
- [설계 규칙](https://typeshade.dev/ko/reference/rules/)
- [오류 코드](https://typeshade.dev/ko/reference/errors/)

## 소스

커밋 af54ddad5의 규칙 원문:

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