-
Notifications
You must be signed in to change notification settings - Fork 221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Obtaining slices of primitive and struct lists #97
Comments
capnproto-c++ has These should be straightforward to port to capnproto-rust. I'm not sure when I'll have time to add them, but maybe you'd like to give it a go? I think maybe the hardest part will be working out how the traits should fit together to allow e.g. an |
That's correct as long as the messages are constructed with the same version of the schema that you're using to read them. Messages from a newer version of the schema (perhaps with |
I'll tinker with it, thanks! A reasonable model for the API is about what I needed to get started.
Yeah, what I'd really like here is a way to express a flat, inextensible struct type like flatbuffers has. This would also make much of my schema considerably more concise, as I wouldn't have to manually inline vectors/matrices/quaternions/etc every time they arise. In lieu of capnp growing such a feature, this'll have to do. |
I'm planning to implement this. Is there any tricky part that I should take care of? Please let me know. |
Actually, my intent of obtaining slices of structs, is to use the However, it seems that @Ralith has a stricter requirement on data layout? I'm not sure what type of slice you're expecting here. You wrote |
I meant what I said. Graphics APIs consume untyped data; the API can't very well statically know the type signatures of your shaders. |
f76c02c adds a new Additionally, we could do something similar with |
I've pushed 6683d7a, which adds the functionality in a new module named Upon further reflection (see capnproto/capnproto#770 (comment)) I decided that |
That looks perfect, thanks! |
I'm trying to use capnp to represent geometry for upload to a GPU. I want to decompress data from disk into a driver-supplied staging buffer, and then submit transfer commands to asynchronously DMA the data of interest directly into GPU memory. The data is formatted as a capnp struct containing a
List(UInt16)
and aList(Vertex)
whereVertex
contains nothing butFloat32
fields.It's my understanding that both of these lists are guaranteed to be laid out in a GPU-friendly way (i.e. dense and contiguous) and can therefore be used directly once copied, but the generated API forces me to instead decompress to CPU memory, then painstakingly copy each element to the staging buffer by hand. Some way to get a
&[u8]
of any struct or primitive list would allow for greater efficiency. For now I'm working around the issue by usingData
instead of the list types, but this represents an undesired weakening of the schema.The text was updated successfully, but these errors were encountered: