I'm looking for some memory/performance advice on which approach is better.
If lets say i have 4 attributes for an mesh
Vertex 3f
Normal 3f
TexCoords 2f
jointID 4i [Integer Joint Indices For Skeleton Animation]
And i need these in cpu memory as they can be modified anytime
Is it better to
a.Create 4 seperate buffers for each component
//3,2,4 are the strides i.e vertex is 3 floats,texCoord is 2 floats so on
FloatBuffer vertices=BufferUtils.createFloatBuffer(numOfVertices*3);
FloatBuffer normals=BufferUtils.createFloatBuffer(numOfVertices*3);
FloatBuffer texCoords=BufferUtils.createFloatBuffer(numOfVertices*2);
IntBuffer vertexJoints=BufferUtils.createIntBuffer(numOfVertices*4);
Or
b.Create a large bytebuffer with enough capacity to store all 4 attributes and create seperate Float/Int Buffer Views for each of the attributes
ByteBuffer meshData=BufferUtils.createByteBuffer(((numOfVertices*3)+(numOfVertices*3)+(numOfVertices*2)+(numOfVertices*4))*4); //*4 because both float/int is 4 bytes
FloatBuffer vertices=meshData.position(0).limit(endVertexByte).asFloatBuffer();
FloatBuffer normals=meshData.position(endVertexByte).limit(endNormalByte).asFloatBuffer();
FloatBuffer texCoords=meshData.position(endNormalByte).limit(endTexCoordByte).asFloatBuffer();
IntBuffer jointIDs=meshData.position(endTexCoordByte).limit(endJointIndexByte or end of buffer in this case).asIntBuffer();
From the docs all of BufferUtils methods create's an directBuffer which is stored in native memory, and all though the 2nd approach create an buffer larger[since we multiply by 4] than all the individual attribute buffers combined , It creates only one large native memory chunk compared to 4 seperate memory areas in the first approach.
But that's just my opinion, thoughts?