MCPcopy Create free account
hub / github.com/Overv/VulkanTutorial / createGraphicsPipeline

Method createGraphicsPipeline

code/25_sampler.cpp:563–675  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

561 }
562
563 void createGraphicsPipeline() {
564 auto vertShaderCode = readFile("shaders/vert.spv");
565 auto fragShaderCode = readFile("shaders/frag.spv");
566
567 VkShaderModule vertShaderModule = createShaderModule(vertShaderCode);
568 VkShaderModule fragShaderModule = createShaderModule(fragShaderCode);
569
570 VkPipelineShaderStageCreateInfo vertShaderStageInfo{};
571 vertShaderStageInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
572 vertShaderStageInfo.stage = VK_SHADER_STAGE_VERTEX_BIT;
573 vertShaderStageInfo.module = vertShaderModule;
574 vertShaderStageInfo.pName = "main";
575
576 VkPipelineShaderStageCreateInfo fragShaderStageInfo{};
577 fragShaderStageInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
578 fragShaderStageInfo.stage = VK_SHADER_STAGE_FRAGMENT_BIT;
579 fragShaderStageInfo.module = fragShaderModule;
580 fragShaderStageInfo.pName = "main";
581
582 VkPipelineShaderStageCreateInfo shaderStages[] = {vertShaderStageInfo, fragShaderStageInfo};
583
584 VkPipelineVertexInputStateCreateInfo vertexInputInfo{};
585 vertexInputInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
586
587 auto bindingDescription = Vertex::getBindingDescription();
588 auto attributeDescriptions = Vertex::getAttributeDescriptions();
589
590 vertexInputInfo.vertexBindingDescriptionCount = 1;
591 vertexInputInfo.vertexAttributeDescriptionCount = static_cast<uint32_t>(attributeDescriptions.size());
592 vertexInputInfo.pVertexBindingDescriptions = &bindingDescription;
593 vertexInputInfo.pVertexAttributeDescriptions = attributeDescriptions.data();
594
595 VkPipelineInputAssemblyStateCreateInfo inputAssembly{};
596 inputAssembly.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
597 inputAssembly.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
598 inputAssembly.primitiveRestartEnable = VK_FALSE;
599
600 VkPipelineViewportStateCreateInfo viewportState{};
601 viewportState.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
602 viewportState.viewportCount = 1;
603 viewportState.scissorCount = 1;
604
605 VkPipelineRasterizationStateCreateInfo rasterizer{};
606 rasterizer.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
607 rasterizer.depthClampEnable = VK_FALSE;
608 rasterizer.rasterizerDiscardEnable = VK_FALSE;
609 rasterizer.polygonMode = VK_POLYGON_MODE_FILL;
610 rasterizer.lineWidth = 1.0f;
611 rasterizer.cullMode = VK_CULL_MODE_BACK_BIT;
612 rasterizer.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE;
613 rasterizer.depthBiasEnable = VK_FALSE;
614
615 VkPipelineMultisampleStateCreateInfo multisampling{};
616 multisampling.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
617 multisampling.sampleShadingEnable = VK_FALSE;
618 multisampling.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT;
619
620 VkPipelineColorBlendAttachmentState colorBlendAttachment{};

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected