67 Commits

Author SHA1 Message Date
massimo tristano
33e8cca80e Optimizations in Material translation code amounting to 50% speed up.
Optimized function UMaterialExpression::GetInputs() with highest exclusive run-time during material translation from 19.79% to 1.79% exclusive run time.

This change caches the inputs upon expression creation by default and return a TArrayView instead of always creating a new transient dynamic array. The optimization also simplifies code for some Expression types.

Also optimized ContainsInputLoopInternal() to use a linked list of stack allocated nodes instead of Pushing/Popping from a dynamic array.

#rb jason.nadro
#preflight 6478b849c26e3b2449ff8608

[CL 25735070 by massimo tristano in ue5-main branch]
2023-06-01 14:48:38 -04:00
massimo tristano
d11cc38546 [Backout] - CL25722170
[FYI] massimo.tristano
Original CL Desc
-----------------------------------------------------------------
Optimizations in Material translation code amounting to 50% speed up.

Optimized function UMaterialExpression::GetInputs() with highest exclusive run-time during material translation from 19.79% to 1.79% exclusive run time.

This change caches the inputs upon expression creation by default and return a TArrayView instead of always creating a new transient dynamic array. The optimization also simplifies code for some Expression types.

Also optimized ContainsInputLoopInternal() to use a linked list of stack allocated nodes instead of Pushing/Popping from a dynamic array.

#rb jason.nadro
#preflight 64776ef44a277ca8f0b9a538

[CL 25722294 by massimo tristano in ue5-main branch]
2023-06-01 05:50:43 -04:00
massimo tristano
fff9f2ef54 Optimizations in Material translation code amounting to 50% speed up.
Optimized function UMaterialExpression::GetInputs() with highest exclusive run-time during material translation from 19.79% to 1.79% exclusive run time.

This change caches the inputs upon expression creation by default and return a TArrayView instead of always creating a new transient dynamic array. The optimization also simplifies code for some Expression types.

Also optimized ContainsInputLoopInternal() to use a linked list of stack allocated nodes instead of Pushing/Popping from a dynamic array.

#rb jason.nadro
#preflight 64776ef44a277ca8f0b9a538

[CL 25722174 by massimo tristano in ue5-main branch]
2023-06-01 05:32:59 -04:00
christopher waters
0d5b23e2e3 Adding includes to prepare for a header dependency cleanup.
#preflight 63b5e0bfff7b9ad7030f0f81

[CL 23581920 by christopher waters in ue5-main branch]
2023-01-04 17:07:40 -05:00
sebastien hillaire
a831062e45 Sparse volumetexture initial commit.
Sparse Volume Texture asset from imported OpenVDB (only a single float channel for now). Static or animated sequence.
It will be possible to generate SVT at runtime from GPU later.
Using FEditorBulkData for handling raw source without loading everything when not caching or cooking.
BulkData used at runtime for loading. No streaming yet.
Importer with dependency on OpenVDB is in a SparseVolumeTexture module only loaded when in editor

Sparse volume texture can be sampled from any materials (sample, sample parameter) and overridden on material instance and material instance dynamic.

Added support for uint in compiler (fetch from page table, see SparseVolumeTextureGetVoxelCoord)
Volume texture with u8 VirtualTextureLayerIndex!=255 (INDEX_NONE) are sparse texture. The layer index then represent what texture/attribute to sample.

#preflight https://horde.devtools.epicgames.com/job/6346a466f93be0f6345af86c
#rb Patrick.Kelly, Charles.deRousiers

[CL 22551963 by sebastien hillaire in ue5-main branch]
2022-10-16 02:28:34 -04:00
Josie Yang
af65e53764 Inline edit support to material expression inputs
- Inline edit support for UPROPERTY of type float, int32, uint32, uint8, enum, bool.
- Editable UPROPERTYs with "OverridingInputProperty" metadata are created as inline widgets next to their corresponding inputs.
- Rest of the editable UPROPERTYs may specify "ShowAsInputPin" metadata to become inline edit pins, with 2 choices: "Primary" - show in primary view, "Advanced" - show in in advanced view.
- Update a bunch of material expressions to reflect the changes, rest of the expressions still need to be worked through.

#jira UE-145276
#rb kevin.Ortegren
#preflight 627a3cc8937a047d62282ba7

[CL 20122451 by Josie Yang in ue5-main branch]
2022-05-10 09:53:13 -04:00
Jason Nadro
fc3dcee397 Restore backed out CL, with fixes.
Also restores follow-up CLs 19973746, 19973782
FStaticParameterSet::MaterialLayers can't be deprecated, since a property with the same name is included via FStaticParameterSetRuntimeData
So instead, FMaterialLayersFunctionsRuntimeData is updated with SerializeFromMismatchedTag, to allow serializing a full FMaterialLayersFunction.
When this happens, the EditorOnly portion is stored in a separate heap allocation, and then transferred to FStaticParameterSet::EditorOnly::MaterialLayers
#preflight 626c3405e31dbb512cef1e98

