mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-25 23:44:35 +00:00
Instrument functions.
This commit is contained in:
parent
516ec6883d
commit
3e19fbc2fb
@ -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));
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user