Vulkan-Hpp
TexelBuffer.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 : TexelBuffer
16 // Use a texel buffer to draw a green triangle.
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 = "TexelBuffer";
28 static char const * EngineName = "Vulkan.hpp";
29 
30 static const std::string vertexShaderText = R"(
31 #version 400
32 
33 #extension GL_ARB_separate_shader_objects : enable
34 #extension GL_ARB_shading_language_420pack : enable
35 
36 layout (binding = 0) uniform samplerBuffer texels;
37 layout (location = 0) out vec4 outColor;
38 
39 vec2 vertices[3];
40 
41 void main()
42 {
43  float r = texelFetch(texels, 0).r;
44  float g = texelFetch(texels, 1).r;
45  float b = texelFetch(texels, 2).r;
46  outColor = vec4(r, g, b, 1.0);
47 
48  vertices[0] = vec2(-1.0, -1.0);
49  vertices[1] = vec2( 1.0, -1.0);
50  vertices[2] = vec2( 0.0, 1.0);
51  gl_Position = vec4(vertices[gl_VertexIndex % 3], 0.0, 1.0);
52 }
53 )";
54 
55 int main( int /*argc*/, char ** /*argv*/ )
56 {
57  const float texels[] = { 118.0f / 255.0f, 185.0f / 255.0f, 0.0f };
58 
59  try
60  {
61  vk::Instance instance = vk::su::createInstance( AppName, EngineName, {}, vk::su::getInstanceExtensions() );
62 #if !defined( NDEBUG )
64 #endif
65 
66  vk::PhysicalDevice physicalDevice = instance.enumeratePhysicalDevices().front();
67 
68  vk::PhysicalDeviceProperties physicalDeviceProperties = physicalDevice.getProperties();
69  if ( physicalDeviceProperties.limits.maxTexelBufferElements < 4 )
70  {
71  std::cout << "maxTexelBufferElements too small\n";
72  exit( -1 );
73  }
74 
75  vk::Format texelFormat = vk::Format::eR32Sfloat;
76  vk::FormatProperties formatProperties = physicalDevice.getFormatProperties( texelFormat );
78  {
79  std::cout << "R32_SFLOAT format unsupported for texel buffer\n";
80  exit( -1 );
81  }
82 
83  vk::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) );
84 
85  std::pair<uint32_t, uint32_t> graphicsAndPresentQueueFamilyIndex = vk::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface );
86  vk::Device device = vk::su::createDevice( physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() );
87 
88  vk::CommandPool commandPool = device.createCommandPool( { {}, graphicsAndPresentQueueFamilyIndex.first } );
89  vk::CommandBuffer commandBuffer =
91 
92  vk::Queue graphicsQueue = device.getQueue( graphicsAndPresentQueueFamilyIndex.first, 0 );
93  vk::Queue presentQueue = device.getQueue( graphicsAndPresentQueueFamilyIndex.second, 0 );
94 
95  vk::su::SwapChainData swapChainData( physicalDevice,
96  device,
97  surfaceData.surface,
98  surfaceData.extent,
100  {},
101  graphicsAndPresentQueueFamilyIndex.first,
102  graphicsAndPresentQueueFamilyIndex.second );
103 
104  vk::su::BufferData texelBufferData( physicalDevice, device, sizeof( texels ), vk::BufferUsageFlagBits::eUniformTexelBuffer );
105  texelBufferData.upload( device, texels );
106 
107  vk::BufferView texelBufferView = device.createBufferView( vk::BufferViewCreateInfo( {}, texelBufferData.buffer, texelFormat, 0, sizeof( texels ) ) );
108 
109  vk::DescriptorSetLayout descriptorSetLayout =
111  vk::PipelineLayout pipelineLayout = device.createPipelineLayout( vk::PipelineLayoutCreateInfo( vk::PipelineLayoutCreateFlags(), descriptorSetLayout ) );
112 
114  device, vk::su::pickSurfaceFormat( physicalDevice.getSurfaceFormatsKHR( surfaceData.surface ) ).format, vk::Format::eUndefined );
115 
116  glslang::InitializeProcess();
119  glslang::FinalizeProcess();
120 
121  std::vector<vk::Framebuffer> framebuffers = vk::su::createFramebuffers( device, renderPass, swapChainData.imageViews, vk::ImageView(), surfaceData.extent );
122 
124  vk::DescriptorSetAllocateInfo descriptorSetAllocateInfo( descriptorPool, descriptorSetLayout );
125  vk::DescriptorSet descriptorSet = device.allocateDescriptorSets( descriptorSetAllocateInfo ).front();
127  device, descriptorSet, { { vk::DescriptorType::eUniformTexelBuffer, texelBufferData.buffer, VK_WHOLE_SIZE, texelBufferView } }, {} );
128 
130  vk::Pipeline graphicsPipeline = vk::su::createGraphicsPipeline( device,
131  pipelineCache,
132  std::make_pair( vertexShaderModule, nullptr ),
133  std::make_pair( fragmentShaderModule, nullptr ),
134  0,
135  {},
137  false,
138  pipelineLayout,
139  renderPass );
140 
141  /* VULKAN_KEY_START */
142 
143  // Get the index of the next available swapchain image:
144  vk::Semaphore imageAcquiredSemaphore = device.createSemaphore( vk::SemaphoreCreateInfo() );
145  vk::ResultValue<uint32_t> currentBuffer = device.acquireNextImageKHR( swapChainData.swapChain, vk::su::FenceTimeout, imageAcquiredSemaphore, nullptr );
146  assert( currentBuffer.result == vk::Result::eSuccess );
147  assert( currentBuffer.value < framebuffers.size() );
148 
149  commandBuffer.begin( vk::CommandBufferBeginInfo() );
150 
151  vk::ClearValue clearValue;
152  clearValue.color = vk::ClearColorValue( 0.2f, 0.2f, 0.2f, 0.2f );
153  vk::RenderPassBeginInfo renderPassBeginInfo(
154  renderPass, framebuffers[currentBuffer.value], vk::Rect2D( vk::Offset2D( 0, 0 ), surfaceData.extent ), clearValue );
155 
156  commandBuffer.beginRenderPass( renderPassBeginInfo, vk::SubpassContents::eInline );
157  commandBuffer.bindPipeline( vk::PipelineBindPoint::eGraphics, graphicsPipeline );
158  commandBuffer.bindDescriptorSets( vk::PipelineBindPoint::eGraphics, pipelineLayout, 0, descriptorSet, nullptr );
159 
160  commandBuffer.setViewport(
161  0, vk::Viewport( 0.0f, 0.0f, static_cast<float>( surfaceData.extent.width ), static_cast<float>( surfaceData.extent.height ), 0.0f, 1.0f ) );
162  commandBuffer.setScissor( 0, vk::Rect2D( vk::Offset2D( 0, 0 ), surfaceData.extent ) );
163 
164  commandBuffer.draw( 3, 1, 0, 0 );
165  commandBuffer.endRenderPass();
166  commandBuffer.end();
167 
168  vk::Fence drawFence = device.createFence( vk::FenceCreateInfo() );
169 
171  vk::SubmitInfo submitInfo( imageAcquiredSemaphore, waitDestinationStageMask, commandBuffer );
172  graphicsQueue.submit( submitInfo, drawFence );
173 
174  while ( vk::Result::eTimeout == device.waitForFences( drawFence, VK_TRUE, vk::su::FenceTimeout ) )
175  ;
176 
177  vk::Result result = presentQueue.presentKHR( vk::PresentInfoKHR( {}, swapChainData.swapChain, currentBuffer.value ) );
178  switch ( result )
179  {
180  case vk::Result::eSuccess: break;
181  case vk::Result::eSuboptimalKHR: std::cout << "vk::Queue::presentKHR returned vk::Result::eSuboptimalKHR !\n"; break;
182  default: assert( false ); // an unexpected result is returned !
183  }
184  std::this_thread::sleep_for( std::chrono::milliseconds( 1000 ) );
185 
186  /* VULKAN_KEY_END */
187 
188  device.waitIdle();
189 
190  device.destroyFence( drawFence );
191  device.destroySemaphore( imageAcquiredSemaphore );
192  device.destroyPipeline( graphicsPipeline );
193  device.destroyPipelineCache( pipelineCache );
194  device.freeDescriptorSets( descriptorPool, descriptorSet );
195  device.destroyDescriptorPool( descriptorPool );
196  for ( auto framebuffer : framebuffers )
197  {
198  device.destroyFramebuffer( framebuffer );
199  }
200  device.destroyShaderModule( fragmentShaderModule );
201  device.destroyShaderModule( vertexShaderModule );
202  device.destroyRenderPass( renderPass );
203  device.destroyPipelineLayout( pipelineLayout );
204  device.destroyDescriptorSetLayout( descriptorSetLayout );
205  device.destroyBufferView( texelBufferView );
206  texelBufferData.clear( device );
207  swapChainData.clear( device );
208  device.freeCommandBuffers( commandPool, commandBuffer );
209  device.destroyCommandPool( commandPool );
210  device.destroy();
211  instance.destroySurfaceKHR( surfaceData.surface );
212 #if !defined( NDEBUG )
213  instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
214 #endif
215  instance.destroy();
216  }
217  catch ( vk::SystemError & err )
218  {
219  std::cout << "vk::SystemError: " << err.what() << std::endl;
220  exit( -1 );
221  }
222  catch ( std::exception & err )
223  {
224  std::cout << "std::exception: " << err.what() << std::endl;
225  exit( -1 );
226  }
227  catch ( ... )
228  {
229  std::cout << "unknown error\n";
230  exit( -1 );
231  }
232  return 0;
233 }
const std::string vertexShaderText
void cout(vk::SurfaceCapabilitiesKHR const &surfaceCapabilities)
int main(int, char **)
Definition: TexelBuffer.cpp:55
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
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
VULKAN_HPP_NODISCARD Result createBufferView(const vk::BufferViewCreateInfo *pCreateInfo, const vk::AllocationCallbacks *pAllocator, vk::BufferView *pView, 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
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
void destroyBufferView(vk::BufferView bufferView, const vk::AllocationCallbacks *pAllocator, 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
void getFormatProperties(vk::Format format, vk::FormatProperties *pFormatProperties, 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
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
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
const std::string fragmentShaderText_C_C
Definition: shaders.hpp:79
vk::FormatFeatureFlags bufferFeatures
vk::PhysicalDeviceLimits limits
void clear(vk::Device const &device)
Definition: utils.hpp:102
void upload(vk::Device const &device, DataType const &data) const
Definition: utils.hpp:109
vk::Buffer buffer
Definition: utils.hpp:159
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
VkClearColorValue color
#define VK_TRUE
Definition: vulkan_core.h:131
#define VK_WHOLE_SIZE
Definition: vulkan_core.h:132