summarylogtreecommitdiffstats
path: root/fedora-fixes.diff
blob: 45d829108931c02e2a41aaf941ef7681697932d0 (plain)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
diff --git a/Makefile.am b/Makefile.am
index 4ec1270..1f2011a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2,16 +2,7 @@ CPPFLAGS =					\
 	$(MESA_CPPFLAGS)			\
 	-D_POSIX_C_SOURCE=200809L
 
-common_CFLAGS = -Wall -O0 -g3
-
-CFLAGS = -std=c11				\
-	 $(common_CFLAGS)			\
-	-Werror=implicit-function-declaration	\
-	-Werror=missing-prototypes
-
-CXXFLAGS = -std=c++11 $(common_CFLAGS)
-
-noinst_PROGRAMS = vkcube
+bin_PROGRAMS = vkcube
 
 BUILT_SOURCES = \
 	vkcube.vert.spv.h			\
@@ -33,4 +24,4 @@ vkcube_SOURCES =				\
 CLEANFILES = $(BUILT_SOURCES)
 
 vkcube_CFLAGS = $(CFLAGS) $(MINIGBM_CPPFLAGS) $(LIBDRM_CFLAGS) $(WAYLAND_CFLAGS)
-vkcube_LDADD = $(MINIGBM_LDFLAGS) $(MESA_LDFLAGS) $(LIBDRM_LIBS) $(WAYLAND_LIBS) -lgbm -lm -lvulkan-1 -lpng16 -lxcb
+vkcube_LDADD = $(MINIGBM_LDFLAGS) $(MESA_LDFLAGS) $(LIBDRM_LIBS) $(WAYLAND_LIBS) -lgbm -lm -lvulkan -lpng16 -lxcb
diff --git a/main.c b/main.c
index 3014e76..5af7929 100644
--- a/main.c
+++ b/main.c
@@ -73,7 +73,7 @@ fail_if(int cond, const char *format, ...)
 }
 
 static void
-init_vk(struct vkcube *vc)
+init_vk(struct vkcube *vc, const char *extension)
 {
    vkCreateInstance(&(VkInstanceCreateInfo) {
          .sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
@@ -81,7 +81,9 @@ init_vk(struct vkcube *vc)
             .sType = VK_STRUCTURE_TYPE_APPLICATION_INFO,
             .pApplicationName = "vkcube",
             .apiVersion = VK_MAKE_VERSION(1, 0, 2),
-         }
+         },
+         .enabledExtensionCount = (extension != NULL),
+         .ppEnabledExtensionNames = &extension,
       },
       NULL,
       &vc->instance);
@@ -281,7 +283,7 @@ write_buffer(struct vkcube *vc, struct vkcube_buffer *b)
 static void
 init_headless(struct vkcube *vc)
 {
-   init_vk(vc);
+   init_vk(vc, NULL);
 
    struct vkcube_buffer *b = &vc->buffers[0];
 
@@ -430,7 +432,10 @@ init_kms(struct vkcube *vc)
 
    vc->gbm_device = gbm_create_device(vc->fd);
 
-   init_vk(vc);
+   init_vk(vc, NULL);
+
+   PFN_vkCreateDmaBufImageINTEL create_dma_buf_image =
+      (PFN_vkCreateDmaBufImageINTEL)vkGetDeviceProcAddr(vc->device, "vkCreateDmaBufImageINTEL");
 
    for (uint32_t i = 0; i < 2; i++) {
       struct vkcube_buffer *b = &vc->buffers[i];
@@ -441,17 +446,17 @@ init_kms(struct vkcube *vc)
 
       fd = gbm_bo_get_fd(b->gbm_bo);
       stride = gbm_bo_get_stride(b->gbm_bo);
-      vkCreateDmaBufImageINTEL(vc->device,
-                               &(VkDmaBufImageCreateInfo) {
-                                  .sType = VK_STRUCTURE_TYPE_DMA_BUF_IMAGE_CREATE_INFO_INTEL,
-                                  .fd = fd,
-                                  .format = VK_FORMAT_R8G8B8A8_SRGB,
-                                  .extent = { vc->width, vc->height, 1 },
-                                  .strideInBytes = stride
-                               },
-                               NULL,
-                               &b->mem,
-                               &b->image);
+      create_dma_buf_image(vc->device,
+                           &(VkDmaBufImageCreateInfo) {
+                              .sType = VK_STRUCTURE_TYPE_DMA_BUF_IMAGE_CREATE_INFO_INTEL,
+                              .fd = fd,
+                              .format = VK_FORMAT_R8G8B8A8_SRGB,
+                              .extent = { vc->width, vc->height, 1 },
+                              .strideInBytes = stride
+                           },
+                           NULL,
+                           &b->mem,
+                           &b->image);
       close(fd);
 
       b->stride = gbm_bo_get_stride(b->gbm_bo);
@@ -600,7 +605,7 @@ init_xcb(struct vkcube *vc)
 
    xcb_flush(vc->xcb.conn);
 
-   init_vk(vc);
+   init_vk(vc, VK_KHR_XCB_SURFACE_EXTENSION_NAME);
 
    if (!vkGetPhysicalDeviceXcbPresentationSupportKHR(vc->physical_device, 0,
                                                      vc->xcb.conn,
@@ -804,9 +809,14 @@ init_wayland(struct vkcube *vc)
    xdg_surface_add_listener(vc->wl.xdg_surface, &xdg_surface_listener, vc);
    xdg_surface_set_title(vc->wl.xdg_surface, "vkcube");
 
-   init_vk(vc);
+   init_vk(vc, VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME);
 
-   if (!vkGetPhysicalDeviceWaylandPresentationSupportKHR(vc->physical_device, 0,
+   PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR get_physical_device_wayland_presentation_support =
+       (PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR)
+       vkGetDeviceProcAddr(vc->device,
+			   "vkGetPhysicalDeviceWaylandPresentationSupportKHR");
+
+   if (!get_physical_device_wayland_presentation_support(vc->physical_device, 0,
                                                          vc->wl.display)) {
       fprintf(stderr, "Vulkan not supported on given Wayland surface");
       abort();
@@ -814,7 +824,10 @@ init_wayland(struct vkcube *vc)
 
    VkSurfaceKHR wsi_surface;
 
-   vkCreateWaylandSurfaceKHR(vc->instance,
+   PFN_vkCreateWaylandSurfaceKHR create_wayland_surface = 
+       (PFN_vkCreateWaylandSurfaceKHR)vkGetInstanceProcAddr(vc->instance, "vkCreateWaylandSurfaceKHR");
+
+   create_wayland_surface(vc->instance,
       &(VkWaylandSurfaceCreateInfoKHR) {
          .sType = VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR,
          .display = vc->wl.display,
@@ -915,7 +928,7 @@ extern struct model cube_model;
 int main(int argc, char *argv[])
 {
    struct vkcube vc;
-   bool headless;
+   bool headless = false;
 
    vc.model = cube_model;
    vc.gbm_device = NULL;