Vulkan-Hpp
PushDescriptors.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 : PushDescriptors
16 // Use Push Descriptors to Draw Textured Cube
17 
18 #include "../utils/geometries.hpp"
19 #include "../utils/math.hpp"
20 #include "../utils/shaders.hpp"
21 #include "../utils/utils.hpp"
22 #include "SPIRV/GlslangToSpv.h"
23 
24 #include <iostream>
25 #include <thread>
26 
27 static char const * AppName = "PushDescriptors";
28 static char const * EngineName = "Vulkan.hpp";
29 
30 int main( int /*argc*/, char ** /*argv*/ )
31 {
32  try
33  {
34 #if ( VULKAN_HPP_DISPATCH_LOADER_DYNAMIC == 1 )
35  // initialize the DipatchLoaderDynamic to use
37 #endif
38 
39  /* VULKAN_KEY_START */
40 
41  // To use PUSH_DESCRIPTOR, you must also specify GET_PHYSICAL_DEVICE_PROPERTIES_2
42  std::vector<vk::ExtensionProperties> extensionProperties = vk::enumerateInstanceExtensionProperties();
43  auto propertyIterator =
44  std::find_if( extensionProperties.begin(),
45  extensionProperties.end(),
46  []( vk::ExtensionProperties ep ) { return ( strcmp( ep.extensionName, VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME ) == 0 ); } );
47  if ( propertyIterator == extensionProperties.end() )
48  {
49  std::cout << "No GET_PHYSICAL_DEVICE_PROPERTIES_2 extension" << std::endl;
50  return 0;
51  }
52 
53  std::vector<std::string> instanceExtensions = vk::su::getInstanceExtensions();
54  instanceExtensions.push_back( VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME );
55 
56  vk::Instance instance = vk::su::createInstance( AppName, EngineName, {}, instanceExtensions );
57 #if !defined( NDEBUG )
59 #endif
60 
61  vk::PhysicalDevice physicalDevice = instance.enumeratePhysicalDevices().front();
62 
63  // Once instance is created, need to make sure the extension is available
64  extensionProperties = physicalDevice.enumerateDeviceExtensionProperties();
65  propertyIterator = std::find_if( extensionProperties.begin(),
66  extensionProperties.end(),
67  []( vk::ExtensionProperties ep ) { return ( strcmp( ep.extensionName, VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME ) == 0 ); } );
68  if ( propertyIterator == extensionProperties.end() )
69  {
70  std::cout << "No extension for push descriptors" << std::endl;
71  return 0;
72  }
73 
74  std::vector<std::string> deviceExtensions = vk::su::getDeviceExtensions();
75  deviceExtensions.push_back( VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME );
76 
77  vk::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) );
78 
79  std::pair<uint32_t, uint32_t> graphicsAndPresentQueueFamilyIndex = vk::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface );
80  vk::Device device = vk::su::createDevice( physicalDevice, graphicsAndPresentQueueFamilyIndex.first, deviceExtensions );
81 
82  vk::CommandPool commandPool = device.createCommandPool( { {}, graphicsAndPresentQueueFamilyIndex.first } );
83  vk::CommandBuffer commandBuffer =
85 
86  vk::Queue graphicsQueue = device.getQueue( graphicsAndPresentQueueFamilyIndex.first, 0 );
87  vk::Queue presentQueue = device.getQueue( graphicsAndPresentQueueFamilyIndex.second, 0 );
88 
89  vk::su::SwapChainData swapChainData( physicalDevice,
90  device,
91  surfaceData.surface,
92  surfaceData.extent,
94  {},
95  graphicsAndPresentQueueFamilyIndex.first,
96  graphicsAndPresentQueueFamilyIndex.second );
97 
98  vk::su::DepthBufferData depthBufferData( physicalDevice, device, vk::Format::eD16Unorm, surfaceData.extent );
99 
100  vk::su::TextureData textureData( physicalDevice, device );
101  commandBuffer.begin( vk::CommandBufferBeginInfo() );
102  textureData.setImage( device, commandBuffer, vk::su::CheckerboardImageGenerator() );
103 
104  vk::su::BufferData uniformBufferData( physicalDevice, device, sizeof( glm::mat4x4 ), vk::BufferUsageFlagBits::eUniformBuffer );
105  glm::mat4x4 mvpcMatrix = vk::su::createModelViewProjectionClipMatrix( surfaceData.extent );
106  vk::su::copyToDevice( device, uniformBufferData.deviceMemory, mvpcMatrix );
107 
108  // Need to specify that descriptor set layout will be for push descriptors
109  vk::DescriptorSetLayout descriptorSetLayout =
114  vk::PipelineLayout pipelineLayout = device.createPipelineLayout( vk::PipelineLayoutCreateInfo( vk::PipelineLayoutCreateFlags(), descriptorSetLayout ) );
115 
117  device, vk::su::pickSurfaceFormat( physicalDevice.getSurfaceFormatsKHR( surfaceData.surface ) ).format, depthBufferData.format );
118 
119  glslang::InitializeProcess();
122  glslang::FinalizeProcess();
123 
124  std::vector<vk::Framebuffer> framebuffers =
125  vk::su::createFramebuffers( device, renderPass, swapChainData.imageViews, depthBufferData.imageView, surfaceData.extent );
126 
127  vk::su::BufferData vertexBufferData( physicalDevice, device, sizeof( texturedCubeData ), vk::BufferUsageFlagBits::eVertexBuffer );
128  vk::su::copyToDevice( device, vertexBufferData.deviceMemory, texturedCubeData, sizeof( texturedCubeData ) / sizeof( texturedCubeData[0] ) );
129 
131  vk::Pipeline graphicsPipeline = vk::su::createGraphicsPipeline( device,
132  pipelineCache,
133  std::make_pair( vertexShaderModule, nullptr ),
134  std::make_pair( fragmentShaderModule, nullptr ),
135  sizeof( texturedCubeData[0] ),
138  true,
139  pipelineLayout,
140  renderPass );
141 
142  // Get the index of the next available swapchain image:
143  vk::Semaphore imageAcquiredSemaphore = device.createSemaphore( vk::SemaphoreCreateInfo() );
144  vk::ResultValue<uint32_t> currentBuffer = device.acquireNextImageKHR( swapChainData.swapChain, vk::su::FenceTimeout, imageAcquiredSemaphore, nullptr );
145  assert( currentBuffer.result == vk::Result::eSuccess );
146  assert( currentBuffer.value < framebuffers.size() );
147 
148  std::array<vk::ClearValue, 2> clearValues;
149  clearValues[0].color = vk::ClearColorValue( 0.2f, 0.2f, 0.2f, 0.2f );
150  clearValues[1].depthStencil = vk::ClearDepthStencilValue( 1.0f, 0 );
151  vk::RenderPassBeginInfo renderPassBeginInfo(
152  renderPass, framebuffers[currentBuffer.value], vk::Rect2D( vk::Offset2D( 0, 0 ), surfaceData.extent ), clearValues );
153  commandBuffer.beginRenderPass( renderPassBeginInfo, vk::SubpassContents::eInline );
154  commandBuffer.bindPipeline( vk::PipelineBindPoint::eGraphics, graphicsPipeline );
155 
156  vk::DescriptorBufferInfo bufferInfo( uniformBufferData.buffer, 0, sizeof( glm::mat4x4 ) );
157  vk::DescriptorImageInfo imageInfo( textureData.sampler, textureData.imageData->imageView, vk::ImageLayout::eShaderReadOnlyOptimal );
158  vk::WriteDescriptorSet writeDescriptorSets[2] = { vk::WriteDescriptorSet( {}, 0, 0, vk::DescriptorType::eUniformBuffer, {}, bufferInfo ),
160 
161  // this call is from an extension and needs the dynamic dispatcher !!
162  commandBuffer.pushDescriptorSetKHR( vk::PipelineBindPoint::eGraphics, pipelineLayout, 0, { 2, writeDescriptorSets } );
163 
164  commandBuffer.bindVertexBuffers( 0, vertexBufferData.buffer, { 0 } );
165  commandBuffer.setViewport(
166  0, vk::Viewport( 0.0f, 0.0f, static_cast<float>( surfaceData.extent.width ), static_cast<float>( surfaceData.extent.height ), 0.0f, 1.0f ) );
167  commandBuffer.setScissor( 0, vk::Rect2D( vk::Offset2D( 0, 0 ), surfaceData.extent ) );
168 
169  commandBuffer.draw( 12 * 3, 1, 0, 0 );
170  commandBuffer.endRenderPass();
171  commandBuffer.end();
172 
173  vk::Fence drawFence = device.createFence( vk::FenceCreateInfo() );
174 
176  vk::SubmitInfo submitInfo( imageAcquiredSemaphore, waitDestinationStageMask, commandBuffer );
177  graphicsQueue.submit( submitInfo, drawFence );
178 
179  while ( vk::Result::eTimeout == device.waitForFences( drawFence, VK_TRUE, vk::su::FenceTimeout ) )
180  ;
181 
182  vk::Result result = presentQueue.presentKHR( vk::PresentInfoKHR( {}, swapChainData.swapChain, currentBuffer.value ) );
183  switch ( result )
184  {
185  case vk::Result::eSuccess: break;
186  case vk::Result::eSuboptimalKHR: std::cout << "vk::Queue::presentKHR returned vk::Result::eSuboptimalKHR !\n"; break;
187  default: assert( false ); // an unexpected result is returned !
188  }
189  std::this_thread::sleep_for( std::chrono::milliseconds( 1000 ) );
190 
191  /* VULKAN_KEY_END */
192 
193  device.waitIdle();
194 
195  device.destroyFence( drawFence );
196  device.destroySemaphore( imageAcquiredSemaphore );
197  device.destroyPipeline( graphicsPipeline );
198  device.destroyPipelineCache( pipelineCache );
199  vertexBufferData.clear( device );
200  for ( auto framebuffer : framebuffers )
201  {
202  device.destroyFramebuffer( framebuffer );
203  }
204  device.destroyShaderModule( fragmentShaderModule );
205  device.destroyShaderModule( vertexShaderModule );
206  device.destroyRenderPass( renderPass );
207  device.destroyPipelineLayout( pipelineLayout );
208  device.destroyDescriptorSetLayout( descriptorSetLayout );
209  textureData.clear( device );
210  uniformBufferData.clear( device );
211  depthBufferData.clear( device );
212  swapChainData.clear( device );
213  device.freeCommandBuffers( commandPool, commandBuffer );
214  device.destroyCommandPool( commandPool );
215  device.destroy();
216  instance.destroySurfaceKHR( surfaceData.surface );
217 #if !defined( NDEBUG )
218  instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
219 #endif
220  instance.destroy();
221  }
222  catch ( vk::SystemError & err )
223  {
224  std::cout << "vk::SystemError: " << err.what() << std::endl;
225  exit( -1 );
226  }
227  catch ( std::exception & err )
228  {
229  std::cout << "std::exception: " << err.what() << std::endl;
230  exit( -1 );
231  }
232  catch ( ... )
233  {
234  std::cout << "unknown error\n";
235  exit( -1 );
236  }
237  return 0;
238 }
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 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
void pushDescriptorSetKHR(vk::PipelineBindPoint pipelineBindPoint, vk::PipelineLayout layout, uint32_t set, uint32_t descriptorWriteCount, const vk::WriteDescriptorSet *pDescriptorWrites, 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 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 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
void destroyFence(vk::Fence fence, const vk::AllocationCallbacks *pAllocator, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS ResultValueType< void >::type waitIdle(Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const
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 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
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 enumerateDeviceExtensionProperties(const char *pLayerName, uint32_t *pPropertyCount, vk::ExtensionProperties *pProperties, 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
glm::mat4x4 createModelViewProjectionClipMatrix(vk::Extent2D const &extent)
Definition: math.cpp:31
vk::SurfaceFormatKHR pickSurfaceFormat(std::vector< vk::SurfaceFormatKHR > const &formats)
Definition: utils.cpp:539
std::vector< std::string > getDeviceExtensions()
Definition: utils.cpp:472
VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE Result enumerateInstanceExtensionProperties(const char *pLayerName, uint32_t *pPropertyCount, vk::ExtensionProperties *pProperties, Dispatch const &d) VULKAN_HPP_NOEXCEPT
@ eR32G32B32A32Sfloat
const std::string fragmentShaderText_T_C
Definition: shaders.hpp:96
const std::string vertexShaderText_PT_T
Definition: shaders.hpp:55
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
vk::Sampler sampler
Definition: utils.hpp:329
std::unique_ptr< ImageData > imageData
Definition: utils.hpp:328
#define VK_TRUE
Definition: vulkan_core.h:131
#define VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME
Definition: vulkan_core.h:8848
#define VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME
Definition: vulkan_core.h:9172
#define VULKAN_HPP_DEFAULT_DISPATCHER