Skip to content
Open
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
176 commits
Select commit Hold shift + click to select a range
28c3662
init
w-czerski Feb 24, 2025
3b416e7
Add profiler configuration
w-czerski Feb 24, 2025
95ae140
rename fix
w-czerski Feb 24, 2025
aae4e6d
remove unused
w-czerski Feb 24, 2025
504f796
remove unused services
w-czerski Feb 24, 2025
3de9a4f
fix headers
w-czerski Feb 24, 2025
a795f7e
debug display on screen
w-czerski Feb 24, 2025
5da4f22
add siplay fps on screen | add refleciton of config
w-czerski Feb 24, 2025
691cef6
improvements
w-czerski Feb 24, 2025
794f8e4
clean up
w-czerski Feb 24, 2025
463d7b0
clang format
w-czerski Feb 24, 2025
1a6b537
fix game launcher ddebug display
w-czerski Feb 24, 2025
d6731b2
save with timestamp
w-czerski Feb 25, 2025
7e03adc
change fps color
w-czerski Feb 25, 2025
67e57ef
Add notification bus for created files
w-czerski Feb 25, 2025
f4109b2
add warning
w-czerski Feb 25, 2025
3c457a8
fix warning - use c_str
w-czerski Feb 25, 2025
f45ffcc
change name
w-czerski Feb 25, 2025
cb9579f
add info in tick
w-czerski Feb 25, 2025
f0f2ead
refactor
w-czerski Feb 25, 2025
f3aa038
fix calcuatlion of avergage frame
w-czerski Feb 25, 2025
50ce465
fix precision to near zero values
w-czerski Feb 25, 2025
b34b388
format
w-czerski Feb 25, 2025
7e6cd09
add more editor options | specify precision and occurrance size
w-czerski Feb 25, 2025
b2ad8f1
clang format
w-czerski Feb 25, 2025
a2d9d01
add cpu and gpu memory collect
w-czerski Feb 25, 2025
a9fa50f
clean up tick | clang format
w-czerski Feb 25, 2025
db92a49
make memory getter functions static
w-czerski Feb 25, 2025
51a18fb
use detailed memory flag
w-czerski Feb 25, 2025
6968a67
fix fps data struct reflection | fix system component, clean up, adju…
w-czerski Feb 27, 2025
76c2b6a
refactor
w-czerski Feb 27, 2025
7e3fdb2
refactor
w-czerski Feb 27, 2025
5aa41f2
refactor | remove redundant headers | remove rpi from cmake, use only…
w-czerski Feb 27, 2025
38f2e6a
rename to Fps | use const reference for notification bus
w-czerski Feb 27, 2025
a4b862f
move static functions to public
w-czerski Feb 27, 2025
6a60562
fix near zero editor reflection
w-czerski Feb 27, 2025
6caedf3
add request bus info | implement bus overrides
w-czerski Feb 27, 2025
632250f
fix activate / deactivate
w-czerski Feb 27, 2025
5230699
rename profiler data -> profiler config
w-czerski Feb 27, 2025
a1f031c
add fix config layout
w-czerski Feb 27, 2025
18444cc
add fix config layout
w-czerski Feb 27, 2025
e1e25a9
add is any save option enabled
w-czerski Feb 27, 2025
9e53459
add option to change save path
w-czerski Feb 27, 2025
2aa4a31
clang format
w-czerski Feb 27, 2025
3f34943
typo fix
w-czerski Feb 27, 2025
48173da
exit early when no save option enabled
w-czerski Feb 27, 2025
53f4144
mark disabled data to -1.0f | using 0.0f might be confusing
w-czerski Feb 28, 2025
0cd0d2c
fix near zero comparison
w-czerski Feb 28, 2025
790e65e
add option to disable instant profiling in editor
w-czerski Feb 28, 2025
63aab4f
fix profiling setup on tick and activate
w-czerski Feb 28, 2025
e6e5013
clang format
w-czerski Feb 28, 2025
efad6b9
apply code review | add path validation | code improvement
w-czerski Mar 3, 2025
d3c67c8
clang tidy & format
w-czerski Mar 3, 2025
e706b4b
valdiate path on activation
w-czerski Mar 3, 2025
8b6bf19
update reflect name
w-czerski Mar 3, 2025
2078121
fix file creation | timestamp
w-czerski Mar 3, 2025
2fcd35d
fix memory reserve
w-czerski Mar 3, 2025
fce0b1f
replace string with IO:PATH
w-czerski Mar 3, 2025
d21c05f
remove redundant code
w-czerski Mar 3, 2025
9a5543c
change string path to AZ:IO:PATH
w-czerski Mar 3, 2025
59ffb83
use deque instead of vector
w-czerski Mar 3, 2025
9180fd9
reflect missing variable
w-czerski Mar 3, 2025
543a644
add info to gem.json
w-czerski Mar 4, 2025
73251a1
init readme
w-czerski Mar 4, 2025
21c6010
add context to readme
w-czerski Mar 4, 2025
b4bcbdb
add extra notification buses for stop/start/reset
w-czerski Mar 4, 2025
5f4e612
add print reset info
w-czerski Mar 4, 2025
b47751b
restore version bump
w-czerski Mar 4, 2025
4032525
clear log entires fix
w-czerski Mar 4, 2025
83fe314
fix comments for deque
w-czerski Mar 4, 2025
0c4440e
init editor variables
w-czerski Mar 4, 2025
106ebad
update comment variable names
w-czerski Mar 4, 2025
e39c70d
remove string format | use char vector | fix buffer allocation
w-czerski Mar 4, 2025
0fecc4c
remove redundant comments
w-czerski Mar 4, 2025
dc7a8a0
use Basic report flag | save 5.0ms
w-czerski Mar 4, 2025
4619a24
remove comment
w-czerski Mar 4, 2025
cf84709
remove redundant code
w-czerski Mar 4, 2025
aac47a9
clean up
w-czerski Mar 4, 2025
db6c49b
add biref summary for profiler bus
w-czerski Mar 4, 2025
cc6f38e
add to log buffer reserved memory data
w-czerski Mar 4, 2025
4d8ca57
change sizte_to -> AZStd::size_t
w-czerski Mar 4, 2025
f033838
fix layout | move buffer size to constexpr outside scope
w-czerski Mar 4, 2025
26eadbb
fix table in readme | imrpove readability
w-czerski Mar 4, 2025
4f4146d
fix readme table
w-czerski Mar 4, 2025
64aca44
restore affected files by clang format
w-czerski Mar 5, 2025
12dc522
use max buffer line size for memory reserve
w-czerski Mar 5, 2025
6c58aa3
remove if else | improve readability
w-czerski Mar 5, 2025
1832ce7
remove profile flag
w-czerski Mar 5, 2025
8724852
add warning print for stop/reset
w-czerski Mar 5, 2025
4262502
queue start profile on activation | add aditional bool flag
w-czerski Mar 5, 2025
9912fca
explanation why use minFps = FloatMax
w-czerski Mar 5, 2025
01992e5
clean up | remove profiling flag
w-czerski Mar 5, 2025
702baf7
refactor layout of config
w-czerski Mar 5, 2025
57911e9
rename config file
w-czerski Mar 5, 2025
567d1b1
move to config structs to namespace Config
w-czerski Mar 5, 2025
93bb809
rename config | add multiple config strutcs | add type ids
w-czerski Mar 5, 2025
4c4537a
fix mask bit shifts
w-czerski Mar 5, 2025
5b9928b
extra option
w-czerski Mar 5, 2025
b18e30b
rename
w-czerski Mar 5, 2025
3d3e88e
create reflect for RecrodSettings
w-czerski Mar 5, 2025
c776279
add other config refelcetions
w-czerski Mar 5, 2025
584c283
add new config to system component
w-czerski Mar 5, 2025
ef6993a
remove enum int cast
w-czerski Mar 5, 2025
c983655
replace old config | build success
w-czerski Mar 6, 2025
46cff25
change version to 0 | use static cast
w-czerski Mar 6, 2025
7ef0556
remove reflect duplicates
w-czerski Mar 6, 2025
502c8bb
fix tick comparison
w-czerski Mar 6, 2025
eb527dc
remove bool from enum
w-czerski Mar 6, 2025
fc4f2d9
add EMA calculation | add smoothing factor
w-czerski Mar 6, 2025
158f1f7
refresh ui
w-czerski Mar 6, 2025
eeacd81
enable print when debug selected
w-czerski Mar 6, 2025
543c3d8
reflect enum
w-czerski Mar 6, 2025
79e231b
remove bool toogles | using enum values
w-czerski Mar 6, 2025
f809190
fix mask comparison
w-czerski Mar 6, 2025
1caa08a
typo fix
w-czerski Mar 6, 2025
23fba4e
fix save data on exit
w-czerski Mar 6, 2025
9be7ec0
fix prfoile start
w-czerski Mar 6, 2025
e115b8d
deactivate fix
w-czerski Mar 6, 2025
9f4a386
simplyfy frame count
w-czerski Mar 6, 2025
445ba4b
remove redundant if statement4
w-czerski Mar 6, 2025
3a1df1d
apply seconds to timestamp
w-czerski Mar 6, 2025
9e70d78
fix comment
w-czerski Mar 6, 2025
f3dd0e9
fix file save on deactivation
w-czerski Mar 6, 2025
02eea87
remove enum serialization
w-czerski Mar 7, 2025
269ddc4
Add Config reflection to System Component
w-czerski Mar 11, 2025
36296d6
create config dir | move config | fix config reflect
w-czerski Mar 11, 2025
8b0a573
simplify if check
w-czerski Mar 11, 2025
bb3fd64
add final to system component
w-czerski Mar 11, 2025
83e92db
swap IO Path to String | add button to add path
w-czerski Mar 17, 2025
5f5f80e
fix headers
w-czerski Mar 17, 2025
8f6c577
rename function
w-czerski Mar 17, 2025
eb1bfc5
clang format
w-czerski Mar 17, 2025
9caff34
remove system in name suffix
w-czerski Mar 17, 2025
e82b2f0
use path.c_str
w-czerski Mar 17, 2025
00ebce0
rename System Component -> Component | remove unused
w-czerski Mar 17, 2025
75f7a23
rename type ids | fix uuid duplicate
w-czerski Mar 17, 2025
988f8e2
resolve serialize duplicates
w-czerski Mar 17, 2025
7947cf6
fix path selector and validation
w-czerski Mar 17, 2025
448e31c
rename
w-czerski Mar 17, 2025
48e57d3
add lua and script canvas support
w-czerski Mar 17, 2025
b54c663
fix path swap to string | operate on IO::Path
w-czerski Mar 17, 2025
0cb786e
option to keep hisotry for better precision
w-czerski Mar 17, 2025
c6dcfe8
fix keep history setting | fix reflect description
w-czerski Mar 17, 2025
329ad2f
simplify logic | clang format
w-czerski Mar 17, 2025
21cb54f
fix game launcher | pass settings from editor
w-czerski Mar 17, 2025
882dd9f
fix formatting | make fields protected
w-czerski Mar 17, 2025
041b8db
add button description
w-czerski Mar 17, 2025
e4c7513
add better description
w-czerski Mar 17, 2025
fb9e926
refactor
w-czerski Mar 17, 2025
c038df1
fix config reflect
w-czerski Mar 17, 2025
c32faf8
add debug visiblity on enabled button
w-czerski Mar 17, 2025
0017cf8
readme update
w-czerski Mar 18, 2025
77ca9e1
readme table update
w-czerski Mar 18, 2025
cddb207
update images resolution
w-czerski Mar 18, 2025
b46a517
add behaviour context for configs | update profile bus
w-czerski Mar 18, 2025
c3074cf
readme update | fix behaviour reflect
w-czerski Mar 18, 2025
2fb02a7
fix formatting
w-czerski Apr 3, 2025
70db269
fix formatting cmake
w-czerski Apr 3, 2025
35f6a20
add missing new line
w-czerski Apr 3, 2025
aa875b1
ediotr context for component
w-czerski Apr 3, 2025
ab86e28
remove editor source files from cmake
w-czerski Apr 3, 2025
c1abc2d
remove ediotr component
w-czerski Apr 3, 2025
c970d6d
remove editor component depencencies
w-czerski Apr 3, 2025
8d2d912
remove editor component type id
w-czerski Apr 3, 2025
15b1771
change path string into AZ::IO::Path
w-czerski Apr 3, 2025
ca30500
remove unecessary checks for config refelections
w-czerski Apr 3, 2025
e164d0e
make config private | refactor
w-czerski Apr 3, 2025
a8b8a45
remove const from bus notifies - blocking file modifications
w-czerski Apr 3, 2025
3ba5c4b
fixed fps counter display positioning
w-czerski Apr 3, 2025
99c5e6f
fix readme conflicts
w-czerski Apr 3, 2025
0ebc0a1
readme update
w-czerski Apr 3, 2025
1be2924
Merge branch 'main' into wc/fps_profiler
w-czerski Apr 3, 2025
6c209c7
remove pure vritual from notify bus
w-czerski Apr 4, 2025
427dcd8
add GetRequiredComponentType list override
w-czerski Apr 4, 2025
55879d4
mark path seleciton as read only
w-czerski Apr 4, 2025
6a382ab
update path validation function
w-czerski Apr 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 23 additions & 37 deletions Gems/FPSProfiler/Code/Include/FPSProfiler/FPSProfilerBus.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ namespace FPSProfiler
* @warning This function is NOT runtime safe. Use @ref SafeChangeSavePath instead.
* @param newSavePath The new file path where profiling data should be saved.
*/
virtual void ChangeSavePath(const AZStd::string& newSavePath) = 0;
virtual void ChangeSavePath(const AZ::IO::Path& newSavePath) = 0;

