Commit Graph

81 Commits

Author SHA1 Message Date
Marc Audy
4562acb429 Fix shadow variables
[CL 2507160 by Marc Audy in Main branch]
2015-04-09 15:23:52 -04:00
Dan Oconnor
76e1440d85 Further changes from PVS-Studio, submitted without modification, reviewed with owners where I was unsure of the change
[CL 2500334 by Dan Oconnor in Main branch]
2015-04-02 16:31:18 -04:00
Mike Fricker
114458bf0f Clang warning fixes: Fixed missing 'override' specifiers
- Also removed some unreferenced functions that adding 'override' revealed

PR #1002 -- Thank you, Omar007!

[CL 2498415 by Mike Fricker in Main branch]
2015-04-01 07:20:55 -04:00
Robert Manuszewski
8fe5db30e3 Merging UE4-Streaming to UE4
- Linkers are no longer UObjects. Renamed ULinker, ULinkerLoad and ULinkerSave to FLinker, FLinkerLoad, FLinkerSave respectively
- Linkers are now associated with their UPackages
- Linker version is now stored in UPackages
- Async loading is now performed on a separate thread (if platform supports it and only in cooked builds), with the exception of PostLoad which is still done on the game thread
- Added UObject::IsPostLoadThreadSafe() function to determine if PostLoad is thread safe and can be executed on the async loading thread (defaults to false)
- UObject creation is now thread safe and can be performed on any thread
- Move many of the linker/UObject globals into FUObjectThreadContext (TLS)
- GetAsyncLoadPercentage() now takes PostLoad into account
- More async loading stats
- Added AtomicallySetFlags/ClearFlags to UObject
- Made FModuleManager thread safe.
- Added FGCScopeGuard as means of preventing GC from executing from non-game thread
- It's possible to disable async loading thread through ini settings.
- Cancelling async loading will now also trigger GC
- Implemented a basic version of async streaming priorities.

Change 2410813 by Mikolaj Sieluzycki:
	Change Sleep in while loop to ConditionalSleep in FMultiReaderSingleWriterGT
Change 2410734 by Mikolaj Sieluzycki:
	Make FModuleManager thread safe.
Change 2399879 by Mikolaj Sieluzycki:
	Basic version of async streaming priorities.
Change 2410707 by Mikolaj Sieluzycki:
	Implement conditional and no stat versions of sleep.
Change 2371939 by Robert Manuszewski:
	Async Loading Improvements: adding more stats (accumulators)
Change 2372403 by Robert Manuszewski:
	Fixing compile errors when STATs are not enabled
Change 2371526 by Robert Manuszewski:
	AsyncLoading Improvements (WIP)
Change 2407198 by Robert Manuszewski:
	Re-implementing delegate fixes for Async Loading
Change 2407425 by Robert Manuszewski:
	Re-implementing cancelling async loading in the async loading branch.
Change 2484362 by Robert Manuszewski:
	Making it possible to disable async loading thread through ini settings.
Change 2484744 by Robert Manuszewski:
	Minimizing locks in GC and other threads when handling UObjects
Change 2480190 by Robert Manuszewski:
	Fixing infinite stall after canceling async loading in non-cooked builds
Change 2484268 by Robert Manuszewski:
	Fixing crash when allocating permanent object pool.
Change 2489761 by Robert Manuszewski:
	Fixing BulkData using linker archive on the main thread even if the linker was created on the async loading thread.
Change 2493624 by Robert Manuszewski:
	Cancelling async loading will now also trigger GC
Change 2487881 by Robert Manuszewski:
	Making ShaderIdMap operations thread safe.
Change 2488067 by Robert Manuszewski:
	Fixing GetAsyncLoadPercentage. It will now also respect PostLoad.
Change 2458640 by Robert Manuszewski:
	Fixing crash in PIE
Change 2458825 by Robert Manuszewski:
	Fixing a few crashes when streaming and the package is missing.
Change 2476935 by Robert Manuszewski:
	Fixing crash while async loading ANavigationData
Change 2477361 by Robert Manuszewski:
	Fixing crashes in cooked game
Change 2480095 by Robert Manuszewski:
	Making FUObjectArray more thread safe
Change 2475443 by Robert Manuszewski:
	Re-enabling single-threaded async loading path for the editor and platforms that don't support multithreading.
Change 2475458 by Robert Manuszewski:
	Making sure bulk data is only loaded on a separate thread if it's not being loaded on the async loading thread.
Change 2476661 by Robert Manuszewski:
	Fixing FlushAsyncLoading not flushing everything
