@@ -273,7 +273,7 @@ static inline void clearVector(T& v, S func, bool downsize = true)
273273
274274// ---------------------------- VULKAN DEVICE MANAGEMENT ----------------------------
275275
276- double GPUDisplayBackendVulkan::checkDevice (vk::PhysicalDevice device, const std::vector<const char *>& reqDeviceExtensions)
276+ double GPUDisplayBackendVulkan::checkDevice (vk::PhysicalDevice device, const std::vector<const char *>& reqDeviceExtensions, bool silent )
277277{
278278 double score = -1 .;
279279 vk::PhysicalDeviceProperties deviceProperties = device.getProperties ();
@@ -287,18 +287,20 @@ double GPUDisplayBackendVulkan::checkDevice(vk::PhysicalDevice device, const std
287287 bool found = false ;
288288 for (uint32_t i = 0 ; i < queueFamilies.size (); i++) {
289289 if (!(queueFamilies[i].queueFlags & vk::QueueFlagBits::eGraphics)) {
290- return (- 1 ) ;
290+ continue ;
291291 }
292292 vk::Bool32 presentSupport = device.getSurfaceSupportKHR (i, mSurface );
293293 if (!presentSupport) {
294- return (- 1 ) ;
294+ continue ;
295295 }
296296 mGraphicsFamily = i;
297297 found = true ;
298298 break ;
299299 }
300300 if (!found) {
301- GPUInfo (" %s ignored due to missing queue properties" , &deviceProperties.deviceName [0 ]);
301+ if (!silent) {
302+ GPUInfo (" %s ignored due to missing queue properties" , &deviceProperties.deviceName [0 ]);
303+ }
302304 return (-1 );
303305 }
304306
@@ -313,13 +315,17 @@ double GPUDisplayBackendVulkan::checkDevice(vk::PhysicalDevice device, const std
313315 }
314316 }
315317 if (extensionsFound < reqDeviceExtensions.size ()) {
316- GPUInfo (" %s ignored due to missing extensions" , &deviceProperties.deviceName [0 ]);
318+ if (!silent) {
319+ GPUInfo (" %s ignored due to missing extensions" , &deviceProperties.deviceName [0 ]);
320+ }
317321 return (-1 );
318322 }
319323
320324 updateSwapChainDetails (device);
321325 if (mSwapChainDetails .formats .empty () || mSwapChainDetails .presentModes .empty ()) {
322- GPUInfo (" %s ignored due to incompatible swap chain" , &deviceProperties.deviceName [0 ]);
326+ if (!silent) {
327+ GPUInfo (" %s ignored due to incompatible swap chain" , &deviceProperties.deviceName [0 ]);
328+ }
323329 return (-1 );
324330 }
325331
@@ -454,21 +460,22 @@ void GPUDisplayBackendVulkan::createDevice()
454460 if (!mPhysicalDevice ) {
455461 throw std::runtime_error (" All available Vulkan devices unsuited" );
456462 }
463+ if (checkDevice (mPhysicalDevice , reqDeviceExtensions, true ) <= 0 ) {
464+ throw std::runtime_error (" Selected vulkan device is incompatible" );
465+ }
457466
458467 updateSwapChainDetails (mPhysicalDevice );
459468 vk::PhysicalDeviceProperties deviceProperties = mPhysicalDevice .getProperties ();
460469 vk::PhysicalDeviceFeatures deviceFeatures = mPhysicalDevice .getFeatures ();
461470 vk::FormatProperties depth32FormatProperties = mPhysicalDevice .getFormatProperties (vk::Format::eD32Sfloat);
462471 vk::FormatProperties depth64FormatProperties = mPhysicalDevice .getFormatProperties (vk::Format::eD32SfloatS8Uint);
463- vk::FormatProperties formatProperties = mPhysicalDevice .getFormatProperties (mSurfaceFormat .format );
464472 GPUInfo (" Using physical Vulkan device %s" , &deviceProperties.deviceName [0 ]);
465473 mMaxMSAAsupported = getMaxUsableSampleCount (deviceProperties);
466474 mZSupported = (bool )(depth32FormatProperties.optimalTilingFeatures & vk::FormatFeatureFlagBits::eDepthStencilAttachment);
467475 mStencilSupported = (bool )(depth64FormatProperties.optimalTilingFeatures & vk::FormatFeatureFlagBits::eDepthStencilAttachment);
468- mCubicFilterSupported = (bool )(formatProperties.optimalTilingFeatures & vk::FormatFeatureFlagBits::eSampledImageFilterCubicEXT);
469476 bool mailboxSupported = std::find (mSwapChainDetails .presentModes .begin (), mSwapChainDetails .presentModes .end (), vk::PresentModeKHR::eMailbox) != mSwapChainDetails .presentModes .end ();
470477 if (mDisplay ->GetProcessingSettings ().debugLevel >= 2 ) {
471- GPUInfo (" Max MSAA: %d, 32 bit Z buffer %d, 32 bit Z buffer + stencil buffer %d, Cubic Filtering %d, Mailbox present mode %d\n " , (int32_t )mMaxMSAAsupported , (int32_t )mZSupported , (int32_t )mStencilSupported , ( int32_t ) mCubicFilterSupported , (int32_t )mailboxSupported);
478+ GPUInfo (" Max MSAA: %d, 32 bit Z buffer %d, 32 bit Z buffer + stencil buffer %d, Mailbox present mode %d\n " , (int32_t )mMaxMSAAsupported , (int32_t )mZSupported , (int32_t )mStencilSupported , (int32_t )mailboxSupported);
472479 }
473480
474481 vk::DeviceQueueCreateInfo queueCreateInfo{};
@@ -1893,8 +1900,8 @@ void GPUDisplayBackendVulkan::OpenGLPrint(const char* s, float x, float y, float
18931900 scale *= 0 .25f ; // Font size is 48 to have nice bitmap, scale to size 12
18941901 }
18951902
1896- for (const char * c = s; *c; c++) {
1897- if ((int32_t )*c > (int32_t )mFontSymbols .size ()) {
1903+ for (const unsigned char * c = ( const unsigned char *) s; *c; c++) {
1904+ if ((int32_t )*c >= (int32_t )mFontSymbols .size ()) {
18981905 GPUError (" Trying to draw unsupported symbol: %d > %d\n " , (int32_t )*c, (int32_t )mFontSymbols .size ());
18991906 continue ;
19001907 }
0 commit comments