/**
* @brief Safely changes the save path during runtime.
* This method stops profiling, saves the current data, and then updates the path.
* @param newSavePath The new file path where profiling data should be saved.
*/
virtual void SafeChangeSavePath(const AZStd::string& newSavePath) = 0;
virtual void SafeChangeSavePath(const AZ::IO::Path& newSavePath) = 0;

/**
* @brief Retrieves the minimum recorded FPS during the profiling session.
Expand Down Expand Up @@ -107,7 +107,7 @@ namespace FPSProfiler
* @param newSavePath The csv file path where the log should be saved.
* @param useSafeChangePath If true, the function will use @ref SafeChangeSavePath to ensure runtime safety.
*/
virtual void SaveLogToFileWithNewPath(const AZStd::string& newSavePath, bool useSafeChangePath) = 0;
virtual void SaveLogToFileWithNewPath(const AZ::IO::Path& newSavePath, bool useSafeChangePath) = 0;

/**
* @brief Enables or disables FPS display on-screen.
Expand Down Expand Up @@ -140,25 +140,19 @@ namespace FPSProfiler
* @brief Called when a new file is created.
* @param config File Save Settings Configuration.
*/
virtual void OnFileCreated(const Configs::FileSaveSettings& config)
{
}
virtual void OnFileCreated(Configs::FileSaveSettings& config) = 0;

