gpt4 book ai didi

graphics - 从计算着色器访问帧缓冲区

转载 作者:行者123 更新时间:2023-11-29 08:27:01 26 4
gpt4 key购买 nike

我有一个渲染图像的计算着色器。图像基本上是一个完成的框架。

我想在屏幕上渲染所述图像。最明显的方法是不渲染到这个图像,而是直接渲染到 frambuffer。然而,有人告诉我,这需要在帧缓冲区上设置 storage 位,而在我的机器上并非如此。

下一个最好的办法是将图像复制到帧缓冲区。这需要在帧缓冲区图像上设置 target 位,幸运的是我的机器恰好是这种情况。

但是,当我尝试复制到帧缓冲区时,Vulkan 给出访问错误,说帧缓冲区未初始化。

AccessError {
error: ImageNotInitialized { requested: PresentSrc },
command_name: "vkCmdCopyImage",
command_param: "destination", command_offset: 4
}

如果重要的话,我正在使用 Rust bindings到伏尔甘。代码非常庞大,整个内容都可以在 GitLab 上找到。 .命令缓冲区创建如下:

let command_buffer = AutoCommandBufferBuilder::new(queue.device().clone(), queue.family())?
.clear_color_image(image.clone(), ClearValue::Float([1.0, 0.0, 0.0, 1.0]))?
.dispatch(
[(WIDTH / 16) as u32, (HEIGHT / 16) as u32, 1],
compute_pipeline.clone(),
set.clone(),
(),
)?
.copy_image(
image.clone(),
[0, 0, 0],
0,
0,
render_manager.images[next_image_index].clone(),
[0, 0, 0],
0,
0,
[WIDTH as u32, HEIGHT as u32, 1],
1,
)?
.build()?;

我知道我可以只在图像上渲染一个四边形,这就是我现在正在做的,但它有很多笨重的代码,并没有做太多事情。

最佳答案

doc关于 ImageNotInitialized 的说法:

Trying to use an image without transitionning it from the "undefined" or "preinitialized" layouts first.

关于graphics - 从计算着色器访问帧缓冲区,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49599624/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com