Vulkan-Hpp
PipelineCache.cpp
Go to the documentation of this file.
1 // Copyright(c) 2019, NVIDIA CORPORATION. All rights reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 //
15 // VulkanHpp Samples : PipelineCache
16 // This sample tries to save and reuse pipeline cache data between runs.
17 
18 #if defined( _MSC_VER )
19 // no need to ignore any warnings with MSVC
20 #elif defined( __clang__ )
21 # pragma clang diagnostic ignored "-Wmissing-braces"
22 #elif defined( __GNUC__ )
23 #else
24 // unknow compiler... just ignore the warnings for yourselves ;)
25 #endif
26 
27 #include "../utils/geometries.hpp"
28 #include "../utils/math.hpp"
29 #include "../utils/shaders.hpp"
30 #include "../utils/utils.hpp"
31 #include "SPIRV/GlslangToSpv.h"
32 
33 #include <fstream>
34 #include <iomanip>
35 #include <thread>
36 
37 // For timestamp code (getMilliseconds)
38 #ifdef WIN32
39 # include <Windows.h>
40 #else
41 # include <sys/time.h>
42 #endif
43 
44 typedef unsigned long long timestamp_t;
46 {
47 #ifdef WIN32
48  LARGE_INTEGER frequency;
49  BOOL useQPC = QueryPerformanceFrequency( &frequency );
50  if ( useQPC )
51  {
52  LARGE_INTEGER now;
53  QueryPerformanceCounter( &now );
54  return ( 1000LL * now.QuadPart ) / frequency.QuadPart;
55  }
56  else
57  {
58  return GetTickCount();
59  }
60 #else
61  struct timeval now;
62  gettimeofday( &now, NULL );
63  return ( now.tv_usec / 1000 ) + (timestamp_t)now.tv_sec;
64 #endif
65 }
66 
67 static char const * AppName = "PipelineCache";
68 static char const * EngineName = "Vulkan.hpp";
69 
70 int main( int /*argc*/, char ** /*argv*/ )
71 {
72  try
73  {
74  vk::Instance instance = vk::su::createInstance( AppName, EngineName, {}, vk::su::getInstanceExtensions() );
75 #if !defined( NDEBUG )
77 #endif
78 
79  vk::PhysicalDevice physicalDevice = instance.enumeratePhysicalDevices().front();
80  vk::PhysicalDeviceProperties properties = physicalDevice.getProperties();
81 
82  vk::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) );
83 
84  std::pair<uint32_t, uint32_t> graphicsAndPresentQueueFamilyIndex = vk::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface );
85  vk::Device device = vk::su::createDevice( physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() );
86 
87  vk::CommandPool commandPool = device.createCommandPool( { {}, graphicsAndPresentQueueFamilyIndex.first } );
88  vk::CommandBuffer commandBuffer =
90 
91  vk::Queue graphicsQueue = device.getQueue( graphicsAndPresentQueueFamilyIndex.first, 0 );
92  vk::Queue presentQueue = device.getQueue( graphicsAndPresentQueueFamilyIndex.second, 0 );
93 
94  vk::su::SwapChainData swapChainData( physicalDevice,
95  device,
96  surfaceData.surface,
97  surfaceData.extent,
99  {},
100  graphicsAndPresentQueueFamilyIndex.first,
101  graphicsAndPresentQueueFamilyIndex.second );
102 
103  vk::su::DepthBufferData depthBufferData( physicalDevice, device, vk::Format::eD16Unorm, surfaceData.extent );
104 
105  vk::su::TextureData textureData( physicalDevice, device );
106  commandBuffer.begin( vk::CommandBufferBeginInfo() );
107  textureData.setImage( device, commandBuffer, vk::su::MonochromeImageGenerator( { 118, 185, 0 } ) );
108 
109  vk::su::BufferData uniformBufferData( physicalDevice, device, sizeof( glm::mat4x4 ), vk::BufferUsageFlagBits::eUniformBuffer );
110  glm::mat4x4 mvpcMatrix = vk::su::createModelViewProjectionClipMatrix( surfaceData.extent );
111  vk::su::copyToDevice( device, uniformBufferData.deviceMemory, mvpcMatrix );
112 
113  vk::DescriptorSetLayout descriptorSetLayout =
117  vk::PipelineLayout pipelineLayout = device.createPipelineLayout( vk::PipelineLayoutCreateInfo( vk::PipelineLayoutCreateFlags(), descriptorSetLayout ) );
118 
120  device, vk::su::pickSurfaceFormat( physicalDevice.getSurfaceFormatsKHR( surfaceData.surface ) ).format, depthBufferData.format );
121 
122  glslang::InitializeProcess();
125  glslang::FinalizeProcess();
126 
127  std::vector<vk::Framebuffer> framebuffers =
128  vk::su::createFramebuffers( device, renderPass, swapChainData.imageViews, depthBufferData.imageView, surfaceData.extent );
129 
130  vk::su::BufferData vertexBufferData( physicalDevice, device, sizeof( texturedCubeData ), vk::BufferUsageFlagBits::eVertexBuffer );
131  vk::su::copyToDevice( device, vertexBufferData.deviceMemory, texturedCubeData, sizeof( texturedCubeData ) / sizeof( texturedCubeData[0] ) );
132 
133  vk::DescriptorPool descriptorPool =
135  vk::DescriptorSetAllocateInfo descriptorSetAllocateInfo( descriptorPool, descriptorSetLayout );
136  vk::DescriptorSet descriptorSet = device.allocateDescriptorSets( descriptorSetAllocateInfo ).front();
137 
138  vk::su::updateDescriptorSets( device, descriptorSet, { { vk::DescriptorType::eUniformBuffer, uniformBufferData.buffer, VK_WHOLE_SIZE, {} } }, textureData );
139 
140  /* VULKAN_KEY_START */
141 
142  // Check disk for existing cache data
143  size_t startCacheSize = 0;
144  char * startCacheData = nullptr;
145 
146  std::string cacheFileName = "pipeline_cache_data.bin";
147  std::ifstream readCacheStream( cacheFileName, std::ios_base::in | std::ios_base::binary );
148  if ( readCacheStream.good() )
149  {
150  // Determine cache size
151  readCacheStream.seekg( 0, readCacheStream.end );
152  startCacheSize = static_cast<size_t>( readCacheStream.tellg() );
153  readCacheStream.seekg( 0, readCacheStream.beg );
154 
155  // Allocate memory to hold the initial cache data
156  startCacheData = (char *)std::malloc( startCacheSize );
157 
158  // Read the data into our buffer
159  readCacheStream.read( startCacheData, startCacheSize );
160 
161  // Clean up and print results
162  readCacheStream.close();
163  std::cout << " Pipeline cache HIT!\n";
164  std::cout << " cacheData loaded from " << cacheFileName << "\n";
165  }
166  else
167  {
168  // No cache found on disk
169  std::cout << " Pipeline cache miss!\n";
170  }
171 
172  if ( startCacheData != nullptr )
173  {
174  // Check for cache validity
175  //
176  // TODO: Update this as the spec evolves. The fields are not defined by the header.
177  //
178  // The code below supports SDK 0.10 Vulkan spec, which contains the following table:
179  //
180  // Offset Size Meaning
181  // ------ ------------ ------------------------------------------------------------------
182  // 0 4 a device ID equal to VkPhysicalDeviceProperties::DeviceId written
183  // as a stream of bytes, with the least significant byte first
184  //
185  // 4 VK_UUID_SIZE a pipeline cache ID equal to VkPhysicalDeviceProperties::pipelineCacheUUID
186  //
187  //
188  // The code must be updated for latest Vulkan spec, which contains the following table:
189  //
190  // Offset Size Meaning
191  // ------ ------------ ------------------------------------------------------------------
192  // 0 4 length in bytes of the entire pipeline cache header written as a
193  // stream of bytes, with the least significant byte first
194  // 4 4 a VkPipelineCacheHeaderVersion value written as a stream of bytes,
195  // with the least significant byte first
196  // 8 4 a vendor ID equal to VkPhysicalDeviceProperties::vendorID written
197  // as a stream of bytes, with the least significant byte first
198  // 12 4 a device ID equal to VkPhysicalDeviceProperties::deviceID written
199  // as a stream of bytes, with the least significant byte first
200  // 16 VK_UUID_SIZE a pipeline cache ID equal to VkPhysicalDeviceProperties::pipelineCacheUUID
201 
202  uint32_t headerLength = 0;
203  uint32_t cacheHeaderVersion = 0;
204  uint32_t vendorID = 0;
205  uint32_t deviceID = 0;
206  uint8_t pipelineCacheUUID[VK_UUID_SIZE] = {};
207 
208  memcpy( &headerLength, (uint8_t *)startCacheData + 0, 4 );
209  memcpy( &cacheHeaderVersion, (uint8_t *)startCacheData + 4, 4 );
210  memcpy( &vendorID, (uint8_t *)startCacheData + 8, 4 );
211  memcpy( &deviceID, (uint8_t *)startCacheData + 12, 4 );
212  memcpy( pipelineCacheUUID, (uint8_t *)startCacheData + 16, VK_UUID_SIZE );
213 
214  // Check each field and report bad values before freeing existing cache
215  bool badCache = false;
216 
217  if ( headerLength <= 0 )
218  {
219  badCache = true;
220  std::cout << " Bad header length in " << cacheFileName << ".\n";
221  std::cout << " Cache contains: " << std::hex << std::setw( 8 ) << headerLength << "\n";
222  }
223 
224  if ( cacheHeaderVersion != VK_PIPELINE_CACHE_HEADER_VERSION_ONE )
225  {
226  badCache = true;
227  std::cout << " Unsupported cache header version in " << cacheFileName << ".\n";
228  std::cout << " Cache contains: " << std::hex << std::setw( 8 ) << cacheHeaderVersion << "\n";
229  }
230 
231  if ( vendorID != properties.vendorID )
232  {
233  badCache = true;
234  std::cout << " Vender ID mismatch in " << cacheFileName << ".\n";
235  std::cout << " Cache contains: " << std::hex << std::setw( 8 ) << vendorID << "\n";
236  std::cout << " Driver expects: " << std::hex << std::setw( 8 ) << properties.vendorID << "\n";
237  }
238 
239  if ( deviceID != properties.deviceID )
240  {
241  badCache = true;
242  std::cout << " Device ID mismatch in " << cacheFileName << ".\n";
243  std::cout << " Cache contains: " << std::hex << std::setw( 8 ) << deviceID << "\n";
244  std::cout << " Driver expects: " << std::hex << std::setw( 8 ) << properties.deviceID << "\n";
245  }
246 
247  if ( memcmp( pipelineCacheUUID, properties.pipelineCacheUUID, sizeof( pipelineCacheUUID ) ) != 0 )
248  {
249  badCache = true;
250  std::cout << " UUID mismatch in " << cacheFileName << ".\n";
251  std::cout << " Cache contains: " << vk::su::UUID( pipelineCacheUUID ) << "\n";
252  std::cout << " Driver expects: " << vk::su::UUID( properties.pipelineCacheUUID ) << "\n";
253  }
254 
255  if ( badCache )
256  {
257  // Don't submit initial cache data if any version info is incorrect
258  free( startCacheData );
259  startCacheSize = 0;
260  startCacheData = nullptr;
261 
262  // And clear out the old cache file for use in next run
263  std::cout << " Deleting cache entry " << cacheFileName << " to repopulate.\n";
264  if ( remove( cacheFileName.c_str() ) != 0 )
265  {
266  std::cerr << "Reading error";
267  exit( EXIT_FAILURE );
268  }
269  }
270  }
271 
272  // Feed the initial cache data into cache creation
273  vk::PipelineCache pipelineCache =
274  device.createPipelineCache( vk::PipelineCacheCreateInfo( vk::PipelineCacheCreateFlags(), startCacheSize, startCacheData ) );
275 
276  // Free our initialData now that pipeline cache has been created
277  free( startCacheData );
278  startCacheData = NULL;
279 
280  // Time (roughly) taken to create the graphics pipeline
281  timestamp_t start = getMilliseconds();
282  vk::Pipeline graphicsPipeline = vk::su::createGraphicsPipeline( device,
283  pipelineCache,
284  std::make_pair( vertexShaderModule, nullptr ),
285  std::make_pair( fragmentShaderModule, nullptr ),
286  sizeof( texturedCubeData[0] ),
289  true,
290  pipelineLayout,
291  renderPass );
292  timestamp_t elapsed = getMilliseconds() - start;
293  std::cout << " vkCreateGraphicsPipeline time: " << (double)elapsed << " ms\n";
294 
295  vk::Semaphore imageAcquiredSemaphore = device.createSemaphore( vk::SemaphoreCreateInfo( vk::SemaphoreCreateFlags() ) );
296 
297  // Get the index of the next available swapchain image:
298  vk::ResultValue<uint32_t> currentBuffer = device.acquireNextImageKHR( swapChainData.swapChain, UINT64_MAX, imageAcquiredSemaphore, nullptr );
299  assert( currentBuffer.result == vk::Result::eSuccess );
300  assert( currentBuffer.value < framebuffers.size() );
301 
302  std::array<vk::ClearValue, 2> clearValues;
303  clearValues[0].color = vk::ClearColorValue( 0.2f, 0.2f, 0.2f, 0.2f );
304  clearValues[1].depthStencil = vk::ClearDepthStencilValue( 1.0f, 0 );
305 
306  commandBuffer.beginRenderPass(
307  vk::RenderPassBeginInfo( renderPass, framebuffers[currentBuffer.value], vk::Rect2D( vk::Offset2D(), surfaceData.extent ), clearValues ),
309  commandBuffer.bindPipeline( vk::PipelineBindPoint::eGraphics, graphicsPipeline );
310  commandBuffer.bindDescriptorSets( vk::PipelineBindPoint::eGraphics, pipelineLayout, 0, descriptorSet, {} );
311 
312  commandBuffer.bindVertexBuffers( 0, vertexBufferData.buffer, { 0 } );
313  commandBuffer.setViewport(
314  0, vk::Viewport( 0.0f, 0.0f, static_cast<float>( surfaceData.extent.width ), static_cast<float>( surfaceData.extent.height ), 0.0f, 1.0f ) );
315  commandBuffer.setScissor( 0, vk::Rect2D( vk::Offset2D( 0, 0 ), surfaceData.extent ) );
316 
317  commandBuffer.draw( 12 * 3, 1, 0, 0 );
318  commandBuffer.endRenderPass();
319  commandBuffer.end();
320 
321  vk::Fence drawFence = device.createFence( vk::FenceCreateInfo() );
322 
324  vk::SubmitInfo submitInfo( imageAcquiredSemaphore, waitDestinationStageMask, commandBuffer );
325  graphicsQueue.submit( submitInfo, drawFence );
326 
327  while ( vk::Result::eTimeout == device.waitForFences( drawFence, VK_TRUE, vk::su::FenceTimeout ) )
328  ;
329 
330  vk::Result result = presentQueue.presentKHR( vk::PresentInfoKHR( {}, swapChainData.swapChain, currentBuffer.value ) );
331  switch ( result )
332  {
333  case vk::Result::eSuccess: break;
334  case vk::Result::eSuboptimalKHR: std::cout << "vk::Queue::presentKHR returned vk::Result::eSuboptimalKHR !\n"; break;
335  default: assert( false ); // an unexpected result is returned !
336  }
337  std::this_thread::sleep_for( std::chrono::milliseconds( 1000 ) );
338 
339  // Store away the cache that we've populated. This could conceivably happen
340  // earlier, depends on when the pipeline cache stops being populated
341  // internally.
342  std::vector<uint8_t> endCacheData = device.getPipelineCacheData( pipelineCache );
343 
344  // Write the file to disk, overwriting whatever was there
345  std::ofstream writeCacheStream( cacheFileName, std::ios_base::out | std::ios_base::binary );
346  if ( writeCacheStream.good() )
347  {
348  writeCacheStream.write( reinterpret_cast<char const *>( endCacheData.data() ), endCacheData.size() );
349  writeCacheStream.close();
350  std::cout << " cacheData written to " << cacheFileName << "\n";
351  }
352  else
353  {
354  // Something bad happened
355  std::cout << " Unable to write cache data to disk!\n";
356  }
357 
358  /* VULKAN_KEY_END */
359 
360  device.destroyFence( drawFence );
361  device.destroySemaphore( imageAcquiredSemaphore );
362  device.destroyPipeline( graphicsPipeline );
363  device.destroyPipelineCache( pipelineCache );
364  device.freeDescriptorSets( descriptorPool, descriptorSet );
365  device.destroyDescriptorPool( descriptorPool );
366  vertexBufferData.clear( device );
367  for ( auto framebuffer : framebuffers )
368  {
369  device.destroyFramebuffer( framebuffer );
370  }
371  device.destroyShaderModule( fragmentShaderModule );
372  device.destroyShaderModule( vertexShaderModule );
373  device.destroyRenderPass( renderPass );
374  device.destroyPipelineLayout( pipelineLayout );
375  device.destroyDescriptorSetLayout( descriptorSetLayout );
376  uniformBufferData.clear( device );
377  textureData.clear( device );
378  depthBufferData.clear( device );
379  swapChainData.clear( device );
380  device.freeCommandBuffers( commandPool, commandBuffer );
381  device.destroyCommandPool( commandPool );
382  device.destroy();
383  instance.destroySurfaceKHR( surfaceData.surface );
384 #if !defined( NDEBUG )
385  instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
386 #endif
387  instance.destroy();
388  }
389  catch ( vk::SystemError & err )
390  {
391  std::cout << "vk::SystemError: " << err.what() << std::endl;
392  exit( -1 );
393  }
394  catch ( std::exception & err )
395  {
396  std::cout << "std::exception: " << err.what() << std::endl;
397  exit( -1 );
398  }
399  catch ( ... )
400  {
401  std::cout << "unknown error\n";
402  exit( -1 );
403  }
404  return 0;
405 }
timestamp_t getMilliseconds()
unsigned long long timestamp_t
int main(int, char **)
void cout(vk::SurfaceCapabilitiesKHR const &surfaceCapabilities)
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS ResultValueType< void >::type end(Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const
void draw(uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
void bindDescriptorSets(vk::PipelineBindPoint pipelineBindPoint, vk::PipelineLayout layout, uint32_t firstSet, uint32_t descriptorSetCount, const vk::DescriptorSet *pDescriptorSets, uint32_t dynamicOffsetCount, const uint32_t *pDynamicOffsets, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
void beginRenderPass(const vk::RenderPassBeginInfo *pRenderPassBegin, vk::SubpassContents contents, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
void setScissor(uint32_t firstScissor, uint32_t scissorCount, const vk::Rect2D *pScissors, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
VULKAN_HPP_NODISCARD Result begin(const vk::CommandBufferBeginInfo *pBeginInfo, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
void bindVertexBuffers(uint32_t firstBinding, uint32_t bindingCount, const vk::Buffer *pBuffers, const vk::DeviceSize *pOffsets, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
void bindPipeline(vk::PipelineBindPoint pipelineBindPoint, vk::Pipeline pipeline, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
void endRenderPass(Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
void setViewport(uint32_t firstViewport, uint32_t viewportCount, const vk::Viewport *pViewports, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
VULKAN_HPP_NODISCARD Result createFence(const vk::FenceCreateInfo *pCreateInfo, const vk::AllocationCallbacks *pAllocator, vk::Fence *pFence, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
VULKAN_HPP_NODISCARD Result createPipelineLayout(const vk::PipelineLayoutCreateInfo *pCreateInfo, const vk::AllocationCallbacks *pAllocator, vk::PipelineLayout *pPipelineLayout, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
void destroyDescriptorPool(vk::DescriptorPool descriptorPool, const vk::AllocationCallbacks *pAllocator, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
void destroySemaphore(vk::Semaphore semaphore, const vk::AllocationCallbacks *pAllocator, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
void destroy(const vk::AllocationCallbacks *pAllocator, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
void destroyShaderModule(vk::ShaderModule shaderModule, const vk::AllocationCallbacks *pAllocator, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
void freeCommandBuffers(vk::CommandPool commandPool, uint32_t commandBufferCount, const vk::CommandBuffer *pCommandBuffers, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
void destroyCommandPool(vk::CommandPool commandPool, const vk::AllocationCallbacks *pAllocator, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
void destroyPipelineCache(vk::PipelineCache pipelineCache, const vk::AllocationCallbacks *pAllocator, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
VULKAN_HPP_NODISCARD Result waitForFences(uint32_t fenceCount, const vk::Fence *pFences, vk::Bool32 waitAll, uint64_t timeout, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
void destroyPipelineLayout(vk::PipelineLayout pipelineLayout, const vk::AllocationCallbacks *pAllocator, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
VULKAN_HPP_NODISCARD Result allocateDescriptorSets(const vk::DescriptorSetAllocateInfo *pAllocateInfo, vk::DescriptorSet *pDescriptorSets, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
VULKAN_HPP_NODISCARD Result createPipelineCache(const vk::PipelineCacheCreateInfo *pCreateInfo, const vk::AllocationCallbacks *pAllocator, vk::PipelineCache *pPipelineCache, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
VULKAN_HPP_NODISCARD Result createSemaphore(const vk::SemaphoreCreateInfo *pCreateInfo, const vk::AllocationCallbacks *pAllocator, vk::Semaphore *pSemaphore, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
void destroyPipeline(vk::Pipeline pipeline, const vk::AllocationCallbacks *pAllocator, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
void destroyDescriptorSetLayout(vk::DescriptorSetLayout descriptorSetLayout, const vk::AllocationCallbacks *pAllocator, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
void destroyRenderPass(vk::RenderPass renderPass, const vk::AllocationCallbacks *pAllocator, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
VULKAN_HPP_NODISCARD Result createCommandPool(const vk::CommandPoolCreateInfo *pCreateInfo, const vk::AllocationCallbacks *pAllocator, vk::CommandPool *pCommandPool, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
Result freeDescriptorSets(vk::DescriptorPool descriptorPool, uint32_t descriptorSetCount, const vk::DescriptorSet *pDescriptorSets, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
void destroyFence(vk::Fence fence, const vk::AllocationCallbacks *pAllocator, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
void getQueue(uint32_t queueFamilyIndex, uint32_t queueIndex, vk::Queue *pQueue, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
VULKAN_HPP_NODISCARD Result allocateCommandBuffers(const vk::CommandBufferAllocateInfo *pAllocateInfo, vk::CommandBuffer *pCommandBuffers, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
VULKAN_HPP_NODISCARD Result getPipelineCacheData(vk::PipelineCache pipelineCache, size_t *pDataSize, void *pData, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
VULKAN_HPP_NODISCARD Result acquireNextImageKHR(vk::SwapchainKHR swapchain, uint64_t timeout, vk::Semaphore semaphore, vk::Fence fence, uint32_t *pImageIndex, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
void destroyFramebuffer(vk::Framebuffer framebuffer, const vk::AllocationCallbacks *pAllocator, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
VULKAN_HPP_NODISCARD Result createDebugUtilsMessengerEXT(const vk::DebugUtilsMessengerCreateInfoEXT *pCreateInfo, const vk::AllocationCallbacks *pAllocator, vk::DebugUtilsMessengerEXT *pMessenger, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
void destroy(const vk::AllocationCallbacks *pAllocator, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
VULKAN_HPP_NODISCARD Result enumeratePhysicalDevices(uint32_t *pPhysicalDeviceCount, vk::PhysicalDevice *pPhysicalDevices, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
void destroySurfaceKHR(vk::SurfaceKHR surface, const vk::AllocationCallbacks *pAllocator, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
void destroyDebugUtilsMessengerEXT(vk::DebugUtilsMessengerEXT messenger, const vk::AllocationCallbacks *pAllocator, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
void getProperties(vk::PhysicalDeviceProperties *pProperties, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
VULKAN_HPP_NODISCARD Result getSurfaceFormatsKHR(vk::SurfaceKHR surface, uint32_t *pSurfaceFormatCount, vk::SurfaceFormatKHR *pSurfaceFormats, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
VULKAN_HPP_NODISCARD Result presentKHR(const vk::PresentInfoKHR *pPresentInfo, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
VULKAN_HPP_NODISCARD Result submit(uint32_t submitCount, const vk::SubmitInfo *pSubmits, vk::Fence fence, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
virtual const char * what() const VULKAN_HPP_NOEXCEPT
Definition: vulkan.hpp:6206
std::vector< vk::Framebuffer > createFramebuffers(vk::Device const &device, vk::RenderPass &renderPass, std::vector< vk::ImageView > const &imageViews, vk::ImageView const &depthImageView, vk::Extent2D const &extent)
Definition: utils.cpp:111
vk::DebugUtilsMessengerCreateInfoEXT makeDebugUtilsMessengerCreateInfoEXT()
Definition: utils.cpp:1025
void copyToDevice(vk::Device const &device, vk::DeviceMemory const &deviceMemory, T const *pData, size_t count, vk::DeviceSize stride=sizeof(T))
Definition: utils.hpp:46
vk::ShaderModule createShaderModule(vk::Device const &device, vk::ShaderStageFlagBits shaderStage, std::string const &shaderText)
Definition: shaders.cpp:88
vk::RenderPass createRenderPass(vk::Device const &device, vk::Format colorFormat, vk::Format depthFormat, vk::AttachmentLoadOp loadOp, vk::ImageLayout colorFinalLayout)
Definition: utils.cpp:314
vk::Pipeline createGraphicsPipeline(vk::Device const &device, vk::PipelineCache const &pipelineCache, std::pair< vk::ShaderModule, vk::SpecializationInfo const * > const &vertexShaderData, std::pair< vk::ShaderModule, vk::SpecializationInfo const * > const &fragmentShaderData, uint32_t vertexStride, std::vector< std::pair< vk::Format, uint32_t >> const &vertexInputAttributeFormatOffset, vk::FrontFace frontFace, bool depthBuffered, vk::PipelineLayout const &pipelineLayout, vk::RenderPass const &renderPass)
Definition: utils.cpp:133
vk::Instance createInstance(std::string const &appName, std::string const &engineName, std::vector< std::string > const &layers, std::vector< std::string > const &extensions, uint32_t apiVersion)
Definition: utils.cpp:279
const uint64_t FenceTimeout
Definition: utils.hpp:31
vk::Device createDevice(vk::PhysicalDevice const &physicalDevice, uint32_t queueFamilyIndex, std::vector< std::string > const &extensions, vk::PhysicalDeviceFeatures const *physicalDeviceFeatures, void const *pNext)
Definition: utils.cpp:86
vk::DescriptorSetLayout createDescriptorSetLayout(vk::Device const &device, std::vector< std::tuple< vk::DescriptorType, uint32_t, vk::ShaderStageFlags >> const &bindingData, vk::DescriptorSetLayoutCreateFlags flags)
Definition: utils.cpp:73
std::pair< uint32_t, uint32_t > findGraphicsAndPresentQueueFamilyIndex(vk::PhysicalDevice physicalDevice, vk::SurfaceKHR const &surface)
Definition: utils.cpp:420
std::vector< std::string > getInstanceExtensions()
Definition: utils.cpp:477
void updateDescriptorSets(vk::Device const &device, vk::DescriptorSet const &descriptorSet, std::vector< std::tuple< vk::DescriptorType, vk::Buffer const &, vk::DeviceSize, vk::BufferView const & >> const &bufferData, vk::su::TextureData const &textureData, uint32_t bindingOffset)
Definition: utils.cpp:660
glm::mat4x4 createModelViewProjectionClipMatrix(vk::Extent2D const &extent)
Definition: math.cpp:31
vk::DescriptorPool createDescriptorPool(vk::Device const &device, std::vector< vk::DescriptorPoolSize > const &poolSizes)
Definition: utils.cpp:62
vk::SurfaceFormatKHR pickSurfaceFormat(std::vector< vk::SurfaceFormatKHR > const &formats)
Definition: utils.cpp:539
std::vector< std::string > getDeviceExtensions()
Definition: utils.cpp:472
@ eR32G32B32A32Sfloat
const std::string fragmentShaderText_T_C
Definition: shaders.hpp:96
const std::string vertexShaderText_PT_T
Definition: shaders.hpp:55
vk::ArrayWrapper1D< uint8_t, VK_UUID_SIZE > pipelineCacheUUID
vk::DeviceMemory deviceMemory
Definition: utils.hpp:160
void clear(vk::Device const &device)
Definition: utils.hpp:102
vk::Buffer buffer
Definition: utils.hpp:159
vk::ImageView imageView
Definition: utils.hpp:191
void clear(vk::Device const &device)
Definition: utils.hpp:181
vk::Format format
Definition: utils.hpp:188
vk::Extent2D extent
Definition: utils.hpp:203
vk::SurfaceKHR surface
Definition: utils.hpp:205
vk::SwapchainKHR swapChain
Definition: utils.hpp:231
std::vector< vk::ImageView > imageViews
Definition: utils.hpp:233
void clear(vk::Device const &device)
Definition: utils.hpp:219
void clear(vk::Device const &device)
Definition: utils.hpp:282
void setImage(vk::Device const &device, vk::CommandBuffer const &commandBuffer, ImageGenerator const &imageGenerator)
Definition: utils.hpp:293
#define VK_TRUE
Definition: vulkan_core.h:131
#define VK_UUID_SIZE
Definition: vulkan_core.h:135
@ VK_PIPELINE_CACHE_HEADER_VERSION_ONE
Definition: vulkan_core.h:1278
#define VK_WHOLE_SIZE
Definition: vulkan_core.h:132