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

Method initialize

samples/SharedHandles/SharedHandles.cpp:132–180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

130 }
131
132 void initialize()
133 {
134 commandBuffer = vk::SharedCommandBuffer{
135 device->allocateCommandBuffers( vk::CommandBufferAllocateInfo( commandPool.get(), vk::CommandBufferLevel::ePrimary, 1 ) ).front(), device, commandPool
136 };
137
138 auto device_handle = device.get();
139 descriptorSetLayout = vk::SharedDescriptorSetLayout{ vk::su::createDescriptorSetLayout(
140 device_handle,
141 { { vk::DescriptorType::eUniformBuffer, 1, vk::ShaderStageFlagBits::eVertex },
142 { vk::DescriptorType::eCombinedImageSampler, 1, vk::ShaderStageFlagBits::eFragment } } ),
143 device };
144
145 auto dsl = descriptorSetLayout.get();
146
147 pipelineLayout = vk::SharedPipelineLayout{ device->createPipelineLayout( vk::PipelineLayoutCreateInfo( vk::PipelineLayoutCreateFlags(), dsl ) ), device };
148
149 glslang::InitializeProcess();
150 vertexShaderModule = vk::SharedShaderModule{ vk::su::createShaderModule( device_handle, vk::ShaderStageFlagBits::eVertex, vertexShaderText_PT_T ), device };
151 fragmentShaderModule =
152 vk::SharedShaderModule{ vk::su::createShaderModule( device_handle, vk::ShaderStageFlagBits::eFragment, fragmentShaderText_T_C ), device };
153 glslang::FinalizeProcess();
154
155 descriptorPool = vk::SharedDescriptorPool{
156 vk::su::createDescriptorPool( device_handle, { { vk::DescriptorType::eUniformBuffer, 1 }, { vk::DescriptorType::eCombinedImageSampler, 1 } } ), device
157 };
158
159 descriptorSetAllocateInfo = vk::DescriptorSetAllocateInfo( descriptorPool.get(), dsl );
160 descriptorSet = vk::SharedDescriptorSet{ device->allocateDescriptorSets( descriptorSetAllocateInfo ).front(), device, descriptorPool };
161
162 pipelineCache = vk::SharedPipelineCache{ device->createPipelineCache( vk::PipelineCacheCreateInfo() ), device };
163 graphicsPipeline = vk::SharedPipeline{ vk::su::createGraphicsPipeline( device_handle,
164 pipelineCache.get(),
165 std::make_pair( vertexShaderModule.get(), nullptr ),
166 std::make_pair( fragmentShaderModule.get(), nullptr ),
167 sizeof( texturedCubeData[0] ),
168 { { vk::Format::eR32G32B32A32Sfloat, 0 }, { vk::Format::eR32G32Sfloat, 16 } },
169 vk::FrontFace::eClockwise,
170 true,
171 pipelineLayout.get(),
172 renderPass.get() ),
173 device };
174
175 // Get the index of the next available swapchain image:
176 vk::ResultValue<uint32_t> currentBufferR = device->acquireNextImageKHR( swapChain.get(), vk::su::FenceTimeout, imageAcquiredSemaphore.get(), nullptr );
177 assert( currentBufferR.result == vk::Result::eSuccess );
178 assert( currentBufferR.value < framebuffers.size() );
179 currentBuffer = currentBufferR.value;
180 }
181
182 void beginFrame( vk::Extent2D extent )
183 {

Callers

nothing calls this directly

Calls 4

createShaderModuleFunction · 0.85
createDescriptorPoolFunction · 0.85
createGraphicsPipelineFunction · 0.85

Tested by

no test coverage detected