Я следую учебному пособию по программированию на вулканском языке от Александра Оверворде и столкнулся с ошибкой сегментацииЯ уже запустил GDB, чтобы найти ошибку, и вот что я получил:
(gdb) bt
#0 0x00007ffff6201435 in ?? () from /usr/lib/libnvidia-glcore.so.418.43
#1 0x00007ffff6203222 in ?? () from /usr/lib/libnvidia-glcore.so.418.43
#2 0x00007ffff6209f00 in ?? () from /usr/lib/libnvidia-glcore.so.418.43
#3 0x0000555555559848 in VulkanEngine::createGraphicsPipeline (
this=0x7fffffffdc50) at main.cpp:452
#4 0x000055555555b7cc in GameApplication::initVulkan (this=0x7fffffffdc50)
at main.cpp:906
#5 0x000055555555b70e in GameApplication::run (this=0x7fffffffdc50)
at main.cpp:879
#6 0x0000555555557712 in main () at main.cpp:931
Судя по всему, это вина Nvidia, но я не уверен.Если кто-нибудь знает, что мне делать с этим, пожалуйста, дайте мне знать!
ОС: KDE Manjaro 5.0.5,
Плазменная версия 5.15.3,
GPU: дополнительные драйверы GTX 1060 3 ГБ
// Function to create the graphics layout and pipeline
void createGraphicsPipeline(){
// Reading the shaders
auto vertShaderCode = readFile("VertShader"); // the vertex shader
auto fragShaderCode = readFile("FragShader"); // the frag shader
// Proccessing the shaders into modules
VkShaderModule vertShaderModule = createShaderModule(vertShaderCode); // implementing the create shader module function
VkShaderModule fragShaderModule = createShaderModule(fragShaderCode); // implementing the create shader module function
// Prepare the shader stages
VkPipelineShaderStageCreateInfo vertShaderStageInfo = {}; // vertex shader stage info
vertShaderStageInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; // type (self-explanetory)
vertShaderStageInfo.stage = VK_SHADER_STAGE_VERTEX_BIT; // states this is a vertex shader
vertShaderStageInfo.module = vertShaderModule; // states the vertex shader module
vertShaderStageInfo.pName = "main"; // states the shader function to invoke
VkPipelineShaderStageCreateInfo fragShaderStageInfo = {}; // fragment shader stage info
vertShaderStageInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; // type (self-explanetory)
vertShaderStageInfo.stage = VK_SHADER_STAGE_FRAGMENT_BIT; // states this is a fragment shader
vertShaderStageInfo.module = fragShaderModule; // states the frament shader module
vertShaderStageInfo.pName = "main"; // states the funtion to invoke
// Pack the shader stages into an array
VkPipelineShaderStageCreateInfo shaderStages[] = {vertShaderStageInfo, fragShaderStageInfo}; // array that contains the shader stages
// Determin how vertex input is computed
VkPipelineVertexInputStateCreateInfo vertexInputInfo = {};
vertexInputInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
vertexInputInfo.vertexBindingDescriptionCount = 0;
vertexInputInfo.pVertexBindingDescriptions = nullptr;
vertexInputInfo.vertexAttributeDescriptionCount = 0;
vertexInputInfo.pVertexAttributeDescriptions = nullptr;
// Define the input assemblies
VkPipelineInputAssemblyStateCreateInfo inputAssembly = {};
inputAssembly.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
inputAssembly.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
inputAssembly.primitiveRestartEnable = VK_FALSE;
// Define viewport
VkViewport viewport = {};
viewport.x = 0.0f; // viewport horizontal offest
viewport.y = 0.0f; // viewport vertical offset
viewport.width = (float) swapChainExtent.width; // viewport screen width
viewport.height = (float) swapChainExtent.height; // viewport screen height
viewport.minDepth = 0.0f; // viewport minimum alpha depth
viewport.maxDepth = 1.0f; // viewport maximum alpha depth
// Define scissor
VkRect2D scissor = {};
scissor.offset = {0, 0}; // scissor screen offset
scissor.extent = swapChainExtent; // scissor screen size
// Combine viewport and scissor objects into viewport state
VkPipelineViewportStateCreateInfo viewportState = {};
viewportState.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; // the type of struct
viewportState.viewportCount = 1; // the total number of viewports
viewportState.pViewports = &viewport; // the viewport objects
viewportState.scissorCount = 1; // the total amount of scissor filters
viewportState.pScissors = &scissor; // the scissor objects
// Setup the rasterizer info
VkPipelineRasterizationStateCreateInfo rasterizer = {};
rasterizer.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; // the struct type (self-explanitory)
rasterizer.depthClampEnable = VK_FALSE; // whether fragments should be clamped instead of discarded
rasterizer.rasterizerDiscardEnable = VK_FALSE; // whether any geometry should not make it to the frame buffer
rasterizer.polygonMode = VK_POLYGON_MODE_FILL; // the selected polygon render mode
// MODE_FILL: fill all polygons with fragments
// MODE_LINE: only polygon edges are drawn
// MODE_POINT; only polygon points are drawn
rasterizer.lineWidth = 1.0f; // determines the polygon line thickness
rasterizer.cullMode = VK_CULL_MODE_BACK_BIT; // selects the polygon culling method
// BACK_BIT: Culls backward facing polygons
// FRONT_BIT: Culls forward facing polygons
// DISABLED: Disables any culling
rasterizer.frontFace = VK_FRONT_FACE_CLOCKWISE; // the direction to look for front faces
rasterizer.depthBiasEnable = VK_FALSE; // whether the rasterizer can alter depth values
rasterizer.depthBiasConstantFactor = 0.0f; // constant amount to alter
rasterizer.depthBiasClamp = 0.0f; // amount to stop depth altering
rasterizer.depthBiasSlopeFactor = 0.0f; // altering factor amount based on fragment slope
// Setup the multisampling info
VkPipelineMultisampleStateCreateInfo multiSampling = {};
multiSampling.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; // the struct type (self-explanitory)
multiSampling.sampleShadingEnable = VK_FALSE;
multiSampling.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; // sets the amount of samples per pixel
// After 2_BIT, the bit values go up by the power of two's
multiSampling.minSampleShading = 1.0f;
multiSampling.pSampleMask = nullptr; // the multisampling on-off mask
multiSampling.alphaToCoverageEnable = VK_FALSE;
multiSampling.alphaToOneEnable = VK_FALSE;
// Define the color blending attachment
VkPipelineColorBlendAttachmentState colorBlendAttachment = {};
colorBlendAttachment.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT |
VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT;
colorBlendAttachment.blendEnable = VK_FALSE;
// Define the color blending state
VkPipelineColorBlendStateCreateInfo colorBlending = {};
colorBlending.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
colorBlending.logicOpEnable = VK_FALSE;
colorBlending.logicOp = VK_LOGIC_OP_COPY;
colorBlending.attachmentCount = 1;
colorBlending.pAttachments = &colorBlendAttachment;
colorBlending.blendConstants[0] = 0.0f;
colorBlending.blendConstants[1] = 0.0f;
colorBlending.blendConstants[2] = 0.0f;
colorBlending.blendConstants[3] = 0.0f;
// Define the pipeline layout information
VkPipelineLayoutCreateInfo pipelineLayoutInfo = {};
pipelineLayoutInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
pipelineLayoutInfo.setLayoutCount = 0;
pipelineLayoutInfo.pSetLayouts = nullptr;
pipelineLayoutInfo.pushConstantRangeCount = 0;
pipelineLayoutInfo.pPushConstantRanges = nullptr;
if(vkCreatePipelineLayout(device, &pipelineLayoutInfo, nullptr, &pipelineLayout) != VK_SUCCESS){
throw std::runtime_error("Failed the create pipeline layout!");
}else{
std::cout<<"Successfully created pipeline layout!"<<std::endl;
}
// Define the pipeline information
VkGraphicsPipelineCreateInfo pipelineInfo = {};
pipelineInfo.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; // the struct type (self-explanitory)
pipelineInfo.stageCount = 2; // number of the shader stages
pipelineInfo.pStages = shaderStages; // reference to the shader stages array
pipelineInfo.pVertexInputState = &vertexInputInfo; // reference to the vertex input state
pipelineInfo.pInputAssemblyState = &inputAssembly; // reference to the input assembly state
pipelineInfo.pViewportState = &viewportState; // reference to the viewport state
pipelineInfo.pRasterizationState = &rasterizer; // reference to the rasterizer state
pipelineInfo.pMultisampleState = &multiSampling; // reference to the multisampling state
pipelineInfo.pDepthStencilState = nullptr; // reference to a depth stencil state
pipelineInfo.pColorBlendState = &colorBlending; // reference to a color blend state
pipelineInfo.pDynamicState = nullptr; // specifies a dynamic state
pipelineInfo.layout = pipelineLayout; // reference to the used pipeline layout
pipelineInfo.renderPass = renderPass; // reference to the used render pass
pipelineInfo.subpass = 0; // index reference to the used subpasses
pipelineInfo.basePipelineHandle = VK_NULL_HANDLE; // reference to another pipeline to shift to
pipelineInfo.basePipelineIndex = -1; // index reference to another pipeline to shift to
// Try to create graphics pipelines and print the outcome
if(vkCreateGraphicsPipelines(device, VK_NULL_HANDLE, 1, &pipelineInfo, nullptr, &graphicsPipeline) == VK_SUCCESS){
std::cout<<"Successfully created graphics pipelines!"<<std::endl;
}else{
throw std::runtime_error("Failed to create graphics pipelines!");
}
// Destroy the uneeded modules
vkDestroyShaderModule(device, fragShaderModule, nullptr); // destroy the vertex shader module
vkDestroyShaderModule(device, vertShaderModule, nullptr); // destroy the fragment shader module
}
class GameApplication{
public:
GameApplication(){}
~GameApplication(){}
void run(){
initWindow();
initVulkan();
mainLoop();
cleanup();
}
void createInstance(){};
private:
VulkanEngine vulkanEngine;
GLFWwindow *appWindow;
// Function to setup render window
void initWindow(){
appWindow = vulkanEngine.getWindow();
vulkanEngine.windowInit();
}
// Initialize vulkan routines
void initVulkan(){
vulkanEngine.createInstance(); // create the engine instance
vulkanEngine.createSurface(); // create window surface
vulkanEngine.pickPhysicalDevice(); // choose GPU to render with
vulkanEngine.createLogicalDevice(); // create the logical process for GPU
vulkanEngine.createSwapChain(); // create window swap chain
vulkanEngine.createImageViews(); // create window image views
vulkanEngine.createRenderPass(); // create a render pass
vulkanEngine.createGraphicsPipeline(); // create graphics pipeline
vulkanEngine.createFrameBuffers(); // create all frame buffers
vulkanEngine.createCommandPool(); // create the command pool
vulkanEngine.createCommandBuffers(); // create all command buffers
vulkanEngine.createSemaphores(); // create render semaphores
}
// Main render loop
void mainLoop(){
while(!glfwWindowShouldClose(appWindow)) // if window should not close
vulkanEngine.windowUpdate(); // update window
vulkanEngine.drawFrame(); // draw a new frame
}
// End of program clean up
void cleanup(){
vulkanEngine.cleanup(); // clean up vulkan waste
vulkanEngine.windowDestroy(); // clean up glfw waste
}
};
Линия 452
if(vkCreateGraphicsPipelines(device, VK_NULL_HANDLE, 1, &pipelineInfo, nullptr, &graphicsPipeline) == VK_SUCCESS){