I am following vkguide but not exactly. I am struggling getting a triangle to appear. When looking at render doc, it seems the vertices are drawn correctly according the the mesh viewer, but nothing actually ends up being drawn?
I have checked my code against vkguide and everything seems okay, and I don't think I have missed anything.
I have also checked renderdoc to see if the shaders are actually a part of the pipeline, and it seems they are correctly, and each shader seems to be in the correct stage.
Vertex winding order: CCW
Cull mode: None
Triangle mesh in render doc:
Vertex shader:
#pragma shader_stage(vertex)
struct VSOutput {
float4 position: SV_POSITION;
[[vk::location(0)]] float3 out_colour: COLOR0;
};
VSOutput main(uint VertexIndex : SV_VertexID)
{
float3x3 positions = float3x3(
float3(0, -0.5, 0.5),
float3(-0.5, 0.5, 0.5),
float3(0.5, 0.5, 0.5)
);
float3x3 colours = float3x3(
float3(1, 0, 0),
float3(0, 1, 0),
float3(0, 0, 1)
);
VSOutput output;
output.position = float4(positions[VertexIndex], 1.0);
output.out_colour = colours[VertexIndex];
return output;
}
Fragment Shader:
#pragma shader_stage(fragment)
struct FSInput {
[[vk::location(0)]] float3 colour: COLOR0;
};
struct FSOutput {
[[vk::location(0)]] float4 colour: COLOR0;
};
FSOutput main(FSInput input)
{
FSOutput output;
output.colour = float4(input.colour , 1.0);
return output;
}
Command buffer recording
void Engine2D::draw_geometry(vk::CommandBuffer command_buffer) {
auto colour_attachment =
init::attachment_info(swapchain.draw_image.image_view, nullptr,
vk::ImageLayout::eColorAttachmentOptimal);
auto render_info =
init::rendering_info(swapchain.extent, &colour_attachment, nullptr);
command_buffer.beginRendering(&render_info);
command_buffer.bindPipeline(vk::PipelineBindPoint::eGraphics,
triangle_pipeline.pipeline);
auto view_port = vk::Viewport{}
.setX(0)
.setY(0)
.setWidth(swapchain.extent.width)
.setHeight(swapchain.extent.height)
.setMinDepth(0)
.setMaxDepth(1);
command_buffer.setViewport(0, view_port);
auto scissor = vk::Rect2D{}
.setOffset(vk::Offset2D{}.setX(0).setY(0))
.setExtent(swapchain.extent);
command_buffer.setScissor(0, scissor);
command_buffer.draw(3, 1, 0, 0);
command_buffer.endRendering();
}
EDIT: I have tried using the same pipeline settings as vkguide, I checked everything over several times, and used and compiled the same OpenGL shaders as them just to be sure, it made no difference.
EDIT: I have tried changing the shader stage count to different values, this did not help
I managed to solve the issue. I switched to testing the program on my laptop, and a received a validation layer error on it that I did not on my other computer, which hinted at a colour attachment format being undefined. With this information I eventually figured out that I did not add the render attachment info to pNext.
auto pipeline_info = vk::GraphicsPipelineCreateInfo{}
..
.setPNext(&rendering_create_info);