Vulkan-Hpp
InputAttachment.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 : InputAttachment
16 // Use an input attachment to draw a yellow triangle
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 // no need to ignore any warnings with GCC
24 #else
25 // unknow compiler... just ignore the warnings for yourselves ;)
26 #endif
27 
28 #include "../utils/geometries.hpp"
29 #include "../utils/math.hpp"
30 #include "../utils/shaders.hpp"
31 #include "../utils/utils.hpp"
32 #include "SPIRV/GlslangToSpv.h"
33 
34 #include <iostream>
35 #include <thread>
36 
37 static char const * AppName = "InputAttachment";
38 static char const * EngineName = "Vulkan.hpp";
39 
40 static std::string vertexShaderText = R"(
41 #version 450
42 
43 vec2 vertices[3];
44 
45 void main()
46 {
47  vertices[0] = vec2(-1.0f, -1.0f);
48  vertices[1] = vec2( 1.0f, -1.0f);
49  vertices[2] = vec2( 0.0f, 1.0f);
50 
51  gl_Position = vec4(vertices[gl_VertexIndex % 3], 0.0f, 1.0f);
52 }
53 )";
54 
55 // Use subpassLoad to read from input attachment
56 static const char * fragmentShaderText = R"(
57 #version 450
58 
59 layout (input_attachment_index = 0, set = 0, binding = 0) uniform subpassInput inputAttachment;
60 
61 layout (location = 0) out vec4 outColor;
62 
63 void main()
64 {
65  outColor = subpassLoad(inputAttachment);
66 }
67 )";
68 
69 int main( int /*argc*/, char ** /*argv*/ )
70 {
71  try
72  {
73  vk::Instance instance = vk::su::createInstance( AppName, EngineName, {}, vk::su::getInstanceExtensions() );
74 #if !defined( NDEBUG )
76 #endif
77 
78  vk::PhysicalDevice physicalDevice = instance.enumeratePhysicalDevices().front();
79 
80  vk::FormatProperties formatProperties = physicalDevice.getFormatProperties( vk::Format::eR8G8B8A8Unorm );
82  {
83  std::cout << "vk::Format::eR8G8B8A8Unorm format unsupported for input attachment\n";
84  exit( -1 );
85  }
86 
87  vk::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) );
88 
89  std::pair<uint32_t, uint32_t> graphicsAndPresentQueueFamilyIndex = vk::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface );
90  vk::Device device = vk::su::createDevice( physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() );
91 
92  vk::CommandPool commandPool = device.createCommandPool( { {}, graphicsAndPresentQueueFamilyIndex.first } );
93  vk::CommandBuffer commandBuffer =
95 
96  vk::Queue graphicsQueue = device.getQueue( graphicsAndPresentQueueFamilyIndex.first, 0 );
97  vk::Queue presentQueue = device.getQueue( graphicsAndPresentQueueFamilyIndex.second, 0 );
98 
99  vk::su::SwapChainData swapChainData( physicalDevice,
100  device,
101  surfaceData.surface,
102  surfaceData.extent,
104  {},
105  graphicsAndPresentQueueFamilyIndex.first,
106  graphicsAndPresentQueueFamilyIndex.second );
107 
108  /* VULKAN_KEY_START */
109 
110  // Create a framebuffer with 2 attachments, one the color attachment the shaders render into, and the other an input
111  // attachment which will be cleared to yellow, and then used by the shaders to color the drawn triangle. Final
112  // result should be a yellow triangle
113 
114  // Create the image that will be used as the input attachment
115  // The image for the color attachment is the presentable image already created as part of the SwapChainData
116  vk::ImageCreateInfo imageCreateInfo( vk::ImageCreateFlags(),
118  swapChainData.colorFormat,
119  vk::Extent3D( surfaceData.extent, 1 ),
120  1,
121  1,
125  vk::Image inputImage = device.createImage( imageCreateInfo );
126 
127  vk::MemoryRequirements memoryRequirements = device.getImageMemoryRequirements( inputImage );
128  uint32_t memoryTypeIndex = vk::su::findMemoryType( physicalDevice.getMemoryProperties(), memoryRequirements.memoryTypeBits, vk::MemoryPropertyFlags() );
129  vk::DeviceMemory inputMemory = device.allocateMemory( vk::MemoryAllocateInfo( memoryRequirements.size, memoryTypeIndex ) );
130  device.bindImageMemory( inputImage, inputMemory, 0 );
131 
132  // Set the image layout to TRANSFER_DST_OPTIMAL to be ready for clear
133  commandBuffer.begin( vk::CommandBufferBeginInfo() );
135 
136  commandBuffer.clearColorImage( inputImage,
138  vk::ClearColorValue( 1.0f, 1.0f, 0.0f, 0.0f ),
140 
141  // Transitioning the layout of the inputImage from TransferDstOptimal to ShaderReadOnlyOptimal is implicitly done by a subpassDependency in the
142  // RenderPassCreateInfo below
143 
144  vk::ImageViewCreateInfo imageViewCreateInfo(
145  {}, inputImage, vk::ImageViewType::e2D, swapChainData.colorFormat, {}, { vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1 } );
146  vk::ImageView inputAttachmentView = device.createImageView( imageViewCreateInfo );
147 
149  vk::DescriptorSetLayout descriptorSetLayout =
151 
152  vk::PipelineLayout pipelineLayout = device.createPipelineLayout( vk::PipelineLayoutCreateInfo( vk::PipelineLayoutCreateFlags(), descriptorSetLayout ) );
153 
154  std::array<vk::AttachmentDescription, 2> attachments = {
155  // First attachment is the color attachment - clear at the beginning of the renderpass and transition layout to
156  // PRESENT_SRC_KHR at the end of renderpass
158  swapChainData.colorFormat,
166  // Second attachment is input attachment. Once cleared it should have width*height yellow pixels.
167  // Doing a subpassLoad in the fragment shader should give the shader the color at the fragments x,y location from
168  // the input attachment
170  swapChainData.colorFormat,
176  vk::ImageLayout::eTransferDstOptimal, // transition layout from TransferDstOptimal to ShaderReadOnlyOptimal
178  };
181  vk::SubpassDescription subpassDescription( {}, vk::PipelineBindPoint::eGraphics, inputReference, colorReference );
182  vk::SubpassDependency subpassDependency( VK_SUBPASS_EXTERNAL,
183  0,
187  vk::AccessFlagBits::eColorAttachmentWrite // needed for first attachment
189  vk::AccessFlagBits::eColorAttachmentRead // needed for second attachment
190  );
191  vk::RenderPassCreateInfo renderPassCreateInfo( {}, attachments, subpassDescription, subpassDependency );
192  vk::RenderPass renderPass = device.createRenderPass( renderPassCreateInfo );
193 
194  glslang::InitializeProcess();
196  vk::ShaderModule fragmentShaderModule = vk::su::createShaderModule( device, vk::ShaderStageFlagBits::eFragment, fragmentShaderText );
197  glslang::FinalizeProcess();
198 
199  std::vector<vk::Framebuffer> framebuffers =
200  vk::su::createFramebuffers( device, renderPass, swapChainData.imageViews, inputAttachmentView, surfaceData.extent );
201 
203  vk::DescriptorPool descriptorPool =
205 
206  vk::DescriptorSetAllocateInfo descriptorSetAllocateInfo( descriptorPool, descriptorSetLayout );
207  vk::DescriptorSet descriptorSet = device.allocateDescriptorSets( descriptorSetAllocateInfo ).front();
208 
209  vk::DescriptorImageInfo inputImageInfo( nullptr, inputAttachmentView, vk::ImageLayout::eShaderReadOnlyOptimal );
210  vk::WriteDescriptorSet writeDescriptorSet( descriptorSet, 0, 0, vk::DescriptorType::eInputAttachment, inputImageInfo );
211  device.updateDescriptorSets( writeDescriptorSet, nullptr );
212 
214  vk::Pipeline graphicsPipeline = vk::su::createGraphicsPipeline( device,
215  pipelineCache,
216  std::make_pair( vertexShaderModule, nullptr ),
217  std::make_pair( fragmentShaderModule, nullptr ),
218  0,
219  {},
221  false,
222  pipelineLayout,
223  renderPass );
224 
225  vk::Semaphore imageAcquiredSemaphore = device.createSemaphore( vk::SemaphoreCreateInfo() );
226 
227  vk::ResultValue<uint32_t> nexImage =
228  device.acquireNextImage2KHR( vk::AcquireNextImageInfoKHR( swapChainData.swapChain, UINT64_MAX, imageAcquiredSemaphore, {}, 1 ) );
229  assert( nexImage.result == vk::Result::eSuccess );
230  uint32_t currentBuffer = nexImage.value;
231 
232  vk::ClearValue clearValue;
233  clearValue.color = vk::ClearColorValue( 0.2f, 0.2f, 0.2f, 0.2f );
234  commandBuffer.beginRenderPass(
235  vk::RenderPassBeginInfo( renderPass, framebuffers[currentBuffer], vk::Rect2D( vk::Offset2D( 0, 0 ), surfaceData.extent ), clearValue ),
237  commandBuffer.bindPipeline( vk::PipelineBindPoint::eGraphics, graphicsPipeline );
238  commandBuffer.bindDescriptorSets( vk::PipelineBindPoint::eGraphics, pipelineLayout, 0, descriptorSet, nullptr );
239 
240  commandBuffer.setViewport(
241  0, vk::Viewport( 0.0f, 0.0f, static_cast<float>( surfaceData.extent.width ), static_cast<float>( surfaceData.extent.height ), 0.0f, 1.0f ) );
242  commandBuffer.setScissor( 0, vk::Rect2D( vk::Offset2D( 0, 0 ), surfaceData.extent ) );
243 
244  commandBuffer.draw( 3, 1, 0, 0 );
245  commandBuffer.endRenderPass();
246  commandBuffer.end();
247 
248  /* VULKAN_KEY_END */
249 
250  vk::su::submitAndWait( device, graphicsQueue, commandBuffer );
251 
252  vk::Result result = presentQueue.presentKHR( vk::PresentInfoKHR( {}, swapChainData.swapChain, currentBuffer ) );
253  switch ( result )
254  {
255  case vk::Result::eSuccess: break;
256  case vk::Result::eSuboptimalKHR: std::cout << "vk::Queue::presentKHR returned vk::Result::eSuboptimalKHR !\n"; break;
257  default: assert( false ); // an unexpected result is returned !
258  }
259  std::this_thread::sleep_for( std::chrono::milliseconds( 1000 ) );
260 
261  device.destroySemaphore( imageAcquiredSemaphore );
262  device.destroyPipeline( graphicsPipeline );
263  device.destroyPipelineCache( pipelineCache );
264  device.freeDescriptorSets( descriptorPool, descriptorSet );
265  device.destroyDescriptorPool( descriptorPool );
266  for ( auto framebuffer : framebuffers )
267  {
268  device.destroyFramebuffer( framebuffer );
269  }
270  device.destroyShaderModule( fragmentShaderModule );
271  device.destroyShaderModule( vertexShaderModule );
272  device.destroyRenderPass( renderPass );
273  device.destroyPipelineLayout( pipelineLayout );
274  device.destroyDescriptorSetLayout( descriptorSetLayout );
275  device.destroyImageView( inputAttachmentView );
276  device.destroyImage( inputImage ); // destroy the inputImage before freeing the bound inputMemory !
277  device.freeMemory( inputMemory );
278  swapChainData.clear( device );
279  device.freeCommandBuffers( commandPool, commandBuffer );
280  device.destroyCommandPool( commandPool );
281  device.destroy();
282  instance.destroySurfaceKHR( surfaceData.surface );
283 #if !defined( NDEBUG )
284  instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
285 #endif
286  instance.destroy();
287  }
288  catch ( vk::SystemError & err )
289  {
290  std::cout << "vk::SystemError: " << err.what() << std::endl;
291  exit( -1 );
292  }
293  catch ( std::exception & err )
294  {
295  std::cout << "std::exception: " << err.what() << std::endl;
296  exit( -1 );
297  }
298  catch ( ... )
299  {
300  std::cout << "unknown error\n";
301  exit( -1 );
302  }
303  return 0;
304 }
int main(int, char **)
const std::string vertexShaderText
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 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 clearColorImage(vk::Image image, vk::ImageLayout imageLayout, const vk::ClearColorValue *pColor, uint32_t rangeCount, const vk::ImageSubresourceRange *pRanges, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
void getImageMemoryRequirements(vk::Image image, vk::MemoryRequirements *pMemoryRequirements, 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
VULKAN_HPP_NODISCARD Result allocateMemory(const vk::MemoryAllocateInfo *pAllocateInfo, const vk::AllocationCallbacks *pAllocator, vk::DeviceMemory *pMemory, 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
VULKAN_HPP_NODISCARD Result acquireNextImage2KHR(const vk::AcquireNextImageInfoKHR *pAcquireInfo, uint32_t *pImageIndex, 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 destroyImageView(vk::ImageView imageView, const vk::AllocationCallbacks *pAllocator, 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 createImageView(const vk::ImageViewCreateInfo *pCreateInfo, const vk::AllocationCallbacks *pAllocator, vk::ImageView *pView, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
VULKAN_HPP_NODISCARD_WHEN_NO_EXCEPTIONS ResultValueType< void >::type bindImageMemory(vk::Image image, vk::DeviceMemory memory, vk::DeviceSize memoryOffset, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const
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
void freeMemory(vk::DeviceMemory memory, const vk::AllocationCallbacks *pAllocator, 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
VULKAN_HPP_NODISCARD Result createRenderPass(const vk::RenderPassCreateInfo *pCreateInfo, const vk::AllocationCallbacks *pAllocator, vk::RenderPass *pRenderPass, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
VULKAN_HPP_NODISCARD Result createImage(const vk::ImageCreateInfo *pCreateInfo, const vk::AllocationCallbacks *pAllocator, vk::Image *pImage, 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 createDescriptorSetLayout(const vk::DescriptorSetLayoutCreateInfo *pCreateInfo, const vk::AllocationCallbacks *pAllocator, vk::DescriptorSetLayout *pSetLayout, 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 destroyImage(vk::Image image, 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 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 getFormatProperties(vk::Format format, vk::FormatProperties *pFormatProperties, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
void getMemoryProperties(vk::PhysicalDeviceMemoryProperties *pMemoryProperties, 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
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
vk::ShaderModule createShaderModule(vk::Device const &device, vk::ShaderStageFlagBits shaderStage, std::string const &shaderText)
Definition: shaders.cpp:88
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
uint32_t findMemoryType(vk::PhysicalDeviceMemoryProperties const &memoryProperties, uint32_t typeBits, vk::MemoryPropertyFlags requirementsMask)
Definition: utils.cpp:456
void setImageLayout(vk::CommandBuffer const &commandBuffer, vk::Image image, vk::Format format, vk::ImageLayout oldImageLayout, vk::ImageLayout newImageLayout)
Definition: utils.cpp:574
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
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
std::pair< uint32_t, uint32_t > findGraphicsAndPresentQueueFamilyIndex(vk::PhysicalDevice physicalDevice, vk::SurfaceKHR const &surface)
Definition: utils.cpp:420
void submitAndWait(vk::Device const &device, vk::Queue const &queue, vk::CommandBuffer const &commandBuffer)
Definition: utils.cpp:651
std::vector< std::string > getInstanceExtensions()
Definition: utils.cpp:477
std::vector< std::string > getDeviceExtensions()
Definition: utils.cpp:472
vk::FormatFeatureFlags optimalTilingFeatures
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
vk::Format colorFormat
Definition: utils.hpp:230
void clear(vk::Device const &device)
Definition: utils.hpp:219
VkClearColorValue color
#define VK_REMAINING_MIP_LEVELS
Definition: vulkan_core.h:129
#define VK_SUBPASS_EXTERNAL
Definition: vulkan_core.h:130
#define VK_REMAINING_ARRAY_LAYERS
Definition: vulkan_core.h:128