| 2618 | } |
| 2619 | |
| 2620 | void Demo::prepare_pipeline() { |
| 2621 | vk::PipelineCacheCreateInfo const pipelineCacheInfo; |
| 2622 | auto result = device.createPipelineCache(&pipelineCacheInfo, nullptr, &pipelineCache); |
| 2623 | VERIFY(result == vk::Result::eSuccess); |
| 2624 | |
| 2625 | std::array<vk::PipelineShaderStageCreateInfo, 2> const shaderStageInfo = { |
| 2626 | vk::PipelineShaderStageCreateInfo().setStage(vk::ShaderStageFlagBits::eVertex).setModule(prepare_vs()).setPName("main"), |
| 2627 | vk::PipelineShaderStageCreateInfo().setStage(vk::ShaderStageFlagBits::eFragment).setModule(prepare_fs()).setPName("main")}; |
| 2628 | |
| 2629 | vk::PipelineVertexInputStateCreateInfo const vertexInputInfo; |
| 2630 | |
| 2631 | auto const inputAssemblyInfo = vk::PipelineInputAssemblyStateCreateInfo().setTopology(vk::PrimitiveTopology::eTriangleList); |
| 2632 | |
| 2633 | // TODO: Where are pViewports and pScissors set? |
| 2634 | auto const viewportInfo = vk::PipelineViewportStateCreateInfo().setViewportCount(1).setScissorCount(1); |
| 2635 | |
| 2636 | auto const rasterizationInfo = vk::PipelineRasterizationStateCreateInfo() |
| 2637 | .setDepthClampEnable(VK_FALSE) |
| 2638 | .setRasterizerDiscardEnable(VK_FALSE) |
| 2639 | .setPolygonMode(vk::PolygonMode::eFill) |
| 2640 | .setCullMode(vk::CullModeFlagBits::eBack) |
| 2641 | .setFrontFace(vk::FrontFace::eCounterClockwise) |
| 2642 | .setDepthBiasEnable(VK_FALSE) |
| 2643 | .setLineWidth(1.0f); |
| 2644 | |
| 2645 | auto const multisampleInfo = vk::PipelineMultisampleStateCreateInfo(); |
| 2646 | |
| 2647 | auto const stencilOp = |
| 2648 | vk::StencilOpState().setFailOp(vk::StencilOp::eKeep).setPassOp(vk::StencilOp::eKeep).setCompareOp(vk::CompareOp::eAlways); |
| 2649 | |
| 2650 | auto const depthStencilInfo = vk::PipelineDepthStencilStateCreateInfo() |
| 2651 | .setDepthTestEnable(VK_TRUE) |
| 2652 | .setDepthWriteEnable(VK_TRUE) |
| 2653 | .setDepthCompareOp(vk::CompareOp::eLessOrEqual) |
| 2654 | .setDepthBoundsTestEnable(VK_FALSE) |
| 2655 | .setStencilTestEnable(VK_FALSE) |
| 2656 | .setFront(stencilOp) |
| 2657 | .setBack(stencilOp); |
| 2658 | |
| 2659 | std::array<vk::PipelineColorBlendAttachmentState, 1> const colorBlendAttachments = { |
| 2660 | vk::PipelineColorBlendAttachmentState().setColorWriteMask(vk::ColorComponentFlagBits::eR | vk::ColorComponentFlagBits::eG | |
| 2661 | vk::ColorComponentFlagBits::eB | vk::ColorComponentFlagBits::eA)}; |
| 2662 | |
| 2663 | auto const colorBlendInfo = vk::PipelineColorBlendStateCreateInfo().setAttachments(colorBlendAttachments); |
| 2664 | |
| 2665 | std::array<vk::DynamicState, 2> const dynamicStates = {vk::DynamicState::eViewport, vk::DynamicState::eScissor}; |
| 2666 | |
| 2667 | auto const dynamicStateInfo = vk::PipelineDynamicStateCreateInfo().setDynamicStates(dynamicStates); |
| 2668 | |
| 2669 | auto pipline_return = device.createGraphicsPipelines(pipelineCache, vk::GraphicsPipelineCreateInfo() |
| 2670 | .setStages(shaderStageInfo) |
| 2671 | .setPVertexInputState(&vertexInputInfo) |
| 2672 | .setPInputAssemblyState(&inputAssemblyInfo) |
| 2673 | .setPViewportState(&viewportInfo) |
| 2674 | .setPRasterizationState(&rasterizationInfo) |
| 2675 | .setPMultisampleState(&multisampleInfo) |
| 2676 | .setPDepthStencilState(&depthStencilInfo) |
| 2677 | .setPColorBlendState(&colorBlendInfo) |
nothing calls this directly
no outgoing calls
no test coverage detected