mirror of
				https://git.suyu.dev/suyu/suyu
				synced 2025-11-03 16:39:01 -06:00 
			
		
		
		
	Integrate the MicroProfile profiling library
This brings goodies such as a configurable user interface and multi-threaded timeline view.
This commit is contained in:
		@@ -4,6 +4,7 @@
 | 
			
		||||
 | 
			
		||||
#include <boost/range/algorithm/fill.hpp>
 | 
			
		||||
 | 
			
		||||
#include "common/microprofile.h"
 | 
			
		||||
#include "common/profiler.h"
 | 
			
		||||
 | 
			
		||||
#include "core/hle/service/gsp_gpu.h"
 | 
			
		||||
@@ -43,6 +44,8 @@ static const u32 expand_bits_to_bytes[] = {
 | 
			
		||||
    0xffff0000, 0xffff00ff, 0xffffff00, 0xffffffff
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
MICROPROFILE_DEFINE(GPU_Drawing, "GPU", "Drawing", MP_RGB(50, 50, 240));
 | 
			
		||||
 | 
			
		||||
static void WritePicaReg(u32 id, u32 value, u32 mask) {
 | 
			
		||||
    auto& regs = g_state.regs;
 | 
			
		||||
 | 
			
		||||
@@ -126,6 +129,7 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) {
 | 
			
		||||
        case PICA_REG_INDEX(trigger_draw_indexed):
 | 
			
		||||
        {
 | 
			
		||||
            Common::Profiling::ScopeTimer scope_timer(category_drawing);
 | 
			
		||||
            MICROPROFILE_SCOPE(GPU_Drawing);
 | 
			
		||||
 | 
			
		||||
#if PICA_LOG_TEV
 | 
			
		||||
            DebugUtils::DumpTevStageConfig(regs.GetTevStages());
 | 
			
		||||
 
 | 
			
		||||
@@ -7,6 +7,7 @@
 | 
			
		||||
#include "common/color.h"
 | 
			
		||||
#include "common/common_types.h"
 | 
			
		||||
#include "common/math_util.h"
 | 
			
		||||
#include "common/microprofile.h"
 | 
			
		||||
#include "common/profiler.h"
 | 
			
		||||
 | 
			
		||||
#include "core/hw/gpu.h"
 | 
			
		||||
@@ -267,6 +268,7 @@ static int SignedArea (const Math::Vec2<Fix12P4>& vtx1,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static Common::Profiling::TimingCategory rasterization_category("Rasterization");
 | 
			
		||||
MICROPROFILE_DEFINE(GPU_Rasterization, "GPU", "Rasterization", MP_RGB(50, 50, 240));
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Helper function for ProcessTriangle with the "reversed" flag to allow for implementing
 | 
			
		||||
@@ -279,6 +281,7 @@ static void ProcessTriangleInternal(const Shader::OutputVertex& v0,
 | 
			
		||||
{
 | 
			
		||||
    const auto& regs = g_state.regs;
 | 
			
		||||
    Common::Profiling::ScopeTimer timer(rasterization_category);
 | 
			
		||||
    MICROPROFILE_SCOPE(GPU_Rasterization);
 | 
			
		||||
 | 
			
		||||
    // vertex positions in rasterizer coordinates
 | 
			
		||||
    static auto FloatToFix = [](float24 flt) {
 | 
			
		||||
 
 | 
			
		||||
@@ -7,6 +7,7 @@
 | 
			
		||||
 | 
			
		||||
#include "common/color.h"
 | 
			
		||||
#include "common/math_util.h"
 | 
			
		||||
#include "common/microprofile.h"
 | 
			
		||||
#include "common/profiler.h"
 | 
			
		||||
 | 
			
		||||
#include "core/hw/gpu.h"
 | 
			
		||||
@@ -777,12 +778,16 @@ void RasterizerOpenGL::SyncDrawState() {
 | 
			
		||||
    state.Apply();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
MICROPROFILE_DEFINE(OpenGL_FramebufferReload, "OpenGL", "FB Reload", MP_RGB(70, 70, 200));
 | 
			
		||||
 | 
			
		||||
void RasterizerOpenGL::ReloadColorBuffer() {
 | 
			
		||||
    u8* color_buffer = Memory::GetPhysicalPointer(Pica::g_state.regs.framebuffer.GetColorBufferPhysicalAddress());
 | 
			
		||||
 | 
			
		||||
    if (color_buffer == nullptr)
 | 
			
		||||
        return;
 | 
			
		||||
 | 
			
		||||
    MICROPROFILE_SCOPE(OpenGL_FramebufferReload);
 | 
			
		||||
 | 
			
		||||
    u32 bytes_per_pixel = Pica::Regs::BytesPerColorPixel(fb_color_texture.format);
 | 
			
		||||
 | 
			
		||||
    std::unique_ptr<u8[]> temp_fb_color_buffer(new u8[fb_color_texture.width * fb_color_texture.height * bytes_per_pixel]);
 | 
			
		||||
@@ -822,6 +827,8 @@ void RasterizerOpenGL::ReloadDepthBuffer() {
 | 
			
		||||
    if (depth_buffer == nullptr)
 | 
			
		||||
        return;
 | 
			
		||||
 | 
			
		||||
    MICROPROFILE_SCOPE(OpenGL_FramebufferReload);
 | 
			
		||||
 | 
			
		||||
    u32 bytes_per_pixel = Pica::Regs::BytesPerDepthPixel(fb_depth_texture.format);
 | 
			
		||||
 | 
			
		||||
    // OpenGL needs 4 bpp alignment for D24
 | 
			
		||||
@@ -868,6 +875,7 @@ void RasterizerOpenGL::ReloadDepthBuffer() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
Common::Profiling::TimingCategory buffer_commit_category("Framebuffer Commit");
 | 
			
		||||
MICROPROFILE_DEFINE(OpenGL_FramebufferCommit, "OpenGL", "FB Commit", MP_RGB(70, 70, 200));
 | 
			
		||||
 | 
			
		||||
void RasterizerOpenGL::CommitColorBuffer() {
 | 
			
		||||
    if (last_fb_color_addr != 0) {
 | 
			
		||||
@@ -875,6 +883,7 @@ void RasterizerOpenGL::CommitColorBuffer() {
 | 
			
		||||
 | 
			
		||||
        if (color_buffer != nullptr) {
 | 
			
		||||
            Common::Profiling::ScopeTimer timer(buffer_commit_category);
 | 
			
		||||
            MICROPROFILE_SCOPE(OpenGL_FramebufferCommit);
 | 
			
		||||
 | 
			
		||||
            u32 bytes_per_pixel = Pica::Regs::BytesPerColorPixel(fb_color_texture.format);
 | 
			
		||||
 | 
			
		||||
@@ -911,6 +920,7 @@ void RasterizerOpenGL::CommitDepthBuffer() {
 | 
			
		||||
 | 
			
		||||
        if (depth_buffer != nullptr) {
 | 
			
		||||
            Common::Profiling::ScopeTimer timer(buffer_commit_category);
 | 
			
		||||
            MICROPROFILE_SCOPE(OpenGL_FramebufferCommit);
 | 
			
		||||
 | 
			
		||||
            u32 bytes_per_pixel = Pica::Regs::BytesPerDepthPixel(fb_depth_texture.format);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -4,6 +4,7 @@
 | 
			
		||||
 | 
			
		||||
#include "common/make_unique.h"
 | 
			
		||||
#include "common/math_util.h"
 | 
			
		||||
#include "common/microprofile.h"
 | 
			
		||||
#include "common/vector_math.h"
 | 
			
		||||
 | 
			
		||||
#include "core/memory.h"
 | 
			
		||||
@@ -16,6 +17,8 @@ RasterizerCacheOpenGL::~RasterizerCacheOpenGL() {
 | 
			
		||||
    FullFlush();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
MICROPROFILE_DEFINE(OpenGL_TextureUpload, "OpenGL", "Texture Upload", MP_RGB(128, 64, 192));
 | 
			
		||||
 | 
			
		||||
void RasterizerCacheOpenGL::LoadAndBindTexture(OpenGLState &state, unsigned texture_unit, const Pica::Regs::FullTextureConfig& config) {
 | 
			
		||||
    PAddr texture_addr = config.config.GetPhysicalAddress();
 | 
			
		||||
 | 
			
		||||
@@ -25,6 +28,8 @@ void RasterizerCacheOpenGL::LoadAndBindTexture(OpenGLState &state, unsigned text
 | 
			
		||||
        state.texture_units[texture_unit].texture_2d = cached_texture->second->texture.handle;
 | 
			
		||||
        state.Apply();
 | 
			
		||||
    } else {
 | 
			
		||||
        MICROPROFILE_SCOPE(OpenGL_TextureUpload);
 | 
			
		||||
 | 
			
		||||
        std::unique_ptr<CachedTexture> new_texture = Common::make_unique<CachedTexture>();
 | 
			
		||||
 | 
			
		||||
        new_texture->texture.Create();
 | 
			
		||||
 
 | 
			
		||||
@@ -9,6 +9,7 @@
 | 
			
		||||
 | 
			
		||||
#include "common/hash.h"
 | 
			
		||||
#include "common/make_unique.h"
 | 
			
		||||
#include "common/microprofile.h"
 | 
			
		||||
#include "common/profiler.h"
 | 
			
		||||
 | 
			
		||||
#include "video_core/debug_utils/debug_utils.h"
 | 
			
		||||
@@ -55,11 +56,13 @@ void Shutdown() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static Common::Profiling::TimingCategory shader_category("Vertex Shader");
 | 
			
		||||
MICROPROFILE_DEFINE(GPU_VertexShader, "GPU", "Vertex Shader", MP_RGB(50, 50, 240));
 | 
			
		||||
 | 
			
		||||
OutputVertex Run(UnitState<false>& state, const InputVertex& input, int num_attributes) {
 | 
			
		||||
    auto& config = g_state.regs.vs;
 | 
			
		||||
 | 
			
		||||
    Common::Profiling::ScopeTimer timer(shader_category);
 | 
			
		||||
    MICROPROFILE_SCOPE(GPU_VertexShader);
 | 
			
		||||
 | 
			
		||||
    state.program_counter = config.main_offset;
 | 
			
		||||
    state.debug.max_offset = 0;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user