Ejemplo n.º 1
0
Texture *TextureManager::LoadTexture(WCHAR *filePath, bool async)
{
    TextureUpload *newTextureUpload = new TextureUpload();
    newTextureUpload->TextureToUpload = new Texture();
    newTextureUpload->UploadState = TextureUploadState_Initialized;
    newTextureUpload->FilePath = filePath;
    newTextureUpload->ImageData = new DirectX::ScratchImage();

    if(async)
    {
        std::lock_guard<std::mutex> lock(mTextureUploadMutex);
        mTextureUploads.Add(newTextureUpload);
        return newTextureUpload->TextureToUpload;
    }

    //synchronous uploads need to lock the upload context and stall for completion
    Direct3DQueueManager *queueManager = mDirect3DManager->GetContextManager()->GetQueueManager();
    UploadContext *uploadContext = mDirect3DManager->GetContextManager()->GetUploadContext();

    ProcessFileRead(newTextureUpload);

    uploadContext->LockUploads();
    TextureBackgroundUpload uploadJob(mDirect3DManager->GetDevice(), queueManager, newTextureUpload);
    uploadJob.ProcessUpload(uploadContext);
    queueManager->GetCopyQueue()->WaitForFenceCPUBlocking(newTextureUpload->UploadFence);
    uploadContext->UnlockUploads();

    uint64 currentUploadFence = queueManager->GetCopyQueue()->PollCurrentFenceValue();
    ProcessTransition(newTextureUpload, currentUploadFence);
    newTextureUpload->TextureToUpload->SetIsReady(true);

    Texture *newTexture = newTextureUpload->TextureToUpload;
    delete newTextureUpload;
    return newTexture;
}
// Called when the game starts or when spawned
void ACameraDirector::BeginPlay()
{
	Super::BeginPlay();

	//Set the target view of the player controller to the first camera in the array, if one exists.
	if (ManagedCameras.Num() > 0)
	{
		ProcessTransition();
	}
}
Ejemplo n.º 3
0
void TextureManager::ProcessCurrentUploads()
{
    std::lock_guard<std::mutex> lock(mTextureUploadMutex);

    Direct3DQueueManager *queueManager = mDirect3DManager->GetContextManager()->GetQueueManager();
    uint64 currentUploadFence = queueManager->GetCopyQueue()->PollCurrentFenceValue();

    uint32 numUploads = mTextureUploads.CurrentSize();
    for (uint32 i = 0; i < numUploads; i++)
    {
        TextureUpload *currentUpload = mTextureUploads[i];
        switch (currentUpload->UploadState)
        {
        case TextureUploadState_Initialized:
            currentUpload->UploadState = TextureUploadState_Read;
            break;
        case TextureUploadState_Read:
            currentUpload->UploadState = TextureUploadState_Pending;
            currentUpload->ReadJob = new TextureReadJob(currentUpload, this);
            ThreadPoolManager::GetSingleton()->GetBackgroundThreadPool()->AddSingleJob(currentUpload->ReadJob);
            break;
        case TextureUploadState_Upload:
            currentUpload->UploadState = TextureUploadState_Pending;
            mDirect3DManager->GetContextManager()->GetUploadContext()->AddBackgroundUpload(new TextureBackgroundUpload(mDirect3DManager->GetDevice(), queueManager, currentUpload));
            break;
        case TextureUploadState_Transition:
            ProcessTransition(currentUpload, currentUploadFence);
            break;
        case TextureUploadState_Completed:
            currentUpload->TextureToUpload->SetIsReady(true);
            currentUpload->UploadState = TextureUploadState_Delete;
            break;
        case TextureUploadState_Pending:
            //Background job is currently pending, just wait
            break;
        default:
            Application::Assert(false);
            break;
        }
    }

    for (int32 i = 0; i < mTextureUploads.CurrentSizeSigned(); i++)
    {
        TextureUpload *currentUpload = mTextureUploads[i];

        if (currentUpload->UploadState == TextureUploadState_Delete)
        {
            mTextureUploads.Remove(i);
            delete currentUpload;
            i--;
        }
    }
}
// Called every frame
void ACameraDirector::Tick( float DeltaTime )
{
	Super::Tick( DeltaTime );
	
	if (ManagedCameras.Num() > 0)
	{
		TimeToNextCameraChange -= DeltaTime;
		if (TimeToNextCameraChange <= 0.f)
		{
			ProcessTransition();
		}
	}
}
Ejemplo n.º 5
0
// I tried to make this pretty closely match what is described in Godefroid and Cormac's POPL paper.  I
// used the stack traversal optimizations and unlike what they describe in their paper I differentiated
// reads and writes.  I'm very tentative about my use of happens-before here, and to some extent about
// the whole algorithm so it could use some double checking. -Katie
void Dpor::CompletedExecution(ChessExecution* exec, size_t depthBound) {
	m_minStep = exec->NumTransitions();
	m_svm = ChessImpl::GetSyncVarManager();
	m_exec = exec;
	m_enabled = static_cast<EnabledSet*>(exec->GetQueryEnabled());
	m_backtrackingPoints.clear();
	m_depthBound = depthBound;
	m_bounded = ChessImpl::GetOptions().bounded;
	const size_t numThreads = ChessImpl::NumThreads();
	const size_t numTrans = exec->NumTransitions();
	m_backtrackingPoints.resize(numTrans);
	m_attributes.clear();
	m_attributes.resize(numTrans);
	m_lastNonPreemptionStep.clear();
	const size_t oldBstep = exec->GetRecordIndex();
	for (size_t i = 0; i < numTrans; i++) {
		const ChessTransition trans = exec->Transition(i);
		if (m_bounded) {
			for (size_t tid = 1; tid < numThreads; tid++) {
				if (trans.tid != tid && m_enabled->IsEnabledAtStep(i, tid) && !exec->RequiresPreemption(i, tid)) {
					m_lastNonPreemptionStep[tid] = i;
				}
			}
		}
		// We don't need to bother actually searching for backtracking points until we get beyond this
		// execution's backtracking point into its record mode transitions - the replay mode ones were
		// already found during a previous execution.
		if (i < oldBstep) {
			PushTransition(i);
			continue;
		}
		// handle choose operations that still have more choices
		if (i < depthBound && trans.op == SVOP::CHOICE && trans.var > 0) {
			AddBacktrackingPoint(i, trans.tid, false /* no matching acquire */);
		}
		// Iterate through every process in the system
		for (size_t tid = 1; tid < numThreads; tid++) {
			ChessTransition lookahead;
			// Find the next task to be performed by tid.
			if (!exec->GetLookaheadAtStep(i, tid, lookahead)) {
				continue;
			}
			assert (lookahead.tid == tid);
			ProcessTransition(i, lookahead);
		}
		PushTransition(i);
	}
	m_mostRecentWrite.clear();
	m_mostRecentAccess.clear();
}