@@ -59,7 +59,7 @@ add to that function.
5959[,c++]
6060----
6161for (const auto& device : devices) {
62- physicalDevice = std::make_unique<vk::raii::PhysicalDevice>( device) ;
62+ physicalDevice = device;
6363 break;
6464}
6565----
@@ -93,14 +93,15 @@ function would look like this:
9393
9494[,c++]
9595----
96- bool isDeviceSuitable(VkPhysicalDevice device) {
97- auto deviceProperties = device.getProperties();
98- auto deviceFeatures = device.getFeatures();
99- if (deviceProperties.deviceType == vk::PhysicalDeviceType::eDiscreteGpu &&
100- deviceFeatures.geometryShader) {
101- physicalDevice = std::make_unique<vk::raii::PhysicalDevice>(device);
102- break;
103- }
96+ bool isDeviceSuitable(vk::raii::PhysicalDevice physicalDevice) {
97+ auto deviceProperties = physicalDevice.getProperties();
98+ auto deviceFeatures = physicalDevice.getFeatures();
99+
100+ if (deviceProperties.deviceType == vk::PhysicalDeviceType::eDiscreteGpu && deviceFeatures.geometryShader) {
101+ return true;
102+ }
103+
104+ return false;
104105}
105106----
106107
@@ -117,7 +118,7 @@ something like that as follows:
117118...
118119
119120void pickPhysicalDevice() {
120- auto devices = vk::raii::PhysicalDevices( * instance );
121+ auto devices = vk::raii::PhysicalDevices( instance );
121122 if (devices.empty()) {
122123 throw std::runtime_error( "failed to find GPUs with Vulkan support!" );
123124 }
@@ -146,7 +147,7 @@ void pickPhysicalDevice() {
146147
147148 // Check if the best candidate is suitable at all
148149 if (candidates.rbegin()->first > 0) {
149- physicalDevice = std::make_unique<vk::raii::PhysicalDevice>( candidates.rbegin()->second) ;
150+ physicalDevice = candidates.rbegin()->second;
150151 } else {
151152 throw std::runtime_error("failed to find a suitable GPU!");
152153 }
@@ -218,9 +219,9 @@ could look like this:
218219
219220[,c++]
220221----
221- uint32_t findQueueFamilies(VkPhysicalDevice device ) {
222+ uint32_t findQueueFamilies(vk::raii::PhysicalDevice physicalDevice ) {
222223 // find the index of the first queue family that supports graphics
223- std::vector<vk::QueueFamilyProperties> queueFamilyProperties = physicalDevice-> getQueueFamilyProperties();
224+ std::vector<vk::QueueFamilyProperties> queueFamilyProperties = physicalDevice. getQueueFamilyProperties();
224225
225226 // get the first index into queueFamilyProperties which supports graphics
226227 auto graphicsQueueFamilyProperty =
0 commit comments