TS8071
프런트엔드 코드 CONSOLE_NOT_RECORDED
compile(src, { console: 'gpu' })에서 나오는 경고입니다. WGSL이 기록하지 않는 console 호출이 있습니다. 메시지가 이유를 알려 줍니다. 정점 진입점이 그 호출에 닿거나, 인자의 크기가 정해져 있지 않거나 값이 아니거나, 스테이지에 스토리지 버퍼를 더 둘 자리가 없습니다. 호출은 CPU에서는 여전히 싱크에 닿습니다(규칙 11.9).
레지스트리에는 이 상수에 대한 문서 주석이 없습니다. 그래서 위 설명은 컴파일러가 이 코드와 함께 내는 메시지를 보고 이 사이트가 쓴 것입니다.
레지스트리 설명과 컴파일러 메시지는 컴파일러 원문이라 한국어 페이지에서도 영어로 둡니다.
예제
"use typeshade"
function lift(x: f32): f32 { console.log("x =", x) return x}
@vertexexport function vs(vi: builtin<"vertex_index">): vec4 { return vec4(lift(f32(vi)), 0., 0., 1.)}
@fragmentexport function fs(p: builtin<"position">): vec4 { return vec4(p.x, 0., 0., 1.)}WGSL이 console 호출을 기록하게 하는 옵션인 { console: 'gpu' }를 주고 컴파일했습니다.
빌드할 때 고정된 컴파일러로 이 프로그램을 컴파일하면 다음 진단이 나옵니다.
TS8071 warning, 4행: This console.log() is not recorded on the GPU, because the vertex entry "vs" reaches it, and a vertex stage cannot write a storage buffer. It still reaches the sink when the function runs on the CPU.
고치는 법
같은 프로그램을 고친 모습입니다. 진단 없이 컴파일됩니다.
"use typeshade"
function lift(x: f32): f32 { return x}
@vertexexport function vs(vi: builtin<"vertex_index">): vec4 { return vec4(lift(f32(vi)), 0., 0., 1.)}
@fragmentexport function fs(p: builtin<"position">): vec4 { console.log("x =", p.x) return vec4(p.x, 0., 0., 1.)}이 코드가 적용하는 규칙
- 규칙 11.9 테스트
- A
consolecall computes nothing a shader reads: its arguments must be evaluated once, in order, on every target, and the call then delivers an event,{ method, args, span, invocation }.
함께 보기
소스
커밋 af54ddad5에서 컴파일러가 이 코드를 내는 곳입니다. 파일마다 한 줄씩 적었습니다.