Add various profiler events for more insights
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include "Engine/Core/Log.h"
|
||||
#include "Engine/Content/Upgraders/AudioClipUpgrader.h"
|
||||
#include "Engine/Content/Factories/BinaryAssetFactory.h"
|
||||
#include "Engine/Profiler/ProfilerCPU.h"
|
||||
#include "Engine/Scripting/ManagedCLR/MUtils.h"
|
||||
#include "Engine/Streaming/StreamingGroup.h"
|
||||
#include "Engine/Serialization/MemoryReadStream.h"
|
||||
@@ -19,10 +20,15 @@ REGISTER_BINARY_ASSET_WITH_UPGRADER(AudioClip, "FlaxEngine.AudioClip", AudioClip
|
||||
|
||||
bool AudioClip::StreamingTask::Run()
|
||||
{
|
||||
PROFILE_CPU_NAMED("AudioStreaming");
|
||||
PROFILE_MEM(Audio);
|
||||
AssetReference<AudioClip> ref = _asset.Get();
|
||||
if (ref == nullptr || AudioBackend::Instance == nullptr)
|
||||
return true;
|
||||
#if TRACY_ENABLE
|
||||
const StringView name(ref->GetPath());
|
||||
ZoneName(*name, name.Length());
|
||||
#endif
|
||||
ScopeLock lock(ref->Locker);
|
||||
const auto& queue = ref->StreamingQueue;
|
||||
if (queue.Count() == 0)
|
||||
@@ -421,6 +427,8 @@ bool AudioClip::WriteBuffer(int32 chunkIndex)
|
||||
// Ensure audio backend exists
|
||||
if (AudioBackend::Instance == nullptr)
|
||||
return true;
|
||||
PROFILE_CPU();
|
||||
PROFILE_MEM(Audio);
|
||||
|
||||
const auto chunk = GetChunk(chunkIndex);
|
||||
if (chunk == nullptr || chunk->IsMissing())
|
||||
@@ -432,6 +440,7 @@ bool AudioClip::WriteBuffer(int32 chunkIndex)
|
||||
Array<byte> tmp1, tmp2;
|
||||
AudioDataInfo info = AudioHeader.Info;
|
||||
const uint32 bytesPerSample = info.BitDepth / 8;
|
||||
ZoneValue(chunk->Size() / 1024); // Audio data size (in kB)
|
||||
|
||||
// Get raw data or decompress it
|
||||
switch (Format())
|
||||
@@ -439,6 +448,7 @@ bool AudioClip::WriteBuffer(int32 chunkIndex)
|
||||
case AudioFormat::Vorbis:
|
||||
{
|
||||
#if COMPILE_WITH_OGG_VORBIS
|
||||
PROFILE_CPU_NAMED("OggVorbisDecode");
|
||||
OggVorbisDecoder decoder;
|
||||
MemoryReadStream stream(chunk->Get(), chunk->Size());
|
||||
AudioDataInfo tmpInfo;
|
||||
|
||||
@@ -535,7 +535,8 @@ void MCore::GC::Collect(int32 generation)
|
||||
|
||||
void MCore::GC::Collect(int32 generation, MGCCollectionMode collectionMode, bool blocking, bool compacting)
|
||||
{
|
||||
PROFILE_CPU();
|
||||
PROFILE_CPU_NAMED("GC Collect");
|
||||
ZoneColor(0xe3c349);
|
||||
static void* GCCollectPtr = GetStaticMethodPointer(TEXT("GCCollect"));
|
||||
CallStaticMethod<void, int, int, bool, bool>(GCCollectPtr, generation, (int)collectionMode, blocking, compacting);
|
||||
}
|
||||
@@ -554,7 +555,8 @@ void MCore::GC::MemoryInfo(int64& totalCommitted, int64& heapSize)
|
||||
|
||||
void MCore::GC::WaitForPendingFinalizers()
|
||||
{
|
||||
PROFILE_CPU();
|
||||
PROFILE_CPU_NAMED("GC WaitForPendingFinalizers");
|
||||
ZoneColor(TracyWaitZoneColor);
|
||||
static void* GCWaitForPendingFinalizersPtr = GetStaticMethodPointer(TEXT("GCWaitForPendingFinalizers"));
|
||||
CallStaticMethod<void>(GCWaitForPendingFinalizersPtr);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "Engine/Core/Core.h"
|
||||
#include "Engine/Core/Math/Math.h"
|
||||
#include "Engine/Core/Memory/Allocation.h"
|
||||
#include "Engine/Profiler/ProfilerCPU.h"
|
||||
#if USE_EDITOR
|
||||
#include "Engine/Serialization/Serialization.h"
|
||||
#include "Engine/Scripting/Enums.h"
|
||||
@@ -181,6 +182,7 @@ void Convert32To24Bits(const int32* input, uint8* output, uint32 numSamples)
|
||||
|
||||
void AudioTool::ConvertToMono(const byte* input, byte* output, uint32 bitDepth, uint32 numSamples, uint32 numChannels)
|
||||
{
|
||||
PROFILE_CPU();
|
||||
switch (bitDepth)
|
||||
{
|
||||
case 8:
|
||||
@@ -203,6 +205,7 @@ void AudioTool::ConvertToMono(const byte* input, byte* output, uint32 bitDepth,
|
||||
|
||||
void AudioTool::ConvertBitDepth(const byte* input, uint32 inBitDepth, byte* output, uint32 outBitDepth, uint32 numSamples)
|
||||
{
|
||||
PROFILE_CPU();
|
||||
int32* srcBuffer = nullptr;
|
||||
|
||||
const bool needTempBuffer = inBitDepth != 32;
|
||||
@@ -262,6 +265,7 @@ void AudioTool::ConvertBitDepth(const byte* input, uint32 inBitDepth, byte* outp
|
||||
|
||||
void AudioTool::ConvertToFloat(const byte* input, uint32 inBitDepth, float* output, uint32 numSamples)
|
||||
{
|
||||
PROFILE_CPU();
|
||||
if (inBitDepth == 8)
|
||||
{
|
||||
for (uint32 i = 0; i < numSamples; i++)
|
||||
@@ -306,6 +310,7 @@ void AudioTool::ConvertToFloat(const byte* input, uint32 inBitDepth, float* outp
|
||||
|
||||
void AudioTool::ConvertFromFloat(const float* input, int32* output, uint32 numSamples)
|
||||
{
|
||||
PROFILE_CPU();
|
||||
for (uint32 i = 0; i < numSamples; i++)
|
||||
{
|
||||
float sample = *(float*)input;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "OggVorbisDecoder.h"
|
||||
#include "Engine/Core/Log.h"
|
||||
#include "Engine/Core/Math/Math.h"
|
||||
#include "Engine/Profiler/ProfilerCPU.h"
|
||||
#include "Engine/Serialization/MemoryReadStream.h"
|
||||
#include <vorbis/codec.h>
|
||||
|
||||
@@ -42,10 +43,25 @@ long oggTell(void* data)
|
||||
return static_cast<long>(decoderData->Stream->GetPosition() - decoderData->Offset);
|
||||
}
|
||||
|
||||
OggVorbisDecoder::OggVorbisDecoder()
|
||||
{
|
||||
Stream = nullptr;
|
||||
Offset = 0;
|
||||
ChannelCount = 0;
|
||||
OggVorbisFile.datasource = nullptr;
|
||||
}
|
||||
|
||||
OggVorbisDecoder::~OggVorbisDecoder()
|
||||
{
|
||||
if (OggVorbisFile.datasource != nullptr)
|
||||
ov_clear(&OggVorbisFile);
|
||||
}
|
||||
|
||||
bool OggVorbisDecoder::Open(ReadStream* stream, AudioDataInfo& info, uint32 offset)
|
||||
{
|
||||
if (stream == nullptr)
|
||||
return false;
|
||||
PROFILE_CPU();
|
||||
|
||||
stream->SetPosition(offset);
|
||||
Stream = stream;
|
||||
@@ -71,11 +87,13 @@ bool OggVorbisDecoder::Open(ReadStream* stream, AudioDataInfo& info, uint32 offs
|
||||
|
||||
void OggVorbisDecoder::Seek(uint32 offset)
|
||||
{
|
||||
PROFILE_CPU();
|
||||
ov_pcm_seek(&OggVorbisFile, offset / ChannelCount);
|
||||
}
|
||||
|
||||
void OggVorbisDecoder::Read(byte* samples, uint32 numSamples)
|
||||
{
|
||||
PROFILE_CPU();
|
||||
uint32 numReadSamples = 0;
|
||||
while (numReadSamples < numSamples)
|
||||
{
|
||||
|
||||
@@ -15,36 +15,23 @@
|
||||
class OggVorbisDecoder : public AudioDecoder
|
||||
{
|
||||
public:
|
||||
|
||||
ReadStream* Stream;
|
||||
uint32 Offset;
|
||||
uint32 ChannelCount;
|
||||
OggVorbis_File OggVorbisFile;
|
||||
|
||||
public:
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="OggVorbisDecoder"/> class.
|
||||
/// </summary>
|
||||
OggVorbisDecoder()
|
||||
{
|
||||
Stream = nullptr;
|
||||
Offset = 0;
|
||||
ChannelCount = 0;
|
||||
OggVorbisFile.datasource = nullptr;
|
||||
}
|
||||
OggVorbisDecoder();
|
||||
|
||||
/// <summary>
|
||||
/// Finalizes an instance of the <see cref="OggVorbisDecoder"/> class.
|
||||
/// </summary>
|
||||
~OggVorbisDecoder()
|
||||
{
|
||||
if (OggVorbisFile.datasource != nullptr)
|
||||
ov_clear(&OggVorbisFile);
|
||||
}
|
||||
~OggVorbisDecoder();
|
||||
|
||||
public:
|
||||
|
||||
// [AudioDecoder]
|
||||
bool Open(ReadStream* stream, AudioDataInfo& info, uint32 offset = 0) override;
|
||||
void Seek(uint32 offset) override;
|
||||
|
||||
Reference in New Issue
Block a user