#DynamicBuffer serialization and deserialization

1 messages · Page 1 of 1 (latest)

dire blade
#

I'm trying to serialize and deserialize a dynamic buffer of unknown at compile time type.

I'm getting confused at how do I modify capacity of given dynamic buffer on entity.

componentPtr = (byte*)EntityManager.GetComponentDataRaw(entity, componentInfo.resolvedType);
var headerPtr = (BufferHeader*)componentPtr;

So I have a BufferHeader.
Then as I assume my next step is just BufferHeader.EnsureCapacity method. But it requires alignment value, which by default is UnsafeUtility.AlignOf<T> where I don't have T.
How am I supposed to obtain this alignment value?
TypeManager.TypeInfo contains AlignmentInBytes and AlignmentInChunkBytes and it's unclear which should I read.

midnight glacier
#

You could just check my save library actually public version is a bit out of date

#

If I recall this alignment used to be hard coded

#

I think they store it inside the dynamic buffer now

#

So just check where it's got from

dire blade
#

huh

#

so there is built in method for that

#

ok

midnight glacier
#

I should say I wrote a few untyped dynamic buffer accessor stuff in core because if I recall a few things were missing that I needed access to

dire blade
#

nah, that won't be much help

#

I need to implement my own caching solution

#

probably in chunk component

midnight glacier
#

I'm just saying there is a chance what you want to do with the dynamic handles isn't actually possible by default

dire blade
#

I don't even use those 😅

#

I'm literally accessing data with raw pointers

#

I even obtain type index in archetype myself

#

so I can cache it

#

and reuse

midnight glacier
#

Odd, the dynamic handle stuff just does this all for you

dire blade
#

well, performance is a concern for this case

#

that's why I can't afford scheduling jobs left and right

#

and neither I know amount of type handles I need beforehand

#

so I just have giga dependency in system and schedule god job to do it all

midnight glacier
#

Either way it has all these methods implemented so seems to be the place to check?

dire blade
#

dw, I already implemented most of it. Just wasn't sure about this align value

#

but since Unity has built in method to resize