MCPcopy Create free account
hub / github.com/KhronosGroup/Vulkan-Hpp / createGraphicsPipeline

Function createGraphicsPipeline

samples/utils/utils.cpp:121–210  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

119 }
120
121 vk::Pipeline createGraphicsPipeline( vk::Device const & device,
122 vk::PipelineCache const & pipelineCache,
123 std::pair<vk::ShaderModule, vk::SpecializationInfo const *> const & vertexShaderData,
124 std::pair<vk::ShaderModule, vk::SpecializationInfo const *> const & fragmentShaderData,
125 uint32_t vertexStride,
126 std::vector<std::pair<vk::Format, uint32_t>> const & vertexInputAttributeFormatOffset,
127 vk::FrontFace frontFace,
128 bool depthBuffered,
129 vk::PipelineLayout const & pipelineLayout,
130 vk::RenderPass const & renderPass )
131 {
132 std::array<vk::PipelineShaderStageCreateInfo, 2> pipelineShaderStageCreateInfos = {
133 vk::PipelineShaderStageCreateInfo(
134 vk::PipelineShaderStageCreateFlags(), vk::ShaderStageFlagBits::eVertex, vertexShaderData.first, "main", vertexShaderData.second ),
135 vk::PipelineShaderStageCreateInfo(
136 vk::PipelineShaderStageCreateFlags(), vk::ShaderStageFlagBits::eFragment, fragmentShaderData.first, "main", fragmentShaderData.second )
137 };
138
139 std::vector<vk::VertexInputAttributeDescription> vertexInputAttributeDescriptions;
140 vk::PipelineVertexInputStateCreateInfo pipelineVertexInputStateCreateInfo;
141 vk::VertexInputBindingDescription vertexInputBindingDescription( 0, vertexStride );
142
143 if ( 0 < vertexStride )
144 {
145 vertexInputAttributeDescriptions.reserve( vertexInputAttributeFormatOffset.size() );
146 for ( uint32_t i = 0; i < vertexInputAttributeFormatOffset.size(); i++ )
147 {
148 vertexInputAttributeDescriptions.emplace_back( i, 0, vertexInputAttributeFormatOffset[i].first, vertexInputAttributeFormatOffset[i].second );
149 }
150 pipelineVertexInputStateCreateInfo.setVertexBindingDescriptions( vertexInputBindingDescription );
151 pipelineVertexInputStateCreateInfo.setVertexAttributeDescriptions( vertexInputAttributeDescriptions );
152 }
153
154 vk::PipelineInputAssemblyStateCreateInfo pipelineInputAssemblyStateCreateInfo( vk::PipelineInputAssemblyStateCreateFlags(),
155 vk::PrimitiveTopology::eTriangleList );
156
157 vk::PipelineViewportStateCreateInfo pipelineViewportStateCreateInfo( vk::PipelineViewportStateCreateFlags(), 1, nullptr, 1, nullptr );
158
159 vk::PipelineRasterizationStateCreateInfo pipelineRasterizationStateCreateInfo( vk::PipelineRasterizationStateCreateFlags(),
160 false,
161 false,
162 vk::PolygonMode::eFill,
163 vk::CullModeFlagBits::eBack,
164 frontFace,
165 false,
166 0.0f,
167 0.0f,
168 0.0f,
169 1.0f );
170
171 vk::PipelineMultisampleStateCreateInfo pipelineMultisampleStateCreateInfo( {}, vk::SampleCountFlagBits::e1 );
172
173 vk::StencilOpState stencilOpState( vk::StencilOp::eKeep, vk::StencilOp::eKeep, vk::StencilOp::eKeep, vk::CompareOp::eAlways );
174 vk::PipelineDepthStencilStateCreateInfo pipelineDepthStencilStateCreateInfo(
175 vk::PipelineDepthStencilStateCreateFlags(), depthBuffered, depthBuffered, vk::CompareOp::eLessOrEqual, false, false, stencilOpState, stencilOpState );
176
177 vk::ColorComponentFlags colorComponentFlags( vk::ColorComponentFlagBits::eR | vk::ColorComponentFlagBits::eG | vk::ColorComponentFlagBits::eB |
178 vk::ColorComponentFlagBits::eA );

Callers 15

mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
initializeMethod · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected