Skip to content

Commit 5e489fc

Browse files
authored
Fix GUI issues with command line viewer (#19)
1 parent f4398e5 commit 5e489fc

4 files changed

Lines changed: 25 additions & 22 deletions

File tree

apps/viewer/main.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ int main(int argc, char** argv) {
8282

8383
if (noGuiFlag) {
8484
config.enableGui = false;
85+
} else {
86+
config.enableGui = true;
8587
}
8688

8789
auto width = widthFlag ? args::get(widthFlag) : 1280;

src/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ file(GLOB SOURCE
1818
vulkan/pipelines/*.cpp
1919
vulkan/windowing/GLFWWindow.cpp)
2020

21+
# Remove DummyGUIManager.cpp from source list
22+
list(REMOVE_ITEM SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/DummyGUIManager.cpp)
23+
2124
add_library(vulkan_splatting STATIC
2225
${SOURCE}
2326
${EXTERNAL_SOURCE}

src/GUIManager.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ void GUIManager::buildGui() {
7979
for (auto& [name, value]: *textMetricsMap) {
8080
ImGui::Text("%s: %.2f", name.c_str(), value);
8181
}
82+
for (auto & [name, values]: *metricsMap) {
83+
ImGui::Text("%s: %.2f", name.c_str(), values.data.empty() ? 0 : values.data.back().y);
84+
}
8285
ImGui::End();
8386

8487
ImGui::SetNextWindowPos(ImVec2(10, 310), ImGuiCond_FirstUseEver);

src/Renderer.cpp

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ void Renderer::recordPreprocessCommandBuffer() {
472472
preprocessCommandBuffer->resetQueryPool(context->queryPool.get(), 0, 12);
473473

474474
preprocessPipeline->bind(preprocessCommandBuffer, 0, 0);
475-
preprocessCommandBuffer->writeTimestamp(vk::PipelineStageFlagBits::eTopOfPipe, context->queryPool.get(),
475+
preprocessCommandBuffer->writeTimestamp(vk::PipelineStageFlagBits::eComputeShader, context->queryPool.get(),
476476
queryManager->registerQuery("preprocess_start"));
477477
preprocessCommandBuffer->dispatch(numGroups, 1, 1);
478478
tileOverlapBuffer->computeWriteReadBarrier(preprocessCommandBuffer.get());
@@ -482,11 +482,11 @@ void Renderer::recordPreprocessCommandBuffer() {
482482

483483
prefixSumPingBuffer->computeWriteReadBarrier(preprocessCommandBuffer.get());
484484

485-
preprocessCommandBuffer->writeTimestamp(vk::PipelineStageFlagBits::eBottomOfPipe, context->queryPool.get(),
485+
preprocessCommandBuffer->writeTimestamp(vk::PipelineStageFlagBits::eComputeShader, context->queryPool.get(),
486486
queryManager->registerQuery("preprocess_end"));
487487

488488
prefixSumPipeline->bind(preprocessCommandBuffer, 0, 0);
489-
preprocessCommandBuffer->writeTimestamp(vk::PipelineStageFlagBits::eTopOfPipe, context->queryPool.get(),
489+
preprocessCommandBuffer->writeTimestamp(vk::PipelineStageFlagBits::eComputeShader, context->queryPool.get(),
490490
queryManager->registerQuery("prefix_sum_start"));
491491
const auto iters = static_cast<uint32_t>(std::ceil(std::log2(static_cast<float>(scene->getNumVertices()))));
492492
for (uint32_t timestep = 0; timestep <= iters; timestep++) {
@@ -513,6 +513,9 @@ void Renderer::recordPreprocessCommandBuffer() {
513513
&totalSumRegion);
514514
}
515515

516+
preprocessCommandBuffer->writeTimestamp(vk::PipelineStageFlagBits::eComputeShader, context->queryPool.get(),
517+
queryManager->registerQuery("prefix_sum_end"));
518+
516519
preprocessCommandBuffer->end();
517520
}
518521

@@ -562,13 +565,10 @@ bool Renderer::recordRenderCommandBuffer(uint32_t currentFrame) {
562565

563566
vertexAttributeBuffer->computeWriteReadBarrier(renderCommandBuffer.get());
564567

565-
renderCommandBuffer->writeTimestamp(vk::PipelineStageFlagBits::eBottomOfPipe, context->queryPool.get(),
566-
queryManager->registerQuery("prefix_sum_end"));
567-
568568
const auto iters = static_cast<uint32_t>(std::ceil(std::log2(static_cast<float>(scene->getNumVertices()))));
569569
auto numGroups = (scene->getNumVertices() + 255) / 256;
570570
preprocessSortPipeline->bind(renderCommandBuffer, 0, iters % 2 == 0 ? 0 : 1);
571-
renderCommandBuffer->writeTimestamp(vk::PipelineStageFlagBits::eTopOfPipe, context->queryPool.get(),
571+
renderCommandBuffer->writeTimestamp(vk::PipelineStageFlagBits::eComputeShader, context->queryPool.get(),
572572
queryManager->registerQuery("preprocess_sort_start"));
573573
uint32_t tileX = (swapchain->swapchainExtent.width + 16 - 1) / 16;
574574
// assert(tileX == 50);
@@ -578,18 +578,16 @@ bool Renderer::recordRenderCommandBuffer(uint32_t currentFrame) {
578578
renderCommandBuffer->dispatch(numGroups, 1, 1);
579579

580580
sortKBufferEven->computeWriteReadBarrier(renderCommandBuffer.get());
581-
renderCommandBuffer->writeTimestamp(vk::PipelineStageFlagBits::eBottomOfPipe, context->queryPool.get(),
581+
renderCommandBuffer->writeTimestamp(vk::PipelineStageFlagBits::eComputeShader, context->queryPool.get(),
582582
queryManager->registerQuery("preprocess_sort_end"));
583583

584584
// std::cout << "Num instances: " << numInstances << std::endl;
585585

586586
assert(numInstances <= scene->getNumVertices() * sortBufferSizeMultiplier);
587+
renderCommandBuffer->writeTimestamp(vk::PipelineStageFlagBits::eComputeShader, context->queryPool.get(),
588+
queryManager->registerQuery("sort_start"));
587589
for (auto i = 0; i < 8; i++) {
588590
sortHistPipeline->bind(renderCommandBuffer, 0, i % 2 == 0 ? 0 : 1);
589-
if (i == 0) {
590-
renderCommandBuffer->writeTimestamp(vk::PipelineStageFlagBits::eTopOfPipe, context->queryPool.get(),
591-
queryManager->registerQuery("sort_start"));
592-
}
593591
auto invocationSize = (numInstances + numRadixSortBlocksPerWorkgroup - 1) / numRadixSortBlocksPerWorkgroup;
594592
invocationSize = (invocationSize + 255) / 256;
595593

@@ -619,12 +617,9 @@ bool Renderer::recordRenderCommandBuffer(uint32_t currentFrame) {
619617
sortKBufferEven->computeWriteReadBarrier(renderCommandBuffer.get());
620618
sortVBufferEven->computeWriteReadBarrier(renderCommandBuffer.get());
621619
}
622-
623-
if (i == 7) {
624-
renderCommandBuffer->writeTimestamp(vk::PipelineStageFlagBits::eBottomOfPipe, context->queryPool.get(),
625-
queryManager->registerQuery("sort_end"));
626-
}
627620
}
621+
renderCommandBuffer->writeTimestamp(vk::PipelineStageFlagBits::eComputeShader, context->queryPool.get(),
622+
queryManager->registerQuery("sort_end"));
628623

629624
renderCommandBuffer->fillBuffer(tileBoundaryBuffer->buffer, 0, VK_WHOLE_SIZE, 0);
630625

@@ -636,19 +631,19 @@ bool Renderer::recordRenderCommandBuffer(uint32_t currentFrame) {
636631

637632
// Since we have 64 bit keys, the sort result is always in the even buffer
638633
tileBoundaryPipeline->bind(renderCommandBuffer, 0, 0);
639-
renderCommandBuffer->writeTimestamp(vk::PipelineStageFlagBits::eTopOfPipe, context->queryPool.get(),
634+
renderCommandBuffer->writeTimestamp(vk::PipelineStageFlagBits::eComputeShader, context->queryPool.get(),
640635
queryManager->registerQuery("tile_boundary_start"));
641636
renderCommandBuffer->pushConstants(tileBoundaryPipeline->pipelineLayout.get(),
642637
vk::ShaderStageFlagBits::eCompute, 0,
643638
sizeof(uint32_t), &numInstances);
644639
renderCommandBuffer->dispatch((numInstances + 255) / 256, 1, 1);
645640

646641
tileBoundaryBuffer->computeWriteReadBarrier(renderCommandBuffer.get());
647-
renderCommandBuffer->writeTimestamp(vk::PipelineStageFlagBits::eBottomOfPipe, context->queryPool.get(),
642+
renderCommandBuffer->writeTimestamp(vk::PipelineStageFlagBits::eComputeShader, context->queryPool.get(),
648643
queryManager->registerQuery("tile_boundary_end"));
649644

650645
renderPipeline->bind(renderCommandBuffer, 0, std::vector<uint32_t>{0, currentImageIndex});
651-
renderCommandBuffer->writeTimestamp(vk::PipelineStageFlagBits::eTopOfPipe, context->queryPool.get(),
646+
renderCommandBuffer->writeTimestamp(vk::PipelineStageFlagBits::eComputeShader, context->queryPool.get(),
652647
queryManager->registerQuery("render_start"));
653648
auto [width, height] = swapchain->swapchainExtent;
654649
uint32_t constants[2] = {width, height};
@@ -691,7 +686,7 @@ bool Renderer::recordRenderCommandBuffer(uint32_t currentFrame) {
691686
vk::PipelineStageFlagBits::eBottomOfPipe,
692687
vk::DependencyFlagBits::eByRegion, nullptr, nullptr, imageMemoryBarrier);
693688
}
694-
renderCommandBuffer->writeTimestamp(vk::PipelineStageFlagBits::eBottomOfPipe, context->queryPool.get(),
689+
renderCommandBuffer->writeTimestamp(vk::PipelineStageFlagBits::eComputeShader, context->queryPool.get(),
695690
queryManager->registerQuery("render_end"));
696691

697692
if (configuration.enableGui) {
@@ -704,7 +699,7 @@ bool Renderer::recordRenderCommandBuffer(uint32_t currentFrame) {
704699
imageMemoryBarrier.dstAccessMask = vk::AccessFlagBits::eMemoryRead;
705700

706701
renderCommandBuffer->pipelineBarrier(vk::PipelineStageFlagBits::eColorAttachmentOutput,
707-
vk::PipelineStageFlagBits::eBottomOfPipe,
702+
vk::PipelineStageFlagBits::eComputeShader,
708703
vk::DependencyFlagBits::eByRegion, nullptr, nullptr, imageMemoryBarrier);
709704
}
710705
renderCommandBuffer->end();

0 commit comments

Comments
 (0)