@@ -1096,6 +1096,7 @@ struct VulkanRenderer
10961096
10971097 bool debugMode ;
10981098 bool preferLowPower ;
1099+ bool requireHardwareAcceleration ;
10991100 SDL_PropertiesID props ;
11001101 Uint32 allowedFramesInFlight ;
11011102
@@ -11343,6 +11344,15 @@ static bool VULKAN_INTERNAL_GetDeviceRank(
1134311344 deviceType = physicalDeviceProperties .deviceType ;
1134411345 }
1134511346
11347+ if (renderer -> requireHardwareAcceleration ) {
11348+ if (deviceType != VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU &&
11349+ deviceType != VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU &&
11350+ deviceType != VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU ) {
11351+ // In addition to CPU, "Other" drivers (including layered drivers) don't count as hardware-accelerated
11352+ return 0 ;
11353+ }
11354+ }
11355+
1134611356 /* Apply a large bias on the devicePriority so that we always respect the order in the priority arrays.
1134711357 * We also rank by e.g. VRAM which should have less influence than the device type.
1134811358 */
@@ -11818,6 +11828,8 @@ static bool VULKAN_PrepareDriver(SDL_VideoDevice *_this, SDL_PropertiesID props)
1181811828 renderer -> desiredDeviceFeatures .sampleRateShading = VK_TRUE ;
1181911829 renderer -> desiredDeviceFeatures .imageCubeArray = VK_TRUE ;
1182011830
11831+ renderer -> requireHardwareAcceleration = SDL_GetBooleanProperty (props , SDL_PROP_GPU_DEVICE_CREATE_VULKAN_REQUIRE_HARDWARE_ACCELERATION , false);
11832+
1182111833 result = VULKAN_INTERNAL_PrepareVulkan (renderer );
1182211834 if (result ) {
1182311835 renderer -> vkDestroyInstance (renderer -> instance , NULL );
@@ -11867,6 +11879,8 @@ static SDL_GPUDevice *VULKAN_CreateDevice(bool debugMode, bool preferLowPower, S
1186711879 renderer -> desiredDeviceFeatures .sampleRateShading = VK_TRUE ;
1186811880 renderer -> desiredDeviceFeatures .imageCubeArray = VK_TRUE ;
1186911881
11882+ renderer -> requireHardwareAcceleration = SDL_GetBooleanProperty (props , SDL_PROP_GPU_DEVICE_CREATE_VULKAN_REQUIRE_HARDWARE_ACCELERATION , false);
11883+
1187011884 if (!VULKAN_INTERNAL_PrepareVulkan (renderer )) {
1187111885 SET_STRING_ERROR ("Failed to initialize Vulkan!" );
1187211886 SDL_free (renderer );
0 commit comments