Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/wolfpld/tracy.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBartosz Taudul <wolf.pld@gmail.com>2019-10-30 00:45:30 +0300
committerBartosz Taudul <wolf.pld@gmail.com>2019-10-30 00:45:30 +0300
commit3e19fbc2fb52ca2443e41309c8261cb9d8ad4c35 (patch)
tree2dcddaad2e60cbd6db2462d824a46a50ce4546cf /examples
parent516ec6883d6b04778e9c61563b260e6db319e111 (diff)
Instrument functions.
Diffstat (limited to 'examples')
-rw-r--r--examples/ToyPathTracer/Source/Test.cpp11
-rw-r--r--examples/ToyPathTracer/Windows/TestWin.cpp14
2 files changed, 25 insertions, 0 deletions
diff --git a/examples/ToyPathTracer/Source/Test.cpp b/examples/ToyPathTracer/Source/Test.cpp
index 8911281a..dadb2060 100644
--- a/examples/ToyPathTracer/Source/Test.cpp
+++ b/examples/ToyPathTracer/Source/Test.cpp
@@ -7,6 +7,8 @@
#endif
#include <atomic>
+#include "../../../Tracy.hpp"
+
// 46 spheres (2 emissive) when enabled; 9 spheres (1 emissive) when disabled
#define DO_BIG_SCENE 1
@@ -82,6 +84,7 @@ bool HitWorld(const Ray& r, float tMin, float tMax, Hit& outHit, int& outID)
static bool Scatter(const Material& mat, const Ray& r_in, const Hit& rec, float3& attenuation, Ray& scattered, float3& outLightE, int& inoutRayCount, uint32_t& state)
{
+ ZoneScoped;
outLightE = float3(0,0,0);
if (mat.type == Material::Lambert)
{
@@ -190,6 +193,7 @@ static bool Scatter(const Material& mat, const Ray& r_in, const Hit& rec, float3
static float3 Trace(const Ray& r, int depth, int& inoutRayCount, uint32_t& state, bool doMaterialE = true)
{
+ ZoneScoped;
Hit rec;
int id = 0;
++inoutRayCount;
@@ -235,6 +239,7 @@ static enkiTaskScheduler* g_TS;
void InitializeTest()
{
+ ZoneScoped;
#if CPU_CAN_DO_THREADS
g_TS = enkiNewTaskScheduler();
enkiInitTaskScheduler(g_TS);
@@ -243,6 +248,7 @@ void InitializeTest()
void ShutdownTest()
{
+ ZoneScoped;
#if CPU_CAN_DO_THREADS
enkiDeleteTaskScheduler(g_TS);
#endif
@@ -261,6 +267,7 @@ struct JobData
static void TraceRowJob(uint32_t start, uint32_t end, uint32_t threadnum, void* data_)
{
+ ZoneScoped;
JobData& data = *(JobData*)data_;
float* backbuffer = data.backbuffer + start * data.screenWidth * 4;
float invWidth = 1.0f / data.screenWidth;
@@ -297,6 +304,7 @@ static void TraceRowJob(uint32_t start, uint32_t end, uint32_t threadnum, void*
void UpdateTest(float time, int frameCount, int screenWidth, int screenHeight, unsigned testFlags)
{
+ ZoneScoped;
if (testFlags & kFlagAnimate)
{
s_Spheres[1].center.setY(cosf(time) + 1.0f);
@@ -339,6 +347,7 @@ void UpdateTest(float time, int frameCount, int screenWidth, int screenHeight, u
void DrawTest(float time, int frameCount, int screenWidth, int screenHeight, float* backbuffer, int& outRayCount, unsigned testFlags)
{
+ ZoneScoped;
JobData args;
args.time = time;
args.frameCount = frameCount;
@@ -364,6 +373,7 @@ void DrawTest(float time, int frameCount, int screenWidth, int screenHeight, flo
void GetObjectCount(int& outCount, int& outObjectSize, int& outMaterialSize, int& outCamSize)
{
+ ZoneScoped;
outCount = kSphereCount;
outObjectSize = sizeof(Sphere);
outMaterialSize = sizeof(Material);
@@ -372,6 +382,7 @@ void GetObjectCount(int& outCount, int& outObjectSize, int& outMaterialSize, int
void GetSceneDesc(void* outObjects, void* outMaterials, void* outCam, void* outEmissives, int* outEmissiveCount)
{
+ ZoneScoped;
memcpy(outObjects, s_Spheres, kSphereCount * sizeof(s_Spheres[0]));
memcpy(outMaterials, s_SphereMats, kSphereCount * sizeof(s_SphereMats[0]));
memcpy(outCam, &s_Cam, sizeof(s_Cam));
diff --git a/examples/ToyPathTracer/Windows/TestWin.cpp b/examples/ToyPathTracer/Windows/TestWin.cpp
index e96b9820..7acc8595 100644
--- a/examples/ToyPathTracer/Windows/TestWin.cpp
+++ b/examples/ToyPathTracer/Windows/TestWin.cpp
@@ -15,6 +15,8 @@
#include "CompiledVertexShader.h"
#include "CompiledPixelShader.h"
+#include "../../../Tracy.hpp"
+
static HINSTANCE g_HInstance;
static HWND g_Wnd;
@@ -226,6 +228,8 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE, _In_ LPWSTR,
ATOM MyRegisterClass(HINSTANCE hInstance)
{
+ ZoneScoped;
+
WNDCLASSEXW wcex;
memset(&wcex, 0, sizeof(wcex));
wcex.cbSize = sizeof(WNDCLASSEX);
@@ -242,6 +246,8 @@ ATOM MyRegisterClass(HINSTANCE hInstance)
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
+ ZoneScoped;
+
g_HInstance = hInstance;
RECT rc = { 0, 0, kBackbufferWidth, kBackbufferHeight };
DWORD style = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX;
@@ -264,6 +270,8 @@ static int s_FrameCount = 0;
static void RenderFrame()
{
+ ZoneScoped;
+
LARGE_INTEGER time1;
#if DO_COMPUTE_GPU
@@ -368,6 +376,8 @@ static void RenderFrame()
g_D3D11Ctx->Draw(3, 0);
g_D3D11SwapChain->Present(0, 0);
+ FrameMark;
+
#if DO_COMPUTE_GPU
g_D3D11Ctx->End(g_QueryDisjoint);
@@ -443,6 +453,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
static HRESULT InitD3DDevice()
{
+ ZoneScoped;
+
HRESULT hr = S_OK;
RECT rc;
@@ -534,6 +546,8 @@ static HRESULT InitD3DDevice()
static void ShutdownD3DDevice()
{
+ ZoneScoped;
+
if (g_D3D11Ctx) g_D3D11Ctx->ClearState();
if (g_D3D11RenderTarget) g_D3D11RenderTarget->Release();