Reading and writing vectors to buffers #1296
Replies: 5 comments 2 replies
-
For motivation I wrote a quick experiment which shows 40% improvement between these two versions:
poc_writef32x3 is implemented using the C API, so a proper implementation should be even faster with a fastcall built-in in the VM. |
Beta Was this translation helpful? Give feedback.
-
Embedders are free to extend the available functions in the environment as they see fit. Every potential combination of operations can be rewritten as a specific C library call (or even a fastcall) and will be faster just by nature of the VM having overhead. While developers on some Luau platforms are limited in what functions they get, other embedders can choose to provide what they need to achieve their performance goals. So no, we are unlikely to add the operations you propose. I would even say your suggestions don't even make sense to involve vectors. One operation that I do expect is maybe readvector/writevector that reads or writes the whole vector. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the answer. I think I explained the rationale poorly. The naming of the existing buffer API in general seems to specify the storage type (as opposed to source data type). E.g.
(Side note:
In this context, I think I also considered an API with multiple values but it has major downsides so I discarded the idea:
Ultimately the decision is of course yours, but hopefully this makes sense. I'm available for writing a RFC and/or implementing the feature if it seems likely we could find a compromise. |
Beta Was this translation helpful? Give feedback.
-
This is an API combinatorial explosion and the goal is to NOT add more variants.
Internal vector type is not going to change.
Can be solved by other means like the one I mentioned with readvector3/4.
I do not support such view.
I don't think it's a valuable effort given what seems to be a fundamental disagreement on the design in this discussion. |
Beta Was this translation helpful? Give feedback.
-
Alright, thanks for your time. |
Beta Was this translation helpful? Give feedback.
-
Hi! We're currently in the process of taking the (fairly) new buffer type into use. It's great but sometimes we'd like to read/write vectors to buffers with a single call. A typical case is vertex data with 2 to 4 floats per element. I'm wondering has it been considered to extend the api to support vectors? E.g.
When reading vectors, extra/unused components would be filled with zero.
readf32x4 and writef32x4 would be only available when Luau is compiled with LUA_VEC_SIZE 4.
In addition to being convenient, I believe these would be significantly faster than separate calls and converting back & forth between scalars and vectors, although it would require benchmarking.
Thoughts?
Beta Was this translation helpful? Give feedback.
All reactions