Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1d212da

Browse files
authored
Fix device scoring example and a typo
1 parent c7c0649 commit 1d212da

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

03_Drawing_a_triangle/00_Setup/03_Physical_devices_and_queue_families.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ VkPhysicalDeviceFeatures deviceFeatures;
103103
vkGetPhysicalDeviceFeatures(physicalDevice, &deviceFeatures);
104104
```
105105

106-
There more details that can be queried from devices that we'll discuss later
106+
There are more details that can be queried from devices that we'll discuss later
107107
concerning device memory and queue families (see the next section).
108108

109109
As an example, let's say we consider our application only usable for dedicated
@@ -137,16 +137,16 @@ void pickPhysicalDevice() {
137137
...
138138
139139
// Use an ordered map to automatically sort candidates by increasing score
140-
std::map<int, VkPhysicalDevice> candidates;
140+
std::multimap<int, VkPhysicalDevice> candidates;
141141
142142
for (const auto& device : devices) {
143143
int score = rateDeviceSuitability(device);
144-
candidates[score] = device;
144+
candidates.insert(std::make_pair(score, device));
145145
}
146146
147147
// Check if the best candidate is suitable at all
148-
if (candidates.begin()->first > 0) {
149-
physicalDevice = candidates.begin()->second;
148+
if (candidates.rbegin()->first > 0) {
149+
physicalDevice = candidates.rbegin()->second;
150150
} else {
151151
throw std::runtime_error("failed to find a suitable GPU!");
152152
}

0 commit comments

Comments
 (0)