コード例 #1
0
ファイル: Iteration12.cpp プロジェクト: rizandigp/Iteration12
//--------------------------------------------------------------------------------------
// Process and render one frame. Called by the main loop
//--------------------------------------------------------------------------------------
void DoFrame()
{
	Timer mainTimer;

    // Clear backbuffer and begin frame
    float ClearColor[4] = { 0.0f, 0.125f, 0.3f, 1.0f }; //red,green,blue,alpha
	pRenderSystem->BeginFrame( ClearColor, 1.0f, 0 );
	
	static double t = 0, dt = 0;
	dt=t;
	t = globalTimer.GetSeconds();
	dt = t-dt;

	if (dt > 1/30.0f)
		dt = 1/30.0f;

	Timer updateTimer;
	scene.Update( dt );
	double t_update = updateTimer.GetMiliseconds();

	scene.RenderDeferred();
	pRenderSystem->EndFrame();

	double t_main = mainTimer.GetMiliseconds();


	// Wait for render thread to finish. Only necessary if we run multithreaded
	pRenderSystem->WaitForFrameToFinish();

	double t_waitrender = mainTimer.GetMiliseconds() - t_main;
	
	char str[20];

	if ( KEYDOWN('T') )
	{
		_gcvt( t_waitrender, 5, str );
		DEBUG_OUTPUT( "main thread wait: " );
		DEBUG_OUTPUT( str );
		DEBUG_OUTPUT( "ms\t" );

		_gcvt( t_main, 5, str );
		DEBUG_OUTPUT( "main thread: " );
		DEBUG_OUTPUT( str );
		DEBUG_OUTPUT( "ms\t  " );

		_gcvt( scene.t_physics, 5, str );
		DEBUG_OUTPUT( "physics: " );
		DEBUG_OUTPUT( str );
		DEBUG_OUTPUT( "ms\t  " );

		/*_gcvt( scene.t_ocean, 5, str );
		DEBUG_OUTPUT( "ocean: " );
		DEBUG_OUTPUT( str );
		DEBUG_OUTPUT( "ms\t  " );*/

		_gcvt( t_update, 5, str );
		DEBUG_OUTPUT( "Scene::update: " );
		DEBUG_OUTPUT( str );
		DEBUG_OUTPUT( "ms\t  " );

		_gcvt( pRenderSystem->GetRenderDispatcher()->t_renderthread, 5, str );
		DEBUG_OUTPUT( "render thread: " );
		DEBUG_OUTPUT( str );
		DEBUG_OUTPUT( "ms\t  " );
		/*
		_gcvt( pRenderSystem->t_renderstarve, 5, str );
		DEBUG_OUTPUT( "starve: " );
		DEBUG_OUTPUT( str );
		DEBUG_OUTPUT( "ms\t  " );
		*/
		_gcvt( pRenderSystem->t_commands, 5, str );
		DEBUG_OUTPUT( "render commands: " );
		DEBUG_OUTPUT( str );
		DEBUG_OUTPUT( "ms\t  " );

		_gcvt( pRenderSystem->GetRenderDispatcher()->t_bindparams, 6, str );
		DEBUG_OUTPUT( "Bind shader params: " );
		DEBUG_OUTPUT( str );
		DEBUG_OUTPUT( "ms\t  " );

		_gcvt( scene.t_scenerender, 6, str );
		DEBUG_OUTPUT( "Scene::render(): " );
		DEBUG_OUTPUT( str );
		DEBUG_OUTPUT( "ms\t  " );
		/*
		_gcvt( pRenderSystem->GetRenderDispatcher()->t_1, 6, str );
		DEBUG_OUTPUT( "(t_1: " );
		DEBUG_OUTPUT( str );
		DEBUG_OUTPUT( "ms\t  " );

		_gcvt( pRenderSystem->GetRenderDispatcher()->t_2, 6, str );
		DEBUG_OUTPUT( "t_2: " );
		DEBUG_OUTPUT( str );
		DEBUG_OUTPUT( "ms)\t  " );
	
		_gcvt( pRenderSystem->GetRenderDispatcher()->t_bindtextures, 6, str );
		DEBUG_OUTPUT( "Bind textures: " );
		DEBUG_OUTPUT( str );
		DEBUG_OUTPUT( "ms\t  " );

		_gcvt( pRenderSystem->GetRenderDispatcher()->t_drawcalls, 6, str );
		DEBUG_OUTPUT( "draw calls: " );
		DEBUG_OUTPUT( str );
		DEBUG_OUTPUT( "ms\t  " );
	
		_gcvt( pRenderSystem->GetRenderDispatcher()->t_BeginFrame, 6, str );
		DEBUG_OUTPUT( "begin frame: " );
		DEBUG_OUTPUT( str );
		DEBUG_OUTPUT( "ms\t  " );

		_gcvt( pRenderSystem->GetRenderDispatcher()->t_EndFrame, 6, str );
		DEBUG_OUTPUT( "end frame: " );
		DEBUG_OUTPUT( str );
		DEBUG_OUTPUT( "ms\t  " );
		*/
		_gcvt( scene.t_Cull, 5, str );
		DEBUG_OUTPUT( "Culling: " );
		DEBUG_OUTPUT( str );
		DEBUG_OUTPUT( "ms\t  " );

		_gcvt( pRenderSystem->t_material, 5, str );
		DEBUG_OUTPUT( "material system: " );
		DEBUG_OUTPUT( str );
		DEBUG_OUTPUT( "ms\t  " );

		_gcvt( pRenderSystem->t_material, 5, str );
		DEBUG_OUTPUT( "Renderer::RenderShadowmap: " );
		DEBUG_OUTPUT( str );
		DEBUG_OUTPUT( "ms\t  " );

		_gcvt( pRenderSystem->t_shaderparams, 5, str );
		DEBUG_OUTPUT( "shaderparams: " );
		DEBUG_OUTPUT( str );
		DEBUG_OUTPUT( "ms\t  " );
		/*
		_gcvt( pRenderSystem->t_shaderparams, 5, str );
		DEBUG_OUTPUT( "new shader params: " );
		DEBUG_OUTPUT( str );
		DEBUG_OUTPUT( "ms\t  " );
		
		_gcvt( pRenderSystem->t_alloc, 7, str );
		DEBUG_OUTPUT( "command alloc: " );
		DEBUG_OUTPUT( str );
		DEBUG_OUTPUT( "ms\t  " );

		_gcvt( pRenderSystem->t_dealloc, 7, str );
		DEBUG_OUTPUT( "command dealloc: " );
		DEBUG_OUTPUT( str );
		DEBUG_OUTPUT( "ms\t  " );
		*/
		_gcvt( pRenderSystem->t_queuepush, 7, str );
		DEBUG_OUTPUT( "render queue push: " );
		DEBUG_OUTPUT( str );
		DEBUG_OUTPUT( "mus\t  " );

		_gcvt( pRenderSystem->t_queuepop, 7, str );
		DEBUG_OUTPUT( "render queue pop: " );
		DEBUG_OUTPUT( str );
		DEBUG_OUTPUT( "mus\t  " );
	
		_gcvt( pRenderSystem->t_renderstarve, 5, str );
		DEBUG_OUTPUT( "render thread starve: " );
		DEBUG_OUTPUT( str );
		DEBUG_OUTPUT( "mus\t  " );
		
		itoa( pRenderSystem->GetRenderDispatcher()->drawcalls, str, 10 );
		DEBUG_OUTPUT( "draw calls: " );
		DEBUG_OUTPUT( str );
		DEBUG_OUTPUT( "\t  " );

		itoa( pRenderSystem->GetRenderDispatcher()->numVerts, str, 10 );
		DEBUG_OUTPUT( "verts: " );
		DEBUG_OUTPUT( str );
		DEBUG_OUTPUT( "\n  " );
		/*
		itoa( sizeof(uint64_t), str, 10 );
		DEBUG_OUTPUT( "sizeof uint64_t: " );
		DEBUG_OUTPUT( str );
		DEBUG_OUTPUT( "\n  " );*/
		/*
		int size = sizeof(D3D11RenderCommand_Draw);
		itoa( size, str, 10 );
		DEBUG_OUTPUT( "D3D11RenderCommand_Draw size: " );
		DEBUG_OUTPUT( str );
		DEBUG_OUTPUT( "\n  " );

		*/
	}
}