Пример #1
0
bool UTexture::IsReadyForFinishDestroy()
{
	bool bReadyForFinishDestroy = false;
	// Check whether super class is ready and whether we have any pending streaming requests in flight.
	if( Super::IsReadyForFinishDestroy() && !UpdateStreamingStatus() )
	{
		// Kick off async resource release if we haven't already.
		if( !bAsyncResourceReleaseHasBeenStarted && (Resource || TextureReference.IsInitialized_GameThread()) )
		{
			// Send the rendering thread a release message for the texture's resource.
			if (Resource)
			{
				BeginReleaseResource(Resource);
			}
			if (TextureReference.IsInitialized_GameThread())
			{
				TextureReference.BeginRelease_GameThread();
			}
			ReleaseFence.BeginFence();
			// Keep track that we already kicked off the async release.
			bAsyncResourceReleaseHasBeenStarted = true;
		}

		// Only allow FinishDestroy to be called once the texture resource has finished its rendering thread cleanup.
		if( !bAsyncResourceReleaseHasBeenStarted || ReleaseFence.IsFenceComplete() )
		{
			bReadyForFinishDestroy = true;
		}
	}
	return bReadyForFinishDestroy;
}
void FStreamingTexture::UpdateDynamicData(const int32 NumStreamedMips[TEXTUREGROUP_MAX], const FTextureStreamingSettings& Settings)
{
	// Note that those values are read from the async task and must not be assigned temporary values!!
	if (Texture)
	{
		UpdateStreamingStatus();

		// The last render time of this texture. Can be FLT_MAX when texture has no resource.
		const float LastRenderTimeForTexture = Texture->GetLastRenderTimeForStreaming();
		LastRenderTime = (FApp::GetCurrentTime() > LastRenderTimeForTexture) ? float( FApp::GetCurrentTime() - LastRenderTimeForTexture ) : 0.0f;

		bForceFullyLoad = Texture->ShouldMipLevelsBeForcedResident() || LODGroup == TEXTUREGROUP_Skybox || (LODGroup == TEXTUREGROUP_HierarchicalLOD && Settings.HLODStrategy == 2);

		const int32 NumCinematicMipLevels = (bForceFullyLoad && Texture->bUseCinematicMipLevels) ? Texture->NumCinematicMipLevels : 0;

		int32 LODBias = 0;
		if (!Settings.bUseAllMips)
		{
			LODBias = FMath::Max<int32>(Texture->GetCachedLODBias() - NumCinematicMipLevels, 0);

			// Reduce the max allowed resolution according to LODBias if the texture group allows it.
			if (IsMaxResolutionAffectedByGlobalBias())
			{
				LODBias += Settings.GlobalMipBiasAsInt();
			}

			LODBias += BudgetMipBias;
		}

		// The max mip count is affected by the texture bias and cinematic bias settings.
		MaxAllowedMips = FMath::Clamp<int32>(FMath::Min<int32>(MipCount - LODBias, GMaxTextureMipCount), NumNonStreamingMips, MipCount);

		if (LODGroup == TEXTUREGROUP_HierarchicalLOD && Settings.HLODStrategy == 1)
		{
			MinAllowedMips = FMath::Clamp<int32>(MaxAllowedMips - 1, NumNonStreamingMips, MaxAllowedMips);
		}
		else if (NumStreamedMips[LODGroup] > 0)
		{
			MinAllowedMips = FMath::Clamp<int32>(MipCount - NumStreamedMips[LODGroup], NumNonStreamingMips, MaxAllowedMips);
		}
		else
		{
			MinAllowedMips = NumNonStreamingMips;
		}
	}
	else
	{
		bReadyForStreaming = false;
		bInFlight = false;
		bCancelRequestAttempted = false;
		bForceFullyLoad = false;
		ResidentMips = 0;
		RequestedMips = 0;
		MinAllowedMips = 0;
		MaxAllowedMips = 0;
		LastRenderTime = FLT_MAX;	
	}
}
Пример #3
0
void UTexture::BeginDestroy()
{
	Super::BeginDestroy();
	if( !UpdateStreamingStatus() && Resource )
	{
		// Send the rendering thread a release message for the texture's resource.
		BeginReleaseResource(Resource);
		Resource->ReleaseFence.BeginFence();
		// Keep track that we alrady kicked off the async release.
		bAsyncResourceReleaseHasBeenStarted = true;
	}
}
FStreamingWaveData::~FStreamingWaveData()
{
	// Make sure there are no pending requests in flight.
	while (UpdateStreamingStatus() == true)
	{
		// Give up timeslice.
		FPlatformProcess::Sleep(0);
	}

	for (auto& LoadedChunk : LoadedChunks)
	{
		FreeLoadedChunk(LoadedChunk);
	}
}
Пример #5
0
void UTexture::BeginDestroy()
{
	Super::BeginDestroy();
	if( !UpdateStreamingStatus() && (Resource || TextureReference.IsInitialized_GameThread()) )
	{
		// Send the rendering thread a release message for the texture's resource.
		if (Resource)
		{
			BeginReleaseResource(Resource);
		}
		if (TextureReference.IsInitialized_GameThread())
		{
			TextureReference.BeginRelease_GameThread();
		}
		ReleaseFence.BeginFence();
		// Keep track that we already kicked off the async release.
		bAsyncResourceReleaseHasBeenStarted = true;
	}
}
void FStreamingTexture::StreamWantedMips(FStreamingManagerTexture& Manager)
{
	if (Texture && bReadyForStreaming && !bInFlight && WantedMips != ResidentMips)
	{
		ensure(ResidentMips == RequestedMips);

		if (Texture->PendingMipChangeRequestStatus.GetValue() == TexState_ReadyFor_Requests)
		{
			Texture->RequestedMips = WantedMips;

			FTexture2DResource* Texture2DResource = (FTexture2DResource*)Texture->Resource;
			Texture2DResource->BeginUpdateMipCount( (bForceFullyLoadHeuristic || bIsTerrainTexture || bIsCharacterTexture) && WantedMips <= VisibleWantedMips );

			UpdateStreamingStatus();

			TrackTextureEvent( this, Texture, bForceFullyLoadHeuristic != 0, &Manager );
		}
		else
		{
			// Did UpdateStreamingTextures() miss a texture? Should never happen!
			UE_LOG(LogContentStreaming, Warning, TEXT("BeginUpdateMipCount failure! PendingMipChangeRequestStatus == %d, Resident=%d, Requested=%d, Wanted=%d"), Texture->PendingMipChangeRequestStatus.GetValue(), Texture->ResidentMips, Texture->RequestedMips, WantedMips );
		}
	}
}