您的位置:首页 > 产品设计 > UI/UE

Havok_2014-1-0_Pc_Xs_User_Guide(1.5.7-计时器)

2015-08-13 22:30 656 查看
计时器

为了收集计时器还有一些其他的事情要做。如果你想收集计时器并在VDB中显示它们,每个线程或SPU必须分配一个缓冲区给它来收集这些计时器。

{

...

// Allocate timer buffer for this thread(200K)

hkMonitorStream::getInstance().resize(200000);

// Create thread pool and job queue

// Specify that the thread pool shouldallocate buffers per thread for timer collection

hkCpuThreadPoolCinfo threadPoolCinfo;

threadPoolCinfo.m_timerBufferPerThreadAllocation= 200000;

hkThreadPool* threadPool = new hkCpuThreadPool( threadPoolCinfo );

// Create a physics world and register withqueue.

hkJobQueue jobQueue;

hkpWorld* physicsWorld = new hkpWorld(worldCinfo);

physicsWorld->registerWithJobQueue(&jobQueue );

// Setup the visual debugger. Just showingthe first line of this setup code,

// see ConsoleExampleMt demo for theremaining code to setup the VDB

hkpPhysicsContext* context = newhkpPhysicsContext();

while( simulating )

{

// Step the world using this thread, andall the threads or SPUs in the thread pool

physicsWorld->stepMultithreaded(&jobQueue, threadPool, timestep );

// Copy timer information from the threadpool to the VDB context, so it can be viewed by the

VDB

// This function also copies the timersfrom this thread.

context->syncTimers( threadPool );

vdb->step();

// After the VDB has been stepped, reset the timer streams in this thread and in the threads of

the thread pool

hkMonitorStream::getInstance().reset();

threadPool->clearTimerData();

}

}

为了从所有的线程收集计时器需要使用上面的代码片段。你必须确保空间是分配给计时器缓冲区,用VDB上下文同步的每一帧,VDB步之后重置。如果你这样做你将能够在VDB中以各种形式查看计时器信息,每个线程的基础上。注意,这段代码在CPU和SPU线程池都是相同的。如果使用SPU线程池,线程池类负责管理SPU的缓冲区和同步主内存。

1.5.7.1 在VDB中查看计时器

为了启用Havok性能监视器,首先打开Statistics Viewer(通过Viewers->Statistics菜单项),然后启用Stat
Graph Overlay(通过View->Render
State->Stat Graph Overlay

菜单项)。为了看到文本版本的性能监控,启用Perf Stats Summary从Windows菜单或Windows工具栏的'T'图标。一般来说,绿色代表集成, 蓝色代表碰撞检测,红色代表Stats
Graph Overlay(统计图叠加)等。对于具体的细节将鼠标悬停在统计图叠加窗口。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: