private void createGraphicsPipeline() { var vertShaderModule = createShaderModule(typeof(Shader_Vert_03)); var fragShaderModule = createShaderModule(typeof(Shader_Frag_03)); VkPipelineShaderStageCreateInfo vertShaderStageInfo = new VkPipelineShaderStageCreateInfo(); vertShaderStageInfo.sType = VkStructureType.VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; vertShaderStageInfo.stage = VkShaderStageFlagBits.VK_SHADER_STAGE_VERTEX_BIT; vertShaderStageInfo.module = vertShaderModule; vertShaderStageInfo.pName = "main"; VkPipelineShaderStageCreateInfo fragShaderStageInfo = new VkPipelineShaderStageCreateInfo(); fragShaderStageInfo.sType = VkStructureType.VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; fragShaderStageInfo.stage = VkShaderStageFlagBits.VK_SHADER_STAGE_FRAGMENT_BIT; fragShaderStageInfo.module = fragShaderModule; fragShaderStageInfo.pName = "main"; VkPipelineShaderStageCreateInfo[] shaderStages = new VkPipelineShaderStageCreateInfo[2] { vertShaderStageInfo, fragShaderStageInfo }; VkPipelineVertexInputStateCreateInfo vertexInputInfo = new VkPipelineVertexInputStateCreateInfo(); vertexInputInfo.sType = VkStructureType.VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; var bindingDescription = Vertex.getBindingDescription(); var attributeDescriptions = Vertex.getAttributeDescriptions(); vertexInputInfo.vertexBindingDescriptionCount = 1; vertexInputInfo.vertexAttributeDescriptionCount = attributeDescriptions.Length; vertexInputInfo.pVertexBindingDescriptions = new VkVertexInputBindingDescription[] { bindingDescription }; vertexInputInfo.pVertexAttributeDescriptions = attributeDescriptions; VkPipelineInputAssemblyStateCreateInfo inputAssembly = new VkPipelineInputAssemblyStateCreateInfo(); inputAssembly.sType = VkStructureType.VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; inputAssembly.topology = VkPrimitiveTopology.VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; inputAssembly.primitiveRestartEnable = VkBool32.VK_FALSE; VkViewport viewport = new VkViewport(); viewport.x = 0.0f; viewport.y = 0.0f; viewport.width = (float)swapChainExtent.width; viewport.height = (float)swapChainExtent.height; viewport.minDepth = 0.0f; viewport.maxDepth = 1.0f; VkRect2D scissor = new VkRect2D(); scissor.offset = new VkOffset2D() { x = 0, y = 0 }; scissor.extent = swapChainExtent; VkPipelineViewportStateCreateInfo viewportState = new VkPipelineViewportStateCreateInfo(); viewportState.sType = VkStructureType.VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; viewportState.viewportCount = 1; viewportState.pViewports = new VkViewport[] { viewport }; viewportState.scissorCount = 1; viewportState.pSicssors = new VkRect2D[] { scissor }; VkPipelineRasterizationStateCreateInfo rasterizer = new VkPipelineRasterizationStateCreateInfo(); rasterizer.sType = VkStructureType.VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; rasterizer.depthClampEnable = VkBool32.VK_FALSE; rasterizer.rasterizerDiscardEnable = VkBool32.VK_FALSE; rasterizer.polygonMode = VkPolygonMode.VK_POLYGON_MODE_FILL; rasterizer.lineWidth = 1.0f; rasterizer.cullMode = VkCullModeFlagBits.VK_CULL_MODE_BACK_BIT; rasterizer.frontFace = VkFrontFace.VK_FRONT_FACE_CLOCKWISE; rasterizer.depthBiasEnable = VkBool32.VK_FALSE; VkPipelineMultisampleStateCreateInfo multisampling = new VkPipelineMultisampleStateCreateInfo(); multisampling.sType = VkStructureType.VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; multisampling.sampleShadingEnable = VkBool32.VK_FALSE; multisampling.rasterizationSamples = VkSampleCountFlagBits.VK_SAMPLE_COUNT_1_BIT; VkPipelineColorBlendAttachmentState colorBlendAttachment = new VkPipelineColorBlendAttachmentState(); colorBlendAttachment.colorWriteMask = VkColorComponentFlagBits.VK_COLOR_COMPONENT_R_BIT | VkColorComponentFlagBits.VK_COLOR_COMPONENT_G_BIT | VkColorComponentFlagBits.VK_COLOR_COMPONENT_B_BIT | VkColorComponentFlagBits.VK_COLOR_COMPONENT_A_BIT; colorBlendAttachment.blendEnable = VkBool32.VK_FALSE; VkPipelineColorBlendStateCreateInfo colorBlending = VkPipelineColorBlendStateCreateInfo.Create(); colorBlending.sType = VkStructureType.VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; colorBlending.logicOpEnable = VkBool32.VK_FALSE; colorBlending.logicOp = VkLogicOp.VK_LOGIC_OP_COPY; colorBlending.attachmentCount = 1; colorBlending.pAttachments = new VkPipelineColorBlendAttachmentState[] { colorBlendAttachment }; colorBlending.blendConstants[0] = 0.0f; colorBlending.blendConstants[1] = 0.0f; colorBlending.blendConstants[2] = 0.0f; colorBlending.blendConstants[3] = 0.0f; VkPipelineLayoutCreateInfo pipelineLayoutInfo = new VkPipelineLayoutCreateInfo(); pipelineLayoutInfo.sType = VkStructureType.VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; pipelineLayoutInfo.setLayoutCount = 0; pipelineLayoutInfo.pushConstantRangeCount = 0; VkResult result = Vulkan.vkCreatePipelineLayout(device, pipelineLayoutInfo, null, out pipelineLayout); if (result != VkResult.VK_SUCCESS) { throw Program.Throw("failed to create pipeline layout!"); } VkGraphicsPipelineCreateInfo pipelineInfo = new VkGraphicsPipelineCreateInfo(); pipelineInfo.sType = VkStructureType.VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; pipelineInfo.stageCount = shaderStages.Length; pipelineInfo.pStages = shaderStages; pipelineInfo.pVertexInputState = vertexInputInfo; pipelineInfo.pInputAssemblyState = inputAssembly; pipelineInfo.pViewportState = viewportState; pipelineInfo.pRasterizationState = rasterizer; pipelineInfo.pMultisampleState = multisampling; pipelineInfo.pColorBlendState = colorBlending; pipelineInfo.layout = pipelineLayout; pipelineInfo.renderPass = renderPass; pipelineInfo.subpass = 0; pipelineInfo.basePipelineHandle = null; VkPipeline[] pipelineResult = new VkPipeline[1]; result = Vulkan.vkCreateGraphicsPipelines(device, null, 1, new VkGraphicsPipelineCreateInfo[] { pipelineInfo }, null, pipelineResult); if (result != VkResult.VK_SUCCESS) { throw Program.Throw("failed to create graphics pipeline!", result); } graphicsPipeline = pipelineResult[0]; Vulkan.vkDestroyShaderModule(device, fragShaderModule, null); Vulkan.vkDestroyShaderModule(device, vertShaderModule, null); }