lowerComputeToFragment()
함수, 출력 분류
Rewrite a gather-only @compute module into a @fragment one that WebGL2 runs as a fullscreen draw into an R32UI target, one texel per invocation.
import { lowerComputeToFragment } from 'typeshade'
시그니처, 설명, 예제는 커밋 c66579bf의 컴파일러 소스에서 그대로 가져온 영어 원문입니다.
구문
function lowerComputeToFragment(m: ModuleDecl): ModuleDecl매개변수
mModuleDecla module with one
@computeentry.
반환값
the rewritten module, with a @fragment entry and no read_write binding.
예외
@link UnsupportedFeatureError(
SD0030) when the module has no@computeentry, noglobal_invocation_idparameter, noread_writestorage binding or nouniformbinding, and when the kernel is not gather-only: a write at an index other thangid.x, more than one write to the output, or a use ofglobal_invocation_idother than.x.@link TypeShadeErrorSD0111instead of the above when the entry is declaredportable: the portable-kernel check then reports every violation with its remedy at once, the same report both backends give.
설명
The rewrite:
- turns the
@computeentry into a@fragmententry and drops its workgroup size; - removes the
@builtin(global_invocation_id)parameter and adds a@builtin(position)one, sogid.xbecomesu32(floor(position.x)) + u32(floor(position.y)) * width, wherewidthis the.ycomponent of the module’s firstuniformbinding; - turns the single
out[gid.x] = ewrite to theread_writestorage binding intoreturn e, typedu32at@location(0), and removes that binding; - turns an expression-less
return;(the bounds guard) intodiscard;.
Read-only storage bindings are left in place; a full emit goes on to rewrite them as data textures, so a module this function returns is not yet ready to emit on its own.
소스
src/core/backends/glsl.ts, 1647행, 커밋 c66579bf 기준