1. We need to ba able to incorporate offsets in a buffer as a start address without slicing. Interleaved vertex formats are an example of this.
Agreed. That's a problem and we need a clean solution, that doesn't create any new objects (slicing)...
2. The gain in stability and security is not that big after all. You can still easily wander off the end of a buffer.
3. Packing buffers in yet another MemoryBuffer (or something) with a cached address will only make the overhead of a buffer even higher. I might want to sacrifice a little performance for the ability to use java buffers directly and not through a proxy.
We sure need some kind of wrapping. Bounds checking can be easily added this way, for even higher security. Besides, I believe most of us use some kind of custom object that holds a ByteBuffer and its address. I use such an object all the time and found it really easy to use.
... And because this is a fairly important and large part of the LWJGL api, please post your best decision here before implementing it.
Totally agreed. We should get a preview of the new API, before releasing anything, so that we can comment on it. We should make the desicion together.
About performance: Even if the overhead was higher (which isn't), GL methods that take a pointer as an argument are called only a few times per frame (usually). So I also believe that performance won't be a problem.
A couple of questions:
- How is
ByteBuffer createDirectBuffer(int address, int length) going to be used? This takes a pointer (address) no matter what. I believe it should be left as is.
- From native code:
(jint) env->GetDirectBufferAddress(buf);This is what adds the 300ns overhead? This would be called everytime we pass a ByteBuffer to a GL method?
OK, my suggestion is to go for a proxy/wrapper, an object from inside the LWJGL API that wraps a ByteBuffer and caches it's address. Make anything that has to do with pointers "LWJGL private", add some bounds check and then some people may stop whining about pointers. And we need a solution about the offsets (as elias pointed out). Anyway, whatever you decide to do, post it here first!