Beispiel #1
0
	void render()
	{
		PSY_PROFILER_SECTION( RenderRoot, "ScnViewComponentViewport::render" );
		pContext_->setFrameBuffer( FrameBuffer_ );
		pContext_->setViewport( Viewport_ );
		pContext_->clear( ClearColour_, EnableClearColour_, EnableClearDepth_, EnableClearStencil_ );
	}
Beispiel #2
0
	void render()
	{
		PSY_PROFILER_SECTION( RenderRoot, "ScnModelComponentRenderNode::render" );
		pContext_->setIndexBuffer( IndexBuffer_ );
		pContext_->setVertexBuffer( 0, VertexBuffer_, VertexStride_ );
		pContext_->setVertexDeclaration( VertexDeclaration_ );
		pContext_->drawIndexedPrimitives( Type_, Offset_, NoofIndices_, 0 );
	}
Beispiel #3
0
//////////////////////////////////////////////////////////////////////////
// execute
//virtual
void SysJobWorker::execute()
{
	// Enter loop.
	while( Active_ )
	{
		PSY_PROFILER_SECTION( SysJobWorker_BeginWait_Profile, "SysJobWorker_BeginWait" );

		// Wait till we are told to resume.
		{
			std::unique_lock< std::mutex > ResumeLock( ResumeMutex_ );
			ResumeEvent_.wait( ResumeLock, [ this ]{ return pCurrentJob_ != NULL; } );
		}

		PSY_PROFILER_SECTION( SysJobWorker_EndWait_Profile, "SysJobWorker_EndWait" );

		if( Active_ == BcTrue )
		{
			BcAssertMsg( pCurrentJob_ != NULL, "No job has been given!" );
		}

		BcAssertMsg( HaveJob_ == BcTrue, "SysJobWorker: We have a job pointer set, but haven't got it via giveJob." );

		// Start timing the job.
#if !PSY_PRODUCTION
		BcTimer Timer;
		Timer.mark();
#endif
		// Execute our job.
		pCurrentJob_->internalExecute();

#if !PSY_PRODUCTION
		// Add time spent to our total.
		const BcU32 TimeWorkingUS = static_cast< BcU32 >( Timer.time() * 1000000.0f );;
		TimeWorkingUS_ += TimeWorkingUS;
		JobsExecuted_++;
#endif			
		// No job now, clean up.
		delete pCurrentJob_;
		pCurrentJob_ = NULL;
		HaveJob_ = BcFalse;
			
		// Signal job queue parent to schedule.
		pParent_->schedule();
	}
}
Beispiel #4
0
//////////////////////////////////////////////////////////////////////////
// process
BcBool SysSystem::process()
{
	PSY_PROFILER_SECTION( TickRoot, "SysSystem::process" );

	// Mark perf timer.
	PerfTimer_.mark();
	
	// Cache process func.
	ProcessFunc processFunc = ProcessFuncs_[ ProcessState_ ];
	
	// Call the correct function for processing.
	BcBool RetVal = (this->*processFunc)();
	
	// Store last tick time.
	LastTickTime_ = (BcF32)PerfTimer_.time();

	BcAssert( LastTickTime_ >= 0.0f );
	
	//BcPrintf( "System %p time: %f ms\n", this, LastTickTime_ * 1000.0f );
	
	return RetVal;
}
Beispiel #5
0
void ScnModelComponent::render( class ScnViewComponent* pViewComponent, RsFrame* pFrame, RsRenderSort Sort )
{
	PSY_PROFILER_SECTION( RenderRoot, std::string( "ScnModelComponent::render" ) );

	Super::render( pViewComponent, pFrame, Sort );

	// Wait for model to have updated.
	UpdateFence_.wait();

	// Gather lights.
	ScnLightingVisitor LightingVisitor( this );

	ScnModelMeshRuntimeList& MeshRuntimes = Model_->MeshRuntimes_;
	ScnModelMeshData* pMeshDatas = Model_->pMeshData_;

	// Set layer.
	Sort.Layer_ = Layer_;
	Sort.Pass_ = Pass_;

	for( BcU32 PrimitiveIdx = 0; PrimitiveIdx < MeshRuntimes.size(); ++PrimitiveIdx )
	{
		ScnModelMeshRuntime* pMeshRuntime = &MeshRuntimes[ PrimitiveIdx ];
		ScnModelMeshData* pMeshData = &pMeshDatas[ pMeshRuntime->MeshDataIndex_ ];
		TPerComponentMeshData& PerComponentMeshData = PerComponentMeshDataList_[ PrimitiveIdx ];
		BcU32 Offset = 0; // This will change when index buffers are merged.

		BcAssertMsg( PerComponentMeshData.MaterialComponentRef_.isValid(), "Material not valid for use on ScnModelComponent \"%s\"", (*getName()).c_str() );

		// Set skinning parameters.
		if( pMeshData->IsSkinned_ )
		{
			PerComponentMeshData.MaterialComponentRef_->setBoneUniformBlock( PerComponentMeshData.UniformBuffer_ );
		}
		else
		{
			PerComponentMeshData.MaterialComponentRef_->setObjectUniformBlock( PerComponentMeshData.UniformBuffer_ );
		}

		// Set lighting parameters.
		LightingVisitor.setMaterialParameters( PerComponentMeshData.MaterialComponentRef_ );
			
		// Set material components for view.
		pViewComponent->setMaterialParameters( PerComponentMeshData.MaterialComponentRef_ );
			
		// Bind material.
		PerComponentMeshData.MaterialComponentRef_->bind( pFrame, Sort );
			
		// Render primitive.
		ScnModelComponentRenderNode* pRenderNode = pFrame->newObject< ScnModelComponentRenderNode >();
			
		pRenderNode->Type_ = pMeshData->Type_;
		pRenderNode->Offset_ = Offset;
		pRenderNode->NoofIndices_ = pMeshData->NoofIndices_;
		pRenderNode->IndexBuffer_ = pMeshRuntime->pIndexBuffer_;
		pRenderNode->VertexBuffer_ = pMeshRuntime->pVertexBuffer_;
		pRenderNode->VertexStride_ = pMeshData->VertexStride_;
		pRenderNode->VertexDeclaration_ = pMeshRuntime->pVertexDeclaration_;
		pRenderNode->Sort_ = Sort;
			
		pFrame->addRenderNode( pRenderNode );
	}
}