Vulkan-Hpp
PushConstants.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 : PushConstants
16 // Use push constants in a simple shader, validate the correct value was read.
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 <iostream>
34 #include <thread>
35 
36 static char const * AppName = "PushConstants";
37 static char const * EngineName = "Vulkan.hpp";
38 
39 const std::string fragmentShaderText = R"(
40 #version 400
41 
42 #extension GL_ARB_separate_shader_objects : enable
43 #extension GL_ARB_shading_language_420pack : enable
44 
45 layout (push_constant) uniform pushBlock
46 {
47  int iFoo;
48  float fBar;
49 } pushConstantsBlock;
50 
51 layout (location = 0) in vec2 inTexCoords;
52 
53 layout (location = 0) out vec4 outColor;
54 
55 void main()
56 {
57  vec4 green = vec4(0.0f, 1.0f, 0.0f, 1.0f);
58  vec4 red = vec4(1.0f, 0.0f, 0.0f, 1.0f);
59 
60  // Start with passing color
61  vec4 resColor = green;
62 
63  // See if we've read in the correct push constants
64  if ((pushConstantsBlock.iFoo != 2) || (pushConstantsBlock.fBar != 1.0f))
65  {
66  resColor = red;
67  }
68 
69  // Create a border to see the cube more easily
70  if ((inTexCoords.x < 0.01f) || (0.99f < inTexCoords.x)
71  || (inTexCoords.y < 0.01f) || (0.99f < inTexCoords.y))
72  {
73  resColor *= vec4(0.1f, 0.1f, 0.1f, 1.0f);
74  }
75 
76  outColor = resColor;
77 }
78 )";
79 
80 int main( int /*argc*/, char ** /*argv*/ )
81 {
82  try
83  {
84  vk::Instance instance = vk::su::createInstance( AppName, EngineName, {}, vk::su::getInstanceExtensions() );
85 #if !defined( NDEBUG )
87 #endif
88 
89  vk::PhysicalDevice physicalDevice = instance.enumeratePhysicalDevices().front();
90 
91  vk::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) );
92 
93  std::pair<uint32_t, uint32_t> graphicsAndPresentQueueFamilyIndex = vk::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface );
94  vk::Device device = vk::su::createDevice( physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() );
95 
96  vk::CommandPool commandPool = device.createCommandPool( { {}, graphicsAndPresentQueueFamilyIndex.first } );
97  vk::CommandBuffer commandBuffer =
99 
100  vk::Queue graphicsQueue = device.getQueue( graphicsAndPresentQueueFamilyIndex.first, 0 );
101  vk::Queue presentQueue = device.getQueue( graphicsAndPresentQueueFamilyIndex.second, 0 );
102 
103  vk::su::SwapChainData swapChainData( physicalDevice,
104  device,
105  surfaceData.surface,
106  surfaceData.extent,
108  {},
109  graphicsAndPresentQueueFamilyIndex.first,
110  graphicsAndPresentQueueFamilyIndex.second );
111 
112  vk::su::DepthBufferData depthBufferData( physicalDevice, device, vk::Format::eD16Unorm, surfaceData.extent );
113 
114  vk::su::BufferData uniformBufferData( physicalDevice, device, sizeof( glm::mat4x4 ), vk::BufferUsageFlagBits::eUniformBuffer );
115  glm::mat4x4 mvpcMatrix = vk::su::createModelViewProjectionClipMatrix( surfaceData.extent );
116  vk::su::copyToDevice( device, uniformBufferData.deviceMemory, mvpcMatrix );
117 
119  device, vk::su::pickSurfaceFormat( physicalDevice.getSurfaceFormatsKHR( surfaceData.surface ) ).format, depthBufferData.format );
120 
121  glslang::InitializeProcess();
124  glslang::FinalizeProcess();
125 
126  std::vector<vk::Framebuffer> framebuffers =
127  vk::su::createFramebuffers( device, renderPass, swapChainData.imageViews, depthBufferData.imageView, surfaceData.extent );
128 
129  vk::su::BufferData vertexBufferData( physicalDevice, device, sizeof( texturedCubeData ), vk::BufferUsageFlagBits::eVertexBuffer );
130  vk::su::copyToDevice( device, vertexBufferData.deviceMemory, texturedCubeData, sizeof( texturedCubeData ) / sizeof( texturedCubeData[0] ) );
131 
132  // Create binding and layout for the following, matching contents of shader
133  // binding 0 = uniform buffer (MVP)
134  vk::DescriptorSetLayout descriptorSetLayout =
136 
137  /* VULKAN_KEY_START */
138 
139  // Set up our push constant range, which mirrors the declaration of
140  vk::PushConstantRange pushConstantRanges( vk::ShaderStageFlagBits::eFragment, 0, 8 );
141  vk::PipelineLayout pipelineLayout =
142  device.createPipelineLayout( vk::PipelineLayoutCreateInfo( vk::PipelineLayoutCreateFlags(), descriptorSetLayout, pushConstantRanges ) );
143 
144  // Create a single pool to contain data for our descriptor set
145  std::array<vk::DescriptorPoolSize, 2> poolSizes = { vk::DescriptorPoolSize( vk::DescriptorType::eUniformBuffer, 1 ),
147  vk::DescriptorPool descriptorPool =
149 
150  // Populate descriptor sets
151  vk::DescriptorSetAllocateInfo descriptorSetAllocateInfo( descriptorPool, descriptorSetLayout );
152  vk::DescriptorSet descriptorSet = device.allocateDescriptorSets( descriptorSetAllocateInfo ).front();
153 
154  // Populate with info about our uniform buffer for MVP
155  vk::DescriptorBufferInfo bufferInfo( uniformBufferData.buffer, 0, sizeof( glm::mat4x4 ) );
156  vk::WriteDescriptorSet writeDescriptorSet( descriptorSet, 0, 0, vk::DescriptorType::eUniformBuffer, {}, bufferInfo );
157  device.updateDescriptorSets( writeDescriptorSet, nullptr );
158 
159  // Create our push constant data, which matches shader expectations
160  std::array<unsigned, 2> pushConstants = { { (unsigned)2, (unsigned)0x3F800000 } };
161 
162  // Ensure we have enough room for push constant data
163  assert( ( sizeof( pushConstants ) <= physicalDevice.getProperties().limits.maxPushConstantsSize ) && "Too many push constants" );
164  commandBuffer.begin( vk::CommandBufferBeginInfo() );
165  commandBuffer.pushConstants<unsigned>( pipelineLayout, vk::ShaderStageFlagBits::eFragment, 0, pushConstants );
166 
167  /* VULKAN_KEY_END */
168 
170  vk::Pipeline graphicsPipeline = vk::su::createGraphicsPipeline( device,
171  pipelineCache,
172  std::make_pair( vertexShaderModule, nullptr ),
173  std::make_pair( fragmentShaderModule, nullptr ),
174  sizeof( texturedCubeData[0] ),
177  true,
178  pipelineLayout,
179  renderPass );
180 
181  vk::Semaphore imageAcquiredSemaphore = device.createSemaphore( vk::SemaphoreCreateInfo() );
182  vk::ResultValue<uint32_t> currentBuffer = device.acquireNextImageKHR( swapChainData.swapChain, vk::su::FenceTimeout, imageAcquiredSemaphore, nullptr );
183  assert( currentBuffer.result == vk::Result::eSuccess );
184  assert( currentBuffer.value < framebuffers.size() );
185 
186  std::array<vk::ClearValue, 2> clearValues;
187  clearValues[0].color = vk::ClearColorValue( 0.2f, 0.2f, 0.2f, 0.2f );
188  clearValues[1].depthStencil = vk::ClearDepthStencilValue( 1.0f, 0 );
189 
190  vk::RenderPassBeginInfo renderPassBeginInfo(
191  renderPass, framebuffers[currentBuffer.value], vk::Rect2D( vk::Offset2D( 0, 0 ), surfaceData.extent ), clearValues );
192  commandBuffer.beginRenderPass( renderPassBeginInfo, vk::SubpassContents::eInline );
193  commandBuffer.bindPipeline( vk::PipelineBindPoint::eGraphics, graphicsPipeline );
194  commandBuffer.bindDescriptorSets( vk::PipelineBindPoint::eGraphics, pipelineLayout, 0, descriptorSet, nullptr );
195 
196  commandBuffer.bindVertexBuffers( 0, vertexBufferData.buffer, { 0 } );
197  commandBuffer.setViewport(
198  0, vk::Viewport( 0.0f, 0.0f, static_cast<float>( surfaceData.extent.width ), static_cast<float>( surfaceData.extent.height ), 0.0f, 1.0f ) );
199  commandBuffer.setScissor( 0, vk::Rect2D( vk::Offset2D( 0, 0 ), surfaceData.extent ) );
200 
201  commandBuffer.draw( 12 * 3, 1, 0, 0 );
202  commandBuffer.endRenderPass();
203  commandBuffer.end();
204 
205  vk::Fence drawFence = device.createFence( vk::FenceCreateInfo() );
206 
208  vk::SubmitInfo submitInfo( imageAcquiredSemaphore, waitDestinationStageMask, commandBuffer );
209  graphicsQueue.submit( submitInfo, drawFence );
210 
211  while ( vk::Result::eTimeout == device.waitForFences( drawFence, VK_TRUE, vk::su::FenceTimeout ) )
212  ;
213 
214  vk::Result result = presentQueue.presentKHR( vk::PresentInfoKHR( {}, swapChainData.swapChain, currentBuffer.value ) );
215  switch ( result )
216  {
217  case vk::Result::eSuccess: break;
218  case vk::Result::eSuboptimalKHR: std::cout << "vk::Queue::presentKHR returned vk::Result::eSuboptimalKHR !\n"; break;
219  default: assert( false ); // an unexpected result is returned !
220  }
221  std::this_thread::sleep_for( std::chrono::milliseconds( 1000 ) );
222 
223  device.destroyFence( drawFence );
224  device.destroySemaphore( imageAcquiredSemaphore );
225  device.destroyPipeline( graphicsPipeline );
226  device.destroyPipelineCache( pipelineCache );
227  device.freeDescriptorSets( descriptorPool, descriptorSet );
228  device.destroyDescriptorPool( descriptorPool );
229  vertexBufferData.clear( device );
230  for ( auto framebuffer : framebuffers )
231  {
232  device.destroyFramebuffer( framebuffer );
233  }
234  device.destroyShaderModule( fragmentShaderModule );
235  device.destroyShaderModule( vertexShaderModule );
236  device.destroyRenderPass( renderPass );
237  device.destroyPipelineLayout( pipelineLayout );
238  device.destroyDescriptorSetLayout( descriptorSetLayout );
239  uniformBufferData.clear( device );
240  depthBufferData.clear( device );
241  swapChainData.clear( device );
242  device.freeCommandBuffers( commandPool, commandBuffer );
243  device.destroyCommandPool( commandPool );
244  device.destroy();
245  instance.destroySurfaceKHR( surfaceData.surface );
246 #if !defined( NDEBUG )
247  instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
248 #endif
249  instance.destroy();
250  }
251  catch ( vk::SystemError & err )
252  {
253  std::cout << "vk::SystemError: " << err.what() << std::endl;
254  exit( -1 );
255  }
256  catch ( std::exception & err )
257  {
258  std::cout << "std::exception: " << err.what() << std::endl;
259  exit( -1 );
260  }
261  catch ( ... )
262  {
263  std::cout << "unknown error\n";
264  exit( -1 );
265  }
266  return 0;
267 }
int main(int, char **)
const std::string fragmentShaderText
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 pushConstants(vk::PipelineLayout layout, vk::ShaderStageFlags stageFlags, uint32_t offset, uint32_t size, const void *pValues, 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 updateDescriptorSets(uint32_t descriptorWriteCount, const vk::WriteDescriptorSet *pDescriptorWrites, uint32_t descriptorCopyCount, const vk::CopyDescriptorSet *pDescriptorCopies, 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 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
VULKAN_HPP_NODISCARD Result createDescriptorPool(const vk::DescriptorPoolCreateInfo *pCreateInfo, const vk::AllocationCallbacks *pAllocator, vk::DescriptorPool *pDescriptorPool, 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
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
@ eR32G32B32A32Sfloat
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
#define VK_TRUE
Definition: vulkan_core.h:131