Commit Graph

153 Commits

Author SHA1 Message Date
Matt Peters
07a0af0f5b BulkDataRegistry
Updating FVirtualizedUntypedBulkData and textures to use the BulkDataRegistry.
BulkDataRegistry: Add get/put accessors for the cached BulkDataList of packages.
EditorDomain: Move ClassDigests into a global variable that can be shared with BulkDataRegistry.
EditorDomain: Improve performance of GetFileSize by fetching metadata only.
Tickable Cook Objects, for systems used by the cooker that need to be ticked.
Implementation of the the BulkDataRegistry that uses the DDC cache for persistent storage of the BulkDataList.

#rb Devin.Doucette, Paul.Chipchase, Zousar.Shaker

[CL 16768772 by Matt Peters in ue5-main branch]
2021-06-24 00:50:53 -04:00
paul chipchase
1178d572e0 Remove UE_USE_VIRTUALBULKDATA and the associated code path, there is now no easy way to revert back to old bulkdata format for StaticMesh/Textures.
#rb Danny.Couture
#rnx
#preflight 60d0386978c3b00001d06c06

* Macro removal
- UE_USE_VIRTUALBULKDATA: Asssumed to be 1.
- UE_VBD_TO_OLD_BULKDATA_PATH: Assumed to be 0 and code paths entirely deleted.
- UE_VBD_CONST: Assumed to be'const'
- Now that these macros are no longer in use some includes of VirtualizationManager.h can be removed (or moved to the cpp).