[Backout] - CL19973745
#fyi bob.tellez
Original CL Desc
-----------------------------------------------------------------
[Backout] - CL19964485
#fyi Ben.Ingram
Original CL Desc
-----------------------------------------------------------------
Add 'Optional' EditorOnly data for UMaterialInterface and UMaterialFunctionInterface
These are separate UObject hierarchies that store editor-only UPROPERTIES, but can be included with cooked content, which allows full editor support.
In principle, all editor-only properties could be moved over.  So far, this has been limited to UMaterialExpressions, and data related to material parameters.
FStaticParameterSet, FMaterialLayersParameters, and FMaterialCachedExpressionData have all been split into separate editor-only/non-editor-only classes,
which allows the editor-only portion to be stored on the optional editor-only UObject.
#preflight 626ab21dad56c0cbbea32dc4
#rb jason.nadro, francis.hurteau
#jira FORT-463329

[CL 20043286 by Jason Nadro in ue5-main branch]
2022-05-04 12:21:52 -04:00
bob tellez
34d8d5badd [Backout] - CL19964485
#fyi Ben.Ingram
Original CL Desc
-----------------------------------------------------------------
Add 'Optional' EditorOnly data for UMaterialInterface and UMaterialFunctionInterface
These are separate UObject hierarchies that store editor-only UPROPERTIES, but can be included with cooked content, which allows full editor support.
In principle, all editor-only properties could be moved over.  So far, this has been limited to UMaterialExpressions, and data related to material parameters.
FStaticParameterSet, FMaterialLayersParameters, and FMaterialCachedExpressionData have all been split into separate editor-only/non-editor-only classes,
which allows the editor-only portion to be stored on the optional editor-only UObject.
#preflight 626ab21dad56c0cbbea32dc4
#rb jason.nadro, francis.hurteau
#jira FORT-463329

[CL 19973745 by bob tellez in ue5-main branch]
2022-04-28 20:08:12 -04:00
Ben Ingram
448b0a9807 Add 'Optional' EditorOnly data for UMaterialInterface and UMaterialFunctionInterface
These are separate UObject hierarchies that store editor-only UPROPERTIES, but can be included with cooked content, which allows full editor support.
In principle, all editor-only properties could be moved over.  So far, this has been limited to UMaterialExpressions, and data related to material parameters.
FStaticParameterSet, FMaterialLayersParameters, and FMaterialCachedExpressionData have all been split into separate editor-only/non-editor-only classes,
which allows the editor-only portion to be stored on the optional editor-only UObject.
#preflight 626ab21dad56c0cbbea32dc4
#rb jason.nadro, francis.hurteau
#jira FORT-463329

[CL 19964485 by Ben Ingram in ue5-main branch]
2022-04-28 12:56:28 -04:00
Ben Ingram
1d363ceaf6 FRequestedType/FPreparedType store full Shader::FType, rather then just an EValueComponentType. This allows correctly converting to either Double4x4 or DoubleInverse4x4. This context is lost with only the component type
#rb none
#jira none
#preflight 625ee12b034d8924cdcc780d

[CL 19811044 by Ben Ingram in ue5-main branch]
2022-04-19 12:40:03 -04:00
ben ingram
f9b20e4ac9 Don't crash if layer function outputs haven't been initialized yet
#rb none
#preflight none
#jira UE-134987

#ROBOMERGE-AUTHOR: ben.ingram
#ROBOMERGE-SOURCE: CL 18741111 in //UE5/Release-5.0/... via CL 18741603 via CL 18742855
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v903-18687472)

[CL 18743211 by ben ingram in ue5-main branch]
2022-01-26 15:36:33 -05:00
Ben Ingram
6f2cbfee8c New material HLSL translator supports functions using control flow
#preflight 61dcc5b94d377749b662ee15
#jira none
#rb none

[CL 18567176 by Ben Ingram in ue5-main branch]
2022-01-10 19:10:49 -05:00
aurel cordonnier
fc542f6cfd Merge from Release-Engine-Staging @ 18081189 to Release-Engine-Test
This represents UE4/Main @18073326, Release-5.0 @18081140 and Dev-PerfTest @18045971

[CL 18081471 by aurel cordonnier in ue5-release-engine-test branch]
2021-11-07 23:43:01 -05:00
aurel cordonnier
a6e741e007 Merge from Release-Engine-Staging @ 17915896 to Release-Engine-Test
This represents UE4/Main @17911760, Release-5.0 @17915875 and Dev-PerfTest @17914035

[CL 17918595 by aurel cordonnier in ue5-release-engine-test branch]
2021-10-25 20:05:28 -04:00
aurel cordonnier
7f517562d5 Merge from Release-Engine-Staging @ 17438845 to Release-Engine-Test
This represents UE4/Main @17430120 and Dev-PerfTest @17437669

[CL 17439044 by aurel cordonnier in ue5-release-engine-test branch]
2021-09-06 12:23:53 -04:00
ben ingram
569985155a Avoid crash when opening material function instance, don't look for expressions connected to inputs, since nothing is connected in this context
#rb none

#ROBOMERGE-SOURCE: CL 16911375 via CL 16920633
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v836-16769935)

