-
Notifications
You must be signed in to change notification settings - Fork 0
Optimizations
I've separated optimizations into two "passes".
- First Pass optimizations are available regardless of the selected backend.
- Second Pass optimizations are available depending on your backend.
Note: I plan to introduce a second frontend to make gifscript bidirectional. How this will affect first pass optimizations is unknown at this time.
gifscript is aware of what registers affect state. XYZ2 pushes vertices, SIGNAL and FINISH creates an interrupt, etc.
Consecutive writes to 'stateless' registers such as PRIM will be culled to only emit the last PRIM write.
Possibly in the future some improvements could be introduced that:
- Keep track of PRIM writes and their types and cull ignored XYZ2 writes
- Look ahead past the preceding write
You can disable dead store elimination by passing --keep-deadstore
to gifscript.
The following is an example of deadstore elimination.
- PRIM tristrip;
- PRIM rect;
RGBA 127,127,127;
PRIM point;
XYZ2 1,0,1;
When starting a GIF packet, there is a PRIM (and PRE) field in the GIFTag. This optimization simply takes the first PRIM write and moves it to the GIFTag field. This can save 1 qw per emit block.
This should have no side-effects, but you can disable GIFTag PRIM by passing --no-tag-prim
ti gifscript.
The following is an example of GIFTag PRIM optimization:
draw_block {
prim point;
xyz2 1,0,0;
xyz2 3,0,0;
}
Instead of emitting:
GIFTAG(3,1,0,0,0,1)
SET_PRIM
SET_XYZ2
SET_XYZ2
It will emit:
GIFTAG(2,1,1,SET_PRIM,0,1)
SET_XYZ2
SET_XYZ2
none