*VirtualizedBulkData
- No longer need need to include VirtualizationManager.h in the bulkdata header file so that is moved to the cpp.
- Removed ::GetBulkDataSize which was only added to keep compatibility to older code paths. This method has not yet been released publicly(it's not in EA) so we don't need to worry that anyone is actually using it.
- Add a new method ::HasPayloadData that allows the caller to poll if the payload exists and if it has a valid data length rather than calling ::GetPayloadSize (I'd like to move away from the need for calling code to know how large the payload is until the payload is actually pulled as it will make eventual thread safety code easier to do in the future).
- Added a method ::SetCompressionFormat that allows the compression format to be changed. Normally this should only be done when ::UpdatePayload is called but we need a way to fix old textures that were saved with the wrong compression flags for a time and to do that we need to be able to 'reset' the compression format in some cases. The method is documented to try and make it clear that this is not really intended for general use. At some point in the future if the engine mandates that packages be resaved to a specific version we can look into deprecating this call.

*StaticMeshSourceData
- MESHDATAKEY_STATICMESH_DERIVEDDATA_VER is currently 1 character shorter than it should be, but that doesn't seem worth changing the key to fix.

*Texture
- When accessing data from IImageWrapper we can take the data pointer directly from the TArray and give it's ownership to the FSharedBuffer being returned rather than cloning it.
- Deprecated FTextureSource::LoadBulkDataWithFileReader as with VBD it will always return true.
- FMipAllocation cannot yet be deleted as it is still required for Lock/Unlock but we can remove the support for old style FByteBulkData for now. There is further clean up work to be done here but we would have to make bigger changes to the FTextureSource api.
- FMipData can now store the data in FSharedBuffer format. In the future we can allow people to access mips via views rather than always taking copies to reduce unnecessary data transfer. This also eliminates the need to pass in a lock.
- FTextureSource::InitLayered still supports the parameter 'NewData' potentially being nullptr (in which case we set the texture data to uninitialized memory) this is another candidate for a future code clean up.
- Added a ::HasPayloadData to use instead of ::GetSizeOnDisk as in many cases the calling code is only interested if there is data at all and not what the exact size is.

* Testing
- Ran benchmarks before/after for cold cooks of an internal project showing overall cook times going from 1:54:28 down to 1:49:36 on average.

[CL 16727381 by paul chipchase in ue5-main branch]
2021-06-21 08:53:20 -04:00
paul chipchase
aef4aad935 Enabling the use of Virtualized BulkData api for both static meshes and textures. NOTE: This will not start virtualizing content data
This will cause the old bulkdata objects to be upgraded when loaded in the editor and saved out in the new format when the package is next saved.

#rb PJ.Kack
#rnx
#preflight 609a4df10ba7b600015e0da2

* UE5CookerObjectVersion
- Note that this work was done in CL 16266112 (it was easier to update this on the DevCooker branch)
- Moved UE_USE_VIRTUALBULKDATA to VirtualizationManager.
- Moved the virtualization versions to UE5MainStreamObjectVersion.
- Note that no package would have been saved with UE_USE_VIRTUALBULKDATA so it is safe to just move the versions.

* UE5MainStreamObjectVersion
- Added the virtialization versions here
- Fixed up some white space issues

* VirtualizationManager
- UE_USE_VIRTUALBULKDATA is now controlled from here.
- When disabled (set to 0) a new code path UE_VBD_TO_OLD_BULKDATA_PATH will be enabled that will attempt to allow packages saved with VBD to be reverted safely.
-- This requires that a new version be added to FUE5MainStreamObjectVersion, there is a static assert to warn people about this.

* VirtualizedBulkData
- Added a new method ::ConvertToOldBulkData which will load the VBD payload from disk and then pass it to the old bulkdata object provided. This is not as efficient as the OldBulkData->VBD path but is only provided as an emergancy way for us to back out if needed, we do not expect this code to actually be used.
- Fixed a bug where converting an empty bulkdata object to VBD would give a warning about invalid guids. If the provided bulkdata object is empty then it is likely that we will not have generated a unique guid for it anyway. A VBD object with no payload would expect to have an unset FPayloadId AND an invalid bulkdata identifier anyway so we can just do that and only warn in the case that a valid payload has no valid guid provided. This has a bonus of making the code easier to read as well.

* StaticMeshSourceData
- Updated MESHDATAKEY_STATICMESH_DERIVEDDATA_VER when UE_USE_VIRTUALBULKDATA is enabled again.
-- This probably isn't required but in theory some of our tests could've written mesh description data to the DDC with the old key, so we should update it to play it safe.

* Texture
- Converted to use FUE5MainStreamObjectVersion for it's version number
- Added a code path that will allow us to convert back to using old style bulkdata if UE_USE_VIRTUALBULKDATA is disabled and UE_VBD_TO_OLD_BULKDATA_PATH is enabled.

*MeshDescription
- Converted to use FUE5MainStreamObjectVersion for it's version number
-- Note that we don't have to tell the archive that we are using this because this was already happening.
- Added a code path that will allow us to convert back to using old style bulkdata if UE_USE_VIRTUALBULKDATA is disabled and UE_VBD_TO_OLD_BULKDATA_PATH is enabled.

[CL 16266408 by paul chipchase in ue5-main branch]
2021-05-11 06:28:45 -04:00
Andrew Davidson
3ddc3a4da3 Merge up from //UE5/Dev-LargeWorldCoordinates
#rb none

[CL 16211417 by Andrew Davidson in ue5-main branch]
2021-05-05 15:07:25 -04:00
halfdan ingvarsson
5ab1f8001f Added IsReservedAttributeName to check if an attribute is "reserved", i.e. meaning it should only be created by the given *MeshAttributes class or its bases.
#rb richard.talbotwatkin
#jira none
#rnx

[CL 16168127 by halfdan ingvarsson in ue5-main branch]
2021-04-30 10:30:27 -04:00
paul chipchase
71b969d9c4 Cherrypicking Mirage code base (disabled) from Dev-Cooker
- The mirage specific code is disabled behind the define UE_USE_VIRTUALBULKDATA, this means that some code paths in Texture/Mesh are much more complex than they need to be as we support both old and new paths. Once the system has been turned on and confirmed to cause no issues then this will be stripped out.
- SavePackageUtilities.cpp, SavePackage.cpp and SavePackage2.cpp are editgrates rather than integrations as those files have changes in DevCooker that we don't want to bring over immediately.
- Also includes a prototype system for storing bulkdata in a sidecar file in the workspace domain rather than in the .uasset/.umap file which although has been discontinued as part of mirage, will have applications for future work for non-virtualized projects and/or text based assets.

#rb Patrick.Finegan (all changes have been reviewed when submitted to Dev-Cooker)
#tests Cooking and running ShooterGame/Frosty and other sample programs using megascan assets
#rnx
#preflight  608be50d870cf400013ff99d

[CL 16167285 by paul chipchase in ue5-main branch]
2021-04-30 08:14:54 -04:00
semion piskarev
58d5cbd5cf MeshModelingTools: Adding current version of UV editor.
#rb Brooke.Hubert, Ryan.Schmidt
#rnx
#jira UETOOL-3108, UETOOL-3110

[CL 16078314 by semion piskarev in ue5-main branch]
2021-04-21 14:36:05 -04:00
danny couture
84f5594941 Add a couple of meaningful Insight traces
#rb Francis.Hurteau

[CL 16060641 by danny couture in ue5-main branch]
2021-04-20 09:46:29 -04:00
Steve Robb
490ff52780 Deprecation of TStaticArray's multi-element init constructor, to avoid confusion of something like TStaticArray<FVector4>(NoInit) and TStaticArray<FVector4>(InPlace, NoInit) producing very different codegen (worse in the original case).
#rb yuriy.odonnell
#jira none

[CL 16053261 by Steve Robb in ue5-main branch]
2021-04-19 14:34:13 -04:00
danny couture
8844de5ffb Add per asset memory usage approximation during async compilation to offer more precise throttling when memory is scarce or we're processing huge assets
- FQueuedThreadPoolWrapper will now try to retract any task it can until the max concurrency goal is achieved to respect priority as much as possible
  - Add memory requirement estimate on IQueuedWork to allow the threadpool wrapper to take action when required
  - Add logic in the asset compiler's threadpool to handle per asset memory requirement instead of using a default for all assets
  - Add estimate for static mesh and textures
  - This change should improve CPU usage when processing small assets on memory constrained systems and should prevent OOM when dealing with several excessively large assets

#jira UETOOL-3082
#rb Francis.Hurteau

[CL 16019139 by danny couture in ue5-main branch]
2021-04-15 05:30:38 -04:00
danny couture
95600e2d31 Avoid renderdata of HLOD being recomputed during cook package save because of non-deterministic guid
- Preserve guid during save if static mesh bulkdata content hasn't changed to avoid triggering unnecessary rebuilds
  - Make sure the next HLOD generation is going to use the HashAsGuid feature to avoid recompiling staticmesh that are generated if they are exactly the same as before

  - 31m10s to 14m15s to cook P_Construct_WP with a warmed-up DDC

#fyi Richard.TalbotWatkin
#rb Matt.Peters, Sebastien.Lussier, Yuriy.ODonnell

[CL 15755322 by danny couture in ue5-main branch]
2021-03-20 20:01:33 -04:00
halfdan ingvarsson
0ca6df2ce0 Added a TAttributesSet::ForEachByType utility function to iterate over attributes of a specific type (e.g. all floats). Allows better specialization of the called function for a given type.
#jira none
#rb Richard.TalbotWatkin

[CL 15658268 by halfdan ingvarsson in ue5-main branch]
2021-03-09 15:46:55 -04:00
Matt Peters
6895cee3ee EditorDomainSave - Strip bulk data from EditorDomain copies of packages. BulkData types in the EditorDomain have flags set to load the data from workspace domain version of the file.
#rb Paul.Chipchase
#rnx

[CL 15643329 by Matt Peters in ue5-main branch]
2021-03-08 14:13:00 -04:00
richard talbotwatkin
9b287d8b0b Better way to ensure that the inner UMeshDescriptionBase is instanced when duplicating the bulkdata wrapper.
#jira UE-109601

#ROBOMERGE-SOURCE: CL 15633007 in //UE5/Release-5.0-EarlyAccess/...
#ROBOMERGE-BOT: STARSHIP (Release-5.0-EarlyAccess -> Main) (v777-15581079)

[CL 15633009 by richard talbotwatkin in ue5-main branch]
2021-03-06 09:04:46 -04:00
richard talbotwatkin
c6c524c9dd Correctly construct an instanced UMeshDescriptionBase as an inner object of UMeshDescriptionBaseBulkData when duplicating a static mesh.
#jira UE-109601

#ROBOMERGE-SOURCE: CL 15626098 in //UE5/Release-5.0-EarlyAccess/...
#ROBOMERGE-BOT: STARSHIP (Release-5.0-EarlyAccess -> Main) (v777-15581079)

[CL 15626196 by richard talbotwatkin in ue5-main branch]
2021-03-05 13:04:39 -04:00
richard talbotwatkin
e62b002625 Changes for allocating StaticMesh subobjects in a more thread-safe way.
Always construct a UMeshDescriptionBase as a default subobject of the MeshDescriptionBulkData object, which can be recycled each time a UMeshDescriptionBase is required for that LOD.
Put GC scope guards around NewObject<> allocations to avoid clashes with GC when allocated on a thread.
Also identified other static mesh subobjects which can be potentially created in cooking commandlets when GC is taking place.
#jira UE-109204
#jira UE-109439
[FYI] Danny.Couture

#ROBOMERGE-SOURCE: CL 15534994 in //UE5/Release-5.0-EarlyAccess/...
#ROBOMERGE-BOT: STARSHIP (Release-5.0-EarlyAccess -> Main) (v771-15082668)

[CL 15535009 by richard talbotwatkin in ue5-main branch]
2021-02-25 18:14:04 -04:00
richard talbotwatkin
8647dbaed2 The MeshDescription object within the bulkdata is no longer marked as Transactable. All transactable changes must occur on the bulkdata itself, and these changes will be propagated to the cached MeshDescription, if one exists, during an undo/redo. Corrected BulkData serialize by only caching the MeshDescription from the BulkData if the archive is loading.
#jira UE-109248
#jira UE-109821

#ROBOMERGE-SOURCE: CL 15530405 in //UE5/Release-5.0-EarlyAccess/...
#ROBOMERGE-BOT: STARSHIP (Release-5.0-EarlyAccess -> Main) (v771-15082668)

[CL 15530441 by richard talbotwatkin in ue5-main branch]
2021-02-25 13:25:49 -04:00
richard talbotwatkin
25a64ff0bb Re-fixed undo/redo of static mesh geometry (FMeshDescriptionBulkData serialization). This must be allowed to happen for non-persistent archives, such as the transaction buffer.
#rb Sebastien.Lussier

#ROBOMERGE-SOURCE: CL 15529772 in //UE5/Release-5.0-EarlyAccess/...
#ROBOMERGE-BOT: STARSHIP (Release-5.0-EarlyAccess -> Main) (v771-15082668)

[CL 15529777 by richard talbotwatkin in ue5-main branch]
2021-02-25 12:43:28 -04:00
sebastien lussier
1b177e5038 MeshDescription fixes
* Added missing write lock in FMeshDescriptionBulkData::SaveMeshDescription( FMeshDescription& MeshDescription )
* Skip serialization of bulk data when archive is a ref collector
#rb danny.couture, richard.talbotwatkin

#ROBOMERGE-SOURCE: CL 15502374 in //UE5/Release-5.0-EarlyAccess/...
#ROBOMERGE-BOT: STARSHIP (Release-5.0-EarlyAccess -> Main) (v771-15082668)

[CL 15503758 by sebastien lussier in ue5-main branch]
2021-02-23 15:17:22 -04:00
richard talbotwatkin
8e65eef33e Fixed issues with editor -game mode.
StaticMesh hi res source model bulk data is no longer a default subobject; instead it is instanced if it was not present in PostLoad, thus fixing issues with object name differences.
MeshDescriptionBaseBulkData is marked as NeedsLoadForEditorGame, as well as not needing load for client or server, so that it can be loaded correctly.
#jira UE-108938

#ROBOMERGE-SOURCE: CL 15481115 in //UE5/Release-5.0-EarlyAccess/...
#ROBOMERGE-BOT: STARSHIP (Release-5.0-EarlyAccess -> Main) (v771-15082668)

[CL 15481116 by richard talbotwatkin in ue5-main branch]
2021-02-19 20:53:13 -04:00
richard talbotwatkin
0a06ce9d2b Declared UMeshDescriptionBaseBulkData an editor-only class by implementing NeedsLoadForClient/Server() returning false. This prevents it from being cooked.
Made the HiResSourceModel MeshDescriptionBulkData a regular default subobject, so that it is still valid in Editor -game builds.
#jira UE-108938
#rb Robert.Manuszewski

#ROBOMERGE-SOURCE: CL 15471361 in //UE5/Release-5.0-EarlyAccess/...
#ROBOMERGE-BOT: STARSHIP (Release-5.0-EarlyAccess -> Main) (v771-15082668)

[CL 15471367 by richard talbotwatkin in ue5-main branch]
2021-02-19 09:24:38 -04:00
Richard TalbotWatkin
bf10d3336a Refactor of source model representation for static meshes.
- Moved source models related classes and implementation into separate files.
- Created a new UObject wrapper for holding mesh description bulk data; this is created as a transactable object inside a UStaticMesh.
- The cached mesh description is now an inner object of the bulk data wrapper; this allows transactions on the bulk data to affect the cached mesh.
- The static mesh SourceModels array can no longer be accessed directly: FStaticMeshSourceModel requires extra initialization before it should be used, so new LODs should be added through the static mesh API.
- Undo/redo is now fixed within the geometry tools
- Fixed regression where mesh description was being unpacked unnecessarily during transactions
- MeshDescription bulk data and its cached MeshDescriptions are now emptied prior to removing the UObject reference, in order to immediately free memory instead of needing to wait for garbage collection
- No more deadlocks when clearing or committing mesh descriptions during garbage collection
- Bulk data UObjects are constructed, where possible, at startup, in order to prevent it from happening during critical moments, e.g. during garbage collection or package saving.
#rb Danny.Couture, Alexis.Matte, Ryan.Schmidt

[CL 15420827 by Richard TalbotWatkin in ue5-main branch]
2021-02-16 15:14:02 -04:00
Richard TalbotWatkin
b0b120e57c Changes to handling of source model data for StaticMeshes.
- The MeshDescription for each source model LOD is now wrapped in a UStaticMeshDescription, meaning that it can be transacted separately to the parent static mesh. This improves memory and time performance in static mesh transactions, e.g. when assigning materials.
- FStaticMeshSourceModel now has its own API for managing the mesh description and its bulk data.
- A new optional Hi-res SourceModel member has been added to StaticMesh; this allows the original source data to be stored here, while a reduced LOD0 can be stored as SourceModel LOD0, to allow geometry modelling tools to work efficiently.
- MeshDescription is now serialized using a proxy archive object which ensures that FNames can always be archived as strings.
- UStaticMeshDescription is now serialized.
- UStaticMeshDescription has been reverted to only holding its own mesh description, instead of being able to reference any external mesh description. This previous change was never released.
- RawMesh is now immediately converted to MeshDescription in PostLoad, so that the MeshDescription[BulkData] pointers are always valid, and can be tag serialised automatically during transactions. RawMesh should now not be used in the editor at all, and will soon be deprecated.

This change results in far quicker and memory-efficient transactions in StaticMeshes. e.g. assign material to a static mesh section for a 20000 vertex mesh now takes less than a second (discounting time to rebuild the render proxy) instead of 7+ seconds.

#rb Alexis.Matte, Danny.Couture

[CL 15248935 by Richard TalbotWatkin in ue5-main branch]
2021-01-28 16:27:47 -04:00
halfdan ingvarsson
5667fa808f MeshDescription: Add SortByPredicate, StableSortByPredicate and SetNumUninitialized to TArrayAttribute
#rb Richard.TalbotWatkins
#jira none
#rnx

[CL 15158781 by halfdan ingvarsson in ue5-main branch]
2021-01-21 16:22:54 -04:00
Richard TalbotWatkin
c1a73f430e Changed behaviour of GetRawArray so that it returns an empty TArrayView when the container has zero elements. Previously it would attempt to dereference the underlying array allocation which may be nullptr for an empty array.
#rb Jimmy.Andrews

[CL 15089599 by Richard TalbotWatkin in ue5-main branch]
2021-01-14 14:31:57 -04:00