Skip to content
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

gltf interop #18

Open
o1lo01ol1o opened this issue Dec 4, 2018 · 4 comments
Open

gltf interop #18

o1lo01ol1o opened this issue Dec 4, 2018 · 4 comments

Comments

@o1lo01ol1o
Copy link
Contributor

Hi,

I recently started a library to load assets from the gltf spec (here) with the aim of being able to efficiently get assets and animations to the vulkan api (using this c++ project as a reference).

I wondered if you could provide some advice: If I have a buffer or raw binary vertex data (ie, a Mesh) parsed as a little endian ByteString, some accessors telling me what components this buffer represents, the number of bytes per component, the stride, etc, what's the best way to get that geometry into a form that I can get to vkVertexBuffer efficiently?

I've looked at the DataFrame PrimBytes instance but I'm not exactly sure where to start as the easytensor vulkan-api design goals are not totally clear to me.

Thanks!

@achirkin
Copy link
Owner

achirkin commented Dec 5, 2018

In the simplest case, if you have raw bytes packed in a vector or a bytestring and a description of the attributes layout, you don't even need to process the content of the data. Just specify the layout similar to Lib/Vulkan/Vertex.hs way and copy the content of the vector as in Lib/Vulkan/VertexBuffer.hs. You just need a pointer to the raw data; for example, if you use vanilla bytestrings, then Data.ByteString.Unsafe.unsafeUseAsCStringLen is a way to go.

The easytensor-vulkan library is totally optional. I want to use easytensor for all matrix math in my future vulkan projects, so this library serves for compatibility. PrimBytes is an interface for fast packing of data; in vulkan-triangles, I use it to store arrays of plain haskell Vertex data types as interleaved vulkan buffers.
Next months I will be intensely working on easytensor to make it more user-friendly and, in particular, automate things like creating VkVertexInputAttributeDescription for a data type. Beware, I will change the interface of PrimBytes soon, maybe even spit it into a separate package.

@o1lo01ol1o
Copy link
Contributor Author

Great, that's helpful, thanks. I'll forgo easytensor integration until it stablizes.

I want to use easytensor for all matrix math in my future vulkan projects

I'm more than a little familiar with the state of (tensor-based) numerics for the Haskell ecosystem, so I have a few answers to this question, but why not something that's backed by BLAS for linear algebra?

@achirkin
Copy link
Owner

achirkin commented Dec 5, 2018

Because I want to implement a Proper pure haskell tensor library in the end :) And in easytensor, I care most of all about a specific performance thing: to implement type family-based overloading of generic data frames with SIMD vectors for graphics-specific cases, such as 4D float vectors and matrices.

@o1lo01ol1o
Copy link
Contributor Author

I'm interested in how you'll handle the SIMD operations, but that's for another thread, I think.

I look forward to its development. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants