From 4a3a40aa40a3067b607c879665675d44b726224a Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Sat, 4 Feb 2023 21:00:10 +0000 Subject: [PATCH] Add more perfetto tracepoints --- app/src/main/cpp/skyline/gpu/buffer_manager.cpp | 1 + app/src/main/cpp/skyline/gpu/buffer_manager.h | 2 ++ app/src/main/cpp/skyline/gpu/interconnect/fermi_2d.cpp | 3 +++ .../gpu/interconnect/kepler_compute/kepler_compute.cpp | 2 ++ .../cpp/skyline/gpu/interconnect/maxwell_3d/active_state.cpp | 1 + .../skyline/gpu/interconnect/maxwell_3d/constant_buffers.cpp | 2 ++ .../cpp/skyline/gpu/interconnect/maxwell_3d/maxwell_3d.cpp | 4 ++++ .../skyline/gpu/interconnect/maxwell_3d/pipeline_state.cpp | 2 ++ app/src/main/cpp/skyline/gpu/texture_manager.cpp | 3 +++ 9 files changed, 20 insertions(+) diff --git a/app/src/main/cpp/skyline/gpu/buffer_manager.cpp b/app/src/main/cpp/skyline/gpu/buffer_manager.cpp index edf6cc60..d5124065 100644 --- a/app/src/main/cpp/skyline/gpu/buffer_manager.cpp +++ b/app/src/main/cpp/skyline/gpu/buffer_manager.cpp @@ -53,6 +53,7 @@ namespace skyline::gpu { } BufferManager::LockedBuffer BufferManager::CoalesceBuffers(span range, const LockedBuffers &srcBuffers, ContextTag tag) { + TRACE_EVENT("gpu", "BufferManager::CoalesceBuffers"); std::shared_ptr newBufferCycle{}; for (auto &srcBuffer : srcBuffers) { // Since new direct buffers will share the underlying backing of source buffers we don't need to wait for the GPU if they're dirty, for non direct buffers we do though as otherwise we won't be able to migrate their contents to the new backing diff --git a/app/src/main/cpp/skyline/gpu/buffer_manager.h b/app/src/main/cpp/skyline/gpu/buffer_manager.h index bcab6bc9..c04108d8 100644 --- a/app/src/main/cpp/skyline/gpu/buffer_manager.h +++ b/app/src/main/cpp/skyline/gpu/buffer_manager.h @@ -3,6 +3,7 @@ #pragma once +#include #include #include #include @@ -99,6 +100,7 @@ namespace skyline::gpu { BufferView FindOrCreateImpl(GuestBuffer guestMapping, ContextTag tag, const std::function, ContextLock &&)> &attachBuffer); BufferView FindOrCreate(GuestBuffer guestMapping, ContextTag tag = {}, const std::function, ContextLock &&)> &attachBuffer = {}) { + TRACE_EVENT("gpu", "BufferManager::FindOrCreate"); auto lookupBuffer{bufferTable[guestMapping.begin().base()]}; if (lookupBuffer != nullptr) if (auto view{lookupBuffer->TryGetView(guestMapping)}; view) diff --git a/app/src/main/cpp/skyline/gpu/interconnect/fermi_2d.cpp b/app/src/main/cpp/skyline/gpu/interconnect/fermi_2d.cpp index ff846bd4..51c841eb 100644 --- a/app/src/main/cpp/skyline/gpu/interconnect/fermi_2d.cpp +++ b/app/src/main/cpp/skyline/gpu/interconnect/fermi_2d.cpp @@ -112,6 +112,8 @@ namespace skyline::gpu::interconnect { executor{channelCtx.executor} {} void Fermi2D::Blit(const Surface &srcSurface, const Surface &dstSurface, float srcRectX, float srcRectY, u32 dstRectWidth, u32 dstRectHeight, u32 dstRectX, u32 dstRectY, float duDx, float dvDy, SampleModeOrigin sampleOrigin, bool resolve, SampleModeFilter filter) { + TRACE_EVENT("gpu", "Fermi2D::Blit"); + // TODO: When we support MSAA perform a resolve operation rather than blit when the `resolve` flag is set. auto srcGuestTexture{GetGuestTexture(srcSurface)}; auto dstGuestTexture{GetGuestTexture(dstSurface)}; @@ -129,6 +131,7 @@ namespace skyline::gpu::interconnect { float centredSrcRectX{sampleOrigin == SampleModeOrigin::Corner ? srcRectX - 0.5f : srcRectX}; float centredSrcRectY{sampleOrigin == SampleModeOrigin::Corner ? srcRectY - 0.5f : srcRectY}; + executor.AddCheckpoint("Before blit"); gpu.helperShaders.blitHelperShader.Blit( gpu, { diff --git a/app/src/main/cpp/skyline/gpu/interconnect/kepler_compute/kepler_compute.cpp b/app/src/main/cpp/skyline/gpu/interconnect/kepler_compute/kepler_compute.cpp index 5fb41e14..ecf391bc 100644 --- a/app/src/main/cpp/skyline/gpu/interconnect/kepler_compute/kepler_compute.cpp +++ b/app/src/main/cpp/skyline/gpu/interconnect/kepler_compute/kepler_compute.cpp @@ -31,6 +31,8 @@ namespace skyline::gpu::interconnect::kepler_compute { if (ctx.gpu.traits.quirks.brokenComputeShaders) return; + TRACE_EVENT("gpu", "KeplerCompute::Dispatch"); + StateUpdateBuilder builder{*ctx.executor.allocator}; constantBuffers.Update(ctx, qmd); diff --git a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/active_state.cpp b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/active_state.cpp index f08c3997..cf54cc5f 100644 --- a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/active_state.cpp +++ b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/active_state.cpp @@ -435,6 +435,7 @@ namespace skyline::gpu::interconnect::maxwell3d { void ActiveState::Update(InterconnectContext &ctx, Textures &textures, ConstantBufferSet &constantBuffers, StateUpdateBuilder &builder, bool indexed, engine::DrawTopology topology, bool estimateIndexBufferSize, u32 drawFirstIndex, u32 drawElementCount, vk::PipelineStageFlags &srcStageMask, vk::PipelineStageFlags &dstStageMask) { + TRACE_EVENT("gpu", "ActiveState::Update"); if (topology != directState.inputAssembly.GetPrimitiveTopology()) { directState.inputAssembly.SetPrimitiveTopology(topology); pipeline.MarkDirty(false); diff --git a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/constant_buffers.cpp b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/constant_buffers.cpp index 0e0d6c39..ee51b379 100644 --- a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/constant_buffers.cpp +++ b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/constant_buffers.cpp @@ -40,6 +40,8 @@ namespace skyline::gpu::interconnect::maxwell3d { } void ConstantBuffers::Load(InterconnectContext &ctx, span data, u32 offset) { + TRACE_EVENT("gpu", "ConstantBuffers::Load"); + auto &view{*selectorState.UpdateGet(ctx, data.size_bytes()).view}; auto srcCpuBuf{data.cast()}; diff --git a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/maxwell_3d.cpp b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/maxwell_3d.cpp index 730604b3..3d14f6f9 100644 --- a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/maxwell_3d.cpp +++ b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/maxwell_3d.cpp @@ -132,6 +132,8 @@ namespace skyline::gpu::interconnect::maxwell3d { if (scissor.extent.width == 0 || scissor.extent.height == 0) return; + TRACE_EVENT("gpu", "Maxwell3D::Clear"); + auto needsAttachmentClearCmd{[&](auto &view) { return scissor.offset.x != 0 || scissor.offset.y != 0 || scissor.extent != vk::Extent2D{view->texture->dimensions} || @@ -215,6 +217,8 @@ namespace skyline::gpu::interconnect::maxwell3d { } void Maxwell3D::Draw(engine::DrawTopology topology, bool transformFeedbackEnable, bool indexed, u32 count, u32 first, u32 instanceCount, u32 vertexOffset, u32 firstInstance) { + TRACE_EVENT("gpu", "Draw", "indexed", indexed, "count", count, "instanceCount", instanceCount); + StateUpdateBuilder builder{*ctx.executor.allocator}; vk::PipelineStageFlags srcStageMask{}, dstStageMask{}; diff --git a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/pipeline_state.cpp b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/pipeline_state.cpp index 771f2e93..29de5904 100644 --- a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/pipeline_state.cpp +++ b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/pipeline_state.cpp @@ -385,6 +385,8 @@ namespace skyline::gpu::interconnect::maxwell3d { ctSelect{engine.ctSelect} {} void PipelineState::Flush(InterconnectContext &ctx, Textures &textures, ConstantBufferSet &constantBuffers, StateUpdateBuilder &builder) { + TRACE_EVENT("gpu", "PipelineState::Flush"); + packedState.dynamicStateActive = ctx.gpu.traits.supportsExtendedDynamicState; packedState.ctSelect = ctSelect; diff --git a/app/src/main/cpp/skyline/gpu/texture_manager.cpp b/app/src/main/cpp/skyline/gpu/texture_manager.cpp index d259533f..d2ec29a1 100644 --- a/app/src/main/cpp/skyline/gpu/texture_manager.cpp +++ b/app/src/main/cpp/skyline/gpu/texture_manager.cpp @@ -1,12 +1,15 @@ // SPDX-License-Identifier: MPL-2.0 // Copyright © 2021 Skyline Team and Contributors (https://github.com/skyline-emu/) +#include #include "texture_manager.h" namespace skyline::gpu { TextureManager::TextureManager(GPU &gpu) : gpu(gpu) {} std::shared_ptr TextureManager::FindOrCreate(const GuestTexture &guestTexture, ContextTag tag) { + TRACE_EVENT("gpu", "TextureManager::FindOrCreate"); + auto guestMapping{guestTexture.mappings.front()}; /*