aboutsummaryrefslogtreecommitdiff
path: root/NvBlast/sdk/profiler
diff options
context:
space:
mode:
authorBryan Galdrikian <[email protected]>2017-02-21 12:07:59 -0800
committerBryan Galdrikian <[email protected]>2017-02-21 12:07:59 -0800
commit446ce137c6823ba9eff273bdafdaf266287c7c98 (patch)
treed20aab3e2ed08d7b3ca71c2f40db6a93ea00c459 /NvBlast/sdk/profiler
downloadblast-1.0.0-beta.tar.xz
blast-1.0.0-beta.zip
first commitv1.0.0-beta
Diffstat (limited to 'NvBlast/sdk/profiler')
-rw-r--r--NvBlast/sdk/profiler/NvBlastProfiler.cpp91
-rw-r--r--NvBlast/sdk/profiler/NvBlastProfilerInternal.h58
2 files changed, 149 insertions, 0 deletions
diff --git a/NvBlast/sdk/profiler/NvBlastProfiler.cpp b/NvBlast/sdk/profiler/NvBlastProfiler.cpp
new file mode 100644
index 0000000..3e82396
--- /dev/null
+++ b/NvBlast/sdk/profiler/NvBlastProfiler.cpp
@@ -0,0 +1,91 @@
+/*
+* Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved.
+*
+* NVIDIA CORPORATION and its licensors retain all intellectual property
+* and proprietary rights in and to this software, related documentation
+* and any modifications thereto. Any use, reproduction, disclosure or
+* distribution of this software and related documentation without an express
+* license agreement from NVIDIA CORPORATION is strictly prohibited.
+*/
+
+#include "NvBlastProfilerInternal.h"
+#include "PxProfiler.h"
+
+#if NV_PROFILE || NV_CHECKED || NV_DEBUG
+
+#if NV_NVTX
+#include "nvToolsExt.h"
+NV_INLINE void platformZoneStart(const char* name) { nvtxRangePush(name); }
+NV_INLINE void platformZoneEnd(const char*) { nvtxRangePop(); }
+
+#elif NV_XBOXONE
+#include "xboxone/NvBlastProfilerXB1.h"
+
+#elif NV_PS4
+#include "ps4/NvBlastProfilerPS4.h"
+
+#else
+NV_INLINE void platformZoneStart(const char*) { }
+NV_INLINE void platformZoneEnd(const char*) { }
+
+#endif
+
+static const uint64_t blastContextId = 0xb1a57;
+static physx::PxProfilerCallback* sCallback = nullptr;
+static bool sPlatform = false;
+static NvBlastProfilerDetail::Level sDetail = NvBlastProfilerDetail::LOW;
+
+void NvBlastProfilerSetCallback(physx::PxProfilerCallback* pcb)
+{
+ sCallback = pcb;
+}
+
+void NvBlastProfilerEnablePlatform(bool enable)
+{
+ sPlatform = enable;
+}
+
+void NvBlastProfilerBegin(const char* name, NvBlastProfilerDetail::Level level)
+{
+ if (level <= sDetail)
+ {
+ if (sCallback != nullptr)
+ {
+ sCallback->zoneStart(name, false, blastContextId);
+ }
+
+ if (sPlatform)
+ {
+ platformZoneStart(name);
+ }
+ }
+}
+
+void NvBlastProfilerEnd(const char* name, NvBlastProfilerDetail::Level level)
+{
+ if (level <= sDetail)
+ {
+ if (sCallback != nullptr)
+ {
+ sCallback->zoneEnd(nullptr, name, false, blastContextId);
+ }
+
+ if (sPlatform)
+ {
+ platformZoneEnd(name);
+ }
+ }
+}
+
+void NvBlastProfilerSetDetail(NvBlastProfilerDetail::Level level)
+{
+ sDetail = level;
+}
+
+#else
+
+void NvBlastProfilerSetCallback(physx::PxProfilerCallback*) {}
+void NvBlastProfilerEnablePlatform(bool) {}
+void NvBlastProfilerSetDetail(NvBlastProfilerDetail::Level) {}
+
+#endif //NV_PROFILE
diff --git a/NvBlast/sdk/profiler/NvBlastProfilerInternal.h b/NvBlast/sdk/profiler/NvBlastProfilerInternal.h
new file mode 100644
index 0000000..9be3c87
--- /dev/null
+++ b/NvBlast/sdk/profiler/NvBlastProfilerInternal.h
@@ -0,0 +1,58 @@
+/*
+* Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved.
+*
+* NVIDIA CORPORATION and its licensors retain all intellectual property
+* and proprietary rights in and to this software, related documentation
+* and any modifications thereto. Any use, reproduction, disclosure or
+* distribution of this software and related documentation without an express
+* license agreement from NVIDIA CORPORATION is strictly prohibited.
+*/
+
+#ifndef NVBLASTPROFILERINTERNAL_H
+#define NVBLASTPROFILERINTERNAL_H
+
+#include "NvBlastPreprocessor.h"
+#include "NvBlastProfiler.h"
+
+#if NV_PROFILE || NV_CHECKED || NV_DEBUG
+
+void NvBlastProfilerBegin(const char* name, NvBlastProfilerDetail::Level);
+void NvBlastProfilerEnd(const char* name, NvBlastProfilerDetail::Level);
+
+class ProfileScope
+{
+public:
+ ProfileScope(const char* name, NvBlastProfilerDetail::Level level) :m_name(name), m_level(level)
+ {
+ NvBlastProfilerBegin(m_name, m_level);
+ }
+
+ ~ProfileScope()
+ {
+ NvBlastProfilerEnd(m_name, m_level);
+ }
+
+private:
+ const char* m_name;
+ NvBlastProfilerDetail::Level m_level;
+};
+
+#define PERF_BLAST_PREFIX "Blast: "
+#define PERF_ZONE_BEGIN(name) NvBlastProfilerBegin(PERF_BLAST_PREFIX name, NvBlastProfilerDetail::HIGH)
+#define PERF_ZONE_END(name) NvBlastProfilerEnd(PERF_BLAST_PREFIX name, NvBlastProfilerDetail::HIGH)
+#define PERF_SCOPE(name, detail) ProfileScope PX_CONCAT(_scope,__LINE__) (PERF_BLAST_PREFIX name, detail)
+#define PERF_SCOPE_L(name) PERF_SCOPE(name, NvBlastProfilerDetail::LOW)
+#define PERF_SCOPE_M(name) PERF_SCOPE(name, NvBlastProfilerDetail::MEDIUM)
+#define PERF_SCOPE_H(name) PERF_SCOPE(name, NvBlastProfilerDetail::HIGH)
+
+#else
+
+#define PERF_ZONE_BEGIN(name)
+#define PERF_ZONE_END(name)
+#define PERF_SCOPE_L(name)
+#define PERF_SCOPE_M(name)
+#define PERF_SCOPE_H(name)
+
+#endif
+
+#endif