GPU/Shader Instruction Set: Difference between revisions

Merry (talk | contribs)
m clarified constant
Flacs (talk | contribs)
added description of control flow behavior (wrote this text at 34C3, not sure why I didn't post it at the time, it would be good if someone could independently verify it all)
Line 897: Line 897:


1.0 can be multiplied 63 times by 0.5 until the result compares equal zero. This is consistent with a 7-bit exponent and output subnormal flushing.
1.0 can be multiplied 63 times by 0.5 until the result compares equal zero. This is consistent with a 7-bit exponent and output subnormal flushing.
== Control Flow ==
Control flow is implemented using three independent stacks: an 8-deep IF stack, a 4-deep CALL stack, and a 4-deep LOOP stack. All stacks are initially empty. After every instruction, the stacks are checked in the order CALL->IF->LOOP and if a stack is popped, the program counter update overwrites any previous update, even if set by a JMP instruction. The IF/LOOP stacks can only pop one entry per instruction, whereas the CALL stack can be completely emptied. If the CALL stack is popped four times in a single instruction, the last program counter update is missed. Executing a BREAK on an empty LOOP stack hangs the GPU. The stacks are actually ring buffers: overflow overwrites the oldest entry, the stack size is clamped.