/**
* @brief Called when an existing file is updated.
* @param config File Save Settings Configuration.
*/
virtual void OnFileUpdate(const Configs::FileSaveSettings& config)
{
}
virtual void OnFileUpdate(Configs::FileSaveSettings& config) = 0;

/**
* @brief Called when a file is successfully saved.
* @param config File Save Settings Configuration.
*/
virtual void OnFileSaved(const Configs::FileSaveSettings& config)
{
}
virtual void OnFileSaved(Configs::FileSaveSettings& config) = 0;

/**
* @brief Called when the profiling process starts.
Expand All @@ -167,20 +161,14 @@ namespace FPSProfiler
* @param debugConfig The configuration settings used for the debugging.
*/
virtual void OnProfileStart(
const Configs::RecordSettings& recordConfig,
const Configs::PrecisionSettings& precisionConfig,
const Configs::DebugSettings& debugConfig)
{
}
Configs::RecordSettings& recordConfig, Configs::PrecisionSettings& precisionConfig, Configs::DebugSettings& debugConfig) = 0;

/**
* @brief Called when the profiling data is reset.
* @param recordConfig The configuration settings used for the record session.
* @param precisionConfig The configuration settings used for the precision.
*/
virtual void OnProfileReset(const Configs::RecordSettings& recordConfig, const Configs::PrecisionSettings& precisionConfig)
{
}
virtual void OnProfileReset(Configs::RecordSettings& recordConfig, Configs::PrecisionSettings& precisionConfig) = 0;

