static Display *dpy;
static Window win;
+static int initflags;
static VkInstance vk;
static VkPhysicalDevice vkpdev;
win = w;
}
-int vk_init(void)
+int vk_init(unsigned int flags, unsigned int *usedflags)
{
+ initflags = flags;
if(create_instance() == -1) return -1;
if(create_surface() == -1) return -1;
if(choose_phys_dev() == -1) return -1;
if(create_device() == -1) return -1;
+
+ if(initflags != flags) {
+ if(usedflags) {
+ *usedflags = initflags;
+ } else {
+ vk_cleanup();
+ return -1;
+ }
+ }
return 0;
}
vksc_extent.width = xsz;
vksc_extent.height = ysz;
- return create_swapchain();
+ if(create_swapchain() == -1) return -1;
+
+ /* TODO create depth/stencil buffers as needed (initflags) */
+ return 0;
}
#define ARRSZ(arr) (sizeof arr / sizeof *arr)
VkDeviceQueueCreateInfo qinf = {0};
VkPhysicalDeviceFeatures feat = {0};
VkDeviceCreateInfo devinf = {0};
- const char *ext[ARRSZ(known_devext_list)];
+ const char *ext[ARRSZ(known_devext_list) + 16];
int i, num_ext;
vkEnumerateDeviceExtensionProperties(vkpdev, 0, &dev_ext_count, 0);
}
}
+ if(initflags & VKINIT_RAY) {
+ if(have_ext(dev_ext, dev_ext_count, "VK_KHR_acceleration_structure") &&
+ have_ext(dev_ext, dev_ext_count, "VK_KHR_ray_tracing_pipeline")) {
+ ext[num_ext++] = "VK_KHR_acceleration_structure";
+ ext[num_ext++] = "VK_KHR_ray_tracing_pipeline";
+ } else {
+ initflags &= ~VKINIT_RAY;
+ }
+ }
+
qinf.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
qinf.queueFamilyIndex = vkqfam_idx;
qinf.queueCount = 1;