44 #define GLFW_INCLUDE_NONE 45 #define GLFW_INCLUDE_VULKAN 48 #define DEMO_TEXTURE_COUNT 1 49 #define VERTEX_BUFFER_BIND_ID 0 50 #define APP_SHORT_NAME "tri" 51 #define APP_LONG_NAME "The Vulkan Triangle Demo Program" 53 #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) 55 #if defined(NDEBUG) && defined(__GNUC__) 56 #define U_ASSERT_ONLY __attribute__((unused)) 61 #define ERR_EXIT(err_msg, err_class) \ 68 #define GET_INSTANCE_PROC_ADDR(inst, entrypoint) \ 70 demo->fp##entrypoint = \ 71 (PFN_vk##entrypoint)vkGetInstanceProcAddr(inst, "vk" #entrypoint); \ 72 if (demo->fp##entrypoint == NULL) { \ 73 ERR_EXIT("vkGetInstanceProcAddr failed to find vk" #entrypoint, \ 74 "vkGetInstanceProcAddr Failure"); \ 78 #define GET_DEVICE_PROC_ADDR(dev, entrypoint) \ 80 demo->fp##entrypoint = \ 81 (PFN_vk##entrypoint)vkGetDeviceProcAddr(dev, "vk" #entrypoint); \ 82 if (demo->fp##entrypoint == NULL) { \ 83 ERR_EXIT("vkGetDeviceProcAddr failed to find vk" #entrypoint, \ 84 "vkGetDeviceProcAddr Failure"); \ 89 0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x08, 0x00,
90 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00,
91 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00,
92 0x47, 0x4c, 0x53, 0x4c, 0x2e, 0x73, 0x74, 0x64, 0x2e, 0x34, 0x35, 0x30,
93 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
94 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x07, 0x00, 0x04, 0x00, 0x00, 0x00,
95 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00,
96 0x09, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x10, 0x00, 0x03, 0x00,
97 0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00,
98 0x02, 0x00, 0x00, 0x00, 0x90, 0x01, 0x00, 0x00, 0x04, 0x00, 0x09, 0x00,
99 0x47, 0x4c, 0x5f, 0x41, 0x52, 0x42, 0x5f, 0x73, 0x65, 0x70, 0x61, 0x72,
100 0x61, 0x74, 0x65, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x65, 0x72, 0x5f, 0x6f,
101 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x00, 0x00, 0x04, 0x00, 0x09, 0x00,
102 0x47, 0x4c, 0x5f, 0x41, 0x52, 0x42, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x69,
103 0x6e, 0x67, 0x5f, 0x6c, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65, 0x5f,
104 0x34, 0x32, 0x30, 0x70, 0x61, 0x63, 0x6b, 0x00, 0x05, 0x00, 0x04, 0x00,
105 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00,
106 0x05, 0x00, 0x05, 0x00, 0x09, 0x00, 0x00, 0x00, 0x75, 0x46, 0x72, 0x61,
107 0x67, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00,
108 0x0d, 0x00, 0x00, 0x00, 0x74, 0x65, 0x78, 0x00, 0x05, 0x00, 0x05, 0x00,
109 0x11, 0x00, 0x00, 0x00, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64,
110 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x00,
111 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00,
112 0x0d, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
113 0x47, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00,
114 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x11, 0x00, 0x00, 0x00,
115 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00,
116 0x02, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00,
117 0x02, 0x00, 0x00, 0x00, 0x16, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, 0x00,
118 0x20, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00,
119 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00,
120 0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
121 0x3b, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00,
122 0x03, 0x00, 0x00, 0x00, 0x19, 0x00, 0x09, 0x00, 0x0a, 0x00, 0x00, 0x00,
123 0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
124 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
125 0x00, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x03, 0x00, 0x0b, 0x00, 0x00, 0x00,
126 0x0a, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00,
127 0x00, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00,
128 0x0c, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
129 0x17, 0x00, 0x04, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
130 0x02, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x10, 0x00, 0x00, 0x00,
131 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00,
132 0x10, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
133 0x36, 0x00, 0x05, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
134 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00,
135 0x05, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0b, 0x00, 0x00, 0x00,
136 0x0e, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00,
137 0x0f, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00,
138 0x57, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00,
139 0x0e, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00,
140 0x09, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00,
141 0x38, 0x00, 0x01, 0x00
145 0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x08, 0x00,
146 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00,
147 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00,
148 0x47, 0x4c, 0x53, 0x4c, 0x2e, 0x73, 0x74, 0x64, 0x2e, 0x34, 0x35, 0x30,
149 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
150 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00,
151 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00,
152 0x09, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00,
153 0x17, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00,
154 0x03, 0x00, 0x03, 0x00, 0x02, 0x00, 0x00, 0x00, 0x90, 0x01, 0x00, 0x00,
155 0x04, 0x00, 0x09, 0x00, 0x47, 0x4c, 0x5f, 0x41, 0x52, 0x42, 0x5f, 0x73,
156 0x65, 0x70, 0x61, 0x72, 0x61, 0x74, 0x65, 0x5f, 0x73, 0x68, 0x61, 0x64,
157 0x65, 0x72, 0x5f, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x00, 0x00,
158 0x04, 0x00, 0x09, 0x00, 0x47, 0x4c, 0x5f, 0x41, 0x52, 0x42, 0x5f, 0x73,
159 0x68, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x5f, 0x6c, 0x61, 0x6e, 0x67, 0x75,
160 0x61, 0x67, 0x65, 0x5f, 0x34, 0x32, 0x30, 0x70, 0x61, 0x63, 0x6b, 0x00,
161 0x05, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e,
162 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x09, 0x00, 0x00, 0x00,
163 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x00, 0x00, 0x00, 0x00,
164 0x05, 0x00, 0x04, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x61, 0x74, 0x74, 0x72,
165 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x11, 0x00, 0x00, 0x00,
166 0x67, 0x6c, 0x5f, 0x50, 0x65, 0x72, 0x56, 0x65, 0x72, 0x74, 0x65, 0x78,
167 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x06, 0x00, 0x11, 0x00, 0x00, 0x00,
168 0x00, 0x00, 0x00, 0x00, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74,
169 0x69, 0x6f, 0x6e, 0x00, 0x06, 0x00, 0x07, 0x00, 0x11, 0x00, 0x00, 0x00,
170 0x01, 0x00, 0x00, 0x00, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x69, 0x6e, 0x74,
171 0x53, 0x69, 0x7a, 0x65, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x07, 0x00,
172 0x11, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x67, 0x6c, 0x5f, 0x43,
173 0x6c, 0x69, 0x70, 0x44, 0x69, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x00,
174 0x05, 0x00, 0x03, 0x00, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
175 0x05, 0x00, 0x03, 0x00, 0x17, 0x00, 0x00, 0x00, 0x70, 0x6f, 0x73, 0x00,
176 0x05, 0x00, 0x05, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x67, 0x6c, 0x5f, 0x56,
177 0x65, 0x72, 0x74, 0x65, 0x78, 0x49, 0x44, 0x00, 0x05, 0x00, 0x06, 0x00,
178 0x1d, 0x00, 0x00, 0x00, 0x67, 0x6c, 0x5f, 0x49, 0x6e, 0x73, 0x74, 0x61,
179 0x6e, 0x63, 0x65, 0x49, 0x44, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00,
180 0x09, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
181 0x47, 0x00, 0x04, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00,
182 0x01, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x11, 0x00, 0x00, 0x00,
183 0x00, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
184 0x48, 0x00, 0x05, 0x00, 0x11, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
185 0x0b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00,
186 0x11, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00,
187 0x03, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x11, 0x00, 0x00, 0x00,
188 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x17, 0x00, 0x00, 0x00,
189 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00,
190 0x1c, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
191 0x47, 0x00, 0x04, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00,
192 0x06, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00,
193 0x21, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
194 0x16, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
195 0x17, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
196 0x02, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00,
197 0x03, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00,
198 0x08, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
199 0x20, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
200 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00,
201 0x0b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00,
202 0x0d, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
203 0x15, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
204 0x00, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00,
205 0x0f, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x04, 0x00,
206 0x10, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
207 0x1e, 0x00, 0x05, 0x00, 0x11, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00,
208 0x06, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00,
209 0x12, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00,
210 0x3b, 0x00, 0x04, 0x00, 0x12, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00,
211 0x03, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00, 0x14, 0x00, 0x00, 0x00,
212 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00,
213 0x14, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
214 0x20, 0x00, 0x04, 0x00, 0x16, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
215 0x0d, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x16, 0x00, 0x00, 0x00,
216 0x17, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00,
217 0x19, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00,
218 0x20, 0x00, 0x04, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
219 0x14, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x1b, 0x00, 0x00, 0x00,
220 0x1c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00,
221 0x1b, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
222 0x36, 0x00, 0x05, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
223 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00,
224 0x05, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00,
225 0x0c, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00,
226 0x09, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00,
227 0x0d, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
228 0x41, 0x00, 0x05, 0x00, 0x19, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00,
229 0x13, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00,
230 0x1a, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00,
231 0x38, 0x00, 0x01, 0x00
250 const char *pLayerPrefix,
const char *pMsg,
283 const char *extension_names[64];
284 const char *enabled_layers[64];
365 const char *pLayerPrefix,
const char *pMsg,
void *pUserData) {
366 char *
message = (
char *)malloc(strlen(pMsg) + 100);
373 sprintf(message,
"ERROR: [%s] Code %d : %s", pLayerPrefix, msgCode,
376 sprintf(message,
"WARNING: [%s] Code %d : %s", pLayerPrefix, msgCode,
382 printf(
"%s\n", message);
405 if ((typeBits & 1) == 1) {
408 requirements_mask) == requirements_mask) {
428 const VkCommandBuffer cmd_bufs[] = {demo->
setup_cmd};
432 .waitSemaphoreCount = 0,
433 .pWaitSemaphores =
NULL,
434 .pWaitDstStageMask =
NULL,
435 .commandBufferCount = 1,
436 .pCommandBuffers = cmd_bufs,
437 .signalSemaphoreCount = 0,
438 .pSignalSemaphores =
NULL};
464 .commandBufferCount = 1,
474 .pInheritanceInfo =
NULL,
483 .srcAccessMask = srcAccessMask,
485 .oldLayout = old_image_layout,
486 .newLayout = new_image_layout,
488 .subresourceRange = {aspectMask, 0, 1, 0, 1}};
517 0,
NULL, 1, pmemory_barrier);
525 .pInheritanceInfo =
NULL,
536 .renderArea.offset.x = 0,
537 .renderArea.offset.y = 0,
538 .renderArea.extent.width = demo->
width,
539 .renderArea.extent.height = demo->
height,
540 .clearValueCount = 2,
541 .pClearValues = clear_values,
564 NULL, 1, &image_memory_barrier);
573 memset(&viewport, 0,
sizeof(viewport));
581 memset(&scissor, 0,
sizeof(scissor));
610 NULL, 1, pmemory_barrier);
618 VkSemaphore imageAcquiredSemaphore, drawCompleteSemaphore;
626 NULL, &imageAcquiredSemaphore);
630 NULL, &drawCompleteSemaphore);
635 imageAcquiredSemaphore,
666 .waitSemaphoreCount = 1,
667 .pWaitSemaphores = &imageAcquiredSemaphore,
668 .pWaitDstStageMask = &pipe_stage_flags,
669 .commandBufferCount = 1,
671 .signalSemaphoreCount = 1,
672 .pSignalSemaphores = &drawCompleteSemaphore};
680 .waitSemaphoreCount = 1,
681 .pWaitSemaphores = &drawCompleteSemaphore,
708 VkSwapchainKHR oldSwapchain = demo->
swapchain;
724 demo->
gpu, demo->
surface, &presentModeCount, presentModes);
763 (desiredNumOfSwapchainImages > surfCapabilities.
maxImageCount)) {
765 desiredNumOfSwapchainImages = surfCapabilities.
maxImageCount;
780 .minImageCount = desiredNumOfSwapchainImages,
781 .imageFormat = demo->
format,
785 .width = swapchainExtent.
width, .height = swapchainExtent.
height,
788 .preTransform = preTransform,
790 .imageArrayLayers = 1,
792 .queueFamilyIndexCount = 0,
793 .pQueueFamilyIndices =
NULL,
794 .presentMode = swapchainPresentMode,
795 .oldSwapchain = oldSwapchain,
816 VkImage *swapchainImages =
860 if (
NULL != presentModes) {
884 .memoryTypeIndex = 0,
957 .format = tex_format,
971 .memoryTypeIndex = 0,
1016 row[x] = tex_colors[(x & 1) ^ (y & 1)];
1041 {0xffff0000, 0xff00ff00},
1063 memset(&staging_texture, 0,
sizeof(staging_texture));
1071 demo, tex_colors[i], &demo->
textures[i],
1090 .srcOffset = {0, 0, 0},
1092 .dstOffset = {0, 0, 0},
1112 assert(!
"No support for B8G8R8A8_UNORM as texture image format");
1131 .unnormalizedCoordinates =
VK_FALSE,
1138 .format = tex_format,
1163 const float vb[3][5] = {
1165 { -1.0f, -1.0f, 0.25f, 0.0f, 0.0f },
1166 { 1.0f, -1.0f, 0.25f, 1.0f, 0.0f },
1167 { 0.0f, 1.0f, 1.0f, 0.5f, 1.0f },
1180 .allocationSize = 0,
1181 .memoryTypeIndex = 0,
1210 memcpy(data, vb,
sizeof(vb));
1247 .pImmutableSamplers =
NULL,
1253 .pBindings = &layout_binding,
1264 .setLayoutCount = 1,
1310 .inputAttachmentCount = 0,
1311 .pInputAttachments =
NULL,
1312 .colorAttachmentCount = 1,
1313 .pColorAttachments = &color_reference,
1314 .pResolveAttachments =
NULL,
1315 .pDepthStencilAttachment = &depth_reference,
1316 .preserveAttachmentCount = 0,
1317 .pPreserveAttachments =
NULL,
1322 .attachmentCount = 2,
1325 .pSubpasses = &subpass,
1326 .dependencyCount = 0,
1327 .pDependencies =
NULL,
1335 static VkShaderModule
1338 VkShaderModule module;
1345 moduleCreateInfo.
pCode = code;
1346 moduleCreateInfo.
flags = 0;
1387 memset(dynamicStateEnables, 0,
sizeof dynamicStateEnables);
1388 memset(&dynamicState, 0,
sizeof dynamicState);
1392 memset(&pipeline, 0,
sizeof(pipeline));
1398 memset(&ia, 0,
sizeof(ia));
1402 memset(&rs, 0,
sizeof(rs));
1412 memset(&cb, 0,
sizeof(cb));
1415 memset(att_state, 0,
sizeof(att_state));
1421 memset(&vp, 0,
sizeof(vp));
1430 memset(&ds, 0,
sizeof(ds));
1442 memset(&ms, 0,
sizeof(ms));
1455 shaderStages[0].
pName =
"main";
1460 shaderStages[1].
pName =
"main";
1469 pipeline.
pStages = shaderStages;
1473 memset(&pipelineCache, 0,
sizeof(pipelineCache));
1499 .pPoolSizes = &type_count,
1518 .descriptorSetCount = 1,
1523 memset(&tex_descs, 0,
sizeof(tex_descs));
1530 memset(&write, 0,
sizeof(write));
1548 .attachmentCount = 2,
1550 .width = demo->
width,
1558 sizeof(VkFramebuffer));
1587 .commandBufferCount = 1,
1607 printf(
"GLFW error: %s\n", description);
1659 printf(
"Cannot create a window in which to draw!\n");
1678 for (i = 0; i < check_count; i++) {
1680 for (j = 0; j < layer_count; j++) {
1681 if (!strcmp(check_names[i], layers[j].layerName)) {
1687 fprintf(stderr,
"Cannot find layer: %s\n", check_names[i]);
1697 uint32_t required_extension_count = 0;
1698 uint32_t instance_extension_count = 0;
1700 uint32_t validation_layer_count = 0;
1701 const char **required_extensions =
NULL;
1702 const char **instance_validation_layers =
NULL;
1706 char *instance_validation_layers_alt1[] = {
1707 "VK_LAYER_LUNARG_standard_validation" 1710 char *instance_validation_layers_alt2[] = {
1711 "VK_LAYER_GOOGLE_threading",
"VK_LAYER_LUNARG_parameter_validation",
1712 "VK_LAYER_LUNARG_object_tracker",
"VK_LAYER_LUNARG_image",
1713 "VK_LAYER_LUNARG_core_validation",
"VK_LAYER_LUNARG_swapchain",
1714 "VK_LAYER_GOOGLE_unique_objects" 1724 instance_validation_layers = (
const char**) instance_validation_layers_alt1;
1725 if (instance_layer_count > 0) {
1735 instance_validation_layers, instance_layer_count,
1737 if (validation_found) {
1740 validation_layer_count = 1;
1743 instance_validation_layers =
1744 (
const char**) instance_validation_layers_alt2;
1748 instance_validation_layers, instance_layer_count,
1750 validation_layer_count =
1752 for (i = 0; i < validation_layer_count; i++) {
1756 free(instance_layers);
1759 if (!validation_found) {
1760 ERR_EXIT(
"vkEnumerateInstanceLayerProperties failed to find " 1761 "required validation layer.\n\n" 1762 "Please look at the Getting Started guide for additional " 1764 "vkCreateInstance Failure");
1770 if (!required_extensions) {
1771 ERR_EXIT(
"glfwGetRequiredInstanceExtensions failed to find the " 1772 "platform surface extensions.\n\nDo you have a compatible " 1773 "Vulkan installable client driver (ICD) installed?\nPlease " 1774 "look at the Getting Started guide for additional " 1776 "vkCreateInstance Failure");
1779 for (i = 0; i < required_extension_count; i++) {
1785 NULL, &instance_extension_count,
NULL);
1788 if (instance_extension_count > 0) {
1792 NULL, &instance_extension_count, instance_extensions);
1794 for (i = 0; i < instance_extension_count; i++) {
1796 instance_extensions[i].extensionName)) {
1805 free(instance_extensions);
1812 .applicationVersion = 0,
1820 .pApplicationInfo = &app,
1822 .ppEnabledLayerNames = (
const char *
const *)instance_validation_layers,
1824 .ppEnabledExtensionNames = (
const char *
const *)demo->
extension_names,
1831 ERR_EXIT(
"Cannot find a compatible Vulkan installable client driver " 1832 "(ICD).\n\nPlease look at the Getting Started guide for " 1833 "additional information.\n",
1834 "vkCreateInstance Failure");
1836 ERR_EXIT(
"Cannot find a specified extension library" 1837 ".\nMake sure your layers path is set appropriately\n",
1838 "vkCreateInstance Failure");
1840 ERR_EXIT(
"vkCreateInstance failed.\n\nDo you have a compatible Vulkan " 1841 "installable client driver (ICD) installed?\nPlease look at " 1842 "the Getting Started guide for additional information.\n",
1843 "vkCreateInstance Failure");
1848 assert(!err && gpu_count > 0);
1850 if (gpu_count > 0) {
1857 demo->
gpu = physical_devices[0];
1858 free(physical_devices);
1860 ERR_EXIT(
"vkEnumeratePhysicalDevices reported zero accessible devices." 1861 "\n\nDo you have a compatible Vulkan installable client" 1862 " driver (ICD) installed?\nPlease look at the Getting Started" 1863 " guide for additional information.\n",
1864 "vkEnumeratePhysicalDevices Failure");
1868 uint32_t device_extension_count = 0;
1873 &device_extension_count,
NULL);
1876 if (device_extension_count > 0) {
1880 demo->
gpu,
NULL, &device_extension_count, device_extensions);
1883 for (i = 0; i < device_extension_count; i++) {
1885 device_extensions[i].extensionName)) {
1886 swapchainExtFound = 1;
1893 free(device_extensions);
1896 if (!swapchainExtFound) {
1897 ERR_EXIT(
"vkEnumerateDeviceExtensionProperties failed to find " 1899 " extension.\n\nDo you have a compatible " 1900 "Vulkan installable client driver (ICD) installed?\nPlease " 1901 "look at the Getting Started guide for additional " 1903 "vkCreateInstance Failure");
1909 demo->
inst,
"vkCreateDebugReportCallbackEXT");
1912 demo->
inst,
"vkDestroyDebugReportCallbackEXT");
1915 "GetProcAddr: Unable to find vkCreateDebugReportCallbackEXT\n",
1916 "vkGetProcAddr Failure");
1920 "GetProcAddr: Unable to find vkDestroyDebugReportCallbackEXT\n",
1921 "vkGetProcAddr Failure");
1925 demo->
inst,
"vkDebugReportMessageEXT");
1927 ERR_EXIT(
"GetProcAddr: Unable to find vkDebugReportMessageEXT\n",
1928 "vkGetProcAddr Failure");
1933 dbgCreateInfo.
flags =
1944 ERR_EXIT(
"CreateDebugReportCallback: out of host memory\n",
1945 "CreateDebugReportCallback Failure");
1948 ERR_EXIT(
"CreateDebugReportCallback: unknown failure\n",
1949 "CreateDebugReportCallback Failure");
1983 float queue_priorities[1] = {0.0};
1989 .pQueuePriorities = queue_priorities};
1993 memset(&features, 0,
sizeof(features));
2001 .queueCreateInfoCount = 1,
2002 .pQueueCreateInfos = &
queue,
2003 .enabledLayerCount = 0,
2004 .ppEnabledLayerNames =
NULL,
2006 .ppEnabledExtensionNames = (
const char *
const *)demo->
extension_names,
2007 .pEnabledFeatures = &features,
2032 &supportsPresent[i]);
2042 graphicsQueueNodeIndex =
i;
2045 if (supportsPresent[i] ==
VK_TRUE) {
2046 graphicsQueueNodeIndex =
i;
2047 presentQueueNodeIndex =
i;
2056 if (supportsPresent[i] ==
VK_TRUE) {
2057 presentQueueNodeIndex =
i;
2062 free(supportsPresent);
2067 ERR_EXIT(
"Could not find a graphics and a present queue\n",
2068 "Swapchain Initialization Failure");
2076 if (graphicsQueueNodeIndex != presentQueueNodeIndex) {
2077 ERR_EXIT(
"Could not find a common graphics and a present queue\n",
2078 "Swapchain Initialization Failure");
2091 &formatCount,
NULL);
2096 &formatCount, surfFormats);
2104 assert(formatCount >= 1);
2119 printf(
"Cannot initialize GLFW.\nExiting ...\n");
2125 printf(
"GLFW failed to find the Vulkan loader.\nExiting ...\n");
2131 static void demo_init(
struct demo *demo,
const int argc,
const char *argv[])
2134 memset(demo, 0,
sizeof(*demo));
2137 for (i = 1; i < argc; i++) {
2138 if (strcmp(argv[i],
"--use_staging") == 0) {
2142 if (strcmp(argv[i],
"--break") == 0) {
2146 if (strcmp(argv[i],
"--validate") == 0) {
2151 i < argc - 1 && sscanf(argv[i + 1],
"%d", &demo->
frameCount) == 1 &&
2157 fprintf(stderr,
"Usage:\n %s [--use_staging] [--validate] [--break] " 2158 "[--c <framecount>]\n",
2277 int main(
const int argc,
const char *argv[]) {
GLenum GLuint GLenum GLsizei const GLchar * message
VKAPI_ATTR void VKAPI_CALL vkCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor, uint32_t scissorCount, const VkRect2D *pScissors)
GLsizeiptr const void GLenum usage
VkFramebuffer * framebuffers
VKAPI_ATTR VkBool32 VKAPI_CALL BreakCallback(VkFlags msgFlags, VkDebugReportObjectTypeEXT objType, uint64_t srcObject, size_t location, int32_t msgCode, const char *pLayerPrefix, const char *pMsg, void *pUserData)
VKAPI_ATTR VkResult VKAPI_CALL vkCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkFramebuffer *pFramebuffer)
VKAPI_ATTR VkResult VKAPI_CALL vkCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, const VkGraphicsPipelineCreateInfo *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines)
VkBool32 depthClampEnable
VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance(const VkInstanceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkInstance *pInstance)
VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, const char *pLayerName, uint32_t *pPropertyCount, VkExtensionProperties *pProperties)
uint32_t swapchainImageCount
int main(const int argc, const char *argv[])
VkShaderModule vert_shader_module
GLenum GLenum GLsizei void * row
#define VK_API_VERSION_1_0
static void demo_prepare_vertices(struct demo *demo)
VKAPI_ATTR void VKAPI_CALL vkDestroyPipeline(VkDevice device, VkPipeline pipeline, const VkAllocationCallbacks *pAllocator)
VKAPI_ATTR void VKAPI_CALL vkDestroyPipelineCache(VkDevice device, VkPipelineCache pipelineCache, const VkAllocationCallbacks *pAllocator)
VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice physicalDevice, uint32_t *pQueueFamilyPropertyCount, VkQueueFamilyProperties *pQueueFamilyProperties)
static void demo_prepare_buffers(struct demo *demo)
void(VKAPI_PTR * PFN_vkDestroyDebugReportCallbackEXT)(VkInstance instance, VkDebugReportCallbackEXT callback, const VkAllocationCallbacks *pAllocator)
VKAPI_ATTR void VKAPI_CALL vkDestroyDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, const VkAllocationCallbacks *pAllocator)
const VkPipelineInputAssemblyStateCreateInfo * pInputAssemblyState
The header of the GLFW 3 API.
static void demo_error_callback(int error, const char *description)
VkCompareOp depthCompareOp
VkBool32 shaderClipDistance
static void demo_init(struct demo *demo, const int argc, const char *argv[])
static void demo_prepare_descriptor_set(struct demo *demo)
VKAPI_ATTR void VKAPI_CALL vkGetImageSubresourceLayout(VkDevice device, VkImage image, const VkImageSubresource *pSubresource, VkSubresourceLayout *pLayout)
VKAPI_ATTR VkResult VKAPI_CALL vkBindBufferMemory(VkDevice device, VkBuffer buffer, VkDeviceMemory memory, VkDeviceSize memoryOffset)
VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFeatures(VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures *pFeatures)
#define DEMO_TEXTURE_COUNT
void(VKAPI_PTR * PFN_vkDebugReportMessageEXT)(VkInstance instance, VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, uint64_t object, size_t location, int32_t messageCode, const char *pLayerPrefix, const char *pMessage)
static void demo_prepare_descriptor_pool(struct demo *demo)
VKAPI_ATTR VkResult VKAPI_CALL vkCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkImage *pImage)
VKAPI_ATTR VkBool32 VKAPI_CALL dbgFunc(VkFlags msgFlags, VkDebugReportObjectTypeEXT objType, uint64_t srcObject, size_t location, int32_t msgCode, const char *pLayerPrefix, const char *pMsg, void *pUserData)
#define GET_DEVICE_PROC_ADDR(dev, entrypoint)
VkDebugReportObjectTypeEXT
VKAPI_ATTR VkResult VKAPI_CALL vkCreateCommandPool(VkDevice device, const VkCommandPoolCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkCommandPool *pCommandPool)
GLFWAPI int glfwVulkanSupported(void)
Returns whether the Vulkan loader and an ICD have been found.
VkResult(VKAPI_PTR * PFN_vkAcquireNextImageKHR)(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout, VkSemaphore semaphore, VkFence fence, uint32_t *pImageIndex)
#define GET_INSTANCE_PROC_ADDR(inst, entrypoint)
GLFWAPI void * glfwGetWindowUserPointer(GLFWwindow *window)
Returns the user pointer of the specified window.
static void demo_prepare_depth(struct demo *demo)
PFN_vkDestroyDebugReportCallbackEXT DestroyDebugReportCallback
VKAPI_ATTR void VKAPI_CALL vkCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount, const VkViewport *pViewports)
VKAPI_ATTR void VKAPI_CALL vkDestroyBuffer(VkDevice device, VkBuffer buffer, const VkAllocationCallbacks *pAllocator)
VkResult(VKAPI_PTR * PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR)(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, VkSurfaceCapabilitiesKHR *pSurfaceCapabilities)
VKAPI_ATTR VkResult VKAPI_CALL vkMapMemory(VkDevice device, VkDeviceMemory memory, VkDeviceSize offset, VkDeviceSize size, VkMemoryMapFlags flags, void **ppData)
const VkPipelineVertexInputStateCreateInfo * pVertexInputState
GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun cbfun)
Sets the error callback.
const VkPipelineDepthStencilStateCreateInfo * pDepthStencilState
VKAPI_ATTR VkResult VKAPI_CALL vkCreateShaderModule(VkDevice device, const VkShaderModuleCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkShaderModule *pShaderModule)
VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceProperties(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties *pProperties)
VkMemoryType memoryTypes[VK_MAX_MEMORY_TYPES]
static void demo_prepare_texture_image(struct demo *demo, const uint32_t *tex_colors, struct texture_object *tex_obj, VkImageTiling tiling, VkImageUsageFlags usage, VkFlags required_props)
VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDevice *pDevice)
GLint GLint GLsizei GLsizei GLsizei depth
const VkPipelineMultisampleStateCreateInfo * pMultisampleState
VKAPI_ATTR VkResult VKAPI_CALL vkCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkImageView *pView)
VkCommandBuffer setup_cmd
VkExtent2D minImageExtent
const VkPipelineColorBlendAttachmentState * pAttachments
VKAPI_ATTR void VKAPI_CALL vkDestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface, const VkAllocationCallbacks *pAllocator)
VKAPI_ATTR VkResult VKAPI_CALL vkAllocateDescriptorSets(VkDevice device, const VkDescriptorSetAllocateInfo *pAllocateInfo, VkDescriptorSet *pDescriptorSets)
VkBool32 rasterizerDiscardEnable
VKAPI_ATTR void VKAPI_CALL vkDestroyFramebuffer(VkDevice device, VkFramebuffer framebuffer, const VkAllocationCallbacks *pAllocator)
VkPhysicalDeviceMemoryProperties memory_properties
VkFlags VkPipelineStageFlags
GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow *window, GLFWframebuffersizefun cbfun)
Sets the framebuffer resize callback for the specified window.
PFN_vkGetSwapchainImagesKHR fpGetSwapchainImagesKHR
PFN_vkQueuePresentKHR fpQueuePresentKHR
VKAPI_ATTR void VKAPI_CALL vkDestroyImageView(VkDevice device, VkImageView imageView, const VkAllocationCallbacks *pAllocator)
VkSurfaceTransformFlagsKHR supportedTransforms
uint32_t enabled_extension_count
#define VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT
VKAPI_ATTR void VKAPI_CALL vkCmdBindDescriptorSets(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, uint32_t firstSet, uint32_t descriptorSetCount, const VkDescriptorSet *pDescriptorSets, uint32_t dynamicOffsetCount, const uint32_t *pDynamicOffsets)
VKAPI_ATTR void VKAPI_CALL vkCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageCopy *pRegions)
static void demo_resize(struct demo *demo)
PFN_vkAcquireNextImageKHR fpAcquireNextImageKHR
VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkFormatProperties *pFormatProperties)
const VkSampleMask * pSampleMask
const VkPipelineColorBlendStateCreateInfo * pColorBlendState
VkBool32 depthBoundsTestEnable
VkDeviceSize allocationSize
static VkShaderModule demo_prepare_shader_module(struct demo *demo, const void *code, size_t size)
GLenum GLenum GLsizei void * image
VKAPI_ATTR void VKAPI_CALL vkDestroyCommandPool(VkDevice device, VkCommandPool commandPool, const VkAllocationCallbacks *pAllocator)
VKAPI_ATTR void VKAPI_CALL vkDestroySampler(VkDevice device, VkSampler sampler, const VkAllocationCallbacks *pAllocator)
VkFlags VkImageUsageFlags
VKAPI_ATTR void VKAPI_CALL vkUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount, const VkWriteDescriptorSet *pDescriptorWrites, uint32_t descriptorCopyCount, const VkCopyDescriptorSet *pDescriptorCopies)
uint32_t graphics_queue_node_index
void(VKAPI_PTR * PFN_vkDestroySwapchainKHR)(VkDevice device, VkSwapchainKHR swapchain, const VkAllocationCallbacks *pAllocator)
VkBool32 depthWriteEnable
VkQueueFamilyProperties * queue_props
uint32_t enabled_layer_count
VKAPI_ATTR void VKAPI_CALL vkDestroyDevice(VkDevice device, const VkAllocationCallbacks *pAllocator)
VKAPI_ATTR void VKAPI_CALL vkCmdPipelineBarrier(VkCommandBuffer commandBuffer, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, uint32_t memoryBarrierCount, const VkMemoryBarrier *pMemoryBarriers, uint32_t bufferMemoryBarrierCount, const VkBufferMemoryBarrier *pBufferMemoryBarriers, uint32_t imageMemoryBarrierCount, const VkImageMemoryBarrier *pImageMemoryBarriers)
VKAPI_ATTR VkResult VKAPI_CALL vkCreateDescriptorSetLayout(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDescriptorSetLayout *pSetLayout)
PFN_vkGetPhysicalDeviceSurfaceFormatsKHR fpGetPhysicalDeviceSurfaceFormatsKHR
VkBool32 stencilTestEnable
VkImageAspectFlags aspectMask
GLFWAPI int glfwInit(void)
Initializes the GLFW library.
static VkBool32 demo_check_layers(uint32_t check_count, const char **check_names, uint32_t layer_count, VkLayerProperties *layers)
VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceExtensionProperties(const char *pLayerName, uint32_t *pPropertyCount, VkExtensionProperties *pProperties)
static void demo_cleanup(struct demo *demo)
VkDescriptorSetLayout desc_layout
GLFWAPI void glfwSetWindowUserPointer(GLFWwindow *window, void *pointer)
Sets the user pointer of the specified window.
PFN_vkDestroySwapchainKHR fpDestroySwapchainKHR
static void demo_init_device(struct demo *demo)
VKAPI_ATTR void VKAPI_CALL vkDestroyRenderPass(VkDevice device, VkRenderPass renderPass, const VkAllocationCallbacks *pAllocator)
GLsizei const GLenum * attachments
VkPolygonMode polygonMode
VkColorComponentFlags colorWriteMask
PFN_vkDebugReportMessageEXT DebugReportMessage
GLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow *window, GLFWwindowrefreshfun cbfun)
Sets the refresh callback for the specified window.
VkDescriptorType descriptorType
VKAPI_ATTR void VKAPI_CALL vkCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding, uint32_t bindingCount, const VkBuffer *pBuffers, const VkDeviceSize *pOffsets)
VkResult(VKAPI_PTR * PFN_vkGetSwapchainImagesKHR)(VkDevice device, VkSwapchainKHR swapchain, uint32_t *pSwapchainImageCount, VkImage *pSwapchainImages)
PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR fpGetPhysicalDeviceSurfaceCapabilitiesKHR
VKAPI_ATTR VkResult VKAPI_CALL vkQueueSubmit(VkQueue queue, uint32_t submitCount, const VkSubmitInfo *pSubmits, VkFence fence)
VKAPI_ATTR VkResult VKAPI_CALL vkEnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount, VkPhysicalDevice *pPhysicalDevices)
static void demo_run(struct demo *demo)
static void demo_draw(struct demo *demo)
const VkPipelineShaderStageCreateInfo * pStages
static void demo_set_image_layout(struct demo *demo, VkImage image, VkImageAspectFlags aspectMask, VkImageLayout old_image_layout, VkImageLayout new_image_layout, VkAccessFlagBits srcAccessMask)
VkImageLayout imageLayout
static void demo_init_connection(struct demo *demo)
GLenum GLuint GLsizei const GLenum * props
VKAPI_ATTR VkResult VKAPI_CALL vkCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer)
VKAPI_ATTR void VKAPI_CALL vkDestroyImage(VkDevice device, VkImage image, const VkAllocationCallbacks *pAllocator)
static bool memory_type_from_properties(struct demo *demo, uint32_t typeBits, VkFlags requirements_mask, uint32_t *typeIndex)
VkImageSubresourceLayers srcSubresource
VkAccessFlags dstAccessMask
GLint GLsizei GLsizei height
VkSurfaceTransformFlagBitsKHR currentTransform
PFN_vkGetPhysicalDeviceSurfaceSupportKHR fpGetPhysicalDeviceSurfaceSupportKHR
GLint GLint GLsizei GLint GLenum format
VkResult(VKAPI_PTR * PFN_vkCreateDebugReportCallbackEXT)(VkInstance instance, const VkDebugReportCallbackCreateInfoEXT *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDebugReportCallbackEXT *pCallback)
static void demo_flush_init_cmd(struct demo *demo)
static void demo_prepare_framebuffers(struct demo *demo)
unsigned __int64 uint64_t
static void demo_refresh_callback(GLFWwindow *window)
VkShaderModule frag_shader_module
VKAPI_ATTR VkResult VKAPI_CALL vkBeginCommandBuffer(VkCommandBuffer commandBuffer, const VkCommandBufferBeginInfo *pBeginInfo)
VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance, const char *pName)
static void demo_prepare(struct demo *demo)
VKAPI_ATTR void VKAPI_CALL vkDestroyShaderModule(VkDevice device, VkShaderModule shaderModule, const VkAllocationCallbacks *pAllocator)
VkPipelineCache pipelineCache
static void demo_prepare_textures(struct demo *demo)
VkPipelineVertexInputStateCreateInfo vi
PFN_vkCreateSwapchainKHR fpCreateSwapchainKHR
static void demo_resize_callback(GLFWwindow *window, int width, int height)
const VkPipelineRasterizationStateCreateInfo * pRasterizationState
VKAPI_ATTR void VKAPI_CALL vkGetBufferMemoryRequirements(VkDevice device, VkBuffer buffer, VkMemoryRequirements *pMemoryRequirements)
VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceLayerProperties(uint32_t *pPropertyCount, VkLayerProperties *pProperties)
VkMemoryPropertyFlags propertyFlags
PFN_vkDebugReportCallbackEXT pfnCallback
VkPipelineLayout pipeline_layout
VKAPI_ATTR void VKAPI_CALL vkFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount, const VkCommandBuffer *pCommandBuffers)
VKAPI_ATTR VkResult VKAPI_CALL vkCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSampler *pSampler)
PFN_vkCreateDebugReportCallbackEXT CreateDebugReportCallback
static const char vertShaderCode[]
const char * extension_names[64]
VkFlags VkSurfaceTransformFlagsKHR
VkSampleCountFlagBits rasterizationSamples
VkDescriptorPool desc_pool
static const textual_icon exit
#define VERTEX_BUFFER_BIND_ID
static void demo_prepare_render_pass(struct demo *demo)
VKAPI_ATTR VkResult VKAPI_CALL vkCreateSemaphore(VkDevice device, const VkSemaphoreCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSemaphore *pSemaphore)
VkResult(VKAPI_PTR * PFN_vkGetPhysicalDeviceSurfacePresentModesKHR)(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t *pPresentModeCount, VkPresentModeKHR *pPresentModes)
GLuint GLsizei const GLuint const GLintptr * offsets
GLFWAPI void glfwSetWindowShouldClose(GLFWwindow *window, int value)
Sets the close flag of the specified window.
VkPipelineBindPoint pipelineBindPoint
VkFlags VkImageAspectFlags
VkPhysicalDeviceProperties gpu_props
VkShaderStageFlagBits stage
static const char fragShaderCode[]
VKAPI_ATTR void VKAPI_CALL vkFreeMemory(VkDevice device, VkDeviceMemory memory, const VkAllocationCallbacks *pAllocator)
VKAPI_ATTR VkResult VKAPI_CALL vkBindImageMemory(VkDevice device, VkImage image, VkDeviceMemory memory, VkDeviceSize memoryOffset)
GLFWAPI GLFWwindow * glfwCreateWindow(int width, int height, const char *title, GLFWmonitor *monitor, GLFWwindow *share)
Creates a window and its associated context.
VkVertexInputBindingDescription vi_bindings[1]
VkVertexInputAttributeDescription vi_attrs[2]
VkExtent2D maxImageExtent
VkDebugReportFlagsEXT flags
static void demo_draw_build_cmd(struct demo *demo)
static void demo_prepare_descriptor_layout(struct demo *demo)
static int validation_error
VkColorSpaceKHR color_space
VKAPI_ATTR void VKAPI_CALL vkCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance)
static void demo_key_callback(GLFWwindow *window, int key, int scancode, int action, int mods)
static VkShaderModule demo_prepare_vs(struct demo *demo)
static const struct @18 vertices[3]
VKAPI_ATTR VkResult VKAPI_CALL vkDeviceWaitIdle(VkDevice device)
GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance, GLFWwindow *handle, const VkAllocationCallbacks *allocator, VkSurfaceKHR *surface)
#define VK_KHR_SWAPCHAIN_EXTENSION_NAME
struct texture_object textures[DEMO_TEXTURE_COUNT]
GLFWAPI void glfwDestroyWindow(GLFWwindow *window)
Destroys the specified window and its context.
GLFWAPI void glfwTerminate(void)
Terminates the GLFW library.
VKAPI_ATTR void VKAPI_CALL vkDestroyPipelineLayout(VkDevice device, VkPipelineLayout pipelineLayout, const VkAllocationCallbacks *pAllocator)
static void demo_init_vk_swapchain(struct demo *demo)
VKAPI_ATTR VkResult VKAPI_CALL vkAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo, VkCommandBuffer *pCommandBuffers)
VkResult(VKAPI_PTR * PFN_vkGetPhysicalDeviceSurfaceFormatsKHR)(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t *pSurfaceFormatCount, VkSurfaceFormatKHR *pSurfaceFormats)
VkPhysicalDeviceFeatures gpu_features
#define ERR_EXIT(err_msg, err_class)
VKAPI_ATTR void VKAPI_CALL vkDestroyDescriptorSetLayout(VkDevice device, VkDescriptorSetLayout descriptorSetLayout, const VkAllocationCallbacks *pAllocator)
GLFWAPI void glfwPollEvents(void)
Processes all pending events.
VKAPI_ATTR void VKAPI_CALL vkCmdEndRenderPass(VkCommandBuffer commandBuffer)
#define VK_EXT_DEBUG_REPORT_EXTENSION_NAME
VKAPI_ATTR VkResult VKAPI_CALL vkEndCommandBuffer(VkCommandBuffer commandBuffer)
const char * enabled_layers[64]
static void demo_destroy_texture_image(struct demo *demo, struct texture_object *tex_obj)
struct demo::@57 vertices
VKAPI_ATTR void VKAPI_CALL vkDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator)
static VkShaderModule demo_prepare_fs(struct demo *demo)
GLenum GLsizei GLsizei GLsizei GLsizei layers
GLFWAPI const char ** glfwGetRequiredInstanceExtensions(uint32_t *count)
Returns the Vulkan instance extensions required by GLFW.
const VkPipelineDynamicStateCreateInfo * pDynamicState
PFN_vkGetPhysicalDeviceSurfacePresentModesKHR fpGetPhysicalDeviceSurfacePresentModesKHR
#define VK_QUEUE_FAMILY_IGNORED
const VkDynamicState * pDynamicStates
VKAPI_ATTR void VKAPI_CALL vkGetDeviceQueue(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex, VkQueue *pQueue)
VKAPI_ATTR VkResult VKAPI_CALL vkAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo, const VkAllocationCallbacks *pAllocator, VkDeviceMemory *pMemory)
VkResult(VKAPI_PTR * PFN_vkQueuePresentKHR)(VkQueue queue, const VkPresentInfoKHR *pPresentInfo)
VKAPI_ATTR VkResult VKAPI_CALL vkCreatePipelineLayout(VkDevice device, const VkPipelineLayoutCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkPipelineLayout *pPipelineLayout)
VKAPI_ATTR VkResult VKAPI_CALL vkCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass)
VKAPI_ATTR void VKAPI_CALL vkCmdBindPipeline(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline)
static void demo_init_vk(struct demo *demo)
const VkPipelineViewportStateCreateInfo * pViewportState
static void demo_prepare_pipeline(struct demo *demo)
VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceMemoryProperties(VkPhysicalDevice physicalDevice, VkPhysicalDeviceMemoryProperties *pMemoryProperties)
VkDebugReportCallbackEXT msg_callback
VKAPI_ATTR void VKAPI_CALL vkGetImageMemoryRequirements(VkDevice device, VkImage image, VkMemoryRequirements *pMemoryRequirements)
VKAPI_ATTR VkResult VKAPI_CALL vkQueueWaitIdle(VkQueue queue)
const VkDescriptorImageInfo * pImageInfo
VKAPI_ATTR void VKAPI_CALL vkDestroySemaphore(VkDevice device, VkSemaphore semaphore, const VkAllocationCallbacks *pAllocator)
VKAPI_ATTR VkResult VKAPI_CALL vkCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDescriptorPool *pDescriptorPool)
static void demo_create_window(struct demo *demo)
struct GLFWwindow GLFWwindow
GLFWAPI void glfwWindowHint(int hint, int value)
Sets the specified window hint to the desired value.
#define GLFW_CLIENT_API
Context client API hint and attribute.
VkShaderModuleCreateFlags flags
VkResult(VKAPI_PTR * PFN_vkGetPhysicalDeviceSurfaceSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, VkSurfaceKHR surface, VkBool32 *pSupported)
VkResult(VKAPI_PTR * PFN_vkCreateSwapchainKHR)(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSwapchainKHR *pSwapchain)
VkImageLayout imageLayout
VKAPI_ATTR VkResult VKAPI_CALL vkCreatePipelineCache(VkDevice device, const VkPipelineCacheCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkPipelineCache *pPipelineCache)
VKAPI_ATTR void VKAPI_CALL vkCmdBeginRenderPass(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin, VkSubpassContents contents)
SwapchainBuffers * buffers
uint32_t dynamicStateCount
VKAPI_ATTR void VKAPI_CALL vkUnmapMemory(VkDevice device, VkDeviceMemory memory)
#define VK_MAX_MEMORY_TYPES
GLFWAPI int glfwWindowShouldClose(GLFWwindow *window)
Checks the close flag of the specified window.