AgonConsole8 / agon-vdp

Official Firmware for the Agon Console8: ESP32 VDP
MIT License
38 stars 17 forks source link

Plot command data read in one go #162

Closed movievertigo closed 6 months ago

movievertigo commented 7 months ago

The 5 bytes of data following a plot command (VDU 25) are now read in in one go instead of reading 1 byte and 2 words. In my test-bed where I'm plotting a lot of triangles (in a strip formation), this improves the number of triangles I can render at 30FPS from 232 to 250 (An 7.75% improvement in speed)

stevesims commented 7 months ago

this change is really nice and simple - very cool - it'll definitely get merged into the next release

I'm tempted to trawl thru the rest of the code and make similar changes, but conversely changing other places to use similar techniques would likely to result in much less significant improvements

one place that could use readIntoBuffer instead of building on top of readByte_t is readWord_t and read24_t - as they are only combining 2 or 3 byte reads, and readIntoBuffer is somewhat more complex, it's tricky to know whether changing those would be worthwhile

I also wonder if perhaps the use of millis is slower than the lower-level xTaskGetTickCountFromISR() that readIntoBuffer uses, and if that's part of the performance difference

all rather tricky to know :grin:

probably all worthy of experimentation though

stevesims commented 7 months ago

ok - my experimentations and investigations have shown that the base underlying readByte_t function we have, which is doing it's own timeout, is unnecessarily complex. the underlying comms stream object already has its own timeout system in place...

rewriting the comms system to just use the underlying timeout mechanism and removing the additional (redundant) timeout system that's been layered on top of it, results in performance that's even faster than this experiment.

with rewritten comms functions that just make use of the underlying comms timeouts, the triangle-test program for me is delivering 20fps with 333 triangles active. (dropping the triangles to around 144 delivers a smooth 60fps - at a few more triangles than that you get the occasional jitter). if I add in the changes from this PR that drops down to around 310 triangles.

it seems this isn't the way to go after all :grin:

movievertigo commented 6 months ago

No worries, sounds like the other improvements have made this one redundant! I'll close it up