-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.c
34 lines (30 loc) · 1.04 KB
/
example.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <assert.h>
#include "vulkan.h"
int main() {
putenv("VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation");
const char* extensions[] = {
"VK_KHR_surface",
"VK_KHR_xcb_surface",
"VK_EXT_debug_report",
"VK_EXT_debug_utils",
};
VkInstanceCreateInfo info = {
.s_type = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
.enabled_extension_count = 4,
.pp_enabled_extension_names = extensions,
};
VkInstance instance;
vk_create_instance(&info, NULL, &instance);
assert(instance);
uint32_t physical_device_count = 1;
VkPhysicalDevice physical_device;
vk_enumerate_physical_devices(instance, &physical_device_count, &physical_device);
assert(physical_device);
VkPhysicalDeviceProperties properties;
vk_get_physical_device_properties(physical_device, &properties);
printf("Using physical device '%s'\n", properties.device_name);
vk_destroy_instance(instance, NULL);
}