Change 2401089 by Jaroslaw Surowiec:
	Core - Added AtomicallySetFlags/ClearFlags to UObject, added a comment to ThisThreadAtomicallyClearedRFUnreachable

[CL 2498249 by Robert Manuszewski in Main branch]
2015-04-01 03:03:18 -04:00
Mark Satterthwaite
608acb6e7c Fix non-unity builds.
#codereview michael.trepka

[CL 2493613 by Mark Satterthwaite in Main branch]
2015-03-27 08:10:31 -04:00
Mark Satterthwaite
9d690116a6 Further optimisations for ShaderCache.
- Several GetTypeHash would produce only very narrow hash distributions, so these have been modified.
- FShaderDrawKey::GetTypeHash was particularly slow (around 4% of sampled time in Mac UT in Instruments) almost all in MemCrc32, so this has been replaced with a much simpler hash routine to bring it down to ~1% sampled time.
- FShaderDrawKey::operator== comparison order changed to try and fail earlier by testing from most-to-least varying attributes.
- Changed the way sampler-state & texture look-up works to avoid unnecessary map lookup.
#codereview michael.trepka

[CL 2493570 by Mark Satterthwaite in Main branch]
2015-03-27 07:20:23 -04:00
Mark Satterthwaite
9fe63a4308 In the shader-cache precompute the object hashes wherever possible to reduce the time spent searching maps, serialising the hashes to boot. Increments the current cache format version.
#codereview michael.trepka

[CL 2493555 by Mark Satterthwaite in Main branch]
2015-03-27 07:00:56 -04:00
Mark Satterthwaite
1f39e8f541 Fix a bug in early submission of compute shaders in the ShaderCache not using the correct hash.
#codereview michael.trepka, dmitry.rekman

[CL 2493544 by Mark Satterthwaite in Main branch]
2015-03-27 06:52:22 -04:00
Mark Satterthwaite
1e3b08f7f7 Disable the ShaderCache's draw-state logging by default in all circumstances since it is currently a significant performance impact and not all project use Shipping builds for release.
#codereview michael.trepka, dmitry.rekman

[CL 2493527 by Mark Satterthwaite in Main branch]
2015-03-27 06:31:34 -04:00
Mark Satterthwaite
835e8be727 Prevent the shader-cache from instantiating incompatible shader resources & crashing the RHI, requires exposing the existing ArePlatformsCompatible function from FShaderResource.
#codereview michael.trepka, dmitry.rekman

[CL 2493508 by Mark Satterthwaite in Main branch]
2015-03-27 06:12:37 -04:00
Rolando Caloca
cac9644426 UE4 - Get more info out of not reproducible crash (UE-11434)
[CL 2486684 by Rolando Caloca in Main branch]
2015-03-20 16:11:01 -04:00
Rolando Caloca
5063a906c8 UE4 - UE-12059 - Improve editor startup time
#codereview milo.yip

[CL 2485451 by Rolando Caloca in Main branch]
2015-03-19 19:11:09 -04:00
Daniel Lamb
e8558c8a9d Fixed sorting issue with vertex factory when serializing. Previously did not consider strings with different lengths different.
#codereview Peter.Sauerbrei, Josh.Adams

[CL 2471387 by Daniel Lamb in Main branch]
2015-03-06 13:31:04 -05:00
Marc Audy
daf220d485 Fix shadowed variables
[CL 2466748 by Marc Audy in Main branch]
2015-03-02 15:12:31 -05:00
Marc Audy
40fce97d17 Fix shadowed variables
[CL 2466246 by Marc Audy in Main branch]
2015-03-02 09:26:47 -05:00
Mark Satterthwaite
65e1a105de Shader caching has been updated to include the option to record draw-states used for each shader so that they may be pre-drawn to reduce in-driver hitching.
- This is especially important on OS X OpenGL where these hitches can be equivalent to several frames, so it is enabled by default for this platform.
- The logging of draw calls is turned on/off with r.UseShaderDrawLog and incurs a fixed overhead as all RHI state is tracked & recorded into the shader cache.
- The actual predrawing is turned on/off with r.UseShaderPredraw and requires an existing cache to be useful, the predrawing takes place at frame-end and can be controlled with r.PredrawBatchTime which the time in ms to spend predrawing each frame until complete, or -1 to do it in one go (currently the default).
- The shader cache is now also versioned with the game able to supply a version distinct from the engine, so that old caches may be invalidated if/when required.
- The shader cache is now compatible with OpenGL SM4 & SM5 on Windows & probably Linux too.
- It may not work correctly with desktop ES2 emulation as that is still untested.
- To make it easier to add to other RHIs the API has been made simper to avoid lots of exposed branches.

