vulkano-rs / vulkano

Safe and rich Rust wrapper around the Vulkan API
Apache License 2.0
4.48k stars 433 forks source link

SubbufferAllocator Question #2426

Closed matt328 closed 9 months ago

matt328 commented 9 months ago

If I'm using subbuffer allocator to 'allocate' a buffer each frame, how do I bind that buffer to a descriptor set? I want to bind a different buffer each frame since it's a single large buffer that holds an array of all of my objects' transforms, and for right now, I'm trying to issue multiple draw calls, and using the gl_instanceId in the shader to index into the object data buffer. I could create a descriptor set each frame, but that seems like it would not perform very well. This is just a stopping point on the way to completely gpu driven rendering, but even if I go completely that route, I'll still have a need to bind a buffer of potentially unknown size to a descriptor set layout.

In general how are buffers allocated with SubbufferAllocator supposed to be bound into descriptor sets?

marc0246 commented 9 months ago

The same way you bind any other buffer to a descriptor set, there's nothing special about SubbufferAllocator. If you need to bind different resources each frame (strong emphasis on "if"), then there's no way around writing a descriptor with that new resource. No, it's not inefficient to allocate a fresh set each frame. Allocation is on the order of a couple nanoseconds. If you had a huge descriptor set, which you only wish to update partially, that would be a very different story, and there's a way to update an existing descriptor set in master.