~mmach/netext73/mesa_2004

« back to all changes in this revision

Viewing changes to src/freedreno/computerator/README.rst

  • Committer: mmach
  • Date: 2022-09-22 20:00:35 UTC
  • Revision ID: netbit73@gmail.com-20220922200035-j2mt0pv92d002zy3
2022-09-22 21:17:58

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Overview
 
2
========
 
3
 
 
4
Computerator is a tool to launch compute shaders, written in assembly.
 
5
The main purpose is to have an easy way to experiment with instructions
 
6
without dealing with the entire compiler stack (which makes controlling
 
7
the order of instructions, the registers chosen, etc, difficult).  The
 
8
choice of compute shaders is simply because there is far less state
 
9
setup required.
 
10
 
 
11
Headers
 
12
-------
 
13
 
 
14
The shader assembly can be prefixed with headers to control state setup:
 
15
 
 
16
* ``@localsize X, Y, Z`` - configures local workgroup size
 
17
* ``@buf SZ (cN.c)`` - configures an SSBO of the specified size (in dwords).
 
18
  The order of the ``@buf`` headers determines the index, ie the first
 
19
  ``@buf`` header is ``g[0]``, the second ``g[1]``, and so on.
 
20
  The iova of the buffer is written as a vec2 to ``cN.c``
 
21
* ``@const(cN.c)`` configures a const vec4 starting at specified
 
22
  const register, ie ``@const(c1.x) 1.0, 2.0, 3.0, 4.0`` will populate
 
23
  ``c1.xyzw`` with ``vec4(1.0, 2.0, 3.0, 4.0)``
 
24
* ``@invocationid(rN.c)`` will populate a vec3 starting at the specified
 
25
  register with the local invocation-id
 
26
* ``@wgid(rN.c)`` will populate a vec3 starting at the specified register
 
27
  with the workgroup-id (must be a high-reg, ie. ``r48.x`` and above)
 
28
* ``@numwg(cN.c)`` will populate a vec3 starting at the specified const
 
29
  register
 
30
 
 
31
Example
 
32
-------
 
33
 
 
34
```
 
35
@localsize 32, 1, 1
 
36
@buf 32  ; g[0]
 
37
@const(c0.x)  0.0, 0.0, 0.0, 0.0
 
38
@const(c1.x)  1.0, 2.0, 3.0, 4.0
 
39
@wgid(r48.x)        ; r48.xyz
 
40
@invocationid(r0.x) ; r0.xyz
 
41
@numwg(c2.x)        ; c2.xyz
 
42
mov.u32u32 r0.y, r0.x
 
43
(rpt5)nop
 
44
stib.untyped.1d.u32.1 g[0] + r0.y, r0.x
 
45
end
 
46
nop
 
47
```
 
48
 
 
49
Usage
 
50
-----
 
51
 
 
52
```
 
53
cat myshader.asm | ./computerator --disasm --groups=4,4,4
 
54
```
 
55