So I have a framebuffer image which later acts as input to a compute shader, and some frames there is geometry drawn to the framebuffer, but some frames this is not necessary.
The thing is, in my current process, when I don't draw anything to that framebuffer, the image contents are undefined which leads to incorrect output of my compute shader. So on frames where there is no geometry drawn, I would like to simply clear the framebuffer.
In OpenGL this would be easy: glClearColor(...)
but so far I have not been able to get it working on Vulkan.
I have tried just doing an empty renderpass: i.e: vkCmdBeginRenderPass
/vkCmdEndRenderpass
with the correct clear values defined in the VkRenderPassBeginInfo
struct.
I have also tried doing a renderpass with only vkCmdClearAttachments
between the bein/end commands.
So far I haven't had any luck. What's the best way to accomplish this?