forked from SaschaWillems/Vulkan
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmultithreading.cpp
More file actions
474 lines (386 loc) · 18.8 KB
/
multithreading.cpp
File metadata and controls
474 lines (386 loc) · 18.8 KB
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
/*
* Vulkan Example - Multi threaded command buffer generation
*
* Copyright (C) 2016-2025 by Sascha Willems - www.saschawillems.de
*
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
*/
#include "vulkanexamplebase.h"
#include "threadpool.hpp"
#include "frustum.hpp"
#include "VulkanglTFModel.h"
class VulkanExample : public VulkanExampleBase
{
public:
bool displayStarSphere = true;
struct {
vkglTF::Model ufo;
vkglTF::Model starSphere;
} models;
// Shared matrices used for thread push constant blocks
struct {
glm::mat4 projection;
glm::mat4 view;
} matrices;
struct {
VkPipeline phong{ VK_NULL_HANDLE };
VkPipeline starsphere{ VK_NULL_HANDLE };
} pipelines;
VkPipelineLayout pipelineLayout{ VK_NULL_HANDLE };
// Secondary scene command buffers used to store backdrop and user interface
struct SecondaryCommandBuffers {
VkCommandBuffer background{ VK_NULL_HANDLE };
VkCommandBuffer ui{ VK_NULL_HANDLE };
};
std::array<SecondaryCommandBuffers, maxConcurrentFrames> secondaryCommandBuffers{};
// Number of animated objects to be renderer
// by using threads and secondary command buffers
uint32_t numObjectsPerThread{ 0 };
// Multi threaded stuff
// Max. number of concurrent threads
uint32_t numThreads{ 0 };
// Use push constants to update shader
// parameters on a per-thread base
struct ThreadPushConstantBlock {
glm::mat4 mvp;
glm::vec3 color;
};
struct ObjectData {
glm::mat4 model;
glm::vec3 pos;
glm::vec3 rotation;
float rotationDir;
float rotationSpeed;
float scale;
float deltaT;
float stateT = 0;
bool visible = true;
};
struct ThreadData {
VkCommandPool commandPool{ VK_NULL_HANDLE };
// One command buffer per render object per max. frames in flight
std::array<std::vector<VkCommandBuffer>, maxConcurrentFrames> commandBuffer;
// One push constant block per render object
std::vector<ThreadPushConstantBlock> pushConstBlock;
// Per object information (position, rotation, etc.)
std::vector<ObjectData> objectData;
};
std::vector<ThreadData> threadData;
vks::ThreadPool threadPool;
// View frustum for culling invisible objects
vks::Frustum frustum;
std::default_random_engine rndEngine;
VulkanExample() : VulkanExampleBase()
{
title = "Multi threaded command buffer";
camera.type = Camera::CameraType::lookat;
camera.setPosition(glm::vec3(0.0f, -0.0f, -32.5f));
camera.setRotation(glm::vec3(0.0f));
camera.setRotationSpeed(0.5f);
camera.setPerspective(60.0f, (float)width / (float)height, 0.1f, 256.0f);
// Get number of max. concurrent threads
numThreads = std::thread::hardware_concurrency();
assert(numThreads > 0);
#if defined(__ANDROID__)
LOGD("numThreads = %d", numThreads);
#else
std::cout << "numThreads = " << numThreads << std::endl;
#endif
threadPool.setThreadCount(numThreads);
numObjectsPerThread = 512 / numThreads;
rndEngine.seed(benchmark.active ? 0 : (unsigned)time(nullptr));
}
~VulkanExample()
{
if (device) {
vkDestroyPipeline(device, pipelines.phong, nullptr);
vkDestroyPipeline(device, pipelines.starsphere, nullptr);
vkDestroyPipelineLayout(device, pipelineLayout, nullptr);
for (auto& thread : threadData) {
for (auto& cmdBuffers : thread.commandBuffer) {
vkFreeCommandBuffers(device, thread.commandPool, static_cast<uint32_t>(cmdBuffers.size()), cmdBuffers.data());
}
vkDestroyCommandPool(device, thread.commandPool, nullptr);
}
}
}
float rnd(float range)
{
std::uniform_real_distribution<float> rndDist(0.0f, range);
return rndDist(rndEngine);
}
// Create all threads and initialize shader push constants
void prepareMultiThreadedRenderer()
{
// The actual commands are issued in secondary command buffers, this also applies to the background and the user interface
for (uint32_t i = 0; i < maxConcurrentFrames; i++) {
VkCommandBufferAllocateInfo cmdBufAllocateInfo = vks::initializers::commandBufferAllocateInfo(cmdPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY, 1);
VK_CHECK_RESULT(vkAllocateCommandBuffers(device, &cmdBufAllocateInfo, &secondaryCommandBuffers[i].background));
VK_CHECK_RESULT(vkAllocateCommandBuffers(device, &cmdBufAllocateInfo, &secondaryCommandBuffers[i].ui));
}
threadData.resize(numThreads);
for (uint32_t i = 0; i < numThreads; i++) {
ThreadData *thread = &threadData[i];
// Command pools need to be per thread
VkCommandPoolCreateInfo cmdPoolInfo = vks::initializers::commandPoolCreateInfo();
cmdPoolInfo.queueFamilyIndex = swapChain.queueNodeIndex;
cmdPoolInfo.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT;
VK_CHECK_RESULT(vkCreateCommandPool(device, &cmdPoolInfo, nullptr, &thread->commandPool));
// One secondary command buffer per object that is updated by this thread
// We also duplicate the command buffers per max. frames in flight
for (auto& commandBuffers : thread->commandBuffer) {
commandBuffers.resize(numObjectsPerThread);
// Generate secondary command buffers for each thread
VkCommandBufferAllocateInfo secondaryCmdBufAllocateInfo = vks::initializers::commandBufferAllocateInfo(thread->commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY, static_cast<uint32_t>(commandBuffers.size()));
VK_CHECK_RESULT(vkAllocateCommandBuffers(device, &secondaryCmdBufAllocateInfo, commandBuffers.data()));
}
thread->pushConstBlock.resize(numObjectsPerThread);
thread->objectData.resize(numObjectsPerThread);
for (uint32_t j = 0; j < numObjectsPerThread; j++) {
float theta = 2.0f * float(M_PI) * rnd(1.0f);
float phi = acos(1.0f - 2.0f * rnd(1.0f));
thread->objectData[j].pos = glm::vec3(sin(phi) * cos(theta), 0.0f, cos(phi)) * 35.0f;
thread->objectData[j].rotation = glm::vec3(0.0f, rnd(360.0f), 0.0f);
thread->objectData[j].deltaT = rnd(1.0f);
thread->objectData[j].rotationDir = (rnd(100.0f) < 50.0f) ? 1.0f : -1.0f;
thread->objectData[j].rotationSpeed = (2.0f + rnd(4.0f)) * thread->objectData[j].rotationDir;
thread->objectData[j].scale = 0.75f + rnd(0.5f);
thread->pushConstBlock[j].color = glm::vec3(rnd(1.0f), rnd(1.0f), rnd(1.0f));
}
}
}
// Builds the secondary command buffer for each thread
void threadRenderCode(uint32_t threadIndex, uint32_t cmdBufferIndex, VkCommandBufferInheritanceInfo inheritanceInfo)
{
ThreadData *thread = &threadData[threadIndex];
ObjectData *objectData = &thread->objectData[cmdBufferIndex];
// Check visibility against view frustum using a simple sphere check based on the radius of the mesh
objectData->visible = frustum.checkSphere(objectData->pos, models.ufo.dimensions.radius * 0.5f);
if (!objectData->visible)
{
return;
}
VkCommandBufferBeginInfo commandBufferBeginInfo = vks::initializers::commandBufferBeginInfo();
commandBufferBeginInfo.flags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
commandBufferBeginInfo.pInheritanceInfo = &inheritanceInfo;
VkCommandBuffer cmdBuffer = thread->commandBuffer[currentBuffer][cmdBufferIndex];
VK_CHECK_RESULT(vkBeginCommandBuffer(cmdBuffer, &commandBufferBeginInfo));
VkViewport viewport = vks::initializers::viewport((float)width, (float)height, 0.0f, 1.0f);
vkCmdSetViewport(cmdBuffer, 0, 1, &viewport);
VkRect2D scissor = vks::initializers::rect2D(width, height, 0, 0);
vkCmdSetScissor(cmdBuffer, 0, 1, &scissor);
vkCmdBindPipeline(cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelines.phong);
// Update
if (!paused) {
objectData->rotation.y += 2.5f * objectData->rotationSpeed * frameTimer;
if (objectData->rotation.y > 360.0f) {
objectData->rotation.y -= 360.0f;
}
objectData->deltaT += 0.15f * frameTimer;
if (objectData->deltaT > 1.0f)
objectData->deltaT -= 1.0f;
objectData->pos.y = sin(glm::radians(objectData->deltaT * 360.0f)) * 2.5f;
}
objectData->model = glm::translate(glm::mat4(1.0f), objectData->pos);
objectData->model = glm::rotate(objectData->model, -sinf(glm::radians(objectData->deltaT * 360.0f)) * 0.25f, glm::vec3(objectData->rotationDir, 0.0f, 0.0f));
objectData->model = glm::rotate(objectData->model, glm::radians(objectData->rotation.y), glm::vec3(0.0f, objectData->rotationDir, 0.0f));
objectData->model = glm::rotate(objectData->model, glm::radians(objectData->deltaT * 360.0f), glm::vec3(0.0f, objectData->rotationDir, 0.0f));
objectData->model = glm::scale(objectData->model, glm::vec3(objectData->scale));
thread->pushConstBlock[cmdBufferIndex].mvp = matrices.projection * matrices.view * objectData->model;
// Update shader push constant block
// Contains model view matrix
vkCmdPushConstants(
cmdBuffer,
pipelineLayout,
VK_SHADER_STAGE_VERTEX_BIT,
0,
sizeof(ThreadPushConstantBlock),
&thread->pushConstBlock[cmdBufferIndex]);
VkDeviceSize offsets[1] = { 0 };
vkCmdBindVertexBuffers(cmdBuffer, 0, 1, &models.ufo.vertices.buffer, offsets);
vkCmdBindIndexBuffer(cmdBuffer, models.ufo.indices.buffer, 0, VK_INDEX_TYPE_UINT32);
vkCmdDrawIndexed(cmdBuffer, models.ufo.indices.count, 1, 0, 0, 0);
VK_CHECK_RESULT(vkEndCommandBuffer(cmdBuffer));
}
void updateSecondaryCommandBuffers(VkCommandBufferInheritanceInfo inheritanceInfo)
{
// Secondary command buffer for the sky sphere
VkCommandBufferBeginInfo commandBufferBeginInfo = vks::initializers::commandBufferBeginInfo();
commandBufferBeginInfo.flags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
commandBufferBeginInfo.pInheritanceInfo = &inheritanceInfo;
VkViewport viewport = vks::initializers::viewport((float)width, (float)height, 0.0f, 1.0f);
VkRect2D scissor = vks::initializers::rect2D(width, height, 0, 0);
/*
Background
*/
VK_CHECK_RESULT(vkBeginCommandBuffer(secondaryCommandBuffers[currentBuffer].background, &commandBufferBeginInfo));
vkCmdSetViewport(secondaryCommandBuffers[currentBuffer].background, 0, 1, &viewport);
vkCmdSetScissor(secondaryCommandBuffers[currentBuffer].background, 0, 1, &scissor);
vkCmdBindPipeline(secondaryCommandBuffers[currentBuffer].background, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelines.starsphere);
glm::mat4 mvp = matrices.projection * matrices.view;
mvp[3] = glm::vec4(0.0f, 0.0f, 0.0f, 1.0f);
mvp = glm::scale(mvp, glm::vec3(2.0f));
vkCmdPushConstants(
secondaryCommandBuffers[currentBuffer].background,
pipelineLayout,
VK_SHADER_STAGE_VERTEX_BIT,
0,
sizeof(mvp),
&mvp);
models.starSphere.draw(secondaryCommandBuffers[currentBuffer].background);
VK_CHECK_RESULT(vkEndCommandBuffer(secondaryCommandBuffers[currentBuffer].background));
/*
User interface
With VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS, the primary command buffer's content has to be defined
by secondary command buffers, which also applies to the UI overlay command buffer
*/
VK_CHECK_RESULT(vkBeginCommandBuffer(secondaryCommandBuffers[currentBuffer].ui, &commandBufferBeginInfo));
vkCmdSetViewport(secondaryCommandBuffers[currentBuffer].ui, 0, 1, &viewport);
vkCmdSetScissor(secondaryCommandBuffers[currentBuffer].ui, 0, 1, &scissor);
vkCmdBindPipeline(secondaryCommandBuffers[currentBuffer].ui, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelines.starsphere);
drawUI(secondaryCommandBuffers[currentBuffer].ui);
VK_CHECK_RESULT(vkEndCommandBuffer(secondaryCommandBuffers[currentBuffer].ui));
}
void loadAssets()
{
const uint32_t glTFLoadingFlags = vkglTF::FileLoadingFlags::PreTransformVertices | vkglTF::FileLoadingFlags::PreMultiplyVertexColors | vkglTF::FileLoadingFlags::FlipY;
models.ufo.loadFromFile(getAssetPath() + "models/retroufo_red_lowpoly.gltf",vulkanDevice, queue,glTFLoadingFlags);
models.starSphere.loadFromFile(getAssetPath() + "models/sphere.gltf", vulkanDevice, queue, glTFLoadingFlags);
}
void preparePipelines()
{
// Layout
VkPipelineLayoutCreateInfo pipelineLayoutCreateInfo = vks::initializers::pipelineLayoutCreateInfo(nullptr, 0);
// Push constants for model matrices
VkPushConstantRange pushConstantRange = vks::initializers::pushConstantRange(VK_SHADER_STAGE_VERTEX_BIT, sizeof(ThreadPushConstantBlock), 0);
// Push constant ranges are part of the pipeline layout
pipelineLayoutCreateInfo.pushConstantRangeCount = 1;
pipelineLayoutCreateInfo.pPushConstantRanges = &pushConstantRange;
VK_CHECK_RESULT(vkCreatePipelineLayout(device, &pipelineLayoutCreateInfo, nullptr, &pipelineLayout));
// Pipelines
VkPipelineInputAssemblyStateCreateInfo inputAssemblyState = vks::initializers::pipelineInputAssemblyStateCreateInfo(VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, 0, VK_FALSE);
VkPipelineRasterizationStateCreateInfo rasterizationState = vks::initializers::pipelineRasterizationStateCreateInfo(VK_POLYGON_MODE_FILL, VK_CULL_MODE_BACK_BIT, VK_FRONT_FACE_COUNTER_CLOCKWISE, 0);
VkPipelineColorBlendAttachmentState blendAttachmentState = vks::initializers::pipelineColorBlendAttachmentState(0xf, VK_FALSE);
VkPipelineColorBlendStateCreateInfo colorBlendState = vks::initializers::pipelineColorBlendStateCreateInfo(1, &blendAttachmentState);
VkPipelineDepthStencilStateCreateInfo depthStencilState = vks::initializers::pipelineDepthStencilStateCreateInfo(VK_TRUE, VK_TRUE, VK_COMPARE_OP_LESS_OR_EQUAL);
VkPipelineViewportStateCreateInfo viewportState = vks::initializers::pipelineViewportStateCreateInfo(1, 1, 0);
VkPipelineMultisampleStateCreateInfo multisampleState = vks::initializers::pipelineMultisampleStateCreateInfo(VK_SAMPLE_COUNT_1_BIT, 0);
std::vector<VkDynamicState> dynamicStateEnables = {VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR};
VkPipelineDynamicStateCreateInfo dynamicState = vks::initializers::pipelineDynamicStateCreateInfo(dynamicStateEnables);
std::array<VkPipelineShaderStageCreateInfo, 2> shaderStages{};
VkGraphicsPipelineCreateInfo pipelineCI = vks::initializers::pipelineCreateInfo(pipelineLayout, renderPass, 0);
pipelineCI.pInputAssemblyState = &inputAssemblyState;
pipelineCI.pRasterizationState = &rasterizationState;
pipelineCI.pColorBlendState = &colorBlendState;
pipelineCI.pMultisampleState = &multisampleState;
pipelineCI.pViewportState = &viewportState;
pipelineCI.pDepthStencilState = &depthStencilState;
pipelineCI.pDynamicState = &dynamicState;
pipelineCI.stageCount = static_cast<uint32_t>(shaderStages.size());
pipelineCI.pStages = shaderStages.data();
pipelineCI.pVertexInputState = vkglTF::Vertex::getPipelineVertexInputState({vkglTF::VertexComponent::Position, vkglTF::VertexComponent::Normal, vkglTF::VertexComponent::Color});
// Object rendering pipeline
shaderStages[0] = loadShader(getShadersPath() + "multithreading/phong.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
shaderStages[1] = loadShader(getShadersPath() + "multithreading/phong.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCI, nullptr, &pipelines.phong));
// Star sphere rendering pipeline
rasterizationState.cullMode = VK_CULL_MODE_FRONT_BIT;
depthStencilState.depthWriteEnable = VK_FALSE;
shaderStages[0] = loadShader(getShadersPath() + "multithreading/starsphere.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
shaderStages[1] = loadShader(getShadersPath() + "multithreading/starsphere.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCI, nullptr, &pipelines.starsphere));
}
void updateMatrices()
{
matrices.projection = camera.matrices.perspective;
matrices.view = camera.matrices.view;
frustum.update(matrices.projection * matrices.view);
}
void prepare()
{
VulkanExampleBase::prepare();
loadAssets();
preparePipelines();
prepareMultiThreadedRenderer();
updateMatrices();
prepared = true;
}
// Updates the secondary command buffers using a thread pool
// and puts them into the primary command buffer that's
// lat submitted to the queue for rendering
void updateCommandBuffer()
{
VkCommandBuffer cmdBuffer = drawCmdBuffers[currentBuffer];
// Contains the list of secondary command buffers to be submitted
std::vector<VkCommandBuffer> commandBuffers;
VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo();
VkClearValue clearValues[2]{};
clearValues[0].color = defaultClearColor;
clearValues[1].depthStencil = { 1.0f, 0 };
VkRenderPassBeginInfo renderPassBeginInfo = vks::initializers::renderPassBeginInfo();
renderPassBeginInfo.renderPass = renderPass;
renderPassBeginInfo.renderArea.offset.x = 0;
renderPassBeginInfo.renderArea.offset.y = 0;
renderPassBeginInfo.renderArea.extent.width = width;
renderPassBeginInfo.renderArea.extent.height = height;
renderPassBeginInfo.clearValueCount = 2;
renderPassBeginInfo.pClearValues = clearValues;
renderPassBeginInfo.framebuffer = frameBuffers[currentImageIndex];
VK_CHECK_RESULT(vkBeginCommandBuffer(drawCmdBuffers[currentBuffer], &cmdBufInfo));
// The primary command buffer does not contain any rendering commands
// These are stored (and retrieved) from the secondary command buffers
vkCmdBeginRenderPass(drawCmdBuffers[currentBuffer], &renderPassBeginInfo, VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS);
// Inheritance info for the secondary command buffers
VkCommandBufferInheritanceInfo inheritanceInfo = vks::initializers::commandBufferInheritanceInfo();
inheritanceInfo.renderPass = renderPassBeginInfo.renderPass;
// Secondary command buffer also use the currently active framebuffer
inheritanceInfo.framebuffer = renderPassBeginInfo.framebuffer;
// Update secondary sene command buffers
updateSecondaryCommandBuffers(inheritanceInfo);
if (displayStarSphere) {
commandBuffers.push_back(secondaryCommandBuffers[currentBuffer].background);
}
// Add a job to the thread's queue for each object to be rendered
for (uint32_t t = 0; t < numThreads; t++) {
for (uint32_t i = 0; i < numObjectsPerThread; i++) {
threadPool.threads[t]->addJob([=, this] { threadRenderCode(t, i, inheritanceInfo); });
}
}
threadPool.wait();
// Only submit if object is within the current view frustum
for (uint32_t t = 0; t < numThreads; t++) {
for (uint32_t i = 0; i < numObjectsPerThread; i++) {
if (threadData[t].objectData[i].visible) {
commandBuffers.push_back(threadData[t].commandBuffer[currentBuffer][i]);
}
}
}
// Render ui last
if (ui.visible) {
commandBuffers.push_back(secondaryCommandBuffers[currentBuffer].ui);
}
// Execute render commands from the secondary command buffer
vkCmdExecuteCommands(drawCmdBuffers[currentBuffer], static_cast<uint32_t>(commandBuffers.size()), commandBuffers.data());
vkCmdEndRenderPass(drawCmdBuffers[currentBuffer]);
VK_CHECK_RESULT(vkEndCommandBuffer(drawCmdBuffers[currentBuffer]));
}
virtual void render()
{
if (!prepared)
return;
VulkanExampleBase::prepareFrame();
updateCommandBuffer();
updateMatrices();
VulkanExampleBase::submitFrame();
}
virtual void OnUpdateUIOverlay(vks::UIOverlay *overlay)
{
if (overlay->header("Statistics")) {
overlay->text("Active threads: %d", numThreads);
}
if (overlay->header("Settings")) {
overlay->checkBox("Stars", &displayStarSphere);
}
}
};
VULKAN_EXAMPLE_MAIN()