chp wrote:Ah, one thing I can think of that should be considered is how you can declare a temporary usage of a matrix, instead of persistant usage. For example GUM uses matrix 0, 1 and 2 as temporaries, but using this interface I cannot flag them without having them stored when it switches context.
That should be simple to do. I thought about it, but I didn't want to complicate the API (not that it would, much). Something like
Code: Select all
void pspvfpu_discardmats(struct pspvfpu_context *c, unsigned matrixset)
, to be called once you've finished with a matrix.
The other thing we could consider is defining an ABI for the VFPU, with conventions something like (roughly):
- Matrix 0 - scratch, never preserved or restored
- Matrix 1 - VFPU function first arg(?) and return
- Matrix 2+3 - VFPU function args 2,3
- Matrix 4-7 - general use, must be context switched by libvfpu
This would allow general purpose VFPU functions which could be used in a number of situations, so everyone wanting to use the VFPU doesn't need to roll their own inline assembler, and doesn't need to keep transferring stuff into and out of either FP registers or memory.
There's at least one problem with converting libgum_vfpu to use libvfpu; you need to call pspvfpu_createcontext() in every thread which starts using libgum as part of the initializer. This requires testing in every gum function whether the context has been created for this thread, and doing it if not.
The real problem is the lack of any kind of thread-local storage model. I think the ideal API would require the creation of a single VFPU context for a particular user/library, which would internally have thread-local VFPU register state so that you can have multithreaded VFPU users.
But of course, libgum (and PSPGL) are strictly single-threaded anyway, so there isn't much practical problem yet. (Though using the VFPU would mean that they're really single-threaded - they must be used from a particular thread, rather than simple wrapping them in a mutex and only allowing one thread at a time in the code).