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