#codereview michael.trepka, dmitry.rekman

[CL 2460109 by Mark Satterthwaite in Main branch]
2015-02-25 08:13:48 -05:00
Daniel Lamb
4901c3eb76 Fixed FCompareShaderTypes so that shader types of different lengths don't accidently compare to the same value...
#codereview Daniel.Wright, Josh.Adams

[CL 2445274 by Daniel Lamb in Main branch]
2015-02-13 15:29:52 -05:00
Daniel Wright
22d1d6dc5f Reworked shader stream out support, now works properly with FShaderResource sharing
* GetStreamOutElements is a callback function on the shadertype, just like ModifyCompilationEnvironment
* If GetStreamOutElements is specified, the FShaderResource includes that shader type in its ID as it can't be shared with any other shader type.
* FShader is no longer a FRenderResource which solves some multiple initialization issues

#codereview Marcus.Wassmer

[CL 2430024 by Daniel Wright in Main branch]
2015-02-03 11:19:45 -05:00
Mark Satterthwaite
165c5a749c [INTEGRATE] Merged CL #2425500 from UE4-UT to Main
Fix crash on shutdown when ShaderCache has not been initialised.

[CL 2425502 by Mark Satterthwaite in Main branch]
2015-01-30 06:25:26 -05:00
Daniel Wright
ba3963fcaf Surfel Global Illumination with Distance Field shadowing
* Disabled by default, need a movable skylight with r.DistanceFieldGI enabled at load time (ConsoleVariables.ini)
* Surfels (oriented disks) are placed on mesh surfaces and capture diffuse color by evaluating the material with actual UVs and world position
* Surfels are lit and shadowed by ray tracing through mesh distance fields (directional light only so far)
* Irradiance cache records are lit with nearby Virtual Point Lights created from lit surfels.  Only using camera based LOD of the surfel representation and object based surfel culling, no hierarchy yet.
* Shadowing of the VPLs is provided by distance field cone tracing.  A depth visibility function is constructed along each of the 9 cone trace directions, and used to shadow the incoming VPL lighting.
* Component reregistration and transform updating causes surfels to be generated again which can be slow.  In the future only the material needs to be re-evaluated.
* Geometry shaders with stream out are now supported, by implementing FShader::GetStreamOutElements
* Compute shaders can now evaluate materal attributes like BaseColor
* SkyLight MaxOcclusionDistance increased to 10m, which is the minimum useful amount for GI

[CL 2424208 by Daniel Wright in Main branch]
2015-01-29 14:46:20 -05:00
Mark Satterthwaite
8ed8eec4ce [INTEGRATE] Merged CL #2424059 from UE4-UT to Main
Fix signed/unsigned mismatch in ShaderCache.h.

[CL 2424061 by Mark Satterthwaite in Main branch]
2015-01-29 13:12:39 -05:00
Mark Satterthwaite
a511ded42a Initial ShaderCore-level cache to start addressing shader hitches [UE-7536]. At present it is only configured by Mac OpenGL, though other APIs could use it. As all shaders & programs are cached it is inappropriate for memory constrained devices so it is only enabled by Desktop platforms.
- The consolve variable "r.UseShaderCaching" controls whether the cache should be used.
   - The cache has to be initialised and shutdown by the RHI.
   - All RHI shader types now contain the SHA hash of the compiled source when the cache is in use so that they can be identified efficiently.
   - All shaders are fetched from the cache rather than being created on-demand.
   - On shader deserialisation the new shader is sent to the render thread for creation & caching.
   - After each shader is cached all complete bound-shader-states that include that shader are constructed and cached.
   - Wrapped OpenGL glCreateShader & glCreateProgram to use name-caching as these operations can synchronise the entire OpenGL pipeline on OS X.

[CL 2423996 by Mark Satterthwaite in Main branch]
2015-01-29 12:34:05 -05:00
Rolando Caloca
6c2f4957bc UE4 - Add r.BasePassOutputsVelocity to DDC and fix the shader define so it only works with opaque & masked materials
[CL 2415847 by Rolando Caloca in Main branch]
2015-01-22 16:40:03 -05:00
Gil Gribb
9579281b0c UE4 - pack instance buffers into smaller space, using half4 etc
[CL 2412177 by Gil Gribb in Main branch]
2015-01-20 09:50:15 -05:00
Daniel Wright
a18361c8ed Removed shader parameter log spam
[CL 2402754 by Daniel Wright in Main branch]
2015-01-10 16:55:58 -05:00