Files
UnrealEngineUWP/Engine/Source/Developer/ShaderFormatVectorVM/Private/VectorVMShaderCompiler.cpp
Marcus Wassmer 64e19e2224 Copying //UE4/Dev-Rendering to //UE4/Dev-Main (Source: //UE4/Dev-Rendering @ 3511476)
#lockdown Nick.Penwarden

=====================================
 MAJOR FEATURES + CHANGES
=====================================

Change 3372740 by Chris.Bunner

	[Experimental] Partial compute post process pipeline (r.PostProcess.PreferCompute).
	StencilSceneTexture added to deferred list.
	A few known issues to be fixed in a follow-up CL.

Change 3374187 by Chris.Bunner

	Volume texture support for CombineLUTs/Tonemap compute pass.
	Refactored common param code to shared sub-class in CombineLUTs and Tonemap PS/CS.
	Skip compute post process out-of-bounds writes.
	Unsigned type conversion fixes.
	Trimmed compute post process shader inputs.

Change 3441680 by Uriel.Doyon

	Added units to point light intensity, to allow the user to specify the value in candelas or lumens.
	New point light actors now configure the intensity in candelas by default.
	Replaced viewport exposure settings by an EV100 slider.
	Hidding the tone mapper in the show flag now still applies the exposure.
	Added a new AutoExposure method called EV100 which allows to specify :
	- MinEV100, MaxEV100
	- Calibration Constnat
	- Exposure Compensation
	#jira UE-42783

Change 3454636 by Uriel.Doyon

	Fixed point light having an extra scale of 16 in mobile
	#jira UE-45272

Change 3454844 by Uriel.Doyon

	Fixed extra X16 on some point lights
	#jira UE-45250

Change 3454934 by Chris.Bunner

	Backing out changelists 3441680, 3454636 and 3454844 for the sake of integration stability.

Change 3461206 by Guillaume.Abadie

	Adds possibility to scene captures and player controller to render no primitives at all.

Change 3461207 by Guillaume.Abadie

	Exposes showflag details to USceneCaptureComponent. This gives the possibility to configure scene capture's showflags in blueprint encapsulated compositing pipeline.

	#jira UE-6810

Change 3461233 by Chris.Bunner

	Added Log10 material expression.
	Added tooltip for Log2 and Log10.

Change 3461434 by Michael.Trepka

	Copy of CL 3456118

	In Metal RHI report texture streaming as immediately successful as on D3D to avoid a race-condition leading to deadlock between the Main, Game, Render & RHI threads.

	#jira UE-44961

Change 3461770 by Benjamin.Hyder

	Submitting TM-RayTracedDistanceField map

Change 3461929 by Marc.Olano

	Add Sobol blueprint and material node test maps to RenderTest project

Change 3462249 by Uriel.Doyon

	Translucency after DoF is now disabled when showflag postprocess is disabled.

Change 3462371 by Brian.Karis

	VT addressing is now 64bit to support huge sparse virtualized volumes

	16bit page tables working.

Change 3462936 by Marc.Olano

	Extend Sobol testing map with comparision between Random Sobol and Next Sobol functions

Change 3464394 by Uriel.Doyon

	Improved synchronization for texture streaming commands.
	This fixes an issue when accessing FStreamingTexture for pending textures.

Change 3464743 by Guillaume.Abadie

	Adds .usf file extension on all shader's source file names and adds checks to verify them at engine load time.

Change 3464818 by Guillaume.Abadie

	Fixes compilation error in FindShaderRelativePath

Change 3465184 by Daniel.Wright

	r.Shadow.PreShadowResolutionFactor 1.0 on Epic shadow settings

Change 3465283 by Marc.Olano

	Update Sobol Gray code tables to match random order tables

Change 3465976 by Arne.Schober

	DR - [UE-44393] - The Canvas is using the Globalshaders for clearing but compilation is done asynconously at load time. Unfortunately there could be Code that uses a canvas to draw and cause this issue in between. There might be some plugins that do this. For now we need to wait and block for the shaqders to be compiled until we can allo the use of the canvas.

	#RB none

Change 3467513 by Guillaume.Abadie

	Fixes an issue where primitives would no longer draw in gameplay.

	#jira UE-45550

Change 3471116 by Richard.Wallis

	Mac OpenGL Is No Longer Supported - Remove All Code & Shader Platforms.  Merge of CL 3327784 dev-editor stream from Michael Trepka with some extra changes.

	- Also removed Metal shader platforms from PlatformSupportsDebugViewShaders() otherwise we get a compiler error.  HLSL register binds not implemented in metal backend.

	#jira UE-39108

Change 3471117 by Richard.Wallis

	Drop down menus clip on 27" Screen iMacs.  Disable viewport HDR rendering on macOS 10.12.x when in editor.
	#jira UE-43026

