Instrument functions.

This commit is contained in:
Bartosz Taudul 2019-10-29 22:45:30 +01:00
parent 516ec6883d
commit 3e19fbc2fb
2 changed files with 25 additions and 0 deletions

View File

@ -7,6 +7,8 @@
#endif #endif
#include <atomic> #include <atomic>
#include "../../../Tracy.hpp"
// 46 spheres (2 emissive) when enabled; 9 spheres (1 emissive) when disabled // 46 spheres (2 emissive) when enabled; 9 spheres (1 emissive) when disabled
#define DO_BIG_SCENE 1 #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) 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); outLightE = float3(0,0,0);
if (mat.type == Material::Lambert) 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) static float3 Trace(const Ray& r, int depth, int& inoutRayCount, uint32_t& state, bool doMaterialE = true)
{ {
ZoneScoped;
Hit rec; Hit rec;
int id = 0; int id = 0;
++inoutRayCount; ++inoutRayCount;
@ -235,6 +239,7 @@ static enkiTaskScheduler* g_TS;
void InitializeTest() void InitializeTest()
{ {
ZoneScoped;
#if CPU_CAN_DO_THREADS #if CPU_CAN_DO_THREADS
g_TS = enkiNewTaskScheduler(); g_TS = enkiNewTaskScheduler();
enkiInitTaskScheduler(g_TS); enkiInitTaskScheduler(g_TS);
@ -243,6 +248,7 @@ void InitializeTest()
void ShutdownTest() void ShutdownTest()
{ {
ZoneScoped;
#if CPU_CAN_DO_THREADS #if CPU_CAN_DO_THREADS
enkiDeleteTaskScheduler(g_TS); enkiDeleteTaskScheduler(g_TS);
#endif #endif
@ -261,6 +267,7 @@ struct JobData
static void TraceRowJob(uint32_t start, uint32_t end, uint32_t threadnum, void* data_) static void TraceRowJob(uint32_t start, uint32_t end, uint32_t threadnum, void* data_)
{ {
ZoneScoped;
JobData& data = *(JobData*)data_; JobData& data = *(JobData*)data_;
float* backbuffer = data.backbuffer + start * data.screenWidth * 4; float* backbuffer = data.backbuffer + start * data.screenWidth * 4;
float invWidth = 1.0f / data.screenWidth; 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) void UpdateTest(float time, int frameCount, int screenWidth, int screenHeight, unsigned testFlags)
{ {
ZoneScoped;
if (testFlags & kFlagAnimate) if (testFlags & kFlagAnimate)
{ {
s_Spheres[1].center.setY(cosf(time) + 1.0f); 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) void DrawTest(float time, int frameCount, int screenWidth, int screenHeight, float* backbuffer, int& outRayCount, unsigned testFlags)
{ {
ZoneScoped;
JobData args; JobData args;
args.time = time; args.time = time;
args.frameCount = frameCount; 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) void GetObjectCount(int& outCount, int& outObjectSize, int& outMaterialSize, int& outCamSize)
{ {
ZoneScoped;
outCount = kSphereCount; outCount = kSphereCount;
outObjectSize = sizeof(Sphere); outObjectSize = sizeof(Sphere);
outMaterialSize = sizeof(Material); 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) void GetSceneDesc(void* outObjects, void* outMaterials, void* outCam, void* outEmissives, int* outEmissiveCount)
{ {
ZoneScoped;
memcpy(outObjects, s_Spheres, kSphereCount * sizeof(s_Spheres[0])); memcpy(outObjects, s_Spheres, kSphereCount * sizeof(s_Spheres[0]));
memcpy(outMaterials, s_SphereMats, kSphereCount * sizeof(s_SphereMats[0])); memcpy(outMaterials, s_SphereMats, kSphereCount * sizeof(s_SphereMats[0]));
memcpy(outCam, &s_Cam, sizeof(s_Cam)); memcpy(outCam, &s_Cam, sizeof(s_Cam));

View File

@ -15,6 +15,8 @@
#include "CompiledVertexShader.h" #include "CompiledVertexShader.h"
#include "CompiledPixelShader.h" #include "CompiledPixelShader.h"
#include "../../../Tracy.hpp"
static HINSTANCE g_HInstance; static HINSTANCE g_HInstance;
static HWND g_Wnd; static HWND g_Wnd;
@ -226,6 +228,8 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE, _In_ LPWSTR,
ATOM MyRegisterClass(HINSTANCE hInstance) ATOM MyRegisterClass(HINSTANCE hInstance)
{ {
ZoneScoped;
WNDCLASSEXW wcex; WNDCLASSEXW wcex;
memset(&wcex, 0, sizeof(wcex)); memset(&wcex, 0, sizeof(wcex));
wcex.cbSize = sizeof(WNDCLASSEX); wcex.cbSize = sizeof(WNDCLASSEX);
@ -242,6 +246,8 @@ ATOM MyRegisterClass(HINSTANCE hInstance)
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{ {
ZoneScoped;
g_HInstance = hInstance; g_HInstance = hInstance;
RECT rc = { 0, 0, kBackbufferWidth, kBackbufferHeight }; RECT rc = { 0, 0, kBackbufferWidth, kBackbufferHeight };
DWORD style = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX; DWORD style = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX;
@ -264,6 +270,8 @@ static int s_FrameCount = 0;
static void RenderFrame() static void RenderFrame()
{ {
ZoneScoped;
LARGE_INTEGER time1; LARGE_INTEGER time1;
#if DO_COMPUTE_GPU #if DO_COMPUTE_GPU
@ -368,6 +376,8 @@ static void RenderFrame()
g_D3D11Ctx->Draw(3, 0); g_D3D11Ctx->Draw(3, 0);
g_D3D11SwapChain->Present(0, 0); g_D3D11SwapChain->Present(0, 0);
FrameMark;
#if DO_COMPUTE_GPU #if DO_COMPUTE_GPU
g_D3D11Ctx->End(g_QueryDisjoint); g_D3D11Ctx->End(g_QueryDisjoint);
@ -443,6 +453,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
static HRESULT InitD3DDevice() static HRESULT InitD3DDevice()
{ {
ZoneScoped;
HRESULT hr = S_OK; HRESULT hr = S_OK;
RECT rc; RECT rc;
@ -534,6 +546,8 @@ static HRESULT InitD3DDevice()
static void ShutdownD3DDevice() static void ShutdownD3DDevice()
{ {
ZoneScoped;
if (g_D3D11Ctx) g_D3D11Ctx->ClearState(); if (g_D3D11Ctx) g_D3D11Ctx->ClearState();
if (g_D3D11RenderTarget) g_D3D11RenderTarget->Release(); if (g_D3D11RenderTarget) g_D3D11RenderTarget->Release();