Rust Vulkano 如何重用命令缓冲区

问题描述

我已经为每帧预先计算了一个命令缓冲区,现在我想循环提交它们。到目前为止我有这段代码

let command_buffer = &command_buffers[image_num];
let future = prevIoUs_frame_end
    .take()
    .unwrap()
    .join(acquire_future)
    .then_execute(queue.clone(),command_buffer)
    .unwrap()
    .then_swapchain_present(queue.clone(),swapchain.clone(),image_num)
    .then_signal_fence_and_flush();

然而这会产生

                       let command_buffer = &command_buffers[image_num];
    |                                       ^^^^^^^^^^^^^^^
    = note: but,the lifetime must be valid for the static lifetime...
note: ...so that the type `&PrimaryAutoCommandBuffer` will meet its required lifetime bounds
   --> src\main.rs:442:22
    |
442 |                     .then_execute(queue.clone(),command_buffer)

我可以看到该函数需要静态生命周期

    fn then_execute<Cb>(
        self,queue: Arc<Queue>,command_buffer: Cb,) -> Result<CommandBufferExecFuture<Self,Cb>,CommandBufferExecError>
    where
        Self: Sized,Cb: PrimaryCommandBuffer + 'static,

也许我应该像这里那样克隆这个缓冲区

https://github.com/bwasty/vulkan-tutorial-rs/blob/f2f6935914bec4e79937b8cac415683c9fbadcb1/src/bin/15_hello_triangle.rs#L523

但是,在版本 vulkano = "0.24.0" 中不再为 PrimaryCommandBuffer 实施克隆

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)