blob: 01bd016a17c5d92a1218fc1a783265496316d9f3 (
plain) (
blame)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# include <luma/main.hh>
# include <cstdint>
# include <string>
# include <vulkan/vulkan.h>
# include <wayland-client.h>
# include <xcb/xcb.h>
void luma::initgfx() {
luma::dat.gfxisinit = true;
if constexpr(luma::usex == 0x1) {
luma::dbgmsg("Creating X connection... ");
luma::dat.xconn = xcb_connect(nullptr,nullptr);
luma::dat.xscrn = xcb_setup_roots_iterator(xcb_get_setup(luma::dat.xconn)).data;
luma::dat.xwin = xcb_generate_id(luma::dat.xconn);
luma::dbgmsg("O.K.\n");
}
else {
luma::dbgmsg("Creating Wayland connection... ");
luma::dat.wldisp = wl_display_connect(nullptr);
if(luma::dat.wldisp == nullptr) {
luma::dbgmsg("Error\n");
}
else {
luma::dbgmsg("O.K.\n");
}
}
luma::dat.vkappinf.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
luma::dat.vkappinf.pApplicationName = "Luma Standard Library";
luma::dat.vkappinf.pEngineName = "Luma Standard Library";
luma::dat.vkinstcrtinf.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
luma::dat.vkinstcrtinf.pApplicationInfo = &luma::dat.vkappinf;
luma::dat.vkinstcrtinf.enabledLayerCount = 0x0;
luma::dbgmsg("Creating Vulkan instance... ");
luma::dat.vkreslt = vkCreateInstance(&luma::dat.vkinstcrtinf,nullptr,&luma::dat.vkinst);
if((luma::dat.vkreslt != VK_SUCCESS)) {
luma::dbgmsg("Error\n");
}
else {
luma::dbgmsg("O.K.\n");
}
std::uint32_t extcount = 0x0;
luma::dat.vkexts = std::vector<VkExtensionProperties>(extcount);
::vkEnumerateInstanceExtensionProperties(nullptr,&extcount,luma::dat.vkexts.data());
luma::dbgmsg(std::basic_string<char> {std::to_string(extcount) + " Vulkan extensions supported.\n"s}.c_str());
luma::dbgmsg("The following Vulkan extensions are supported:\n");
for(auto const & ext : luma::dat.vkexts) {
luma::dbgmsg(ext.extensionName);
}
std::uint32_t devcount = 0x0;
::vkEnumeratePhysicalDevices(luma::dat.vkinst,&devcount,luma::dat.vkphysdevs.data());
luma::dbgmsg(std::basic_string<char> {std::to_string(devcount) + " Vulkan-compatible device(s) found.\n"s}.c_str());
}
|