Hard coded blue values are black in my minimal vulkan triangle application

I'm following the guide at vkguide.dev and at the moment I have just a small triangle displaying on my screen. However, it seems that I have messed up something with how colors are represented. When I hardcode the triangle to be blue (fragColor = vec4(0.f, 0.f, 1.f, 1.f) and set the background to red via the ClearValue in my renderpass, my triangle looks like this:

Triangle with black instead of the expected blue with a red background

Another weird behavior is that with a blue background (which works if I use it as a clearValue), my red triangle (fragColor = vec4(1.f, 0.f, 0.f, 1.f) turns into pink:

Pink triangle on blue background

The tutorial I am using recommended the vk-bootstrap library to set up Swapchain-, Device-, Queue- and Vulkan Instance creation, so there might also be a default in there which does not work with my setup. I'm on Linux with the proprietary Nvidia driver, but hopefully none of that is the issue here.


Solution 1:

As noted in the comments: The problem was caused by a wrongly setup pipeline color blend attachment state with a missing bit for the blue channel in the color write mask. This caused the triangle to seemingly change colors depending on the clear color for the render pass.