You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Manual.md
+29-10Lines changed: 29 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,8 +28,6 @@ Procedures are delimited using the `.proc` and `.end` directives. E.g.
28
28
.end
29
29
```
30
30
31
-
A valid PICA200 shader must contain a `main` procedure.
32
-
33
31
Instructions consist of an opcode name and a comma-delimited list of arguments.
34
32
35
33
Directives are special statements that start with a period and control certain aspects of `picasso`'s code emission; such as defining procedures, uniforms, constants and more.
@@ -43,7 +41,7 @@ PICA200 registers are often used as arguments to instructions. There exist the f
43
41
-`i0` through `i3`: Integer vector uniforms (special purpose).
44
42
-`b0` through `b15`: Boolean uniforms (special purpose).
45
43
46
-
All registers contain 32-bit floating point vectors; except for integer vector uniforms (containing 8-bit integers) and boolean uniforms. Vectors have 4 components: x, y, z and w. Uniforms are special registers that are writable by the CPU; thus they are used to pass configuration parameters to the shader such as transformation matrices. Sometimes they are preloaded with constant values that may be used in the logic of the shader.
44
+
All registers contain floating point vectors (it is currently unknown whether they are 24-bit or 32-bit); except for integer vector uniforms (containing 8-bit integers) and boolean uniforms. Vectors have 4 components: x, y, z and w. Uniforms are special registers that are writable by the CPU; thus they are used to pass configuration parameters to the shader such as transformation matrices. Sometimes they are preloaded with constant values that may be used in the logic of the shader.
47
45
48
46
In most situations, vectors may be [swizzled](http://en.wikipedia.org/wiki/Swizzling_%28computer_graphics%29), that is; their components may be rearranged. Register arguments support specifying a swizzling mask: `r0.wwxy`. The swizzling mask usually has 4 components (but not more), if it has less the last component is repeated to fill the mask. The default mask applied to registers is `xyzw`; that is, identity (no effect).
49
47
@@ -57,6 +55,12 @@ Some source operands of instructions (called SRC1) support relative addressing.
57
55
58
56
Normal floating-point vector registers may also be negated by prepending a minus sign before it, e.g. `-r2` or `-someArray[lcnt+2]`.
59
57
58
+
## Linking Model
59
+
60
+
`picasso` takes one or more source code files, and assembles them into a single `.shbin` file. A DVLE object is generated for each source code file, unless the `.nodvle` directive is used (see below). Procedures are shared amongst all source code files, and they may be defined and called wherever. Uniform space is also shared, that is, if two source code files declare the same uniform, they are assigned the same location. Constants however are not shared, and the same space is reused for the constants of each DVLE. Outputs and aliases are necessarily not shared either.
61
+
62
+
The entry point of a DVLE may be set with the `.entry` directive. If this directive is not used, `main` is assumed as the entrypoint.
63
+
60
64
## Supported Directives
61
65
62
66
### .proc
@@ -147,6 +151,8 @@ Allocates a new output register, wires it to a certain output property and creat
147
151
-`7`: Under investigation.
148
152
-`view`: Under investigation.
149
153
154
+
The properties also accept an output mask, e.g. `texcoord0.xy`.
155
+
150
156
Example:
151
157
152
158
```
@@ -155,6 +161,18 @@ Example:
155
161
.out outTex texcoord0
156
162
```
157
163
164
+
### .entry
165
+
```
166
+
.entry procedureName
167
+
```
168
+
Specifies the name of the procedure to use as the entrypoint of the current DVLE. If this directive is not used, `main` is assumed.
169
+
170
+
### .nodvle
171
+
```
172
+
.nodvle
173
+
```
174
+
This directive tells `picasso` not to generate a DVLE for the source code file that is being processed. This allows for writing files that contain shared procedures to be used by other files.
175
+
158
176
## Supported Instructions
159
177
160
178
See [Shader Instruction Set](http://3dbrew.org/wiki/Shader_Instruction_Set) for more details.
@@ -174,9 +192,6 @@ Syntax | Description
174
192
`slt rDest, rSrc1, rSrc2` |
175
193
`max rDest, rSrc1, rSrc2` |
176
194
`min rDest, rSrc1, rSrc2` |
177
-
`dphi rDest, rSrc2, rSrc1` |
178
-
`sgei rDest, rSrc2, rSrc1` |
179
-
`slti rDest, rSrc2, rSrc1` |
180
195
`ex2 rDest, rSrc1` |
181
196
`lg2 rDest, rSrc1` |
182
197
`ex2 rDest, rSrc1` |
@@ -195,14 +210,18 @@ Syntax | Description
195
210
`callu bReg, procName` |
196
211
`ifu bReg` |
197
212
`jmpu bReg, labelName` |
198
-
`madi rDest, rSrc1, rSrc2, rSrc1` |
199
-
`mad rDest, rSrc1, rSrc1, rSrc2` |
213
+
`mad rDest, rSrc1, rSrc2, rSrc3` |
200
214
201
215
### Description of operands
202
216
203
217
-`rDest`: Represents a destination operand (register).
204
-
-`rSrc1`: Represents a so-called SRC1 source operand (register), which allows accessing floating-point vector uniforms and relative addressing.
205
-
-`rSrc2`: Represents a so-called SRC2 source operand (register), which is limited to input and scratch registers.
218
+
-`rSrc1`/`rSrc2`/`rSrc3`: Represents a source operand (register). Depending on the position, some registers may be supported and some may not.
219
+
- Narrow source operands are limited to input and scratch registers.
220
+
- Wide source operands also support floating-point vector uniforms and relative addressing.
221
+
- In instructions that take one source operand, it is always wide.
222
+
- In instructions that take two source operands, the first is wide and the second is narrow.
223
+
- `dph`/`sge`/`slt` have a special form where the first operand is narrow and the second is wide. This usage is detected automatically by `picasso`.
224
+
- `mad`, which takes three source operands, has two forms: the first is wide-wide-narrow, and the second is wide-narrow-wide. This is also detected automatically.
206
225
-`iReg`: Represents an integer vector uniform source operand.
207
226
-`bReg`: Represents a boolean uniform source operand.
0 commit comments