I’ve built multiple renderers with Vulkan, but I have no idea what’s wrong here. I’m using dynamic rendering.
I’ve double checked everything from pipeline creation to draw calls in RenderDoc. I can see the mesh and shaders in RenderDoc and the pipeline should work. I also don’t get any validation errors.
void Render()
Renderer::DrawData drawData;
if (m_Renderer.BeginFrame(drawData)) {
VkViewport viewport {
.x = 0.0f,
.y = 0.0f,
.width = (float)m_Renderer.m_GpuSwapchainExtent.width,
.height = (float)m_Renderer.m_GpuSwapchainExtent.height,
.minDepth = 0.0f,
.maxDepth = 1.0f,
};
VkRect2D scissor {
.offset = { 0, 0 },
.extent = {
m_Renderer.m_GpuSwapchainExtent.width,
m_Renderer.m_GpuSwapchainExtent.height
},
};
vkCmdSetViewport(drawData.commandBuffer, 0, 1, &viewport);
vkCmdSetScissor(drawData.commandBuffer, 0, 1, &scissor);
VkRenderingAttachmentInfo colorAttachment{
.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO,
.pNext = nullptr,
.imageView = drawData.swapchainImageView,
.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
.resolveMode = VK_RESOLVE_MODE_NONE,
.resolveImageView = VK_NULL_HANDLE,
.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR,
.storeOp = VK_ATTACHMENT_STORE_OP_STORE,
.clearValue = { .color { .float32 { 1.0f, 0.0f, 0.0f, 1.0f } } },
};
VkRenderingInfo renderingInfo {
.sType = VK_STRUCTURE_TYPE_RENDERING_INFO,
.pNext = nullptr,
.flags = 0,
.renderArea = scissor,
.layerCount = 1,
.viewMask = 0,
.colorAttachmentCount = 1,
.pColorAttachments = &colorAttachment,
.pDepthAttachment = nullptr,
};
vkCmdBeginRendering(drawData.commandBuffer, &renderingInfo);
CameraData1* cameras[1] = { &m_GameCamera };
for (size_t i = 0; i < 1; i++) {
for (GraphicsPipeline& pipeline : m_GraphicsPipelines) {
vkCmdBindPipeline(drawData.commandBuffer,
VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline.m_GpuPipeline);
for (Entity* entity : pipeline.m_Entites) {
VkDescriptorSet* pDescriptorSets = nullptr;
VkBuffer* pVertexBuffer = nullptr;
VkBuffer* pIndexBuffer = nullptr;
uint32_t meshCount = 0;
MeshData* meshes = nullptr;
entity->RenderUpdate(pipeline, *cameras[i],
pipeline.m_DescriptorSetCount, &pDescriptorSets, meshCount, &meshes);
if (pDescriptorSets) {
vkCmdBindDescriptorSets(drawData.commandBuffer,
VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline.m_GpuPipelineLayout, 0, pipeline.m_DescriptorSetCount, pDescriptorSets, 0, nullptr);
}
if (meshCount && !meshes) {
continue;
}
for (uint32_t j = 0; j < meshCount; j++) {
vkCmdBindVertexBuffers(drawData.commandBuffer, 0, meshes[j].vertexBufferCount, meshes[j].vertexBuffers, meshes[j].vertexBufferOffsets);
vkCmdBindIndexBuffer(drawData.commandBuffer, meshes[j].indexBuffer, 0, VK_INDEX_TYPE_UINT32);
vkCmdDrawIndexed(drawData.commandBuffer, 3, 1, 0, 0, 0);
}
}
}
}
vkCmdEndRendering(drawData.commandBuffer);
m_Renderer.EndFrame();
}
}
I’ve also turned of face culling and depth goes from 0 to 1 everywhere.
New contributor
Einari Mäkiranta is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.