calculate serialized size and actually serialize in two separate calls #614
-
Is there a way to calculate the size of the buffer you'll be serializing to (so that you allocate the memory and not the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
There is no function for that but it would not be difficult to write one for libktx. There are a couple of wrinkles preventing it being easy outside the library. There isn't any way to get the supercompressionGlobalData byte length from a ktxTexture2 object (only needed for textures compressed with BasisLZ/ETC1S). The internal hashlist has to be traversed to calculated the length of the key-value data. I'd happily accept a PR to add such a function to libktx. An alternative is to add a variant of Which is better for your situation? |
Beta Was this translation helpful? Give feedback.
There is no function for that but it would not be difficult to write one for libktx. There are a couple of wrinkles preventing it being easy outside the library. There isn't any way to get the supercompressionGlobalData byte length from a ktxTexture2 object (only needed for textures compressed with BasisLZ/ETC1S). The internal hashlist has to be traversed to calculated the length of the key-value data.
I'd happily accept a PR to add such a function to libktx.
An alternative is to add a variant of
ktxTexture2_WriteToMemory
that lets you provide a pointer to a memory allocator.Which is better for your situation?