---
title: "규칙 11.7: 대상과 오라클, TypeShade 셰이더 언어 설계 규칙과 그 근거, 출처, 검증 방식"
description: "TypeShade 언어 설계 규칙 11.7(대상과 오라클)입니다. The CPU tier, which runs a host call of a module's function and, where there is no GPU tier…"
url: https://typeshade.dev/ko/reference/rules/11-7/
language: ko
---

# 규칙 11.7

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

The CPU tier, which runs a host call of a module’s function and, where there is no GPU tier, the invocations of an entry a host calls and the pixels of a fragment entry a host draws ([Rule 8.24](https://typeshade.dev/ko/reference/rules/8-24/)), is the oracle’s generated code (`generateModuleJs`) at `f32` precision, written into the module the bundler reads as module code, with no `new Function`, over the op library alone, `typeshade/runtime/internal`. The CPU tier holds a kernel function’s texture in memory of its own (change 0077): a `CpuTexture` of `src/core/cpu-texture.ts`, the texels of a 2D texture in row order as the bytes of its format, which `device.texture()` makes on a device with no WebGPU device and which an `ImageData` is copied into. Over such a texture `textureLoad`, `textureStore` and `textureDimensions` compute: a store converts the value as WebGPU converts it for the format (a float format keeps the `f32`, a `unorm` or `snorm` one clamps to its range and rounds to the nearest step, an integer one keeps the low bits), a load outside the texture reads the nearest texel inside and a store outside is dropped. Every other texture builtin, and any of these over a texture that is not in that memory, keeps the stub contract (`GPU_STUBS`).

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

## 근거

a host call computes what the GPU would, so it rounds as `f32` does, which the default `f64` algebra oracle is blind to by construction. The generated code computes each operation as the interpreter’s runtime helper does: a vector operation of a known width, on operands nothing can leave missing, is written one component at a time, each the scalar operation the helper applies to it (`dot`, `length`, `distance`, `normalize` and `cross` summed in the order their entries sum), and every other operation, one on an operand that may be missing (a helper’s `discard`, an element read past an array’s end) among them, calls the helper itself; `src/core/cpu-codegen.test.ts` holds the two to each other bit for bit in both precisions, so the tier is the oracle and not a fourth implementation ([Rule 11.1](https://typeshade.dev/ko/reference/rules/11-1/)). Building it with `new Function` at run time would need `unsafe-eval`, which a strict content security policy forbids, and would ship the IR and the generator; as module code it is minified with the application, and the application ships the op library only.

## 출처

change `0009` in `changes/` (“The CPU tier’s precision”); `src/core/oracle.ts` (the `'f32'` mode, “a correctly-rounding `f32` machine over the same IR”); [Rule 11.1](https://typeshade.dev/ko/reference/rules/11-1/).

## 검증 방식

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

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

`hostFace` in `src/compiler/ts/host-face.ts`, which generates at `precision: 'f32'`, and `src/runtime/host/runtime.ts`, what a generated module imports through `typeshade/runtime/internal`; pinned by `src/compiler/ts/host-face.test.ts`, where every call equals `compileModule(m, { precision: 'f32' })` on inputs chosen so the `f32` and `f64` answers part, and the generated module holds no `new Function`. The texture memory is `CpuTexture` and `cpuTextureCall` in `src/core/cpu-texture.ts`, which the generated code’s `gpuStub` asks first (`src/core/cpu-codegen-runtime.ts`); pinned by `src/core/cpu-texture.test.ts` (each format’s conversion, the channels, the edge), by `src/compiler/ts/host-kernel-texture.test.ts` (a kernel call on a device of the CPU tier, each byte as the format rounds it) and by the import journey, whose CPU-tier run of `invertImage` gives each byte its WebGPU run gives (change 0077).

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

- [`src/compiler/ts/host-draw.test.ts:3`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/host-draw.test.ts#L3)
- [`src/compiler/ts/host-entry.test.ts:3`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/host-entry.test.ts#L3)
- [`src/compiler/ts/host-face-cpu-tier.test.ts:3`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/host-face-cpu-tier.test.ts#L3)
- [`src/compiler/ts/host-face.test.ts:3`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/host-face.test.ts#L3)
- [`src/compiler/ts/host-face.ts:83`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/host-face.ts#L83)
- [`src/compiler/ts/host-kernel-texture.test.ts:3`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/host-kernel-texture.test.ts#L3)
- [`src/core/cpu-codegen-runtime.ts:9`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/cpu-codegen-runtime.ts#L9)
- [`src/core/cpu-texture.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/cpu-texture.test.ts#L1)
- [`src/core/cpu-texture.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/cpu-texture.ts#L1)
- [`src/runtime/host/runtime.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/runtime/host/runtime.ts#L1)

## 설명하는 절

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

- [§34 A shadow map, read by comparison](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/use-typeshade-surface.md#34-a-shadow-map-read-by-comparison)
- [§64 Calling a module from host code](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/use-typeshade-surface.md#64-calling-a-module-from-host-code)
- [§65 A loop that runs as a kernel](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/use-typeshade-surface.md#65-a-loop-that-runs-as-a-kernel)
- [§71 A chain of kernel calls in one dispatch: `fuse`](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/use-typeshade-surface.md#71-a-chain-of-kernel-calls-in-one-dispatch-fuse)

## 함께 보기

- [규칙 11.6](https://typeshade.dev/ko/reference/rules/11-6/) 테스트
- [규칙 11.8](https://typeshade.dev/ko/reference/rules/11-8/) 테스트
- [규칙 8.24](https://typeshade.dev/ko/reference/rules/8-24/)
- [규칙 11.1](https://typeshade.dev/ko/reference/rules/11-1/)
- [설계 규칙](https://typeshade.dev/ko/reference/rules/)
- [오류 코드](https://typeshade.dev/ko/reference/errors/)

## 소스

커밋 af54ddad5의 규칙 원문:

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