17ec681f3SmrgOverview
27ec681f3Smrg========
37ec681f3Smrg
47ec681f3SmrgComputerator is a tool to launch compute shaders, written in assembly.
57ec681f3SmrgThe main purpose is to have an easy way to experiment with instructions
67ec681f3Smrgwithout dealing with the entire compiler stack (which makes controlling
77ec681f3Smrgthe order of instructions, the registers chosen, etc, difficult).  The
87ec681f3Smrgchoice of compute shaders is simply because there is far less state
97ec681f3Smrgsetup required.
107ec681f3Smrg
117ec681f3SmrgHeaders
127ec681f3Smrg-------
137ec681f3Smrg
147ec681f3SmrgThe shader assembly can be prefixed with headers to control state setup:
157ec681f3Smrg
167ec681f3Smrg* ``@localsize X, Y, Z`` - configures local workgroup size
177ec681f3Smrg* ``@buf SZ (cN.c)`` - configures an SSBO of the specified size (in dwords).
187ec681f3Smrg  The order of the ``@buf`` headers determines the index, ie the first
197ec681f3Smrg  ``@buf`` header is ``g[0]``, the second ``g[1]``, and so on.
207ec681f3Smrg  The iova of the buffer is written as a vec2 to ``cN.c``
217ec681f3Smrg* ``@const(cN.c)`` configures a const vec4 starting at specified
227ec681f3Smrg  const register, ie ``@const(c1.x) 1.0, 2.0, 3.0, 4.0`` will populate
237ec681f3Smrg  ``c1.xyzw`` with ``vec4(1.0, 2.0, 3.0, 4.0)``
247ec681f3Smrg* ``@invocationid(rN.c)`` will populate a vec3 starting at the specified
257ec681f3Smrg  register with the local invocation-id
267ec681f3Smrg* ``@wgid(rN.c)`` will populate a vec3 starting at the specified register
277ec681f3Smrg  with the workgroup-id (must be a high-reg, ie. ``r48.x`` and above)
287ec681f3Smrg* ``@numwg(cN.c)`` will populate a vec3 starting at the specified const
297ec681f3Smrg  register
307ec681f3Smrg
317ec681f3SmrgExample
327ec681f3Smrg-------
337ec681f3Smrg
347ec681f3Smrg```
357ec681f3Smrg@localsize 32, 1, 1
367ec681f3Smrg@buf 32  ; g[0]
377ec681f3Smrg@const(c0.x)  0.0, 0.0, 0.0, 0.0
387ec681f3Smrg@const(c1.x)  1.0, 2.0, 3.0, 4.0
397ec681f3Smrg@wgid(r48.x)        ; r48.xyz
407ec681f3Smrg@invocationid(r0.x) ; r0.xyz
417ec681f3Smrg@numwg(c2.x)        ; c2.xyz
427ec681f3Smrgmov.u32u32 r0.y, r0.x
437ec681f3Smrg(rpt5)nop
447ec681f3Smrgstib.untyped.1d.u32.1 g[0] + r0.y, r0.x
457ec681f3Smrgend
467ec681f3Smrgnop
477ec681f3Smrg```
487ec681f3Smrg
497ec681f3SmrgUsage
507ec681f3Smrg-----
517ec681f3Smrg
527ec681f3Smrg```
537ec681f3Smrgcat myshader.asm | ./computerator --disasm --groups=4,4,4
547ec681f3Smrg```
557ec681f3Smrg
56