Enumerate physical devices to check for any supporting shaderFloat64

This commit is contained in:
Camden Dixie O'Brien 2025-01-17 15:12:46 +00:00
parent 03364ad387
commit a8acdc4b01

20
main.c
View File

@ -15,6 +15,7 @@
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define CLAMP(x, min, max) MAX((min), MIN(x, (max)))
#define PHYSICAL_DEV_BUFFER_SIZE 8
#define QUEUE_FAMILY_PROP_BUFFER_SIZE 16
#define EXT_PROP_BUFFER_SIZE 256
#define SURFACE_FMT_BUFFER_SIZE 64
@ -96,15 +97,22 @@ int main(void)
assert(result == VK_SUCCESS);
// Select a physical device
VkPhysicalDevice physical_devs[PHYSICAL_DEV_BUFFER_SIZE];
uint32_t dev_count = PHYSICAL_DEV_BUFFER_SIZE;
result = vkEnumeratePhysicalDevices(inst, &dev_count, physical_devs);
assert(result == VK_SUCCESS);
bool found_physical_dev = false;
VkPhysicalDevice physical_dev;
uint32_t dev_count = 1;
result = vkEnumeratePhysicalDevices(inst, &dev_count, &physical_dev);
assert(result == VK_SUCCESS || result == VK_INCOMPLETE);
for (unsigned i = 0; i < dev_count; ++i) {
// Check that the device supports double precision
VkPhysicalDeviceFeatures features;
vkGetPhysicalDeviceFeatures(physical_dev, &features);
assert(features.shaderFloat64);
vkGetPhysicalDeviceFeatures(physical_devs[i], &features);
if (features.shaderFloat64) {
physical_dev = physical_devs[i];
found_physical_dev = true;
}
}
assert(found_physical_dev);
// Select queue family
uint32_t queue_family_count = QUEUE_FAMILY_PROP_BUFFER_SIZE;