void USoundWave::PostLoad() { Super::PostLoad(); if (GetOutermost()->HasAnyPackageFlags(PKG_ReloadingForCooker)) { return; } // Compress to whatever formats the active target platforms want // static here as an optimization ITargetPlatformManagerModule* TPM = GetTargetPlatformManager(); if (TPM) { const TArray<ITargetPlatform*>& Platforms = TPM->GetActiveTargetPlatforms(); for (int32 Index = 0; Index < Platforms.Num(); Index++) { GetCompressedData(Platforms[Index]->GetWaveFormat(this)); } } // We don't precache default objects and we don't precache in the Editor as the latter will // most likely cause us to run out of memory. if (!GIsEditor && !IsTemplate( RF_ClassDefaultObject ) && GEngine) { FAudioDevice* AudioDevice = GEngine->GetMainAudioDevice(); if (AudioDevice && AudioDevice->AreStartupSoundsPreCached()) { // Upload the data to the hardware, but only if we've precached startup sounds already AudioDevice->Precache(this); } // remove bulk data if no AudioDevice is used and no sounds were initialized else if(IsRunningGame()) { RawData.RemoveBulkData(); } } // Only add this streaming sound if we're not a dedicated server or if there is an audio device manager if (IsStreaming() && !IsRunningDedicatedServer() && GEngine && GEngine->GetAudioDeviceManager()) { #if WITH_EDITORONLY_DATA FinishCachePlatformData(); #endif // #if WITH_EDITORONLY_DATA IStreamingManager::Get().GetAudioStreamingManager().AddStreamingSoundWave(this); } #if WITH_EDITORONLY_DATA if (!SourceFilePath_DEPRECATED.IsEmpty() && AssetImportData) { FAssetImportInfo Info; Info.Insert(FAssetImportInfo::FSourceFile(SourceFilePath_DEPRECATED)); AssetImportData->SourceData = MoveTemp(Info); } #endif // #if WITH_EDITORONLY_DATA INC_FLOAT_STAT_BY( STAT_AudioBufferTime, Duration ); INC_FLOAT_STAT_BY( STAT_AudioBufferTimeChannels, NumChannels * Duration ); }
void UTextureCube::PostLoad() { #if WITH_EDITOR FinishCachePlatformData(); #endif // #if WITH_EDITOR Super::PostLoad(); }
void USoundWave::PostLoad() { Super::PostLoad(); if (GetOutermost()->PackageFlags & PKG_ReloadingForCooker) { return; } // Compress to whatever formats the active target platforms want // static here as an optimization ITargetPlatformManagerModule* TPM = GetTargetPlatformManager(); if (TPM) { const TArray<ITargetPlatform*>& Platforms = TPM->GetActiveTargetPlatforms(); for (int32 Index = 0; Index < Platforms.Num(); Index++) { GetCompressedData(Platforms[Index]->GetWaveFormat(this)); } } // We don't precache default objects and we don't precache in the Editor as the latter will // most likely cause us to run out of memory. if( !GIsEditor && !IsTemplate( RF_ClassDefaultObject ) && GEngine ) { FAudioDevice* AudioDevice = GEngine->GetAudioDevice(); if( AudioDevice && AudioDevice->bStartupSoundsPreCached) { // Upload the data to the hardware, but only if we've precached startup sounds already AudioDevice->Precache( this ); } // remove bulk data if no AudioDevice is used and no sounds were initialized else if( IsRunningGame() ) { RawData.RemoveBulkData(); } } if (IsStreaming()) { #if WITH_EDITORONLY_DATA FinishCachePlatformData(); #endif // #if WITH_EDITORONLY_DATA IStreamingManager::Get().GetAudioStreamingManager().AddStreamingSoundWave(this); } INC_FLOAT_STAT_BY( STAT_AudioBufferTime, Duration ); INC_FLOAT_STAT_BY( STAT_AudioBufferTimeChannels, NumChannels * Duration ); }
void FShadowMapPendingTexture::StartEncoding(UWorld* InWorld) { // Create the shadow-map texture. auto Texture = NewObject<UShadowMapTexture2D>(Outer); Texture->Filter = GUseBilinearLightmaps ? TF_Default : TF_Nearest; // Signed distance field textures get stored in linear space, since they need more precision near .5. Texture->SRGB = false; Texture->LODGroup = TEXTUREGROUP_Shadowmap; Texture->ShadowmapFlags = ShadowmapFlags; Texture->Source.Init2DWithMipChain(GetSizeX(), GetSizeY(), TSF_BGRA8); Texture->MipGenSettings = TMGS_LeaveExistingMips; Texture->CompressionNone = true; int32 TextureSizeX = Texture->Source.GetSizeX(); int32 TextureSizeY = Texture->Source.GetSizeY(); { // Create the uncompressed top mip-level. TArray< TArray<FFourDistanceFieldSamples> > MipData; FShadowMap2D::EncodeSingleTexture(*this, Texture, MipData); // Copy the mip-map data into the UShadowMapTexture2D's mip-map array. for(int32 MipIndex = 0;MipIndex < MipData.Num();MipIndex++) { FColor* DestMipData = (FColor*)Texture->Source.LockMip(MipIndex); uint32 MipSizeX = FMath::Max(1,TextureSizeX >> MipIndex); uint32 MipSizeY = FMath::Max(1,TextureSizeY >> MipIndex); for(uint32 Y = 0;Y < MipSizeY;Y++) { for(uint32 X = 0;X < MipSizeX;X++) { const FFourDistanceFieldSamples& SourceSample = MipData[MipIndex][Y * MipSizeX + X]; DestMipData[ Y * MipSizeX + X ] = FColor(SourceSample.Samples[0].Distance, SourceSample.Samples[1].Distance, SourceSample.Samples[2].Distance, SourceSample.Samples[3].Distance); } } Texture->Source.UnlockMip(MipIndex); } } // Update the texture resource. Texture->BeginCachePlatformData(); Texture->FinishCachePlatformData(); Texture->UpdateResource(); // Update stats. int32 TextureSize = Texture->CalcTextureMemorySizeEnum( TMC_AllMips ); GNumShadowmapTotalTexels += TextureSizeX * TextureSizeY; GNumShadowmapTextures++; GShadowmapTotalSize += TextureSize; GShadowmapTotalStreamingSize += (ShadowmapFlags & SMF_Streamed) ? TextureSize : 0; UPackage* TexturePackage = Texture->GetOutermost(); for ( int32 LevelIndex=0; TexturePackage && LevelIndex < InWorld->GetNumLevels(); LevelIndex++ ) { ULevel* Level = InWorld->GetLevel(LevelIndex); UPackage* LevelPackage = Level->GetOutermost(); if ( TexturePackage == LevelPackage ) { Level->ShadowmapTotalSize += float(TextureSize) / 1024.0f; break; } } }