Change 3471130 by Richard.Wallis

	Mac GPU hang causes editor output log to be written to the wrong file.  Try to emulate windows behaviour when opening a file for reading or writing.  Tested against behaviour of windows log file with multiple instances running.

	- Only defined in for Mac and non shipping.

	#jira UE-44934

Change 3471224 by Guillaume.Abadie

	Lets the ProjectFileGenerator to look at Shaders/ directories in plugin and game projects.

Change 3471646 by Daniel.Wright

	Fixed ensure opening UT system settings

Change 3471862 by Arne.Schober

	DR - revert accidently checked in changes.
	#RB Chris.Bunner

Change 3472249 by Guillaume.Abadie

	Implements virtual shader source directory mapping.

	- /Engine/... maps to Engine/Shaders/...
	- /Plugin/FooBar/... maps to FooBar plugin's Shaders/ directory
	- /Project/... maps to project's Shaders/ directory

Change 3472443 by Daniel.Wright

	Moved the Rendering category for lights to be just below the Light category, so the bVisible property is easily accessible

Change 3474537 by Uriel.Doyon

	Fixed lighting needs rebuild happening after blueprint rescript and a non symetrical Quaterion != ToQuaternion(ToRotator(Quaternion)

Change 3475192 by Guillaume.Abadie

	Implements LensDistortion engine plugin.

	This CL import a polished version of Raven's lens distortion and undistortion from OpenCV parameters:
	 - It is implemented as the first engine plugin with its own shaders and render thread commands;
	 - Has feature tests in EngineTest with gold images directly extracted from OpenCV itself (GenerateLensDistortionUndistortReferences.py)

Change 3475209 by Guillaume.Abadie

	Back out changelist 3475192

Change 3475252 by Guillaume.Abadie

	Reland: Implements LensDistortion engine plugin.

	This CL import a polished version of Raven's lens distortion and undistortion from OpenCV parameters:
	 - It is implemented as the first engine plugin with its own shaders and render thread commands;
	 - Has feature tests in EngineTest with gold images directly extracted from OpenCV itself (GenerateLensDistortionUndistortReferences.py)

Change 3475389 by Guillaume.Abadie

	Adds LensDistortion plugin's feature tests.

Change 3475538 by Guillaume.Abadie

	Adds the /Engine/* prefix on all of the renderer's USF file references.

Change 3475568 by Guillaume.Abadie

	Adds a check for virtual shader source file path format in FShaderType::FShaderType()

Change 3475871 by Guillaume.Abadie

	Fixes a bug in shader compile worker, were an error in a relative #include USF file would trigger an check failure in CheckVirtualShaderFilePath

Change 3475997 by Yujiang.Wang

	Workaround for a compiler optimization bug introduced in VS2015 Update 3.

	* The bug causes TSHVector<2>::CalcDiffuseTransfer to go to infinity at certain spot, making movable objects with ILCQ_Volume indirect lighting cache interpolation get very dark.
	* Debug builds don't exhibit this bug.
	* Semantics are exactly the same as the original code.

Change 3476203 by David.Hill

	Compute SSAO: problem wiht AmbientOcclusionLevels and with various viewporttest sizes.  Only seen when Levels >=2
	#jira UE-45741

Change 3476536 by Benjamin.Hyder

	adding player start to Ray Traced Distance Field Shadows Map

Change 3478298 by Benjamin.Hyder

	disabling mesh distance fields in Tm-Raytraced_DistanceField_Shadows map

Change 3478948 by Rolando.Caloca

	DR - Nicer check

Change 3478949 by Rolando.Caloca

	DR - Default GPU morphs to enabled

Change 3478950 by Rolando.Caloca

	DR - By default -vulkan will launch SM5

Change 3478984 by Rolando.Caloca

	DR - Pass down -vulkan

Change 3479655 by Richard.Wallis

	Video track does not switch in AVF Media Player.  Need to disable unused video tracks to allow AVPlayerItemVideoOutput to decode the required track.

	- Minimal change to allow video track changes/selection.
	- Audio samples are extracted using AVAssetReaderTrackOutput but video uses AVPlayerItemVideoOutput.  Video could also use AVAssetReaderTrackOutput to access the video data unless there is an iOS reason not to...
	- Flush the audio sink sample buffers so we get instant audio track changes

	#jira UE-39750, UE-39749

Change 3479834 by Rolando.Caloca

	DR - Fix issue with bad vertex colors (per licensee)

Change 3480376 by Guillaume.Abadie

	Disables ComputeLightGrid() if no volumetric fog and no lighting.

	#jira UE-45377

Change 3480596 by Yujiang.Wang

	Fix for dynamic shadows and raytraced distance field shadows of directional lights not appearing in planar reflection

	* Bug caused by incorrect shadow culling volumes for cascaded shadow map and backface culling mode for WholeSceneShadowProjection
	* Fixed by taking View.bReverseCulling into account

	#jira UE-34452

Change 3480600 by Yujiang.Wang

	Fix for UE-42376

	* The bug is caused by post-processing ambient cubemaps not being supported in forward shading currently.
	* This fix replaces all the occurences of them in CalcSceneView with a skylight using the cubemap
	* If a CalcSceneView is used solely for setting the PP ambient cubemap, it is removed.

	#jira UE-42376

Change 3480784 by Rolando.Caloca

	DR - hlslcc - Initial support for [RW]StructuredBuffer

Change 3481690 by Uriel.Doyon

	Attempt to fix static analysis warning

Change 3482012 by Simon.Tovey

	Fixed issue when building distribution lookup tables where the final sample fell short of the max input time.
	As sampling is done only over this range, under constant interpolation the final value was never actually sampled and so cut from the final optimized LUT.

	#tests constant interpolation now works.

	#jira UE-45614

Change 3482965 by Yujiang.Wang

	Some quality of life changes for UE-42757

	* The UV overlay in static mesh editor now has a darker background
	* Selected edges are getting highlighted and bolder
	* When some edges are selected others turn grey

	#jira UE-42757

Change 3483014 by David.Hill

	Change labels on bloom boost from x,y,z to min, max, mult.
	#jira UE-43904

	a PropertyRedirect in BaseEngine.ini allows this to work with older version.

Change 3484573 by Yujiang.Wang

	Fix for shadow color not updated after light build when a texture is changed and reimported

	* Bug caused by counter-intuitive design of UMaterial::GetReferencedFunctionIds and UMaterial::GetReferencedParameterCollectionIds, both of which will reset the OutIds parameter
	* Renamed to AppendReferencedFunctionIdsTo and AppendReferencedParameterCollectionIdsTo, the resets are removed

	#jira UE-45647

Change 3484969 by Yujiang.Wang

	Fix for UE-39929 inconsistent type between C++ and shader code

	* MeshDistanceFieldCasterIndices is declared as Buffer<uint> in CapsuleShadowShaders.usf, while created as PF_R32_SINT in CapsuleShadowRendering.cpp
	* Changed PF_R32_SINT to PF_R32_UINT in CapsuleShadowRendering.cpp

	#jira UE-39929

Change 3485012 by Yujiang.Wang

	Fix for UE-39929 #2: Changed int32 to uint32 to match PF_R32_UINT

	#jira UE-39929

Change 3485146 by Guillaume.Abadie

	Destroyes scene capture's view states on the UnRegister, to avoid large memory usage cause by the ViewState's render targets when moving blueprints arround.

	#jira UE-43455

Change 3486602 by Joe.Conley

	Adding "texcoord" keyword to UMaterialExpressionTextureCoordinate so you can search for the name that is displayed on the node in the graph.

Change 3487471 by Yujiang.Wang

	Github #3659: Improved performance of DumpUnbuiltLightInteractions

	* Replaced TArrays with TSets

	#jira UE-45783

Change 3487641 by Guillaume.Abadie

	Fixes some shader file name casing issues in LPV.

Change 3488014 by Uriel.Doyon

	New AllowAsyncLoading flag for UTexture::CachePlatformData().
	It allows to load the source texture data in the async task if the source bulk data was not yet loaded.

	Data loaded that way is not sharable between tasks and will be discarded.
	This is required because updating the source data is not thread safe.

	#jira UERNDR-190
	#jira UE-33401

Change 3488249 by Uriel.Doyon

	Fixed long stall in UpdateResourceStreaming() caused by Actor.GetComponents() not resetting the number of actors anymore.
	Fixed inconsistent results in ALODActor::HasValidSubActors() caused by the same change.

	#jira UE-46004

Change 3490228 by Mark.Satterthwaite

	Fix the Nvidia driver bug with the old reversebits fallback function - you need to use the native reverse_bits intrinsic or use some uint(ushort()) casts to get the compiler to do the right thing, which means injecting the reverse_bits function in MetalBackend not the HLSL (as it has no such type).

	#jira UE-46067

Change 3490538 by Arne.Schober

	Back out changelist 3488249
	#RB none

Change 3490551 by Arne.Schober

	Back out changelist 3488249
	#RB none

Change 3491828 by Guillaume.Abadie

	Fixes another USf file reference casing issue in C++.

Change 3491924 by Yujiang.Wang

	Fix for UE-43302 Crash when entering the DebugCreatePlayer console command with planar reflections in the level

	* Crash caused by check(Views.Num() <= 2); in SceneCaptureRendering.cpp
	* We still want to support at most 2 views for performance, but now instead of crash the planar reflections in additional views will simply turn black

	#jira UE-43302

Change 3492359 by Guillaume.Abadie

	Fixes non editor launches, failing in FGenericPlatformProcess::AddShaderSourceDirectoryMapping().

Change 3492367 by Marc.Olano

	Change Sobol texture size to 32x16, tweak distribution

Change 3492599 by Marcus.Wassmer

	PR #3669: -Fix logmessages ParticleModules_Location.cpp (Contributed by UpwindSpring01)

Change 3493473 by Uriel.Doyon

	Back out changelist 3490538

Change 3493590 by Uriel.Doyon

	Back out changelist 3490551
	Fixed missing #pragma once

Change 3493911 by Marcus.Wassmer

	Fix potential GPU crash/hang caused by out of bound subresource updates.
	Added checks at cross-platform level to catch any instance earlier.

Change 3494139 by Uriel.Doyon

	Fixed shadow variable issue on UE4Editor Linux.

Change 3494364 by Richard.Wallis

	Mac OpenGL Is No Longer Supported - Remove All Code & Shader Platforms - Part 2: Remove some more areas and fixes for previous attempt.  Also removed OpenGL based GPU performance checks in EditorEngine.cpp - assuming that any GPU that can run Metal is currently OK for UE4.

	OpenGL left in the following areas:

	- OpenGLShaderCompiler
	- StandaloneRenderer

	The following files need to be reviewed in conjunction with CL 3471116 as there were some logic errors made:

	- OpenGLTexture.cpp

	#jira UE-39108

Change 3494413 by Guillaume.Abadie

	Updates r.InvalidateCachedShader and bump ShaderVersion.ush.

Change 3494422 by Guillaume.Abadie

	Adds LensDistortion plugin's Private shader directory.

Change 3494717 by Guillaume.Abadie

	Strengthens shader compiler with checks on generated file names and shader type file names.

Change 3494763 by Guillaume.Abadie

	Removes a nolonger standing TODO in GlobalBeginCompileShader() that was automatically adding /Engine/ prefix to all relative virtual shader source file path.

Change 3494985 by Rolando.Caloca

	DR - Integrate Vulkan Rewrite

Change 3495031 by Rolando.Caloca

	DR - Delete file as it moved

Change 3495032 by Rolando.Caloca

	DR - Show Vulkan SM5 instead of SM4 on windows packaging
	- Also added support for Vulkan SM5_UB

Change 3495202 by Uriel.Doyon

	Fixed static analysis warning with pointer dereferencing.

Change 3495342 by Rolando.Caloca

	DR - clang compile fix

Change 3495354 by Rolando.Caloca

	DR - clang compile fixes

Change 3495420 by Marc.Olano

	Use Sobol sampling for PCSS

Change 3495799 by Rolando.Caloca

	DR - Delete old dev assets

Change 3496202 by Mark.Satterthwaite

	Switch to using actual Vector*Matrix intrinsic for Metal to avoid a problem whereby the Metal compiler reorders operations in such a way that it loses precision and ends up being different between pre-pass and base-pass.

	#jira UE-46070

Change 3496253 by Uriel.Doyon

	Fixed static analysis warning for IncludeTool

Change 3496631 by Guillaume.Abadie

	Makes AScreenshotFunctionalTest::ScreenshotOptions blueprint readable.

Change 3496851 by Guillaume.Abadie

	Fixes back slash issues in Platform.usf.

Change 3496852 by Guillaume.Abadie

	Fixes other back slashes includes in PS4 specific usf files.

Change 3496941 by Guillaume.Abadie

	Adds a check() for no backslash in virtual shader file paths.

Change 3497661 by Guillaume.Abadie

	Lets FLensDistortionCameraModel::GetUndistortOverscanFactor() early return 1.0 if the camera model is does an identity transform.

Change 3497969 by Richard.Wallis

	Fix for start Up Movies Are not Playing for iOS Devices.  Handle case when movie is loading aysnc in background - need to wait for state changes otherwise it skips intermediate movies.

	- Tested on iOS and Mac.

	#jira UE-39585

Change 3498035 by Guillaume.Abadie

	Polishes //Engine/Plugins/Compositing/LensDistortion/Shaders/Private/UVGeneration.usf from debuging artifacts.

Change 3498101 by Rolando.Caloca

	DR - Compile fix

Change 3498254 by Guillaume.Abadie

	Exposes comparing FLensDistortionCameraModel to blueprint with == and != operator nodes for cross frame uv displacement map caching.

Change 3498264 by Guillaume.Abadie

	Integrate 3267269: Implements SceneCaptureComponent2D::bCameraCutThisFrame

Change 3498371 by Yujiang.Wang

	Fix for UE-46149 Planar Reflections display screenspace info when viewports are >2

	* Prevent planar reflections being rendered when ViewIndex >= GMaxPlanarReflectionViews
	* Now planar reflections in >2 viewports will fallback to other reflection methods (SSR, reflection captures)

	#jira UE-46149

Change 3498409 by Rolando.Caloca

	DR - Swap resolves

Change 3498410 by Guillaume.Abadie

	Adds support for opacity output alpha for post process material when doing a draw material to render target.

Change 3498705 by Rolando.Caloca

	DR - Add UID for debugging mem allocations

Change 3498759 by Marcus.Wassmer

	No post processing in vertexcolor view mode

	#jira UE-44704

Change 3498891 by Rolando.Caloca

	DR - Minor Vulkan per frame allocator refactor in prep for changes

Change 3499206 by Rolando.Caloca

	DR - Fix temp frame allocator OOM on Vulkan

	#jira UE-45913

Change 3499319 by Rolando.Caloca

	DR - Vulkan support for StorageBuffer

Change 3499339 by Rolando.Caloca

	DR - Remove deprecated typedef

Change 3499400 by Rolando.Caloca

	DR - Remove some RHICmdList deprecated functions

Change 3499422 by Rolando.Caloca

	DR - Allow buffer transitions inside render passes

Change 3500370 by Rolando.Caloca

	DR - Compile fix

Change 3500474 by Rolando.Caloca

	DR - Fix static analysis

Change 3500517 by Guillaume.Abadie

	Exposes r.PostProcessing.PropagateAlpha to the renderer settings.

Change 3500537 by Guillaume.Abadie

	Fixes a bug where scene capture WorldToView matrix would get scale != 1 when scaling the scene capture actor in the world.

	#jira UE-39389

Change 3501069 by Mark.Satterthwaite

	Bring back temporary 4.16 fix for iOS 9 (CL #3425995) into Dev-Rendering for 4.17 as a real fix will need to wait for 4.18.

	temporary fix for skewed textures on IOS 9
	#jira UE-44468

Change 3501164 by Michael.Lentine

	PR #3402: UE-43131: Format argument count not equal to actual arguments (Contributed by projectgheist)


Change 3501222 by Benjamin.Hyder

	Checking in Tm_SobolNoise map

Change 3501612 by zachary.wilson

	Adding testing content for RTDF shadows on planar reflections

Change 3501708 by Guillaume.Abadie

	Break FPostProcessSettings into smallers structs.

Change 3501830 by Olaf.Piesche

	#jira UE-39628; using fix proposed in UDN, will investigate further

Change 3501954 by Marcus.Wassmer

	Duplicate 3480903
	Light culling safety measures.

Change 3502032 by Mark.Satterthwaite

	Fix generation of Metal precompiled headers for the bytecode compiler when using Xcode 9.

Change 3502118 by Uriel.Doyon

	Fixed shader compilation issues.

Change 3502191 by Guillaume.Abadie

	Implements Composure plugin to make compositing in UE4 easier.

Change 3502192 by Guillaume.Abadie

	Implements Composure feature testing in EngineTests

Change 3502196 by Guillaume.Abadie

	Creates a dependency of Composure plugin over LensDistortion plugin.

Change 3502213 by Arciel.Rekman

	Fix for loading shaders on Linux (UE-46276).

Change 3502243 by Brian.Karis

	Bent normal map support.

	Multibounce AO.
	Spherical Gaussian based specular occlusion.

Change 3502506 by Guillaume.Abadie

	Fixes compilation failure in Composure with unity build.

Change 3502507 by Guillaume.Abadie

	Fixes composure Set Pass with Render Target blueprint helper.

Change 3502510 by Guillaume.Abadie

	Attempts to fix ComposureUtils.cpp compile errors.

Change 3502515 by Guillaume.Abadie

	Some other composure failure fixes.

Change 3502545 by Guillaume.Abadie

	Fixes some unity build related error in Composure.

Change 3502548 by Guillaume.Abadie

	Fixes last missing includes in ComposurePostProcessPass.cpp

Change 3502672 by Guillaume.Abadie

	Fixes linux warning in Composure.

Change 3502790 by Ryan.Brucks

	float4 PseudoVolumeTexture: Fixed frame layout being a float instead of float2. Now works correctly with non-square frame layouts. Only called in custom nodes and calling with a float still functions properly so no old content will break.

Change 3502836 by Guillaume.Abadie

	Propagates scene capture engine showflag changes from blueprint editor to the blueprint instances.

	#jira UE-6810

Change 3503096 by Guillaume.Abadie

	Resave a unversioned asset.

Change 3503228 by Yujiang.Wang

	Fix for UE-45646 Dynamic Light placed inside of a Dynamic Static Mesh doesn't pass through the geometry

	* Bug caused by bReflectiveShadowmap not being passed into SetViewFlagsForShadowPass
	* Replaced the true with bReflectiveShadowmap

	#jira UE-45646

Change 3503284 by Rolando.Caloca

	DR - Fixed initial clear on rendertargets
	- Added support for r.Vulkan.EnableValidation 1, 2, 3 & 4
	- Dump the vulkan log into VS output log
	- Added validation for layouts when using dump log

Change 3503545 by Arciel.Rekman

	Fix black UI on Linux (UE-46333)

	- Rebuilt hlslcc with clang 3.7.0. Whatever issues we're running in with newer clangs still seem to persist.

	#jira UE-46333

Change 3503638 by Daniel.Wright

	[Copy] Changed DynamicBentNormalAO back to fp16, as PF_FloatR11G11B10 was not enough precision and introduced banding

Change 3503787 by Marcus.Wassmer

	Fix difference between gpu/cpu morph target application

Change 3503902 by Marcus.Wassmer

	Roll back TAA refactor until we have time to look into the bad interaction with DOF.

Change 3503953 by Arne.Schober

	DR - UE-46319 - borked Reflections: The resource transition needs to be in this weired place for PS4 and switch until we teach the interface to know about subresources.
	#RB Marcus.Wassmer

Change 3504131 by Rolando.Caloca

	DR - Maintain a cache of pipeline and descriptor set layouts
	- Fix marker dump

Change 3504462 by Guillaume.Abadie

	Fixes an assertion failure that was failing because compute light grid was not done, but the shader used where not necessarily using compute light grid results.

	#jira UE-46277

Change 3504779 by Chris.Bunner

	Potential static analysis fix.

	#jira UE-46360

Change 3504950 by Marc.Olano

	Allow Sobol material nodes & textures only if feature level is at least ES3.1

	#jira UE-46334
	#jira UE-46317

Change 3505035 by Daniel.Wright

	Increased MaxSearchCount in GetShaderIncludes.  The previous limit of 20 is now getting hit in BasePassPixelShader.usf, causing compiles to fail erroneously.

Change 3505386 by Daniel.Wright

	GetShaderIncludes handles infinite recursion gracefully, needed by Metal causing BasePassTessellation.usf to include BasePassVertexShader.usf

Change 3505491 by Rolando.Caloca

	DR - Fix crash on first frame of particles on modern APIs

Change 3505557 by Chris.Bunner

	[Duplicate] Workaround for outdated shader map crash.

	#jira UE-46061

Change 3506071 by Rolando.Caloca

	DR - Vulkan fixes
	- Fix copy out of bounds reading textures to CPU
	- Defer event deletion
	- Split validation for errors and warnings
	- Skip validation error about attachment not used

Change 3506698 by Guillaume.Abadie

	Fixes Composure alpha channel clobering and performance regression in bloom and tonemapper passes caused by scene capture API compatibility breakage brought by Fortnite merge.

Change 3506797 by Rolando.Caloca

	DR - Fix static analysis

	#jira UE-46428

Change 3506861 by Rolando.Caloca

	DR - Fix crash due to layering violation

	#jira UE-46424
	#jira UE-46431

Change 3508098 by Rolando.Caloca

	DR - Fix for Vulkan ES31 crash
	- Fix for AMD ensure

Change 3508123 by Rolando.Caloca

	DR - Disable occlusion queries on Vulkan to avoid flickering
	- Fix for bad HZB & cube mips on Vulkan (now using RHIGenerateMips)
	- Fix for decal blending

	#jira UE-46376

Change 3509064 by Uriel.Doyon

	Changing the logic arround generating an error when HasHadBulkDataCleared() so that it only triggers if the DDC are not found.
	#jira UE-46427

Change 3509854 by Marc.Olano

	Fix 2D Sobol gray code numbers.
	Just changes some numbers in initialization tables, so no effect on existing tests or content.

Change 3509920 by Marcus.Wassmer

	Fix LPV fastvram ensure

Change 3509937 by Rolando.Caloca

	DR - Fix crash due to deleted viewport

	#jira UE-46281

Change 3509988 by Marcus.Wassmer

	Roll back part of Sobol fix to avoid full shader recompile for integration.

Change 3510255 by Rolando.Caloca

	DR - Fix popup window ensure

	#jira UE-46511

Change 3510646 by Marcus.Wassmer

	fix ios compiles

Change 3511442 by Rolando.Caloca

	DR - Change mesh simplification check to ensure/checkslow to unblock

	#jira UE-46538


DONE!

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
CHANGES WITH MULTIPLE PLATFORMS!!! YOU MUST COPY THESE INTO THE OTHER ONES AS MAKES SENSE!!
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX


Change 3467095 by Guillaume.Abadie

	Nukes all += TEXT(".usf")

	#jira UE-45530

Change 3475084 by Guillaume.Abadie

	Fixes compilation failure of the shader compiler on PS4 and XboxOne

Change 3477464 by Guillaume.Abadie

	Fixes dumpshaderinfo that generate unecessary sub directory, breaking shell scripts.

Change 3494395 by Guillaume.Abadie

	Moves all engine shader files into Public and Private directory, and introduce the .ush extensions for header file that do not contains entry points.

	DONE!

[CL 3511602 by Marcus Wassmer in Main branch]
2017-06-27 11:38:28 -04:00

214 lines
8.1 KiB
C++

// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
// ..
#include "ShaderFormatVectorVM.h"
#include "VectorVMBackend.h"
#include "CoreMinimal.h"
#include "FileHelper.h"
#include "ShaderCore.h"
#include "CrossCompilerCommon.h"
#include "ShaderCompilerCommon.h"
#include "ShaderPreprocessor.h"
#include "INiagaraCompiler.h"
#include "VectorVM.h"
DEFINE_LOG_CATEGORY_STATIC(LogVectorVMShaderCompiler, Log, All);
/*------------------------------------------------------------------------------
External interface.
------------------------------------------------------------------------------*/
static FString CreateCrossCompilerBatchFile( const FString& ShaderFile, const FString& OutputFile, const FString& EntryPoint, EHlslShaderFrequency Frequency, uint8 Version, uint32 CCFlags )
{
const TCHAR* VersionSwitch = TEXT("");
return CrossCompiler::CreateBatchFileContents(ShaderFile, OutputFile, Frequency, EntryPoint, VersionSwitch, CCFlags, TEXT(""));
}
/**
* Compile a shader for the VectorVM on Windows.
* @param Input - The input shader code and environment.
* @param Output - Contains shader compilation results upon return.
*/
void CompileShader_VectorVM(const FShaderCompilerInput& Input, FShaderCompilerOutput& Output, const FString& WorkingDirectory, uint8 Version)
{
}
//TODO: Move to this output living in the shader eco-system with the compute shaders too but for now just do things more directly.
void CompileShader_VectorVM(const FShaderCompilerInput& Input, FShaderCompilerOutput& Output,const FString& WorkingDirectory, uint8 Version, FNiagaraCompilationOutput& NiagaraOutput)
{
FString PreprocessedShader;
FShaderCompilerDefinitions AdditionalDefines;
EHlslCompileTarget HlslCompilerTarget = HCT_FeatureLevelSM5;
ECompilerFlags PlatformFlowControl = CFLAG_AvoidFlowControl;
AdditionalDefines.SetDefine(TEXT("COMPILER_HLSLCC"), 1);
AdditionalDefines.SetDefine(TEXT("COMPILER_VECTORVM"), 1);
const bool bDumpDebugInfo = (Input.DumpDebugInfoPath != TEXT("") && IFileManager::Get().DirectoryExists(*Input.DumpDebugInfoPath));
AdditionalDefines.SetDefine(TEXT("FORCE_FLOATS"), (uint32)1);
auto DoPreprocess = [&]() -> bool
{
if (Input.bSkipPreprocessedCache)
{
return FFileHelper::LoadFileToString(PreprocessedShader, *Input.VirtualSourceFilePath);
}
else
{
return PreprocessShader(PreprocessedShader, Output, Input, AdditionalDefines);
}
};
if (DoPreprocess())
{
//TODO: Need to remove any unsupported features here?
char* ShaderSource = NULL;
char* ErrorLog = NULL;
const EHlslShaderFrequency Frequency = HSF_VertexShader;
//TODO: Do this later when we implement the rest of the shader plumbing stuff.
// // Write out the preprocessed file and a batch file to compile it if requested (DumpDebugInfoPath is valid)
// if (bDumpDebugInfo)
// {
// FArchive* FileWriter = IFileManager::Get().CreateFileWriter(*(Input.DumpDebugInfoPath / Input.GetSourceFilename()));
// if (FileWriter)
// {
// auto AnsiSourceFile = StringCast<ANSICHAR>(*PreprocessedShader);
// FileWriter->Serialize((ANSICHAR*)AnsiSourceFile.Get(), AnsiSourceFile.Length());
// FileWriter->Close();
// delete FileWriter;
// }
//
// if (Input.bGenerateDirectCompileFile)
// {
// FFileHelper::SaveStringToFile(CreateShaderCompilerWorkerDirectCommandLine(Input), *(Input.DumpDebugInfoPath / TEXT("DirectCompile.txt")));
// }
// }
//Is stuff like this needed? What others?
uint32 CCFlags = HLSLCC_NoPreprocess;
CCFlags |= HLSLCC_PrintAST;
//CCFlags |= HLSLCC_UseFullPrecisionInPS;
//TODO: Do this later when we implement the rest of the shader plumbing stuff.
// if (bDumpDebugInfo)
// {
// const FString VVMFile = (Input.DumpDebugInfoPath / TEXT("Output.vvm"));
// const FString USFFile = (Input.DumpDebugInfoPath / Input.GetSourceFilename());
// const FString CCBatchFileContents = CreateCrossCompilerBatchFile(USFFile, VVMFile, *Input.EntryPointName, Frequency, Version, CCFlags);
// if (!CCBatchFileContents.IsEmpty())
// {
// const TCHAR * ScriptName = PLATFORM_WINDOWS ? TEXT("CrossCompile.bat") : TEXT("CrossCompile.sh");
// FFileHelper::SaveStringToFile(CCBatchFileContents, *(Input.DumpDebugInfoPath / ScriptName));
// }
// }
//NEEDED?
// Required as we added the RemoveUniformBuffersFromSource() function (the cross-compiler won't be able to interpret comments w/o a preprocessor)
//CCFlags &= ~HLSLCC_NoPreprocess;
FVectorVMCodeBackend VVMBackEnd(CCFlags, HlslCompilerTarget, NiagaraOutput);
FVectorVMLanguageSpec VVMLanguageSpec;
int32 Result = 0;
FHlslCrossCompilerContext CrossCompilerContext(CCFlags, Frequency, HlslCompilerTarget);
if (CrossCompilerContext.Init(TCHAR_TO_ANSI(*Input.VirtualSourceFilePath), &VVMLanguageSpec))
{
Result = CrossCompilerContext.Run(
TCHAR_TO_ANSI(*PreprocessedShader),
TCHAR_TO_ANSI(*Input.EntryPointName),
&VVMBackEnd,
&ShaderSource,
&ErrorLog
) ? 1 : 0;
}
NiagaraOutput.Errors = ErrorLog;
//TODO: Try to get rid of the CompilationOutput and have the vm bytecode life in the shader eco-system as the compute shader version will.
// int32 SourceLen = VVMBackEnd.ByteCode.Num();//ShaderSource ? FCStringAnsi::Strlen(ShaderSource) : 0;
// if (SourceLen > 0)
// {
// if (bDumpDebugInfo)
// {
// const FString GLSLFile = (Input.DumpDebugInfoPath / TEXT("Output.vvm"));
//
// if (SourceLen > 0)
// {
// uint32 Len = FCStringAnsi::Strlen(TCHAR_TO_ANSI(*Input.VirtualSourceFilePath)) + FCStringAnsi::Strlen(TCHAR_TO_ANSI(*Input.EntryPointName)) + FCStringAnsi::Strlen(ShaderSource) + 20;
// char* Dest = (char*)malloc(Len);
// FCStringAnsi::Snprintf(Dest, Len, "// ! %s:%s\n%s", (const char*)TCHAR_TO_ANSI(*Input.VirtualSourceFilePath), (const char*)TCHAR_TO_ANSI(*Input.EntryPointName), (const char*)ShaderSource);
// free(ShaderSource);
// ShaderSource = Dest;
// SourceLen = FCStringAnsi::Strlen(ShaderSource);
//
// FArchive* FileWriter = IFileManager::Get().CreateFileWriter(*(Input.DumpDebugInfoPath / Input.VirtualSourceFilePath + TEXT(".vvm")));
// if (FileWriter)
// {
// FileWriter->Serialize(ShaderSource,SourceLen+1);
// FileWriter->Close();
// delete FileWriter;
// }
// }
// }
//HMMMM....?
// #if VALIDATE_GLSL_WITH_DRIVER
// PrecompileShader(Output, Input, ShaderSource, Version, Frequency);
// #else // VALIDATE_GLSL_WITH_DRIVER
//SourceLen = FCStringAnsi::Strlen(ShaderSource);
// Output.Target = Input.Target;
//BuildShaderOutput(Output, Input, ShaderSource, SourceLen, Version);
// Output.bSucceeded = true;
//Should we add optional data to define the register allocations etc so that someone can just write hlsl directly and have it become a niagara sim?
// Output.ShaderCode.GetWriteAccess().Append((uint8*)VVMBackEnd.ByteCode.GetData(), VVMBackEnd.ByteCode.Num());
// Output.ShaderCode.FinalizeShaderCode();
//#endif // VALIDATE_GLSL_WITH_DRIVER
// }
// else
// {
//ES2 Command line is throwing me off. Is this needed?
// if (bDumpDebugInfo)
// {
// // Generate the batch file to help track down cross-compiler issues if necessary
// const FString VVMFile = (Input.DumpDebugInfoPath / TEXT("Output.vvm"));
// const FString VVMBatchFileContents = CreateCommandLineGLSLES2(VVMFile, (Input.DumpDebugInfoPath / TEXT("Output.asm")), Version, Frequency, false);
// if (!VVMBatchFileContents.IsEmpty())
// {
// FFileHelper::SaveStringToFile(VVMBatchFileContents, *(Input.DumpDebugInfoPath / TEXT("VVMCompile.bat")));
// }
// }
//
// Output.bSucceeded = false;
//
// FString Tmp = ANSI_TO_TCHAR(ErrorLog);
// TArray<FString> ErrorLines;
// Tmp.ParseIntoArray(ErrorLines, TEXT("\n"), true);
// for (int32 LineIndex = 0; LineIndex < ErrorLines.Num(); ++LineIndex)
// {
// const FString& Line = ErrorLines[LineIndex];
// CrossCompiler::ParseHlslccError(Output.Errors, Line);
// }
// }
if (ShaderSource)
{
UE_LOG(LogVectorVMShaderCompiler, Warning, TEXT("%s"), (const char*)ShaderSource);
free(ShaderSource);
}
if (ErrorLog)
{
UE_LOG(LogVectorVMShaderCompiler, Warning, TEXT("%s"), (const char*)ErrorLog);
free(ErrorLog);
}
}
}