/**
* @brief Called when the profiling process stops.
Expand All @@ -190,12 +178,10 @@ namespace FPSProfiler
* @param debugConfig The configuration settings used for the debugging.
*/
virtual void OnProfileStop(
const Configs::FileSaveSettings& saveConfig,
const Configs::RecordSettings& recordConfig,
const Configs::PrecisionSettings& precisionConfig,
const Configs::DebugSettings& debugConfig)
{
}
Configs::FileSaveSettings& saveConfig,
Configs::RecordSettings& recordConfig,
Configs::PrecisionSettings& precisionConfig,
Configs::DebugSettings& debugConfig) = 0;
};

class FPSProfilerNotificationBusTraits : public AZ::EBusTraits
Expand Down Expand Up @@ -226,39 +212,39 @@ namespace FPSProfiler
OnProfileReset,
OnProfileStop);

void OnFileCreated(const Configs::FileSaveSettings& config) override
void OnFileCreated(Configs::FileSaveSettings& config) override
{
Call(FN_OnFileCreated, config);
}

void OnFileUpdate(const Configs::FileSaveSettings& config) override
void OnFileUpdate(Configs::FileSaveSettings& config) override
{
Call(FN_OnFileUpdate, config);
}

void OnFileSaved(const Configs::FileSaveSettings& config) override
void OnFileSaved(Configs::FileSaveSettings& config) override
{
Call(FN_OnFileSaved, config);
}

