vulkano-rs/vulkano

Persistent Descriptor Set Usage

matt328 opened this issue · 1 comments

Are these really intended to be new()ed every frame like in the examples? In my profiler I'm seeing that call make 3 allocations that are never freed until the program exits, and memory usage increases indefinitely. I suspect I'm doing something wrong with buffer handling since the deferred example does this each frame and doesn't leak memory.

This is how I'm creating the descriptor set each frame:

let p = PersistentDescriptorSet::new(
    &self.descriptor_set_allocator,
    self.pipeline.layout().set_layouts()[1].clone(),
    [WriteDescriptorSet::buffer(0, object_data_buffer)],
    [],
)

And this is how I'm setting up the object_data_buffer:

let object_data_buffer = self
    .buffer_allocator
    .allocate_slice(self.object_data.len() as _)?;
object_data_buffer
    .write()?
    .copy_from_slice(&self.object_data);

self.object_data is a Vec<ObjectData> where ObjectData is the type that's reflected from the shader module.

I want object_data to be possibly a different length each frame. In reality I'd batch things so it doesn't change every frame, but I'm having a hard time determining how to bind variable length arrays of data into buffers and descriptor sets.

https://vkguide.dev/docs/chapter-4/storage_buffers/ is the technique I'm trying to implement with each object's data in a single buffer, referenced in the vertex shader by gl_BaseInstance.

If all of this usage looks ok, I can attach a Tracy Profiler trace file if that would be useful.

  • Version of vulkano: 0.34.0
  • OS: Windows 10
  • GPU Nvidia RTX 3060

Sorry, I realized I had larger issues and vulkano is not to blame here.