foo
authorJohn Tsiombikas <nuclear@member.fsf.org>
Sun, 19 Dec 2021 07:43:34 +0000 (09:43 +0200)
committerJohn Tsiombikas <nuclear@member.fsf.org>
Sun, 19 Dec 2021 07:43:34 +0000 (09:43 +0200)
src/vk.c

index 1fcba58..edc3bf1 100644 (file)
--- a/src/vk.c
+++ b/src/vk.c
@@ -20,7 +20,7 @@ static uint32_t inst_ext_count, dev_ext_count, inst_layers_count;
 static VkPhysicalDevice *pdev_list;
 static uint32_t num_pdev;
 
-static int have_debug_report;
+static int have_raytrace, have_debug_report;
 
 #define ARRSZ(arr)     (sizeof arr / sizeof *arr)
 static const char *known_layer_list[] = {
@@ -103,6 +103,8 @@ static int create_instance(void)
        for(i=0; i<inst_ext_count; i++) {
                printf(" - %s\n", inst_ext[i].extensionName);
        }
+
+       have_raytrace = have_inst_ext("VK_KHR_ray_tracing_pipeline");
        have_debug_report = have_inst_ext("VK_KHR_debug_report");
 
        for(i=0; i<ARRSZ(known_layer_list); i++) {
@@ -139,6 +141,7 @@ static int create_device(void)
 {
        int i;
        VkPhysicalDeviceProperties2 pdevprop2;
+       VkPhysicalDeviceRayTracingPipelinePropertiesKHR raypipe_prop;
        VkPhysicalDeviceAccelerationStructurePropertiesKHR rayacc_prop;
 
        vkEnumeratePhysicalDevices(vk, &num_pdev, 0);
@@ -147,15 +150,29 @@ static int create_device(void)
 
        printf("Found %d physical devices\n", num_pdev);
        for(i=0; i<num_pdev; i++) {
-               memset(&rayacc_prop, 0, sizeof rayacc_prop);
-               rayacc_prop.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ACCELERATION_STRUCTURE_PROPERTIES_KHR;
+               if(have_raytrace) {
+                       memset(&rayacc_prop, 0, sizeof rayacc_prop);
+                       rayacc_prop.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ACCELERATION_STRUCTURE_PROPERTIES_KHR;
+
+                       memset(&raypipe_prop, 0, sizeof raypipe_prop);
+                       raypipe_prop.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_PIPELINE_PROPERTIES_KHR;
+                       raypipe_prop.pNext = &rayacc_prop;
+               }
 
                memset(&pdevprop2, 0, sizeof pdevprop2);
                pdevprop2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2;
-               pdevprop2.pNext = &rayacc_prop;
+               pdevprop2.pNext = have_raytrace ? &raypipe_prop : 0;
 
                vkGetPhysicalDeviceProperties2(pdev_list[i], &pdevprop2);
                printf(" %d: %s\n", i, pdevprop2.properties.deviceName);
+               if(have_raytrace) {
+                       printf("  Raytracing properties:\n");
+                       printf("    max ray recursion: %u\n", raypipe_prop.maxRayRecursionDepth);
+                       printf("    max ray dispatch: %u\n", raypipe_prop.maxRayDispatchInvocationCount);
+                       printf("    max leaf geometry: %llu\n", (unsigned long long)rayacc_prop.maxGeometryCount);
+                       printf("    max leaf primitves: %llu\n", (unsigned long long)rayacc_prop.maxPrimitiveCount);
+                       printf("    max instances: %llu\n", (unsigned long long)rayacc_prop.maxInstanceCount);
+               }
        }
 
        return 0;