Estou tentando entrar no Vulkan, mas estou tendo alguns problemas. Meu aplicativo ( repositório GitHub ) deve renderizar um triângulo vermelho no centro da tela. No entanto, cada vez que o executo, obtenho um de cinco resultados diferentes em vez da saída esperada.
Parece que há vários erros de camada de validação relacionados à criação do pipeline. Suspeito que essa seja a causa raiz, mas não tenho certeza por onde começar.
Estou usando 6.13.6-arch1-1. Minha placa de vídeo é Intel Corporation TigerLake-LP GT2 [Iris Xe Graphics]. É uma placa de vídeo integrada.
O erro definitivamente acontece aqui:
void App::drawFrame()
{
uint32_t imageIndex;
auto result = tveSwapChain.acquireNextImage(&imageIndex);
if(result != VK_SUCCESS && result != VK_SUBOPTIMAL_KHR)
{
throw std::runtime_error("Failed to acquire swap chain image");
}
result = tveSwapChain.submitCommandBuffers(&commandBuffers[imageIndex], &imageIndex);
if(result != VK_SUCCESS)
{
throw std::runtime_error("Failed to present swap chain image");
}
}
Ou aqui:
void TvePipeline::createGraphicsPipeline(const TveDevice &device, const std::string &vertFilepath,
const std::string &fragFilepath, const PipelineConfigInfo &configInfo)
{
assert(configInfo.pipelineLayout != VK_NULL_HANDLE &&
"Cannot create graphics pipeline: no pipelineLayout provided in configInfo.");
assert(configInfo.renderPass != VK_NULL_HANDLE &&
"Cannot create graphics pipeline: no renderPass provided in configInfo.");
auto vertCode = readFile(vertFilepath);
auto fragCode = readFile(fragFilepath);
createShaderModule(vertCode, &vertShaderModule);
createShaderModule(fragCode, &fragShaderModule);
VkPipelineShaderStageCreateInfo shaderStages[2];
shaderStages[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT;
shaderStages[0].module = vertShaderModule;
shaderStages[0].pName = "main";
shaderStages[0].flags = 0;
shaderStages[0].pNext = nullptr;
shaderStages[0].pSpecializationInfo = nullptr;
shaderStages[1].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
shaderStages[1].stage = VK_SHADER_STAGE_FRAGMENT_BIT;
shaderStages[1].module = fragShaderModule;
shaderStages[1].pName = "main";
shaderStages[1].flags = 0;
shaderStages[1].pNext = nullptr;
shaderStages[1].pSpecializationInfo = nullptr;
VkPipelineVertexInputStateCreateInfo vertexInputInfo{};
vertexInputInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
vertexInputInfo.vertexAttributeDescriptionCount = 0;
vertexInputInfo.vertexBindingDescriptionCount = 0;
vertexInputInfo.pVertexAttributeDescriptions = nullptr;
vertexInputInfo.pVertexBindingDescriptions = nullptr;
VkPipelineViewportStateCreateInfo viewportInfo{};
viewportInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
viewportInfo.viewportCount = 1;
viewportInfo.pViewports = &configInfo.viewport;
viewportInfo.scissorCount = 1;
viewportInfo.pScissors = &configInfo.scissor;
VkGraphicsPipelineCreateInfo pipelineInfo;
pipelineInfo.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
pipelineInfo.stageCount = 2;
pipelineInfo.pStages = shaderStages;
pipelineInfo.pVertexInputState = &vertexInputInfo;
pipelineInfo.pInputAssemblyState = &configInfo.inputAssemblyInfo;
pipelineInfo.pViewportState = &viewportInfo;
pipelineInfo.pRasterizationState = &configInfo.rasterizationInfo;
pipelineInfo.pMultisampleState = &configInfo.multisampleInfo;
pipelineInfo.pColorBlendState = &configInfo.colorBlendInfo;
pipelineInfo.pDepthStencilState = &configInfo.depthStencilInfo;
pipelineInfo.pDynamicState = nullptr;
pipelineInfo.layout = configInfo.pipelineLayout;
pipelineInfo.renderPass = configInfo.renderPass;
pipelineInfo.subpass = configInfo.subpass;
pipelineInfo.basePipelineIndex = -1;
pipelineInfo.basePipelineHandle = VK_NULL_HANDLE;
if (vkCreateGraphicsPipelines(tveDevice.device(), VK_NULL_HANDLE, 1, &pipelineInfo, nullptr, &graphicsPipeline) !=
VK_SUCCESS)
{
throw std::runtime_error("Failed to create graphics pipeline");
}
}