void OnProfileStart(
const Configs::RecordSettings& recordConfig,
const Configs::PrecisionSettings& precisionConfig,
const Configs::DebugSettings& debugConfig) override
Configs::RecordSettings& recordConfig,
Configs::PrecisionSettings& precisionConfig,
Configs::DebugSettings& debugConfig) override
{
Call(FN_OnProfileStart, recordConfig, precisionConfig, debugConfig);
}

void OnProfileReset(const Configs::RecordSettings& recordConfig, const Configs::PrecisionSettings& precisionConfig) override
void OnProfileReset(Configs::RecordSettings& recordConfig, Configs::PrecisionSettings& precisionConfig) override
{
Call(FN_OnProfileReset, recordConfig, precisionConfig);
}

void OnProfileStop(
const Configs::FileSaveSettings& saveConfig,
const Configs::RecordSettings& recordConfig,
const Configs::PrecisionSettings& precisionConfig,
const Configs::DebugSettings& debugConfig) override
Configs::FileSaveSettings& saveConfig,
Configs::RecordSettings& recordConfig,
Configs::PrecisionSettings& precisionConfig,
Configs::DebugSettings& debugConfig) override
{
Call(FN_OnProfileStop, saveConfig, recordConfig, precisionConfig, debugConfig);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ namespace FPSProfiler
{
// System Component TypeIds
inline constexpr const char* FPSProfilerComponentTypeId = "{B11CE88E-E1C5-404F-83D2-0D3850445A13}";
inline constexpr const char* FPSProfilerEditorComponentTypeId = "{F4308920-CD0B-4A2E-91DE-2EC1E970F97A}";

// Configs TypeIds
inline constexpr const char* FPSProfilerConfigFileTypeId = "{68627A89-9426-4640-B460-63E6AA42CFBC}";
Expand Down
48 changes: 30 additions & 18 deletions Gems/FPSProfiler/Code/Source/Clients/FPSProfilerComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <Atom/RHI/MemoryStatisticsBuilder.h>
#include <Atom/RHI/RHISystemInterface.h>
#include <AzCore/IO/FileIO.h>
#include <AzCore/Serialization/EditContext.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/std/numeric.h>

Expand All @@ -24,6 +25,20 @@ namespace FPSProfiler
->Field("m_configRecord", &FPSProfilerComponent::m_configRecord)
->Field("m_configPrecision", &FPSProfilerComponent::m_configPrecision)
->Field("m_configDebug", &FPSProfilerComponent::m_configDebug);

if (AZ::EditContext* editContext = serializeContext->GetEditContext())
{
editContext->Class<FPSProfilerComponent>("FPS Profiler", "Tracks FPS, GPU and CPU performance and saves it into .csv")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::Category, "Performance")
->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC_CE("Level"))
->Attribute(AZ::Edit::Attributes::AutoExpand, true)

->DataElement(AZ::Edit::UIHandlers::Default, &FPSProfilerComponent::m_configFile)
->DataElement(AZ::Edit::UIHandlers::Default, &FPSProfilerComponent::m_configRecord)
->DataElement(AZ::Edit::UIHandlers::Default, &FPSProfilerComponent::m_configPrecision)
->DataElement(AZ::Edit::UIHandlers::Default, &FPSProfilerComponent::m_configDebug);
}
}

