FibHeap
FibHeap

Reputation: 359

Clear all Layers with vkCmdBeginRenderPass (Vulkan, Layered rendering)

I have a framebuffer with one color attachment, which is a cube map with 6 layers. I try to use layered rendering with the geometry shader. Rendering of a simple triangle to all layers works. But I am not sure how to clear all layers with vkCmdBeginRenderPass.

vkCmdBeginRenderPass supports pClearValues and clearValueCount but I can not specify the number of layers. So only the first layer is cleared. Setting clearValueCount to 6 and giving 6 clear values also does not help.

I saw that vkCmdClearAttachments seems to allow to specify the layers.

Is vkCmdClearAttachments the only way, or did I miss something? Is there maybe a reason that vkCmdBeginRenderPass only clears the first layer although rendering seems to render to all layers?

Upvotes: 0

Views: 905

Answers (1)

Sascha Willems
Sascha Willems

Reputation: 5808

clearValueCount refers to the number of attachments to clear (with regards to their clearOp), not the layers of a framebuffer.

The number of layers to be cleared at the start of a renderpass (if clearOp is set to clear) for a framebuffer is specified via the layerCount of it's imageView's subresource.

Upvotes: 1

Related Questions