Adding in tracy profiler
This commit is contained in:
@@ -8,3 +8,6 @@
|
|||||||
path = third_party/imgui
|
path = third_party/imgui
|
||||||
url = https://github.com/ocornut/imgui.git
|
url = https://github.com/ocornut/imgui.git
|
||||||
branch = docking
|
branch = docking
|
||||||
|
[submodule "third_party/tracy"]
|
||||||
|
path = third_party/tracy
|
||||||
|
url = https://github.com/wolfpld/tracy.git
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ target_link_libraries(${ENGINE_NAME} PUBLIC
|
|||||||
glm
|
glm
|
||||||
imgui
|
imgui
|
||||||
entt
|
entt
|
||||||
|
Tracy::TracyClient
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(${ENGINE_NAME} PRIVATE
|
target_link_libraries(${ENGINE_NAME} PRIVATE
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#include <sophia/application.hpp>
|
#include <sophia/application.hpp>
|
||||||
#include <sophia/util/logger.hpp>
|
#include <sophia/util/logger.hpp>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <tracy/Tracy.hpp>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <vulkan/vulkan.hpp>
|
#include <vulkan/vulkan.hpp>
|
||||||
@@ -118,7 +119,10 @@ class Application::Impl {
|
|||||||
glm::vec2(static_cast<float>(extent.width),
|
glm::vec2(static_cast<float>(extent.width),
|
||||||
static_cast<float>(extent.height)),
|
static_cast<float>(extent.height)),
|
||||||
this->application.camera};
|
this->application.camera};
|
||||||
this->application.onUpdate(frameInfo);
|
{
|
||||||
|
ZoneScopedN("Application::onUpdate");
|
||||||
|
this->application.onUpdate(frameInfo);
|
||||||
|
}
|
||||||
this->application.camera.setProjection(
|
this->application.camera.setProjection(
|
||||||
-frameInfo.currentFramebufferExtent.x / 2.f,
|
-frameInfo.currentFramebufferExtent.x / 2.f,
|
||||||
frameInfo.currentFramebufferExtent.x / 2.f,
|
frameInfo.currentFramebufferExtent.x / 2.f,
|
||||||
@@ -134,7 +138,10 @@ class Application::Impl {
|
|||||||
sceneRenderer.beginFrame(renderContext.getFrameIndex());
|
sceneRenderer.beginFrame(renderContext.getFrameIndex());
|
||||||
|
|
||||||
panelRegistry.update(frameInfo);
|
panelRegistry.update(frameInfo);
|
||||||
this->application.onRender();
|
{
|
||||||
|
ZoneScopedN("Application::onRender");
|
||||||
|
this->application.onRender();
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<ModelRenderSystem::MeshInstance> instances;
|
std::vector<ModelRenderSystem::MeshInstance> instances;
|
||||||
instances.reserve(this->meshes.size() + this->drawCalls.size());
|
instances.reserve(this->meshes.size() + this->drawCalls.size());
|
||||||
@@ -176,6 +183,7 @@ class Application::Impl {
|
|||||||
},
|
},
|
||||||
[&sceneRenderer, &sceneRegistry, &sceneViewRegistry,
|
[&sceneRenderer, &sceneRegistry, &sceneViewRegistry,
|
||||||
&viewsWithoutCamera, handle](vk::CommandBuffer commandBuffer) {
|
&viewsWithoutCamera, handle](vk::CommandBuffer commandBuffer) {
|
||||||
|
ZoneScopedN("scene view pass");
|
||||||
const SceneView& view = sceneViewRegistry.peek(handle);
|
const SceneView& view = sceneViewRegistry.peek(handle);
|
||||||
Entity camera =
|
Entity camera =
|
||||||
view.camera ? view.camera
|
view.camera ? view.camera
|
||||||
@@ -204,6 +212,7 @@ class Application::Impl {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
[&](vk::CommandBuffer commandBuffer) {
|
[&](vk::CommandBuffer commandBuffer) {
|
||||||
|
ZoneScopedN("main pass");
|
||||||
modelRenderSystem.render(commandBuffer, instances, frameInfo);
|
modelRenderSystem.render(commandBuffer, instances, frameInfo);
|
||||||
|
|
||||||
imguiRenderer.endFrame(commandBuffer);
|
imguiRenderer.endFrame(commandBuffer);
|
||||||
@@ -212,6 +221,7 @@ class Application::Impl {
|
|||||||
graph.execute(commandBuffer);
|
graph.execute(commandBuffer);
|
||||||
|
|
||||||
renderContext.endFrame();
|
renderContext.endFrame();
|
||||||
|
FrameMark;
|
||||||
|
|
||||||
frameIndex++;
|
frameIndex++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
#include <imgui_impl_vulkan.h>
|
#include <imgui_impl_vulkan.h>
|
||||||
#include <imgui_internal.h>
|
#include <imgui_internal.h>
|
||||||
|
|
||||||
|
#include <tracy/Tracy.hpp>
|
||||||
|
|
||||||
#include "resources/render_target.hpp"
|
#include "resources/render_target.hpp"
|
||||||
|
|
||||||
namespace sophia {
|
namespace sophia {
|
||||||
@@ -79,6 +81,7 @@ ImGuiRenderer::~ImGuiRenderer() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ImGuiRenderer::beginFrame() {
|
void ImGuiRenderer::beginFrame() {
|
||||||
|
ZoneScoped;
|
||||||
releaseStaleTextures();
|
releaseStaleTextures();
|
||||||
|
|
||||||
ImGui_ImplVulkan_NewFrame();
|
ImGui_ImplVulkan_NewFrame();
|
||||||
@@ -183,6 +186,7 @@ void ImGuiRenderer::applyLayoutIfNeeded(ImGuiID dockspaceId,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ImGuiRenderer::endFrame(vk::CommandBuffer commandBuffer) {
|
void ImGuiRenderer::endFrame(vk::CommandBuffer commandBuffer) {
|
||||||
|
ZoneScoped;
|
||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
ImDrawData* mainDrawData = ImGui::GetDrawData();
|
ImDrawData* mainDrawData = ImGui::GetDrawData();
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "renderer/model_render_system.hpp"
|
#include "renderer/model_render_system.hpp"
|
||||||
|
|
||||||
#include <sophia/util/assert.hpp>
|
#include <sophia/util/assert.hpp>
|
||||||
|
#include <tracy/Tracy.hpp>
|
||||||
|
|
||||||
#include "shaders/model_render_system.frag.spv.h"
|
#include "shaders/model_render_system.frag.spv.h"
|
||||||
#include "shaders/model_render_system.vert.spv.h"
|
#include "shaders/model_render_system.vert.spv.h"
|
||||||
@@ -44,6 +45,7 @@ ModelRenderSystem::~ModelRenderSystem() {
|
|||||||
void ModelRenderSystem::render(vk::CommandBuffer commandBuffer,
|
void ModelRenderSystem::render(vk::CommandBuffer commandBuffer,
|
||||||
std::span<const MeshInstance> instances,
|
std::span<const MeshInstance> instances,
|
||||||
const FrameInfo& frameInfo) {
|
const FrameInfo& frameInfo) {
|
||||||
|
ZoneScoped;
|
||||||
glm::mat4 viewProjection = frameInfo.camera.getViewProjection();
|
glm::mat4 viewProjection = frameInfo.camera.getViewProjection();
|
||||||
|
|
||||||
this->graphicsPipeline->bind(commandBuffer);
|
this->graphicsPipeline->bind(commandBuffer);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include <sophia/util/assert.hpp>
|
#include <sophia/util/assert.hpp>
|
||||||
#include <sophia/util/logger.hpp>
|
#include <sophia/util/logger.hpp>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
#include <tracy/Tracy.hpp>
|
||||||
|
|
||||||
#include "vulkan/access.hpp"
|
#include "vulkan/access.hpp"
|
||||||
|
|
||||||
@@ -18,14 +19,19 @@ RenderContext::RenderContext(Window& window, Device& device)
|
|||||||
RenderContext::~RenderContext() { this->device.waitIdle(); }
|
RenderContext::~RenderContext() { this->device.waitIdle(); }
|
||||||
|
|
||||||
vk::CommandBuffer RenderContext::beginFrame() {
|
vk::CommandBuffer RenderContext::beginFrame() {
|
||||||
|
ZoneScoped;
|
||||||
SOPHIA_ASSERT(!this->isFrameStarted,
|
SOPHIA_ASSERT(!this->isFrameStarted,
|
||||||
"Can't call beginFrame while already in progress");
|
"Can't call beginFrame while already in progress");
|
||||||
|
|
||||||
FrameData& frame = this->frames[this->currentFrameIndex];
|
FrameData& frame = this->frames[this->currentFrameIndex];
|
||||||
|
|
||||||
vk::Fence inFlightFence = frame.inFlight.get();
|
vk::Fence inFlightFence = frame.inFlight.get();
|
||||||
vk::Result fenceResult = this->device.get()->waitForFences(
|
vk::Result fenceResult;
|
||||||
inFlightFence, vk::True, std::numeric_limits<u64>::max());
|
{
|
||||||
|
ZoneScopedN("wait for frame fence");
|
||||||
|
fenceResult = this->device.get()->waitForFences(
|
||||||
|
inFlightFence, vk::True, std::numeric_limits<u64>::max());
|
||||||
|
}
|
||||||
|
|
||||||
if (fenceResult != vk::Result::eSuccess) {
|
if (fenceResult != vk::Result::eSuccess) {
|
||||||
log::error("failed to wait for fence: " + vk::to_string(fenceResult));
|
log::error("failed to wait for fence: " + vk::to_string(fenceResult));
|
||||||
@@ -73,6 +79,7 @@ vk::CommandBuffer RenderContext::beginFrame() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RenderContext::endFrame() {
|
void RenderContext::endFrame() {
|
||||||
|
ZoneScoped;
|
||||||
SOPHIA_ASSERT(this->isFrameStarted,
|
SOPHIA_ASSERT(this->isFrameStarted,
|
||||||
"Can't call endFrame while no frame is in progress");
|
"Can't call endFrame while no frame is in progress");
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "renderer/render_graph.hpp"
|
#include "renderer/render_graph.hpp"
|
||||||
|
|
||||||
#include <sophia/util/assert.hpp>
|
#include <sophia/util/assert.hpp>
|
||||||
|
#include <tracy/Tracy.hpp>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "vulkan/debug_label.hpp"
|
#include "vulkan/debug_label.hpp"
|
||||||
@@ -24,6 +25,7 @@ void RenderGraph::addPass(std::string name, const SetupFn& setup,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RenderGraph::execute(vk::CommandBuffer commandBuffer) {
|
void RenderGraph::execute(vk::CommandBuffer commandBuffer) {
|
||||||
|
ZoneScoped;
|
||||||
for (Pass& pass : this->passes) {
|
for (Pass& pass : this->passes) {
|
||||||
this->recordPass(commandBuffer, pass);
|
this->recordPass(commandBuffer, pass);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <sophia/components.hpp>
|
#include <sophia/components.hpp>
|
||||||
#include <sophia/util/assert.hpp>
|
#include <sophia/util/assert.hpp>
|
||||||
|
#include <tracy/Tracy.hpp>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
|
|
||||||
namespace sophia {
|
namespace sophia {
|
||||||
@@ -15,11 +16,13 @@ SceneRenderer::SceneRenderer(const SceneRegistry& sceneRegistry,
|
|||||||
spriteRenderSystem{device, colorFormat, resources} {}
|
spriteRenderSystem{device, colorFormat, resources} {}
|
||||||
|
|
||||||
void SceneRenderer::beginFrame(u32 frameIndex) {
|
void SceneRenderer::beginFrame(u32 frameIndex) {
|
||||||
|
ZoneScoped;
|
||||||
this->spriteRenderSystem.beginFrame(frameIndex);
|
this->spriteRenderSystem.beginFrame(frameIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SceneRenderer::render(vk::CommandBuffer commandBuffer,
|
void SceneRenderer::render(vk::CommandBuffer commandBuffer,
|
||||||
const SceneView& sceneView, Entity camera) {
|
const SceneView& sceneView, Entity camera) {
|
||||||
|
ZoneScoped;
|
||||||
SOPHIA_ASSERT(camera.hasComponent<CameraComponent>(),
|
SOPHIA_ASSERT(camera.hasComponent<CameraComponent>(),
|
||||||
"camera does not have camera component!");
|
"camera does not have camera component!");
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <sophia/util/assert.hpp>
|
#include <sophia/util/assert.hpp>
|
||||||
#include <sophia/util/logger.hpp>
|
#include <sophia/util/logger.hpp>
|
||||||
|
#include <tracy/Tracy.hpp>
|
||||||
|
|
||||||
#include "shaders/sprite.frag.spv.h"
|
#include "shaders/sprite.frag.spv.h"
|
||||||
#include "shaders/sprite.vert.spv.h"
|
#include "shaders/sprite.vert.spv.h"
|
||||||
@@ -36,6 +37,7 @@ void SpriteRenderSystem::render(vk::CommandBuffer commandBuffer,
|
|||||||
const glm::mat4& viewProjection,
|
const glm::mat4& viewProjection,
|
||||||
std::span<const Instance> instances,
|
std::span<const Instance> instances,
|
||||||
std::span<const Batch> batches) {
|
std::span<const Batch> batches) {
|
||||||
|
ZoneScoped;
|
||||||
if (instances.empty()) {
|
if (instances.empty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
#include "resources/pools/render_target_pool.hpp"
|
#include "resources/pools/render_target_pool.hpp"
|
||||||
|
|
||||||
|
#include <tracy/Tracy.hpp>
|
||||||
|
|
||||||
namespace sophia {
|
namespace sophia {
|
||||||
|
|
||||||
RenderTargetPool::RenderTargetPool(Device& device, vk::Format format)
|
RenderTargetPool::RenderTargetPool(Device& device, vk::Format format)
|
||||||
@@ -16,6 +18,7 @@ void RenderTargetPool::release(RenderTargetHandle handle) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RenderTargetPool::applyPendingResizes() {
|
void RenderTargetPool::applyPendingResizes() {
|
||||||
|
ZoneScoped;
|
||||||
pool.forEach([](RenderTarget& target) { target.applyPendingResize(); });
|
pool.forEach([](RenderTarget& target) { target.applyPendingResize(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#include <sophia/ui/panel_registry.hpp>
|
#include <sophia/ui/panel_registry.hpp>
|
||||||
|
#include <tracy/Tracy.hpp>
|
||||||
|
|
||||||
namespace sophia {
|
namespace sophia {
|
||||||
|
|
||||||
@@ -13,6 +14,7 @@ u32 PanelRegistry::visibleCount() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PanelRegistry::update(const FrameInfo& frameInfo) {
|
void PanelRegistry::update(const FrameInfo& frameInfo) {
|
||||||
|
ZoneScoped;
|
||||||
pool.forEach([&frameInfo](Panel& panel) {
|
pool.forEach([&frameInfo](Panel& panel) {
|
||||||
if (panel.isVisible()) {
|
if (panel.isVisible()) {
|
||||||
panel.draw(frameInfo);
|
panel.draw(frameInfo);
|
||||||
|
|||||||
Vendored
+6
@@ -45,6 +45,12 @@ add_library(stb_image STATIC
|
|||||||
)
|
)
|
||||||
target_include_directories(stb_image PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/stb_image)
|
target_include_directories(stb_image PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/stb_image)
|
||||||
|
|
||||||
|
# Tracy profiler client (static). Configure with -DTRACY_ENABLE=OFF to compile
|
||||||
|
# all profiling macros out.
|
||||||
|
option(TRACY_ENABLE "Enable Tracy profiling" ON)
|
||||||
|
option(TRACY_ON_DEMAND "Only collect data while the viewer is connected" ON)
|
||||||
|
add_subdirectory(tracy)
|
||||||
|
|
||||||
# 5. IMGUI (static)
|
# 5. IMGUI (static)
|
||||||
set(IMGUI_DIR ${CMAKE_CURRENT_SOURCE_DIR}/imgui)
|
set(IMGUI_DIR ${CMAKE_CURRENT_SOURCE_DIR}/imgui)
|
||||||
|
|
||||||
|
|||||||
+1
Submodule third_party/tracy added at 30997d5ca6
Reference in New Issue
Block a user