Closed mysterymath closed 11 months ago
@asiekierka , @jroweboy , @johnwbyrd, PTAL!
Closes #185
This is a good and useful library. When convenient, just because I suspect that SoA type transformations will seem alien to the old-school 6502 community and to Joe Programmer, you may wish to put in a readme.md file that describes why it's important and useful for generating fast code on the 6502.
This is a good and useful library. When convenient, just because I suspect that SoA type transformations will seem alien to the old-school 6502 community and to Joe Programmer, you may wish to put in a readme.md file that describes why it's important and useful for generating fast code on the 6502.
That's a good idea; I've modified the doc comment for the main class to include a broader introduction to the idea and why one would do this. That helps motivate everything about the library's syntax and semantics, so it's important that it's understood going in.
This adds two new types to the SDK under
soa.h
:soa::Array<T, s>
is an array ofT
of sizes
, but where the k'th byte of eachT
are stored contiguously.soa::Ptr<T>
is a pointer to an element ofsoa::Array
.The include-eable
soa-struct.h
specializessoa::Ptr<T>
for a struct type, including its members as distinctsoa::Ptr<T>
instances that point to the members.Using this library allows global arrays of structs to be accessed using the absolute indexed addressing mode if it's always known at compile-time what portion of the struct is being accessed. This is generally true if there are no pointers into the array; in that common case, using this library can produce a huge speedup.
See the included example for more details; the library is quite expansive in practice, so the examples walk through what you can and can't do with it.