Add Windows PIX runtime support
Signed-off-by: Jeremy Ong <jcong@amazon.com>
This commit is contained in:
@@ -18,6 +18,12 @@
|
||||
#include <AzCore/std/functional.h>
|
||||
#include <AzCore/Math/Crc.h>
|
||||
|
||||
#ifdef USE_PIX
|
||||
#include <AzCore/PlatformIncl.h>
|
||||
#include <WinPixEventRuntime/pix3.h>
|
||||
#endif
|
||||
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace Debug
|
||||
@@ -495,6 +501,10 @@ namespace AZ
|
||||
ProfilerRegister*
|
||||
ProfilerRegister::TimerCreateAndStart(const char* systemName, const char* name, ProfilerSection * section, const char* function, int line)
|
||||
{
|
||||
#if defined(USE_PIX)
|
||||
PIXBeginEvent(PIX_COLOR(0, 0, 1), "%s:%s", name, function);
|
||||
#endif
|
||||
|
||||
AZStd::chrono::system_clock::time_point start = AZStd::chrono::system_clock::now();
|
||||
ProfilerRegister* reg = CreateRegister(systemName, name, function, line, ProfilerRegister::PRT_TIME);
|
||||
AZStd::chrono::system_clock::time_point end = AZStd::chrono::system_clock::now();
|
||||
@@ -537,6 +547,11 @@ namespace AZ
|
||||
void ProfilerRegister::TimerStart(ProfilerSection* section)
|
||||
{
|
||||
ProfilerRegister* reg = this;
|
||||
|
||||
#if defined(USE_PIX)
|
||||
PIXBeginEvent(PIX_COLOR(0, 0, 1), "%s:%s", reg->m_name, reg->m_function);
|
||||
#endif
|
||||
|
||||
if (reg->m_isActive)
|
||||
{
|
||||
section->m_register = reg;
|
||||
@@ -555,6 +570,10 @@ namespace AZ
|
||||
//=========================================================================
|
||||
void ProfilerRegister::TimerStop()
|
||||
{
|
||||
#if defined(USE_PIX)
|
||||
PIXEndEvent();
|
||||
#endif
|
||||
|
||||
AZStd::chrono::system_clock::time_point end = AZStd::chrono::system_clock::now();
|
||||
ProfilerSection* section = m_threadData->m_stack.back();
|
||||
AZStd::chrono::microseconds elapsedTime = end - section->m_start;
|
||||
|
||||
@@ -5,8 +5,7 @@
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#ifndef AZCORE_PROFILER_H
|
||||
#define AZCORE_PROFILER_H 1
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/std/chrono/chrono.h>
|
||||
#include <AzCore/std/function/function_fwd.h>
|
||||
@@ -615,5 +614,3 @@ namespace AZ
|
||||
}
|
||||
} // namespace AZ
|
||||
|
||||
#endif // AZCORE_PROFILER_H
|
||||
#pragma once
|
||||
|
||||
@@ -19,6 +19,12 @@ if(LY_RAD_TELEMETRY_ENABLED)
|
||||
set(AZ_CORE_RADTELEMETRY_BUILD_DEPENDENCIES 3rdParty::RadTelemetry)
|
||||
endif()
|
||||
|
||||
if(PAL_TRAIT_PROF_PIX_SUPPORTED AND LY_PIX_ENABLED)
|
||||
set(LY_PIX_PATH "${LY_3RDPARTY_PATH}/winpixeventruntime" CACHE PATH "Path to the Windows Pix Event Runtime.")
|
||||
set(AZ_CORE_PIX_BUILD_DEPENDENCIES 3rdParty::pix)
|
||||
set(AZ_CORE_PIX_BUILD_DEFINES "USE_PIX")
|
||||
endif()
|
||||
|
||||
ly_add_target(
|
||||
NAME AzCore STATIC
|
||||
NAMESPACE AZ
|
||||
@@ -45,6 +51,10 @@ ly_add_target(
|
||||
3rdParty::zstd
|
||||
3rdParty::cityhash
|
||||
${AZ_CORE_RADTELEMETRY_BUILD_DEPENDENCIES}
|
||||
${AZ_CORE_PIX_BUILD_DEPENDENCIES}
|
||||
COMPILE_DEFINITIONS
|
||||
PUBLIC
|
||||
${AZ_CORE_PIX_BUILD_DEFINES}
|
||||
)
|
||||
ly_add_source_properties(
|
||||
SOURCES
|
||||
|
||||
Reference in New Issue
Block a user