[CL 16920748 by ben ingram in ue5-release-engine-test branch]
2021-07-22 00:43:16 -04:00
aurel cordonnier
02c0f425e8 Copy up from Release-Engine-Staging @ 16738359
This represents UE4/Main @ 16738161 and Dev-PerfTest @ 16737719

[CL 16738582 by aurel cordonnier in ue5-release-engine-test branch]
2021-06-22 00:27:54 -04:00
ben ingram
b5d97f57c2 Remove concept of 'linked scopes', instead track number of exec input connections to each expression, and use that to process if/else scopes
- This way we don't need to move statements around, can generate both if/else scope correctly before switching back to parent scope
- Will make it easier to track locals within the current scope
#rb none
#jira none

#ROBOMERGE-SOURCE: CL 16354735 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v804-16311228)

[CL 16354746 by ben ingram in ue5-release-engine-test branch]
2021-05-17 13:03:18 -04:00
Ben Ingram
b6fcc96128 Early WIP of refactored material HLSL translator/generator.
Only mildly functional currently, my goal here is to get feedback on the high level direction.  The new code is disabled by default; it needs to be opted-into per material (and the UI for that is hidden by default behind a CVAR), so it shouldn't affect any existing workflows.
Basic outline:
* UMaterialExpression::Compile is replaced by GenerateHLSLStatement/GenerateHLSLExpression
* GenerateHLSLExpression returns a HLSLTree::FExpression derived object.  This is broadly similar to FShaderCodeChunk, except FExpression stores pointers to dependent expressions, and only generates the final HLSL string on demand (EmitHLSL method).  FExpression will have many derived classes to represent various HLSL expresisons like Add, Parameter, Constant, etc.
* GenerateHLSLStatement returns a HLSLTree::FStatement.  Statements represent chunk of HLSL code rather than a value.  'if(...)' is a statement for example.
* UMaterialExpression will normally override only 1 of GenerateHLSLStatement/GenerateHLSLExpression, although both are possible (for loop may override both, since the for loop index is an expression for example)
* FMaterialHLSLGenerator is the 'context' object passed to GenerateHLSLStatement/GenerateHLSLExpression.  This is kind of like FHLSLMaterialTranslator.  It's responsible for tracking which scope statements/expressions belong to (this can evolve as a given expression/statement is accessed from multiple UMaterialExpressions)
* HLSLTree.h contains the implementation of Expression and FStatement.  I feel like it's possible this could be useful outside of the material system (for example could be shared with Niagara).  Will be tricky to partition/organize the code in such a way to make this work though.
* HLSLTreeCommon.h contains derived expression/statement types.  The intent is to support plugins that define additional derived types.
* MaterialExpressionHLSL.cpp contains the implementations of GenerateHLSLStatement/GenerateHLSLExpression I've added so far.  Eventually all expression types will need to be converted over (this will be a big job).  Once the new system is done, we can remove all the old Compile() functions in MaterialExpressions.cpp
* I haven't given any real thought to Strata or analytic derivatives yet, but I don't forsee any serious problem adapting them to this new system

#jira none
#rb arciel.rekman, sebastien.hillaire, rune.stubbe

[CL 15536071 by Ben Ingram in ue5-main branch]
2021-02-25 19:27:22 -04:00
Marc Audy
bf80889353 UE5/Release-Engine-Staging to UE5/Main
This represents UE4/Main up to CL# 14958402

[CL 15028197 by Marc Audy in ue5-main branch]
2021-01-08 19:56:07 -04:00
Zousar Shaker
fc2ad21a5e Prototype Wrapped Object Pointers (ObjectHandle/ObjectPtr)
Call-site changes for non-scalar wrapped object pointer upgrades in Engine + Shootergame

#rb devin.doucette

[CL 14996467 by Zousar Shaker in ue5-main branch]
2021-01-05 19:16:25 -04:00
Marc Audy
ada7c144fa Merge //UE5/Release-Engine-Staging @14903491 to //UE5/Main
[CL 14906022 by Marc Audy in ue5-main branch]
2020-12-11 14:21:20 -04:00
Marc Audy
4c1bb11c29 Merge UE5/Release-Engine-Staging to UE5/Main @ 14548662
This represents UE4/Main @ 14525125 + cherrypicked fixes
#skipundocheck

[CL 14551026 by Marc Audy in ue5-main branch]
2020-10-22 19:19:16 -04:00
daren cheng
0e796eb369 Add grouping to material graph.
Add composite & pinbase expressions / nodes, which use reroutes under the hood to ensure zero material overhead.
Convert MaterialEditor to a WorkflowCentricApplication.
Generally add subgraph existence support to MaterialGraph / MaterialEditor.

#jira UE-96104
#rb Ben.Ingram Lauren.Barnes
#fyi Lauren.Barnes

[CL 14437968 by daren cheng in ue5-main branch]
2020-10-07 10:35:24 -04:00
Marc Audy
11f5b21210 Merging //UE5/Release-Engine-Staging @ 13752110 to Main (//UE5/Main)
#rnx

[CL 13753156 by Marc Audy in ue5-main branch]
2020-06-23 18:40:00 -04:00