fp64Guard
이 페이지에서

fp64Guard()

함수, f64 에뮬레이션 분류

Pin the slot of the fp64 guard texture.

import { fp64Guard } from 'typeshade'

시그니처, 설명, 예제는 커밋 c66579bf의 컴파일러 소스에서 그대로 가져온 영어 원문입니다.

구문

function fp64Guard(at: { group: number; binding: number }): Fp64GuardHandle

매개변수

at { group: number; binding: number }

the group and binding to pin the guard texture to.

반환값

Fp64GuardHandle

the Fp64GuardHandle: .binding for module({ uses }), and .type.

예외

SD0042

A module declaring its own fp64 binding with a different type or space fails emit with SD0042, and a declaration whose name starts with df64 or is one of the emitted DF64Vec2, DF64Vec3, DF64Vec4 structs collides with the emulation and fails with SD0043.

SD0043

A module declaring its own fp64 binding with a different type or space fails emit with SD0042, and a declaration whose name starts with df64 or is one of the emitted DF64Vec2, DF64Vec3, DF64Vec4 structs collides with the emulation and fails with SD0043.

설명

Most modules never call this: the guard is injected for you, and this exists for a fixed bind-group layout that needs it at a chosen (group, binding).

Every module whose lowered code calls a guarded df64 helper gets a texture_2d<f32> binding named _fp64 added by fp64Lower, deterministically at group 0 in the first free binding. A module whose only f64 work is comparisons, widening and narrowing, negation, or scaling by a power-of-two literal calls none and gets no binding; a host that binds _fp64 unconditionally should look for it in reflect() first. The host must bind a 1 by 1 texture whose single texel reads back exactly 1.0, an RGBA8 white texel or an R32F 1.0, and the shader multiplies the error-compensation terms by that texel.

It is a texture for a reason. WGSL permits reassociation, and Metal defaults to fast math, so without a value the compiler cannot see through, a downstream compiler can legally fold the emulation’s terms back to f32 precision. A uniform is not enough either: some drivers specialize pipelines on observed uniform values and hot-swap a re-optimized variant that folds the terms anyway. No compiler treats a texel as a compile-time constant.

Either way the binding appears in reflect as an ordinary 2D texture, so a host building its bind group from the reflection creates it without special-casing.

The names around it are reserved. A module declaring its own _fp64 binding with a different type or space fails emit with SD0042, and a declaration whose name starts with df64_ or is one of the emitted DF64Vec2, DF64Vec3, DF64Vec4 structs collides with the emulation and fails with SD0043.

예제

예제

import { fp64Guard, module } from 'typeshade'
// Only needed when the host's bind-group layout fixes the slot.
const m = module({ uses: [U, fp64Guard({ group: 0, binding: 3 })], funcs: [k] })

관련 가이드

함께 보기

소스

src/core/fp64/df64-lib.ts, 197행, 커밋 c66579bf 기준

이 페이지 편집 문제 보고