2016-12-08 08:52:44 -05:00
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
2014-09-29 14:31:38 -04:00
// .
2014-06-05 16:38:54 -04:00
# include "ShaderCompilerCommon.h"
Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3209340)
#lockdown Nick.Penwarden
#rb none
==========================
MAJOR FEATURES + CHANGES
==========================
Change 3209340 on 2016/11/23 by Ben.Marsh
Convert UE4 codebase to an "include what you use" model - where every header just includes the dependencies it needs, rather than every source file including large monolithic headers like Engine.h and UnrealEd.h.
Measured full rebuild times around 2x faster using XGE on Windows, and improvements of 25% or more for incremental builds and full rebuilds on most other platforms.
* Every header now includes everything it needs to compile.
* There's a CoreMinimal.h header that gets you a set of ubiquitous types from Core (eg. FString, FName, TArray, FVector, etc...). Most headers now include this first.
* There's a CoreTypes.h header that sets up primitive UE4 types and build macros (int32, PLATFORM_WIN64, etc...). All headers in Core include this first, as does CoreMinimal.h.
* Every .cpp file includes its matching .h file first.
* This helps validate that each header is including everything it needs to compile.
* No engine code includes a monolithic header such as Engine.h or UnrealEd.h any more.
* You will get a warning if you try to include one of these from the engine. They still exist for compatibility with game projects and do not produce warnings when included there.
* There have only been minor changes to our internal games down to accommodate these changes. The intent is for this to be as seamless as possible.
* No engine code explicitly includes a precompiled header any more.
* We still use PCHs, but they're force-included on the compiler command line by UnrealBuildTool instead. This lets us tune what they contain without breaking any existing include dependencies.
* PCHs are generated by a tool to get a statistical amount of coverage for the source files using it, and I've seeded the new shared PCHs to contain any header included by > 15% of source files.
Tool used to generate this transform is at Engine\Source\Programs\IncludeTool.
[CL 3209342 by Ben Marsh in Main branch]
2016-11-23 15:48:37 -05:00
# include "Misc/Paths.h"
# include "Modules/ModuleManager.h"
Copying //UE4/Dev-Rendering to //UE4/Dev-Main (Source: //UE4/Dev-Rendering @ 3109293)
#lockdown Nick.Penwarden
#rb none
==========================
MAJOR FEATURES + CHANGES
==========================
Change 3091951 on 2016/08/17 by Chris.Bunner
(Duplicate) CL 3090919: Fixed edge case interactions in HLOD ray rejection logic in Lightmass.
Change 3093162 on 2016/08/18 by Ben.Woodhouse
Fix minor memory leak (missing delete of RT Heartbeat thread)
Change 3093470 on 2016/08/18 by Ben.Woodhouse
Fix minor leak in FMonitoredProcess - the Thread member would get leaked if the FMonitoredProcess was cancelled, because it gets NULLed without deleting it. Fix is to add a bool to keep track of whether the thread is running, rather than using the Thread pointer.
Also fixes a race condition where the FMonitoredProcess::Thread member could get initialized after the thread had completed. This would cause IsRunning to never return false, even if the thread has completed, and the editor would hang on startup (this was fixed by setting bIsRunning to true before creating the thread)
Change 3093698 on 2016/08/18 by Daniel.Wright
Translucent lighting volume draw event cleanup
Change 3093700 on 2016/08/18 by Daniel.Wright
Clamp on box reflection capture transition distance visualizer
Change 3093755 on 2016/08/18 by Ryan.Vance
Merging stereo planar reflections from Odin.
Change 3094060 on 2016/08/18 by Daniel.Wright
Fully featured base pass reflection captures with blending and parallax correction
* Used in the forward renderer when materials opt-in to 'High Quality Reflections'
* Used in the deferred renderer for translucent 'Surface ForwardShading' materials
* Reflection captures are culled to a frustum space grid using the same reverse linked-list method as lights in the forward renderer
* Fixed grid culling in stereo / splitscreen
* The ReflectionEnvironment compute shader used in the deferred path also uses the culled grid now which reduces its cost from .93ms -> .70ms on 970 GTX. PS4 cost is about the same.
* Capsule indirect self-shadowing is now reduced in the forward path to match deferred, and both are controlled by r.CapsuleIndirectShadowSelfShadowIntensity
* SetupHZB is now skipped when SSAO / SSR / HZB are all disabled
Change 3094160 on 2016/08/18 by Daniel.Wright
CIS fixes
Change 3094899 on 2016/08/19 by Ben.Woodhouse
Batching optimization for dragging components onto blueprints, reported on UDN. Adding 2300 static mesh actors now takes 3 seconds instead of 40 minutes.
https://udn.unrealengine.com/questions/305821/suspected-rhi-uniform-buffer-leak-when-adding-stat.html
#jira UE-34937
Change 3095256 on 2016/08/19 by Daniel.Wright
Disabled ISR warning spamming CIS
Change 3095468 on 2016/08/19 by Daniel.Wright
Fixed refcounting on hit proxy render targets
Change 3095470 on 2016/08/19 by Daniel.Wright
Added bVisibleInReflectionCaptures to primitive component, which is useful for hiding objects too close to the capture point
Change 3096274 on 2016/08/22 by Rolando.Caloca
DR - vk - added missing BC4
Change 3096291 on 2016/08/22 by Rolando.Caloca
DR - vk - Fix image views for some rendertarget formats
- Fix ImageViews on sub mips
Change 3096579 on 2016/08/22 by Rolando.Caloca
DR - vk - Fix rendering for shaders with no descriptors
Change 3096584 on 2016/08/22 by Rolando.Caloca
DR - vk - Fix 3d texture update
Change 3096813 on 2016/08/22 by Rolando.Caloca
DR - Fix GL linking errors
PR #2615
Change 3097062 on 2016/08/22 by Rolando.Caloca
DR - vk - Added unified mem flag
- Added Mip index into UAV
- Switched compute descriptor set index 0
Change 3097065 on 2016/08/22 by Rolando.Caloca
DR - vk - Framebuffer barriers now wait on STAGE_FRAGMENT_SHADER instead of STAGE_BOTTOM_OF_PIPE
Change 3097084 on 2016/08/22 by Daniel.Wright
Enabled r.VertexFoggingForOpaque by default to match other forward renderer choices (fast by default)
Change 3097086 on 2016/08/22 by Rolando.Caloca
DR - vk - Missed file
Change 3097943 on 2016/08/23 by Rolando.Caloca
DR - hlslcc - Remove duplicated definitions out into a common header
Change 3098166 on 2016/08/23 by Rolando.Caloca
DR - Custom Renderer callback after getting SceneColor
Change 3098418 on 2016/08/23 by Olaf.Piesche
Moving vertex factory dirtying to always happen in-editor for mesh emitters on dynamic data reinitialization; there are several cases in which this needs to happen (some material changes, mesh reimports...) which are difficult to track, so in-editor we just always recreate the mesh particle vertex factory with the dynamic data.
#jira UE-34838
Change 3098448 on 2016/08/23 by Rolando.Caloca
DR - vk - fixes for depth/stencil descriptors
- Minor debug dump improvement
Change 3098463 on 2016/08/23 by Daniel.Wright
Static lights with MinRoughness = 1.0 don't get their source shapes drawn into reflection captures, since they are being used as virtual area lights
Change 3098556 on 2016/08/23 by Daniel.Wright
Lightmass area shadows only mark texels as mapped inside the light's influence, which fixes multiple stationary lights with bUseAreaShadowsForStationaryLight interfering.
Change 3098672 on 2016/08/23 by Rolando.Caloca
DR - vk - Fixed crash when using vertex shaders with no descriptors
Change 3099173 on 2016/08/24 by Ben.Woodhouse
Fixed various issues with subsurface profile, for checkerboard and non-checkerboard code paths
- Re-enable non-checkerboard skin by default
- Checkerboard issues fixed:
- Emissive lighting was being applied twice due to not taking checkerboard pattern into account
- Emissive lighting was modulated by basecolor in the recombine
- Metallic materials were contributing specular lighting to the diffuse channel
- Non-checkerboard fixes:
- Fix write mask during SkyLightDiffuse so alpha is updated correctly
- Metallic specular lighting was broken (specularColor was lerping to white instead of baseColor)
- Optimisation: Fall back to default lit for pixels where the opacity is 0.
- For non-checkerboard, this gives better handling of metallic/emissive for pixels where SSS is not required (non-CB RGBA encoding for diffuse/spec doesn't cope well with colored specular or emissive)
- For checkerboard, this gives similar results in terms of shading, but we get full-resolution shading on non SSS pixels
#jira UE-34561
Change 3099673 on 2016/08/24 by Daniel.Wright
Removed unused reflection shape variables
Change 3099674 on 2016/08/24 by Daniel.Wright
Fixed translucent materials not working in DrawMaterialToRenderTarget (fallout from cl 3089208)
Fixed ensure with FRendererModule::DrawTile in the forward renderer, trying to bind light attenuation texture
Change 3099700 on 2016/08/24 by Daniel.Wright
Disabled log spam when a Rift is connected but not being used
Change 3099730 on 2016/08/24 by Daniel.Wright
MSAA depth resolve uses depth of closest surface, hides some artifacts with dynamic shadowing against the skybox
Change 3099789 on 2016/08/24 by Brian.Karis
FloatRGB is now always supported.
If 11:11:10 isn't supported by hardware this format by definition will map to a different format meaning it is always supported.
Change 3099987 on 2016/08/24 by Daniel.Wright
Fixed light grid debug asserts on PS4
* Always creating the local light buffer, even if it won't be used by the shader
* Transition ViewState FRWBuffers to writable at the beginning of a new frame
Change 3100120 on 2016/08/24 by Rolando.Caloca
DR - vk - Use 256MB pages for GPU memory
Change 3100151 on 2016/08/24 by Daniel.Wright
PS4 gracefully falls back to Temporal AA when MSAA is requested, as the GNM RHI doesn't support MSAA yet
Change 3100302 on 2016/08/24 by Rolando.Caloca
DR - vk - Mem system changes
- Now allocates a readback heap from GPU->CPU
- Removed bad total memory on heap/type
- Added fallback to another mem type if it's OOM
Change 3101110 on 2016/08/25 by Rolando.Caloca
DR - vk - Remove r.Vulkan.UseGLSL
Change 3101121 on 2016/08/25 by Rolando.Caloca
DR - vk - Initial support for HiResShot
Change 3101450 on 2016/08/25 by Rolando.Caloca
DR - vk - Remove imagelayout from textures; renamed a method for clarity
Change 3101462 on 2016/08/25 by Daniel.Wright
Planar reflections no longer update GPU particles, fixes Scene Depth particle collision
Change 3101525 on 2016/08/25 by Frank.Fella
Niagara - Remove public include modules from niagara, and remove the public include dependency on niagara from UnrealEd, and fix up fallout.
Change 3101613 on 2016/08/25 by Rolando.Caloca
DR - vk - Fix static analysis warning
Change 3101686 on 2016/08/25 by Frank.Fella
Niagara - Move asset type actions into the niagara module.
Change 3101865 on 2016/08/25 by Rolando.Caloca
DR - vk - Fix compile issue when enabling dump layer
Change 3101946 on 2016/08/25 by Frank.Fella
Orion - Fix include error caused by niagara include fixup.
Change 3101999 on 2016/08/25 by Frank.Fella
Fortnite - Fix include error caused by niagara include fixup.
Change 3102035 on 2016/08/25 by Frank.Fella
Ocean - Fix include error caused by niagara include fixup.
Change 3102047 on 2016/08/25 by Frank.Fella
UnrealTournament - Fix include error caused by niagara include fixup.
Change 3102627 on 2016/08/26 by Frank.Fella
Niagara - Move stats group declaration to the niagara module and move the stats declarations in the niagara module into the cpp files.
Change 3102654 on 2016/08/26 by Ben.Woodhouse
Fix for D3D error with mismatched vertex/pixel shader registers for SV_POSITION input. Remove unused PixelPosition attribute from interpolators
#jira UE-33424
Change 3102780 on 2016/08/26 by Ben.Woodhouse
Make shadow culling take FOV into account, via LODDistanceFactor
Also set the LODDistanceFactorSquared member of the view, which was previously uninitialized
#jira UE-33873
Change 3102930 on 2016/08/26 by Rolando.Caloca
DR - vk - Do not require backbuffer at start, like Metal
Change 3103061 on 2016/08/26 by Rolando.Caloca
DR - vk - More debug dump to help track down issues
Change 3103143 on 2016/08/26 by Rolando.Caloca
DR - vk - Added partial image view for each texture for Depth/Stencil
- Removed some unused members from textures
Change 3104162 on 2016/08/29 by Gil.Gribb
Merging //UE4/Dev-Main@3104155 to Dev-Rendering (//UE4/Dev-Rendering)
Change 3104491 on 2016/08/29 by Rolando.Caloca
DR - vk - Fix merge issue
Change 3104500 on 2016/08/29 by Rolando.Caloca
DR - Rebuilt hlslcc libs after merge
Change 3104978 on 2016/08/29 by John.Billon
-Moved Particle Cutouts to the Required Module
-Pre-existing SubUVAnimation data is automatically moved to required on Init.
-Added Default Particle Cutouts project setting that will attempt to find and use a texture on a particle's material for a cutout by default.
Change 3105249 on 2016/08/29 by John.Billon
Fixing non-editor compile error.
Change 3105326 on 2016/08/29 by Zabir.Hoque
SIMD Movie Player on XB1
Change 3105813 on 2016/08/30 by John.Billon
Fixing static analysis warning.
Change 3106322 on 2016/08/30 by Matt.Kuhlenschmidt
Removed duplicated view uniform shader parameters initialization between slate and scene rendering. Moved all the duped initialization into a single shared method. The shared method should be where new parameters are initialized if they are required for the view to work properly.
Change 3106350 on 2016/08/30 by Rolando.Caloca
DR - vk - Added missing texture formats
- Added texture debug name
Change 3106547 on 2016/08/30 by Rolando.Caloca
DR - Added ESimpleRenderTargetMode::EExistingColorAndClearDepth
Change 3106631 on 2016/08/30 by Uriel.Doyon
Dirty Texture Streaming Build do not dirty maps anymore.
#jira UE-35241
Change 3106919 on 2016/08/30 by Rolando.Caloca
DR - Temp workaround to get Vulkan up & running, might require hlslcc fix
Change 3106974 on 2016/08/30 by Uriel.Doyon
Changed lightmass exports version from GUID to INT in order to shorten filenames.
Change 3106988 on 2016/08/30 by Uriel.Doyon
New project specific config value r.Streaming.CheckBuildStatus used to specify whether the engine should check if the "Texture Streaming Build" is dirty (false by default).
#jira UE-35227
Change 3107927 on 2016/08/31 by John.Billon
-Duplicating OpenGL4 ClearUAV Implementation from 4.13
-Fixed uav clear format.
#Jira UE-35345
Change 3108095 on 2016/08/31 by Marc.Olano
Restore initialization of noise textures, accidentally removed in @3106322
#jira UE-35369
Change 3108557 on 2016/08/31 by John.Billon
Fixing HTML5 compile error
[CL 3109297 by Gil Gribb in Main branch]
2016-08-31 21:22:32 -04:00
# include "HlslccDefinitions.h"
2014-09-21 20:35:48 -04:00
2014-06-05 16:38:54 -04:00
IMPLEMENT_MODULE ( FDefaultModuleImpl , ShaderCompilerCommon ) ;
2014-09-21 20:35:48 -04:00
2015-10-06 15:59:09 -04:00
int16 GetNumUniformBuffersUsed ( const FShaderCompilerResourceTable & InSRT )
2014-08-25 14:41:54 -04:00
{
auto CountLambda = [ & ] ( const TArray < uint32 > & In )
{
int16 LastIndex = - 1 ;
for ( int32 i = 0 ; i < In . Num ( ) ; + + i )
{
auto BufferIndex = FRHIResourceTableEntry : : GetUniformBufferIndex ( In [ i ] ) ;
2015-04-09 17:01:04 -04:00
if ( BufferIndex ! = static_cast < uint16 > ( FRHIResourceTableEntry : : GetEndOfStreamToken ( ) ) )
2014-08-25 14:41:54 -04:00
{
LastIndex = FMath : : Max ( LastIndex , ( int16 ) BufferIndex ) ;
}
}
return LastIndex + 1 ;
} ;
int16 Num = CountLambda ( InSRT . SamplerMap ) ;
Num = FMath : : Max ( Num , ( int16 ) CountLambda ( InSRT . ShaderResourceViewMap ) ) ;
Num = FMath : : Max ( Num , ( int16 ) CountLambda ( InSRT . TextureMap ) ) ;
Num = FMath : : Max ( Num , ( int16 ) CountLambda ( InSRT . UnorderedAccessViewMap ) ) ;
return Num ;
}
2014-06-05 16:38:54 -04:00
void BuildResourceTableTokenStream ( const TArray < uint32 > & InResourceMap , int32 MaxBoundResourceTable , TArray < uint32 > & OutTokenStream )
{
// First we sort the resource map.
TArray < uint32 > SortedResourceMap = InResourceMap ;
SortedResourceMap . Sort ( ) ;
// The token stream begins with a table that contains offsets per bound uniform buffer.
// This offset provides the start of the token stream.
OutTokenStream . AddZeroed ( MaxBoundResourceTable + 1 ) ;
auto LastBufferIndex = FRHIResourceTableEntry : : GetEndOfStreamToken ( ) ;
for ( int32 i = 0 ; i < SortedResourceMap . Num ( ) ; + + i )
{
auto BufferIndex = FRHIResourceTableEntry : : GetUniformBufferIndex ( SortedResourceMap [ i ] ) ;
if ( BufferIndex ! = LastBufferIndex )
{
// Store the offset for resources from this buffer.
OutTokenStream [ BufferIndex ] = OutTokenStream . Num ( ) ;
LastBufferIndex = BufferIndex ;
}
OutTokenStream . Add ( SortedResourceMap [ i ] ) ;
}
// Add a token to mark the end of the stream. Not needed if there are no bound resources.
if ( OutTokenStream . Num ( ) )
{
OutTokenStream . Add ( FRHIResourceTableEntry : : GetEndOfStreamToken ( ) ) ;
}
}
2014-09-21 20:35:48 -04:00
2014-06-05 16:38:54 -04:00
void BuildResourceTableMapping (
const TMap < FString , FResourceTableEntry > & ResourceTableMap ,
const TMap < FString , uint32 > & ResourceTableLayoutHashes ,
TBitArray < > & UsedUniformBufferSlots ,
FShaderParameterMap & ParameterMap ,
2015-10-06 15:59:09 -04:00
FShaderCompilerResourceTable & OutSRT )
2014-06-05 16:38:54 -04:00
{
check ( OutSRT . ResourceTableBits = = 0 ) ;
check ( OutSRT . ResourceTableLayoutHashes . Num ( ) = = 0 ) ;
// Build resource table mapping
int32 MaxBoundResourceTable = - 1 ;
TArray < uint32 > ResourceTableSRVs ;
TArray < uint32 > ResourceTableSamplerStates ;
TArray < uint32 > ResourceTableUAVs ;
for ( auto MapIt = ResourceTableMap . CreateConstIterator ( ) ; MapIt ; + + MapIt )
{
const FString & Name = MapIt - > Key ;
const FResourceTableEntry & Entry = MapIt - > Value ;
uint16 BufferIndex , BaseIndex , Size ;
if ( ParameterMap . FindParameterAllocation ( * Name , BufferIndex , BaseIndex , Size ) )
{
ParameterMap . RemoveParameterAllocation ( * Name ) ;
uint16 UniformBufferIndex = INDEX_NONE , UBBaseIndex , UBSize ;
if ( ParameterMap . FindParameterAllocation ( * Entry . UniformBufferName , UniformBufferIndex , UBBaseIndex , UBSize ) = = false )
{
UniformBufferIndex = UsedUniformBufferSlots . FindAndSetFirstZeroBit ( ) ;
ParameterMap . AddParameterAllocation ( * Entry . UniformBufferName , UniformBufferIndex , 0 , 0 ) ;
}
OutSRT . ResourceTableBits | = ( 1 < < UniformBufferIndex ) ;
MaxBoundResourceTable = FMath : : Max < int32 > ( MaxBoundResourceTable , ( int32 ) UniformBufferIndex ) ;
while ( OutSRT . ResourceTableLayoutHashes . Num ( ) < = MaxBoundResourceTable )
{
OutSRT . ResourceTableLayoutHashes . Add ( 0 ) ;
}
OutSRT . ResourceTableLayoutHashes [ UniformBufferIndex ] = ResourceTableLayoutHashes . FindChecked ( Entry . UniformBufferName ) ;
auto ResourceMap = FRHIResourceTableEntry : : Create ( UniformBufferIndex , Entry . ResourceIndex , BaseIndex ) ;
switch ( Entry . Type )
{
case UBMT_TEXTURE :
OutSRT . TextureMap . Add ( ResourceMap ) ;
break ;
case UBMT_SAMPLER :
OutSRT . SamplerMap . Add ( ResourceMap ) ;
break ;
case UBMT_SRV :
OutSRT . ShaderResourceViewMap . Add ( ResourceMap ) ;
break ;
case UBMT_UAV :
OutSRT . UnorderedAccessViewMap . Add ( ResourceMap ) ;
break ;
default :
check ( 0 ) ;
}
}
}
OutSRT . MaxBoundResourceTable = MaxBoundResourceTable ;
}
2015-05-28 16:46:01 -04:00
// Specialized version of FString::ReplaceInline that checks that the search word is not inside a #line directive
2015-01-12 18:28:54 -05:00
static void WholeWordReplaceInline ( FString & String , TCHAR * StartPtr , const TCHAR * SearchText , const TCHAR * ReplacementText )
{
if ( String . Len ( ) > 0
& & SearchText ! = nullptr & & * SearchText ! = 0
& & ReplacementText ! = nullptr & & FCString : : Strcmp ( SearchText , ReplacementText ) ! = 0 )
{
const int32 NumCharsToReplace = FCString : : Strlen ( SearchText ) ;
const int32 NumCharsToInsert = FCString : : Strlen ( ReplacementText ) ;
check ( NumCharsToInsert = = NumCharsToReplace ) ;
check ( * StartPtr ) ;
TCHAR * Pos = FCString : : Strstr ( StartPtr , SearchText ) ;
while ( Pos ! = nullptr )
{
// Find a " character, indicating we might be inside a #line directive
TCHAR * FoundQuote = nullptr ;
auto * ValidatePos = Pos ;
do
{
- - ValidatePos ;
if ( * ValidatePos = = ' \" ' )
{
FoundQuote = ValidatePos ;
break ;
}
}
while ( ValidatePos > = StartPtr & & * ValidatePos ! = ' \n ' ) ;
bool bReplace = true ;
if ( FoundQuote )
{
// Validate that we're indeed inside a #line directive by first finding the last \n character
TCHAR * FoundEOL = nullptr ;
do
{
- - ValidatePos ;
if ( * ValidatePos = = ' \n ' )
{
FoundEOL = ValidatePos ;
break ;
}
}
while ( ValidatePos > StartPtr ) ;
// Finally make sure the directive is between the \n and the and the quote
if ( FoundEOL )
{
auto * FoundInclude = FCString : : Strstr ( FoundEOL + 1 , TEXT ( " #line " ) ) ;
if ( FoundInclude & & FoundInclude < FoundQuote )
{
bReplace = false ;
}
}
}
2015-05-28 16:46:01 -04:00
// Make sure this is not part of an identifier
if ( bReplace & & Pos > StartPtr )
{
const auto Char = Pos [ - 1 ] ;
if ( ( Char > = ' a ' & & Char < = ' z ' ) | |
( Char > = ' A ' & & Char < = ' Z ' ) | |
( Char > = ' 0 ' & & Char < = ' 9 ' ) | |
Char = = ' _ ' )
{
bReplace = false ;
}
}
2015-01-12 18:28:54 -05:00
if ( bReplace )
{
// FCString::Strcpy inserts a terminating zero so can't use that
for ( int32 i = 0 ; i < NumCharsToInsert ; i + + )
{
Pos [ i ] = ReplacementText [ i ] ;
}
}
if ( Pos + NumCharsToReplace - * String < String . Len ( ) )
{
Pos = FCString : : Strstr ( Pos + NumCharsToReplace , SearchText ) ;
}
else
{
break ;
}
}
}
}
2014-09-21 20:35:48 -04:00
2016-01-07 11:21:22 -05:00
bool RemoveUniformBuffersFromSource ( FString & SourceCode )
2014-06-05 16:38:54 -04:00
{
static const FString StaticStructToken ( TEXT ( " static const struct " ) ) ;
int32 StaticStructTokenPos = SourceCode . Find ( StaticStructToken , ESearchCase : : CaseSensitive , ESearchDir : : FromStart ) ;
while ( StaticStructTokenPos ! = INDEX_NONE )
{
static const FString CloseBraceSpaceToken ( TEXT ( " } " ) ) ;
int32 CloseBraceSpaceTokenPos = SourceCode . Find ( CloseBraceSpaceToken , ESearchCase : : CaseSensitive , ESearchDir : : FromStart , StaticStructTokenPos + StaticStructToken . Len ( ) ) ;
if ( CloseBraceSpaceTokenPos = = INDEX_NONE )
{
check ( 0 ) ; //@todo-rco: ERROR
return false ;
}
int32 NamePos = CloseBraceSpaceTokenPos + CloseBraceSpaceToken . Len ( ) ;
static const FString SpaceEqualsToken ( TEXT ( " = " ) ) ;
int32 SpaceEqualsTokenPos = SourceCode . Find ( SpaceEqualsToken , ESearchCase : : CaseSensitive , ESearchDir : : FromStart , NamePos ) ;
if ( SpaceEqualsTokenPos = = INDEX_NONE )
{
check ( 0 ) ; //@todo-rco: ERROR
return false ;
}
FString UniformBufferName = SourceCode . Mid ( NamePos , SpaceEqualsTokenPos - NamePos ) ;
check ( UniformBufferName . Len ( ) > 0 ) ;
static const FString CloseBraceSemicolorToken ( TEXT ( " }; " ) ) ;
int32 CloseBraceSemicolonTokenPos = SourceCode . Find ( CloseBraceSemicolorToken , ESearchCase : : CaseSensitive , ESearchDir : : FromStart , SpaceEqualsTokenPos + SpaceEqualsToken . Len ( ) ) ;
if ( CloseBraceSemicolonTokenPos = = INDEX_NONE )
{
check ( 0 ) ; //@todo-rco: ERROR
return false ;
}
// Comment out this UB
auto & SourceCharArray = SourceCode . GetCharArray ( ) ;
SourceCharArray [ StaticStructTokenPos ] = TCHAR ( ' / ' ) ;
SourceCharArray [ StaticStructTokenPos + 1 ] = TCHAR ( ' * ' ) ;
SourceCharArray [ CloseBraceSemicolonTokenPos ] = TCHAR ( ' * ' ) ;
SourceCharArray [ CloseBraceSemicolonTokenPos + 1 ] = TCHAR ( ' / ' ) ;
// Find & Replace this UB
FString UBSource = UniformBufferName + FString ( TEXT ( " . " ) ) ;
FString UBDest = UniformBufferName + FString ( TEXT ( " _ " ) ) ;
2015-01-12 18:28:54 -05:00
WholeWordReplaceInline ( SourceCode , & SourceCharArray [ CloseBraceSemicolonTokenPos + 2 ] , * UBSource , * UBDest ) ;
2014-06-05 16:38:54 -04:00
// Find next UB
StaticStructTokenPos = SourceCode . Find ( StaticStructToken , ESearchCase : : CaseSensitive , ESearchDir : : FromStart , CloseBraceSemicolonTokenPos + 2 ) ;
}
return true ;
}
2014-06-30 18:32:57 -04:00
2014-09-21 20:35:48 -04:00
2016-06-08 16:02:23 -04:00
FString CreateShaderCompilerWorkerDirectCommandLine ( const FShaderCompilerInput & Input )
{
FString Text ( TEXT ( " -directcompile -format= " ) ) ;
Text + = Input . ShaderFormat . GetPlainNameString ( ) ;
Text + = TEXT ( " -entry= " ) ;
Text + = Input . EntryPointName ;
switch ( Input . Target . Frequency )
{
case SF_Vertex : Text + = TEXT ( " -vs " ) ; break ;
case SF_Hull : Text + = TEXT ( " -hs " ) ; break ;
case SF_Domain : Text + = TEXT ( " -ds " ) ; break ;
case SF_Geometry : Text + = TEXT ( " -gs " ) ; break ;
case SF_Pixel : Text + = TEXT ( " -ps " ) ; break ;
case SF_Compute : Text + = TEXT ( " -cs " ) ; break ;
default : ensure ( 0 ) ; break ;
}
if ( Input . bCompilingForShaderPipeline )
{
Text + = TEXT ( " -pipeline " ) ;
}
if ( Input . bIncludeUsedOutputs )
{
Text + = TEXT ( " -usedoutputs= " ) ;
for ( int32 Index = 0 ; Index < Input . UsedOutputs . Num ( ) ; + + Index )
{
if ( Index ! = 0 )
{
Text + = TEXT ( " + " ) ;
}
Text + = Input . UsedOutputs [ Index ] ;
}
}
Text + = TEXT ( " " ) ;
Text + = Input . DumpDebugInfoPath / Input . SourceFilename + TEXT ( " .usf " ) ;
uint64 CFlags = 0 ;
for ( int32 Index = 0 ; Index < Input . Environment . CompilerFlags . Num ( ) ; + + Index )
{
CFlags = CFlags | ( ( uint64 ) 1 < < ( uint64 ) Input . Environment . CompilerFlags [ Index ] ) ;
}
if ( CFlags )
{
Text + = TEXT ( " -cflags= " ) ;
Text + = FString : : Printf ( TEXT ( " %llu " ) , CFlags ) ;
}
return Text ;
}
2015-07-02 11:52:03 -04:00
namespace CrossCompiler
2014-06-30 18:32:57 -04:00
{
2015-07-30 13:31:13 -04:00
FString CreateBatchFileContents ( const FString & ShaderFile , const FString & OutputFile , uint32 Frequency , const FString & EntryPoint , const FString & VersionSwitch , uint32 CCFlags , const FString & ExtraArguments )
2015-02-22 19:58:52 -05:00
{
2015-07-30 13:31:13 -04:00
const TCHAR * FrequencySwitch = TEXT ( " " ) ;
switch ( Frequency )
{
case HSF_PixelShader : FrequencySwitch = TEXT ( " -ps " ) ; break ;
case HSF_VertexShader : FrequencySwitch = TEXT ( " -vs " ) ; break ;
case HSF_HullShader : FrequencySwitch = TEXT ( " -hs " ) ; break ;
case HSF_DomainShader : FrequencySwitch = TEXT ( " -ds " ) ; break ;
case HSF_ComputeShader : FrequencySwitch = TEXT ( " -cs " ) ; break ;
case HSF_GeometryShader : FrequencySwitch = TEXT ( " -gs " ) ; break ;
default : check ( 0 ) ; break ;
}
FString CCTCmdLine = ExtraArguments ;
CCTCmdLine + = ( ( CCFlags & HLSLCC_NoValidation ) = = HLSLCC_NoValidation ) ? TEXT ( " -novalidate " ) : TEXT ( " " ) ;
CCTCmdLine + = ( ( CCFlags & HLSLCC_DX11ClipSpace ) = = HLSLCC_DX11ClipSpace ) ? TEXT ( " -dx11clip " ) : TEXT ( " " ) ;
CCTCmdLine + = ( ( CCFlags & HLSLCC_NoPreprocess ) = = HLSLCC_NoPreprocess ) ? TEXT ( " -nopp " ) : TEXT ( " " ) ;
CCTCmdLine + = ( ( CCFlags & HLSLCC_FlattenUniformBuffers ) = = HLSLCC_FlattenUniformBuffers ) ? TEXT ( " -flattenub " ) : TEXT ( " " ) ;
CCTCmdLine + = ( ( CCFlags & HLSLCC_FlattenUniformBufferStructures ) = = HLSLCC_FlattenUniformBufferStructures ) ? TEXT ( " -flattenubstruct " ) : TEXT ( " " ) ;
CCTCmdLine + = ( ( CCFlags & HLSLCC_GroupFlattenedUniformBuffers ) = = HLSLCC_GroupFlattenedUniformBuffers ) ? TEXT ( " -groupflatub " ) : TEXT ( " " ) ;
CCTCmdLine + = ( ( CCFlags & HLSLCC_ApplyCommonSubexpressionElimination ) = = HLSLCC_ApplyCommonSubexpressionElimination ) ? TEXT ( " -cse " ) : TEXT ( " " ) ;
CCTCmdLine + = ( ( CCFlags & HLSLCC_ExpandSubexpressions ) = = HLSLCC_ExpandSubexpressions ) ? TEXT ( " -xpxpr " ) : TEXT ( " " ) ;
CCTCmdLine + = ( ( CCFlags & HLSLCC_SeparateShaderObjects ) = = HLSLCC_SeparateShaderObjects ) ? TEXT ( " -separateshaders " ) : TEXT ( " " ) ;
2015-09-28 16:09:22 -04:00
CCTCmdLine + = ( ( CCFlags & HLSLCC_PackUniformsIntoUniformBuffers ) = = HLSLCC_PackUniformsIntoUniformBuffers ) ? TEXT ( " -packintoubs " ) : TEXT ( " " ) ;
Copying //UE4/Dev-Rendering to //UE4/Dev-Main (Source: //UE4/Dev-Rendering @ 2998063)
#lockdown nick.penwarden
==========================
MAJOR FEATURES + CHANGES
==========================
Change 2981877 on 2016/05/18 by Rolando.Caloca
DR - Fix some PVS warnings
- Removed 'uniform' as a keyword on hlslcc as it's ignored/causes issues/doesn't really optimize
#jira UE-30996
Change 2981966 on 2016/05/18 by Rolando.Caloca
DR - Fix OpenGL crash quitting editor
#jira UE-25549
Change 2982072 on 2016/05/18 by Uriel.Doyon
Fixed a "Build Texture Streaming" crash related to custom outputs.
Fixed issue with debug view mode and translucent primitives
Fix bug with visibility that made some texture low res.
Enabled per instance visibility in the texture streaming order (in game only).
Improved InvestigateTexture Logs.
Tweaked the mip computations from screen size.
Change 2982077 on 2016/05/18 by Uriel.Doyon
Removed debug options!
Change 2982108 on 2016/05/18 by Olaf.Piesche
#jira UE-30772
moving AMD hacks to console variables
Change 2982422 on 2016/05/18 by Gil.Gribb
UE4 - Potential crash fix on foliage occlusion queries and reflection captures.
Change 2982547 on 2016/05/18 by Martin.Mittring
UE-26409 Crash when Light Propagation Volume Plugin is disabled on a Project
Change 2982548 on 2016/05/18 by Martin.Mittring
Refactored MRT and outer Pixel Shader output to a struct
to allow it passed in/out of functions allowing for a more readable code (less #ifdefs, reducing the boolean hell)
Needed for upcoming MeshDecals
Change 2982601 on 2016/05/18 by Daniel.Wright
Movable skylight now matches stationary for subsurface shading models
* Two sided was broken in 4.11, Subsurface had never been handled
Change 2982603 on 2016/05/18 by Daniel.Wright
DrawMaterialToRenderTarget / BeginDrawCanvasToRenderTarget now work correctly with material parameter collections and Time
* FCanvas stores an optional scene to render to, UWorld caches the UCanvas needed for implementing these functions
Change 2982618 on 2016/05/18 by Daniel.Wright
Better categories for some Rendering project settings
Change 2982619 on 2016/05/18 by Daniel.Wright
Scene capture 2d improvements
* Orthographic projection supported
* Opacity is now captured in alpha, allows partial rendering in a scene capture and compositing into another scene later
* Various GBuffer attributes are now available to be captured, including depth
* Changed Blueprint capture function to CaptureScene, which happens immediately (was previously deferred), allowing multiple captures with different parameters
Change 2982664 on 2016/05/18 by Daniel.Wright
Fading out planar reflections based on roughness since they don't have support for variable roughness (fade starts at .2 roughness, ends at .3)
Change 2982684 on 2016/05/18 by Martin.Mittring
polish ImageValidator
Change 2982685 on 2016/05/18 by Martin.Mittring
show testimage on sm4 as well
Change 2982736 on 2016/05/18 by Uriel.Doyon
Improved overbudget retention logic.
Updated ListStreamingTextures stats.
Change 2982854 on 2016/05/18 by Martin.Mittring
ImageValidator can now save/load IVxml file
Change 2982863 on 2016/05/18 by Daniel.Wright
Fixed shader compile error
Change 2982864 on 2016/05/18 by Daniel.Wright
Removed deprecation message
Change 2982927 on 2016/05/18 by Martin.Mittring
ImageValidator is now sorting by time
Change 2983743 on 2016/05/19 by Chris.Bunner
Saturated tri-planar UV function outputs to prevent negative blending
#jira UE-30964
Change 2983747 on 2016/05/19 by Martin.Wilson
Fix for morph curves not getting applied to meshes in cooked builds (smart names were not being corrected).
Change 2984008 on 2016/05/19 by Brian.Karis
New contact shadows feature.
Hair uses ray cast for nonshadow lights
Change 2984009 on 2016/05/19 by Brian.Karis
changed to ShadowedBits
Change 2984054 on 2016/05/19 by Brian.Karis
Deleted old motion blur
Change 2984420 on 2016/05/19 by Daniel.Wright
Shorter display name for WorldPosition material node
Change 2984423 on 2016/05/19 by Daniel.Wright
Fixed WorldPosition and ScreenPosition for downsampled separate translucency by scaling SvPosition before those computations. The View uniform buffer still contains incorrect buffer sizes for this pass.
Change 2984432 on 2016/05/19 by Rolando.Caloca
DR - Disable PPCombineLUT for Vulkan to work around glslang issue (will need to be reenabled when adding SM4/5 path)
Change 2985415 on 2016/05/20 by Daniel.Wright
Added a Texture2D exporter for .hdr
Texture2D exporters now implement SupportsObject properly, so you only see extensions that are valid based on the format
Change 2985439 on 2016/05/20 by Daniel.Wright
Scene color alpha clear value validation
Change 2987173 on 2016/05/23 by Martin.Mittring
ImageValidator Report with Thumbnail (cannot be copied and pasted into email), non Thumbnail version could be.
Change 2987248 on 2016/05/23 by Martin.Mittring
ImageValidator: added Summary, removed timer hack
Change 2987369 on 2016/05/23 by Martin.Mittring
ImageValidator polish
Change 2987390 on 2016/05/23 by Brian.Karis
Improvement to temporal aa sharpness and speed.
Change 2988038 on 2016/05/24 by Gil.Gribb
Merging //UE4/Dev-Main@2987977 to Dev-Rendering (//UE4/Dev-Rendering)
Change 2988304 on 2016/05/24 by Martin.Mittring
added const to prevent coding errors
Change 2988332 on 2016/05/24 by Brian.Karis
Fixed motion blur crash on SM4
Change 2988446 on 2016/05/24 by Martin.Mittring
nicer UI
Change 2988990 on 2016/05/24 by Martin.Mittring
fixed UE-31227 Building lighting produces bad results
#jira:UE-31227
Change 2989729 on 2016/05/25 by Uriel.Doyon
Fixed lightmaps and shadowmaps having low resolutions after building the lighting.
#jira UE-31254
Change 2989752 on 2016/05/25 by Olaf.Piesche
CVar to disable/freeze GPU particle simulation
Change 2989811 on 2016/05/25 by Daniel.Wright
Making use of MATERIALBLENDING_ANY_TRANSLUCENT
Change 2989812 on 2016/05/25 by Daniel.Wright
Hide DFGI show flags from UI
Change 2989901 on 2016/05/25 by Daniel.Wright
Height fog now works properly in planar reflections
* The ray used for computing fog is first clipped by the reflection plane
Change 2989904 on 2016/05/25 by Daniel.Wright
Always use PF_FloatRGBA for LightAccumulation to guarantee alpha channel and negative range
Change 2989991 on 2016/05/25 by Daniel.Wright
Improved usability for DBuffer Decals
* 'Show Decals' works correctly, previously would fetch from uninitialized textures
* DBuffer being enabled forces a full prepass, previously decals would render incorrectly unless correct settings of r.EarlyZPass were used
* Improved the PrePass draw event to indicate whether it's full or partial
* Materials using DBuffer blend modes will fail to compile when the DBuffer project setting is disabled, instead of just being invisible
* r.EarlyZPass can now be changed at runtime, which is useful for profiling
Change 2990008 on 2016/05/25 by Daniel.Wright
Fixed capsule shadows on skeletal meshes with scaling
Change 2990274 on 2016/05/25 by Daniel.Wright
Fixed DFAO (from cl 2961310)
Change 2990304 on 2016/05/25 by Martin.Mittring
OR-22233 GPU Sprites invisible unless solo'd
#jira:OR-22233
Change 2990309 on 2016/05/25 by Martin.Mittring
Added SubDSurface actor (using CPU code of OpenSubDiv), component, asset as starting point for more work in that direction,
(Early work in progress)
Change 2990363 on 2016/05/25 by Daniel.Wright
Spreading precomputed visibility to neighbors now uses a 2d grid to find neighbors, speeds up the process for 800k cells from 40 mins to 20s
Change 2990392 on 2016/05/25 by Daniel.Wright
Added r.AOSpecularOcclusionMode, which determines how specular should be occluded by DFAO
0: Apply non-directional AO to specular.
1: (default) Intersect the reflection cone with the unoccluded cone produced by DFAO. This gives more accurate occlusion than 0, but can bring out DFAO sampling artifacts.
2: (experimental) Cone trace through distance fields along the reflection vector. Costs about the same as DFAO again because more cone tracing is done, but produces more accurate occlusion.
Change 2990454 on 2016/05/25 by Martin.Mittring
polish readme
Change 2990610 on 2016/05/25 by Martin.Mittring
fixed building with VS2015, the right OpenSubDiv .lib files are missing, temporarily disabled the relevant code
#code_review:Shane.Caudle
Change 2990754 on 2016/05/25 by Zabir.Hoque
Fix compiler warning: C4456: declaration of 'NewStaticMesh' hides previous local declaration.
#CodeReview: Martin.Mittring
Change 2990801 on 2016/05/25 by Zabir.Hoque
Only allocate reflection capture cubemaps if we are actually doing a reflection capture. The old approach always allocated based on CVar and worked with a warning on D3D since if SRC was larger than the DST, the extra SRC area was dropped. New approach only allocates when necessary and is correctly sized everytime. Also hardened access to CVar and what users are allowed to set.
#CodeReview Marcus.Wassmer, Rolando.Caloca, Daniel.Wright, Martin.Mittring
Change 2991169 on 2016/05/26 by Martin.Mittring
fixed compiler warning
WARNING: Non-editor build cannot depend on non-redistributable modules. Details:
#lockdown: gil.gribb
Change 2991238 on 2016/05/26 by Martin.Mittring
fixed build
fatal error C1083: Cannot open include file: 'RawMesh.h': No such file or directory (when RawMesh is not part of PrivateDependencyModuleNames in Engine.Build.cs)
#lockdown:Gil.Gribb
Change 2991726 on 2016/05/26 by Daniel.Wright
Subsurface materials are now handled with simple forward shading
#jira OR-22237
#lockdown gil.gribb
Change 2991727 on 2016/05/26 by Daniel.Wright
Emissive decals are now supported with simple forward shading
#jira OR-22282
#lockdown Gil.Gribb
Change 2994849 on 2016/05/31 by Daniel.Wright
Disabled fix for WorldPosition and ScreenPosition in downsampled separate translucency, since it breaks GetScreenAlignedUV (used in DepthFade), since the uniform buffer still contains full res buffer sizes
#lockdown Gil.Gribb
Change 2997243 on 2016/06/01 by Gil.Gribb
Merging //UE4/Dev-Main@2996565 to Dev-Rendering (//UE4/Dev-Rendering)
#lockdown nick.penwarden
[CL 2998067 by Gil Gribb in Main branch]
2016-06-02 13:13:43 -04:00
CCTCmdLine + = ( ( CCFlags & HLSLCC_FixAtomicReferences ) = = HLSLCC_FixAtomicReferences ) ? TEXT ( " -fixatomics " ) : TEXT ( " " ) ;
2016-06-13 12:20:22 -04:00
CCTCmdLine + = ( ( CCFlags & HLSLCC_UseFullPrecisionInPS ) = = HLSLCC_UseFullPrecisionInPS ) ? TEXT ( " -usefullprecision " ) : TEXT ( " " ) ;
2015-07-02 11:52:03 -04:00
FString BatchFile ;
if ( PLATFORM_MAC )
{
2015-07-30 13:31:13 -04:00
BatchFile = FPaths : : RootDir ( ) / FString : : Printf ( TEXT ( " Engine/Source/ThirdParty/hlslcc/hlslcc/bin/Mac/hlslcc_64 %s -o=%s %s -entry=%s %s %s " ) , * ShaderFile , * OutputFile , FrequencySwitch , * EntryPoint , * VersionSwitch , * CCTCmdLine ) ;
2015-07-02 11:52:03 -04:00
}
else if ( PLATFORM_LINUX )
{
2015-08-03 16:07:57 -04:00
BatchFile = TEXT ( " #!/bin/sh \n " ) ;
2016-03-17 11:10:14 -04:00
// add an extra '/' to the file name (which is absolute at this point) because CrossCompilerTool will strip out first '/' considering it a legacy DOS-style switch marker.
BatchFile + = FPaths : : RootDir ( ) / FString : : Printf ( TEXT ( " Engine/Binaries/Linux/CrossCompilerTool /%s -o=%s %s -entry=%s %s %s " ) , * ShaderFile , * OutputFile , FrequencySwitch , * EntryPoint , * VersionSwitch , * CCTCmdLine ) ;
2015-07-02 11:52:03 -04:00
}
else if ( PLATFORM_WINDOWS )
{
BatchFile = TEXT ( " @echo off " ) ;
BatchFile + = TEXT ( " \n if defined ue.hlslcc GOTO DONE \n set ue.hlslcc= " ) ;
BatchFile + = FPaths : : RootDir ( ) / TEXT ( " Engine \\ Binaries \\ Win64 \\ CrossCompilerTool.exe " ) ;
BatchFile + = TEXT ( " \n \n :DONE \n %ue.hlslcc% " ) ;
2015-07-30 13:31:13 -04:00
BatchFile + = FString : : Printf ( TEXT ( " \" %s \" -o= \" %s \" %s -entry=%s %s %s " ) , * ShaderFile , * OutputFile , FrequencySwitch , * EntryPoint , * VersionSwitch , * CCTCmdLine ) ;
2015-07-02 11:52:03 -04:00
BatchFile + = TEXT ( " \n pause \n " ) ;
}
else
{
checkf ( false , TEXT ( " CreateCrossCompilerBatchFileContents: unsupported platform! " ) ) ;
}
return BatchFile ;
2015-02-22 19:58:52 -05:00
}
2015-07-02 11:52:03 -04:00
/**
* Parse an error emitted by the HLSL cross - compiler .
* @ param OutErrors - Array into which compiler errors may be added .
* @ param InLine - A line from the compile log .
*/
void ParseHlslccError ( TArray < FShaderCompilerError > & OutErrors , const FString & InLine )
{
const TCHAR * p = * InLine ;
FShaderCompilerError * Error = new ( OutErrors ) FShaderCompilerError ( ) ;
// Copy the filename.
while ( * p & & * p ! = TEXT ( ' ( ' ) ) { Error - > ErrorFile + = ( * p + + ) ; }
Error - > ErrorFile = GetRelativeShaderFilename ( Error - > ErrorFile ) ;
p + + ;
// Parse the line number.
int32 LineNumber = 0 ;
while ( * p & & * p > = TEXT ( ' 0 ' ) & & * p < = TEXT ( ' 9 ' ) )
{
LineNumber = 10 * LineNumber + ( * p + + - TEXT ( ' 0 ' ) ) ;
}
Error - > ErrorLineString = * FString : : Printf ( TEXT ( " %d " ) , LineNumber ) ;
// Skip to the warning message.
while ( * p & & ( * p = = TEXT ( ' ) ' ) | | * p = = TEXT ( ' : ' ) | | * p = = TEXT ( ' ' ) | | * p = = TEXT ( ' \t ' ) ) ) { p + + ; }
Error - > StrippedErrorMessage = p ;
}
/** Map shader frequency -> string for messages. */
static const TCHAR * FrequencyStringTable [ ] =
{
TEXT ( " Vertex " ) ,
TEXT ( " Hull " ) ,
TEXT ( " Domain " ) ,
TEXT ( " Pixel " ) ,
TEXT ( " Geometry " ) ,
TEXT ( " Compute " )
} ;
/** Compile time check to verify that the GL mapping tables are up-to-date. */
static_assert ( SF_NumFrequencies = = ARRAY_COUNT ( FrequencyStringTable ) , " NumFrequencies changed. Please update tables. " ) ;
const TCHAR * GetFrequencyName ( EShaderFrequency Frequency )
{
check ( ( int32 ) Frequency > = 0 & & Frequency < SF_NumFrequencies ) ;
return FrequencyStringTable [ Frequency ] ;
}
FHlslccHeader : : FHlslccHeader ( ) :
Name ( TEXT ( " " ) )
{
NumThreads [ 0 ] = NumThreads [ 1 ] = NumThreads [ 2 ] = 0 ;
}
bool FHlslccHeader : : Read ( const ANSICHAR * & ShaderSource , int32 SourceLen )
{
# define DEF_PREFIX_STR(Str) \
static const ANSICHAR * Str # # Prefix = " // @ " # Str " : " ; \
static const int32 Str # # PrefixLen = FCStringAnsi : : Strlen ( Str # # Prefix )
DEF_PREFIX_STR ( Inputs ) ;
DEF_PREFIX_STR ( Outputs ) ;
DEF_PREFIX_STR ( UniformBlocks ) ;
DEF_PREFIX_STR ( Uniforms ) ;
DEF_PREFIX_STR ( PackedGlobals ) ;
DEF_PREFIX_STR ( PackedUB ) ;
DEF_PREFIX_STR ( PackedUBCopies ) ;
DEF_PREFIX_STR ( PackedUBGlobalCopies ) ;
DEF_PREFIX_STR ( Samplers ) ;
DEF_PREFIX_STR ( UAVs ) ;
DEF_PREFIX_STR ( SamplerStates ) ;
DEF_PREFIX_STR ( NumThreads ) ;
# undef DEF_PREFIX_STR
// Skip any comments that come before the signature.
while ( FCStringAnsi : : Strncmp ( ShaderSource , " // " , 2 ) = = 0 & &
FCStringAnsi : : Strncmp ( ShaderSource + 2 , " ! " , 2 ) ! = 0 & &
FCStringAnsi : : Strncmp ( ShaderSource + 2 , " @ " , 2 ) ! = 0 )
{
ShaderSource + = 2 ;
while ( * ShaderSource & & * ShaderSource + + ! = ' \n ' )
{
// Do nothing
}
}
// Read shader name if any
2015-07-02 15:19:30 -04:00
if ( FCStringAnsi : : Strncmp ( ShaderSource , " // ! " , 4 ) = = 0 )
2015-07-02 11:52:03 -04:00
{
2015-07-02 15:19:30 -04:00
ShaderSource + = 4 ;
2015-07-02 11:52:03 -04:00
while ( * ShaderSource & & * ShaderSource ! = ' \n ' )
{
Name + = ( TCHAR ) * ShaderSource ;
+ + ShaderSource ;
}
2015-07-02 15:19:30 -04:00
if ( * ShaderSource = = ' \n ' )
{
+ + ShaderSource ;
}
}
// Skip any comments that come before the signature.
while ( FCStringAnsi : : Strncmp ( ShaderSource , " // " , 2 ) = = 0 & &
FCStringAnsi : : Strncmp ( ShaderSource + 2 , " @ " , 2 ) ! = 0 )
{
ShaderSource + = 2 ;
while ( * ShaderSource & & * ShaderSource + + ! = ' \n ' )
{
// Do nothing
}
2015-07-02 11:52:03 -04:00
}
if ( FCStringAnsi : : Strncmp ( ShaderSource , InputsPrefix , InputsPrefixLen ) = = 0 )
{
ShaderSource + = InputsPrefixLen ;
if ( ! ReadInOut ( ShaderSource , Inputs ) )
{
return false ;
}
}
if ( FCStringAnsi : : Strncmp ( ShaderSource , OutputsPrefix , OutputsPrefixLen ) = = 0 )
{
ShaderSource + = OutputsPrefixLen ;
if ( ! ReadInOut ( ShaderSource , Outputs ) )
{
return false ;
}
}
if ( FCStringAnsi : : Strncmp ( ShaderSource , UniformBlocksPrefix , UniformBlocksPrefixLen ) = = 0 )
{
ShaderSource + = UniformBlocksPrefixLen ;
while ( * ShaderSource & & * ShaderSource ! = ' \n ' )
{
FAttribute UniformBlock ;
if ( ! ParseIdentifier ( ShaderSource , UniformBlock . Name ) )
{
return false ;
}
if ( ! Match ( ShaderSource , ' ( ' ) )
{
return false ;
}
if ( ! ParseIntegerNumber ( ShaderSource , UniformBlock . Index ) )
{
return false ;
}
if ( ! Match ( ShaderSource , ' ) ' ) )
{
return false ;
}
UniformBlocks . Add ( UniformBlock ) ;
if ( Match ( ShaderSource , ' \n ' ) )
{
break ;
}
if ( Match ( ShaderSource , ' , ' ) )
{
continue ;
}
//#todo-rco: Need a log here
//UE_LOG(ShaderCompilerCommon, Warning, TEXT("Invalid char '%c'"), *ShaderSource);
return false ;
}
}
if ( FCStringAnsi : : Strncmp ( ShaderSource , UniformsPrefix , UniformsPrefixLen ) = = 0 )
{
// @todo-mobile: Will we ever need to support this code path?
check ( 0 ) ;
return false ;
/*
ShaderSource + = UniformsPrefixLen ;
while ( * ShaderSource & & * ShaderSource ! = ' \n ' )
{
uint16 ArrayIndex = 0 ;
uint16 Offset = 0 ;
uint16 NumComponents = 0 ;
FString ParameterName = ParseIdentifier ( ShaderSource ) ;
verify ( ParameterName . Len ( ) > 0 ) ;
verify ( Match ( ShaderSource , ' ( ' ) ) ;
ArrayIndex = ParseNumber ( ShaderSource ) ;
verify ( Match ( ShaderSource , ' : ' ) ) ;
Offset = ParseNumber ( ShaderSource ) ;
verify ( Match ( ShaderSource , ' : ' ) ) ;
NumComponents = ParseNumber ( ShaderSource ) ;
verify ( Match ( ShaderSource , ' ) ' ) ) ;
ParameterMap . AddParameterAllocation (
* ParameterName ,
ArrayIndex ,
Offset * BytesPerComponent ,
NumComponents * BytesPerComponent
) ;
if ( ArrayIndex < OGL_NUM_PACKED_UNIFORM_ARRAYS )
{
PackedUniformSize [ ArrayIndex ] = FMath : : Max < uint16 > (
PackedUniformSize [ ArrayIndex ] ,
BytesPerComponent * ( Offset + NumComponents )
) ;
}
// Skip the comma.
if ( Match ( ShaderSource , ' \n ' ) )
{
break ;
}
verify ( Match ( ShaderSource , ' , ' ) ) ;
}
Match ( ShaderSource , ' \n ' ) ;
*/
}
// @PackedGlobals: Global0(h:0,1),Global1(h:4,1),Global2(h:8,1)
if ( FCStringAnsi : : Strncmp ( ShaderSource , PackedGlobalsPrefix , PackedGlobalsPrefixLen ) = = 0 )
{
ShaderSource + = PackedGlobalsPrefixLen ;
while ( * ShaderSource & & * ShaderSource ! = ' \n ' )
{
FPackedGlobal PackedGlobal ;
if ( ! ParseIdentifier ( ShaderSource , PackedGlobal . Name ) )
{
return false ;
}
if ( ! Match ( ShaderSource , ' ( ' ) )
{
return false ;
}
PackedGlobal . PackedType = * ShaderSource + + ;
if ( ! Match ( ShaderSource , ' : ' ) )
{
return false ;
}
if ( ! ParseIntegerNumber ( ShaderSource , PackedGlobal . Offset ) )
{
return false ;
}
if ( ! Match ( ShaderSource , ' , ' ) )
{
return false ;
}
if ( ! ParseIntegerNumber ( ShaderSource , PackedGlobal . Count ) )
{
return false ;
}
if ( ! Match ( ShaderSource , ' ) ' ) )
{
return false ;
}
PackedGlobals . Add ( PackedGlobal ) ;
// Break if EOL
if ( Match ( ShaderSource , ' \n ' ) )
{
break ;
}
// Has to be a comma!
if ( Match ( ShaderSource , ' , ' ) )
{
continue ;
}
//#todo-rco: Need a log here
//UE_LOG(ShaderCompilerCommon, Warning, TEXT("Invalid char '%c'"), *ShaderSource);
return false ;
}
}
// Packed Uniform Buffers (Multiple lines)
// @PackedUB: CBuffer(0): CBMember0(0,1),CBMember1(1,1)
while ( FCStringAnsi : : Strncmp ( ShaderSource , PackedUBPrefix , PackedUBPrefixLen ) = = 0 )
{
ShaderSource + = PackedUBPrefixLen ;
FPackedUB PackedUB ;
if ( ! ParseIdentifier ( ShaderSource , PackedUB . Attribute . Name ) )
{
return false ;
}
if ( ! Match ( ShaderSource , ' ( ' ) )
{
return false ;
}
if ( ! ParseIntegerNumber ( ShaderSource , PackedUB . Attribute . Index ) )
{
return false ;
}
if ( ! Match ( ShaderSource , ' ) ' ) )
{
return false ;
}
if ( ! Match ( ShaderSource , ' : ' ) )
{
return false ;
}
if ( ! Match ( ShaderSource , ' ' ) )
{
return false ;
}
while ( * ShaderSource & & * ShaderSource ! = ' \n ' )
{
FPackedUB : : FMember Member ;
ParseIdentifier ( ShaderSource , Member . Name ) ;
if ( ! Match ( ShaderSource , ' ( ' ) )
{
return false ;
}
if ( ! ParseIntegerNumber ( ShaderSource , Member . Offset ) )
{
return false ;
}
if ( ! Match ( ShaderSource , ' , ' ) )
{
return false ;
}
if ( ! ParseIntegerNumber ( ShaderSource , Member . Count ) )
{
return false ;
}
if ( ! Match ( ShaderSource , ' ) ' ) )
{
return false ;
}
PackedUB . Members . Add ( Member ) ;
// Break if EOL
if ( Match ( ShaderSource , ' \n ' ) )
{
break ;
}
// Has to be a comma!
if ( Match ( ShaderSource , ' , ' ) )
{
continue ;
}
//#todo-rco: Need a log here
//UE_LOG(ShaderCompilerCommon, Warning, TEXT("Invalid char '%c'"), *ShaderSource);
return false ;
}
PackedUBs . Add ( PackedUB ) ;
}
// @PackedUBCopies: 0:0-0:h:0:1,0:1-0:h:4:1,1:0-1:h:0:1
if ( FCStringAnsi : : Strncmp ( ShaderSource , PackedUBCopiesPrefix , PackedUBCopiesPrefixLen ) = = 0 )
{
ShaderSource + = PackedUBCopiesPrefixLen ;
if ( ! ReadCopies ( ShaderSource , false , PackedUBCopies ) )
{
return false ;
}
}
// @PackedUBGlobalCopies: 0:0-h:12:1,0:1-h:16:1,1:0-h:20:1
if ( FCStringAnsi : : Strncmp ( ShaderSource , PackedUBGlobalCopiesPrefix , PackedUBGlobalCopiesPrefixLen ) = = 0 )
{
ShaderSource + = PackedUBGlobalCopiesPrefixLen ;
if ( ! ReadCopies ( ShaderSource , true , PackedUBGlobalCopies ) )
{
return false ;
}
}
if ( FCStringAnsi : : Strncmp ( ShaderSource , SamplersPrefix , SamplersPrefixLen ) = = 0 )
{
ShaderSource + = SamplersPrefixLen ;
while ( * ShaderSource & & * ShaderSource ! = ' \n ' )
{
FSampler Sampler ;
if ( ! ParseIdentifier ( ShaderSource , Sampler . Name ) )
{
return false ;
}
if ( ! Match ( ShaderSource , ' ( ' ) )
{
return false ;
}
if ( ! ParseIntegerNumber ( ShaderSource , Sampler . Offset ) )
{
return false ;
}
if ( ! Match ( ShaderSource , ' : ' ) )
{
return false ;
}
if ( ! ParseIntegerNumber ( ShaderSource , Sampler . Count ) )
{
return false ;
}
if ( Match ( ShaderSource , ' [ ' ) )
{
// Sampler States
do
{
FString SamplerState ;
if ( ! ParseIdentifier ( ShaderSource , SamplerState ) )
{
return false ;
}
Sampler . SamplerStates . Add ( SamplerState ) ;
}
while ( Match ( ShaderSource , ' , ' ) ) ;
if ( ! Match ( ShaderSource , ' ] ' ) )
{
return false ;
}
}
if ( ! Match ( ShaderSource , ' ) ' ) )
{
return false ;
}
Samplers . Add ( Sampler ) ;
// Break if EOL
if ( Match ( ShaderSource , ' \n ' ) )
{
break ;
}
// Has to be a comma!
if ( Match ( ShaderSource , ' , ' ) )
{
continue ;
}
//#todo-rco: Need a log here
//UE_LOG(ShaderCompilerCommon, Warning, TEXT("Invalid char '%c'"), *ShaderSource);
return false ;
}
}
if ( FCStringAnsi : : Strncmp ( ShaderSource , UAVsPrefix , UAVsPrefixLen ) = = 0 )
{
ShaderSource + = UAVsPrefixLen ;
while ( * ShaderSource & & * ShaderSource ! = ' \n ' )
{
FUAV UAV ;
if ( ! ParseIdentifier ( ShaderSource , UAV . Name ) )
{
return false ;
}
if ( ! Match ( ShaderSource , ' ( ' ) )
{
return false ;
}
if ( ! ParseIntegerNumber ( ShaderSource , UAV . Offset ) )
{
return false ;
}
if ( ! Match ( ShaderSource , ' : ' ) )
{
return false ;
}
if ( ! ParseIntegerNumber ( ShaderSource , UAV . Count ) )
{
return false ;
}
if ( ! Match ( ShaderSource , ' ) ' ) )
{
return false ;
}
UAVs . Add ( UAV ) ;
// Break if EOL
if ( Match ( ShaderSource , ' \n ' ) )
{
break ;
}
// Has to be a comma!
if ( Match ( ShaderSource , ' , ' ) )
{
continue ;
}
//#todo-rco: Need a log here
//UE_LOG(ShaderCompilerCommon, Warning, TEXT("Invalid char '%c'"), *ShaderSource);
return false ;
}
}
if ( FCStringAnsi : : Strncmp ( ShaderSource , SamplerStatesPrefix , SamplerStatesPrefixLen ) = = 0 )
{
ShaderSource + = SamplerStatesPrefixLen ;
while ( * ShaderSource & & * ShaderSource ! = ' \n ' )
{
FAttribute SamplerState ;
if ( ! ParseIntegerNumber ( ShaderSource , SamplerState . Index ) )
{
return false ;
}
if ( ! Match ( ShaderSource , ' : ' ) )
{
return false ;
}
if ( ! ParseIdentifier ( ShaderSource , SamplerState . Name ) )
{
return false ;
}
SamplerStates . Add ( SamplerState ) ;
2015-07-02 15:19:30 -04:00
// Break if EOL
if ( Match ( ShaderSource , ' \n ' ) )
{
break ;
}
// Has to be a comma!
if ( Match ( ShaderSource , ' , ' ) )
{
continue ;
}
//#todo-rco: Need a log here
//UE_LOG(ShaderCompilerCommon, Warning, TEXT("Invalid char '%c'"), *ShaderSource);
return false ;
2015-07-02 11:52:03 -04:00
}
}
if ( FCStringAnsi : : Strncmp ( ShaderSource , NumThreadsPrefix , NumThreadsPrefixLen ) = = 0 )
{
ShaderSource + = NumThreadsPrefixLen ;
if ( ! ParseIntegerNumber ( ShaderSource , NumThreads [ 0 ] ) )
{
return false ;
}
if ( ! Match ( ShaderSource , ' , ' ) )
{
return false ;
}
if ( ! Match ( ShaderSource , ' ' ) )
{
return false ;
}
if ( ! ParseIntegerNumber ( ShaderSource , NumThreads [ 1 ] ) )
{
return false ;
}
if ( ! Match ( ShaderSource , ' , ' ) )
{
return false ;
}
if ( ! Match ( ShaderSource , ' ' ) )
{
return false ;
}
if ( ! ParseIntegerNumber ( ShaderSource , NumThreads [ 2 ] ) )
{
return false ;
}
if ( ! Match ( ShaderSource , ' \n ' ) )
{
return false ;
}
}
Copying //UE4/Dev-Rendering to //UE4/Dev-Main (Source: //UE4/Dev-Rendering @ 3231693)
#lockdown Nick.Penwarden
#rb none
==========================
MAJOR FEATURES + CHANGES
==========================
Change 3219796 on 2016/12/02 by Rolando.Caloca
DR - vk - Increase timeout to 60ms
Change 3219884 on 2016/12/02 by Daniel.Wright
Assert to help track down rare crash locking capsule indirect shadow vertex buffer
Change 3219885 on 2016/12/02 by Daniel.Wright
Fixed saving a package that doesn't exist on disk but exists in p4 at a newer revision when the user chooses 'Mark Writable'
Change 3219886 on 2016/12/02 by Daniel.Wright
Don't create projected shadows when r.ShadowQuality is 0
* Fixes crash in the forward path trying to render shadows
* In the deferred path, the shadowmap was still being rendered and only the projection skipped, now all cost will be skipped
Change 3219887 on 2016/12/02 by Daniel.Wright
Changed ClearRenderTarget2D default alpha to 1, which is necessary for correct compositing
Change 3219893 on 2016/12/02 by Daniel.Wright
AMD AGS library with approved TPS
Disabled DFAO on AMD pre-GCN PC video cards to workaround a driver bug which won't be fixed (Radeon 6xxx and below)
Change 3219913 on 2016/12/02 by Daniel.Wright
Level unload of a lighting scenario propagates the lighting scenario change - fixes crash when precomputed lighting volume data gets unloaded
Change 3220029 on 2016/12/02 by Daniel.Wright
Async shader compiling now recreates scene proxies which are affected by the material which was compiled. This fixes crashes which were occuring as proxies cache various material properties, but applying compiled materials would not update these cached properties (bRequiresAdjacencyInformation).
* A new ensure has been added in FMeshElementCollector::AddMesh and FBatchingSPDI::DrawMesh to catch attempts to render with a material not reported in GetUsedMaterials
* Fixed UParticleSystemComponent::GetUsedMaterials and UMaterialBillboardComponent::GetUsedMaterials
* FMaterialUpdateContext should be changed to use the same pattern, but that hasn't been done yet
Change 3220108 on 2016/12/02 by Daniel.Wright
Fixed shadowmap channel assignment for stationary lights which are not in a lighting scenario level, when a lighting scenario level is present
Change 3220504 on 2016/12/03 by Mark.Satterthwaite
Metal Desktop Tessellation support from Unicorn.
- Apple: Metal tessellation support added to MetalShaderFormat, MetalRHI and incl. changes to engine runtime/shaders for Desktop renderer and enabled in ElementalDemo by default (OS X 10.11 will run SM4).
- Epic: Support for different Metal shader standards on Mac, iOS & tvOS which required moving some RHI functions around as this is a project setting and not a compile-time constant.
- Epic: Fragment shader UAV support, which is also tied to newer Metal shader standard like Tessellation.
- Epic: Significant refactor of MetalRHI's internals to clearly separate state-caching from render-pass management and command-encoding.
- Epic: Internal MetalRHI validation code is now cleanly separated out into custom implementations of the Metal @protocol's and is on by default.
- Epic: Various fixes to Layered Rendering for Metal.
- Omits Mobile Tessellation support which needs further revision.
Change 3220881 on 2016/12/04 by Mark.Satterthwaite
Compiles fixes for iOS & static analysis fixes from Windows.
Change 3221180 on 2016/12/05 by Guillaume.Abadie
Avoid compiling PreviousFrameSwitch's both Current Frame and Previous Frame inputs every time.
Change 3221217 on 2016/12/05 by Chris.Bunner
More NVAPI warning fixups.
Change 3221219 on 2016/12/05 by Chris.Bunner
When comparing overriden properties used to force instance recompilation we need to check against the base material, not assume the immediate parent.
#jira UE-37792
Change 3221220 on 2016/12/05 by Chris.Bunner
Exported GetAllStaticSwitchParamNames and GetAllStaticComponentMaskParamNames.
#jira UE-35132
Change 3221221 on 2016/12/05 by Chris.Bunner
PR #2785: Fix comment typo in RendererInterface.h (Contributed by dustin-biser)
#jira UE-35760
Change 3221223 on 2016/12/05 by Chris.Bunner
Default to include dev-code when compiling material preview stats.
#jira UE-20321
Change 3221534 on 2016/12/05 by Rolando.Caloca
DR - Added FDynamicRHI::GetName()
Change 3221833 on 2016/12/05 by Chris.Bunner
Set correct output extent on PostProcessUpscale (allows users to extend chain correctly).
#jira UE-36989
Change 3221852 on 2016/12/05 by Chris.Bunner
32-bit/ch EXR screenshot and frame dump output.
Fixed row increment bug in 128-bit/px surface format readback.
#jira UE-37962
Change 3222059 on 2016/12/05 by Rolando.Caloca
DR - vk - Fix memory type not found
Change 3222104 on 2016/12/05 by Rolando.Caloca
DR - Lambdaize
- Added quicker method to check if system textures are initialized
Change 3222290 on 2016/12/05 by Mark.Satterthwaite
Trivial fixes to reporting Metal shader pipeline errors - need to check if Hull & Domain exist.
Change 3222864 on 2016/12/06 by Rolando.Caloca
DR - Fix mem leak when exiting
Change 3222873 on 2016/12/06 by Rolando.Caloca
DR - vk - Minor info to help track down leaks
Change 3222875 on 2016/12/06 by Rolando.Caloca
DR - Fix mem leak with VisualizeTexture
#jira UE-39360
Change 3223226 on 2016/12/06 by Chris.Bunner
Static analysis warning workaround.
Change 3223235 on 2016/12/06 by Ben.Woodhouse
Integrate from NREAL: Set a custom projection matrix on a SceneCapture2D
Change 3223343 on 2016/12/06 by Chris.Bunner
Moved HLOD persistent data to viewstate to fix per-view compatability.
#jira UE-37539
Change 3223349 on 2016/12/06 by Chris.Bunner
Fixed HLOD with FreezeRendering command.
#jira UE-29839
Change 3223371 on 2016/12/06 by Michael.Trepka
Removed obsolete check() in FMetalSurface constructor
Change 3223450 on 2016/12/06 by Chris.Bunner
Added explicit ScRGB output device selection rather than Nvidia-only hardcoded checks. Allows easier support for Mac and other devices moving forward.
Change 3223638 on 2016/12/06 by Michael.Trepka
Restored part of the check() in FMetalSurface constructor removed in CL 3223371
Change 3223642 on 2016/12/06 by Mark.Satterthwaite
Experimental Metal EDR/HDR output support for Mac (iOS/tvOS need custom formats & shaders so they are not supported yet).
- Only available on macOS Sierra (10.12) for Macs with HDR displays (e.g. Retina iMacs).
- Enable with -metaledr command-line argument as it is off-by-default.
- Sets up the CAMetalLayer & the back-buffer for RGBA_FP16 output on Mac using DCI-P3 as the color gamut and ACES 1000 nit ScRGB output encoding.
Change 3223830 on 2016/12/06 by Rolando.Caloca
DR - vk - Better error when finding an invalid Vulkan driver
#jira UE-37495
Change 3223869 on 2016/12/06 by Rolando.Caloca
DR - vk - Reuse fences
Change 3223906 on 2016/12/06 by Guillaume.Abadie
Fix alpha through TempAA artifact causing a small darker edge layouts.
Change 3224199 on 2016/12/06 by Mark.Satterthwaite
Fix a dumb copy-paste error from the HDR changes to Metal.
Change 3224220 on 2016/12/06 by Mark.Satterthwaite
Fix various errors with Metal UAV & Render-Pass Restart support so that we can use the Pixel Shader culling for DistanceField effects.
- Unfortunately Metal requires that a texture be bound to start a render-pass, so reuse the dummy depth-stencil surface from the problematic editor preview tile rendering.
Change 3224236 on 2016/12/06 by Mark.Satterthwaite
IWYU CIS compile fix for iOS.
Change 3224366 on 2016/12/06 by Mark.Satterthwaite
Simplify some of the changes from CL# 3224220 so that we don't perform unnecessary clears.
- If the RenderPass is broken to issue compute or blit operations then treat the cached RenderTargetsInfo as invalid, unless the RenderPass is restarted.
- This guarantees that we don't erroneously ignore calls to SetRenderTargets if the calling code issues a dispatch between two RenderPasses that use the same RenderTargetsInfo.
Change 3224416 on 2016/12/06 by Uriel.Doyon
New default implementation for UPrimitiveComponent::GetStreamingTextureInfo using a conservative heuristic where the textures are stretched across the bounds.
Optimized UPrimitiveComponent::GetStreamingTextureInfoWithNULLRemoval by not handling registered components with no proxy (essentially hidden game / collision primitives).
Added blueprint support for texture streaming built data through FStaticMeshComponentInstanceData.
Fix for material texture streaming data not being available on some cooked builds.
Enabled split requests on all texture load requests (first loading everything visible and then loaded everything not visible).
This is controlled by "r.Streaming.MinMipForSplitRequest" which defines the minimum mip for which to allow splitting.
Forced residency are now loaded in two steps (visible, then forced), improving reactiveness.
Updated "stat streaming" to include "UnkownRefMips" which represent texture with no known component referencing them,
and also "LastRenderTimeMips" which related to timed primitives.
Changed "Forced Mips" so that it only shows mips that are loaded become of forced residency.
"Texture Streaming Build" now updates the map check after execution.
Removed Orphaned texture logic as this has become irrelevant with the latest retention priority logic.
Updated "r.streaming.usenewmetrics" so that it shows behavior before and after 4.12 improvements.
Change 3224532 on 2016/12/07 by Uriel.Doyon
Integrated CL 3223965 :
Building texture streaming data for materials does not wait for pending shaders to finish compilation anymore.
Added more options to allow the user to cancel this build also.
Change 3224714 on 2016/12/07 by Ben.Woodhouse
Cherry pick CL 3223972 from //fortnite/main:
Disable Geometry shader onchip on XB1. This saves 4ms for a single shadow casting point light @ 512x512 (4.8ms to 1.8ms)
Change 3224715 on 2016/12/07 by Ben.Woodhouse
New version of d3dx12.h from Microsoft which incorporates my suggested static analysis fixes. This avoids us diverging from the official version
Change 3224975 on 2016/12/07 by Rolando.Caloca
DR - vk - Dump improvements
Change 3225012 on 2016/12/07 by Rolando.Caloca
DR - Show warning if trying to use num samples != (1,2,4,8,16)
Change 3225126 on 2016/12/07 by Chris.Bunner
Added 'force 128-bit rendering pipeline' to high-res screenshot tool.
#jira UE-39345
Change 3225449 on 2016/12/07 by Chris.Bunner
Updated engine rendering defaults to better match current best practices.
#jira UE-38081
Change 3225485 on 2016/12/07 by Chris.Bunner
Moved QuantizeSceneBufferSize to RenderCore and added call for PostProcess settings. Fixes screenpercentage out-of-bounds reads in some cases.
#jira UE-19394
Change 3225486 on 2016/12/07 by Chris.Bunner
Only disable TAA during HighResScreenshots if we don't have a reasonable frame-delay enabled.
Change 3225505 on 2016/12/07 by Daniel.Wright
Fixed exponential height fog disappearing with no skybox
Change 3225655 on 2016/12/07 by Benjamin.Hyder
Updating TM-Shadermodels to include Translucent lighting, Two sided, updated cloth animation, and adjusted lighting.
Change 3225668 on 2016/12/07 by Chris.Bunner
Dirty owning packages when user manually forces regeneration of all reflection captures.
#jira UE-38759
Change 3226139 on 2016/12/07 by Rolando.Caloca
DR - Fix recompute tangents disabling skin cache
- Make some macros into lambdas
#jira UE-39143
Change 3226212 on 2016/12/07 by Daniel.Wright
Features which require a full prepass use DDM_AllOpaque instead of DDM_AllOccluders, which can be skipped if the component has bUseAsOccluder=false
Change 3226213 on 2016/12/07 by Daniel.Wright
Scene Capture 2D can specify a global clip plane, which is useful for portals
* Requires the global clip plane project setting to be enabled
Change 3226214 on 2016/12/07 by Daniel.Wright
Improved deferred shadowing with MSAA by upsampling light attenuation intelligently in the base pass
* If the current fragment's depth doesn't match what was used for deferred shadowing, the neighbor (cross pattern) with the nearest depth's shadowing is used
* Edge artifacts can still occur where the upsample fails or the shadow factor was computed per-sample due to depth / stencil testing
* Indirect Occlusion from capsule shadows also uses the nearest depth neighbor UV for no extra cost
* Base pass on 970 GTX 1.69ms -> 1.85ms (.16ms) in RoboRecall
Change 3226258 on 2016/12/07 by Rolando.Caloca
DR - Typo fix
Change 3226259 on 2016/12/07 by Rolando.Caloca
DR - compile fix
#jira UE-39143
Change 3226932 on 2016/12/08 by Chris.Bunner
Re-saved Infiltrator maps to update reflection captures.
#jira UE-38759
Change 3227063 on 2016/12/08 by Mark.Satterthwaite
For Metal platforms ONLY temporarily disable USE_LIGHT_GRID_REFLECTION_CAPTURE_CULLING to avoid UE-37436 while the Nvidia driver team investigate why this doesn't work for them but does for the others. This won't affect non-Metal platforms and the intent is to revert this prior to 4.16 provided we can work through the problem with Nvidia.
#jira UE-37436
Change 3227120 on 2016/12/08 by Gil.Gribb
Merging //UE4/Dev-Main@3226895 to Dev-Rendering (//UE4/Dev-Rendering)
Change 3227211 on 2016/12/08 by Arne.Schober
DR - UE-38585 - Fixing crash where HierInstStaticMesh duplication fails. Also reverting the fix from UE-28189 which is redundant.
Change 3227257 on 2016/12/08 by Marc.Olano
Extension to PseudoVolumeTexture for more flexible layout
Change by ryan.brucks
Change 3227286 on 2016/12/08 by Rolando.Caloca
DR - Fix crash when using custom expressions and using reserved keywords
#jira UE-39311
Change 3227376 on 2016/12/08 by Mark.Satterthwaite
Must not include a private header inside the MenuStack public header as that causes compile errors in plugins.
Change 3227415 on 2016/12/08 by Mark.Satterthwaite
Fix shader compilation due to my disabling of USE_LIGHT_GRID_REFLECTION_CAPTURE_CULLING on Metal - InstancedCompositeTileReflectionCaptureIndices needs to be defined even though Metal doesn't support instanced-stereo rendering.
Change 3227516 on 2016/12/08 by Daniel.Wright
Implemented UWidgetComponent::GetUsedMaterials
Change 3227521 on 2016/12/08 by Guillaume.Abadie
Fixes post process volume's indirect lighting color.
#jira UE-38888
Change 3227567 on 2016/12/08 by Marc.Olano
New upscale filters: Lanczos-2 (new default), Lanczos-3 and Gaussian Unsharp Mask
Change 3227628 on 2016/12/08 by Daniel.Wright
Removed redundant ResolveSceneDepthTexture from the merge
Change 3227635 on 2016/12/08 by Daniel.Wright
Forward renderer supports shadowing from movable lights and light functions
* Only 4 shadow casting movable or stationary lights can overlap at any point in space, otherwise the movable lights will lose their shadows and an on-screen message will be displayed
* Light functions only work on shadow casting lights since they need a shadowmap channel to be assigned
Change 3227660 on 2016/12/08 by Rolando.Caloca
DR - vk - Fix r.MobileMSAA on Vulkan
- r.MobileMSAA is now read-only (to be fixed on 4.16)
- Show time for PSO creation hitches
#jira UE-39184
Change 3227704 on 2016/12/08 by Mark.Satterthwaite
Fix Mac HDR causing incorrect output color encoding being used, HDR support is now entirely off unless you pass -metaledr which will enable it regardless of whether the current display supports HDR (as we haven't written the detection code yet). Fixed the LUT/UI compositing along the way - Mac Metal wasn't using volume LUT as it should have been, RHISupportsVertexShaderLayer now correctly returns false for non-Mac Metal platforms.
Change 3227705 on 2016/12/08 by Daniel.Wright
Replaced built-in samplers in the nearest depth translucency upsample because the built-in samplers are no longer bound on PC (cl 2852426)
Change 3227787 on 2016/12/08 by Chris.Bunner
Added extent clear to motion blur pass to catch misized buffers bringing in errors.
Added early out to clear call when excluded region matches RT region.
#jira UE-39437
Change 3228177 on 2016/12/08 by Marc.Olano
Fix DCC sqrt(int) error
Change 3228285 on 2016/12/08 by Chris.Bunner
Back out changelist 3225449.
#jira UE-39528
Change 3228680 on 2016/12/09 by Gil.Gribb
Merging //UE4/Dev-Main@3228528 to Dev-Rendering (//UE4/Dev-Rendering)
Change 3228940 on 2016/12/09 by Mark.Satterthwaite
Editor fixes for 4.15:
- PostProcessTonemap can't fail to bind a texture to the ColorLUT or the subsequent rendering will be garbage: the changes for optimising stereo rendering forgot to account for the Editor's use of Views without States for the asset preview thumbnails. Amended the CombineLUT post-processing to allocate a local output texture when there's no ViewState and read from this when this situation arises which makes everything function again.
- Don't start render-passes without a valid render-target-array in MetalRHI.
Change 3228950 on 2016/12/09 by Mark.Satterthwaite
Make GPUSkinCache run on Mac Metal - it wasn't working because it was forcibly disabled on all platforms but for Windows D3D 11.
- Fixed the Skeleton editor tree trying to access a widget before it has been constructed.
- Enable GPUSkinCache for Metal SM5: doesn't render correctly, even on AMD, so needs Radar's filing and investigation.
#jira UE-39256
Change 3229013 on 2016/12/09 by Mark.Satterthwaite
Further tidy up in SSkeletonTreeView as suggested by Nick.A.
Change 3229101 on 2016/12/09 by Chris.Bunner
Log compile error fix and updated cvar comments.
Change 3229236 on 2016/12/09 by Ben.Woodhouse
XB1 D3D11 and D3D12: Use the DXGI frame statistics to get accurate GPU time unaffected by bubbles
Change 3229430 on 2016/12/09 by Ben.Woodhouse
PR #2680: Optimized histogram generation. (Contributed by PjotrSvetachov)
Profiled on nvidia 980GTX (2x faster), and on XB1 (marginally faster)
Change 3229580 on 2016/12/09 by Marcus.Wassmer
DepthBoundsTest for AMD.
Change 3229701 on 2016/12/09 by Michael.Trepka
Changed "OS X" to "macOS" in few places where we display it and updated the code that asks users to update to latest version to check for 10.12.2
Change 3229706 on 2016/12/09 by Chris.Bunner
Added GameUserSettings controls for HDR display output.
Removed Metal commandline as this should replace the need for it.
Change 3229774 on 2016/12/09 by Michael.Trepka
Disabled OpenGL on Mac. -opengl is now ignored, we always use Metal. On old Macs that do not support Metal we show a message saying that the app requires Metal and exit.
Change 3229819 on 2016/12/09 by Chris.Bunner
Updated engine rendering defaults to better match current best practices.
#jira UE-38081
Change 3229948 on 2016/12/09 by Rolando.Caloca
DR - Fix d3d debug error
#jira UE-39589
Change 3230341 on 2016/12/11 by Mark.Satterthwaite
Don't fatally assert that the game-thread stalled waiting for the rendering thread in the Editor executable, even when running -game as the rendering thread can take a while to respond if shaders need to be compiled.
#jira UE-39613
Change 3230860 on 2016/12/12 by Marcus.Wassmer
Experimental Nvidia AFR support.
Change 3230930 on 2016/12/12 by Mark.Satterthwaite
Disable RHICmdList state-caching on Mac - Metal already does this internally and depends on receiving all state changes in order to function.
Change 3231252 on 2016/12/12 by Marcus.Wassmer
Fix NumGPU detection. (SLI only crash)
Change 3231486 on 2016/12/12 by Mark.Satterthwaite
Fix a stupid mistake in MetalStateCache::CommitResourceTable that would unnecessarily rebind samplers.
Change 3231661 on 2016/12/12 by Mark.Satterthwaite
Retain the RHI samplers in MetalRHI to guarantee lifetime.
[CL 3231696 by Gil Gribb in Main branch]
2016-12-12 17:47:42 -05:00
Copying //UE4/Dev-Rendering to //UE4/Dev-Main (Source: //UE4/Dev-Rendering @ 3185985)
#lockdown Nick.Penwarden
#rb none
==========================
MAJOR FEATURES + CHANGES
==========================
Change 3170391 on 2016/10/21 by Ben.Woodhouse
Remove the wait on end of frame ensure, because we can't rely on all the the underlying codepaths to never miss a call to flush RHI resources. The consequences of missing a flush on a given frame are not serious now, since we enforce the synchronisation with a fence, preventing the rendering thread from getting too far ahead. We will simply accumulate resources for an additional frame when this happens.
#jira UE-37437
#fyi rolando.caloca, marcus.wassmer
Change 3170659 on 2016/10/21 by Rolando.Caloca
DR - vk - Prep work for state key changes
Change 3170676 on 2016/10/21 by Rolando.Caloca
DR - vk - Reworked blend state keys
- Added depth/stencil to pipeline key
Change 3170848 on 2016/10/21 by Daniel.Wright
Level viewport 'show stats' option is now enabled by default, which avoids confusion with artists thinking lighting is built, when really the message is hidden.
Change 3170849 on 2016/10/21 by Daniel.Wright
Split FProjectedShadowInfo::RenderProjection into smaller functions which make the algorithm structure clear
Change 3170995 on 2016/10/21 by Rolando.Caloca
DR - vk - Show object on vulkan validation msgs
Change 3171085 on 2016/10/21 by Rolando.Caloca
DR - vk - Fix pipelines being used with incompatible renderpasses
Change 3171159 on 2016/10/21 by Rolando.Caloca
DR - vk - Fix layout when reading textures on CPU
Change 3171167 on 2016/10/21 by Rolando.Caloca
DR - vk - compile fix
Change 3172462 on 2016/10/24 by Daniel.Wright
Added a warning about shader compile times to the material tooltip
Change 3172463 on 2016/10/24 by Daniel.Wright
Reduced MinUnoccludedFraction to avoid artitfacts when a stationary light touches only a tiny part of a mesh
Change 3172716 on 2016/10/24 by Brian.Karis
Fix for crash UE-37369 when reimporting over a generated LOD.
Change 3172967 on 2016/10/24 by Rolando.Caloca
DR - vk - Fix writing buffers while GPU was using them
Change 3174187 on 2016/10/25 by Olaf.Piesche
UE-37020
Change 3174718 on 2016/10/26 by Rolando.Caloca
DR - vk - Remove old timestamp queries, increase occlusion queries per pool to 4k
Change 3175960 on 2016/10/26 by Rolando.Caloca
DR - Added support for hlslcc header to have custom parsing
Change 3176611 on 2016/10/27 by David.Hill
DrawWireCone confusion:
In response to a UDN, I'm updating confusing parameter names and comments for
DrawWireCone() and DrawWireSphereCappedCone()
Change 3177111 on 2016/10/27 by Rolando.Caloca
DR - vk - Fix timestamps for frame
Change 3177192 on 2016/10/27 by Arne.Schober
DR - DitherLOD refactor - moved computation of the DepthStencil state out of SetMeshRenderState into GetDitheredLODTransitionState this is a prerequisite of further PSO work where we want to move up State setting in a similar war and reuse FMeshDrawingRenderState
Change 3177278 on 2016/10/27 by Olaf.Piesche
UE-37484
Change 3177297 on 2016/10/27 by Rolando.Caloca
DR - vk - Enable GRHISupportsBaseVertexIndex
Change 3177607 on 2016/10/27 by Rolando.Caloca
DR - vk - SM4 UB prep
Change 3178052 on 2016/10/28 by Arne.Schober
DR - fix WebGL - the WebGL compiler is very picky on double underscores and does want the presission to be defined before any function definition.
Change 3178156 on 2016/10/28 by Rolando.Caloca
DR - vk - Added query timer
- Fixed inline issues
Change 3178158 on 2016/10/28 by Rolando.Caloca
DR - vk - Fixes for out of stencil bits
Change 3178462 on 2016/10/28 by Rolando.Caloca
DR - vk - Fixes for Elemental
Change 3179131 on 2016/10/28 by Rolando.Caloca
DR - vk - Fix for r.Vulkan.UseRealUBs
Change 3179139 on 2016/10/28 by Rolando.Caloca
DR - vk - Move UB ring buffer to context
Change 3179145 on 2016/10/28 by Rolando.Caloca
DR - vk - Fix buffer barriers
Change 3179888 on 2016/10/31 by Rolando.Caloca
DR - vk - Align buffers to 16 bytes as we sometimes write to them with SIMD
Change 3179923 on 2016/10/31 by Rolando.Caloca
DR - vk - Wait for swapchain counter
Change 3180430 on 2016/10/31 by Rolando.Caloca
DR - vk - Properly wait for occlusion queries/cmd buffer
- Actual log error if trying to use occlusion queries out of order
Change 3180746 on 2016/10/31 by Rolando.Caloca
DR - vk - Undo some waiting as it was on the wrong thread
Change 3182115 on 2016/11/01 by Rolando.Caloca
DR - hlslcc Linux path fix
Change 3182118 on 2016/11/01 by Daniel.Wright
Fixed global distance field seam artifacts from landscapes with no subsections
Change 3182368 on 2016/11/01 by Daniel.Wright
Dynamic Indirect Shadows for static meshes using distance fields
* These Distance Field indirect shadows use the same tile culled and downsampled framework that capsule shadows use, with similar GPU cost
* Individual StaticMesh assets can enable bGenerateMeshDistanceField to compute a distance field, without the memory cost of enabling for the whole project
* New StaticMeshComponent properties bCastDynamicIndirectShadow and DynamicIndirectShadowMinVisibility
* New WorldSettings property DynamicIndirectShadowsSelfShadowingIntensity which replaces the cvar
* The GBuffer now stores HasDynamicIndirectShadowCasterRepresentation instead of HasHeightfieldRepresentation
* DFAO from landscape is now done through the global distance field entirely. Landscape contribution to the global distance field is deferred to attempt to workaround texture streaming issues.
Change 3182408 on 2016/11/01 by Rolando.Caloca
DR - vk - Reworked occlusion queries, fixes flickering on AMD
Change 3182585 on 2016/11/01 by Daniel.Wright
PS4 compile fix
Change 3183151 on 2016/11/02 by Rolando.Caloca
DR - vk - Fix issue when processing super quick cmd buffers
Change 3183160 on 2016/11/02 by Rolando.Caloca
Dr - vk - Call reset queries outside render pass
Change 3183182 on 2016/11/02 by Rolando.Caloca
DR - Switch clear
Change 3183194 on 2016/11/02 by Rolando.Caloca
DR - Try to catch crash ahead of time
Change 3183268 on 2016/11/02 by Rolando.Caloca
DR - vk - Rename RenderPassState to TransitionState
Change 3183440 on 2016/11/02 by Daniel.Wright
Renamed 'Dynamic Indirect Shadow' to 'Distance Field Indirect Shadow'
Change 3183793 on 2016/11/02 by Daniel.Wright
Added ShadowResolutionScale to lightcomponent
Change 3183796 on 2016/11/02 by Daniel.Wright
Improved bSimulatePhysics comment, with info on why it might be greyed out
Change 3183797 on 2016/11/02 by Daniel.Wright
Precomputed shadowmaps no longer enable Force2To1Aspect, which is only needed for lightmaps. Improves shadowmap utilization.
Change 3183915 on 2016/11/02 by Rolando.Caloca
DR - vk - Remove redundant renderpasses
Change 3183991 on 2016/11/02 by Daniel.Wright
Added r.ReflectionEnvironmentLightmapMixLargestWeight, useful for restricting lightmap mixing to darkening only
Change 3184001 on 2016/11/02 by Daniel.Wright
Better draw event for IndirectCapsuleShadows in stereo
Change 3184096 on 2016/11/02 by Chris.Bunner
HDR for D3D11 - NVAPI toggle and encoding, UI compositing.
Removed some outdated tonemamping cvars and modes.
Change 3184399 on 2016/11/02 by Daniel.Wright
Static analysis workaround
Change 3184455 on 2016/11/02 by Mark.Satterthwaite
Fix missing log10 from FCompositePS on hlslcc shader platforms so that QA can continue their integration.
#jira UE-38164
Change 3184953 on 2016/11/03 by Chris.Bunner
Fixing CIS warnings.
[CL 3186011 by Marcus Wassmer in Main branch]
2016-11-03 16:55:27 -04:00
return ParseCustomHeaderEntries ( ShaderSource ) ;
2015-07-02 11:52:03 -04:00
}
bool FHlslccHeader : : ReadCopies ( const ANSICHAR * & ShaderSource , bool bGlobals , TArray < FPackedUBCopy > & OutCopies )
{
while ( * ShaderSource & & * ShaderSource ! = ' \n ' )
{
FPackedUBCopy PackedUBCopy ;
PackedUBCopy . DestUB = 0 ;
if ( ! ParseIntegerNumber ( ShaderSource , PackedUBCopy . SourceUB ) )
{
return false ;
}
if ( ! Match ( ShaderSource , ' : ' ) )
{
return false ;
}
if ( ! ParseIntegerNumber ( ShaderSource , PackedUBCopy . SourceOffset ) )
{
return false ;
}
if ( ! Match ( ShaderSource , ' - ' ) )
{
return false ;
}
if ( ! bGlobals )
{
if ( ! ParseIntegerNumber ( ShaderSource , PackedUBCopy . DestUB ) )
{
return false ;
}
if ( ! Match ( ShaderSource , ' : ' ) )
{
return false ;
}
}
PackedUBCopy . DestPackedType = * ShaderSource + + ;
if ( ! Match ( ShaderSource , ' : ' ) )
{
return false ;
}
if ( ! ParseIntegerNumber ( ShaderSource , PackedUBCopy . DestOffset ) )
{
return false ;
}
if ( ! Match ( ShaderSource , ' : ' ) )
{
return false ;
}
if ( ! ParseIntegerNumber ( ShaderSource , PackedUBCopy . Count ) )
{
return false ;
}
OutCopies . Add ( PackedUBCopy ) ;
// Break if EOL
if ( Match ( ShaderSource , ' \n ' ) )
{
break ;
}
// Has to be a comma!
if ( Match ( ShaderSource , ' , ' ) )
{
continue ;
}
//#todo-rco: Need a log here
//UE_LOG(ShaderCompilerCommon, Warning, TEXT("Invalid char '%c'"), *ShaderSource);
return false ;
}
return true ;
}
bool FHlslccHeader : : ReadInOut ( const ANSICHAR * & ShaderSource , TArray < FInOut > & OutAttributes )
{
while ( * ShaderSource & & * ShaderSource ! = ' \n ' )
{
FInOut Attribute ;
if ( ! ParseIdentifier ( ShaderSource , Attribute . Type ) )
{
return false ;
}
if ( Match ( ShaderSource , ' [ ' ) )
{
if ( ! ParseIntegerNumber ( ShaderSource , Attribute . ArrayCount ) )
{
return false ;
}
if ( ! Match ( ShaderSource , ' ] ' ) )
{
return false ;
}
}
else
{
Attribute . ArrayCount = 0 ;
}
2015-07-02 14:43:11 -04:00
if ( Match ( ShaderSource , ' ; ' ) )
2015-07-02 11:52:03 -04:00
{
2015-07-02 14:43:11 -04:00
if ( ! ParseSignedNumber ( ShaderSource , Attribute . Index ) )
{
return false ;
}
2015-07-02 11:52:03 -04:00
}
if ( ! Match ( ShaderSource , ' : ' ) )
{
return false ;
}
if ( ! ParseIdentifier ( ShaderSource , Attribute . Name ) )
{
return false ;
}
2015-07-10 14:14:44 -04:00
// Optional array suffix
if ( Match ( ShaderSource , ' [ ' ) )
{
Attribute . Name + = ' [ ' ;
while ( * ShaderSource )
{
Attribute . Name + = * ShaderSource ;
if ( Match ( ShaderSource , ' ] ' ) )
{
break ;
}
+ + ShaderSource ;
}
}
2015-07-02 11:52:03 -04:00
OutAttributes . Add ( Attribute ) ;
// Break if EOL
if ( Match ( ShaderSource , ' \n ' ) )
{
break ;
}
// Has to be a comma!
if ( Match ( ShaderSource , ' , ' ) )
{
continue ;
}
//#todo-rco: Need a log here
//UE_LOG(ShaderCompilerCommon, Warning, TEXT("Invalid char '%c'"), *ShaderSource);
return false ;
}
return true ;
}
2014-06-30 18:32:57 -04:00
}