Files
UnrealEngineUWP/Engine/Source/Developer/DerivedDataCache/Private/FileSystemDerivedDataBackend.cpp

328 lines
12 KiB
C++
Raw Normal View History

// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
#include "Core.h"
#include "DerivedDataBackendInterface.h"
#include "DDCCleanup.h"
#define MAX_BACKEND_KEY_LENGTH (120)
#define MAX_BACKEND_NUMBERED_SUBFOLDER_LENGTH (9)
#if PLATFORM_LINUX // PATH_MAX on Linux is 4096 (getconf PATH_MAX /, also see limits.h), so this value can be larger (note that it is still arbitrary).
// This should not affect sharing the cache between platforms as the absolute paths will be different anyway.
#define MAX_CACHE_DIR_LEN (3119)
#else
#define MAX_CACHE_DIR_LEN (119)
#endif // PLATFORM_LINUX
#define MAX_CACHE_EXTENTION_LEN (4)
/**
* Cache server that uses the OS filesystem
* The entire API should be callable from any thread (except the singleton can be assumed to be called at least once before concurrent access).
**/
class FFileSystemDerivedDataBackend : public FDerivedDataBackendInterface
{
public:
/**
* Constructor that should only be called once by the singleton, grabs the cache path from the ini
* @param InCacheDirectory directory to store the cache in
* @param bForceReadOnly if true, do not attempt to write to this cache
*/
FFileSystemDerivedDataBackend(const TCHAR* InCacheDirectory, bool bForceReadOnly, bool bTouchFiles, bool bPurgeTransientData, bool bDeleteOldFiles, int32 InDaysToDeleteUnusedFiles, int32 InMaxNumFoldersToCheck, int32 InMaxContinuousFileChecks)
: CachePath(InCacheDirectory)
, bReadOnly(bForceReadOnly)
, bFailed(true)
, bTouch(bTouchFiles)
, bPurgeTransient(bPurgeTransientData)
, DaysToDeleteUnusedFiles(InDaysToDeleteUnusedFiles)
{
// If we find a platform that has more stingent limits, this needs to be rethought.
static_assert(MAX_BACKEND_KEY_LENGTH + MAX_CACHE_DIR_LEN + MAX_BACKEND_NUMBERED_SUBFOLDER_LENGTH + MAX_CACHE_EXTENTION_LEN < PLATFORM_MAX_FILEPATH_LENGTH,
"Not enough room left for cache keys in max path.");
const double SlowInitDuration = 10.0;
double AccessDuration = 0.0;
check(CachePath.Len());
FPaths::NormalizeFilename(CachePath);
const FString AbsoluteCachePath = IFileManager::Get().ConvertToAbsolutePathForExternalAppForRead(*CachePath);
if (AbsoluteCachePath.Len() > MAX_CACHE_DIR_LEN)
{
const FText ErrorMessage = FText::Format( NSLOCTEXT("DerivedDataCache", "PathTooLong", "Cache path {0} is longer than {1} characters...please adjust [DerivedDataBackendGraph] paths to be shorter (this leaves more room for cache keys)."), FText::FromString( AbsoluteCachePath ), FText::AsNumber( MAX_CACHE_DIR_LEN ) );
FMessageDialog::Open(EAppMsgType::Ok, ErrorMessage);
UE_LOG(LogDerivedDataCache, Fatal, TEXT("%s"), *ErrorMessage.ToString());
}
if (!bReadOnly)
{
double TestStart = FPlatformTime::Seconds();
FString TempFilename = CachePath / FGuid::NewGuid().ToString() + ".tmp";
FFileHelper::SaveStringToFile(FString("TEST"),*TempFilename);
int32 TestFileSize = IFileManager::Get().FileSize(*TempFilename);
if (TestFileSize < 4)
{
UE_LOG(LogDerivedDataCache, Warning, TEXT("Fail to write to %s, derived data cache to this directory will be read only."),*CachePath);
}
else
{
bFailed = false;
}
if (TestFileSize >= 0)
{
IFileManager::Get().Delete(*TempFilename, false, false, true);
}
AccessDuration = FPlatformTime::Seconds() - TestStart;
}
if (bFailed)
{
double StartTime = FPlatformTime::Seconds();
TArray<FString> FilesAndDirectories;
IFileManager::Get().FindFiles(FilesAndDirectories,*(CachePath / TEXT("*.*")), true, true);
AccessDuration = FPlatformTime::Seconds() - StartTime;
if (FilesAndDirectories.Num() > 0)
{
bReadOnly = true;
bFailed = false;
}
}
if (FString(FCommandLine::Get()).Contains(TEXT("DerivedDataCache")) )
{
bTouch = true; // we always touch files when running the DDC commandlet
}
// The command line (-ddctouch) enables touch on all filesystem backends if specified.
bTouch = bTouch || FParse::Param(FCommandLine::Get(), TEXT("DDCTOUCH"));
if (bReadOnly)
{
bTouch = false; // we won't touch read only paths
}
if (bTouch)
{
UE_LOG(LogDerivedDataCache, Display, TEXT("Files in %s will be touched."),*CachePath);
}
if (!bFailed && AccessDuration > SlowInitDuration && !GIsBuildMachine)
{
UE_LOG(LogDerivedDataCache, Warning, TEXT("%s access is very slow (initialization took %.2lf seconds), consider disabling it."), *CachePath, AccessDuration);
}
if (!bReadOnly && !bFailed && bDeleteOldFiles && !FParse::Param(FCommandLine::Get(),TEXT("NODDCCLEANUP")) && FDDCCleanup::Get())
{
FDDCCleanup::Get()->AddFilesystem( CachePath, InDaysToDeleteUnusedFiles, InMaxNumFoldersToCheck, InMaxContinuousFileChecks );
}
}
/** return true if the cache is usable **/
bool IsUsable()
{
return !bFailed;
}
/** return true if this cache is writable **/
virtual bool IsWritable() override
{
return !bReadOnly;
}
/**
* Synchronous test for the existence of a cache item
*
* @param CacheKey Alphanumeric+underscore key of this cache item
* @return true if the data probably will be found, this can't be guaranteed because of concurrency in the backends, corruption, etc
*/
virtual bool CachedDataProbablyExists(const TCHAR* CacheKey) override
{
Copying //UE4/Dev-Platform to Dev-Main (//UE4/Dev-Main) Change 2783376 on 2015/11/30 by Nick.Shin upgrading emscripten SDK to 1.35.9 following instruction from the README file Change 2787414 on 2015/12/02 by Nick.Shin upgrading emscripten to 1.35.0 removing old SDK and tools for Mac and Win64 Change 2790218 on 2015/12/04 by Nick.Shin merge (CL: #2790164) from //UE4/Dev-Physics to //UE4/Dev-Platform PhysX HTML5 bc files Change 2794786 on 2015/12/08 by Nick.Shin merge CL #2794757 part 1 of 2 from //UE4/Dev-Physics/PhysX/PhysX_3.3/Lib/html5 to //UE4/Dev-Platform/Engine/Source/ThirdParty/PhysX/PhysX-3.3/lib/HTML5/ Change 2794789 on 2015/12/08 by Nick.Shin merge CL #2794758 part 2 of 2 from //UE4/Dev-Physics/PhysX/PhysX_3.3/Lib/html5 to //UE4/Dev-Platform/Engine/Source/ThirdParty/PhysX/PhysX-3.3/lib/HTML5/ Change 2799151 on 2015/12/10 by Dmitry.Rekman Guarantee XGE.xml sorting order for 10+ builds. - A licensee pointed out the problem that AutomationTool.UE4Build.FindXGEFiles() sorts the files by filename, so e.g. UBTExport.10.xge.xml takes priority over UBTExport.2.xge.xml. #codereview Ben.Marsh Change 2799440 on 2015/12/11 by Mark.Satterthwaite Duplicate CL #2790251: Temporarily revert some of the changes for Mac mouse cursor locking as they were causing more problems than they solved. Change 2799441 on 2015/12/11 by Mark.Satterthwaite Duplicate CL #2796111 & #2796158: Fix cooking shader cache files - it wasn't being enabled despite a cached shader format being listed. Change 2799442 on 2015/12/11 by Mark.Satterthwaite Duplicate CL #2797758: Defer calls to AUGraphUpdate into FCoreAudioDevice::UpdateHardware - this call will synchronise the calling thread with the CoreAudio thread/run-loop so that the CoreAudio graph is safe to modify and this may incur a significant stall. This means it is far more efficient to amortise the cost of all changes to the graph with a single call. To ensure correctness the audio format conversion components are cached and disposed of after the call to AUGraphUpdate so that any existing operations on the CoreAudio thread are completed prior to disposal. Change 2799601 on 2015/12/11 by Mark.Satterthwaite Implement background reading of NSPipe's in Mac ExecProcess to avoid the sub-process blocking trying to write to the meagre 8kb internal buffers. This may fix problems with SVN on Mac. Change 2799657 on 2015/12/11 by Mark.Satterthwaite Remove the hlslcc major version from the Metal and OpenGL shader formats to ensure that there are enough bits to represent the different version components. There's no expectation that the major version of hlslcc will change and it will soon be removed entirely. Change 2799691 on 2015/12/11 by Mark.Satterthwaite Merging final internal-only changes from WWDC. Change 2800182 on 2015/12/11 by Mark.Satterthwaite Capture the system.log contents from the moment we boot to the point we crash to report GPU restarts and other system errors not written into our own logs. Change 2801395 on 2015/12/14 by Mark.Satterthwaite Fix the Metal shader compiler so that it properly reports the number of sampler objects in use, not the number of textures as Metal separates its 16 samplers and up-to 128 textures in a single shader stage, like D3D and unlike OpenGL. This fixes a lot of material compile errors in newer projects which aren't being designed for obsolete OpenGL. Change 2801653 on 2015/12/14 by Daniel.Lamb Load package differ can now diff header part of packages. Changed the way IsChildCooker is handled improves performance of multiprocess cooker. Change 2801655 on 2015/12/14 by Daniel.Lamb Added cooker warning to resave packages if they don't have collision data for their static meshes. Added NavCollision creation on static mesh import so that we save out the NavCollision. Change 2801923 on 2015/12/14 by Daniel.Lamb Fix compilation error with CreateLoader. Change 2802076 on 2015/12/14 by Daniel.Lamb Remove some debugging assistance code. Change 2803207 on 2015/12/15 by Mark.Satterthwaite Add missing Metal formats for PF_R16_SINT/UINT. Change 2803254 on 2015/12/15 by Mark.Satterthwaite Add additional uint/2/3/4 overrides for SV_Target(x) to MetalUtils and when generating the output variable look for an exact type match before restoring to the first match with the correct number of elements. This ensures that we generate uint/2/3/4 writes when required for CopyStencilToLightingChannelsPS without breaking anything else. Change 2803259 on 2015/12/15 by Mark.Satterthwaite Fix stencil texture swizzle for Metal which uses .x not .g for stencil value. Change 2803262 on 2015/12/15 by Mark.Satterthwaite Fix FMetalRHICommandContext::RHISetScissorRect handling 0 sized rects when RHISetScissorRect is called before RHISetViewport. Change 2803321 on 2015/12/15 by Mark.Satterthwaite Duplicate CL #2786291: Fix Metal validation errors caused by incorrect instance count and also a crash-bug caused by accessing a defunct depth-stencil texture. This should be enough to ensure Metal works even if you've been playing previously with OpenGL. Change 2803413 on 2015/12/15 by Mark.Satterthwaite Workaround the Material Editor's unfortunate habit of rendering tiles without a depth/stencil-buffer attached despite tiles wanting to write to depth - in Metal we have to create a temporary Depth-Stencil texture so that we don't crash the driver because it won't rewrite the shaders for us (unlike D3D/GL). Change 2806247 on 2015/12/16 by Daniel.Lamb Fixed UParticleRequiredModule deterministic cook issue. #codereview Olaf.Piesche Change 2806834 on 2015/12/17 by Mark.Satterthwaite Temporarily work around absence of Checked & Shipping APEX/PhysX binaries on Mac. Change 2807017 on 2015/12/17 by Mark.Satterthwaite Handle the shader cache being initialised for cooking multiple times until I can sort out the implementation properly. Change 2807027 on 2015/12/17 by Daniel.Lamb Enabled DDC stats.
2016-01-19 09:54:25 -05:00
#if ENABLE_DDC_STATS
static FName NAME_CachedDataProbablyExists(TEXT("CachedDataProbablyExists"));
FDDCScopeStatHelper Stat(CacheKey, NAME_CachedDataProbablyExists);
static FName NAME_FileDDCPath(TEXT("FileDDCPath"));
Stat.AddTag(NAME_FileDDCPath, CachePath);
#endif
check(!bFailed);
FString Filename = BuildFilename(CacheKey);
FDateTime TimeStamp = IFileManager::Get().GetTimeStamp(*Filename);
bool bExists = TimeStamp > FDateTime::MinValue();
if (bExists)
{
// Update file timestamp to prevent it from being deleted by DDC Cleanup.
if (bTouch ||
(!bReadOnly && (FDateTime::UtcNow() - TimeStamp).GetDays() > (DaysToDeleteUnusedFiles / 4)))
{
IFileManager::Get().SetTimeStamp(*Filename, FDateTime::UtcNow());
}
}
return bExists;
}
/**
* Synchronous retrieve of a cache item
*
* @param CacheKey Alphanumeric+underscore key of this cache item
* @param OutData Buffer to receive the results, if any were found
* @return true if any data was found, and in this case OutData is non-empty
*/
Copying //UE4/Dev-Platform to //UE4/Main ========================== MAJOR FEATURES + CHANGES ========================== Change 2719147 on 2015/10/07 by Mark.Satterthwaite Allow the shader cache to perform some precompilation synchronously on load before falling back to asynchronous compilation to balance load times against total time spent precompiling. Added a stat to the group that reports how long the precompile has been running until it completes so it is easier to track. Change 2719182 on 2015/10/07 by Mark.Satterthwaite Refactor the ShaderCache's internal data structures and change the way we handle recording whether a particular predraw state has been submitted to try and make it more efficient. Change 2719185 on 2015/10/07 by Mark.Satterthwaite Merging CL #2717701: Try and fix random crashes on Mac when manipulating bound-shader-states caused by ShaderCache potentially providing a bogus shader state pointer on exit from predraw. Change 2719434 on 2015/10/07 by Mark.Satterthwaite Make sure that Mac ensures reports have a source context and a sane callstack when sent to the crash-reports server. Change 2724764 on 2015/10/12 by Josh.Adams [Initial AppleTV support] Merging //depot/YakBranch/... to //UE4/Dev-Platform/... Change 2726266 on 2015/10/13 by Lee.Clark PS4 - Calc reserve size required for DMA copy when using unsafe command buffers Change 2726401 on 2015/10/13 by Mark.Satterthwaite Merging CL #2716418: Fix UE-15228 'Crash Report Client doesn't restart into project editor on Mac' by reporting the original command line supplied by LaunchMac, not the modified one that strips the project name. The CRC can then relaunch as expected. #jira UE-15228 Change 2726421 on 2015/10/13 by Lee.Clark PS4 - Don't try to clear invalid targets Change 2727040 on 2015/10/13 by Michael.Trepka Merging CL 2724777 - Fixed splash screen rendering for images with DPI different than 72 Change 2729783 on 2015/10/15 by Keith.Judge Fix huge memory leak in Test/Shipping configurations, caused because I am a numpty. Change 2729847 on 2015/10/15 by Mark.Satterthwaite Merging CL #2729846: On OS X unconstrain windows from the dimension of the parent display when in Windowed mode - it is OK for them to be larger in this case. They do need to be repositioned if on the Primary display so that they don't creep under the menu bar and become unmovable/unclosable and Fullscreen windows still need to be constrained to a single display. We can now take screenshots of windows that are larger than the display & not get grey bars beyond the cutoff. #jira UE-21992 Change 2729865 on 2015/10/15 by Keith.Judge Fast semantics - Finish up resource transitions, adding resource decompression where appropriate and using non-fast clears where we can't determine the resource transition. Change 2729897 on 2015/10/15 by Keith.Judge Fast Semantics - Make sure all GetData() calls are made safe with GPU fences. Change 2729972 on 2015/10/15 by Keith.Judge Removed the last vestiges of ID3D11DeviceContext/ID3D11DeviceContext1 from the Xbox RHI. Everything now uses ID3D11DeviceContextX directly. This should be marginally quicker as it stops a double call to ClearState(). Change 2731503 on 2015/10/16 by Keith.Judge Added _XDK_VERSION to the DDC key for textures, which should solve the issue of the tiling mode changing in August XDK (and future changes Microsoft may inflict). Change 2731596 on 2015/10/16 by Keith.Judge Fast Semantics - Add deferred resource deletion queue to make deleted resources be actually deleted a number of frames later so that the GPU is definitely finished with them. Hooked up the temporary SRVs for dynamic VBs as a first step. Change 2731928 on 2015/10/16 by Michael.Trepka PR #1659: Mac/Build.sh handles additional arguments (Contributed by judgeaxl) Change 2731934 on 2015/10/16 by Michael.Trepka PR #1618: added clang 3.7.0 -Wshift-negative-value ignore in JpegImageWrapper.cpp (Contributed by bsekura) Change 2732018 on 2015/10/16 by Mark.Satterthwaite Emit a shader code cache for each platforms requested shader formats, this is separate to the targeted formats as not all can or need to be cached. - The implementation extends the ShaderCache's hooks in FShaderResource's serialisation function to capture the required shaders. - Each target platform has its own list of cached shader formats, analogous to the list of targeted RHIs. Presently only the Mac implements this. - Code cached shaders are now compressed (for size) to reduce the overhead associated with keeping all the shader code around - this works esp. well for text-based formats like GLSL. Change 2732365 on 2015/10/16 by Josh.Adams - Packaging a TVOS .ipa now works (still haven't tried any of the Editor integration like Launch On) Change 2733170 on 2015/10/18 by Terence.Burns Fix for Android IAP query not returning entire inventory. Change 2733174 on 2015/10/18 by Terence.Burns Fix Movie player issue where wait for movie to finish isnt being respected. Seems a stray bUserCanceled event flag was causing this not to be observed. Added some verbose logging to apple movie player. Change 2733488 on 2015/10/19 by Mark.Satterthwaite Added the ability to merge the .ushadercache files used by the ShaderCache to store shader & draw state information. - Fixed a bug that would cause invalid shader membership and draw state information to be logged. - Added a separate command-line tool to merge shader cache files, currently Mac-only but in theory should work on other platforms too. Change 2735226 on 2015/10/20 by Mark.Satterthwaite Fix temporal AA rendering on GL/Mac OS X - you can't rely on EyeAdaptation values unless SM5 is available so only perform that code on SM5 & we must correctly clamp saturate(NaN) to 0 as the current hlslcc won't do that for us (& is required by the HLSL spec). The latter used to be clamped in the AA_ALPHA && AA_VELOCITY_WEIGHTING code block that was removed recently. #jira UE-21214 #jira UE-19913 Change 2736722 on 2015/10/21 by Daniel.Lamb Improved performance of cooking stats system. Change 2737172 on 2015/10/21 by Daniel.Lamb Improved cooking stats performance for ddc stats.
2015-12-10 16:56:55 -05:00
virtual bool GetCachedData(const TCHAR* CacheKey, TArray<uint8>& Data) override
{
Copying //UE4/Dev-Platform to Dev-Main (//UE4/Dev-Main) Change 2783376 on 2015/11/30 by Nick.Shin upgrading emscripten SDK to 1.35.9 following instruction from the README file Change 2787414 on 2015/12/02 by Nick.Shin upgrading emscripten to 1.35.0 removing old SDK and tools for Mac and Win64 Change 2790218 on 2015/12/04 by Nick.Shin merge (CL: #2790164) from //UE4/Dev-Physics to //UE4/Dev-Platform PhysX HTML5 bc files Change 2794786 on 2015/12/08 by Nick.Shin merge CL #2794757 part 1 of 2 from //UE4/Dev-Physics/PhysX/PhysX_3.3/Lib/html5 to //UE4/Dev-Platform/Engine/Source/ThirdParty/PhysX/PhysX-3.3/lib/HTML5/ Change 2794789 on 2015/12/08 by Nick.Shin merge CL #2794758 part 2 of 2 from //UE4/Dev-Physics/PhysX/PhysX_3.3/Lib/html5 to //UE4/Dev-Platform/Engine/Source/ThirdParty/PhysX/PhysX-3.3/lib/HTML5/ Change 2799151 on 2015/12/10 by Dmitry.Rekman Guarantee XGE.xml sorting order for 10+ builds. - A licensee pointed out the problem that AutomationTool.UE4Build.FindXGEFiles() sorts the files by filename, so e.g. UBTExport.10.xge.xml takes priority over UBTExport.2.xge.xml. #codereview Ben.Marsh Change 2799440 on 2015/12/11 by Mark.Satterthwaite Duplicate CL #2790251: Temporarily revert some of the changes for Mac mouse cursor locking as they were causing more problems than they solved. Change 2799441 on 2015/12/11 by Mark.Satterthwaite Duplicate CL #2796111 & #2796158: Fix cooking shader cache files - it wasn't being enabled despite a cached shader format being listed. Change 2799442 on 2015/12/11 by Mark.Satterthwaite Duplicate CL #2797758: Defer calls to AUGraphUpdate into FCoreAudioDevice::UpdateHardware - this call will synchronise the calling thread with the CoreAudio thread/run-loop so that the CoreAudio graph is safe to modify and this may incur a significant stall. This means it is far more efficient to amortise the cost of all changes to the graph with a single call. To ensure correctness the audio format conversion components are cached and disposed of after the call to AUGraphUpdate so that any existing operations on the CoreAudio thread are completed prior to disposal. Change 2799601 on 2015/12/11 by Mark.Satterthwaite Implement background reading of NSPipe's in Mac ExecProcess to avoid the sub-process blocking trying to write to the meagre 8kb internal buffers. This may fix problems with SVN on Mac. Change 2799657 on 2015/12/11 by Mark.Satterthwaite Remove the hlslcc major version from the Metal and OpenGL shader formats to ensure that there are enough bits to represent the different version components. There's no expectation that the major version of hlslcc will change and it will soon be removed entirely. Change 2799691 on 2015/12/11 by Mark.Satterthwaite Merging final internal-only changes from WWDC. Change 2800182 on 2015/12/11 by Mark.Satterthwaite Capture the system.log contents from the moment we boot to the point we crash to report GPU restarts and other system errors not written into our own logs. Change 2801395 on 2015/12/14 by Mark.Satterthwaite Fix the Metal shader compiler so that it properly reports the number of sampler objects in use, not the number of textures as Metal separates its 16 samplers and up-to 128 textures in a single shader stage, like D3D and unlike OpenGL. This fixes a lot of material compile errors in newer projects which aren't being designed for obsolete OpenGL. Change 2801653 on 2015/12/14 by Daniel.Lamb Load package differ can now diff header part of packages. Changed the way IsChildCooker is handled improves performance of multiprocess cooker. Change 2801655 on 2015/12/14 by Daniel.Lamb Added cooker warning to resave packages if they don't have collision data for their static meshes. Added NavCollision creation on static mesh import so that we save out the NavCollision. Change 2801923 on 2015/12/14 by Daniel.Lamb Fix compilation error with CreateLoader. Change 2802076 on 2015/12/14 by Daniel.Lamb Remove some debugging assistance code. Change 2803207 on 2015/12/15 by Mark.Satterthwaite Add missing Metal formats for PF_R16_SINT/UINT. Change 2803254 on 2015/12/15 by Mark.Satterthwaite Add additional uint/2/3/4 overrides for SV_Target(x) to MetalUtils and when generating the output variable look for an exact type match before restoring to the first match with the correct number of elements. This ensures that we generate uint/2/3/4 writes when required for CopyStencilToLightingChannelsPS without breaking anything else. Change 2803259 on 2015/12/15 by Mark.Satterthwaite Fix stencil texture swizzle for Metal which uses .x not .g for stencil value. Change 2803262 on 2015/12/15 by Mark.Satterthwaite Fix FMetalRHICommandContext::RHISetScissorRect handling 0 sized rects when RHISetScissorRect is called before RHISetViewport. Change 2803321 on 2015/12/15 by Mark.Satterthwaite Duplicate CL #2786291: Fix Metal validation errors caused by incorrect instance count and also a crash-bug caused by accessing a defunct depth-stencil texture. This should be enough to ensure Metal works even if you've been playing previously with OpenGL. Change 2803413 on 2015/12/15 by Mark.Satterthwaite Workaround the Material Editor's unfortunate habit of rendering tiles without a depth/stencil-buffer attached despite tiles wanting to write to depth - in Metal we have to create a temporary Depth-Stencil texture so that we don't crash the driver because it won't rewrite the shaders for us (unlike D3D/GL). Change 2806247 on 2015/12/16 by Daniel.Lamb Fixed UParticleRequiredModule deterministic cook issue. #codereview Olaf.Piesche Change 2806834 on 2015/12/17 by Mark.Satterthwaite Temporarily work around absence of Checked & Shipping APEX/PhysX binaries on Mac. Change 2807017 on 2015/12/17 by Mark.Satterthwaite Handle the shader cache being initialised for cooking multiple times until I can sort out the implementation properly. Change 2807027 on 2015/12/17 by Daniel.Lamb Enabled DDC stats.
2016-01-19 09:54:25 -05:00
#if ENABLE_DDC_STATS
static FName NAME_GetCachedData(TEXT("GetCachedData"));
FDDCScopeStatHelper Stat(CacheKey, NAME_GetCachedData);
static FName NAME_FileDDCPath(TEXT("FileDDCPath"));
static FName NAME_Retrieved(TEXT("Retrieved"));
Stat.AddTag(NAME_FileDDCPath, CachePath);
#endif
check(!bFailed);
FString Filename = BuildFilename(CacheKey);
double StartTime = FPlatformTime::Seconds();
if (FFileHelper::LoadFileToArray(Data,*Filename,FILEREAD_Silent))
{
if(!GIsBuildMachine)
{
double ReadDuration = FPlatformTime::Seconds() - StartTime;
double ReadSpeed = ReadDuration > 5.0 ? (Data.Num() / ReadDuration) / (1024.0 * 1024.0) : 100.0;
// Slower than 0.5MB/s?
UE_CLOG(ReadSpeed < 0.5, LogDerivedDataCache, Warning, TEXT("%s is very slow (%.2lfMB/s) when accessing %s, consider disabling it."), *CachePath, ReadSpeed, *Filename);
}
UE_LOG(LogDerivedDataCache, Verbose, TEXT("FileSystemDerivedDataBackend: Cache hit on %s"),*Filename);
Copying //UE4/Dev-Platform to Dev-Main (//UE4/Dev-Main) Change 2783376 on 2015/11/30 by Nick.Shin upgrading emscripten SDK to 1.35.9 following instruction from the README file Change 2787414 on 2015/12/02 by Nick.Shin upgrading emscripten to 1.35.0 removing old SDK and tools for Mac and Win64 Change 2790218 on 2015/12/04 by Nick.Shin merge (CL: #2790164) from //UE4/Dev-Physics to //UE4/Dev-Platform PhysX HTML5 bc files Change 2794786 on 2015/12/08 by Nick.Shin merge CL #2794757 part 1 of 2 from //UE4/Dev-Physics/PhysX/PhysX_3.3/Lib/html5 to //UE4/Dev-Platform/Engine/Source/ThirdParty/PhysX/PhysX-3.3/lib/HTML5/ Change 2794789 on 2015/12/08 by Nick.Shin merge CL #2794758 part 2 of 2 from //UE4/Dev-Physics/PhysX/PhysX_3.3/Lib/html5 to //UE4/Dev-Platform/Engine/Source/ThirdParty/PhysX/PhysX-3.3/lib/HTML5/ Change 2799151 on 2015/12/10 by Dmitry.Rekman Guarantee XGE.xml sorting order for 10+ builds. - A licensee pointed out the problem that AutomationTool.UE4Build.FindXGEFiles() sorts the files by filename, so e.g. UBTExport.10.xge.xml takes priority over UBTExport.2.xge.xml. #codereview Ben.Marsh Change 2799440 on 2015/12/11 by Mark.Satterthwaite Duplicate CL #2790251: Temporarily revert some of the changes for Mac mouse cursor locking as they were causing more problems than they solved. Change 2799441 on 2015/12/11 by Mark.Satterthwaite Duplicate CL #2796111 & #2796158: Fix cooking shader cache files - it wasn't being enabled despite a cached shader format being listed. Change 2799442 on 2015/12/11 by Mark.Satterthwaite Duplicate CL #2797758: Defer calls to AUGraphUpdate into FCoreAudioDevice::UpdateHardware - this call will synchronise the calling thread with the CoreAudio thread/run-loop so that the CoreAudio graph is safe to modify and this may incur a significant stall. This means it is far more efficient to amortise the cost of all changes to the graph with a single call. To ensure correctness the audio format conversion components are cached and disposed of after the call to AUGraphUpdate so that any existing operations on the CoreAudio thread are completed prior to disposal. Change 2799601 on 2015/12/11 by Mark.Satterthwaite Implement background reading of NSPipe's in Mac ExecProcess to avoid the sub-process blocking trying to write to the meagre 8kb internal buffers. This may fix problems with SVN on Mac. Change 2799657 on 2015/12/11 by Mark.Satterthwaite Remove the hlslcc major version from the Metal and OpenGL shader formats to ensure that there are enough bits to represent the different version components. There's no expectation that the major version of hlslcc will change and it will soon be removed entirely. Change 2799691 on 2015/12/11 by Mark.Satterthwaite Merging final internal-only changes from WWDC. Change 2800182 on 2015/12/11 by Mark.Satterthwaite Capture the system.log contents from the moment we boot to the point we crash to report GPU restarts and other system errors not written into our own logs. Change 2801395 on 2015/12/14 by Mark.Satterthwaite Fix the Metal shader compiler so that it properly reports the number of sampler objects in use, not the number of textures as Metal separates its 16 samplers and up-to 128 textures in a single shader stage, like D3D and unlike OpenGL. This fixes a lot of material compile errors in newer projects which aren't being designed for obsolete OpenGL. Change 2801653 on 2015/12/14 by Daniel.Lamb Load package differ can now diff header part of packages. Changed the way IsChildCooker is handled improves performance of multiprocess cooker. Change 2801655 on 2015/12/14 by Daniel.Lamb Added cooker warning to resave packages if they don't have collision data for their static meshes. Added NavCollision creation on static mesh import so that we save out the NavCollision. Change 2801923 on 2015/12/14 by Daniel.Lamb Fix compilation error with CreateLoader. Change 2802076 on 2015/12/14 by Daniel.Lamb Remove some debugging assistance code. Change 2803207 on 2015/12/15 by Mark.Satterthwaite Add missing Metal formats for PF_R16_SINT/UINT. Change 2803254 on 2015/12/15 by Mark.Satterthwaite Add additional uint/2/3/4 overrides for SV_Target(x) to MetalUtils and when generating the output variable look for an exact type match before restoring to the first match with the correct number of elements. This ensures that we generate uint/2/3/4 writes when required for CopyStencilToLightingChannelsPS without breaking anything else. Change 2803259 on 2015/12/15 by Mark.Satterthwaite Fix stencil texture swizzle for Metal which uses .x not .g for stencil value. Change 2803262 on 2015/12/15 by Mark.Satterthwaite Fix FMetalRHICommandContext::RHISetScissorRect handling 0 sized rects when RHISetScissorRect is called before RHISetViewport. Change 2803321 on 2015/12/15 by Mark.Satterthwaite Duplicate CL #2786291: Fix Metal validation errors caused by incorrect instance count and also a crash-bug caused by accessing a defunct depth-stencil texture. This should be enough to ensure Metal works even if you've been playing previously with OpenGL. Change 2803413 on 2015/12/15 by Mark.Satterthwaite Workaround the Material Editor's unfortunate habit of rendering tiles without a depth/stencil-buffer attached despite tiles wanting to write to depth - in Metal we have to create a temporary Depth-Stencil texture so that we don't crash the driver because it won't rewrite the shaders for us (unlike D3D/GL). Change 2806247 on 2015/12/16 by Daniel.Lamb Fixed UParticleRequiredModule deterministic cook issue. #codereview Olaf.Piesche Change 2806834 on 2015/12/17 by Mark.Satterthwaite Temporarily work around absence of Checked & Shipping APEX/PhysX binaries on Mac. Change 2807017 on 2015/12/17 by Mark.Satterthwaite Handle the shader cache being initialised for cooking multiple times until I can sort out the implementation properly. Change 2807027 on 2015/12/17 by Daniel.Lamb Enabled DDC stats.
2016-01-19 09:54:25 -05:00
#if ENABLE_DDC_STATS
Stat.AddTag(NAME_Retrieved, true);
#endif
return true;
}
UE_LOG(LogDerivedDataCache, Verbose, TEXT("FileSystemDerivedDataBackend: Cache miss on %s"),*Filename);
Data.Empty();
Copying //UE4/Dev-Platform to Dev-Main (//UE4/Dev-Main) Change 2783376 on 2015/11/30 by Nick.Shin upgrading emscripten SDK to 1.35.9 following instruction from the README file Change 2787414 on 2015/12/02 by Nick.Shin upgrading emscripten to 1.35.0 removing old SDK and tools for Mac and Win64 Change 2790218 on 2015/12/04 by Nick.Shin merge (CL: #2790164) from //UE4/Dev-Physics to //UE4/Dev-Platform PhysX HTML5 bc files Change 2794786 on 2015/12/08 by Nick.Shin merge CL #2794757 part 1 of 2 from //UE4/Dev-Physics/PhysX/PhysX_3.3/Lib/html5 to //UE4/Dev-Platform/Engine/Source/ThirdParty/PhysX/PhysX-3.3/lib/HTML5/ Change 2794789 on 2015/12/08 by Nick.Shin merge CL #2794758 part 2 of 2 from //UE4/Dev-Physics/PhysX/PhysX_3.3/Lib/html5 to //UE4/Dev-Platform/Engine/Source/ThirdParty/PhysX/PhysX-3.3/lib/HTML5/ Change 2799151 on 2015/12/10 by Dmitry.Rekman Guarantee XGE.xml sorting order for 10+ builds. - A licensee pointed out the problem that AutomationTool.UE4Build.FindXGEFiles() sorts the files by filename, so e.g. UBTExport.10.xge.xml takes priority over UBTExport.2.xge.xml. #codereview Ben.Marsh Change 2799440 on 2015/12/11 by Mark.Satterthwaite Duplicate CL #2790251: Temporarily revert some of the changes for Mac mouse cursor locking as they were causing more problems than they solved. Change 2799441 on 2015/12/11 by Mark.Satterthwaite Duplicate CL #2796111 & #2796158: Fix cooking shader cache files - it wasn't being enabled despite a cached shader format being listed. Change 2799442 on 2015/12/11 by Mark.Satterthwaite Duplicate CL #2797758: Defer calls to AUGraphUpdate into FCoreAudioDevice::UpdateHardware - this call will synchronise the calling thread with the CoreAudio thread/run-loop so that the CoreAudio graph is safe to modify and this may incur a significant stall. This means it is far more efficient to amortise the cost of all changes to the graph with a single call. To ensure correctness the audio format conversion components are cached and disposed of after the call to AUGraphUpdate so that any existing operations on the CoreAudio thread are completed prior to disposal. Change 2799601 on 2015/12/11 by Mark.Satterthwaite Implement background reading of NSPipe's in Mac ExecProcess to avoid the sub-process blocking trying to write to the meagre 8kb internal buffers. This may fix problems with SVN on Mac. Change 2799657 on 2015/12/11 by Mark.Satterthwaite Remove the hlslcc major version from the Metal and OpenGL shader formats to ensure that there are enough bits to represent the different version components. There's no expectation that the major version of hlslcc will change and it will soon be removed entirely. Change 2799691 on 2015/12/11 by Mark.Satterthwaite Merging final internal-only changes from WWDC. Change 2800182 on 2015/12/11 by Mark.Satterthwaite Capture the system.log contents from the moment we boot to the point we crash to report GPU restarts and other system errors not written into our own logs. Change 2801395 on 2015/12/14 by Mark.Satterthwaite Fix the Metal shader compiler so that it properly reports the number of sampler objects in use, not the number of textures as Metal separates its 16 samplers and up-to 128 textures in a single shader stage, like D3D and unlike OpenGL. This fixes a lot of material compile errors in newer projects which aren't being designed for obsolete OpenGL. Change 2801653 on 2015/12/14 by Daniel.Lamb Load package differ can now diff header part of packages. Changed the way IsChildCooker is handled improves performance of multiprocess cooker. Change 2801655 on 2015/12/14 by Daniel.Lamb Added cooker warning to resave packages if they don't have collision data for their static meshes. Added NavCollision creation on static mesh import so that we save out the NavCollision. Change 2801923 on 2015/12/14 by Daniel.Lamb Fix compilation error with CreateLoader. Change 2802076 on 2015/12/14 by Daniel.Lamb Remove some debugging assistance code. Change 2803207 on 2015/12/15 by Mark.Satterthwaite Add missing Metal formats for PF_R16_SINT/UINT. Change 2803254 on 2015/12/15 by Mark.Satterthwaite Add additional uint/2/3/4 overrides for SV_Target(x) to MetalUtils and when generating the output variable look for an exact type match before restoring to the first match with the correct number of elements. This ensures that we generate uint/2/3/4 writes when required for CopyStencilToLightingChannelsPS without breaking anything else. Change 2803259 on 2015/12/15 by Mark.Satterthwaite Fix stencil texture swizzle for Metal which uses .x not .g for stencil value. Change 2803262 on 2015/12/15 by Mark.Satterthwaite Fix FMetalRHICommandContext::RHISetScissorRect handling 0 sized rects when RHISetScissorRect is called before RHISetViewport. Change 2803321 on 2015/12/15 by Mark.Satterthwaite Duplicate CL #2786291: Fix Metal validation errors caused by incorrect instance count and also a crash-bug caused by accessing a defunct depth-stencil texture. This should be enough to ensure Metal works even if you've been playing previously with OpenGL. Change 2803413 on 2015/12/15 by Mark.Satterthwaite Workaround the Material Editor's unfortunate habit of rendering tiles without a depth/stencil-buffer attached despite tiles wanting to write to depth - in Metal we have to create a temporary Depth-Stencil texture so that we don't crash the driver because it won't rewrite the shaders for us (unlike D3D/GL). Change 2806247 on 2015/12/16 by Daniel.Lamb Fixed UParticleRequiredModule deterministic cook issue. #codereview Olaf.Piesche Change 2806834 on 2015/12/17 by Mark.Satterthwaite Temporarily work around absence of Checked & Shipping APEX/PhysX binaries on Mac. Change 2807017 on 2015/12/17 by Mark.Satterthwaite Handle the shader cache being initialised for cooking multiple times until I can sort out the implementation properly. Change 2807027 on 2015/12/17 by Daniel.Lamb Enabled DDC stats.
2016-01-19 09:54:25 -05:00
#if ENABLE_DDC_STATS
Stat.AddTag(NAME_Retrieved, false);
#endif
return false;
}
/**
* Asynchronous, fire-and-forget placement of a cache item
*
* @param CacheKey Alphanumeric+underscore key of this cache item
* @param OutData Buffer containing the data to cache, can be destroyed after the call returns, immediately
* @param bPutEvenIfExists If true, then do not attempt skip the put even if CachedDataProbablyExists returns true
*/
Copying //UE4/Dev-Platform to //UE4/Main ========================== MAJOR FEATURES + CHANGES ========================== Change 2719147 on 2015/10/07 by Mark.Satterthwaite Allow the shader cache to perform some precompilation synchronously on load before falling back to asynchronous compilation to balance load times against total time spent precompiling. Added a stat to the group that reports how long the precompile has been running until it completes so it is easier to track. Change 2719182 on 2015/10/07 by Mark.Satterthwaite Refactor the ShaderCache's internal data structures and change the way we handle recording whether a particular predraw state has been submitted to try and make it more efficient. Change 2719185 on 2015/10/07 by Mark.Satterthwaite Merging CL #2717701: Try and fix random crashes on Mac when manipulating bound-shader-states caused by ShaderCache potentially providing a bogus shader state pointer on exit from predraw. Change 2719434 on 2015/10/07 by Mark.Satterthwaite Make sure that Mac ensures reports have a source context and a sane callstack when sent to the crash-reports server. Change 2724764 on 2015/10/12 by Josh.Adams [Initial AppleTV support] Merging //depot/YakBranch/... to //UE4/Dev-Platform/... Change 2726266 on 2015/10/13 by Lee.Clark PS4 - Calc reserve size required for DMA copy when using unsafe command buffers Change 2726401 on 2015/10/13 by Mark.Satterthwaite Merging CL #2716418: Fix UE-15228 'Crash Report Client doesn't restart into project editor on Mac' by reporting the original command line supplied by LaunchMac, not the modified one that strips the project name. The CRC can then relaunch as expected. #jira UE-15228 Change 2726421 on 2015/10/13 by Lee.Clark PS4 - Don't try to clear invalid targets Change 2727040 on 2015/10/13 by Michael.Trepka Merging CL 2724777 - Fixed splash screen rendering for images with DPI different than 72 Change 2729783 on 2015/10/15 by Keith.Judge Fix huge memory leak in Test/Shipping configurations, caused because I am a numpty. Change 2729847 on 2015/10/15 by Mark.Satterthwaite Merging CL #2729846: On OS X unconstrain windows from the dimension of the parent display when in Windowed mode - it is OK for them to be larger in this case. They do need to be repositioned if on the Primary display so that they don't creep under the menu bar and become unmovable/unclosable and Fullscreen windows still need to be constrained to a single display. We can now take screenshots of windows that are larger than the display & not get grey bars beyond the cutoff. #jira UE-21992 Change 2729865 on 2015/10/15 by Keith.Judge Fast semantics - Finish up resource transitions, adding resource decompression where appropriate and using non-fast clears where we can't determine the resource transition. Change 2729897 on 2015/10/15 by Keith.Judge Fast Semantics - Make sure all GetData() calls are made safe with GPU fences. Change 2729972 on 2015/10/15 by Keith.Judge Removed the last vestiges of ID3D11DeviceContext/ID3D11DeviceContext1 from the Xbox RHI. Everything now uses ID3D11DeviceContextX directly. This should be marginally quicker as it stops a double call to ClearState(). Change 2731503 on 2015/10/16 by Keith.Judge Added _XDK_VERSION to the DDC key for textures, which should solve the issue of the tiling mode changing in August XDK (and future changes Microsoft may inflict). Change 2731596 on 2015/10/16 by Keith.Judge Fast Semantics - Add deferred resource deletion queue to make deleted resources be actually deleted a number of frames later so that the GPU is definitely finished with them. Hooked up the temporary SRVs for dynamic VBs as a first step. Change 2731928 on 2015/10/16 by Michael.Trepka PR #1659: Mac/Build.sh handles additional arguments (Contributed by judgeaxl) Change 2731934 on 2015/10/16 by Michael.Trepka PR #1618: added clang 3.7.0 -Wshift-negative-value ignore in JpegImageWrapper.cpp (Contributed by bsekura) Change 2732018 on 2015/10/16 by Mark.Satterthwaite Emit a shader code cache for each platforms requested shader formats, this is separate to the targeted formats as not all can or need to be cached. - The implementation extends the ShaderCache's hooks in FShaderResource's serialisation function to capture the required shaders. - Each target platform has its own list of cached shader formats, analogous to the list of targeted RHIs. Presently only the Mac implements this. - Code cached shaders are now compressed (for size) to reduce the overhead associated with keeping all the shader code around - this works esp. well for text-based formats like GLSL. Change 2732365 on 2015/10/16 by Josh.Adams - Packaging a TVOS .ipa now works (still haven't tried any of the Editor integration like Launch On) Change 2733170 on 2015/10/18 by Terence.Burns Fix for Android IAP query not returning entire inventory. Change 2733174 on 2015/10/18 by Terence.Burns Fix Movie player issue where wait for movie to finish isnt being respected. Seems a stray bUserCanceled event flag was causing this not to be observed. Added some verbose logging to apple movie player. Change 2733488 on 2015/10/19 by Mark.Satterthwaite Added the ability to merge the .ushadercache files used by the ShaderCache to store shader & draw state information. - Fixed a bug that would cause invalid shader membership and draw state information to be logged. - Added a separate command-line tool to merge shader cache files, currently Mac-only but in theory should work on other platforms too. Change 2735226 on 2015/10/20 by Mark.Satterthwaite Fix temporal AA rendering on GL/Mac OS X - you can't rely on EyeAdaptation values unless SM5 is available so only perform that code on SM5 & we must correctly clamp saturate(NaN) to 0 as the current hlslcc won't do that for us (& is required by the HLSL spec). The latter used to be clamped in the AA_ALPHA && AA_VELOCITY_WEIGHTING code block that was removed recently. #jira UE-21214 #jira UE-19913 Change 2736722 on 2015/10/21 by Daniel.Lamb Improved performance of cooking stats system. Change 2737172 on 2015/10/21 by Daniel.Lamb Improved cooking stats performance for ddc stats.
2015-12-10 16:56:55 -05:00
virtual void PutCachedData(const TCHAR* CacheKey, TArray<uint8>& Data, bool bPutEvenIfExists) override
{
Copying //UE4/Dev-Platform to Dev-Main (//UE4/Dev-Main) Change 2783376 on 2015/11/30 by Nick.Shin upgrading emscripten SDK to 1.35.9 following instruction from the README file Change 2787414 on 2015/12/02 by Nick.Shin upgrading emscripten to 1.35.0 removing old SDK and tools for Mac and Win64 Change 2790218 on 2015/12/04 by Nick.Shin merge (CL: #2790164) from //UE4/Dev-Physics to //UE4/Dev-Platform PhysX HTML5 bc files Change 2794786 on 2015/12/08 by Nick.Shin merge CL #2794757 part 1 of 2 from //UE4/Dev-Physics/PhysX/PhysX_3.3/Lib/html5 to //UE4/Dev-Platform/Engine/Source/ThirdParty/PhysX/PhysX-3.3/lib/HTML5/ Change 2794789 on 2015/12/08 by Nick.Shin merge CL #2794758 part 2 of 2 from //UE4/Dev-Physics/PhysX/PhysX_3.3/Lib/html5 to //UE4/Dev-Platform/Engine/Source/ThirdParty/PhysX/PhysX-3.3/lib/HTML5/ Change 2799151 on 2015/12/10 by Dmitry.Rekman Guarantee XGE.xml sorting order for 10+ builds. - A licensee pointed out the problem that AutomationTool.UE4Build.FindXGEFiles() sorts the files by filename, so e.g. UBTExport.10.xge.xml takes priority over UBTExport.2.xge.xml. #codereview Ben.Marsh Change 2799440 on 2015/12/11 by Mark.Satterthwaite Duplicate CL #2790251: Temporarily revert some of the changes for Mac mouse cursor locking as they were causing more problems than they solved. Change 2799441 on 2015/12/11 by Mark.Satterthwaite Duplicate CL #2796111 & #2796158: Fix cooking shader cache files - it wasn't being enabled despite a cached shader format being listed. Change 2799442 on 2015/12/11 by Mark.Satterthwaite Duplicate CL #2797758: Defer calls to AUGraphUpdate into FCoreAudioDevice::UpdateHardware - this call will synchronise the calling thread with the CoreAudio thread/run-loop so that the CoreAudio graph is safe to modify and this may incur a significant stall. This means it is far more efficient to amortise the cost of all changes to the graph with a single call. To ensure correctness the audio format conversion components are cached and disposed of after the call to AUGraphUpdate so that any existing operations on the CoreAudio thread are completed prior to disposal. Change 2799601 on 2015/12/11 by Mark.Satterthwaite Implement background reading of NSPipe's in Mac ExecProcess to avoid the sub-process blocking trying to write to the meagre 8kb internal buffers. This may fix problems with SVN on Mac. Change 2799657 on 2015/12/11 by Mark.Satterthwaite Remove the hlslcc major version from the Metal and OpenGL shader formats to ensure that there are enough bits to represent the different version components. There's no expectation that the major version of hlslcc will change and it will soon be removed entirely. Change 2799691 on 2015/12/11 by Mark.Satterthwaite Merging final internal-only changes from WWDC. Change 2800182 on 2015/12/11 by Mark.Satterthwaite Capture the system.log contents from the moment we boot to the point we crash to report GPU restarts and other system errors not written into our own logs. Change 2801395 on 2015/12/14 by Mark.Satterthwaite Fix the Metal shader compiler so that it properly reports the number of sampler objects in use, not the number of textures as Metal separates its 16 samplers and up-to 128 textures in a single shader stage, like D3D and unlike OpenGL. This fixes a lot of material compile errors in newer projects which aren't being designed for obsolete OpenGL. Change 2801653 on 2015/12/14 by Daniel.Lamb Load package differ can now diff header part of packages. Changed the way IsChildCooker is handled improves performance of multiprocess cooker. Change 2801655 on 2015/12/14 by Daniel.Lamb Added cooker warning to resave packages if they don't have collision data for their static meshes. Added NavCollision creation on static mesh import so that we save out the NavCollision. Change 2801923 on 2015/12/14 by Daniel.Lamb Fix compilation error with CreateLoader. Change 2802076 on 2015/12/14 by Daniel.Lamb Remove some debugging assistance code. Change 2803207 on 2015/12/15 by Mark.Satterthwaite Add missing Metal formats for PF_R16_SINT/UINT. Change 2803254 on 2015/12/15 by Mark.Satterthwaite Add additional uint/2/3/4 overrides for SV_Target(x) to MetalUtils and when generating the output variable look for an exact type match before restoring to the first match with the correct number of elements. This ensures that we generate uint/2/3/4 writes when required for CopyStencilToLightingChannelsPS without breaking anything else. Change 2803259 on 2015/12/15 by Mark.Satterthwaite Fix stencil texture swizzle for Metal which uses .x not .g for stencil value. Change 2803262 on 2015/12/15 by Mark.Satterthwaite Fix FMetalRHICommandContext::RHISetScissorRect handling 0 sized rects when RHISetScissorRect is called before RHISetViewport. Change 2803321 on 2015/12/15 by Mark.Satterthwaite Duplicate CL #2786291: Fix Metal validation errors caused by incorrect instance count and also a crash-bug caused by accessing a defunct depth-stencil texture. This should be enough to ensure Metal works even if you've been playing previously with OpenGL. Change 2803413 on 2015/12/15 by Mark.Satterthwaite Workaround the Material Editor's unfortunate habit of rendering tiles without a depth/stencil-buffer attached despite tiles wanting to write to depth - in Metal we have to create a temporary Depth-Stencil texture so that we don't crash the driver because it won't rewrite the shaders for us (unlike D3D/GL). Change 2806247 on 2015/12/16 by Daniel.Lamb Fixed UParticleRequiredModule deterministic cook issue. #codereview Olaf.Piesche Change 2806834 on 2015/12/17 by Mark.Satterthwaite Temporarily work around absence of Checked & Shipping APEX/PhysX binaries on Mac. Change 2807017 on 2015/12/17 by Mark.Satterthwaite Handle the shader cache being initialised for cooking multiple times until I can sort out the implementation properly. Change 2807027 on 2015/12/17 by Daniel.Lamb Enabled DDC stats.
2016-01-19 09:54:25 -05:00
#if ENABLE_DDC_STATS
static FName NAME_PutCachedData(TEXT("PutCachedData"));
FDDCScopeStatHelper Stat(CacheKey, NAME_PutCachedData);
static FName NAME_FileDDCPath(TEXT("FileDDCPath"));
Stat.AddTag(NAME_FileDDCPath, CachePath);
#endif
check(!bFailed);
if (!bReadOnly)
{
if (bPutEvenIfExists || !CachedDataProbablyExists(CacheKey))
{
check(Data.Num());
FString Filename = BuildFilename(CacheKey);
FString TempFilename(TEXT("temp."));
TempFilename += FGuid::NewGuid().ToString();
TempFilename = FPaths::GetPath(Filename) / TempFilename;
bool bResult;
{
bResult = FFileHelper::SaveArrayToFile(Data, *TempFilename);
}
if (bResult)
{
if (IFileManager::Get().FileSize(*TempFilename) == Data.Num())
{
bool DoMove = !CachedDataProbablyExists(CacheKey);
if (bPutEvenIfExists && !DoMove)
{
DoMove = true;
RemoveCachedData(CacheKey, /*bTransient=*/ false);
}
if (DoMove)
{
if (!IFileManager::Get().Move(*Filename, *TempFilename, true, true, false, true))
{
UE_LOG(LogDerivedDataCache, Log, TEXT("FFileSystemDerivedDataBackend: Move collision, attempt at redundant update, OK %s."),*Filename);
}
else
{
UE_LOG(LogDerivedDataCache, Verbose, TEXT("FFileSystemDerivedDataBackend: Successful cache put to %s"),*Filename);
}
}
}
else
{
UE_LOG(LogDerivedDataCache, Warning, TEXT("FFileSystemDerivedDataBackend: Temp file is short %s!"),*TempFilename);
}
}
else
{
UE_LOG(LogDerivedDataCache, Warning, TEXT("FFileSystemDerivedDataBackend: Could not write temp file %s!"),*TempFilename);
}
// if everything worked, this is not necessary, but we will make every effort to avoid leaving junk in the cache
if (FPaths::FileExists(TempFilename))
{
IFileManager::Get().Delete(*TempFilename, false, false, true);
}
}
}
}
void RemoveCachedData(const TCHAR* CacheKey, bool bTransient) override
{
check(!bFailed);
if (!bReadOnly && (!bTransient || bPurgeTransient))
{
FString Filename = BuildFilename(CacheKey);
if (bTransient)
{
UE_LOG(LogDerivedDataCache,Verbose,TEXT("Deleting transient cached data. Key=%s Filename=%s"),CacheKey,*Filename);
}
IFileManager::Get().Delete(*Filename, false, false, true);
}
}
private:
/**
* Threadsafe method to compute the filename from the cachekey, currently just adds a path and an extension.
*
* @param CacheKey Alphanumeric+underscore key of this cache item
* @return filename built from the cache key
*/
FString BuildFilename(const TCHAR* CacheKey)
{
FString Key = FString(CacheKey).ToUpper();
for (int32 i = 0; i < Key.Len(); i++)
{
check(FChar::IsAlnum(Key[i]) || FChar::IsUnderscore(Key[i]) || Key[i] == L'$');
}
uint32 Hash = FCrc::StrCrc_DEPRECATED(*Key);
// this creates a tree of 1000 directories
FString HashPath = FString::Printf(TEXT("%1d/%1d/%1d/"),(Hash/100)%10,(Hash/10)%10,Hash%10);
return CachePath / HashPath / Key + TEXT(".udd");
}
/** Base path we are storing the cache files in. **/
FString CachePath;
/** If true, do not attempt to write to this cache **/
bool bReadOnly;
/** If true, we failed to write to this directory and it did not contain anything so we should not be used **/
bool bFailed;
/** If true, CachedDataProbablyExists will update the file timestamps. */
bool bTouch;
/** If true, allow transient data to be removed from the cache. */
bool bPurgeTransient;
/** Age of file when it should be deleted from DDC cache. */
int32 DaysToDeleteUnusedFiles;
};
FDerivedDataBackendInterface* CreateFileSystemDerivedDataBackend(const TCHAR* CacheDirectory, bool bForceReadOnly /*= false*/, bool bTouchFiles /*= false*/, bool bPurgeTransient /*= false*/, bool bDeleteOldFiles /*= false*/, int32 InDaysToDeleteUnusedFiles /*= 60*/, int32 InMaxNumFoldersToCheck /*= -1*/, int32 InMaxContinuousFileChecks /*= -1*/)
{
FFileSystemDerivedDataBackend* FileDDB = new FFileSystemDerivedDataBackend(CacheDirectory, bForceReadOnly, bTouchFiles, bPurgeTransient, bDeleteOldFiles, InDaysToDeleteUnusedFiles, InMaxNumFoldersToCheck, InMaxContinuousFileChecks);
if (!FileDDB->IsUsable())
{
delete FileDDB;
FileDDB = NULL;
}
return FileDDB;
}