MCPcopy Create free account
hub / github.com/KhronosGroup/Vulkan-Hpp / main

Function main

RAII_Samples/MultipleSets/MultipleSets.cpp:81–260  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79)";
80
81int main()
82{
83 try
84 {
85 vk::raii::Context context;
86 vk::raii::Instance instance = vk::raii::su::makeInstance( context, AppName, EngineName, {}, vk::su::getInstanceExtensions() );
87#if !defined( NDEBUG )
88 vk::raii::DebugUtilsMessengerEXT debugUtilsMessenger( instance, vk::su::makeDebugUtilsMessengerCreateInfoEXT() );
89#endif
90 vk::raii::PhysicalDevice physicalDevice = vk::raii::PhysicalDevices( instance ).front();
91
92 vk::FormatProperties formatProperties = physicalDevice.getFormatProperties( vk::Format::eR8G8B8A8Unorm );
93 if ( !( formatProperties.optimalTilingFeatures & vk::FormatFeatureFlagBits::eColorAttachment ) )
94 {
95 std::cout << "vk::Format::eR8G8B8A8Unorm format unsupported for input attachment\n";
96 exit( -1 );
97 }
98
99 vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) );
100
101 std::pair<uint32_t, uint32_t> graphicsAndPresentQueueFamilyIndex =
102 vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface );
103 vk::raii::Device device = vk::raii::su::makeDevice( physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() );
104
105 vk::raii::CommandPool commandPool = vk::raii::CommandPool( device, { {}, graphicsAndPresentQueueFamilyIndex.first } );
106 vk::raii::CommandBuffer commandBuffer = vk::raii::su::makeCommandBuffer( device, commandPool );
107
108 vk::raii::Queue graphicsQueue( device, graphicsAndPresentQueueFamilyIndex.first, 0 );
109 vk::raii::Queue presentQueue( device, graphicsAndPresentQueueFamilyIndex.second, 0 );
110
111 vk::raii::su::SwapChainData swapChainData( physicalDevice,
112 device,
113 surfaceData.surface,
114 surfaceData.extent,
115 vk::ImageUsageFlagBits::eColorAttachment | vk::ImageUsageFlagBits::eTransferSrc,
116 {},
117 graphicsAndPresentQueueFamilyIndex.first,
118 graphicsAndPresentQueueFamilyIndex.second );
119
120 vk::raii::su::DepthBufferData depthBufferData( physicalDevice, device, vk::Format::eD16Unorm, surfaceData.extent );
121
122 vk::raii::su::TextureData textureData( physicalDevice, device );
123
124 commandBuffer.begin( vk::CommandBufferBeginInfo() );
125 textureData.setImage( commandBuffer, vk::su::MonochromeImageGenerator( { 118, 185, 0 } ) );
126
127 vk::raii::su::BufferData uniformBufferData( physicalDevice, device, sizeof( glm::mat4x4 ), vk::BufferUsageFlagBits::eUniformBuffer );
128 glm::mat4x4 mvpcMatrix = vk::su::createModelViewProjectionClipMatrix( surfaceData.extent );
129 vk::raii::su::copyToDevice( uniformBufferData.deviceMemory, mvpcMatrix );
130
131 vk::Format colorFormat = vk::su::pickSurfaceFormat( physicalDevice.getSurfaceFormatsKHR( surfaceData.surface ) ).format;
132 vk::raii::RenderPass renderPass = vk::raii::su::makeRenderPass( device, colorFormat, depthBufferData.format );
133
134 glslang::InitializeProcess();
135 vk::raii::ShaderModule vertexShaderModule = vk::raii::su::makeShaderModule( device, vk::ShaderStageFlagBits::eVertex, vertexShaderText );
136 vk::raii::ShaderModule fragmentShaderModule = vk::raii::su::makeShaderModule( device, vk::ShaderStageFlagBits::eFragment, fragmentShaderText );
137 glslang::FinalizeProcess();
138

Callers

nothing calls this directly

Calls 15

makeInstanceFunction · 0.85
getInstanceExtensionsFunction · 0.85
makeDeviceFunction · 0.85
getDeviceExtensionsFunction · 0.85
makeCommandBufferFunction · 0.85
pickSurfaceFormatFunction · 0.85
makeRenderPassFunction · 0.85
makeShaderModuleFunction · 0.85
makeFramebuffersFunction · 0.85

Tested by

no test coverage detected