// EBus Reflect for Lua and Script Canvas
Expand Down Expand Up @@ -309,7 +324,7 @@ namespace FPSProfiler
return m_configRecord.m_RecordStats != Configs::RecordStatistics::None;
}

void FPSProfilerComponent::ChangeSavePath(const AZStd::string& newSavePath)
void FPSProfilerComponent::ChangeSavePath(const AZ::IO::Path& newSavePath)
{
if (!IsPathValid(newSavePath))
{
Expand All @@ -320,7 +335,7 @@ namespace FPSProfiler
AZ_Warning("FPS Profiler", !m_configDebug.m_PrintDebugInfo && !m_isProfiling, "Path changed during activated profiling.");
}

void FPSProfilerComponent::SafeChangeSavePath(const AZStd::string& newSavePath)
void FPSProfilerComponent::SafeChangeSavePath(const AZ::IO::Path& newSavePath)
{
// If profiling is enabled, save current opened file and stop profiling.
StopProfiling();
Expand Down Expand Up @@ -378,7 +393,7 @@ namespace FPSProfiler
WriteDataToFile();
}

void FPSProfilerComponent::SaveLogToFileWithNewPath(const AZStd::string& newSavePath, bool useSafeChangePath)
void FPSProfilerComponent::SaveLogToFileWithNewPath(const AZ::IO::Path& newSavePath, bool useSafeChangePath)
{
if (useSafeChangePath)
{
Expand Down Expand Up @@ -470,10 +485,9 @@ namespace FPSProfiler
char timestamp[20];
strftime(timestamp, sizeof(timestamp), "%Y%m%d_%H%M%S", &timeInfo);

AZ::IO::Path logFilePath(m_configFile.m_OutputFilename);
logFilePath.ReplaceFilename((logFilePath.Stem().String() + "_" + timestamp + logFilePath.Extension().String()).data());

m_configFile.m_OutputFilename = logFilePath.c_str();
m_configFile.m_OutputFilename.ReplaceFilename(
(m_configFile.m_OutputFilename.Stem().String() + "_" + timestamp + m_configFile.m_OutputFilename.Extension().String())
.data());
}

// Write profiling headers to file
Expand Down Expand Up @@ -516,19 +530,17 @@ namespace FPSProfiler
return static_cast<float>(bytes) / (1024.0f * 1024.0f);
}

bool FPSProfilerComponent::IsPathValid(const AZStd::string& path) const
bool FPSProfilerComponent::IsPathValid(const AZ::IO::Path& path) const
{
AZ::IO::FileIOBase* fileIO = AZ::IO::FileIOBase::GetInstance();
AZ::IO::Path pathToValidate(path.c_str());

if (pathToValidate.empty() || !pathToValidate.HasFilename() || !pathToValidate.HasExtension() || !fileIO ||
!fileIO->ResolvePath(pathToValidate))
if (path.empty() || !path.HasFilename() || !path.HasExtension() || !fileIO || !fileIO->ResolvePath(path))
{
const char* reason = pathToValidate.empty() ? "Path cannot be empty."
: !pathToValidate.HasFilename() ? "Path must have a file at the end."
: !pathToValidate.HasExtension() ? "Path must have a *.csv extension."
: !fileIO ? "Could not get a FileIO object. Try again."
: "Path is not registered or recognizable by O3DE FileIO System.";
const char* reason = path.empty() ? "Path cannot be empty."
: !path.HasFilename() ? "Path must have a file at the end."
: !path.HasExtension() ? "Path must have a *.csv extension."
: !fileIO ? "Could not get a FileIO object. Try again."
: "Path is not registered or recognizable by O3DE FileIO System.";

AZ_Warning("FPSProfiler::IsPathValid", !m_configDebug.m_PrintDebugInfo, "%s", reason);
return false;
Expand All @@ -551,7 +563,7 @@ namespace FPSProfiler
debugDisplay->SetColor(AZ::Colors::Red);
debugDisplay->SetAlpha(1.0f);

AZStd::string debugText = AZStd::string::format("Profiler | FPS: %.2f", m_currentFps);
debugDisplay->Draw2dTextLabel(10, 10, 1.0f, debugText.c_str(), true);
AZStd::string debugText = AZStd::string::format("FPS: %.2f", m_currentFps);
debugDisplay->Draw2dTextLabel(100, 50, 1.0f, debugText.c_str(), true);
}
} // namespace FPSProfiler
33 changes: 16 additions & 17 deletions Gems/FPSProfiler/Code/Source/Clients/FPSProfilerComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,26 +45,37 @@ namespace FPSProfiler
void ResetProfilingData() override;
[[nodiscard]] bool IsProfiling() const override;
[[nodiscard]] bool IsAnySaveOptionEnabled() const override;
void ChangeSavePath(const AZStd::string& newSavePath) override;
void SafeChangeSavePath(const AZStd::string& newSavePath) override;
void ChangeSavePath(const AZ::IO::Path& newSavePath) override;
void SafeChangeSavePath(const AZ::IO::Path& newSavePath) override;
[[nodiscard]] float GetMinFps() const override;
[[nodiscard]] float GetMaxFps() const override;
[[nodiscard]] float GetAvgFps() const override;
[[nodiscard]] float GetCurrentFps() const override;
[[nodiscard]] AZStd::pair<AZStd::size_t, AZStd::size_t> GetCpuMemoryUsed() const override;
[[nodiscard]] AZStd::pair<AZStd::size_t, AZStd::size_t> GetGpuMemoryUsed() const override;
void SaveLogToFile() override;
void SaveLogToFileWithNewPath(const AZStd::string& newSavePath, bool useSafeChangePath) override;
void SaveLogToFileWithNewPath(const AZ::IO::Path& newSavePath, bool useSafeChangePath) override;
void ShowFpsOnScreen(bool enable) override;

public:
private:
// File Operations
void CreateLogFile();
void WriteDataToFile();

// Utility Functions
void CalculateFpsData(const float& deltaTime);
static float BytesToMB(AZStd::size_t bytes);
[[nodiscard]] bool IsPathValid(const AZ::IO::Path& path) const;

// Debug Display
void ShowFps() const;

// Profiler Configurations
Configs::FileSaveSettings m_configFile; //!< Stores editor settings for the profiler
Configs::RecordSettings m_configRecord; //!< Stores editor settings for the profiler
Configs::PrecisionSettings m_configPrecision; //!< Stores editor settings for the profiler
Configs::DebugSettings m_configDebug; //!< Stores editor settings for the profiler

private:
// FPS Tracking Data
bool m_isProfiling = false; //!< Flag to indicate if profiling is active
float m_minFps = 0.0f; //!< Lowest FPS value recorded
Expand All @@ -80,17 +91,5 @@ namespace FPSProfiler
AZStd::vector<char> m_logBuffer; //!< Buffer for log entries, cleared periodically if auto save enabled.
static constexpr AZStd::size_t MAX_LOG_BUFFER_SIZE = 1024 * 128; //!< Max log buffer size
static constexpr AZStd::size_t MAX_LOG_BUFFER_LINE_SIZE = 128; //!< Max length per log line

// File Operations
void CreateLogFile();
void WriteDataToFile();

// Utility Functions
void CalculateFpsData(const float& deltaTime);
static float BytesToMB(AZStd::size_t bytes);
[[nodiscard]] bool IsPathValid(const AZStd::string& path) const;

// Debug Display
void ShowFps() const;
};
} // namespace FPSProfiler
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ namespace FPSProfiler::Configs
{
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
{
if (serializeContext->FindClassData(azrtti_typeid<FileSaveSettings>())) // Prevent duplicate registration
{
return;
}

serializeContext->Class<FileSaveSettings>()
->Version(0)
->Field("m_OutputFilename", &FileSaveSettings::m_OutputFilename)
Expand Down Expand Up @@ -86,11 +81,6 @@ namespace FPSProfiler::Configs
{
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
{
if (serializeContext->FindClassData(azrtti_typeid<RecordSettings>())) // Prevent duplicate registration
{
return;
}

serializeContext->Class<RecordSettings>()
->Version(0)
->Field("m_recordType", &RecordSettings::m_recordType)
Expand Down Expand Up @@ -152,11 +142,6 @@ namespace FPSProfiler::Configs

if (auto behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
{
if (behaviorContext->m_classes.contains("RecordSettings"))
{
return;
}

behaviorContext->Class<RecordSettings>("RecordSettings")
->Attribute(AZ::Script::Attributes::Category, "FPSProfiler")
->Constructor<>()
Expand All @@ -171,11 +156,6 @@ namespace FPSProfiler::Configs
{
if (auto* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
{
if (serializeContext->FindClassData(azrtti_typeid<PrecisionSettings>())) // Prevent duplicate registration
{
return;
}

serializeContext->Class<PrecisionSettings>()
->Version(0)
->Field("m_NearZeroPrecision", &PrecisionSettings::m_NearZeroPrecision)
Expand Down Expand Up @@ -249,11 +229,6 @@ namespace FPSProfiler::Configs
{
if (auto* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
{
if (serializeContext->FindClassData(azrtti_typeid<DebugSettings>())) // Prevent duplicate registration
{
return;
}

serializeContext->Class<DebugSettings>()
->Version(0)
->Field("m_PrintDebugInfo", &DebugSettings::m_PrintDebugInfo)
Expand Down Expand Up @@ -301,4 +276,4 @@ namespace FPSProfiler::Configs
->Property("m_Color", BehaviorValueProperty(&DebugSettings::m_Color));
}
}
} // namespace FPSProfiler::Configs
} // namespace FPSProfiler::Configs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace FPSProfiler::Configs
AZ_TYPE_INFO(FileSaveSettings, FPSProfilerConfigFileTypeId);
static void Reflect(AZ::ReflectContext* context);

AZStd::string m_OutputFilename = "@user@/fps_log.csv";
AZ::IO::Path m_OutputFilename = "@user@/fps_log.csv";
bool m_AutoSave = true;
int m_AutoSaveAtFrame = 100;
bool m_SaveWithTimestamp = true;
Expand Down
Loading