tracy: guards for missing vk profiler context

This commit is contained in:
psucien 2024-06-11 22:57:37 +02:00
parent 955752a24b
commit 64569ff737
2 changed files with 18 additions and 8 deletions

View File

@ -272,8 +272,9 @@ void RendererVulkan::Present(Frame* frame) {
const vk::CommandBuffer cmdbuf = frame->cmdbuf; const vk::CommandBuffer cmdbuf = frame->cmdbuf;
cmdbuf.begin(begin_info); cmdbuf.begin(begin_info);
{ {
TracyVkZoneC(instance.GetProfilerContext(), cmdbuf, "Host frame", auto* profiler_ctx = instance.GetProfilerContext();
MarkersPallete::GpuMarkerColor); TracyVkNamedZoneC(profiler_ctx, renderer_gpu_zone, cmdbuf, "Host frame",
MarkersPallete::GpuMarkerColor, profiler_ctx != nullptr);
const vk::Extent2D extent = swapchain.GetExtent(); const vk::Extent2D extent = swapchain.GetExtent();
const std::array pre_barriers{ const std::array pre_barriers{
@ -339,8 +340,11 @@ void RendererVulkan::Present(Frame* frame) {
cmdbuf.pipelineBarrier(vk::PipelineStageFlagBits::eAllCommands, cmdbuf.pipelineBarrier(vk::PipelineStageFlagBits::eAllCommands,
vk::PipelineStageFlagBits::eAllCommands, vk::PipelineStageFlagBits::eAllCommands,
vk::DependencyFlagBits::eByRegion, {}, {}, post_barrier); vk::DependencyFlagBits::eByRegion, {}, {}, post_barrier);
if (profiler_ctx) {
TracyVkCollect(profiler_ctx, cmdbuf);
}
} }
TracyVkCollect(instance.GetProfilerContext(), cmdbuf);
cmdbuf.end(); cmdbuf.end();
static constexpr std::array<vk::PipelineStageFlags, 2> wait_stage_masks = { static constexpr std::array<vk::PipelineStageFlags, 2> wait_stage_masks = {

View File

@ -46,16 +46,22 @@ void Scheduler::AllocateWorkerCommandBuffers() {
current_cmdbuf = command_pool.Commit(); current_cmdbuf = command_pool.Commit();
current_cmdbuf.begin(begin_info); current_cmdbuf.begin(begin_info);
static const auto scope_loc = GPU_SCOPE_LOCATION("Guest Frame", MarkersPallete::GpuMarkerColor); auto* profiler_ctx = instance.GetProfilerContext();
new (profiler_scope) if (profiler_ctx) {
tracy::VkCtxScope{instance.GetProfilerContext(), &scope_loc, current_cmdbuf, true}; static const auto scope_loc =
GPU_SCOPE_LOCATION("Guest Frame", MarkersPallete::GpuMarkerColor);
new (profiler_scope) tracy::VkCtxScope{profiler_ctx, &scope_loc, current_cmdbuf, true};
}
} }
void Scheduler::SubmitExecution(vk::Semaphore signal_semaphore, vk::Semaphore wait_semaphore) { void Scheduler::SubmitExecution(vk::Semaphore signal_semaphore, vk::Semaphore wait_semaphore) {
const u64 signal_value = master_semaphore.NextTick(); const u64 signal_value = master_semaphore.NextTick();
profiler_scope->~VkCtxScope(); auto* profiler_ctx = instance.GetProfilerContext();
TracyVkCollect(instance.GetProfilerContext(), current_cmdbuf); if (profiler_ctx) {
profiler_scope->~VkCtxScope();
TracyVkCollect(profiler_ctx, current_cmdbuf);
}
std::scoped_lock lk{submit_mutex}; std::scoped_lock lk{submit_mutex};
master_semaphore.SubmitWork(current_cmdbuf, wait_semaphore, signal_semaphore, signal_value); master_semaphore.SubmitWork(current_cmdbuf, wait_semaphore, signal_semaphore, signal_value);