From 0e75dba14294d9c8ef59a422dd916e0c9ec2b2e9 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Fri, 30 Apr 2021 16:27:57 +0200 Subject: [PATCH] Optimize C++ compilation time --- Source/Editor/Analytics/EditorAnalytics.cpp | 1 + Source/Editor/Content/PreviewsCache.cpp | 2 +- Source/Editor/Cooker/GameCooker.cpp | 1 + Source/Editor/Cooker/Steps/CookAssetsStep.cpp | 1 + Source/Editor/Cooker/Steps/DeployDataStep.cpp | 1 + .../CustomEditors/CustomEditorsUtil.cpp | 1 + Source/Editor/Scripting/ScriptsBuilder.cpp | 1 + Source/Editor/Utilities/EditorUtilities.cpp | 1 + Source/Editor/Windows/SplashScreen.cpp | 2 + .../Animations/Graph/AnimGraph.Custom.cpp | 12 + Source/Engine/Animations/Graph/AnimGraph.cpp | 4 +- Source/Engine/Animations/Graph/AnimGraph.h | 16 +- .../SceneAnimations/SceneAnimation.cpp | 2 +- .../SceneAnimations/SceneAnimationPlayer.cpp | 1 + .../SceneAnimations/SceneAnimationPlayer.h | 1 + Source/Engine/Audio/AudioClip.cpp | 3 +- Source/Engine/CSG/CSGBuilder.cpp | 1 + Source/Engine/Content/Assets/Animation.cpp | 2 +- .../Engine/Content/Assets/AnimationGraph.cpp | 2 +- .../Content/Assets/AnimationGraphFunction.cpp | 2 +- Source/Engine/Content/Assets/CubeTexture.cpp | 2 +- Source/Engine/Content/Assets/IESProfile.cpp | 2 +- Source/Engine/Content/Assets/Material.cpp | 17 +- .../Content/Assets/MaterialFunction.cpp | 2 +- .../Content/Assets/MaterialInstance.cpp | 2 +- Source/Engine/Content/Assets/Model.cpp | 4 +- Source/Engine/Content/Assets/RawDataAsset.cpp | 2 +- Source/Engine/Content/Assets/Shader.cpp | 6 +- Source/Engine/Content/Assets/Shader.h | 4 +- Source/Engine/Content/Assets/SkeletonMask.cpp | 2 +- Source/Engine/Content/Assets/SkinnedModel.cpp | 9 +- Source/Engine/Content/Assets/SkinnedModel.h | 5 +- Source/Engine/Content/Assets/Texture.cpp | 2 +- Source/Engine/Content/Assets/VisualScript.cpp | 2 +- Source/Engine/Content/BinaryAsset.cpp | 8 +- Source/Engine/Content/BinaryAsset.h | 9 +- Source/Engine/Content/Cache/AssetsCache.cpp | 12 + Source/Engine/Content/Cache/AssetsCache.h | 28 +- Source/Engine/Content/Content.cpp | 1 + .../Content/Factories/BinaryAssetFactory.cpp | 5 +- .../Content/Factories/BinaryAssetFactory.h | 25 +- .../Engine/Content/Factories/IAssetFactory.h | 3 - Source/Engine/Content/Storage/AssetHeader.h | 21 +- .../Content/Storage/ContentStorageManager.h | 1 + Source/Engine/Content/Storage/FlaxStorage.cpp | 5 + .../Content/Storage/FlaxStorageReference.h | 5 +- .../Content/Upgraders/AudioClipUpgrader.h | 4 + .../Content/Upgraders/BinaryAssetUpgrader.h | 4 + .../Content/Upgraders/FontAssetUpgrader.h | 4 + .../Engine/Content/Upgraders/IAssetUpgrader.h | 4 + .../Upgraders/MaterialInstanceUpgrader.h | 4 + .../Content/Upgraders/ModelAssetUpgrader.h | 4 + .../Content/Upgraders/ShaderAssetUpgrader.h | 4 + .../Content/Upgraders/SkeletonMaskUpgrader.h | 4 + .../Upgraders/SkinnedModelAssetUpgrader.h | 4 + .../Content/Upgraders/TextureAssetUpgrader.h | 4 + Source/Engine/ContentImporters/CreateJson.cpp | 1 + Source/Engine/Core/Collections/Dictionary.h | 8 +- Source/Engine/Core/Memory/Memory.h | 2 + Source/Engine/Core/Types/DataContainer.h | 20 +- Source/Engine/Core/Types/DateTime.cpp | 96 ++- Source/Engine/Core/Types/DateTime.h | 155 +---- Source/Engine/Core/Types/String.h | 1 + Source/Engine/Core/Types/StringView.h | 6 - Source/Engine/Core/Types/TimeSpan.h | 1 - Source/Engine/Debug/DebugDraw.cpp | 8 +- Source/Engine/Debug/DebugLog.cpp | 1 + Source/Engine/Engine/Base/GameBase.cpp | 4 +- Source/Engine/Engine/GameplayGlobals.cpp | 6 +- Source/Engine/Engine/Globals.cpp | 1 - Source/Engine/Engine/Globals.h | 3 - Source/Engine/Foliage/Foliage.cpp | 1 + Source/Engine/Graphics/GPUDevice.cpp | 1 + .../Graphics/Materials/MaterialParams.cpp | 38 +- .../Graphics/Materials/MaterialParams.h | 11 +- .../Materials/MaterialShaderFeatures.cpp | 1 + Source/Engine/Graphics/Models/Mesh.cpp | 7 + Source/Engine/Graphics/Models/Mesh.h | 20 +- .../Engine/Graphics/Models/ModelData.Tool.cpp | 1 + Source/Engine/Graphics/Models/SkinnedMesh.cpp | 2 + Source/Engine/Graphics/Models/SkinnedMesh.h | 6 +- .../Graphics/Models/SkinnedModelLOD.cpp | 6 + .../Engine/Graphics/Models/SkinnedModelLOD.h | 7 +- Source/Engine/Graphics/PostProcessSettings.h | 1 + Source/Engine/Graphics/RenderTools.cpp | 1 + .../Shaders/Cache/ShaderAssetBase.cpp | 34 + .../Graphics/Shaders/Cache/ShaderAssetBase.h | 61 +- .../Engine/Graphics/Textures/ITextureOwner.h | 3 +- .../Graphics/Textures/StreamingTexture.cpp | 36 +- .../Graphics/Textures/StreamingTexture.h | 62 +- .../Engine/Graphics/Textures/TextureBase.cpp | 39 +- Source/Engine/Graphics/Textures/TextureBase.h | 34 +- .../GraphicsDevice/Vulkan/GPUDeviceVulkan.cpp | 3 +- Source/Engine/Level/Actor.cpp | 1 + Source/Engine/Level/Actors/AnimatedModel.cpp | 1 + Source/Engine/Level/Actors/AnimatedModel.h | 1 + Source/Engine/Level/Actors/Camera.cpp | 6 +- .../Engine/Level/Actors/EnvironmentProbe.cpp | 1 + Source/Engine/Level/Actors/Light.cpp | 3 + Source/Engine/Level/Actors/Sky.cpp | 7 +- Source/Engine/Level/Actors/Sky.h | 2 + Source/Engine/Level/Actors/SkyLight.cpp | 1 + Source/Engine/Level/Actors/SplineModel.cpp | 5 + Source/Engine/Level/Actors/StaticModel.cpp | 3 + Source/Engine/Level/Actors/StaticModel.h | 1 + Source/Engine/Level/Level.cpp | 1 + Source/Engine/Level/Level.h | 1 + Source/Engine/Level/Prefabs/Prefab.Apply.cpp | 1 + Source/Engine/Level/Prefabs/Prefab.h | 2 +- Source/Engine/Level/Scene/Lightmap.cpp | 9 + Source/Engine/Level/Scene/Lightmap.h | 9 +- Source/Engine/Level/Scene/Scene.cpp | 3 + Source/Engine/Level/Scene/SceneRendering.cpp | 1 + Source/Engine/Level/SceneObject.h | 4 +- Source/Engine/Level/SceneObjectsFactory.cpp | 1 + .../Localization/LocalizedStringTable.h | 1 + Source/Engine/Navigation/NavMeshData.cpp | 1 + Source/Engine/Navigation/NavMeshData.h | 3 + .../Graph/CPU/ParticleEmitterGraph.CPU.cpp | 3 +- .../Graph/CPU/ParticleEmitterGraph.CPU.h | 2 + .../Particles/Graph/GPU/GPUParticles.cpp | 2 + ...rticleEmitterGraph.GPU.ParticleModules.cpp | 1 + .../GPU/ParticleEmitterGraph.GPU.Textures.cpp | 1 + .../Graph/GPU/ParticleEmitterGraph.GPU.cpp | 5 +- Source/Engine/Particles/ParticleEmitter.cpp | 18 +- .../Particles/ParticleEmitterFunction.cpp | 2 +- Source/Engine/Particles/ParticleManager.cpp | 4 +- Source/Engine/Particles/ParticleSystem.cpp | 2 +- Source/Engine/Particles/ParticlesData.cpp | 2 + Source/Engine/Particles/ParticlesData.h | 2 +- .../Engine/Particles/ParticlesSimulation.cpp | 2 + .../Engine/Physics/Colliders/MeshCollider.cpp | 1 + .../Physics/Colliders/SplineCollider.cpp | 1 + Source/Engine/Physics/CollisionData.cpp | 2 +- .../Engine/Physics/SimulationEventCallback.h | 3 +- .../Platform/Android/AndroidFileSystem.cpp | 1 + Source/Engine/Platform/Base/PlatformBase.cpp | 2 + Source/Engine/Platform/Unix/UnixFile.cpp | 1 + .../Engine/Platform/Win32/Win32Platform.cpp | 1 + .../Platform/Windows/WindowsPlatform.cpp | 1 + Source/Engine/Render2D/FontAsset.cpp | 2 +- Source/Engine/Render2D/FontTextureAtlas.cpp | 2 +- Source/Engine/Render2D/Render2D.cpp | 10 +- Source/Engine/Render2D/SpriteAtlas.cpp | 2 +- .../Engine/Renderer/AmbientOcclusionPass.cpp | 6 +- Source/Engine/Renderer/AntiAliasing/FXAA.cpp | 1 + Source/Engine/Renderer/AntiAliasing/SMAA.cpp | 1 + Source/Engine/Renderer/AntiAliasing/TAA.cpp | 2 + .../Engine/Renderer/AtmospherePreCompute.cpp | 6 +- Source/Engine/Renderer/ColorGradingPass.cpp | 2 + Source/Engine/Renderer/DepthOfFieldPass.cpp | 10 +- .../Renderer/Editor/LightmapUVsDensity.cpp | 2 + .../Renderer/Editor/LightmapUVsDensity.h | 2 + .../Engine/Renderer/Editor/VertexColors.cpp | 2 + Source/Engine/Renderer/Editor/VertexColors.h | 2 + Source/Engine/Renderer/EyeAdaptationPass.cpp | 11 +- Source/Engine/Renderer/ForwardPass.cpp | 4 + Source/Engine/Renderer/GBufferPass.cpp | 6 +- Source/Engine/Renderer/HistogramPass.cpp | 2 + Source/Engine/Renderer/LightPass.cpp | 1 + Source/Engine/Renderer/MotionBlurPass.cpp | 5 + Source/Engine/Renderer/PostProcessingPass.cpp | 1 + Source/Engine/Renderer/ProbesRenderer.cpp | 3 +- Source/Engine/Renderer/ReflectionsPass.cpp | 2 + Source/Engine/Renderer/Renderer.cpp | 1 + .../Renderer/ScreenSpaceReflectionsPass.cpp | 2 + Source/Engine/Renderer/ShadowsPass.cpp | 3 +- Source/Engine/Renderer/ShadowsPass.h | 1 + Source/Engine/Renderer/Utils/BitonicSort.cpp | 1 + Source/Engine/Renderer/Utils/MultiScaler.cpp | 1 + Source/Engine/Renderer/VolumetricFogPass.cpp | 1 + Source/Engine/Renderer/VolumetricFogPass.h | 4 + Source/Engine/Scripting/BinaryModule.cpp | 5 + Source/Engine/Scripting/BinaryModule.h | 6 +- Source/Engine/Scripting/InternalCalls.h | 4 +- .../Scripting/ManagedCLR/MAssembly.Mono.cpp | 2 + .../Engine/Scripting/ManagedCLR/MAssembly.h | 1 + .../Scripting/ManagedCLR/MCore.Mono.cpp | 1 + Source/Engine/Scripting/ManagedCLR/MUtils.h | 1 + .../Engine/Scripting/Scripting.Internal.cpp | 1 + Source/Engine/Scripting/Scripting.cpp | 11 +- Source/Engine/Scripting/Scripting.h | 27 +- Source/Engine/Scripting/Types.h | 1 + .../Engine/Serialization/ISerializeModifier.h | 28 +- Source/Engine/Serialization/JsonWriter.cpp | 205 +++++- Source/Engine/Serialization/JsonWriter.h | 245 +------ Source/Engine/Serialization/Serialization.cpp | 15 + Source/Engine/Serialization/Serialization.h | 2 +- .../ShadersCompilation/ShaderCompiler.cpp | 1 + .../ShadersCompilation/ShadersCompilation.cpp | 1 + .../ShadowsOfMordor/Builder.BuildCache.cpp | 3 + .../Engine/ShadowsOfMordor/Builder.Charts.cpp | 2 +- .../Engine/ShadowsOfMordor/Builder.DoWork.cpp | 2 + .../Engine/ShadowsOfMordor/Builder.Jobs.cpp | 4 +- Source/Engine/ShadowsOfMordor/Builder.cpp | 3 + Source/Engine/ShadowsOfMordor/Builder.h | 4 + Source/Engine/Streaming/StreamableResource.h | 43 +- Source/Engine/Terrain/Terrain.cpp | 3 +- Source/Engine/Terrain/TerrainChunk.cpp | 2 + Source/Engine/Terrain/TerrainPatch.cpp | 3 +- Source/Engine/Threading/ConcurrentQueue.h | 2 +- Source/Engine/Threading/ThreadPool.cpp | 6 + Source/Engine/Threading/Threading.h | 25 +- .../Tools/AudioTool/OggVorbisEncoder.cpp | 1 + .../MaterialGenerator.Layer.cpp | 6 +- .../MaterialGenerator/MaterialGenerator.cpp | 1 + Source/Engine/Tools/ModelTool/ModelTool.cpp | 1 + .../Engine/Tools/TextureTool/TextureTool.cpp | 1 + Source/Engine/UI/SpriteRender.cpp | 1 + Source/Engine/Utilities/Screenshot.cpp | 1 + Source/Engine/Utilities/TextWriter.h | 4 +- Source/Engine/Visject/ShaderGraph.h | 1 + .../Engine/Visject/ShaderGraphUtilities.cpp | 2 + Source/ThirdParty/concurrentqueue.h | 5 +- Source/ThirdParty/fmt/core.h | 4 +- Source/ThirdParty/fmt/format-inl.h | 37 - Source/ThirdParty/fmt/format.h | 637 +----------------- Source/ThirdParty/fmt/ostream.h | 2 +- Source/ThirdParty/rapidjson/document.h | 31 - .../rapidjson/internal/biginteger.h | 2 +- Source/ThirdParty/rapidjson/internal/diyfp.h | 2 +- Source/ThirdParty/rapidjson/reader.h | 5 +- 222 files changed, 1095 insertions(+), 1506 deletions(-) diff --git a/Source/Editor/Analytics/EditorAnalytics.cpp b/Source/Editor/Analytics/EditorAnalytics.cpp index 3f067719e..c2a293c15 100644 --- a/Source/Editor/Analytics/EditorAnalytics.cpp +++ b/Source/Editor/Analytics/EditorAnalytics.cpp @@ -10,6 +10,7 @@ #include "Editor/Editor.h" #include "Editor/ProjectInfo.h" #include "Engine/Engine/EngineService.h" +#include "Engine/Engine/Globals.h" #include "Engine/Graphics/GPUDevice.h" #include "Engine/Utilities/StringConverter.h" #include "FlaxEngine.Gen.h" diff --git a/Source/Editor/Content/PreviewsCache.cpp b/Source/Editor/Content/PreviewsCache.cpp index c51e8cabb..c89b00004 100644 --- a/Source/Editor/Content/PreviewsCache.cpp +++ b/Source/Editor/Content/PreviewsCache.cpp @@ -76,7 +76,7 @@ void PreviewsCache::FlushTask::OnEnd() ThreadPoolTask::OnEnd(); } -REGISTER_BINARY_ASSET(PreviewsCache, "FlaxEditor.PreviewsCache", ::New(), false); +REGISTER_BINARY_ASSET_WITH_UPGRADER(PreviewsCache, "FlaxEditor.PreviewsCache", TextureAssetUpgrader, false); PreviewsCache::PreviewsCache(const SpawnParams& params, const AssetInfo* info) : SpriteAtlas(params, info) diff --git a/Source/Editor/Cooker/GameCooker.cpp b/Source/Editor/Cooker/GameCooker.cpp index c50b10572..f64045ff5 100644 --- a/Source/Editor/Cooker/GameCooker.cpp +++ b/Source/Editor/Cooker/GameCooker.cpp @@ -10,6 +10,7 @@ #include "Engine/Serialization/JsonTools.h" #include "Engine/Content/Content.h" #include "Engine/Engine/EngineService.h" +#include "Engine/Engine/Globals.h" #include "Engine/Threading/ThreadSpawner.h" #include "Engine/Platform/FileSystem.h" #include "Steps/ValidateStep.h" diff --git a/Source/Editor/Cooker/Steps/CookAssetsStep.cpp b/Source/Editor/Cooker/Steps/CookAssetsStep.cpp index 90d5bfd55..5f097f638 100644 --- a/Source/Editor/Cooker/Steps/CookAssetsStep.cpp +++ b/Source/Editor/Cooker/Steps/CookAssetsStep.cpp @@ -29,6 +29,7 @@ #include "Engine/Graphics/RenderTools.h" #include "Engine/Graphics/Textures/TextureData.h" #include "Engine/Engine/Base/GameBase.h" +#include "Engine/Engine/Globals.h" #include "Engine/Tools/TextureTool/TextureTool.h" #if PLATFORM_TOOLS_WINDOWS #include "Engine/Platform/Windows/WindowsPlatformSettings.h" diff --git a/Source/Editor/Cooker/Steps/DeployDataStep.cpp b/Source/Editor/Cooker/Steps/DeployDataStep.cpp index ab7f3a7b2..17ddbf73c 100644 --- a/Source/Editor/Cooker/Steps/DeployDataStep.cpp +++ b/Source/Editor/Cooker/Steps/DeployDataStep.cpp @@ -7,6 +7,7 @@ #include "Engine/Core/Config/GameSettings.h" #include "Engine/Renderer/ReflectionsPass.h" #include "Engine/Renderer/AntiAliasing/SMAA.h" +#include "Engine/Engine/Globals.h" bool DeployDataStep::Perform(CookingData& data) { diff --git a/Source/Editor/CustomEditors/CustomEditorsUtil.cpp b/Source/Editor/CustomEditors/CustomEditorsUtil.cpp index ffd42d750..519acdf60 100644 --- a/Source/Editor/CustomEditors/CustomEditorsUtil.cpp +++ b/Source/Editor/CustomEditors/CustomEditorsUtil.cpp @@ -3,6 +3,7 @@ #include "CustomEditorsUtil.h" #include "Engine/Core/Log.h" #include "Engine/Core/Types/DateTime.h" +#include "Engine/Core/Types/TimeSpan.h" #include "Engine/Core/Collections/Dictionary.h" #include "Engine/Engine/EngineService.h" #include "Engine/Scripting/Scripting.h" diff --git a/Source/Editor/Scripting/ScriptsBuilder.cpp b/Source/Editor/Scripting/ScriptsBuilder.cpp index 00a93b66c..71323dc34 100644 --- a/Source/Editor/Scripting/ScriptsBuilder.cpp +++ b/Source/Editor/Scripting/ScriptsBuilder.cpp @@ -9,6 +9,7 @@ #include "Engine/Core/Types/StringBuilder.h" #include "Engine/Debug/Exceptions/FileNotFoundException.h" #include "Engine/Engine/Engine.h" +#include "Engine/Engine/Globals.h" #include "Engine/Platform/FileSystem.h" #include "Engine/Platform/FileSystemWatcher.h" #include "Engine/Threading/ThreadPool.h" diff --git a/Source/Editor/Utilities/EditorUtilities.cpp b/Source/Editor/Utilities/EditorUtilities.cpp index aa26388c1..85d409b92 100644 --- a/Source/Editor/Utilities/EditorUtilities.cpp +++ b/Source/Editor/Utilities/EditorUtilities.cpp @@ -1,6 +1,7 @@ // Copyright (c) 2012-2021 Wojciech Figat. All rights reserved. #include "EditorUtilities.h" +#include "Engine/Engine/Globals.h" #include "Engine/Platform/File.h" #include "Engine/Platform/FileSystem.h" #include "Engine/Core/Log.h" diff --git a/Source/Editor/Windows/SplashScreen.cpp b/Source/Editor/Windows/SplashScreen.cpp index cd0c70f02..e4b8ddc3e 100644 --- a/Source/Editor/Windows/SplashScreen.cpp +++ b/Source/Editor/Windows/SplashScreen.cpp @@ -2,7 +2,9 @@ #include "SplashScreen.h" #include "Engine/Core/Log.h" +#include "Engine/Core/Types/TimeSpan.h" #include "Engine/Engine/CommandLine.h" +#include "Engine/Engine/Globals.h" #include "Engine/Render2D/FontAsset.h" #include "Engine/Render2D/Font.h" #include "Engine/Render2D/TextLayoutOptions.h" diff --git a/Source/Engine/Animations/Graph/AnimGraph.Custom.cpp b/Source/Engine/Animations/Graph/AnimGraph.Custom.cpp index eaa080f9a..91ef2cc54 100644 --- a/Source/Engine/Animations/Graph/AnimGraph.Custom.cpp +++ b/Source/Engine/Animations/Graph/AnimGraph.Custom.cpp @@ -10,6 +10,7 @@ #include "Engine/Scripting/ManagedCLR/MUtils.h" #include "Engine/Scripting/Scripting.h" #include "Engine/Scripting/MException.h" +#include "Engine/Content/Assets/SkinnedModel.h" #include struct InternalInitData @@ -144,6 +145,17 @@ void AnimGraphExecutor::ProcessGroupCustom(Box* boxBase, Node* nodeBase, Value& box->Cache = value; } +bool AnimGraph::IsReady() const +{ + return BaseModel && BaseModel->IsLoaded(); +} + +bool AnimGraph::CanUseWithSkeleton(SkinnedModel* other) const +{ + // All data loaded and bones count the same + return IsReady() && other && other->IsLoaded() && other->Skeleton.Bones.Count() == BaseModel->Skeleton.Bones.Count(); +} + void AnimGraph::ClearCustomNode(Node* node) { // Clear data diff --git a/Source/Engine/Animations/Graph/AnimGraph.cpp b/Source/Engine/Animations/Graph/AnimGraph.cpp index 2abbb3ff3..8ef9adcdb 100644 --- a/Source/Engine/Animations/Graph/AnimGraph.cpp +++ b/Source/Engine/Animations/Graph/AnimGraph.cpp @@ -1,8 +1,10 @@ // Copyright (c) 2012-2021 Wojciech Figat. All rights reserved. #include "AnimGraph.h" -#include "Engine/Engine/Time.h" +#include "Engine/Content/Assets/SkinnedModel.h" +#include "Engine/Graphics/Models/SkeletonData.h" #include "Engine/Scripting/Scripting.h" +#include "Engine/Engine/Time.h" RootMotionData RootMotionData::Identity = { Vector3(0.0f), Quaternion(0.0f, 0.0f, 0.0f, 1.0f) }; diff --git a/Source/Engine/Animations/Graph/AnimGraph.h b/Source/Engine/Animations/Graph/AnimGraph.h index 714f6e9b8..3b7aa0030 100644 --- a/Source/Engine/Animations/Graph/AnimGraph.h +++ b/Source/Engine/Animations/Graph/AnimGraph.h @@ -3,9 +3,9 @@ #pragma once #include "Engine/Visject/VisjectGraph.h" -#include "Engine/Content/Assets/SkinnedModel.h" #include "Engine/Content/Assets/Animation.h" #include "Engine/Animations/AlphaBlend.h" +#include "Engine/Core/Math/Matrix.h" #include "../Config.h" #define ANIM_GRAPH_PARAM_BASE_MODEL_ID Guid(1000, 0, 0, 0) @@ -21,6 +21,8 @@ class AnimSubGraph; class AnimGraphBase; class AnimGraphNode; class AnimGraphExecutor; +class SkinnedModel; +class SkeletonData; /// /// The root motion data container. Supports displacement and rotation (no scale component). @@ -777,22 +779,14 @@ public: /// /// Determines whether this graph is ready for the animation evaluation. /// - /// True if is ready and can be used for the animation evaluation, otherwise false. - bool IsReady() const - { - return BaseModel && BaseModel->IsLoaded(); - } + bool IsReady() const; /// /// Determines whether this graph can be used with the specified skeleton. /// /// The other skinned model to check. /// True if can perform the update, otherwise false. - bool CanUseWithSkeleton(SkinnedModel* other) const - { - // All data loaded and bones count the same - return IsReady() && other && other->IsLoaded() && other->Skeleton.Bones.Count() == BaseModel->Skeleton.Bones.Count(); - } + bool CanUseWithSkeleton(SkinnedModel* other) const; private: diff --git a/Source/Engine/Animations/SceneAnimations/SceneAnimation.cpp b/Source/Engine/Animations/SceneAnimations/SceneAnimation.cpp index 1693a8f4d..f669c72c2 100644 --- a/Source/Engine/Animations/SceneAnimations/SceneAnimation.cpp +++ b/Source/Engine/Animations/SceneAnimations/SceneAnimation.cpp @@ -8,7 +8,7 @@ #include "Engine/Audio/AudioClip.h" #include "Engine/Graphics/PostProcessSettings.h" -REGISTER_BINARY_ASSET(SceneAnimation, "FlaxEngine.SceneAnimation", nullptr, false); +REGISTER_BINARY_ASSET(SceneAnimation, "FlaxEngine.SceneAnimation", false); SceneAnimation::SceneAnimation(const SpawnParams& params, const AssetInfo* info) : BinaryAsset(params, info) diff --git a/Source/Engine/Animations/SceneAnimations/SceneAnimationPlayer.cpp b/Source/Engine/Animations/SceneAnimations/SceneAnimationPlayer.cpp index 784eebb28..7d1cf1a78 100644 --- a/Source/Engine/Animations/SceneAnimations/SceneAnimationPlayer.cpp +++ b/Source/Engine/Animations/SceneAnimations/SceneAnimationPlayer.cpp @@ -9,6 +9,7 @@ #include "Engine/Serialization/Serialization.h" #include "Engine/Audio/AudioClip.h" #include "Engine/Audio/AudioSource.h" +#include "Engine/Graphics/RenderTask.h" #include "Engine/Renderer/RenderList.h" #include "Engine/Scripting/Scripting.h" #include "Engine/Scripting/Script.h" diff --git a/Source/Engine/Animations/SceneAnimations/SceneAnimationPlayer.h b/Source/Engine/Animations/SceneAnimations/SceneAnimationPlayer.h index d8934c126..53c311ff6 100644 --- a/Source/Engine/Animations/SceneAnimations/SceneAnimationPlayer.h +++ b/Source/Engine/Animations/SceneAnimations/SceneAnimationPlayer.h @@ -3,6 +3,7 @@ #pragma once #include "Engine/Level/Actor.h" +#include "Engine/Core/Collections/Dictionary.h" #include "Engine/Content/AssetReference.h" #include "Engine/Level/Actors/PostFxVolume.h" #include "SceneAnimation.h" diff --git a/Source/Engine/Audio/AudioClip.cpp b/Source/Engine/Audio/AudioClip.cpp index 29dd2a153..3213850d3 100644 --- a/Source/Engine/Audio/AudioClip.cpp +++ b/Source/Engine/Audio/AudioClip.cpp @@ -4,6 +4,7 @@ #include "Audio.h" #include "AudioSource.h" #include "AudioBackend.h" +#include "Engine/Core/Log.h" #include "Engine/Content/Upgraders/AudioClipUpgrader.h" #include "Engine/Content/Factories/BinaryAssetFactory.h" #include "Engine/Scripting/ManagedCLR/MUtils.h" @@ -12,7 +13,7 @@ #include "Engine/Tools/AudioTool/OggVorbisDecoder.h" #include "Engine/Tools/AudioTool/AudioTool.h" -REGISTER_BINARY_ASSET(AudioClip, "FlaxEngine.AudioClip", ::New(), false); +REGISTER_BINARY_ASSET_WITH_UPGRADER(AudioClip, "FlaxEngine.AudioClip", AudioClipUpgrader, false); bool AudioClip::StreamingTask::Run() { diff --git a/Source/Engine/CSG/CSGBuilder.cpp b/Source/Engine/CSG/CSGBuilder.cpp index b62f2a2f0..ca32862d7 100644 --- a/Source/Engine/CSG/CSGBuilder.cpp +++ b/Source/Engine/CSG/CSGBuilder.cpp @@ -7,6 +7,7 @@ #include "Engine/Level/SceneQuery.h" #include "Engine/Level/Actor.h" #include "Engine/Core/Log.h" +#include "Engine/Core/Types/TimeSpan.h" #include "Engine/Graphics/Models/ModelData.h" #include "Engine/Content/Content.h" #include "Engine/Content/Assets/Model.h" diff --git a/Source/Engine/Content/Assets/Animation.cpp b/Source/Engine/Content/Assets/Animation.cpp index 963ddaceb..d768eabf0 100644 --- a/Source/Engine/Content/Assets/Animation.cpp +++ b/Source/Engine/Content/Assets/Animation.cpp @@ -11,7 +11,7 @@ #include "Engine/Serialization/MemoryWriteStream.h" #endif -REGISTER_BINARY_ASSET(Animation, "FlaxEngine.Animation", nullptr, false); +REGISTER_BINARY_ASSET(Animation, "FlaxEngine.Animation", false); Animation::Animation(const SpawnParams& params, const AssetInfo* info) : BinaryAsset(params, info) diff --git a/Source/Engine/Content/Assets/AnimationGraph.cpp b/Source/Engine/Content/Assets/AnimationGraph.cpp index 2c0a1c803..078a7a305 100644 --- a/Source/Engine/Content/Assets/AnimationGraph.cpp +++ b/Source/Engine/Content/Assets/AnimationGraph.cpp @@ -9,7 +9,7 @@ #include "Engine/Serialization/MemoryReadStream.h" #include "Engine/Content/Factories/BinaryAssetFactory.h" -REGISTER_BINARY_ASSET(AnimationGraph, "FlaxEngine.AnimationGraph", nullptr, false); +REGISTER_BINARY_ASSET(AnimationGraph, "FlaxEngine.AnimationGraph", false); AnimationGraph::AnimationGraph(const SpawnParams& params, const AssetInfo* info) : BinaryAsset(params, info) diff --git a/Source/Engine/Content/Assets/AnimationGraphFunction.cpp b/Source/Engine/Content/Assets/AnimationGraphFunction.cpp index 7674d93bc..69e611cd4 100644 --- a/Source/Engine/Content/Assets/AnimationGraphFunction.cpp +++ b/Source/Engine/Content/Assets/AnimationGraphFunction.cpp @@ -6,7 +6,7 @@ #include "Engine/Serialization/MemoryReadStream.h" #include "Engine/Content/Factories/BinaryAssetFactory.h" -REGISTER_BINARY_ASSET(AnimationGraphFunction, "FlaxEngine.AnimationGraphFunction", nullptr, false); +REGISTER_BINARY_ASSET(AnimationGraphFunction, "FlaxEngine.AnimationGraphFunction", false); AnimationGraphFunction::AnimationGraphFunction(const SpawnParams& params, const AssetInfo* info) : BinaryAsset(params, info) diff --git a/Source/Engine/Content/Assets/CubeTexture.cpp b/Source/Engine/Content/Assets/CubeTexture.cpp index 084955a88..1b9095cab 100644 --- a/Source/Engine/Content/Assets/CubeTexture.cpp +++ b/Source/Engine/Content/Assets/CubeTexture.cpp @@ -4,7 +4,7 @@ #include "Engine/Content/Factories/BinaryAssetFactory.h" #include "Engine/Content/Upgraders/TextureAssetUpgrader.h" -REGISTER_BINARY_ASSET(CubeTexture, "FlaxEngine.CubeTexture", ::New(), true); +REGISTER_BINARY_ASSET_WITH_UPGRADER(CubeTexture, "FlaxEngine.CubeTexture", TextureAssetUpgrader, true); CubeTexture::CubeTexture(const SpawnParams& params, const AssetInfo* info) : TextureBase(params, info) diff --git a/Source/Engine/Content/Assets/IESProfile.cpp b/Source/Engine/Content/Assets/IESProfile.cpp index 34f0c59c1..1c1d340be 100644 --- a/Source/Engine/Content/Assets/IESProfile.cpp +++ b/Source/Engine/Content/Assets/IESProfile.cpp @@ -4,7 +4,7 @@ #include "Engine/Content/Factories/BinaryAssetFactory.h" #include "Engine/Content/Upgraders/TextureAssetUpgrader.h" -REGISTER_BINARY_ASSET(IESProfile, "FlaxEngine.IESProfile", ::New(), false); +REGISTER_BINARY_ASSET_WITH_UPGRADER(IESProfile, "FlaxEngine.IESProfile", TextureAssetUpgrader, false); IESProfile::IESProfile(const SpawnParams& params, const AssetInfo* info) : TextureBase(params, info) diff --git a/Source/Engine/Content/Assets/Material.cpp b/Source/Engine/Content/Assets/Material.cpp index 4d1e5d283..1f97c6f08 100644 --- a/Source/Engine/Content/Assets/Material.cpp +++ b/Source/Engine/Content/Assets/Material.cpp @@ -16,6 +16,9 @@ #include "Engine/Utilities/Encryption.h" #include "Engine/Tools/MaterialGenerator/MaterialGenerator.h" #include "Engine/ShadersCompilation/Config.h" +#if BUILD_DEBUG +#include "Engine/Engine/Globals.h" +#endif #endif /// @@ -23,7 +26,7 @@ /// #define MATERIAL_AUTO_GENERATE_MISSING_SOURCE (USE_EDITOR) -REGISTER_BINARY_ASSET(Material, "FlaxEngine.Material", ::New(), false); +REGISTER_BINARY_ASSET_WITH_UPGRADER(Material, "FlaxEngine.Material", ShaderAssetUpgrader, false); Material::Material(const SpawnParams& params, const AssetInfo* info) : ShaderAssetTypeBase(params, info) @@ -116,7 +119,7 @@ Asset::LoadResult Material::load() FlaxChunk* materialParamsChunk; // Special case for Null renderer - if (GPUDevice::Instance->GetRendererType() == RendererType::Null) + if (IsNullRenderer()) { // Hack loading MemoryReadStream shaderCacheStream(nullptr, 0); @@ -152,18 +155,16 @@ Asset::LoadResult Material::load() // - If material version is not supported then material cannot be loaded #if COMPILE_WITH_SHADER_COMPILER -#if BUILD_DEBUG - // Materials force reload! - Globals::ConvertLoadedMaterialsByForce = false; -#endif - // Check if current engine has different materials version or convert it by force or has no source generated at all if (_shaderHeader.Material.GraphVersion != MATERIAL_GRAPH_VERSION - || Globals::ConvertLoadedMaterialsByForce #if MATERIAL_AUTO_GENERATE_MISSING_SOURCE || !HasChunk(SHADER_FILE_CHUNK_SOURCE) #endif || HasDependenciesModified() +#if COMPILE_WITH_DEV_ENV + // Set to true to enable force GPU shader regeneration (don't commit it) + || false +#endif ) { // Prepare diff --git a/Source/Engine/Content/Assets/MaterialFunction.cpp b/Source/Engine/Content/Assets/MaterialFunction.cpp index 97af31960..ca3cc58fb 100644 --- a/Source/Engine/Content/Assets/MaterialFunction.cpp +++ b/Source/Engine/Content/Assets/MaterialFunction.cpp @@ -8,7 +8,7 @@ #endif #include "Engine/Content/Factories/BinaryAssetFactory.h" -REGISTER_BINARY_ASSET(MaterialFunction, "FlaxEngine.MaterialFunction", nullptr, false); +REGISTER_BINARY_ASSET(MaterialFunction, "FlaxEngine.MaterialFunction", false); MaterialFunction::MaterialFunction(const SpawnParams& params, const AssetInfo* info) : BinaryAsset(params, info) diff --git a/Source/Engine/Content/Assets/MaterialInstance.cpp b/Source/Engine/Content/Assets/MaterialInstance.cpp index 874f607ce..5ea8c9351 100644 --- a/Source/Engine/Content/Assets/MaterialInstance.cpp +++ b/Source/Engine/Content/Assets/MaterialInstance.cpp @@ -7,7 +7,7 @@ #include "Engine/Content/Factories/BinaryAssetFactory.h" #include "Engine/Serialization/MemoryReadStream.h" -REGISTER_BINARY_ASSET(MaterialInstance, "FlaxEngine.MaterialInstance", ::New(), true); +REGISTER_BINARY_ASSET_WITH_UPGRADER(MaterialInstance, "FlaxEngine.MaterialInstance", MaterialInstanceUpgrader, true); MaterialInstance::MaterialInstance(const SpawnParams& params, const AssetInfo* info) : MaterialBase(params, info) diff --git a/Source/Engine/Content/Assets/Model.cpp b/Source/Engine/Content/Assets/Model.cpp index d6e8f1809..b05dece38 100644 --- a/Source/Engine/Content/Assets/Model.cpp +++ b/Source/Engine/Content/Assets/Model.cpp @@ -8,9 +8,11 @@ #include "Engine/Content/Upgraders/ModelAssetUpgrader.h" #include "Engine/Content/Factories/BinaryAssetFactory.h" #include "Engine/Graphics/RenderTools.h" +#include "Engine/Graphics/RenderTask.h" #include "Engine/Graphics/Models/ModelInstanceEntry.h" #include "Engine/Streaming/StreamingGroup.h" #include "Engine/Debug/Exceptions/ArgumentOutOfRangeException.h" +#include "Engine/Renderer/DrawCall.h" #if GPU_ENABLE_ASYNC_RESOURCES_CREATION #include "Engine/Threading/ThreadPoolTask.h" #define STREAM_TASK_BASE ThreadPoolTask @@ -113,7 +115,7 @@ protected: } }; -REGISTER_BINARY_ASSET(Model, "FlaxEngine.Model", ::New(), true); +REGISTER_BINARY_ASSET_WITH_UPGRADER(Model, "FlaxEngine.Model", ModelAssetUpgrader, true); Model::Model(const SpawnParams& params, const AssetInfo* info) : ModelBase(params, info, StreamingGroups::Instance()->Models()) diff --git a/Source/Engine/Content/Assets/RawDataAsset.cpp b/Source/Engine/Content/Assets/RawDataAsset.cpp index f93395579..98b9e3251 100644 --- a/Source/Engine/Content/Assets/RawDataAsset.cpp +++ b/Source/Engine/Content/Assets/RawDataAsset.cpp @@ -4,7 +4,7 @@ #include "Engine/Content/Factories/BinaryAssetFactory.h" #include "Engine/Platform/FileSystem.h" -REGISTER_BINARY_ASSET(RawDataAsset, "FlaxEngine.RawDataAsset", nullptr, true); +REGISTER_BINARY_ASSET(RawDataAsset, "FlaxEngine.RawDataAsset", true); RawDataAsset::RawDataAsset(const SpawnParams& params, const AssetInfo* info) : BinaryAsset(params, info) diff --git a/Source/Engine/Content/Assets/Shader.cpp b/Source/Engine/Content/Assets/Shader.cpp index 929abc933..3f54eadbf 100644 --- a/Source/Engine/Content/Assets/Shader.cpp +++ b/Source/Engine/Content/Assets/Shader.cpp @@ -2,11 +2,13 @@ #include "Shader.h" #include "Engine/Core/Log.h" +#include "Engine/Graphics/GPUDevice.h" +#include "Engine/Graphics/Shaders/GPUShader.h" #include "Engine/Content/Upgraders/ShaderAssetUpgrader.h" #include "Engine/Content/Factories/BinaryAssetFactory.h" #include "Engine/Serialization/MemoryReadStream.h" -REGISTER_BINARY_ASSET(Shader, "FlaxEngine.Shader", ::New(), false); +REGISTER_BINARY_ASSET_WITH_UPGRADER(Shader, "FlaxEngine.Shader", ShaderAssetUpgrader, false); Shader::Shader(const SpawnParams& params, const AssetInfo* info) : ShaderAssetTypeBase(params, info) @@ -25,7 +27,7 @@ Shader::~Shader() Asset::LoadResult Shader::load() { // Special case for Null renderer that doesn't need shaders - if (GPUDevice::Instance->GetRendererType() == RendererType::Null) + if (IsNullRenderer()) { return LoadResult::Ok; } diff --git a/Source/Engine/Content/Assets/Shader.h b/Source/Engine/Content/Assets/Shader.h index b97aafd98..9efdf8d6d 100644 --- a/Source/Engine/Content/Assets/Shader.h +++ b/Source/Engine/Content/Assets/Shader.h @@ -3,9 +3,10 @@ #pragma once #include "../BinaryAsset.h" -#include "Engine/Graphics/Shaders/GPUShader.h" #include "Engine/Graphics/Shaders/Cache/ShaderAssetBase.h" +class GPUShader; + /// /// The shader asset. Contains a program that runs on the GPU and is able to perform rendering calculation using textures, vertices and other resources. /// @@ -33,7 +34,6 @@ public: /// /// Gets the GPU shader object. /// - /// The GPU shader object. FORCE_INLINE GPUShader* GetShader() const { return GPU; diff --git a/Source/Engine/Content/Assets/SkeletonMask.cpp b/Source/Engine/Content/Assets/SkeletonMask.cpp index 0742e2951..27529df4d 100644 --- a/Source/Engine/Content/Assets/SkeletonMask.cpp +++ b/Source/Engine/Content/Assets/SkeletonMask.cpp @@ -7,7 +7,7 @@ #include "Engine/Content/Factories/BinaryAssetFactory.h" #include "Engine/Content/Upgraders/SkeletonMaskUpgrader.h" -REGISTER_BINARY_ASSET(SkeletonMask, "FlaxEngine.SkeletonMask", ::New(), true); +REGISTER_BINARY_ASSET_WITH_UPGRADER(SkeletonMask, "FlaxEngine.SkeletonMask", SkeletonMaskUpgrader, true); SkeletonMask::SkeletonMask(const SpawnParams& params, const AssetInfo* info) : BinaryAsset(params, info) diff --git a/Source/Engine/Content/Assets/SkinnedModel.cpp b/Source/Engine/Content/Assets/SkinnedModel.cpp index 7c498b8e8..b98ba2e57 100644 --- a/Source/Engine/Content/Assets/SkinnedModel.cpp +++ b/Source/Engine/Content/Assets/SkinnedModel.cpp @@ -7,12 +7,14 @@ #include "Engine/Streaming/StreamingGroup.h" #include "Engine/Threading/ThreadPoolTask.h" #include "Engine/Graphics/RenderTools.h" +#include "Engine/Graphics/RenderTask.h" #include "Engine/Graphics/Models/ModelInstanceEntry.h" #include "Engine/Graphics/Models/Config.h" #include "Engine/Content/WeakAssetReference.h" #include "Engine/Content/Factories/BinaryAssetFactory.h" #include "Engine/Content/Upgraders/SkinnedModelAssetUpgrader.h" #include "Engine/Debug/Exceptions/ArgumentOutOfRangeException.h" +#include "Engine/Renderer/DrawCall.h" #define CHECK_INVALID_BUFFER(buffer) \ if (buffer->IsValidFor(this) == false) \ @@ -106,7 +108,7 @@ protected: } }; -REGISTER_BINARY_ASSET(SkinnedModel, "FlaxEngine.SkinnedModel", ::New(), true); +REGISTER_BINARY_ASSET_WITH_UPGRADER(SkinnedModel, "FlaxEngine.SkinnedModel", SkinnedModelAssetUpgrader, true); SkinnedModel::SkinnedModel(const SpawnParams& params, const AssetInfo* info) : ModelBase(params, info, StreamingGroups::Instance()->SkinnedModels()) @@ -120,6 +122,11 @@ SkinnedModel::~SkinnedModel() ASSERT(_streamingTask == nullptr); } +bool SkinnedModel::HasAnyLODInitialized() const +{ + return LODs.HasItems() && LODs.Last().HasAnyMeshInitialized(); +} + Array SkinnedModel::GetBlendShapes() { Array result; diff --git a/Source/Engine/Content/Assets/SkinnedModel.h b/Source/Engine/Content/Assets/SkinnedModel.h index 0dabcef05..d2d6eba96 100644 --- a/Source/Engine/Content/Assets/SkinnedModel.h +++ b/Source/Engine/Content/Assets/SkinnedModel.h @@ -103,10 +103,7 @@ public: /// Determines whether any LOD has been initialized. /// /// True if any LOD has been initialized, otherwise false. - FORCE_INLINE bool HasAnyLODInitialized() const - { - return LODs.HasItems() && LODs.Last().HasAnyMeshInitialized(); - } + bool HasAnyLODInitialized() const; /// /// Determines whether this model can be rendered. diff --git a/Source/Engine/Content/Assets/Texture.cpp b/Source/Engine/Content/Assets/Texture.cpp index 22c86028a..23dbff0e2 100644 --- a/Source/Engine/Content/Assets/Texture.cpp +++ b/Source/Engine/Content/Assets/Texture.cpp @@ -10,7 +10,7 @@ #include "Engine/Scripting/MainThreadManagedInvokeAction.h" #include "Engine/Tools/TextureTool/TextureTool.h" -REGISTER_BINARY_ASSET(Texture, "FlaxEngine.Texture", ::New(), true); +REGISTER_BINARY_ASSET_WITH_UPGRADER(Texture, "FlaxEngine.Texture", TextureAssetUpgrader, true); Texture::Texture(const SpawnParams& params, const AssetInfo* info) : TextureBase(params, info) diff --git a/Source/Engine/Content/Assets/VisualScript.cpp b/Source/Engine/Content/Assets/VisualScript.cpp index 5fd9d6f3f..6667f973d 100644 --- a/Source/Engine/Content/Assets/VisualScript.cpp +++ b/Source/Engine/Content/Assets/VisualScript.cpp @@ -1276,7 +1276,7 @@ void VisualScriptExecutor::ProcessGroupFlow(Box* boxBase, Node* node, Value& val } } -REGISTER_BINARY_ASSET(VisualScript, "FlaxEngine.VisualScript", nullptr, false); +REGISTER_BINARY_ASSET(VisualScript, "FlaxEngine.VisualScript", false); VisualScript::VisualScript(const SpawnParams& params, const AssetInfo* info) : BinaryAsset(params, info) diff --git a/Source/Engine/Content/BinaryAsset.cpp b/Source/Engine/Content/BinaryAsset.cpp index baa065698..79ad9f8dc 100644 --- a/Source/Engine/Content/BinaryAsset.cpp +++ b/Source/Engine/Content/BinaryAsset.cpp @@ -132,6 +132,13 @@ void BinaryAsset::GetImportMetadata(String& path, String& username) const } } +String BinaryAsset::GetImportPath() const +{ + String path, username; + GetImportMetadata(path, username); + return path; +} + void BinaryAsset::ClearDependencies() { for (auto& e : Dependencies) @@ -492,7 +499,6 @@ protected: return Result::Ok; } - void OnEnd() override { _dataLock.Release(); diff --git a/Source/Engine/Content/BinaryAsset.h b/Source/Engine/Content/BinaryAsset.h index c533399d2..f73c7ec6e 100644 --- a/Source/Engine/Content/BinaryAsset.h +++ b/Source/Engine/Content/BinaryAsset.h @@ -109,13 +109,7 @@ public: /// /// Gets the imported file path from the asset metadata (can be empty if not available). /// - /// The imported source file path. - API_PROPERTY() String GetImportPath() const - { - String path, username; - GetImportMetadata(path, username); - return path; - } + API_PROPERTY() String GetImportPath() const; /// /// Clears the asset dependencies list and unregisters from tracking their changes. @@ -131,7 +125,6 @@ public: /// /// Determines whether any of the dependency assets was modified after last modification time of this asset (last file write time check). /// - /// true if one or more dependencies were modified; otherwise, false. bool HasDependenciesModified() const; protected: diff --git a/Source/Engine/Content/Cache/AssetsCache.cpp b/Source/Engine/Content/Cache/AssetsCache.cpp index f8d3433ed..42a61c2a3 100644 --- a/Source/Engine/Content/Cache/AssetsCache.cpp +++ b/Source/Engine/Content/Cache/AssetsCache.cpp @@ -3,6 +3,7 @@ #include "AssetsCache.h" #include "Engine/Core/Log.h" #include "Engine/Core/DeleteMe.h" +#include "Engine/Core/Types/TimeSpan.h" #include "Engine/Platform/FileSystem.h" #include "Engine/Serialization/FileWriteStream.h" #include "Engine/Serialization/FileReadStream.h" @@ -10,6 +11,7 @@ #include "Engine/Content/Storage/ContentStorageManager.h" #include "Engine/Content/Storage/JsonStorageProxy.h" #include "Engine/Profiler/ProfilerCPU.h" +#include "Engine/Engine/Globals.h" #include "FlaxEngine.Gen.h" AssetsCache::AssetsCache() @@ -402,6 +404,16 @@ void AssetsCache::RegisterAssets(FlaxStorage* storage) _isDirty = true; } +void AssetsCache::RegisterAsset(const AssetHeader& header, const StringView& path) +{ + RegisterAsset(header.ID, header.TypeName, path); +} + +void AssetsCache::RegisterAssets(const FlaxStorageReference& storage) +{ + RegisterAssets(storage.Get()); +} + void AssetsCache::RegisterAsset(const Guid& id, const String& typeName, const StringView& path) { PROFILE_CPU(); diff --git a/Source/Engine/Content/Cache/AssetsCache.h b/Source/Engine/Content/Cache/AssetsCache.h index 3186b3cfc..f81fc920d 100644 --- a/Source/Engine/Content/Cache/AssetsCache.h +++ b/Source/Engine/Content/Cache/AssetsCache.h @@ -2,13 +2,19 @@ #pragma once +#include "../AssetInfo.h" +#include "../Config.h" #include "Engine/Core/Types/Guid.h" +#if ENABLE_ASSETS_DISCOVERY +#include "Engine/Core/Types/DateTime.h" +#endif #include "Engine/Core/Types/String.h" #include "Engine/Core/Collections/Dictionary.h" #include "Engine/Platform/CriticalSection.h" -#include "Engine/Content/Storage/FlaxStorageReference.h" -#include "../AssetInfo.h" -#include "../Config.h" + +struct AssetHeader; +struct FlaxStorageReference; +class FlaxStorage; /// /// Assets cache flags. @@ -46,19 +52,17 @@ public: AssetInfo Info; #if ENABLE_ASSETS_DISCOVERY - /// /// The file modified date. /// DateTime FileModified; - #endif Entry() { } - Entry(const Guid& id, const String& typeName, const StringView& path) + Entry(const Guid& id, const StringView& typeName, const StringView& path) : Info(id, typeName, path) #if ENABLE_ASSETS_DISCOVERY , FileModified(DateTime::NowUTC()) @@ -167,16 +171,13 @@ public: /// /// The asset typename. /// The result array. - void GetAllByTypeName(const StringView& typeName, Array& result) const; + void GetAllByTypeName(const StringView& typeName, Array& result) const; /// /// Register assets in the cache /// /// Flax assets container reference - FORCE_INLINE void RegisterAssets(const FlaxStorageReference& storage) - { - RegisterAssets(storage.Get()); - } + void RegisterAssets(const FlaxStorageReference& storage); /// /// Register assets in the cache @@ -189,10 +190,7 @@ public: /// /// Flax asset file header /// Asset path - FORCE_INLINE void RegisterAsset(const AssetHeader& header, const StringView& path) - { - RegisterAsset(header.ID, header.TypeName, path); - } + void RegisterAsset(const AssetHeader& header, const StringView& path); /// /// Register asset in the cache diff --git a/Source/Engine/Content/Content.cpp b/Source/Engine/Content/Content.cpp index 493147355..0b3f9a1d7 100644 --- a/Source/Engine/Content/Content.cpp +++ b/Source/Engine/Content/Content.cpp @@ -14,6 +14,7 @@ #include "Engine/Threading/Threading.h" #include "Engine/Graphics/Graphics.h" #include "Engine/Engine/Time.h" +#include "Engine/Engine/Globals.h" #include "Engine/Level/Types.h" #include "Engine/Profiler/ProfilerCPU.h" #include "Engine/Scripting/ManagedCLR/MClass.h" diff --git a/Source/Engine/Content/Factories/BinaryAssetFactory.cpp b/Source/Engine/Content/Factories/BinaryAssetFactory.cpp index c3c4e8178..9dedd92f9 100644 --- a/Source/Engine/Content/Factories/BinaryAssetFactory.cpp +++ b/Source/Engine/Content/Factories/BinaryAssetFactory.cpp @@ -4,6 +4,7 @@ #include "../BinaryAsset.h" #include "Engine/Core/Log.h" #include "Engine/Core/Math/Math.h" +#include "Engine/Core/Types/TimeSpan.h" #include "Engine/Platform/FileSystem.h" #include "Engine/Content/Storage/ContentStorageManager.h" #if USE_EDITOR @@ -30,7 +31,7 @@ bool BinaryAssetFactoryBase::Init(BinaryAsset* asset) return true; } -#if COMPILE_WITH_ASSET_UPGRADERS +#if USE_EDITOR // Check if need to perform data conversion to the newer version (only in Editor) const auto upgrader = GetUpgrader(); if (storage->AllowDataModifications() && upgrader && upgrader->ShouldUpgrade(initData.SerializedVersion)) @@ -113,7 +114,7 @@ bool BinaryAssetFactoryBase::Init(BinaryAsset* asset) return false; } -#if COMPILE_WITH_ASSET_UPGRADERS +#if USE_EDITOR bool BinaryAssetFactoryBase::UpgradeAsset(const AssetInfo& info, FlaxStorage* storage, AssetMigrationContext& context) { diff --git a/Source/Engine/Content/Factories/BinaryAssetFactory.h b/Source/Engine/Content/Factories/BinaryAssetFactory.h index d2af137b6..1040ea3c5 100644 --- a/Source/Engine/Content/Factories/BinaryAssetFactory.h +++ b/Source/Engine/Content/Factories/BinaryAssetFactory.h @@ -3,7 +3,9 @@ #pragma once #include "IAssetFactory.h" +#if USE_EDITOR #include "Engine/Content/Upgraders/BinaryAssetUpgrader.h" +#endif #include "Engine/Content/AssetInfo.h" #include "Engine/Scripting/ScriptingObject.h" @@ -29,7 +31,7 @@ protected: virtual BinaryAsset* Create(const AssetInfo& info) = 0; virtual bool IsVersionSupported(uint32 serializedVersion) const = 0; -#if COMPILE_WITH_ASSET_UPGRADERS +#if USE_EDITOR bool UpgradeAsset(const AssetInfo& info, FlaxStorage* storage, AssetMigrationContext& context); #endif @@ -65,16 +67,31 @@ protected: } }; -#define REGISTER_BINARY_ASSET(type, typeName, upgrader, supportsVirtualAssets) \ +#define REGISTER_BINARY_ASSET(type, typeName, supportsVirtualAssets) \ + const String type::TypeName = TEXT(typeName); \ + class CONCAT_MACROS(Factory, type) : public BinaryAssetFactory \ + { \ + public: \ + CONCAT_MACROS(Factory, type)() { IAssetFactory::Get().Add(type::TypeName, this); } \ + ~CONCAT_MACROS(Factory, type)() { IAssetFactory::Get().Remove(type::TypeName); } \ + bool SupportsVirtualAssets() const override { return supportsVirtualAssets; } \ + }; \ + static CONCAT_MACROS(Factory, type) CONCAT_MACROS(CFactory, type) + +#if USE_EDITOR +#define REGISTER_BINARY_ASSET_WITH_UPGRADER(type, typeName, upgrader, supportsVirtualAssets) \ const String type::TypeName = TEXT(typeName); \ class CONCAT_MACROS(Factory, type) : public BinaryAssetFactory \ { \ private: \ - IAssetUpgrader* _upgrader = upgrader; \ + IAssetUpgrader* _upgrader = ::New(); \ public: \ CONCAT_MACROS(Factory, type)() { IAssetFactory::Get().Add(type::TypeName, this); } \ - ~CONCAT_MACROS(Factory, type)() { if (_upgrader) Delete(_upgrader); IAssetFactory::Get().Remove(type::TypeName); } \ + ~CONCAT_MACROS(Factory, type)() { Delete(_upgrader); IAssetFactory::Get().Remove(type::TypeName); } \ bool SupportsVirtualAssets() const override { return supportsVirtualAssets; } \ IAssetUpgrader* GetUpgrader() const override { return _upgrader; } \ }; \ static CONCAT_MACROS(Factory, type) CONCAT_MACROS(CFactory, type) +#else +#define REGISTER_BINARY_ASSET_WITH_UPGRADER(type, typeName, upgrader, supportsVirtualAssets) REGISTER_BINARY_ASSET(type, typeName, supportsVirtualAssets) +#endif diff --git a/Source/Engine/Content/Factories/IAssetFactory.h b/Source/Engine/Content/Factories/IAssetFactory.h index b72f8e8e2..a4f5681b4 100644 --- a/Source/Engine/Content/Factories/IAssetFactory.h +++ b/Source/Engine/Content/Factories/IAssetFactory.h @@ -9,9 +9,6 @@ struct AssetInfo; class Asset; class IAssetUpgrader; -// Enables upgrading asset files from the older version format -#define COMPILE_WITH_ASSET_UPGRADERS (USE_EDITOR) - /// /// The asset objects factory. /// diff --git a/Source/Engine/Content/Storage/AssetHeader.h b/Source/Engine/Content/Storage/AssetHeader.h index 19609fd2c..03d8c6028 100644 --- a/Source/Engine/Content/Storage/AssetHeader.h +++ b/Source/Engine/Content/Storage/AssetHeader.h @@ -5,7 +5,9 @@ #include "Engine/Core/Types/Guid.h" #include "Engine/Core/Types/Pair.h" #include "Engine/Core/Types/String.h" -#include "Engine/Core/Types/DataContainer.h" +#if USE_EDITOR +#include "Engine/Core/Collections/Array.h" +#endif #include "FlaxChunk.h" /// @@ -54,7 +56,8 @@ public: /// Gets the chunks. /// /// The output data. - void GetChunks(Array& output) const + template + void GetChunks(Array& output) const { for (int32 i = 0; i < ASSET_FILE_DATA_CHUNKS; i++) { @@ -67,7 +70,8 @@ public: /// Gets the chunks that are loaded. /// /// The output data. - void GetLoadedChunks(Array& output) const + template + void GetLoadedChunks(Array& output) const { for (int32 i = 0; i < ASSET_FILE_DATA_CHUNKS; i++) { @@ -130,7 +134,7 @@ struct FLAXENGINE_API AssetInitData /// /// The serialized asset version /// - uint32 SerializedVersion; + uint32 SerializedVersion = 0; /// /// The custom asset data (should be small, for eg. texture description structure). @@ -138,7 +142,6 @@ struct FLAXENGINE_API AssetInitData BytesContainer CustomData; #if USE_EDITOR - /// /// The asset metadata information. Stored in a Json format. /// @@ -148,24 +151,16 @@ struct FLAXENGINE_API AssetInitData /// Asset dependencies list used by the asset for tracking (eg. material functions used by material asset). The pair of asset ID and cached file edit time (for tracking modification). /// Array> Dependencies; - #endif public: - AssetInitData() - : SerializedVersion(0) - { - } - /// /// Gets the hash code. /// - /// Hash Code uint32 GetHashCode() const { // Note: do not use Metadata/Dependencies because it may not be loaded (it's optional) - uint32 hashCode = GetHash(Header.ID); hashCode = (hashCode * 397) ^ SerializedVersion; hashCode = (hashCode * 397) ^ CustomData.Length(); diff --git a/Source/Engine/Content/Storage/ContentStorageManager.h b/Source/Engine/Content/Storage/ContentStorageManager.h index 2d7ce5fd7..e18ead571 100644 --- a/Source/Engine/Content/Storage/ContentStorageManager.h +++ b/Source/Engine/Content/Storage/ContentStorageManager.h @@ -3,6 +3,7 @@ #pragma once #include "FlaxStorageReference.h" +#include "Engine/Core/Types/TimeSpan.h" class FlaxFile; class FlaxPackage; diff --git a/Source/Engine/Content/Storage/FlaxStorage.cpp b/Source/Engine/Content/Storage/FlaxStorage.cpp index 1a3d5c6b0..bc2cfd332 100644 --- a/Source/Engine/Content/Storage/FlaxStorage.cpp +++ b/Source/Engine/Content/Storage/FlaxStorage.cpp @@ -5,10 +5,15 @@ #include "FlaxPackage.h" #include "ContentStorageManager.h" #include "Engine/Core/Log.h" +#include "Engine/Core/Types/TimeSpan.h" #include "Engine/Platform/File.h" #include "Engine/Serialization/FileWriteStream.h" +#if USE_EDITOR #include "Engine/Serialization/JsonWriter.h" #include "Engine/Serialization/JsonWriters.h" +#else +#include "Engine/Engine/Globals.h" +#endif #include String AssetHeader::ToString() const diff --git a/Source/Engine/Content/Storage/FlaxStorageReference.h b/Source/Engine/Content/Storage/FlaxStorageReference.h index d690227ae..7297bc779 100644 --- a/Source/Engine/Content/Storage/FlaxStorageReference.h +++ b/Source/Engine/Content/Storage/FlaxStorageReference.h @@ -5,7 +5,7 @@ #include "FlaxStorage.h" /// -/// Flax Storage Container Reference +/// Flax Storage container reference. /// struct FLAXENGINE_API FlaxStorageReference { @@ -44,10 +44,8 @@ public: public: - // Assignment operator FlaxStorageReference& operator=(const FlaxStorageReference& other) { - // Protect against invalid self-assignment if (this != &other) { if (_storage) @@ -56,7 +54,6 @@ public: if (_storage) _storage->AddRef(); } - return *this; } diff --git a/Source/Engine/Content/Upgraders/AudioClipUpgrader.h b/Source/Engine/Content/Upgraders/AudioClipUpgrader.h index 5e2555958..ee0d131b7 100644 --- a/Source/Engine/Content/Upgraders/AudioClipUpgrader.h +++ b/Source/Engine/Content/Upgraders/AudioClipUpgrader.h @@ -2,6 +2,8 @@ #pragma once +#if USE_EDITOR + #include "BinaryAssetUpgrader.h" #include "Engine/Audio/AudioClip.h" #include "Engine/Tools/AudioTool/OggVorbisDecoder.h" @@ -130,3 +132,5 @@ private: return false; } }; + +#endif diff --git a/Source/Engine/Content/Upgraders/BinaryAssetUpgrader.h b/Source/Engine/Content/Upgraders/BinaryAssetUpgrader.h index c97d9d53c..551c4e1e7 100644 --- a/Source/Engine/Content/Upgraders/BinaryAssetUpgrader.h +++ b/Source/Engine/Content/Upgraders/BinaryAssetUpgrader.h @@ -2,6 +2,8 @@ #pragma once +#if USE_EDITOR + #include "IAssetUpgrader.h" #include "Engine/Content/Storage/AssetHeader.h" #include "Engine/Core/Log.h" @@ -205,3 +207,5 @@ public: return false; } }; + +#endif diff --git a/Source/Engine/Content/Upgraders/FontAssetUpgrader.h b/Source/Engine/Content/Upgraders/FontAssetUpgrader.h index cb26fa8d2..8be02b973 100644 --- a/Source/Engine/Content/Upgraders/FontAssetUpgrader.h +++ b/Source/Engine/Content/Upgraders/FontAssetUpgrader.h @@ -2,6 +2,8 @@ #pragma once +#if USE_EDITOR + #include "BinaryAssetUpgrader.h" #include "Engine/Render2D/FontAsset.h" @@ -71,3 +73,5 @@ private: return CopyChunk(context, 0); } }; + +#endif diff --git a/Source/Engine/Content/Upgraders/IAssetUpgrader.h b/Source/Engine/Content/Upgraders/IAssetUpgrader.h index bc174859d..edff613e7 100644 --- a/Source/Engine/Content/Upgraders/IAssetUpgrader.h +++ b/Source/Engine/Content/Upgraders/IAssetUpgrader.h @@ -2,6 +2,8 @@ #pragma once +#if USE_EDITOR + #include "Engine/Core/Types/BaseTypes.h" /// @@ -27,3 +29,5 @@ public: /// True if perform conversion, otherwise false. virtual bool ShouldUpgrade(uint32 serializedVersion) const = 0; }; + +#endif diff --git a/Source/Engine/Content/Upgraders/MaterialInstanceUpgrader.h b/Source/Engine/Content/Upgraders/MaterialInstanceUpgrader.h index 31caeb230..6fd5093f5 100644 --- a/Source/Engine/Content/Upgraders/MaterialInstanceUpgrader.h +++ b/Source/Engine/Content/Upgraders/MaterialInstanceUpgrader.h @@ -2,6 +2,8 @@ #pragma once +#if USE_EDITOR + #include "BinaryAssetUpgrader.h" #include "Engine/Core/Core.h" #include "Engine/Platform/Platform.h" @@ -105,3 +107,5 @@ private: return false; } }; + +#endif diff --git a/Source/Engine/Content/Upgraders/ModelAssetUpgrader.h b/Source/Engine/Content/Upgraders/ModelAssetUpgrader.h index 98bc630cb..b09d1c280 100644 --- a/Source/Engine/Content/Upgraders/ModelAssetUpgrader.h +++ b/Source/Engine/Content/Upgraders/ModelAssetUpgrader.h @@ -2,6 +2,8 @@ #pragma once +#if USE_EDITOR + #include "BinaryAssetUpgrader.h" #include "Engine/Core/Core.h" #include "Engine/Platform/Platform.h" @@ -1223,3 +1225,5 @@ private: return false; } }; + +#endif diff --git a/Source/Engine/Content/Upgraders/ShaderAssetUpgrader.h b/Source/Engine/Content/Upgraders/ShaderAssetUpgrader.h index d85079304..eb84649ad 100644 --- a/Source/Engine/Content/Upgraders/ShaderAssetUpgrader.h +++ b/Source/Engine/Content/Upgraders/ShaderAssetUpgrader.h @@ -2,6 +2,8 @@ #pragma once +#if USE_EDITOR + #include "BinaryAssetUpgrader.h" #include "Engine/Platform/Platform.h" #include "Engine/Graphics/Shaders/Cache/ShaderStorage.h" @@ -86,3 +88,5 @@ private: return CopyChunks(context); } }; + +#endif diff --git a/Source/Engine/Content/Upgraders/SkeletonMaskUpgrader.h b/Source/Engine/Content/Upgraders/SkeletonMaskUpgrader.h index 5058aed68..431c71014 100644 --- a/Source/Engine/Content/Upgraders/SkeletonMaskUpgrader.h +++ b/Source/Engine/Content/Upgraders/SkeletonMaskUpgrader.h @@ -2,6 +2,8 @@ #pragma once +#if USE_EDITOR + #include "BinaryAssetUpgrader.h" #include "Engine/Content/Assets/SkinnedModel.h" #include "Engine/Serialization/MemoryReadStream.h" @@ -97,3 +99,5 @@ private: return false; } }; + +#endif diff --git a/Source/Engine/Content/Upgraders/SkinnedModelAssetUpgrader.h b/Source/Engine/Content/Upgraders/SkinnedModelAssetUpgrader.h index ef0a21b6d..c026daebe 100644 --- a/Source/Engine/Content/Upgraders/SkinnedModelAssetUpgrader.h +++ b/Source/Engine/Content/Upgraders/SkinnedModelAssetUpgrader.h @@ -2,6 +2,8 @@ #pragma once +#if USE_EDITOR + #include "BinaryAssetUpgrader.h" #include "Engine/Platform/Platform.h" #include "Engine/Serialization/MemoryReadStream.h" @@ -423,3 +425,5 @@ private: return false; } }; + +#endif diff --git a/Source/Engine/Content/Upgraders/TextureAssetUpgrader.h b/Source/Engine/Content/Upgraders/TextureAssetUpgrader.h index e1d75dba5..a598538f9 100644 --- a/Source/Engine/Content/Upgraders/TextureAssetUpgrader.h +++ b/Source/Engine/Content/Upgraders/TextureAssetUpgrader.h @@ -2,6 +2,8 @@ #pragma once +#if USE_EDITOR + #include "BinaryAssetUpgrader.h" #include "Engine/Core/Core.h" #include "Engine/Platform/Platform.h" @@ -825,3 +827,5 @@ private: return true; } }; + +#endif diff --git a/Source/Engine/ContentImporters/CreateJson.cpp b/Source/Engine/ContentImporters/CreateJson.cpp index 862c5028f..5aff3219e 100644 --- a/Source/Engine/ContentImporters/CreateJson.cpp +++ b/Source/Engine/ContentImporters/CreateJson.cpp @@ -5,6 +5,7 @@ #if COMPILE_WITH_ASSETS_IMPORTER #include "Engine/Core/Log.h" +#include "Engine/Core/Math/Math.h" #include "Engine/Platform/File.h" #include "Engine/Platform/FileSystem.h" #include "Engine/Content/Content.h" diff --git a/Source/Engine/Core/Collections/Dictionary.h b/Source/Engine/Core/Collections/Dictionary.h index 99bad0bef..08b404bfd 100644 --- a/Source/Engine/Core/Collections/Dictionary.h +++ b/Source/Engine/Core/Collections/Dictionary.h @@ -2,7 +2,7 @@ #pragma once -#include "Engine/Core/Collections/Array.h" +#include "Engine/Core/Memory/Memory.h" #include "Engine/Core/Collections/HashFunctions.h" #include "Engine/Core/Collections/Config.h" @@ -781,7 +781,8 @@ public: /// Gets the keys collection to the output array (will contain unique items). /// /// The result. - void GetKeys(Array& result) const + template + void GetKeys(Array& result) const { for (auto i = Begin(); i.IsNotEnd(); ++i) result.Add(i->Key); @@ -791,7 +792,8 @@ public: /// Gets the values collection to the output array (may contain duplicates). /// /// The result. - void GetValues(Array& result) const + template + void GetValues(Array& result) const { for (auto i = Begin(); i.IsNotEnd(); ++i) result.Add(i->Value); diff --git a/Source/Engine/Core/Memory/Memory.h b/Source/Engine/Core/Memory/Memory.h index 6341ca21f..344e54a13 100644 --- a/Source/Engine/Core/Memory/Memory.h +++ b/Source/Engine/Core/Memory/Memory.h @@ -3,6 +3,8 @@ #pragma once #include "Engine/Core/Templates.h" +#include "Engine/Platform/Platform.h" +#include #include "CrtAllocator.h" typedef CrtAllocator Allocator; diff --git a/Source/Engine/Core/Types/DataContainer.h b/Source/Engine/Core/Types/DataContainer.h index 8b504e58f..a229acdc8 100644 --- a/Source/Engine/Core/Types/DataContainer.h +++ b/Source/Engine/Core/Types/DataContainer.h @@ -3,10 +3,9 @@ #pragma once #include "Span.h" -#include "Engine/Core/Collections/Array.h" +#include "Engine/Core/Templates.h" +#include "Engine/Core/Memory/Memory.h" #include "Engine/Platform/Platform.h" -#include "Engine/Serialization/WriteStream.h" -#include "Engine/Serialization/ReadStream.h" /// /// Universal utility class that can store the chunk of data or just reference to the memory. @@ -49,7 +48,8 @@ public: /// Initializes a new instance of the class. /// /// The data array to link. - DataContainer(const Array& data) + template + DataContainer(const Array& data) : Base((T*)data.Get(), data.Count()) , _isAllocated(false) { @@ -147,7 +147,8 @@ public: /// Link external data /// /// Data array to link - void Link(const Array& data) + template + void Link(const Array& data) { Link(data.Get(), data.Count()); } @@ -217,7 +218,8 @@ public: /// Copies the data to a new allocated chunk /// /// Data array to copy - FORCE_INLINE void Copy(const Array& data) + template + FORCE_INLINE void Copy(const Array& data) { if (data.HasItems()) Copy(data.Get(), data.Count()); @@ -347,10 +349,9 @@ public: public: + template void Read(ReadStream* stream, int32 length) { - // Note: this may not work for the objects, use with primitive types and structures - ASSERT(stream != nullptr); Allocate(length); if (length > 0) @@ -359,10 +360,9 @@ public: } } + template void Write(WriteStream* stream) const { - // Note: this may not work for the objects, use with primitive types and structures - ASSERT(stream != nullptr); if (Base::_length > 0) { diff --git a/Source/Engine/Core/Types/DateTime.cpp b/Source/Engine/Core/Types/DateTime.cpp index 5090c62a1..c4d2124ad 100644 --- a/Source/Engine/Core/Types/DateTime.cpp +++ b/Source/Engine/Core/Types/DateTime.cpp @@ -6,8 +6,8 @@ #include "Engine/Platform/Platform.h" #include "Engine/Core/Math/Math.h" -const int32 DateTime::CachedDaysPerMonth[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; -const int32 DateTime::CachedDaysToMonth[] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 }; +const int32 CachedDaysPerMonth[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; +const int32 CachedDaysToMonth[] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 }; DateTime::DateTime(int32 year, int32 month, int32 day, int32 hour, int32 minute, int32 second, int32 millisecond) { @@ -25,6 +25,11 @@ DateTime::DateTime(int32 year, int32 month, int32 day, int32 hour, int32 minute, + millisecond * Constants::TicksPerMillisecond; } +DateTime DateTime::GetDate() const +{ + return DateTime(Ticks - Ticks % Constants::TicksPerDay); +} + void DateTime::GetDate(int32& year, int32& month, int32& day) const { // Based on: @@ -68,6 +73,11 @@ int32 DateTime::GetDayOfYear() const return day; } +int32 DateTime::GetHour() const +{ + return static_cast(Ticks / Constants::TicksPerHour % 24); +} + int32 DateTime::GetHour12() const { const int32 hour = GetHour(); @@ -78,6 +88,26 @@ int32 DateTime::GetHour12() const return hour; } +double DateTime::GetJulianDay() const +{ + return 1721425.5 + static_cast(Ticks) / Constants::TicksPerDay; +} + +double DateTime::GetModifiedJulianDay() const +{ + return GetJulianDay() - 2400000.5; +} + +int32 DateTime::GetMillisecond() const +{ + return static_cast(Ticks / Constants::TicksPerMillisecond % 1000); +} + +int32 DateTime::GetMinute() const +{ + return static_cast(Ticks / Constants::TicksPerMinute % 60); +} + int32 DateTime::GetMonth() const { int32 year, month, day; @@ -85,6 +115,21 @@ int32 DateTime::GetMonth() const return month; } +MonthOfYear DateTime::GetMonthOfYear() const +{ + return static_cast(GetMonth()); +} + +int32 DateTime::GetSecond() const +{ + return static_cast(Ticks / Constants::TicksPerSecond % 60); +} + +TimeSpan DateTime::GetTimeOfDay() const +{ + return TimeSpan(Ticks % Constants::TicksPerDay); +} + int32 DateTime::GetYear() const { int32 year, month, day; @@ -92,6 +137,11 @@ int32 DateTime::GetYear() const return year; } +int32 DateTime::ToUnixTimestamp() const +{ + return static_cast((Ticks - DateTime(1970, 1, 1).Ticks) / Constants::TicksPerSecond); +} + int32 DateTime::DaysInMonth(int32 year, int32 month) { ASSERT_LOW_LAYER((month >= 1) && (month <= 12)); @@ -105,6 +155,16 @@ int32 DateTime::DaysInYear(int32 year) return IsLeapYear(year) ? 366 : 365; } +DateTime DateTime::FromJulianDay(double julianDay) +{ + return DateTime(static_cast((julianDay - 1721425.5) * Constants::TicksPerDay)); +} + +DateTime DateTime::FromUnixTimestamp(int32 unixTime) +{ + return DateTime(1970, 1, 1) + TimeSpan(static_cast(unixTime) * Constants::TicksPerSecond); +} + bool DateTime::IsLeapYear(int32 year) { if ((year % 4) == 0) @@ -114,6 +174,11 @@ bool DateTime::IsLeapYear(int32 year) return false; } +DateTime DateTime::MaxValue() +{ + return DateTime(3652059 * Constants::TicksPerDay - 1); +} + DateTime DateTime::Now() { int32 year, month, day, dayOfWeek, hour, minute, second, millisecond; @@ -144,3 +209,30 @@ String DateTime::ToFileNameString() const GetDate(year, month, day); return String::Format(TEXT("{0}_{1:0>2}_{2:0>2}_{3:0>2}_{4:0>2}_{5:0>2}"), year, month, day, GetHour(), GetMinute(), GetSecond()); } + +DateTime DateTime::operator+(const TimeSpan& other) const +{ + return DateTime(Ticks + other.Ticks); +} + +DateTime& DateTime::operator+=(const TimeSpan& other) +{ + Ticks += other.Ticks; + return *this; +} + +TimeSpan DateTime::operator-(const DateTime& other) const +{ + return TimeSpan(Ticks - other.Ticks); +} + +DateTime DateTime::operator-(const TimeSpan& other) const +{ + return DateTime(Ticks - other.Ticks); +} + +DateTime& DateTime::operator-=(const TimeSpan& other) +{ + Ticks -= other.Ticks; + return *this; +} diff --git a/Source/Engine/Core/Types/DateTime.h b/Source/Engine/Core/Types/DateTime.h index a1bf245e1..08817f78f 100644 --- a/Source/Engine/Core/Types/DateTime.h +++ b/Source/Engine/Core/Types/DateTime.h @@ -3,7 +3,8 @@ #pragma once #include "BaseTypes.h" -#include "TimeSpan.h" +#include "Engine/Core/Formatting.h" +#include "Engine/Core/Templates.h" #include "Engine/Core/Enums.h" /// @@ -21,11 +22,6 @@ DECLARE_ENUM_EX_12(MonthOfYear, int32, 1, January, February, March, April, May, /// API_STRUCT(InBuild, Namespace="System") struct FLAXENGINE_API DateTime { -private: - - static const int32 CachedDaysPerMonth[]; - static const int32 CachedDaysToMonth[]; - public: /// @@ -77,32 +73,11 @@ public: public: - DateTime operator+(const TimeSpan& other) const - { - return DateTime(Ticks + other.Ticks); - } - - DateTime& operator+=(const TimeSpan& other) - { - Ticks += other.Ticks; - return *this; - } - - TimeSpan operator-(const DateTime& other) const - { - return TimeSpan(Ticks - other.Ticks); - } - - DateTime operator-(const TimeSpan& other) const - { - return DateTime(Ticks - other.Ticks); - } - - DateTime& operator-=(const TimeSpan& other) - { - Ticks -= other.Ticks; - return *this; - } + DateTime operator+(const TimeSpan& other) const; + DateTime& operator+=(const TimeSpan& other); + TimeSpan operator-(const DateTime& other) const; + DateTime operator-(const TimeSpan& other) const; + DateTime& operator-=(const TimeSpan& other); bool operator==(const DateTime& other) const { @@ -139,11 +114,7 @@ public: /// /// Gets the date part of this date. The time part is truncated and becomes 00:00:00.000. /// - /// A DateTime object containing the date. - DateTime GetDate() const - { - return DateTime(Ticks - Ticks % Constants::TicksPerDay); - } + DateTime GetDate() const; /// /// Gets the date components of this date. @@ -156,106 +127,68 @@ public: /// /// Gets this date's day part (1 to 31). /// - /// The day of the month. int32 GetDay() const; /// /// Calculates this date's day of the week (Sunday - Saturday). /// - /// The week day. DayOfWeek GetDayOfWeek() const; /// /// Gets this date's day of the year. /// - /// The day of year. int32 GetDayOfYear() const; /// /// Gets this date's hour part in 24-hour clock format (0 to 23). /// - /// The hour. - int32 GetHour() const - { - return static_cast(Ticks / Constants::TicksPerHour % 24); - } + int32 GetHour() const; /// /// Gets this date's hour part in 12-hour clock format (1 to 12). /// - /// The hour in AM/PM format. int32 GetHour12() const; /// /// Gets the Julian Day for this date. /// - /// - /// The Julian Day is the number of days since the inception of the Julian calendar at noon on Monday, January 1, 4713 B.C.E. The minimum Julian Day that can be represented in DateTime is 1721425.5, which corresponds to Monday, January 1, 0001 in the Gregorian calendar. - /// - /// Julian Day. - double GetJulianDay() const - { - return 1721425.5 + static_cast(Ticks) / Constants::TicksPerDay; - } + /// The Julian Day is the number of days since the inception of the Julian calendar at noon on Monday, January 1, 4713 B.C.E. The minimum Julian Day that can be represented in DateTime is 1721425.5, which corresponds to Monday, January 1, 0001 in the Gregorian calendar. + double GetJulianDay() const; /// /// Gets the Modified Julian day. /// - /// - /// The Modified Julian Day is calculated by subtracting 2400000.5, which corresponds to midnight UTC on November 17, 1858 in the Gregorian calendar. - /// - /// The Modified Julian Day. - double GetModifiedJulianDay() const - { - return GetJulianDay() - 2400000.5; - } + /// The Modified Julian Day is calculated by subtracting 2400000.5, which corresponds to midnight UTC on November 17, 1858 in the Gregorian calendar. + double GetModifiedJulianDay() const; /// /// Gets this date's millisecond part (0 to 999). /// - /// The millisecond. - int32 GetMillisecond() const - { - return static_cast(Ticks / Constants::TicksPerMillisecond % 1000); - } + int32 GetMillisecond() const; /// /// Gets this date's minute part (0 to 59). /// - /// The minute. - int32 GetMinute() const - { - return static_cast(Ticks / Constants::TicksPerMinute % 60); - } + int32 GetMinute() const; /// /// Gets this date's the month part (1 to 12). /// - /// The month. int32 GetMonth() const; /// /// Gets the date's month of the year (January to December). /// - /// The month of year. - MonthOfYear GetMonthOfYear() const - { - return static_cast(GetMonth()); - } + MonthOfYear GetMonthOfYear() const; /// /// Gets this date's second part. /// - /// The second. - int32 GetSecond() const - { - return static_cast(Ticks / Constants::TicksPerSecond % 60); - } + int32 GetSecond() const; /// - /// Gets this date's representation as number of ticks. + /// Gets this date's representation as number of ticks since midnight, January 1, 0001. /// - /// The number of ticks since midnight, January 1, 0001. int64 GetTicks() const { return Ticks; @@ -264,26 +197,17 @@ public: /// /// Gets the time elapsed since midnight of this date. /// - /// The time span since midnight. - TimeSpan GetTimeOfDay() const - { - return TimeSpan(Ticks % Constants::TicksPerDay); - } + TimeSpan GetTimeOfDay() const; /// /// Gets this date's year part. /// - /// The year. int32 GetYear() const; /// /// Gets this date as the number of seconds since the Unix Epoch (January 1st of 1970). /// - /// The time. - int32 ToUnixTimestamp() const - { - return static_cast((Ticks - DateTime(1970, 1, 1).Ticks) / Constants::TicksPerSecond); - } + int32 ToUnixTimestamp() const; public: @@ -307,27 +231,19 @@ public: /// /// The Julian Day. /// Gregorian date and time. - static DateTime FromJulianDay(double julianDay) - { - return DateTime(static_cast((julianDay - 1721425.5) * Constants::TicksPerDay)); - } + static DateTime FromJulianDay(double julianDay); /// /// Returns the date from Unix time (seconds from midnight 1970-01-01). /// /// The Unix time (seconds from midnight 1970-01-01). /// The Gregorian date and time. - static DateTime FromUnixTimestamp(int32 unixTime) - { - return DateTime(1970, 1, 1) + TimeSpan(static_cast(unixTime) * Constants::TicksPerSecond); - } + static DateTime FromUnixTimestamp(int32 unixTime); /// /// Determines whether the specified year is a leap year. /// - /// - /// A leap year is a year containing one additional day in order to keep the calendar synchronized with the astronomical year. - /// + /// A leap year is a year containing one additional day in order to keep the calendar synchronized with the astronomical year. /// The year. /// true if the specified year os a leap year; otherwise, false. static bool IsLeapYear(int32 year); @@ -335,22 +251,15 @@ public: /// /// Returns the maximum date value. /// - /// - /// The maximum date value is December 31, 9999, 23:59:59.9999999. - /// - /// The date. - static DateTime MaxValue() - { - return DateTime(3652059 * Constants::TicksPerDay - 1); - } + /// The maximum date value is December 31, 9999, 23:59:59.9999999. + /// The maximum valid date. + static DateTime MaxValue(); /// /// Returns the minimum date value. /// - /// - /// The minimum date value is January 1, 0001, 00:00:00.0. - /// - /// The date. + /// The minimum date value is January 1, 0001, 00:00:00.0. + /// The minimum valid date. static DateTime MinValue() { return DateTime(1, 1, 1, 0, 0, 0, 0); @@ -359,18 +268,14 @@ public: /// /// Gets the local date and time on this computer. /// - /// - ///This method takes into account the local computer's time zone and daylight saving settings. For time zone independent time comparisons, and when comparing times between different computers, use NowUTC() instead. - /// + /// This method takes into account the local computer's time zone and daylight saving settings. For time zone independent time comparisons, and when comparing times between different computers, use NowUTC() instead. /// The current date and time. static DateTime Now(); /// /// Gets the UTC date and time on this computer. /// - /// - /// This method returns the Coordinated Universal Time (UTC), which does not take the local computer's time zone and daylight savings settings into account. It should be used when comparing dates and times that should be independent of the user's locale. To get the date and time in the current locale, use Now() instead. - /// + /// This method returns the Coordinated Universal Time (UTC), which does not take the local computer's time zone and daylight savings settings into account. It should be used when comparing dates and times that should be independent of the user's locale. To get the date and time in the current locale, use Now() instead. /// The current date and time. static DateTime NowUTC(); diff --git a/Source/Engine/Core/Types/String.h b/Source/Engine/Core/Types/String.h index 950018c03..75d484303 100644 --- a/Source/Engine/Core/Types/String.h +++ b/Source/Engine/Core/Types/String.h @@ -5,6 +5,7 @@ #include "Engine/Platform/Platform.h" #include "Engine/Platform/StringUtils.h" #include "Engine/Core/Formatting.h" +#include "Engine/Core/Templates.h" /// /// Represents text as a sequence of characters. Container uses a single dynamic memory allocation to store the characters data. Characters sequence is always null-terminated. diff --git a/Source/Engine/Core/Types/StringView.h b/Source/Engine/Core/Types/StringView.h index bbfdbccd7..fe245e8f2 100644 --- a/Source/Engine/Core/Types/StringView.h +++ b/Source/Engine/Core/Types/StringView.h @@ -66,7 +66,6 @@ public: /// /// Returns true if string is empty. /// - /// True if string is empty, otherwise false. FORCE_INLINE bool IsEmpty() const { return _length == 0; @@ -75,7 +74,6 @@ public: /// /// Returns true if string isn't empty. /// - /// True if string isn't empty, otherwise false. FORCE_INLINE bool HasChars() const { return _length != 0; @@ -84,7 +82,6 @@ public: /// /// Gets the length of the string. /// - /// The string length. FORCE_INLINE int32 Length() const { return _length; @@ -93,7 +90,6 @@ public: /// /// Gets the pointer to the string. /// - /// The string. FORCE_INLINE const T* operator*() const { return _data; @@ -102,7 +98,6 @@ public: /// /// Gets the pointer to the string. /// - /// The string. FORCE_INLINE const T* Get() const { return _data; @@ -111,7 +106,6 @@ public: /// /// Gets the pointer to the string or to the static empty text if string is null. Returned pointer is always valid (read-only). /// - /// The string handle. FORCE_INLINE const T* GetText() const { return _data ? _data : (const T*)TEXT(""); diff --git a/Source/Engine/Core/Types/TimeSpan.h b/Source/Engine/Core/Types/TimeSpan.h index 0b56d8ee1..cb663d80c 100644 --- a/Source/Engine/Core/Types/TimeSpan.h +++ b/Source/Engine/Core/Types/TimeSpan.h @@ -3,7 +3,6 @@ #pragma once #include "BaseTypes.h" -#include "Engine/Platform/Platform.h" #include "Engine/Core/Formatting.h" #include "Engine/Core/Templates.h" diff --git a/Source/Engine/Debug/DebugDraw.cpp b/Source/Engine/Debug/DebugDraw.cpp index a3569ded9..b443577fb 100644 --- a/Source/Engine/Debug/DebugDraw.cpp +++ b/Source/Engine/Debug/DebugDraw.cpp @@ -12,11 +12,13 @@ #include "Engine/Content/Assets/Shader.h" #include "Engine/Content/AssetReference.h" #include "Engine/Graphics/GPUContext.h" -#include "Engine/Graphics/RenderTask.h" -#include "Engine/Graphics/DynamicBuffer.h" +#include "Engine/Graphics/GPUDevice.h" #include "Engine/Graphics/GPUPipelineState.h" -#include "Engine/Graphics/Shaders/GPUConstantBuffer.h" +#include "Engine/Graphics/RenderTask.h" #include "Engine/Graphics/RenderBuffers.h" +#include "Engine/Graphics/DynamicBuffer.h" +#include "Engine/Graphics/Shaders/GPUConstantBuffer.h" +#include "Engine/Graphics/Shaders/GPUShader.h" #include "Engine/Animations/AnimationUtils.h" #include "Engine/Profiler/Profiler.h" #include "Engine/Debug/DebugLog.h" diff --git a/Source/Engine/Debug/DebugLog.cpp b/Source/Engine/Debug/DebugLog.cpp index 9263651b9..fb0ab901b 100644 --- a/Source/Engine/Debug/DebugLog.cpp +++ b/Source/Engine/Debug/DebugLog.cpp @@ -7,6 +7,7 @@ #include "Engine/Scripting/ManagedCLR/MDomain.h" #include "Engine/Scripting/ManagedCLR/MAssembly.h" #include "Engine/Scripting/ManagedCLR/MClass.h" +#include "Engine/Threading/Threading.h" #include "FlaxEngine.Gen.h" #include #include diff --git a/Source/Engine/Engine/Base/GameBase.cpp b/Source/Engine/Engine/Base/GameBase.cpp index 62e187e7d..a4b10adf9 100644 --- a/Source/Engine/Engine/Base/GameBase.cpp +++ b/Source/Engine/Engine/Base/GameBase.cpp @@ -6,6 +6,7 @@ #include "Engine/Engine/Time.h" #include "Engine/Engine/Engine.h" +#include "Engine/Engine/Globals.h" #include "Engine/Platform/Window.h" #include "Engine/Profiler/Profiler.h" #include "Engine/Level/Level.h" @@ -17,6 +18,7 @@ #include "Engine/Graphics/RenderTask.h" #include "Engine/Render2D/Render2D.h" #include "Engine/Graphics/GPUDevice.h" +#include "Engine/Graphics/Textures/GPUTexture.h" #include "Engine/Utilities/Encryption.h" #include "Engine/Core/Log.h" #include "FlaxEngine.Gen.h" @@ -241,7 +243,7 @@ void GameBaseImpl::OnPostRender(GPUContext* context, RenderContext& renderContex const Rectangle screenRect(viewport.X, viewport.Y, viewport.Width, viewport.Height); Rectangle imageArea = screenRect; imageArea.Scale(0.6f); - const float aspectRatio = static_cast(splashScreen->Width()) / splashScreen->Height(); + const float aspectRatio = static_cast(splashScreen->Width()) / static_cast(splashScreen->Height()); const float height = imageArea.GetWidth() / aspectRatio; imageArea.Location.Y += (imageArea.GetHeight() - height) * 0.5f; imageArea.Size.Y = height; diff --git a/Source/Engine/Engine/GameplayGlobals.cpp b/Source/Engine/Engine/GameplayGlobals.cpp index f945832cc..0525f3169 100644 --- a/Source/Engine/Engine/GameplayGlobals.cpp +++ b/Source/Engine/Engine/GameplayGlobals.cpp @@ -8,6 +8,8 @@ #include "Engine/Content/Factories/BinaryAssetFactory.h" #include "Engine/Content/Upgraders/BinaryAssetUpgrader.h" +#if USE_EDITOR + class GameplayGlobalsUpgrader : public BinaryAssetUpgrader { public: @@ -50,7 +52,9 @@ private: } }; -REGISTER_BINARY_ASSET(GameplayGlobals, "FlaxEngine.GameplayGlobals", ::New(), true); +#endif + +REGISTER_BINARY_ASSET_WITH_UPGRADER(GameplayGlobals, "FlaxEngine.GameplayGlobals", GameplayGlobalsUpgrader, true); GameplayGlobals::GameplayGlobals(const SpawnParams& params, const AssetInfo* info) : BinaryAsset(params, info) diff --git a/Source/Engine/Engine/Globals.cpp b/Source/Engine/Engine/Globals.cpp index 9f180fa12..e65823350 100644 --- a/Source/Engine/Engine/Globals.cpp +++ b/Source/Engine/Engine/Globals.cpp @@ -25,4 +25,3 @@ int32 Globals::EngineBuildNumber = FLAXENGINE_VERSION_BUILD; String Globals::ProductName; String Globals::CompanyName; int32 Globals::ContentKey; -bool Globals::ConvertLoadedMaterialsByForce; diff --git a/Source/Engine/Engine/Globals.h b/Source/Engine/Engine/Globals.h index 16c47d8ee..6d88b11bf 100644 --- a/Source/Engine/Engine/Globals.h +++ b/Source/Engine/Engine/Globals.h @@ -94,7 +94,4 @@ DECLARE_SCRIPTING_TYPE_NO_SPAWN(Globals); /// The content data keycode. /// static int32 ContentKey; - - // True if convert all loaded material by force - static bool ConvertLoadedMaterialsByForce; }; diff --git a/Source/Engine/Foliage/Foliage.cpp b/Source/Engine/Foliage/Foliage.cpp index c38191adf..bb809d4e0 100644 --- a/Source/Engine/Foliage/Foliage.cpp +++ b/Source/Engine/Foliage/Foliage.cpp @@ -5,6 +5,7 @@ #include "FoliageCluster.h" #include "Engine/Core/Random.h" #include "Engine/Engine/Engine.h" +#include "Engine/Graphics/RenderTask.h" #include "Engine/Level/Scene/Scene.h" #include "Engine/Level/SceneQuery.h" #include "Engine/Profiler/ProfilerCPU.h" diff --git a/Source/Engine/Graphics/GPUDevice.cpp b/Source/Engine/Graphics/GPUDevice.cpp index 51d92cd3f..8f30dc85a 100644 --- a/Source/Engine/Graphics/GPUDevice.cpp +++ b/Source/Engine/Graphics/GPUDevice.cpp @@ -6,6 +6,7 @@ #include "RenderTask.h" #include "RenderTools.h" #include "Graphics.h" +#include "Shaders/GPUShader.h" #include "Async/DefaultGPUTasksExecutor.h" #include "Engine/Content/Assets/Shader.h" #include "Engine/Content/Assets/Material.h" diff --git a/Source/Engine/Graphics/Materials/MaterialParams.cpp b/Source/Engine/Graphics/Materials/MaterialParams.cpp index 5ce55f1c4..b5ff66c3b 100644 --- a/Source/Engine/Graphics/Materials/MaterialParams.cpp +++ b/Source/Engine/Graphics/Materials/MaterialParams.cpp @@ -2,6 +2,8 @@ #include "MaterialParams.h" #include "MaterialInfo.h" +#include "Engine/Core/Math/Vector4.h" +#include "Engine/Core/Math/Matrix.h" #include "Engine/Content/Content.h" #include "Engine/Graphics/GPUContext.h" #include "Engine/Engine/GameplayGlobals.h" @@ -96,11 +98,11 @@ Variant MaterialParameter::GetValue() const case MaterialParameterType::Vector3: return _asVector3; case MaterialParameterType::Vector4: - return _asVector4; + return *(Vector4*)&AsData; case MaterialParameterType::Color: return _asColor; case MaterialParameterType::Matrix: - return Variant(_asMatrix); + return Variant(*(Matrix*)&AsData); case MaterialParameterType::NormalMap: case MaterialParameterType::Texture: case MaterialParameterType::CubeTexture: @@ -140,13 +142,13 @@ void MaterialParameter::SetValue(const Variant& value) _asVector3 = (Vector3)value; break; case MaterialParameterType::Vector4: - _asVector4 = (Vector4)value; + *(Vector4*)&AsData = (Vector4)value; break; case MaterialParameterType::Color: _asColor = (Color)value; break; case MaterialParameterType::Matrix: - _asMatrix = (Matrix)value; + *(Matrix*)&AsData = (Matrix)value; break; case MaterialParameterType::NormalMap: case MaterialParameterType::Texture: @@ -245,13 +247,13 @@ void MaterialParameter::Bind(BindMeta& meta) const *((Vector3*)(meta.Constants + _offset)) = _asVector3; break; case MaterialParameterType::Vector4: - *((Vector4*)(meta.Constants + _offset)) = _asVector4; + *((Vector4*)(meta.Constants + _offset)) = *(Vector4*)&AsData; break; case MaterialParameterType::Color: *((Color*)(meta.Constants + _offset)) = _asColor; break; case MaterialParameterType::Matrix: - Matrix::Transpose(_asMatrix, *(Matrix*)(meta.Constants + _offset)); + Matrix::Transpose(*(Matrix*)&AsData, *(Matrix*)(meta.Constants + _offset)); break; case MaterialParameterType::NormalMap: { @@ -406,13 +408,13 @@ void MaterialParameter::clone(const MaterialParameter* param) _asVector3 = param->_asVector3; break; case MaterialParameterType::Vector4: - _asVector4 = param->_asVector4; + *(Vector4*)&AsData = *(Vector4*)¶m->AsData; break; case MaterialParameterType::Color: _asColor = param->_asColor; break; case MaterialParameterType::Matrix: - _asMatrix = param->_asMatrix; + *(Matrix*)&AsData = *(Matrix*)¶m->AsData; break; default: break; @@ -585,13 +587,13 @@ bool MaterialParams::Load(ReadStream* stream) stream->Read(¶m->_asVector3); break; case MaterialParameterType::Vector4: - stream->Read(¶m->_asVector4); + stream->Read((Vector4*)¶m->AsData); break; case MaterialParameterType::Color: stream->Read(¶m->_asColor); break; case MaterialParameterType::Matrix: - stream->Read(¶m->_asMatrix); + stream->Read((Matrix*)¶m->AsData); break; case MaterialParameterType::NormalMap: case MaterialParameterType::Texture: @@ -658,13 +660,13 @@ bool MaterialParams::Load(ReadStream* stream) stream->Read(¶m->_asVector3); break; case MaterialParameterType::Vector4: - stream->Read(¶m->_asVector4); + stream->Read((Vector4*)¶m->AsData); break; case MaterialParameterType::Color: stream->Read(¶m->_asColor); break; case MaterialParameterType::Matrix: - stream->Read(¶m->_asMatrix); + stream->Read((Matrix*)¶m->AsData); break; case MaterialParameterType::NormalMap: case MaterialParameterType::Texture: @@ -732,13 +734,13 @@ bool MaterialParams::Load(ReadStream* stream) stream->Read(¶m->_asVector3); break; case MaterialParameterType::Vector4: - stream->Read(¶m->_asVector4); + stream->Read((Vector4*)¶m->AsData); break; case MaterialParameterType::Color: stream->Read(¶m->_asColor); break; case MaterialParameterType::Matrix: - stream->Read(¶m->_asMatrix); + stream->Read((Matrix*)¶m->AsData); break; case MaterialParameterType::NormalMap: case MaterialParameterType::Texture: @@ -824,13 +826,13 @@ void MaterialParams::Save(WriteStream* stream) stream->Write(¶m->_asVector3); break; case MaterialParameterType::Vector4: - stream->Write(¶m->_asVector4); + stream->Write((Vector4*)¶m->AsData); break; case MaterialParameterType::Color: stream->Write(¶m->_asColor); break; case MaterialParameterType::Matrix: - stream->Write(¶m->_asMatrix); + stream->Write((Matrix*)¶m->AsData); break; case MaterialParameterType::NormalMap: case MaterialParameterType::Texture: @@ -898,13 +900,13 @@ void MaterialParams::Save(WriteStream* stream, const ArrayWrite(¶m.AsVector3); break; case MaterialParameterType::Vector4: - stream->Write(¶m.AsVector4); + stream->Write((Vector4*)¶m.AsData); break; case MaterialParameterType::Color: stream->Write(¶m.AsColor); break; case MaterialParameterType::Matrix: - stream->Write(¶m.AsMatrix); + stream->Write((Matrix*)¶m.AsData); break; case MaterialParameterType::NormalMap: case MaterialParameterType::Texture: diff --git a/Source/Engine/Graphics/Materials/MaterialParams.h b/Source/Engine/Graphics/Materials/MaterialParams.h index c51ffb8f9..d4fef1966 100644 --- a/Source/Engine/Graphics/Materials/MaterialParams.h +++ b/Source/Engine/Graphics/Materials/MaterialParams.h @@ -2,7 +2,9 @@ #pragma once -#include "Engine/Core/Math/Matrix.h" +#include "Engine/Core/Math/Color.h" +#include "Engine/Core/Math/Vector2.h" +#include "Engine/Core/Math/Vector3.h" #include "Engine/Core/Types/StringView.h" #include "Engine/Core/Collections/Array.h" #include "Engine/Scripting/ScriptingObjectReference.h" @@ -12,6 +14,7 @@ class MaterialInstance; class MaterialParams; class GPUContext; +class GPUTextureView; class RenderBuffers; struct MaterialParamsLink @@ -143,10 +146,9 @@ struct SerializedMaterialParam float AsFloat; Vector2 AsVector2; Vector3 AsVector3; - Vector4 AsVector4; Color AsColor; Guid AsGuid; - Matrix AsMatrix; + byte AsData[16 * 4]; }; byte RegisterIndex; @@ -181,9 +183,8 @@ private: float _asFloat; Vector2 _asVector2; Vector3 _asVector3; - Vector4 _asVector4; Color _asColor; - Matrix _asMatrix; + byte AsData[16 * 4]; }; AssetReference _asAsset; diff --git a/Source/Engine/Graphics/Materials/MaterialShaderFeatures.cpp b/Source/Engine/Graphics/Materials/MaterialShaderFeatures.cpp index abc28a0de..2c5dc147a 100644 --- a/Source/Engine/Graphics/Materials/MaterialShaderFeatures.cpp +++ b/Source/Engine/Graphics/Materials/MaterialShaderFeatures.cpp @@ -2,6 +2,7 @@ #include "MaterialShaderFeatures.h" #include "Engine/Graphics/RenderTask.h" +#include "Engine/Graphics/Textures/GPUTexture.h" #include "Engine/Renderer/RenderList.h" #include "Engine/Renderer/ShadowsPass.h" #if USE_EDITOR diff --git a/Source/Engine/Graphics/Models/Mesh.cpp b/Source/Engine/Graphics/Models/Mesh.cpp index 4454a44ce..dddbd6a3e 100644 --- a/Source/Engine/Graphics/Models/Mesh.cpp +++ b/Source/Engine/Graphics/Models/Mesh.cpp @@ -5,6 +5,8 @@ #include "Engine/Content/Assets/Material.h" #include "Engine/Content/Assets/Model.h" #include "Engine/Graphics/GPUContext.h" +#include "Engine/Graphics/GPUDevice.h" +#include "Engine/Graphics/RenderTask.h" #include "Engine/Level/Scene/Scene.h" #include "Engine/Renderer/RenderList.h" #include "Engine/Serialization/MemoryReadStream.h" @@ -131,6 +133,11 @@ namespace } } +bool Mesh::HasVertexColors() const +{ + return _vertexBuffers[2] != nullptr && _vertexBuffers[2]->IsAllocated(); +} + bool Mesh::UpdateMesh(uint32 vertexCount, uint32 triangleCount, VB0ElementType* vb0, VB1ElementType* vb1, VB2ElementType* vb2, void* ib, bool use16BitIndices) { auto model = (Model*)_model; diff --git a/Source/Engine/Graphics/Models/Mesh.h b/Source/Engine/Graphics/Models/Mesh.h index f378f9f8e..ca5174f7b 100644 --- a/Source/Engine/Graphics/Models/Mesh.h +++ b/Source/Engine/Graphics/Models/Mesh.h @@ -3,15 +3,16 @@ #pragma once #include "MeshBase.h" -#include "Engine/Renderer/RenderList.h" -#include "Engine/Graphics/RenderTask.h" #include "ModelInstanceEntry.h" #include "Config.h" #include "Types.h" +#include "Engine/Level/Types.h" #if USE_PRECISE_MESH_INTERSECTS #include "CollisionProxy.h" #endif +struct GeometryDrawStateData; +class Lightmap; class GPUBuffer; /// @@ -21,7 +22,6 @@ API_CLASS(NoSpawn) class FLAXENGINE_API Mesh : public MeshBase { DECLARE_SCRIPTING_TYPE_WITH_CONSTRUCTOR_IMPL(Mesh, MeshBase); protected: - int32 _index; int32 _lodIndex; bool _hasLightmapUVs; @@ -32,7 +32,6 @@ protected: #endif public: - Mesh(const Mesh& other) : Mesh() { @@ -47,7 +46,6 @@ public: ~Mesh(); public: - /// /// Gets the model owning this mesh. /// @@ -104,10 +102,7 @@ public: /// Determines whether this mesh has a vertex colors buffer. /// /// True if this mesh has a vertex colors buffers. - API_PROPERTY() FORCE_INLINE bool HasVertexColors() const - { - return _vertexBuffers[2] != nullptr && _vertexBuffers[2]->IsAllocated(); - } + API_PROPERTY() bool HasVertexColors() const; /// /// Determines whether this mesh contains valid lightmap texture coordinates data. @@ -132,7 +127,6 @@ public: #endif public: - /// /// Updates the model mesh (used by the virtual models created with Init rather than Load). /// @@ -211,7 +205,6 @@ public: bool UpdateMesh(uint32 vertexCount, uint32 triangleCount, Vector3* vertices, uint32* triangles, Vector3* normals = nullptr, Vector3* tangents = nullptr, Vector2* uvs = nullptr, Color32* colors = nullptr); public: - /// /// Updates the model mesh index buffer (used by the virtual models created with Init rather than Load). /// @@ -244,7 +237,6 @@ public: bool UpdateTriangles(uint32 triangleCount, void* ib, bool use16BitIndices); public: - /// /// Initializes instance of the class. /// @@ -276,7 +268,6 @@ public: void Unload(); public: - /// /// Determines if there is an intersection between the mesh and a ray in given world /// @@ -297,7 +288,6 @@ public: } public: - /// /// Gets the draw call geometry for this mesh. Sets the index and vertex buffers. /// @@ -397,14 +387,12 @@ public: void Draw(const RenderContext& renderContext, const DrawInfo& info, float lodDitherFactor) const; public: - // [MeshBase] bool DownloadDataGPU(MeshBufferType type, BytesContainer& result) const override; Task* DownloadDataGPUAsync(MeshBufferType type, BytesContainer& result) const override; bool DownloadDataCPU(MeshBufferType type, BytesContainer& result) const override; private: - // Internal bindings API_FUNCTION(NoProxy) ScriptingObject* GetParentModel(); API_FUNCTION(NoProxy) bool UpdateMeshInt(int32 vertexCount, int32 triangleCount, MonoArray* verticesObj, MonoArray* trianglesObj, MonoArray* normalsObj, MonoArray* tangentsObj, MonoArray* uvObj, MonoArray* colorsObj); diff --git a/Source/Engine/Graphics/Models/ModelData.Tool.cpp b/Source/Engine/Graphics/Models/ModelData.Tool.cpp index 8439a30d1..8faa9dcaa 100644 --- a/Source/Engine/Graphics/Models/ModelData.Tool.cpp +++ b/Source/Engine/Graphics/Models/ModelData.Tool.cpp @@ -6,6 +6,7 @@ #include "Engine/Core/Log.h" #include "Engine/Core/Utilities.h" #include "Engine/Core/Types/DateTime.h" +#include "Engine/Core/Types/TimeSpan.h" #include "Engine/Core/Collections/BitArray.h" #include "Engine/Tools/ModelTool/ModelTool.h" #include "Engine/Tools/ModelTool/VertexTriangleAdjacency.h" diff --git a/Source/Engine/Graphics/Models/SkinnedMesh.cpp b/Source/Engine/Graphics/Models/SkinnedMesh.cpp index 41d7cfb5b..f2d1134d9 100644 --- a/Source/Engine/Graphics/Models/SkinnedMesh.cpp +++ b/Source/Engine/Graphics/Models/SkinnedMesh.cpp @@ -4,6 +4,8 @@ #include "ModelInstanceEntry.h" #include "Engine/Content/Assets/Material.h" #include "Engine/Content/Assets/SkinnedModel.h" +#include "Engine/Graphics/GPUDevice.h" +#include "Engine/Graphics/RenderTask.h" #include "Engine/Level/Scene/Scene.h" #include "Engine/Renderer/RenderList.h" #include "Engine/Serialization/MemoryReadStream.h" diff --git a/Source/Engine/Graphics/Models/SkinnedMesh.h b/Source/Engine/Graphics/Models/SkinnedMesh.h index c61b0a794..eb854189e 100644 --- a/Source/Engine/Graphics/Models/SkinnedMesh.h +++ b/Source/Engine/Graphics/Models/SkinnedMesh.h @@ -3,13 +3,13 @@ #pragma once #include "MeshBase.h" -#include "Engine/Renderer/RenderList.h" -#include "Engine/Graphics/RenderTask.h" -#include "ModelInstanceEntry.h" #include "Types.h" #include "BlendShape.h" +struct GeometryDrawStateData; +struct RenderContext; class GPUBuffer; +class SkinnedMeshDrawData; /// /// Represents part of the skinned model that is made of vertices and can be rendered using custom material, transformation and skeleton bones hierarchy. diff --git a/Source/Engine/Graphics/Models/SkinnedModelLOD.cpp b/Source/Engine/Graphics/Models/SkinnedModelLOD.cpp index db0e8b86e..e2a43d085 100644 --- a/Source/Engine/Graphics/Models/SkinnedModelLOD.cpp +++ b/Source/Engine/Graphics/Models/SkinnedModelLOD.cpp @@ -5,6 +5,12 @@ #include "Engine/Content/Assets/Model.h" #include "Engine/Serialization/MemoryReadStream.h" +bool SkinnedModelLOD::HasAnyMeshInitialized() const +{ + // Note: we initialize all meshes at once so the last one can be used to check it. + return Meshes.HasItems() && Meshes.Last().IsInitialized(); +} + bool SkinnedModelLOD::Load(MemoryReadStream& stream) { // Load LOD for each mesh diff --git a/Source/Engine/Graphics/Models/SkinnedModelLOD.h b/Source/Engine/Graphics/Models/SkinnedModelLOD.h index 673bbb4e2..758db0a1b 100644 --- a/Source/Engine/Graphics/Models/SkinnedModelLOD.h +++ b/Source/Engine/Graphics/Models/SkinnedModelLOD.h @@ -33,12 +33,7 @@ public: /// /// Determines whether any mesh has been initialized. /// - /// True if any mesh has been initialized, otherwise false. - FORCE_INLINE bool HasAnyMeshInitialized() const - { - // Note: we initialize all meshes at once so the last one can be used to check it. - return Meshes.HasItems() && Meshes.Last().IsInitialized(); - } + bool HasAnyMeshInitialized() const; public: diff --git a/Source/Engine/Graphics/PostProcessSettings.h b/Source/Engine/Graphics/PostProcessSettings.h index 400deb3c1..e1607906f 100644 --- a/Source/Engine/Graphics/PostProcessSettings.h +++ b/Source/Engine/Graphics/PostProcessSettings.h @@ -3,6 +3,7 @@ #pragma once #include "Engine/Core/Math/Vector3.h" +#include "Engine/Core/Math/Vector4.h" #include "Engine/Content/AssetReference.h" #include "Engine/Serialization/ISerializable.h" #include "Engine/Content/Assets/Texture.h" diff --git a/Source/Engine/Graphics/RenderTools.cpp b/Source/Engine/Graphics/RenderTools.cpp index c14a18c40..142906192 100644 --- a/Source/Engine/Graphics/RenderTools.cpp +++ b/Source/Engine/Graphics/RenderTools.cpp @@ -6,6 +6,7 @@ #include "PixelFormat.h" #include "RenderView.h" #include "GPUDevice.h" +#include "RenderTask.h" #include "Engine/Content/Assets/Model.h" #include "Engine/Content/Assets/SkinnedModel.h" #include "Engine/Engine/Time.h" diff --git a/Source/Engine/Graphics/Shaders/Cache/ShaderAssetBase.cpp b/Source/Engine/Graphics/Shaders/Cache/ShaderAssetBase.cpp index 4d8b8cf1d..8ce11ec70 100644 --- a/Source/Engine/Graphics/Shaders/Cache/ShaderAssetBase.cpp +++ b/Source/Engine/Graphics/Shaders/Cache/ShaderAssetBase.cpp @@ -4,6 +4,8 @@ #include "ShaderStorage.h" #include "ShaderCacheManager.h" #include "Engine/Engine/CommandLine.h" +#include "Engine/Graphics/GPUDevice.h" +#include "Engine/Graphics/Shaders/GPUShader.h" #include "Engine/Serialization/MemoryReadStream.h" #include "Engine/ShadowsOfMordor/AtlasChartsPacker.h" @@ -31,6 +33,16 @@ ShaderStorage::CachingMode ShaderStorage::GetCachingMode() #endif +bool ShaderAssetBase::IsNullRenderer() +{ + return GPUDevice::Instance->GetRendererType() == RendererType::Null; +} + +int32 ShaderAssetBase::GetCacheChunkIndex() +{ + return GetCacheChunkIndex(GPUDevice::Instance->GetShaderProfile()); +} + int32 ShaderAssetBase::GetCacheChunkIndex(ShaderProfile profile) { int32 result; @@ -61,6 +73,28 @@ int32 ShaderAssetBase::GetCacheChunkIndex(ShaderProfile profile) return result; } +bool ShaderAssetBase::initBase(AssetInitData& initData) +{ + // Validate version + if (initData.SerializedVersion != ShaderStorage::Header::Version) + { + LOG(Warning, "Invalid shader serialized version."); + return true; + } + + // Validate data + if (initData.CustomData.Length() != sizeof(_shaderHeader)) + { + LOG(Warning, "Invalid shader header."); + return true; + } + + // Load header 'as-is' + Platform::MemoryCopy(&_shaderHeader, initData.CustomData.Get(), sizeof(_shaderHeader)); + + return false; +} + #if USE_EDITOR bool ShaderAssetBase::Save() diff --git a/Source/Engine/Graphics/Shaders/Cache/ShaderAssetBase.h b/Source/Engine/Graphics/Shaders/Cache/ShaderAssetBase.h index ab1f79aee..57262eed8 100644 --- a/Source/Engine/Graphics/Shaders/Cache/ShaderAssetBase.h +++ b/Source/Engine/Graphics/Shaders/Cache/ShaderAssetBase.h @@ -4,7 +4,6 @@ #include "Engine/Core/Types/DataContainer.h" #include "Engine/Content/BinaryAsset.h" -#include "Engine/Graphics/GPUDevice.h" #include "ShaderStorage.h" /// @@ -18,17 +17,15 @@ protected: public: - /// - /// Gets internal shader cache chunk index - /// - /// Chunk index - FORCE_INLINE static int32 GetCacheChunkIndex() - { - return GetCacheChunkIndex(GPUDevice::Instance->GetShaderProfile()); - } + static bool IsNullRenderer(); /// - /// Gets internal shader cache chunk index + /// Gets internal shader cache chunk index (for current GPU device shader profile). + /// + static int32 GetCacheChunkIndex(); + + /// + /// Gets internal shader cache chunk index. /// /// Shader profile /// Chunk index @@ -47,11 +44,12 @@ public: #endif protected: - + + bool initBase(AssetInitData& initData); + /// /// Gets the parent asset. /// - /// The asset. virtual BinaryAsset* GetShaderAsset() const = 0; #if USE_EDITOR @@ -110,7 +108,7 @@ protected: }; /// -/// Base class for assets that can contain shader +/// Base class for binary assets that can contain shader. /// template class ShaderAssetTypeBase : public BaseType, public ShaderAssetBase @@ -121,11 +119,6 @@ public: protected: - /// - /// Init - /// - /// Asset scripting class metadata - /// Asset information explicit ShaderAssetTypeBase(const ScriptingObjectSpawnParams& params, const AssetInfo* info) : BaseType(params, info) { @@ -134,38 +127,22 @@ protected: protected: // [BaseType] - BinaryAsset* GetShaderAsset() const override - { - return (BinaryAsset*)this; - } bool init(AssetInitData& initData) override { - // Validate version - if (initData.SerializedVersion != ShadersSerializedVersion) - { - LOG(Warning, "Invalid shader serialized version."); - return true; - } - - // Validate data - if (initData.CustomData.Length() != sizeof(_shaderHeader)) - { - LOG(Warning, "Invalid shader header."); - return true; - } - - // Load header 'as-is' - Platform::MemoryCopy(&_shaderHeader, initData.CustomData.Get(), sizeof(_shaderHeader)); - - return false; + return initBase(initData); } - AssetChunksFlag getChunksToPreload() const override { AssetChunksFlag result = 0; const auto cachingMode = ShaderStorage::GetCachingMode(); - if (cachingMode == ShaderStorage::CachingMode::AssetInternal && GPUDevice::Instance->GetRendererType() != RendererType::Null) + if (cachingMode == ShaderStorage::CachingMode::AssetInternal && IsNullRenderer()) result |= GET_CHUNK_FLAG(GetCacheChunkIndex()); return result; } + + // [ShaderAssetBase] + BinaryAsset* GetShaderAsset() const override + { + return (BinaryAsset*)this; + } }; diff --git a/Source/Engine/Graphics/Textures/ITextureOwner.h b/Source/Engine/Graphics/Textures/ITextureOwner.h index 8f66298ba..196b76664 100644 --- a/Source/Engine/Graphics/Textures/ITextureOwner.h +++ b/Source/Engine/Graphics/Textures/ITextureOwner.h @@ -18,8 +18,7 @@ public: /// /// Gets the texture owner mutex used to synchronize texture logic. /// - /// The mutex. - virtual CriticalSection* GetOwnerLocker() const = 0; + virtual CriticalSection& GetOwnerLocker() const = 0; /// /// Get texture mip map data diff --git a/Source/Engine/Graphics/Textures/StreamingTexture.cpp b/Source/Engine/Graphics/Textures/StreamingTexture.cpp index 15b9c540c..d5a1e9339 100644 --- a/Source/Engine/Graphics/Textures/StreamingTexture.cpp +++ b/Source/Engine/Graphics/Textures/StreamingTexture.cpp @@ -33,6 +33,23 @@ StreamingTexture::~StreamingTexture() ASSERT(_streamingTasksCount == 0); } +Vector2 StreamingTexture::Size() const +{ + return _texture->Size(); +} + +int32 StreamingTexture::TextureMipIndexToTotalIndex(int32 textureMipIndex) const +{ + const int32 missingMips = TotalMipLevels() - _texture->MipLevels(); + return textureMipIndex + missingMips; +} + +int32 StreamingTexture::TotalIndexToTextureMipIndex(int32 mipIndex) const +{ + const int32 missingMips = TotalMipLevels() - _texture->MipLevels(); + return mipIndex - missingMips; +} + bool StreamingTexture::Create(const TextureHeader& header) { // Validate header (further validation is performed by the Texture.Init) @@ -90,13 +107,27 @@ uint64 StreamingTexture::GetTotalMemoryUsage() const return CalculateTextureMemoryUsage(_header.Format, _header.Width, _header.Height, _header.MipLevels) * arraySize; } +String StreamingTexture::ToString() const +{ + return _texture->ToString(); +} + +int32 StreamingTexture::GetCurrentResidency() const +{ + return _texture->ResidentMipLevels(); +} + +int32 StreamingTexture::GetAllocatedResidency() const +{ + return _texture->MipLevels(); +} + bool StreamingTexture::CanBeUpdated() const { // Streaming Texture cannot be updated if: // - is not initialized // - mip data uploading job running // - resize texture job running - return IsInitialized() && Platform::AtomicRead(&_streamingTasksCount) == 0; } @@ -146,7 +177,6 @@ protected: return Result::Ok; } - void OnEnd() override { Platform::InterlockedDecrement(&_streamingTexture->_streamingTasksCount); @@ -154,7 +184,6 @@ protected: // Base GPUTask::OnEnd(); } - void OnSync() override { Swap(_streamingTexture->_texture, _newTexture); @@ -298,7 +327,6 @@ protected: return Result::Ok; } - void OnEnd() override { _dataLock.Release(); diff --git a/Source/Engine/Graphics/Textures/StreamingTexture.h b/Source/Engine/Graphics/Textures/StreamingTexture.h index 3b6e94959..1dda71ba4 100644 --- a/Source/Engine/Graphics/Textures/StreamingTexture.h +++ b/Source/Engine/Graphics/Textures/StreamingTexture.h @@ -2,7 +2,6 @@ #pragma once -#include "GPUTexture.h" #include "ITextureOwner.h" #include "Engine/Streaming/StreamableResource.h" #include "Types.h" @@ -14,7 +13,6 @@ class FLAXENGINE_API StreamingTexture : public Object, public StreamableResource { friend class StreamTextureMipTask; friend class StreamTextureResizeTask; - protected: ITextureOwner* _owner; @@ -25,16 +23,7 @@ protected: public: - /// - /// Init - /// - /// Parent object - /// Texture object name StreamingTexture(ITextureOwner* owner, const String& name); - - /// - /// Destructor - /// ~StreamingTexture(); public: @@ -42,31 +31,23 @@ public: /// /// Gets the owner. /// - /// The owner. FORCE_INLINE ITextureOwner* GetOwner() const { return _owner; } /// - /// Gets texture object handle + /// Gets texture object handle. /// - /// Texture object FORCE_INLINE GPUTexture* GetTexture() const { return _texture; } /// - /// Gets texture size of Vector2::Zero if not loaded + /// Gets texture size of Vector2::Zero if not loaded. /// - /// Texture size - FORCE_INLINE Vector2 Size() const - { - return _texture->Size(); - } - -public: + Vector2 Size() const; /// /// Gets a value indicating whether this instance is initialized. @@ -88,7 +69,6 @@ public: /// /// Gets total texture height (in texels) /// - /// Texture width FORCE_INLINE int32 TotalHeight() const { return _header.Height; @@ -97,7 +77,6 @@ public: /// /// Gets total texture array size /// - /// Texture array size FORCE_INLINE int32 TotalArraySize() const { return IsCubeMap() ? 6 : 1; @@ -106,7 +85,6 @@ public: /// /// Gets total texture mip levels count /// - /// Texture mip levels FORCE_INLINE int32 TotalMipLevels() const { return _header.MipLevels; @@ -115,7 +93,6 @@ public: /// /// Returns texture format type /// - /// Texture format type FORCE_INLINE TextureFormatType GetFormatType() const { return _header.Type; @@ -124,7 +101,6 @@ public: /// /// Returns true if it's a cube map texture /// - /// True if i's a cubemap FORCE_INLINE bool IsCubeMap() const { return _header.IsCubeMap; @@ -133,7 +109,6 @@ public: /// /// Returns true if texture cannot be used during GPU resources streaming system /// - /// True if texture cannot be used during GPU resources streaming system FORCE_INLINE bool NeverStream() const { return _header.NeverStream; @@ -142,7 +117,6 @@ public: /// /// Gets the texture header. /// - /// Header FORCE_INLINE const TextureHeader* GetHeader() const { return &_header; @@ -163,22 +137,14 @@ public: /// /// Index of the texture mip. /// The index of the mip map. - FORCE_INLINE int32 TextureMipIndexToTotalIndex(int32 textureMipIndex) const - { - const int32 missingMips = TotalMipLevels() - _texture->MipLevels(); - return textureMipIndex + missingMips; - } + int32 TextureMipIndexToTotalIndex(int32 textureMipIndex) const; /// /// Converts absolute mip map index to the allocated texture mip index. /// /// Index of the texture mip. /// The index of the mip map. - FORCE_INLINE int32 TotalIndexToTextureMipIndex(int32 mipIndex) const - { - const int32 missingMips = TotalMipLevels() - _texture->MipLevels(); - return mipIndex - missingMips; - } + int32 TotalIndexToTextureMipIndex(int32 mipIndex) const; public: @@ -211,27 +177,15 @@ public: public: // [Object] - String ToString() const override - { - return _texture->ToString(); - } + String ToString() const override; // [StreamableResource] int32 GetMaxResidency() const override { return _header.MipLevels; } - - int32 GetCurrentResidency() const override - { - return _texture->ResidentMipLevels(); - } - - int32 GetAllocatedResidency() const override - { - return _texture->MipLevels(); - } - + int32 GetCurrentResidency() const override; + int32 GetAllocatedResidency() const override; bool CanBeUpdated() const override; Task* UpdateAllocation(int32 residency) override; Task* CreateStreamingTask(int32 residency) override; diff --git a/Source/Engine/Graphics/Textures/TextureBase.cpp b/Source/Engine/Graphics/Textures/TextureBase.cpp index 83e781a5a..d21d61f2f 100644 --- a/Source/Engine/Graphics/Textures/TextureBase.cpp +++ b/Source/Engine/Graphics/Textures/TextureBase.cpp @@ -3,10 +3,11 @@ #include "TextureBase.h" #include "TextureData.h" #include "Engine/Graphics/GPUDevice.h" -#include "Engine/Debug/Exceptions/ArgumentOutOfRangeException.h" -#include "Engine/Debug/Exceptions/InvalidOperationException.h" +#include "Engine/Graphics/Textures/GPUTexture.h" #include "Engine/Graphics/RenderTools.h" #include "Engine/Graphics/PixelFormatExtensions.h" +#include "Engine/Debug/Exceptions/ArgumentOutOfRangeException.h" +#include "Engine/Debug/Exceptions/InvalidOperationException.h" #include "Engine/Core/Math/Color32.h" #include "Engine/Profiler/ProfilerCPU.h" #include "Engine/Content/Factories/BinaryAssetFactory.h" @@ -22,6 +23,36 @@ TextureBase::TextureBase(const SpawnParams& params, const AssetInfo* info) { } +Vector2 TextureBase::Size() const +{ + return Vector2(static_cast(_texture.TotalWidth()), static_cast(_texture.TotalHeight())); +} + +int32 TextureBase::GetArraySize() const +{ + return StreamingTexture()->TotalArraySize(); +} + +int32 TextureBase::GetMipLevels() const +{ + return StreamingTexture()->TotalMipLevels(); +} + +int32 TextureBase::GetResidentMipLevels() const +{ + return GetTexture()->ResidentMipLevels(); +} + +uint64 TextureBase::GetCurrentMemoryUsage() const +{ + return GetTexture()->GetMemoryUsage(); +} + +uint64 TextureBase::GetTotalMemoryUsage() const +{ + return StreamingTexture()->GetTotalMemoryUsage(); +} + BytesContainer TextureBase::GetMipData(int32 mipIndex, int32& rowPitch, int32& slicePitch) { BytesContainer result; @@ -193,9 +224,9 @@ int32 TextureBase::calculateChunkIndex(int32 mipIndex) const return mipIndex; } -CriticalSection* TextureBase::GetOwnerLocker() const +CriticalSection& TextureBase::GetOwnerLocker() const { - return &_parent->Locker; + return _parent->Locker; } void TextureBase::unload(bool isReloading) diff --git a/Source/Engine/Graphics/Textures/TextureBase.h b/Source/Engine/Graphics/Textures/TextureBase.h index 2cb895a23..7839f940a 100644 --- a/Source/Engine/Graphics/Textures/TextureBase.h +++ b/Source/Engine/Graphics/Textures/TextureBase.h @@ -6,6 +6,8 @@ #include "StreamingTexture.h" #include "Engine/Core/Log.h" +class TextureData; + /// /// Base class for , , and other assets that can contain texture data. /// @@ -103,50 +105,32 @@ public: /// /// Gets the total size of the texture. Actual resident size may be different due to dynamic content streaming. Returns Vector2::Zero if texture is not loaded. /// - API_PROPERTY() FORCE_INLINE Vector2 Size() const - { - return Vector2(static_cast(_texture.TotalWidth()), static_cast(_texture.TotalHeight())); - } + API_PROPERTY() Vector2 Size() const; /// /// Gets the total array size of the texture. /// - API_PROPERTY() int32 GetArraySize() const - { - return StreamingTexture()->TotalArraySize(); - } + API_PROPERTY() int32 GetArraySize() const; /// /// Gets the total mip levels count of the texture. Actual resident mipmaps count may be different due to dynamic content streaming. /// - API_PROPERTY() int32 GetMipLevels() const - { - return StreamingTexture()->TotalMipLevels(); - } + API_PROPERTY() int32 GetMipLevels() const; /// /// Gets the current mip levels count of the texture that are on GPU ready to use. /// - API_PROPERTY() int32 GetResidentMipLevels() const - { - return GetTexture()->ResidentMipLevels(); - } + API_PROPERTY() int32 GetResidentMipLevels() const; /// /// Gets the amount of the memory used by this resource. Exact value may differ due to memory alignment and resource allocation policy. /// - API_PROPERTY() uint64 GetCurrentMemoryUsage() const - { - return GetTexture()->GetMemoryUsage(); - } + API_PROPERTY() uint64 GetCurrentMemoryUsage() const; /// /// Gets the total memory usage that texture may have in use (if loaded to the maximum quality). Exact value may differ due to memory alignment and resource allocation policy. /// - API_PROPERTY() uint64 GetTotalMemoryUsage() const - { - return StreamingTexture()->GetTotalMemoryUsage(); - } + API_PROPERTY() uint64 GetTotalMemoryUsage() const; public: @@ -186,7 +170,7 @@ private: public: // [ITextureOwner] - CriticalSection* GetOwnerLocker() const override; + CriticalSection& GetOwnerLocker() const override; Task* RequestMipDataAsync(int32 mipIndex) override; FlaxStorage::LockData LockData() override; void GetMipData(int32 mipIndex, BytesContainer& data) const override; diff --git a/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.cpp b/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.cpp index d61296f49..a0b64a3bb 100644 --- a/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.cpp +++ b/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.cpp @@ -27,6 +27,7 @@ #include "Engine/Core/Utilities.h" #include "Engine/Core/Math/Color32.h" #include "Engine/Engine/Engine.h" +#include "Engine/Engine/Globals.h" #include "Engine/Engine/CommandLine.h" #include "Engine/Utilities/StringConverter.h" #include "Engine/Profiler/ProfilerCPU.h" @@ -352,7 +353,7 @@ DeferredDeletionQueueVulkan::~DeferredDeletionQueueVulkan() void DeferredDeletionQueueVulkan::ReleaseResources(bool deleteImmediately) { - ScopeLock lock(&_locker); + ScopeLock lock(_locker); const uint64 checkFrame = Engine::FrameCount - VULKAN_RESOURCE_DELETE_SAFE_FRAMES_COUNT; for (int32 i = 0; i < _entries.Count(); i++) { diff --git a/Source/Engine/Level/Actor.cpp b/Source/Engine/Level/Actor.cpp index 93f5c05c6..33d107579 100644 --- a/Source/Engine/Level/Actor.cpp +++ b/Source/Engine/Level/Actor.cpp @@ -15,6 +15,7 @@ #include "Engine/Core/Cache.h" #include "Engine/Core/Collections/CollectionPoolCache.h" #include "Engine/Debug/Exceptions/JsonParseException.h" +#include "Engine/Graphics/RenderTask.h" #include "Engine/Graphics/RenderView.h" #include "Engine/Profiler/ProfilerCPU.h" #include "Engine/Scripting/Scripting.h" diff --git a/Source/Engine/Level/Actors/AnimatedModel.cpp b/Source/Engine/Level/Actors/AnimatedModel.cpp index f0ae7017e..842621e1d 100644 --- a/Source/Engine/Level/Actors/AnimatedModel.cpp +++ b/Source/Engine/Level/Actors/AnimatedModel.cpp @@ -8,6 +8,7 @@ #include "Editor/Editor.h" #endif #include "Engine/Graphics/GPUDevice.h" +#include "Engine/Graphics/RenderTask.h" #include "Engine/Level/Scene/Scene.h" #include "Engine/Level/SceneObjectsFactory.h" #include "Engine/Serialization/Serialization.h" diff --git a/Source/Engine/Level/Actors/AnimatedModel.h b/Source/Engine/Level/Actors/AnimatedModel.h index d5d9b4424..bbced6878 100644 --- a/Source/Engine/Level/Actors/AnimatedModel.h +++ b/Source/Engine/Level/Actors/AnimatedModel.h @@ -6,6 +6,7 @@ #include "Engine/Content/Assets/SkinnedModel.h" #include "Engine/Content/Assets/AnimationGraph.h" #include "Engine/Graphics/Models/SkinnedMeshDrawData.h" +#include "Engine/Renderer/DrawCall.h" /// /// Performs an animation and renders a skinned model. diff --git a/Source/Engine/Level/Actors/Camera.cpp b/Source/Engine/Level/Actors/Camera.cpp index c37e30607..1cc7ba53b 100644 --- a/Source/Engine/Level/Actors/Camera.cpp +++ b/Source/Engine/Level/Actors/Camera.cpp @@ -5,14 +5,16 @@ #include "Engine/Core/Math/Viewport.h" #include "Engine/Content/Assets/Model.h" #include "Engine/Content/Content.h" -#include "Engine/Platform/Window.h" #include "Engine/Serialization/Serialization.h" -#include "Engine/Level/Scene/SceneRendering.h" #if USE_EDITOR #include "Editor/Editor.h" #include "Editor/Managed/ManagedEditor.h" +#include "Engine/Renderer/DrawCall.h" +#include "Engine/Graphics/RenderTask.h" +#include "Engine/Level/Scene/SceneRendering.h" #else #include "Engine/Engine/Engine.h" +#include "Engine/Platform/Window.h" #endif Array Camera::Cameras; diff --git a/Source/Engine/Level/Actors/EnvironmentProbe.cpp b/Source/Engine/Level/Actors/EnvironmentProbe.cpp index 9a2bb08a8..d5939d722 100644 --- a/Source/Engine/Level/Actors/EnvironmentProbe.cpp +++ b/Source/Engine/Level/Actors/EnvironmentProbe.cpp @@ -3,6 +3,7 @@ #include "EnvironmentProbe.h" #include "Engine/Platform/FileSystem.h" #include "Engine/Graphics/RenderView.h" +#include "Engine/Graphics/RenderTask.h" #include "Engine/Graphics/Textures/TextureData.h" #include "Engine/Renderer/RenderList.h" #include "Engine/Renderer/ProbesRenderer.h" diff --git a/Source/Engine/Level/Actors/Light.cpp b/Source/Engine/Level/Actors/Light.cpp index 56e3368b0..9f80216c5 100644 --- a/Source/Engine/Level/Actors/Light.cpp +++ b/Source/Engine/Level/Actors/Light.cpp @@ -2,6 +2,9 @@ #include "Light.h" #include "../Scene/Scene.h" +#if USE_EDITOR +#include "Engine/Graphics/RenderView.h" +#endif #include "Engine/Serialization/Serialization.h" Light::Light(const SpawnParams& params) diff --git a/Source/Engine/Level/Actors/Sky.cpp b/Source/Engine/Level/Actors/Sky.cpp index 49f46e9b9..1e35c27f0 100644 --- a/Source/Engine/Level/Actors/Sky.cpp +++ b/Source/Engine/Level/Actors/Sky.cpp @@ -4,14 +4,17 @@ #include "DirectionalLight.h" #include "Engine/Core/Math/Color.h" #include "Engine/Content/Content.h" -#include "Engine/Graphics/RenderView.h" #include "Engine/Renderer/RenderList.h" #include "Engine/Renderer/AtmospherePreCompute.h" #include "Engine/Renderer/GBufferPass.h" #include "Engine/Graphics/RenderBuffers.h" +#include "Engine/Graphics/RenderView.h" +#include "Engine/Graphics/RenderTask.h" #include "Engine/Graphics/GPUContext.h" -#include "Engine/Serialization/Serialization.h" +#include "Engine/Graphics/GPUDevice.h" #include "Engine/Graphics/Shaders/GPUConstantBuffer.h" +#include "Engine/Graphics/Shaders/GPUShader.h" +#include "Engine/Serialization/Serialization.h" #include "Engine/Level/Scene/SceneRendering.h" PACK_STRUCT(struct Data { diff --git a/Source/Engine/Level/Actors/Sky.h b/Source/Engine/Level/Actors/Sky.h index c5c81edc0..eafd8d9e6 100644 --- a/Source/Engine/Level/Actors/Sky.h +++ b/Source/Engine/Level/Actors/Sky.h @@ -9,6 +9,8 @@ #include "Engine/Renderer/Config.h" #include "Engine/Renderer/DrawCall.h" +class GPUPipelineState; + /// /// Sky actor renders atmosphere around the scene with fog and sky. /// diff --git a/Source/Engine/Level/Actors/SkyLight.cpp b/Source/Engine/Level/Actors/SkyLight.cpp index 03e1d3ca5..da7efbf31 100644 --- a/Source/Engine/Level/Actors/SkyLight.cpp +++ b/Source/Engine/Level/Actors/SkyLight.cpp @@ -3,6 +3,7 @@ #include "SkyLight.h" #include "Engine/Platform/FileSystem.h" #include "Engine/Graphics/RenderView.h" +#include "Engine/Graphics/RenderTask.h" #include "Engine/Graphics/Textures/TextureData.h" #include "Engine/Renderer/RenderList.h" #include "Engine/Renderer/ProbesRenderer.h" diff --git a/Source/Engine/Level/Actors/SplineModel.cpp b/Source/Engine/Level/Actors/SplineModel.cpp index ffa995f58..3e874f07f 100644 --- a/Source/Engine/Level/Actors/SplineModel.cpp +++ b/Source/Engine/Level/Actors/SplineModel.cpp @@ -5,9 +5,14 @@ #include "Engine/Engine/Engine.h" #include "Engine/Core/Math/Matrix3x4.h" #include "Engine/Serialization/Serialization.h" +#include "Engine/Graphics/GPUBufferDescription.h" #include "Engine/Graphics/GPUDevice.h" +#include "Engine/Graphics/GPUBuffer.h" +#include "Engine/Graphics/RenderTask.h" #include "Engine/Graphics/RenderTools.h" #include "Engine/Profiler/ProfilerCPU.h" +#include "Engine/Renderer/DrawCall.h" +#include "Engine/Renderer/RenderList.h" #if USE_EDITOR #include "Editor/Editor.h" #endif diff --git a/Source/Engine/Level/Actors/StaticModel.cpp b/Source/Engine/Level/Actors/StaticModel.cpp index 3f81b22c3..0005e74f9 100644 --- a/Source/Engine/Level/Actors/StaticModel.cpp +++ b/Source/Engine/Level/Actors/StaticModel.cpp @@ -2,7 +2,10 @@ #include "StaticModel.h" #include "Engine/Engine/Engine.h" +#include "Engine/Graphics/GPUBuffer.h" +#include "Engine/Graphics/GPUBufferDescription.h" #include "Engine/Graphics/GPUDevice.h" +#include "Engine/Graphics/RenderTask.h" #include "Engine/Serialization/Serialization.h" #include "Engine/Level/Prefabs/PrefabManager.h" #include "Engine/Level/Scene/Scene.h" diff --git a/Source/Engine/Level/Actors/StaticModel.h b/Source/Engine/Level/Actors/StaticModel.h index a255ba4ab..b3276cc83 100644 --- a/Source/Engine/Level/Actors/StaticModel.h +++ b/Source/Engine/Level/Actors/StaticModel.h @@ -4,6 +4,7 @@ #include "ModelInstanceActor.h" #include "Engine/Content/Assets/Model.h" +#include "Engine/Renderer/DrawCall.h" #include "Engine/Renderer/Lightmaps.h" /// diff --git a/Source/Engine/Level/Level.cpp b/Source/Engine/Level/Level.cpp index 613427d9f..dabb6db21 100644 --- a/Source/Engine/Level/Level.cpp +++ b/Source/Engine/Level/Level.cpp @@ -10,6 +10,7 @@ #include "Engine/Core/Collections/CollectionPoolCache.h" #include "Engine/Core/ObjectsRemovalService.h" #include "Engine/Core/Config/LayersTagsSettings.h" +#include "Engine/Core/Types/LayersMask.h" #include "Engine/Debug/Exceptions/ArgumentException.h" #include "Engine/Debug/Exceptions/ArgumentNullException.h" #include "Engine/Debug/Exceptions/InvalidOperationException.h" diff --git a/Source/Engine/Level/Level.h b/Source/Engine/Level/Level.h index 9fe9cb39b..1f7f0bb98 100644 --- a/Source/Engine/Level/Level.h +++ b/Source/Engine/Level/Level.h @@ -5,6 +5,7 @@ #include "Engine/Core/Delegate.h" #include "Engine/Core/Types/DateTime.h" #include "Engine/Core/Types/DataContainer.h" +#include "Engine/Core/Collections/Array.h" #include "Engine/Platform/CriticalSection.h" #include "Engine/Scripting/ScriptingType.h" #include "Engine/Serialization/JsonFwd.h" diff --git a/Source/Engine/Level/Prefabs/Prefab.Apply.cpp b/Source/Engine/Level/Prefabs/Prefab.Apply.cpp index a6a0edd4b..abad0c275 100644 --- a/Source/Engine/Level/Prefabs/Prefab.Apply.cpp +++ b/Source/Engine/Level/Prefabs/Prefab.Apply.cpp @@ -6,6 +6,7 @@ #include "Engine/Core/ObjectsRemovalService.h" #include "Engine/Core/Cache.h" +#include "Engine/Core/Types/TimeSpan.h" #include "Engine/Scripting/Scripting.h" #include "Engine/Scripting/Script.h" #include "Engine/Serialization/Json.h" diff --git a/Source/Engine/Level/Prefabs/Prefab.h b/Source/Engine/Level/Prefabs/Prefab.h index f5c25d273..694b50cdd 100644 --- a/Source/Engine/Level/Prefabs/Prefab.h +++ b/Source/Engine/Level/Prefabs/Prefab.h @@ -3,6 +3,7 @@ #pragma once #include "Engine/Content/JsonAsset.h" +#include "Engine/Core/Collections/Array.h" #include "Engine/Core/Collections/Dictionary.h" class Actor; @@ -15,7 +16,6 @@ class SceneObject; API_CLASS(NoSpawn) class FLAXENGINE_API Prefab : public JsonAssetBase { DECLARE_ASSET_HEADER(Prefab); - private: bool _isCreatingDefaultInstance; diff --git a/Source/Engine/Level/Scene/Lightmap.cpp b/Source/Engine/Level/Scene/Lightmap.cpp index 4a2eec796..88fa88b5a 100644 --- a/Source/Engine/Level/Scene/Lightmap.cpp +++ b/Source/Engine/Level/Scene/Lightmap.cpp @@ -6,6 +6,7 @@ #include "Engine/Content/Content.h" #include "Engine/Level/Level.h" #include "Engine/Level/Scene/SceneLightmapsData.h" +#include "Engine/Graphics/Textures/GPUTexture.h" #if USE_EDITOR #include "Engine/ContentImporters/ImportTexture.h" #include "Engine/ContentImporters/AssetsImportingManager.h" @@ -136,6 +137,14 @@ void Lightmap::EnsureSize(int32 size) } } +bool Lightmap::IsReady() const +{ + // TODO: link for events and cache this to be a boolean value + return _textures[0] && _textures[0]->GetTexture()->ResidentMipLevels() > 0 + && _textures[1] && _textures[1]->GetTexture()->ResidentMipLevels() > 0 + && _textures[2] && _textures[2]->GetTexture()->ResidentMipLevels() > 0; +} + #if USE_EDITOR bool Lightmap::OnInitLightmap(TextureData& image) diff --git a/Source/Engine/Level/Scene/Lightmap.h b/Source/Engine/Level/Scene/Lightmap.h index c4550145d..6941f4323 100644 --- a/Source/Engine/Level/Scene/Lightmap.h +++ b/Source/Engine/Level/Scene/Lightmap.h @@ -96,14 +96,7 @@ public: /// /// Determines whether this lightmap is ready (textures can be used by the renderer). /// - /// True if lightmap textures are ready to use by renderer, otherwise false. - FORCE_INLINE bool IsReady() const - { - // TODO: link for events and cache this to be a boolean value - return _textures[0] && _textures[0]->GetTexture()->ResidentMipLevels() > 0 - && _textures[1] && _textures[1]->GetTexture()->ResidentMipLevels() > 0 - && _textures[2] && _textures[2]->GetTexture()->ResidentMipLevels() > 0; - } + bool IsReady() const; private: diff --git a/Source/Engine/Level/Scene/Scene.cpp b/Source/Engine/Level/Scene/Scene.cpp index 968c6d0aa..fb9b4ce50 100644 --- a/Source/Engine/Level/Scene/Scene.cpp +++ b/Source/Engine/Level/Scene/Scene.cpp @@ -13,6 +13,9 @@ #include "Engine/Navigation/NavMesh.h" #include "Engine/Profiler/ProfilerCPU.h" #include "Engine/Serialization/Serialization.h" +#if USE_EDITOR +#include "Engine/Engine/Globals.h" +#endif REGISTER_JSON_ASSET(SceneAsset, "FlaxEngine.SceneAsset", false); diff --git a/Source/Engine/Level/Scene/SceneRendering.cpp b/Source/Engine/Level/Scene/SceneRendering.cpp index 0fb96b735..ce93b3e1c 100644 --- a/Source/Engine/Level/Scene/SceneRendering.cpp +++ b/Source/Engine/Level/Scene/SceneRendering.cpp @@ -2,6 +2,7 @@ #include "SceneRendering.h" #include "Scene.h" +#include "Engine/Graphics/RenderTask.h" #include "Engine/Graphics/RenderView.h" #include "Engine/Level/Actors/PostFxVolume.h" diff --git a/Source/Engine/Level/SceneObject.h b/Source/Engine/Level/SceneObject.h index a3ebdc71d..e3fcb8863 100644 --- a/Source/Engine/Level/SceneObject.h +++ b/Source/Engine/Level/SceneObject.h @@ -2,9 +2,9 @@ #pragma once -#include "Engine/Core/Common.h" -#include "Engine/Serialization/ISerializable.h" #include "Engine/Scripting/ScriptingObject.h" +#include "Engine/Serialization/ISerializable.h" +#include "Engine/Core/Collections/Array.h" class SceneTicking; class ScriptsFactory; diff --git a/Source/Engine/Level/SceneObjectsFactory.cpp b/Source/Engine/Level/SceneObjectsFactory.cpp index 5eca3230e..85cbc930f 100644 --- a/Source/Engine/Level/SceneObjectsFactory.cpp +++ b/Source/Engine/Level/SceneObjectsFactory.cpp @@ -10,6 +10,7 @@ #include "Engine/Serialization/ISerializeModifier.h" #include "Engine/Serialization/JsonWriters.h" #include "Engine/Profiler/ProfilerCPU.h" +#include "Engine/Threading/ThreadLocal.h" SceneObject* SceneObjectsFactory::Spawn(ISerializable::DeserializeStream& stream, ISerializeModifier* modifier) { diff --git a/Source/Engine/Localization/LocalizedStringTable.h b/Source/Engine/Localization/LocalizedStringTable.h index 53e5bd6a4..1c1b8d795 100644 --- a/Source/Engine/Localization/LocalizedStringTable.h +++ b/Source/Engine/Localization/LocalizedStringTable.h @@ -3,6 +3,7 @@ #pragma once #include "Engine/Content/JsonAsset.h" +#include "Engine/Core/Collections/Array.h" #include "Engine/Core/Collections/Dictionary.h" /// diff --git a/Source/Engine/Navigation/NavMeshData.cpp b/Source/Engine/Navigation/NavMeshData.cpp index fdf1f7aeb..3ea39e268 100644 --- a/Source/Engine/Navigation/NavMeshData.cpp +++ b/Source/Engine/Navigation/NavMeshData.cpp @@ -2,6 +2,7 @@ #include "NavMeshData.h" #include "Engine/Core/Log.h" +#include "Engine/Serialization/WriteStream.h" #include "Engine/Serialization/MemoryReadStream.h" void NavMeshData::Save(WriteStream& stream) diff --git a/Source/Engine/Navigation/NavMeshData.h b/Source/Engine/Navigation/NavMeshData.h index 806862c69..b2763abf5 100644 --- a/Source/Engine/Navigation/NavMeshData.h +++ b/Source/Engine/Navigation/NavMeshData.h @@ -3,6 +3,9 @@ #pragma once #include "Engine/Core/Types/DataContainer.h" +#include "Engine/Core/Collections/Array.h" + +class WriteStream; struct NavMeshTileDataHeader { diff --git a/Source/Engine/Particles/Graph/CPU/ParticleEmitterGraph.CPU.cpp b/Source/Engine/Particles/Graph/CPU/ParticleEmitterGraph.CPU.cpp index 2415350ed..52b159947 100644 --- a/Source/Engine/Particles/Graph/CPU/ParticleEmitterGraph.CPU.cpp +++ b/Source/Engine/Particles/Graph/CPU/ParticleEmitterGraph.CPU.cpp @@ -1,8 +1,9 @@ // Copyright (c) 2012-2021 Wojciech Figat. All rights reserved. #include "ParticleEmitterGraph.CPU.h" -#include "Engine/Content/Assets/Model.h" #include "Engine/Core/Collections/Sorting.h" +#include "Engine/Content/Assets/Model.h" +#include "Engine/Renderer/RenderList.h" #include "Engine/Particles/ParticleEffect.h" #include "Engine/Engine/Time.h" diff --git a/Source/Engine/Particles/Graph/CPU/ParticleEmitterGraph.CPU.h b/Source/Engine/Particles/Graph/CPU/ParticleEmitterGraph.CPU.h index 33423e9d7..34d7cec2e 100644 --- a/Source/Engine/Particles/Graph/CPU/ParticleEmitterGraph.CPU.h +++ b/Source/Engine/Particles/Graph/CPU/ParticleEmitterGraph.CPU.h @@ -6,7 +6,9 @@ #include "Engine/Particles/ParticlesSimulation.h" #include "Engine/Particles/ParticlesData.h" #include "Engine/Visject/VisjectGraph.h" +#include "Engine/Core/Collections/Dictionary.h" +struct RenderContext; class ParticleEffect; class ParticleEmitterGraphCPU; class ParticleEmitterGraphCPUBase; diff --git a/Source/Engine/Particles/Graph/GPU/GPUParticles.cpp b/Source/Engine/Particles/Graph/GPU/GPUParticles.cpp index 3d49efec0..6cc718a25 100644 --- a/Source/Engine/Particles/Graph/GPU/GPUParticles.cpp +++ b/Source/Engine/Particles/Graph/GPU/GPUParticles.cpp @@ -6,6 +6,8 @@ #include "Engine/Particles/ParticleEmitter.h" #include "Engine/Particles/ParticleEffect.h" #include "Engine/Graphics/RenderTask.h" +#include "Engine/Graphics/GPUDevice.h" +#include "Engine/Graphics/GPUBuffer.h" #include "Engine/Graphics/Shaders/GPUShader.h" #include "Engine/Graphics/Shaders/GPUConstantBuffer.h" diff --git a/Source/Engine/Particles/Graph/GPU/ParticleEmitterGraph.GPU.ParticleModules.cpp b/Source/Engine/Particles/Graph/GPU/ParticleEmitterGraph.GPU.ParticleModules.cpp index 3ac8ad9a0..12793c198 100644 --- a/Source/Engine/Particles/Graph/GPU/ParticleEmitterGraph.GPU.ParticleModules.cpp +++ b/Source/Engine/Particles/Graph/GPU/ParticleEmitterGraph.GPU.ParticleModules.cpp @@ -1,6 +1,7 @@ // Copyright (c) 2012-2021 Wojciech Figat. All rights reserved. #include "ParticleEmitterGraph.GPU.h" +#include "Engine/Graphics/Materials/MaterialInfo.h" #define SET_ATTRIBUTE(attribute, value) _writer.Write(TEXT("\t{0} = {1};\n"), attribute.Value, value) diff --git a/Source/Engine/Particles/Graph/GPU/ParticleEmitterGraph.GPU.Textures.cpp b/Source/Engine/Particles/Graph/GPU/ParticleEmitterGraph.GPU.Textures.cpp index e1d864b4e..35c30ce55 100644 --- a/Source/Engine/Particles/Graph/GPU/ParticleEmitterGraph.GPU.Textures.cpp +++ b/Source/Engine/Particles/Graph/GPU/ParticleEmitterGraph.GPU.Textures.cpp @@ -3,6 +3,7 @@ #if COMPILE_WITH_PARTICLE_GPU_GRAPH #include "ParticleEmitterGraph.GPU.h" +#include "Engine/Graphics/Materials/MaterialInfo.h" bool ParticleEmitterGPUGenerator::loadTexture(Node* caller, Box* box, const SerializedMaterialParam& texture, Value& result) { diff --git a/Source/Engine/Particles/Graph/GPU/ParticleEmitterGraph.GPU.cpp b/Source/Engine/Particles/Graph/GPU/ParticleEmitterGraph.GPU.cpp index 785e53ae3..72a98009c 100644 --- a/Source/Engine/Particles/Graph/GPU/ParticleEmitterGraph.GPU.cpp +++ b/Source/Engine/Particles/Graph/GPU/ParticleEmitterGraph.GPU.cpp @@ -5,6 +5,7 @@ #include "ParticleEmitterGraph.GPU.h" #include "Engine/Serialization/FileReadStream.h" #include "Engine/Visject/ShaderGraphUtilities.h" +#include "Engine/Engine/Globals.h" /// /// GPU particles shader source code template has special marks for generated code. @@ -456,7 +457,7 @@ void ParticleEmitterGPUGenerator::PrepareGraph(ParticleEmitterGraphGPU* graph) break; case VariantType::Vector4: mp.Type = MaterialParameterType::Vector4; - mp.AsVector4 = param->Value.AsVector4(); + *(Vector4*)&mp.AsData = param->Value.AsVector4(); break; case VariantType::Color: mp.Type = MaterialParameterType::Color; @@ -490,7 +491,7 @@ void ParticleEmitterGPUGenerator::PrepareGraph(ParticleEmitterGraphGPU* graph) break; case VariantType::Matrix: mp.Type = MaterialParameterType::Matrix; - mp.AsMatrix = (Matrix)param->Value; + *(Matrix*)&mp.AsData = (Matrix)param->Value; break; default: OnError(nullptr, nullptr, String::Format(TEXT("Invalid or unsupported particle parameter type {0}."), param->Type)); diff --git a/Source/Engine/Particles/ParticleEmitter.cpp b/Source/Engine/Particles/ParticleEmitter.cpp index 777c2f0f5..0b1d3fbf4 100644 --- a/Source/Engine/Particles/ParticleEmitter.cpp +++ b/Source/Engine/Particles/ParticleEmitter.cpp @@ -8,22 +8,28 @@ #include "Engine/Content/Upgraders/ShaderAssetUpgrader.h" #include "Engine/Core/Log.h" #include "Engine/Core/Types/DataContainer.h" -#include "Engine/Graphics/GPULimits.h" #include "Engine/Graphics/Shaders/Cache/ShaderCacheManager.h" -#include "Engine/Graphics/Shaders/Cache/ShaderStorage.h" #include "Engine/Level/Level.h" #include "Engine/Serialization/MemoryReadStream.h" #include "Engine/Serialization/MemoryWriteStream.h" #if USE_EDITOR #include "ParticleEmitterFunction.h" #include "Engine/ShadersCompilation/Config.h" +#if BUILD_DEBUG +#include "Engine/Engine/Globals.h" +#endif +#endif +#if COMPILE_WITH_GPU_PARTICLES +#include "Engine/Graphics/GPUDevice.h" +#include "Engine/Graphics/GPULimits.h" +#include "Engine/Graphics/Shaders/Cache/ShaderStorage.h" #endif #if COMPILE_WITH_PARTICLE_GPU_GRAPH && COMPILE_WITH_SHADER_COMPILER #include "Engine/Particles/Graph/GPU/ParticleEmitterGraph.GPU.h" #include "Engine/Utilities/Encryption.h" #endif -REGISTER_BINARY_ASSET(ParticleEmitter, "FlaxEngine.ParticleEmitter", ::New(), false); +REGISTER_BINARY_ASSET_WITH_UPGRADER(ParticleEmitter, "FlaxEngine.ParticleEmitter", ShaderAssetUpgrader, false); ParticleEmitter::ParticleEmitter(const SpawnParams& params, const AssetInfo* info) : ShaderAssetTypeBase(params, info) @@ -128,10 +134,10 @@ Asset::LoadResult ParticleEmitter::load() #if USE_EDITOR || !HasChunk(SHADER_FILE_CHUNK_SOURCE) #endif -#if COMPILE_WITH_DEV_ENV - // Set to true to enable force GPU particle simulation shaders regeneration - || false || HasDependenciesModified() +#if COMPILE_WITH_DEV_ENV + // Set to true to enable force GPU particle simulation shaders regeneration (don't commit it) + || false #endif )) { diff --git a/Source/Engine/Particles/ParticleEmitterFunction.cpp b/Source/Engine/Particles/ParticleEmitterFunction.cpp index 3dc48321b..24282f083 100644 --- a/Source/Engine/Particles/ParticleEmitterFunction.cpp +++ b/Source/Engine/Particles/ParticleEmitterFunction.cpp @@ -8,7 +8,7 @@ #endif #include "Engine/Content/Factories/BinaryAssetFactory.h" -REGISTER_BINARY_ASSET(ParticleEmitterFunction, "FlaxEngine.ParticleEmitterFunction", nullptr, false); +REGISTER_BINARY_ASSET(ParticleEmitterFunction, "FlaxEngine.ParticleEmitterFunction", false); ParticleEmitterFunction::ParticleEmitterFunction(const SpawnParams& params, const AssetInfo* info) : BinaryAsset(params, info) diff --git a/Source/Engine/Particles/ParticleManager.cpp b/Source/Engine/Particles/ParticleManager.cpp index 99ce64b73..75d39cd13 100644 --- a/Source/Engine/Particles/ParticleManager.cpp +++ b/Source/Engine/Particles/ParticleManager.cpp @@ -7,13 +7,15 @@ #include "Engine/Engine/EngineService.h" #include "Engine/Engine/Time.h" #include "Engine/Graphics/GPUBuffer.h" +#include "Engine/Graphics/GPUPipelineStatePermutations.h" #include "Engine/Graphics/RenderTask.h" +#include "Engine/Graphics/DynamicBuffer.h" #include "Engine/Profiler/ProfilerCPU.h" #include "Engine/Renderer/DrawCall.h" +#include "Engine/Renderer/RenderList.h" #include "ParticleEffect.h" #if COMPILE_WITH_GPU_PARTICLES #include "Engine/Content/Assets/Shader.h" -#include "Engine/Graphics/GPUPipelineStatePermutations.h" #include "Engine/Profiler/ProfilerGPU.h" #include "Engine/Renderer/Utils/BitonicSort.h" #endif diff --git a/Source/Engine/Particles/ParticleSystem.cpp b/Source/Engine/Particles/ParticleSystem.cpp index 63b69b132..cb6bd4061 100644 --- a/Source/Engine/Particles/ParticleSystem.cpp +++ b/Source/Engine/Particles/ParticleSystem.cpp @@ -7,7 +7,7 @@ #include "Engine/Serialization/MemoryReadStream.h" #include "Engine/Serialization/MemoryWriteStream.h" -REGISTER_BINARY_ASSET(ParticleSystem, "FlaxEngine.ParticleSystem", nullptr, true); +REGISTER_BINARY_ASSET(ParticleSystem, "FlaxEngine.ParticleSystem", true); ParticleSystem::ParticleSystem(const SpawnParams& params, const AssetInfo* info) : BinaryAsset(params, info) diff --git a/Source/Engine/Particles/ParticlesData.cpp b/Source/Engine/Particles/ParticlesData.cpp index 13840eb66..ee490d216 100644 --- a/Source/Engine/Particles/ParticlesData.cpp +++ b/Source/Engine/Particles/ParticlesData.cpp @@ -3,6 +3,8 @@ #include "ParticlesData.h" #include "ParticleEmitter.h" #include "Engine/Graphics/GPUBuffer.h" +#include "Engine/Graphics/GPUDevice.h" +#include "Engine/Graphics/DynamicBuffer.h" ParticleBuffer::ParticleBuffer() { diff --git a/Source/Engine/Particles/ParticlesData.h b/Source/Engine/Particles/ParticlesData.h index 418792cfa..edda3c507 100644 --- a/Source/Engine/Particles/ParticlesData.h +++ b/Source/Engine/Particles/ParticlesData.h @@ -4,7 +4,7 @@ #include "Engine/Core/Types/String.h" #include "Engine/Core/Types/StringView.h" -#include "Engine/Renderer/RenderList.h" +#include "Engine/Core/Collections/Array.h" #include "Types.h" // The maximum amount of particle attributes to use diff --git a/Source/Engine/Particles/ParticlesSimulation.cpp b/Source/Engine/Particles/ParticlesSimulation.cpp index 0b6e3691d..fb0e9bf74 100644 --- a/Source/Engine/Particles/ParticlesSimulation.cpp +++ b/Source/Engine/Particles/ParticlesSimulation.cpp @@ -4,6 +4,8 @@ #include "ParticleManager.h" #include "ParticleSystem.h" #include "ParticleEmitter.h" +#include "Engine/Graphics/GPUBuffer.h" +#include "Engine/Graphics/GPUDevice.h" ParticleEmitterInstance::ParticleEmitterInstance() { diff --git a/Source/Engine/Physics/Colliders/MeshCollider.cpp b/Source/Engine/Physics/Colliders/MeshCollider.cpp index 85536bc7f..5ed8da92c 100644 --- a/Source/Engine/Physics/Colliders/MeshCollider.cpp +++ b/Source/Engine/Physics/Colliders/MeshCollider.cpp @@ -2,6 +2,7 @@ #include "MeshCollider.h" #include "Engine/Core/Math/Matrix.h" +#include "Engine/Core/Math/Ray.h" #include "Engine/Serialization/Serialization.h" #include "Engine/Physics/Utilities.h" #include "Engine/Physics/Physics.h" diff --git a/Source/Engine/Physics/Colliders/SplineCollider.cpp b/Source/Engine/Physics/Colliders/SplineCollider.cpp index 7bff077e0..98665aa05 100644 --- a/Source/Engine/Physics/Colliders/SplineCollider.cpp +++ b/Source/Engine/Physics/Colliders/SplineCollider.cpp @@ -3,6 +3,7 @@ #include "SplineCollider.h" #include "Engine/Core/Log.h" #include "Engine/Core/Math/Matrix.h" +#include "Engine/Core/Math/Ray.h" #include "Engine/Level/Actors/Spline.h" #include "Engine/Serialization/Serialization.h" #include "Engine/Physics/Utilities.h" diff --git a/Source/Engine/Physics/CollisionData.cpp b/Source/Engine/Physics/CollisionData.cpp index 63822539d..a8621da09 100644 --- a/Source/Engine/Physics/CollisionData.cpp +++ b/Source/Engine/Physics/CollisionData.cpp @@ -12,7 +12,7 @@ #include #include -REGISTER_BINARY_ASSET(CollisionData, "FlaxEngine.CollisionData", nullptr, true); +REGISTER_BINARY_ASSET(CollisionData, "FlaxEngine.CollisionData", true); CollisionData::CollisionData(const SpawnParams& params, const AssetInfo* info) : BinaryAsset(params, info) diff --git a/Source/Engine/Physics/SimulationEventCallback.h b/Source/Engine/Physics/SimulationEventCallback.h index 9e0e3393e..00f610717 100644 --- a/Source/Engine/Physics/SimulationEventCallback.h +++ b/Source/Engine/Physics/SimulationEventCallback.h @@ -4,8 +4,9 @@ #include "Types.h" #include "Collisions.h" -#include "Engine/Core/Types/Pair.h" #include "Colliders/Collider.h" +#include "Engine/Core/Types/Pair.h" +#include "Engine/Core/Collections/Dictionary.h" #include /// diff --git a/Source/Engine/Platform/Android/AndroidFileSystem.cpp b/Source/Engine/Platform/Android/AndroidFileSystem.cpp index b6186d7df..0d76e34af 100644 --- a/Source/Engine/Platform/Android/AndroidFileSystem.cpp +++ b/Source/Engine/Platform/Android/AndroidFileSystem.cpp @@ -6,6 +6,7 @@ #include "Engine/Platform/File.h" #include "Engine/Core/Types/String.h" #include "Engine/Core/Types/StringView.h" +#include "Engine/Core/Types/TimeSpan.h" #include "Engine/Core/Math/Math.h" #include "Engine/Engine/Globals.h" #include "Engine/Utilities/StringConverter.h" diff --git a/Source/Engine/Platform/Base/PlatformBase.cpp b/Source/Engine/Platform/Base/PlatformBase.cpp index e33ae1499..b47f3c076 100644 --- a/Source/Engine/Platform/Base/PlatformBase.cpp +++ b/Source/Engine/Platform/Base/PlatformBase.cpp @@ -7,6 +7,7 @@ #include "Engine/Platform/FileSystem.h" #include "Engine/Core/Log.h" #include "Engine/Core/Types/DateTime.h" +#include "Engine/Core/Types/TimeSpan.h" #include "Engine/Core/Types/Guid.h" #include "Engine/Core/Types/StringBuilder.h" #include "Engine/Core/Collections/Dictionary.h" @@ -18,6 +19,7 @@ #include "Engine/Threading/Threading.h" #include "Engine/Engine/CommandLine.h" #include "Engine/Engine/Engine.h" +#include "Engine/Engine/Globals.h" #include "Engine/Utilities/StringConverter.h" #include "Engine/Platform/BatteryInfo.h" #include diff --git a/Source/Engine/Platform/Unix/UnixFile.cpp b/Source/Engine/Platform/Unix/UnixFile.cpp index 1b6516582..cbbd51b57 100644 --- a/Source/Engine/Platform/Unix/UnixFile.cpp +++ b/Source/Engine/Platform/Unix/UnixFile.cpp @@ -6,6 +6,7 @@ #include "Engine/Core/Log.h" #include "Engine/Core/Types/String.h" #include "Engine/Core/Types/DateTime.h" +#include "Engine/Core/Types/TimeSpan.h" #include "Engine/Utilities/StringConverter.h" #include "Engine/Core/Log.h" #if USE_LINUX diff --git a/Source/Engine/Platform/Win32/Win32Platform.cpp b/Source/Engine/Platform/Win32/Win32Platform.cpp index d80cc6dd7..a342b3c2c 100644 --- a/Source/Engine/Platform/Win32/Win32Platform.cpp +++ b/Source/Engine/Platform/Win32/Win32Platform.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #pragma comment(lib, "Iphlpapi.lib") namespace diff --git a/Source/Engine/Platform/Windows/WindowsPlatform.cpp b/Source/Engine/Platform/Windows/WindowsPlatform.cpp index 8bff48f18..ada4227ba 100644 --- a/Source/Engine/Platform/Windows/WindowsPlatform.cpp +++ b/Source/Engine/Platform/Windows/WindowsPlatform.cpp @@ -11,6 +11,7 @@ #include "Engine/Engine/Globals.h" #include "Engine/Core/Log.h" #include "Engine/Core/Collections/Dictionary.h" +#include "Engine/Core/Collections/Array.h" #include "Engine/Platform/MessageBox.h" #include "Engine/Engine/Engine.h" #include "../Win32/IncludeWindowsHeaders.h" diff --git a/Source/Engine/Render2D/FontAsset.cpp b/Source/Engine/Render2D/FontAsset.cpp index 8b14b1cfc..5210bc9e2 100644 --- a/Source/Engine/Render2D/FontAsset.cpp +++ b/Source/Engine/Render2D/FontAsset.cpp @@ -12,7 +12,7 @@ #include "Engine/Platform/FileSystem.h" #endif -REGISTER_BINARY_ASSET(FontAsset, "FlaxEngine.FontAsset", ::New(), false); +REGISTER_BINARY_ASSET_WITH_UPGRADER(FontAsset, "FlaxEngine.FontAsset", FontAssetUpgrader, false); FontAsset::FontAsset(const SpawnParams& params, const AssetInfo* info) : BinaryAsset(params, info) diff --git a/Source/Engine/Render2D/FontTextureAtlas.cpp b/Source/Engine/Render2D/FontTextureAtlas.cpp index c394937fd..63c547750 100644 --- a/Source/Engine/Render2D/FontTextureAtlas.cpp +++ b/Source/Engine/Render2D/FontTextureAtlas.cpp @@ -7,7 +7,7 @@ #include "Engine/Graphics/PixelFormatExtensions.h" #include "Engine/Graphics/GPUDevice.h" -REGISTER_BINARY_ASSET(FontTextureAtlas, "FlaxEngine.FontTextureAtlas", nullptr, true); +REGISTER_BINARY_ASSET(FontTextureAtlas, "FlaxEngine.FontTextureAtlas", true); FontTextureAtlas::FontTextureAtlas(const SpawnParams& params, const AssetInfo* info) : Texture(params, info) diff --git a/Source/Engine/Render2D/Render2D.cpp b/Source/Engine/Render2D/Render2D.cpp index 64517ce03..3bc438183 100644 --- a/Source/Engine/Render2D/Render2D.cpp +++ b/Source/Engine/Render2D/Render2D.cpp @@ -11,16 +11,18 @@ #include "Engine/Content/Assets/MaterialBase.h" #include "Engine/Content/Content.h" #include "Engine/Profiler/Profiler.h" -#include "Engine/Graphics/RenderTask.h" -#include "Engine/Graphics/DynamicBuffer.h" #include "Engine/Graphics/GPUContext.h" +#include "Engine/Graphics/GPUDevice.h" +#include "Engine/Graphics/GPUPipelineState.h" +#include "Engine/Graphics/RenderTask.h" +#include "Engine/Graphics/RenderTargetPool.h" +#include "Engine/Graphics/DynamicBuffer.h" +#include "Engine/Graphics/Shaders/GPUShader.h" #include "Engine/Graphics/Shaders/GPUConstantBuffer.h" #include "Engine/Animations/AnimationUtils.h" #include "Engine/Core/Math/Half.h" #include "Engine/Core/Math/Math.h" #include "Engine/Engine/EngineService.h" -#include "Engine/Graphics/GPUPipelineState.h" -#include "Engine/Graphics/RenderTargetPool.h" #if USE_EDITOR diff --git a/Source/Engine/Render2D/SpriteAtlas.cpp b/Source/Engine/Render2D/SpriteAtlas.cpp index fba2b8a06..b1a941ba1 100644 --- a/Source/Engine/Render2D/SpriteAtlas.cpp +++ b/Source/Engine/Render2D/SpriteAtlas.cpp @@ -12,7 +12,7 @@ const SpriteHandle SpriteHandle::Invalid = { nullptr, INVALID_INDEX }; -REGISTER_BINARY_ASSET(SpriteAtlas, "FlaxEngine.SpriteAtlas", ::New(), true); +REGISTER_BINARY_ASSET_WITH_UPGRADER(SpriteAtlas, "FlaxEngine.SpriteAtlas", TextureAssetUpgrader, true); bool SpriteHandle::GetSprite(Sprite* result) const { diff --git a/Source/Engine/Renderer/AmbientOcclusionPass.cpp b/Source/Engine/Renderer/AmbientOcclusionPass.cpp index 46027e118..7e4ac0d33 100644 --- a/Source/Engine/Renderer/AmbientOcclusionPass.cpp +++ b/Source/Engine/Renderer/AmbientOcclusionPass.cpp @@ -1,16 +1,18 @@ // Copyright (c) 2012-2021 Wojciech Figat. All rights reserved. #include "AmbientOcclusionPass.h" +#include "RenderList.h" +#include "GBufferPass.h" #include "Engine/Content/Assets/Shader.h" #include "Engine/Content/Content.h" #include "Engine/Graphics/Graphics.h" #include "Engine/Graphics/GPUContext.h" +#include "Engine/Graphics/GPUDevice.h" +#include "Engine/Graphics/Shaders/GPUShader.h" #include "Engine/Graphics/RenderTask.h" #include "Engine/Graphics/RenderTargetPool.h" #include "Engine/Graphics/RenderBuffers.h" #include "Engine/Utilities/StringConverter.h" -#include "RenderList.h" -#include "GBufferPass.h" AmbientOcclusionPass::ASSAO_Settings::ASSAO_Settings() { diff --git a/Source/Engine/Renderer/AntiAliasing/FXAA.cpp b/Source/Engine/Renderer/AntiAliasing/FXAA.cpp index 3dcb6ae71..1675f6193 100644 --- a/Source/Engine/Renderer/AntiAliasing/FXAA.cpp +++ b/Source/Engine/Renderer/AntiAliasing/FXAA.cpp @@ -5,6 +5,7 @@ #include "Engine/Content/Content.h" #include "Engine/Graphics/GPUContext.h" #include "Engine/Graphics/Graphics.h" +#include "Engine/Graphics/RenderTask.h" bool FXAA::Init() { diff --git a/Source/Engine/Renderer/AntiAliasing/SMAA.cpp b/Source/Engine/Renderer/AntiAliasing/SMAA.cpp index 7c1ee0c16..515d2a883 100644 --- a/Source/Engine/Renderer/AntiAliasing/SMAA.cpp +++ b/Source/Engine/Renderer/AntiAliasing/SMAA.cpp @@ -6,6 +6,7 @@ #include "Engine/Graphics/Graphics.h" #include "Engine/Graphics/GPUContext.h" #include "Engine/Graphics/RenderTargetPool.h" +#include "Engine/Graphics/RenderTask.h" bool SMAA::setupResources() { diff --git a/Source/Engine/Renderer/AntiAliasing/TAA.cpp b/Source/Engine/Renderer/AntiAliasing/TAA.cpp index a1fee93ad..e61132b42 100644 --- a/Source/Engine/Renderer/AntiAliasing/TAA.cpp +++ b/Source/Engine/Renderer/AntiAliasing/TAA.cpp @@ -7,6 +7,8 @@ #include "Engine/Graphics/GPUContext.h" #include "Engine/Graphics/RenderTargetPool.h" #include "Engine/Graphics/RenderBuffers.h" +#include "Engine/Graphics/RenderTask.h" +#include "Engine/Renderer/RenderList.h" #include "Engine/Engine/Engine.h" bool TAA::Init() diff --git a/Source/Engine/Renderer/AtmospherePreCompute.cpp b/Source/Engine/Renderer/AtmospherePreCompute.cpp index cef9964ca..d0083bfc6 100644 --- a/Source/Engine/Renderer/AtmospherePreCompute.cpp +++ b/Source/Engine/Renderer/AtmospherePreCompute.cpp @@ -6,13 +6,15 @@ #include "Engine/Content/Content.h" #include "Engine/Engine/EngineService.h" #include "Engine/Graphics/GPUContext.h" +#include "Engine/Graphics/GPUDevice.h" +#include "Engine/Graphics/GPUPipelineState.h" +#include "Engine/Graphics/RenderTask.h" +#include "Engine/Graphics/Shaders/GPUShader.h" #include "Engine/Graphics/Textures/GPUTexture.h" #include "Engine/Graphics/Textures/TextureData.h" #include "Engine/Platform/Window.h" #include "RendererPass.h" #include "Engine/Threading/ThreadPoolTask.h" -#include "Engine/Graphics/GPUPipelineState.h" -#include "Engine/Graphics/RenderTask.h" #include "Engine/Content/Assets/Shader.h" #include "Engine/Content/AssetReference.h" diff --git a/Source/Engine/Renderer/ColorGradingPass.cpp b/Source/Engine/Renderer/ColorGradingPass.cpp index c40248caa..536caf91a 100644 --- a/Source/Engine/Renderer/ColorGradingPass.cpp +++ b/Source/Engine/Renderer/ColorGradingPass.cpp @@ -1,10 +1,12 @@ // Copyright (c) 2012-2021 Wojciech Figat. All rights reserved. #include "ColorGradingPass.h" +#include "RenderList.h" #include "Engine/Content/Content.h" #include "Engine/Graphics/GPUContext.h" #include "Engine/Graphics/GPULimits.h" #include "Engine/Graphics/RenderTargetPool.h" +#include "Engine/Graphics/RenderTask.h" PACK_STRUCT(struct Data { Vector4 ColorSaturationShadows; diff --git a/Source/Engine/Renderer/DepthOfFieldPass.cpp b/Source/Engine/Renderer/DepthOfFieldPass.cpp index afa48ad13..3e5cdda92 100644 --- a/Source/Engine/Renderer/DepthOfFieldPass.cpp +++ b/Source/Engine/Renderer/DepthOfFieldPass.cpp @@ -1,15 +1,19 @@ // Copyright (c) 2012-2021 Wojciech Figat. All rights reserved. #include "DepthOfFieldPass.h" +#include "RenderList.h" #include "Engine/Content/Assets/Shader.h" #include "Engine/Content/Content.h" #include "Engine/Graphics/Textures/GPUTexture.h" #include "Engine/Graphics/GPUBuffer.h" -#include "Engine/Graphics/RenderTargetPool.h" #include "Engine/Graphics/GPUContext.h" -#include "Engine/Graphics/PostProcessBase.h" -#include "Engine/Graphics/RenderBuffers.h" +#include "Engine/Graphics/GPUDevice.h" #include "Engine/Graphics/GPULimits.h" +#include "Engine/Graphics/PostProcessBase.h" +#include "Engine/Graphics/RenderTargetPool.h" +#include "Engine/Graphics/RenderBuffers.h" +#include "Engine/Graphics/RenderTask.h" +#include "Engine/Graphics/Shaders/GPUShader.h" // This must match hlsl defines #define DOF_MAX_SAMPLE_RADIUS 10 diff --git a/Source/Engine/Renderer/Editor/LightmapUVsDensity.cpp b/Source/Engine/Renderer/Editor/LightmapUVsDensity.cpp index 9ba9f1a0d..4f1533870 100644 --- a/Source/Engine/Renderer/Editor/LightmapUVsDensity.cpp +++ b/Source/Engine/Renderer/Editor/LightmapUVsDensity.cpp @@ -5,7 +5,9 @@ #include "LightmapUVsDensity.h" #include "Engine/Content/Content.h" #include "Engine/Content/Assets/Model.h" +#include "Engine/Graphics/GPUDevice.h" #include "Engine/Graphics/GPUPipelineState.h" +#include "Engine/Graphics/Shaders/GPUShader.h" #include "Engine/Graphics/Shaders/GPUConstantBuffer.h" #include "Engine/Graphics/RenderTask.h" #include "Engine/Renderer/DrawCall.h" diff --git a/Source/Engine/Renderer/Editor/LightmapUVsDensity.h b/Source/Engine/Renderer/Editor/LightmapUVsDensity.h index 70a7b1b0e..8431fb168 100644 --- a/Source/Engine/Renderer/Editor/LightmapUVsDensity.h +++ b/Source/Engine/Renderer/Editor/LightmapUVsDensity.h @@ -9,6 +9,8 @@ #include "Engine/Content/Assets/Texture.h" #include "Engine/Graphics/Materials/IMaterial.h" +class GPUPipelineState; + /// /// Lightmap UVs Density rendering for profiling and debugging in editor. /// diff --git a/Source/Engine/Renderer/Editor/VertexColors.cpp b/Source/Engine/Renderer/Editor/VertexColors.cpp index 07bdea813..a74a70baf 100644 --- a/Source/Engine/Renderer/Editor/VertexColors.cpp +++ b/Source/Engine/Renderer/Editor/VertexColors.cpp @@ -4,7 +4,9 @@ #include "VertexColors.h" #include "Engine/Content/Content.h" +#include "Engine/Graphics/GPUDevice.h" #include "Engine/Graphics/GPUPipelineState.h" +#include "Engine/Graphics/Shaders/GPUShader.h" #include "Engine/Graphics/Shaders/GPUConstantBuffer.h" #include "Engine/Graphics/RenderTask.h" #include "Engine/Renderer/DrawCall.h" diff --git a/Source/Engine/Renderer/Editor/VertexColors.h b/Source/Engine/Renderer/Editor/VertexColors.h index 5ee726789..49e2b7c9d 100644 --- a/Source/Engine/Renderer/Editor/VertexColors.h +++ b/Source/Engine/Renderer/Editor/VertexColors.h @@ -8,6 +8,8 @@ #include "Engine/Content/Assets/Shader.h" #include "Engine/Graphics/Materials/IMaterial.h" +class GPUPipelineState; + /// /// Vertex Colors rendering for profiling and debugging in editor. /// diff --git a/Source/Engine/Renderer/EyeAdaptationPass.cpp b/Source/Engine/Renderer/EyeAdaptationPass.cpp index 3bfbb9daa..42f973c23 100644 --- a/Source/Engine/Renderer/EyeAdaptationPass.cpp +++ b/Source/Engine/Renderer/EyeAdaptationPass.cpp @@ -1,18 +1,21 @@ // Copyright (c) 2012-2021 Wojciech Figat. All rights reserved. #include "EyeAdaptationPass.h" +#include "HistogramPass.h" #include "RenderList.h" #include "Engine/Core/Math/Int2.h" #include "Engine/Content/Assets/Shader.h" #include "Engine/Content/Content.h" -#include "Engine/Graphics/PostProcessBase.h" +#include "Engine/Graphics/GPUDevice.h" #include "Engine/Graphics/GPUContext.h" +#include "Engine/Graphics/GPULimits.h" +#include "Engine/Graphics/PostProcessBase.h" +#include "Engine/Graphics/Shaders/GPUShader.h" +#include "Engine/Graphics/RenderTask.h" #include "Engine/Graphics/RenderTargetPool.h" #include "Engine/Graphics/RenderBuffers.h" -#include "Engine/Engine/Time.h" -#include "Engine/Graphics/GPULimits.h" #include "Engine/Engine/Engine.h" -#include "HistogramPass.h" +#include "Engine/Engine/Time.h" PACK_STRUCT(struct EyeAdaptationData { float MinBrightness; diff --git a/Source/Engine/Renderer/ForwardPass.cpp b/Source/Engine/Renderer/ForwardPass.cpp index 93ccf0750..83d0429e5 100644 --- a/Source/Engine/Renderer/ForwardPass.cpp +++ b/Source/Engine/Renderer/ForwardPass.cpp @@ -1,12 +1,16 @@ // Copyright (c) 2012-2021 Wojciech Figat. All rights reserved. #include "ForwardPass.h" +#include "RenderList.h" #include "Engine/Core/Collections/Sorting.h" #include "Engine/Content/Assets/Model.h" #include "Engine/Content/Assets/Shader.h" #include "Engine/Content/Content.h" +#include "Engine/Graphics/GPUDevice.h" #include "Engine/Graphics/RenderBuffers.h" #include "Engine/Graphics/RenderTargetPool.h" +#include "Engine/Graphics/RenderTask.h" +#include "Engine/Graphics/Shaders/GPUShader.h" ForwardPass::ForwardPass() : _shader(nullptr) diff --git a/Source/Engine/Renderer/GBufferPass.cpp b/Source/Engine/Renderer/GBufferPass.cpp index 2165e25dc..0791f1dc2 100644 --- a/Source/Engine/Renderer/GBufferPass.cpp +++ b/Source/Engine/Renderer/GBufferPass.cpp @@ -1,11 +1,15 @@ // Copyright (c) 2012-2021 Wojciech Figat. All rights reserved. #include "GBufferPass.h" +#include "RenderList.h" #include "Engine/Renderer/Editor/VertexColors.h" #include "Engine/Renderer/Editor/LightmapUVsDensity.h" #include "Engine/Core/Collections/Sorting.h" -#include "Engine/Graphics/RenderBuffers.h" +#include "Engine/Graphics/GPUDevice.h" #include "Engine/Graphics/GPUContext.h" +#include "Engine/Graphics/Shaders/GPUShader.h" +#include "Engine/Graphics/RenderTask.h" +#include "Engine/Graphics/RenderBuffers.h" #include "Engine/Content/Assets/Shader.h" #include "Engine/Content/Content.h" #include "Engine/Content/Assets/Model.h" diff --git a/Source/Engine/Renderer/HistogramPass.cpp b/Source/Engine/Renderer/HistogramPass.cpp index e8bfc9fad..928f0c6b3 100644 --- a/Source/Engine/Renderer/HistogramPass.cpp +++ b/Source/Engine/Renderer/HistogramPass.cpp @@ -9,6 +9,8 @@ #include "Engine/Graphics/RenderBuffers.h" #include "Engine/Graphics/GPULimits.h" #include "Engine/Engine/Engine.h" +#include "Engine/Graphics/GPUDevice.h" +#include "Engine/Graphics/Shaders/GPUShader.h" // Those defines must match the HLSL #define THREADGROUP_SIZE_X 16 diff --git a/Source/Engine/Renderer/LightPass.cpp b/Source/Engine/Renderer/LightPass.cpp index c79033c37..64219ef9c 100644 --- a/Source/Engine/Renderer/LightPass.cpp +++ b/Source/Engine/Renderer/LightPass.cpp @@ -9,6 +9,7 @@ #include "Engine/Graphics/RenderTargetPool.h" #include "Engine/Content/Assets/CubeTexture.h" #include "Engine/Content/Content.h" +#include "Engine/Graphics/RenderTask.h" PACK_STRUCT(struct PerLight{ LightData Light; diff --git a/Source/Engine/Renderer/MotionBlurPass.cpp b/Source/Engine/Renderer/MotionBlurPass.cpp index 689916708..8555676a4 100644 --- a/Source/Engine/Renderer/MotionBlurPass.cpp +++ b/Source/Engine/Renderer/MotionBlurPass.cpp @@ -3,6 +3,7 @@ #include "MotionBlurPass.h" #include "GBufferPass.h" #include "Renderer.h" +#include "RenderList.h" #include "Engine/Core/Config/GraphicsSettings.h" #include "Engine/Content/Assets/Shader.h" #include "Engine/Content/Content.h" @@ -10,6 +11,10 @@ #include "Engine/Graphics/GPULimits.h" #include "Engine/Graphics/RenderTargetPool.h" #include "Engine/Graphics/RenderBuffers.h" +#include "Engine/Graphics/GPUDevice.h" +#include "Engine/Graphics/PostProcessSettings.h" +#include "Engine/Graphics/RenderTask.h" +#include "Engine/Graphics/Shaders/GPUShader.h" #include "Engine/Engine/Time.h" PACK_STRUCT(struct Data { diff --git a/Source/Engine/Renderer/PostProcessingPass.cpp b/Source/Engine/Renderer/PostProcessingPass.cpp index 4e5b4d4fb..660e76ac5 100644 --- a/Source/Engine/Renderer/PostProcessingPass.cpp +++ b/Source/Engine/Renderer/PostProcessingPass.cpp @@ -6,6 +6,7 @@ #include "Engine/Content/Content.h" #include "Engine/Graphics/PostProcessBase.h" #include "Engine/Graphics/GPUContext.h" +#include "Engine/Graphics/RenderTask.h" #include "Engine/Graphics/RenderBuffers.h" #include "Engine/Graphics/RenderTargetPool.h" #include "Engine/Engine/Time.h" diff --git a/Source/Engine/Renderer/ProbesRenderer.cpp b/Source/Engine/Renderer/ProbesRenderer.cpp index 3f48f8c6e..0a078b4b7 100644 --- a/Source/Engine/Renderer/ProbesRenderer.cpp +++ b/Source/Engine/Renderer/ProbesRenderer.cpp @@ -14,10 +14,11 @@ #include "Engine/Level/SceneQuery.h" #include "Engine/ContentExporters/AssetExporters.h" #include "Engine/Serialization/FileWriteStream.h" -#include "Engine/Graphics/GPUContext.h" #include "Engine/Engine/Time.h" #include "Engine/Content/Assets/Shader.h" #include "Engine/Content/AssetReference.h" +#include "Engine/Graphics/GPUContext.h" +#include "Engine/Graphics/Textures/GPUTexture.h" #include "Engine/Graphics/Textures/TextureData.h" #include "Engine/Graphics/RenderTask.h" #include "Engine/Engine/Engine.h" diff --git a/Source/Engine/Renderer/ReflectionsPass.cpp b/Source/Engine/Renderer/ReflectionsPass.cpp index c3108cf0d..90214371f 100644 --- a/Source/Engine/Renderer/ReflectionsPass.cpp +++ b/Source/Engine/Renderer/ReflectionsPass.cpp @@ -2,11 +2,13 @@ #include "ReflectionsPass.h" #include "GBufferPass.h" +#include "RenderList.h" #include "ScreenSpaceReflectionsPass.h" #include "Engine/Core/Collections/Sorting.h" #include "Engine/Content/Content.h" #include "Engine/Graphics/RenderBuffers.h" #include "Engine/Graphics/RenderTools.h" +#include "Engine/Graphics/RenderTask.h" #include "Engine/Graphics/RenderTargetPool.h" #include "Engine/Level/Actors/EnvironmentProbe.h" diff --git a/Source/Engine/Renderer/Renderer.cpp b/Source/Engine/Renderer/Renderer.cpp index 89efef74c..f2abe867a 100644 --- a/Source/Engine/Renderer/Renderer.cpp +++ b/Source/Engine/Renderer/Renderer.cpp @@ -4,6 +4,7 @@ #include "Engine/Graphics/GPUContext.h" #include "Engine/Graphics/RenderTargetPool.h" #include "Engine/Graphics/RenderBuffers.h" +#include "Engine/Graphics/RenderTask.h" #include "Engine/Engine/EngineService.h" #include "GBufferPass.h" #include "ForwardPass.h" diff --git a/Source/Engine/Renderer/ScreenSpaceReflectionsPass.cpp b/Source/Engine/Renderer/ScreenSpaceReflectionsPass.cpp index 5e81db45c..bd1662773 100644 --- a/Source/Engine/Renderer/ScreenSpaceReflectionsPass.cpp +++ b/Source/Engine/Renderer/ScreenSpaceReflectionsPass.cpp @@ -3,6 +3,7 @@ #include "ScreenSpaceReflectionsPass.h" #include "ReflectionsPass.h" #include "GBufferPass.h" +#include "RenderList.h" #include "Engine/Content/Content.h" #include "Engine/Graphics/Graphics.h" #include "Engine/Graphics/RenderTools.h" @@ -12,6 +13,7 @@ #include "Engine/Platform/Window.h" #include "Utils/MultiScaler.h" #include "Engine/Engine/Engine.h" +#include "Engine/Graphics/RenderTask.h" #define REFLECTIONS_FORMAT PixelFormat::R11G11B10_Float #define RESOLVE_PASS_OUTPUT_FORMAT PixelFormat::R16G16B16A16_Float diff --git a/Source/Engine/Renderer/ShadowsPass.cpp b/Source/Engine/Renderer/ShadowsPass.cpp index 7e1504e42..3f724dfaa 100644 --- a/Source/Engine/Renderer/ShadowsPass.cpp +++ b/Source/Engine/Renderer/ShadowsPass.cpp @@ -4,9 +4,10 @@ #include "GBufferPass.h" #include "VolumetricFogPass.h" #include "Engine/Graphics/Graphics.h" +#include "Engine/Graphics/RenderTask.h" #include "Engine/Graphics/RenderBuffers.h" -#include "Engine/Content/Content.h" #include "Engine/Graphics/PixelFormatExtensions.h" +#include "Engine/Content/Content.h" #if USE_EDITOR #include "Engine/Renderer/Lightmaps.h" #endif diff --git a/Source/Engine/Renderer/ShadowsPass.h b/Source/Engine/Renderer/ShadowsPass.h index 3d3190670..6a72913f8 100644 --- a/Source/Engine/Renderer/ShadowsPass.h +++ b/Source/Engine/Renderer/ShadowsPass.h @@ -7,6 +7,7 @@ #include "RendererPass.h" #include "Engine/Content/Assets/Shader.h" #include "Engine/Content/Assets/Model.h" +#include "Engine/Graphics/RenderTask.h" /// /// Pixel format for fullscreen render target used for shadows calculations diff --git a/Source/Engine/Renderer/Utils/BitonicSort.cpp b/Source/Engine/Renderer/Utils/BitonicSort.cpp index dc67e5326..3858a7fae 100644 --- a/Source/Engine/Renderer/Utils/BitonicSort.cpp +++ b/Source/Engine/Renderer/Utils/BitonicSort.cpp @@ -2,6 +2,7 @@ #include "BitonicSort.h" #include "Engine/Content/Content.h" +#include "Engine/Graphics/GPUBuffer.h" #include "Engine/Graphics/GPULimits.h" #define INDIRECT_ARGS_STRIDE 12 diff --git a/Source/Engine/Renderer/Utils/MultiScaler.cpp b/Source/Engine/Renderer/Utils/MultiScaler.cpp index 2c6e8ba14..f38edab35 100644 --- a/Source/Engine/Renderer/Utils/MultiScaler.cpp +++ b/Source/Engine/Renderer/Utils/MultiScaler.cpp @@ -1,6 +1,7 @@ // Copyright (c) 2012-2021 Wojciech Figat. All rights reserved. #include "MultiScaler.h" +#include "Engine/Graphics/Textures/GPUTexture.h" #include "Engine/Content/Content.h" MultiScaler::MultiScaler() diff --git a/Source/Engine/Renderer/VolumetricFogPass.cpp b/Source/Engine/Renderer/VolumetricFogPass.cpp index d37fccbdb..3a5307789 100644 --- a/Source/Engine/Renderer/VolumetricFogPass.cpp +++ b/Source/Engine/Renderer/VolumetricFogPass.cpp @@ -4,6 +4,7 @@ #include "ShadowsPass.h" #include "GBufferPass.h" #include "Engine/Graphics/Graphics.h" +#include "Engine/Graphics/RenderTask.h" #include "Engine/Graphics/RenderBuffers.h" #include "Engine/Graphics/GPULimits.h" #include "Engine/Graphics/RenderTargetPool.h" diff --git a/Source/Engine/Renderer/VolumetricFogPass.h b/Source/Engine/Renderer/VolumetricFogPass.h index 52fc84a77..4c86185ff 100644 --- a/Source/Engine/Renderer/VolumetricFogPass.h +++ b/Source/Engine/Renderer/VolumetricFogPass.h @@ -6,6 +6,10 @@ #include "Engine/Graphics/GPUPipelineStatePermutations.h" #include "RendererPass.h" +struct VolumetricFogOptions; +struct RendererSpotLightData; +struct RendererPointLightData; + /// /// Volumetric fog rendering service. /// diff --git a/Source/Engine/Scripting/BinaryModule.cpp b/Source/Engine/Scripting/BinaryModule.cpp index a348b04cd..93d086af0 100644 --- a/Source/Engine/Scripting/BinaryModule.cpp +++ b/Source/Engine/Scripting/BinaryModule.cpp @@ -417,6 +417,11 @@ BinaryModule::BinaryModule() GetModules().Add(this); } +void* BinaryModule::FindMethod(const ScriptingTypeHandle& typeHandle, const ScriptingTypeMethodSignature& signature) +{ + return FindMethod(typeHandle, signature.Name, signature.Params.Count()); +} + void BinaryModule::Destroy(bool isReloading) { // Unregister diff --git a/Source/Engine/Scripting/BinaryModule.h b/Source/Engine/Scripting/BinaryModule.h index 5d470965b..572a11818 100644 --- a/Source/Engine/Scripting/BinaryModule.h +++ b/Source/Engine/Scripting/BinaryModule.h @@ -7,6 +7,7 @@ #include "Engine/Core/Types/String.h" #include "Engine/Core/Types/Variant.h" #include "Engine/Core/Collections/Dictionary.h" +#include "Engine/Core/Collections/Array.h" #include "Engine/Serialization/ISerializable.h" #include "ManagedCLR/MAssemblyOptions.h" @@ -131,10 +132,7 @@ public: /// The type to find method inside it. /// The method signature. /// The method or null if failed to get it. - virtual void* FindMethod(const ScriptingTypeHandle& typeHandle, const ScriptingTypeMethodSignature& signature) - { - return FindMethod(typeHandle, signature.Name, signature.Params.Count()); - } + virtual void* FindMethod(const ScriptingTypeHandle& typeHandle, const ScriptingTypeMethodSignature& signature); /// /// Invokes a given scripting method. diff --git a/Source/Engine/Scripting/InternalCalls.h b/Source/Engine/Scripting/InternalCalls.h index 8f8702f56..3a1c33160 100644 --- a/Source/Engine/Scripting/InternalCalls.h +++ b/Source/Engine/Scripting/InternalCalls.h @@ -5,11 +5,11 @@ #include "Engine/Debug/DebugLog.h" #include "Engine/Core/Log.h" #include "ScriptingType.h" -#include +extern "C" FLAXENGINE_API void mono_add_internal_call(const char* name, const void* method); #define ADD_INTERNAL_CALL(fullName, method) mono_add_internal_call(fullName, (const void*)method) -#if BUILD_RELEASE +#if BUILD_RELEASE && 0 // Using invalid handle will crash engine in Release build #define INTERNAL_CALL_CHECK(obj) diff --git a/Source/Engine/Scripting/ManagedCLR/MAssembly.Mono.cpp b/Source/Engine/Scripting/ManagedCLR/MAssembly.Mono.cpp index 224565429..f24429da4 100644 --- a/Source/Engine/Scripting/ManagedCLR/MAssembly.Mono.cpp +++ b/Source/Engine/Scripting/ManagedCLR/MAssembly.Mono.cpp @@ -8,6 +8,7 @@ #include "MDomain.h" #include "MUtils.h" #include "Engine/Core/Log.h" +#include "Engine/Core/Types/TimeSpan.h" #include "Engine/Platform/FileSystem.h" #include "Engine/Debug/Exceptions/InvalidOperationException.h" #include "Engine/Debug/Exceptions/FileNotFoundException.h" @@ -16,6 +17,7 @@ #include "Engine/Scripting/Scripting.h" #include "Engine/Platform/StringUtils.h" #include "Engine/Platform/File.h" +#include "Engine/Threading/Threading.h" #include #include #include diff --git a/Source/Engine/Scripting/ManagedCLR/MAssembly.h b/Source/Engine/Scripting/ManagedCLR/MAssembly.h index 17cb8b624..ff44f8b12 100644 --- a/Source/Engine/Scripting/ManagedCLR/MAssembly.h +++ b/Source/Engine/Scripting/ManagedCLR/MAssembly.h @@ -6,6 +6,7 @@ #include "MAssemblyOptions.h" #include "Engine/Core/Delegate.h" #include "Engine/Core/Types/String.h" +#include "Engine/Core/Collections/Array.h" #include "Engine/Core/Collections/Dictionary.h" #include "Engine/Platform/CriticalSection.h" diff --git a/Source/Engine/Scripting/ManagedCLR/MCore.Mono.cpp b/Source/Engine/Scripting/ManagedCLR/MCore.Mono.cpp index fc8f8ee2b..289378ffa 100644 --- a/Source/Engine/Scripting/ManagedCLR/MCore.Mono.cpp +++ b/Source/Engine/Scripting/ManagedCLR/MCore.Mono.cpp @@ -10,6 +10,7 @@ #include "Engine/Core/Types/String.h" #include "Engine/Core/Types/DateTime.h" #include "Engine/Engine/CommandLine.h" +#include "Engine/Engine/Globals.h" #include "Engine/Debug/Exceptions/Exceptions.h" #include "Engine/Threading/Threading.h" #include "Engine/Platform/Thread.h" diff --git a/Source/Engine/Scripting/ManagedCLR/MUtils.h b/Source/Engine/Scripting/ManagedCLR/MUtils.h index 2eafee53f..5171efbf7 100644 --- a/Source/Engine/Scripting/ManagedCLR/MUtils.h +++ b/Source/Engine/Scripting/ManagedCLR/MUtils.h @@ -6,6 +6,7 @@ #include "Engine/Core/Types/StringView.h" #include "Engine/Core/Types/DataContainer.h" #include "Engine/Core/Types/Variant.h" +#include "Engine/Core/Collections/Array.h" #include "Engine/Scripting/ScriptingObject.h" #include #include diff --git a/Source/Engine/Scripting/Scripting.Internal.cpp b/Source/Engine/Scripting/Scripting.Internal.cpp index 225c59b80..79e578401 100644 --- a/Source/Engine/Scripting/Scripting.Internal.cpp +++ b/Source/Engine/Scripting/Scripting.Internal.cpp @@ -9,6 +9,7 @@ #include "Engine/Scripting/ManagedCLR/MUtils.h" #include "Engine/Core/ObjectsRemovalService.h" #include "Engine/Profiler/Profiler.h" +#include "Engine/Threading/Threading.h" #include namespace ProfilerInternal diff --git a/Source/Engine/Scripting/Scripting.cpp b/Source/Engine/Scripting/Scripting.cpp index d5766ed77..8e79d6b63 100644 --- a/Source/Engine/Scripting/Scripting.cpp +++ b/Source/Engine/Scripting/Scripting.cpp @@ -6,6 +6,7 @@ #include "ScriptingType.h" #include "FlaxEngine.Gen.h" #include "Engine/Threading/Threading.h" +#include "Engine/Threading/ThreadLocal.h" #include "Engine/Threading/IRunnable.h" #include "Engine/Platform/FileSystem.h" #include "Engine/Platform/File.h" @@ -21,10 +22,12 @@ #include "MException.h" #include "Engine/Level/Level.h" #include "Engine/Core/ObjectsRemovalService.h" +#include "Engine/Core/Types/TimeSpan.h" #include "Engine/Profiler/ProfilerCPU.h" #include "Engine/Content/Asset.h" #include "Engine/Content/Content.h" #include "Engine/Engine/EngineService.h" +#include "Engine/Engine/Globals.h" #include "Engine/Graphics/RenderTask.h" #include "Engine/Serialization/JsonTools.h" #include @@ -109,7 +112,7 @@ Action Scripting::ScriptsLoaded; Action Scripting::ScriptsUnload; Action Scripting::ScriptsReloading; Action Scripting::ScriptsReloaded; -ThreadLocal Scripting::ObjectsLookupIdMapping; +ThreadLocal Scripting::ObjectsLookupIdMapping; ScriptingService ScriptingServiceInstance; bool initFlaxEngine(); @@ -224,12 +227,6 @@ MDomain* Scripting::GetRootDomain() return _monoRootDomain; } -MonoDomain* Scripting::GetMonoScriptsDomain() -{ - ASSERT(_monoScriptsDomain != nullptr); - return _monoScriptsDomain->GetNative(); -} - MDomain* Scripting::GetScriptsDomain() { return _monoScriptsDomain; diff --git a/Source/Engine/Scripting/Scripting.h b/Source/Engine/Scripting/Scripting.h index f3c7d972c..98fddfc7f 100644 --- a/Source/Engine/Scripting/Scripting.h +++ b/Source/Engine/Scripting/Scripting.h @@ -2,11 +2,12 @@ #pragma once -#include "Engine/Core/Collections/Dictionary.h" -#include "Engine/Threading/ThreadLocal.h" -#include "ScriptingObject.h" +#include "Engine/Core/Types/BaseTypes.h" +#include "Engine/Scripting/ScriptingType.h" +#include "Types.h" -class BinaryModule; +template +class ThreadLocal; /// /// Embedded managed scripting runtime service. @@ -26,41 +27,33 @@ public: /// /// Action fired on scripting engine loaded (always main thread). /// - static Action ScriptsLoaded; + static Delegate<> ScriptsLoaded; /// /// Action fired on scripting engine unloading start (always main thread). /// - static Action ScriptsUnload; + static Delegate<> ScriptsUnload; /// /// Action fired on scripting engine reload start (always main thread). /// - static Action ScriptsReloading; + static Delegate<> ScriptsReloading; /// /// Action fired on scripting engine reload start (always main thread). /// - static Action ScriptsReloaded; + static Delegate<> ScriptsReloaded; public: /// /// Gets mono root domain /// - /// The Mono root domain. static MDomain* GetRootDomain(); - /// - /// Gets mono scripts domain - /// - /// The Mono domain. - static MonoDomain* GetMonoScriptsDomain(); - /// /// Gets scripts domain /// - /// The domain. static MDomain* GetScriptsDomain(); public: @@ -123,7 +116,7 @@ public: /// /// The objects lookup identifier mapping used to override the object ids on FindObject call (used by the object references deserialization). /// - static ThreadLocal ObjectsLookupIdMapping; + static ThreadLocal ObjectsLookupIdMapping; /// /// Finds the object by the given identifier. Searches registered scene objects and optionally assets. Logs warning if fails. diff --git a/Source/Engine/Scripting/Types.h b/Source/Engine/Scripting/Types.h index 8ee3c7693..8f52524ec 100644 --- a/Source/Engine/Scripting/Types.h +++ b/Source/Engine/Scripting/Types.h @@ -6,6 +6,7 @@ class Scripting; struct ScriptingType; class BinaryModule; class ScriptingObject; +class MDomain; class MException; class MAssembly; class MClass; diff --git a/Source/Engine/Serialization/ISerializeModifier.h b/Source/Engine/Serialization/ISerializeModifier.h index bd0826933..a26af02d6 100644 --- a/Source/Engine/Serialization/ISerializeModifier.h +++ b/Source/Engine/Serialization/ISerializeModifier.h @@ -16,36 +16,10 @@ public: /// /// Number of engine build when data was serialized. Useful to upgrade data from the older storage format. /// - uint32 EngineBuild; + uint32 EngineBuild = FLAXENGINE_VERSION_BUILD; /// /// The object IDs mapping. Key is a serialized object id, value is mapped value to use. /// Dictionary IdsMapping; - -public: - - /// - /// Initializes a new instance of the class. - /// - ISerializeModifier() - : EngineBuild(FLAXENGINE_VERSION_BUILD) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The engine build. - ISerializeModifier(uint32 engineBuild) - : EngineBuild(engineBuild) - { - } - - /// - /// Finalizes an instance of the class. - /// - virtual ~ISerializeModifier() - { - } }; diff --git a/Source/Engine/Serialization/JsonWriter.cpp b/Source/Engine/Serialization/JsonWriter.cpp index de90b49b4..1a5586fd4 100644 --- a/Source/Engine/Serialization/JsonWriter.cpp +++ b/Source/Engine/Serialization/JsonWriter.cpp @@ -4,6 +4,12 @@ #include "Engine/Core/Log.h" #include "Engine/Core/Types/CommonValue.h" #include "Engine/Content/Content.h" +#include "Engine/Core/Math/Int2.h" +#include "Engine/Core/Math/Int3.h" +#include "Engine/Core/Math/Int4.h" +#include "Engine/Core/Math/Color.h" +#include "Engine/Core/Math/Plane.h" +#include "Engine/Core/Types/DateTime.h" #include "Engine/Level/Prefabs/Prefab.h" #include "Engine/Level/SceneObject.h" #include "Engine/Utilities/Encryption.h" @@ -16,6 +22,121 @@ void JsonWriter::Blob(const void* data, int32 length) String(base64.Get(), base64.Count()); } +void JsonWriter::DateTime(const ::DateTime& value) +{ + Int64(value.Ticks); +} + +void JsonWriter::Vector2(const ::Vector2& value) +{ + StartObject(); + JKEY("X"); + Float(value.X); + JKEY("Y"); + Float(value.Y); + EndObject(); +} + +void JsonWriter::Vector3(const ::Vector3& value) +{ + StartObject(); + JKEY("X"); + Float(value.X); + JKEY("Y"); + Float(value.Y); + JKEY("Z"); + Float(value.Z); + EndObject(); +} + +void JsonWriter::Vector4(const ::Vector4& value) +{ + StartObject(); + JKEY("X"); + Float(value.X); + JKEY("Y"); + Float(value.Y); + JKEY("Z"); + Float(value.Z); + JKEY("W"); + Float(value.W); + EndObject(); +} + +void JsonWriter::Int2(const ::Int2& value) +{ + StartObject(); + JKEY("X"); + Int(value.X); + JKEY("Y"); + Int(value.Y); + EndObject(); +} + +void JsonWriter::Int3(const ::Int3& value) +{ + StartObject(); + JKEY("X"); + Int(value.X); + JKEY("Y"); + Int(value.Y); + JKEY("Z"); + Int(value.Z); + EndObject(); +} + +void JsonWriter::Int4(const ::Int4& value) +{ + StartObject(); + JKEY("X"); + Int(value.X); + JKEY("Y"); + Int(value.Y); + JKEY("Z"); + Int(value.Z); + JKEY("W"); + Int(value.W); + EndObject(); +} + +void JsonWriter::Color(const ::Color& value) +{ + StartObject(); + JKEY("R"); + Float(value.R); + JKEY("G"); + Float(value.G); + JKEY("B"); + Float(value.B); + JKEY("A"); + Float(value.A); + EndObject(); +} + +void JsonWriter::Quaternion(const ::Quaternion& value) +{ + StartObject(); + JKEY("X"); + Float(value.X); + JKEY("Y"); + Float(value.Y); + JKEY("Z"); + Float(value.Z); + JKEY("W"); + Float(value.W); + EndObject(); +} + +void JsonWriter::Ray(const ::Ray& value) +{ + StartObject(); + JKEY("Position"); + Vector3(value.Position); + JKEY("Direction"); + Vector3(value.Direction); + EndObject(); +} + void JsonWriter::Matrix(const ::Matrix& value) { StartObject(); @@ -127,13 +248,95 @@ void JsonWriter::CommonValue(const ::CommonValue& value) Guid(value.GetObjectId()); break; default: - CRASH; + CRASH; break; } EndObject(); } +void JsonWriter::Transform(const ::Transform& value) +{ + StartObject(); + if (!value.Translation.IsZero()) + { + JKEY("Translation"); + Vector3(value.Translation); + } + if (!value.Orientation.IsIdentity()) + { + JKEY("Orientation"); + Quaternion(value.Orientation); + } + if (!value.Scale.IsOne()) + { + JKEY("Scale"); + Vector3(value.Scale); + } + EndObject(); +} + +void JsonWriter::Transform(const ::Transform& value, const ::Transform* other) +{ + StartObject(); + if (!other || !Vector3::NearEqual(value.Translation, other->Translation)) + { + JKEY("Translation"); + Vector3(value.Translation); + } + if (!other || !Quaternion::NearEqual(value.Orientation, other->Orientation)) + { + JKEY("Orientation"); + Quaternion(value.Orientation); + } + if (!other || !Vector3::NearEqual(value.Scale, other->Scale)) + { + JKEY("Scale"); + Vector3(value.Scale); + } + EndObject(); +} + +void JsonWriter::Plane(const ::Plane& value) +{ + StartObject(); + JKEY("Normal"); + Vector3(value.Normal); + JKEY("D"); + Float(value.D); + EndObject(); +} + +void JsonWriter::Rectangle(const ::Rectangle& value) +{ + StartObject(); + JKEY("Location"); + Vector2(value.Location); + JKEY("Size"); + Vector2(value.Size); + EndObject(); +} + +void JsonWriter::BoundingSphere(const ::BoundingSphere& value) +{ + StartObject(); + JKEY("Center"); + Vector3(value.Center); + JKEY("Radius"); + Float(value.Radius); + EndObject(); +} + +void JsonWriter::BoundingBox(const ::BoundingBox& value) +{ + StartObject(); + JKEY("Minimum"); + Vector3(value.Minimum); + JKEY("Maximum"); + Vector3(value.Maximum); + EndObject(); +} + void JsonWriter::Guid(const ::Guid& value) { // Unoptimized version: diff --git a/Source/Engine/Serialization/JsonWriter.h b/Source/Engine/Serialization/JsonWriter.h index ff73e96f0..b77b92695 100644 --- a/Source/Engine/Serialization/JsonWriter.h +++ b/Source/Engine/Serialization/JsonWriter.h @@ -4,27 +4,11 @@ #include "Engine/Core/Types/String.h" #include "Engine/Core/Types/StringView.h" -#include "Engine/Core/Types/Guid.h" -#include "Engine/Core/Types/DateTime.h" -#include "Engine/Core/Math/BoundingBox.h" -#include "Engine/Core/Math/BoundingSphere.h" -#include "Engine/Core/Math/Vector2.h" -#include "Engine/Core/Math/Vector3.h" -#include "Engine/Core/Math/Vector4.h" -#include "Engine/Core/Math/Int2.h" -#include "Engine/Core/Math/Int3.h" -#include "Engine/Core/Math/Int4.h" -#include "Engine/Core/Math/Color.h" -#include "Engine/Core/Math/Quaternion.h" -#include "Engine/Core/Math/Ray.h" -#include "Engine/Core/Math/Transform.h" -#include "Engine/Core/Math/Rectangle.h" -#include "Engine/Core/Math/Plane.h" #include "Engine/Utilities/StringConverter.h" -#include "ISerializable.h" struct CommonValue; struct Matrix; +struct Transform; class ISerializable; // Helper macro for JSON serialization keys (reduces allocations count) @@ -108,11 +92,6 @@ public: RawValue(json, StringUtils::Length(json)); } - FORCE_INLINE void DateTime(const DateTime& value) - { - Int64(value.Ticks); - } - // Raw bytes blob serialized as base64 string void Blob(const void* data, int32 length); @@ -122,217 +101,27 @@ public: Int(static_cast(value)); } - void Vector2(const Vector2& value) - { - StartObject(); - JKEY("X"); - Float(value.X); - JKEY("Y"); - Float(value.Y); - EndObject(); - } - - void Vector3(const Vector3& value) - { - StartObject(); - JKEY("X"); - Float(value.X); - JKEY("Y"); - Float(value.Y); - JKEY("Z"); - Float(value.Z); - EndObject(); - } - - void Vector4(const Vector4& value) - { - StartObject(); - JKEY("X"); - Float(value.X); - JKEY("Y"); - Float(value.Y); - JKEY("Z"); - Float(value.Z); - JKEY("W"); - Float(value.W); - EndObject(); - } - - void Int2(const Int2& value) - { - StartObject(); - JKEY("X"); - Int(value.X); - JKEY("Y"); - Int(value.Y); - EndObject(); - } - - void Int3(const Int3& value) - { - StartObject(); - JKEY("X"); - Int(value.X); - JKEY("Y"); - Int(value.Y); - JKEY("Z"); - Int(value.Z); - EndObject(); - } - - void Int4(const Int4& value) - { - StartObject(); - JKEY("X"); - Int(value.X); - JKEY("Y"); - Int(value.Y); - JKEY("Z"); - Int(value.Z); - JKEY("W"); - Int(value.W); - EndObject(); - } - - void Color(const Color& value) - { - StartObject(); - JKEY("R"); - Float(value.R); - JKEY("G"); - Float(value.G); - JKEY("B"); - Float(value.B); - JKEY("A"); - Float(value.A); - EndObject(); - } - - void Quaternion(const Quaternion& value) - { - StartObject(); - JKEY("X"); - Float(value.X); - JKEY("Y"); - Float(value.Y); - JKEY("Z"); - Float(value.Z); - JKEY("W"); - Float(value.W); - EndObject(); - } - - void Ray(const Ray& value) - { - StartObject(); - JKEY("Position"); - Vector3(value.Position); - JKEY("Direction"); - Vector3(value.Direction); - EndObject(); - } - + void DateTime(const DateTime& value); + void Vector2(const Vector2& value); + void Vector3(const Vector3& value); + void Vector4(const Vector4& value); + void Int2(const Int2& value); + void Int3(const Int3& value); + void Int4(const Int4& value); + void Color(const Color& value); + void Quaternion(const Quaternion& value); + void Ray(const Ray& value); void Matrix(const Matrix& value); void CommonValue(const CommonValue& value); - - void Transform(const ::Transform& value) - { - StartObject(); - if (!value.Translation.IsZero()) - { - JKEY("Translation"); - Vector3(value.Translation); - } - if (!value.Orientation.IsIdentity()) - { - JKEY("Orientation"); - Quaternion(value.Orientation); - } - if (!value.Scale.IsOne()) - { - JKEY("Scale"); - Vector3(value.Scale); - } - EndObject(); - } - - void Transform(const ::Transform& value, const ::Transform* other) - { - StartObject(); - if (!other || !Vector3::NearEqual(value.Translation, other->Translation)) - { - JKEY("Translation"); - Vector3(value.Translation); - } - if (!other || !Quaternion::NearEqual(value.Orientation, other->Orientation)) - { - JKEY("Orientation"); - Quaternion(value.Orientation); - } - if (!other || !Vector3::NearEqual(value.Scale, other->Scale)) - { - JKEY("Scale"); - Vector3(value.Scale); - } - EndObject(); - } - - void Plane(const Plane& value) - { - StartObject(); - JKEY("Normal"); - Vector3(value.Normal); - JKEY("D"); - Float(value.D); - EndObject(); - } - - void Rectangle(const Rectangle& value) - { - StartObject(); - JKEY("Location"); - Vector2(value.Location); - JKEY("Size"); - Vector2(value.Size); - EndObject(); - } - - void BoundingSphere(const BoundingSphere& value) - { - StartObject(); - JKEY("Center"); - Vector3(value.Center); - JKEY("Radius"); - Float(value.Radius); - EndObject(); - } - - void BoundingBox(const BoundingBox& value) - { - StartObject(); - JKEY("Minimum"); - Vector3(value.Minimum); - JKEY("Maximum"); - Vector3(value.Maximum); - EndObject(); - } - + void Transform(const ::Transform& value); + void Transform(const ::Transform& value, const ::Transform* other); + void Plane(const Plane& value); + void Rectangle(const Rectangle& value); + void BoundingSphere(const BoundingSphere& value); + void BoundingBox(const BoundingBox& value); void Guid(const Guid& value); - void Object(ISerializable* value, const void* otherObj); // Serializes scene object (handles prefab with diff serialization) void SceneObject(class SceneObject* obj); - -public: - - void Array(const ::Guid* value, int32 count) - { - StartArray(); - for (int32 i = 0; i < count; i++) - { - Guid(value[i]); - } - EndArray(count); - } }; diff --git a/Source/Engine/Serialization/Serialization.cpp b/Source/Engine/Serialization/Serialization.cpp index 30cfde962..308e39019 100644 --- a/Source/Engine/Serialization/Serialization.cpp +++ b/Source/Engine/Serialization/Serialization.cpp @@ -3,6 +3,21 @@ #include "Serialization.h" #include "Engine/Core/Types/Version.h" #include "Engine/Core/Types/Variant.h" +#include "Engine/Core/Types/DateTime.h" +#include "Engine/Core/Types/TimeSpan.h" +#include "Engine/Core/Math/Ray.h" +#include "Engine/Core/Math/Vector2.h" +#include "Engine/Core/Math/Vector3.h" +#include "Engine/Core/Math/Vector4.h" +#include "Engine/Core/Math/Quaternion.h" +#include "Engine/Core/Math/BoundingBox.h" +#include "Engine/Core/Math/BoundingSphere.h" +#include "Engine/Core/Math/Rectangle.h" +#include "Engine/Core/Math/Transform.h" +#include "Engine/Core/Math/Int2.h" +#include "Engine/Core/Math/Int3.h" +#include "Engine/Core/Math/Int4.h" +#include "Engine/Core/Math/Color.h" #include "Engine/Core/Math/Color32.h" #include "Engine/Core/Math/Matrix.h" #include "Engine/Utilities/Encryption.h" diff --git a/Source/Engine/Serialization/Serialization.h b/Source/Engine/Serialization/Serialization.h index 0a2fad106..1413525e7 100644 --- a/Source/Engine/Serialization/Serialization.h +++ b/Source/Engine/Serialization/Serialization.h @@ -165,7 +165,7 @@ namespace Serialization inline bool ShouldSerialize(const float& v, const void* otherObj) { - return !otherObj || Math::Abs(v - *(float*)otherObj) > SERIALIZE_EPSILON; + return !otherObj || abs(v - *(float*)otherObj) > SERIALIZE_EPSILON; } inline void Serialize(ISerializable::SerializeStream& stream, const float& v, const void* otherObj) { diff --git a/Source/Engine/ShadersCompilation/ShaderCompiler.cpp b/Source/Engine/ShadersCompilation/ShaderCompiler.cpp index 87401e0d0..32decb15f 100644 --- a/Source/Engine/ShadersCompilation/ShaderCompiler.cpp +++ b/Source/Engine/ShadersCompilation/ShaderCompiler.cpp @@ -5,6 +5,7 @@ #include "ShaderCompiler.h" #include "Engine/Core/Log.h" #include "Engine/Core/Collections/Dictionary.h" +#include "Engine/Engine/Globals.h" #include "Engine/Platform/File.h" #include "Engine/Platform/FileSystem.h" #include "Engine/Graphics/RenderTools.h" diff --git a/Source/Engine/ShadersCompilation/ShadersCompilation.cpp b/Source/Engine/ShadersCompilation/ShadersCompilation.cpp index 8d9907fa4..d39d2a2c5 100644 --- a/Source/Engine/ShadersCompilation/ShadersCompilation.cpp +++ b/Source/Engine/ShadersCompilation/ShadersCompilation.cpp @@ -9,6 +9,7 @@ #include "Engine/Threading/Threading.h" #include "Engine/Core/Log.h" #include "Engine/Core/Math/Math.h" +#include "Engine/Core/Types/TimeSpan.h" #include "Parser/ShaderProcessing.h" #include "Engine/Graphics/RenderTools.h" #include "Engine/Graphics/Shaders/GPUShader.h" diff --git a/Source/Engine/ShadowsOfMordor/Builder.BuildCache.cpp b/Source/Engine/ShadowsOfMordor/Builder.BuildCache.cpp index e3610d2e2..5228d7594 100644 --- a/Source/Engine/ShadowsOfMordor/Builder.BuildCache.cpp +++ b/Source/Engine/ShadowsOfMordor/Builder.BuildCache.cpp @@ -6,6 +6,9 @@ #include "Engine/Content/Content.h" #include "Engine/ContentImporters/AssetsImportingManager.h" #include "Engine/ContentImporters/ImportTexture.h" +#include "Engine/Graphics/GPUBuffer.h" +#include "Engine/Graphics/GPUBufferDescription.h" +#include "Engine/Graphics/GPUDevice.h" #include "Engine/Graphics/PixelFormatExtensions.h" ShadowsOfMordor::Builder::LightmapBuildCache::~LightmapBuildCache() diff --git a/Source/Engine/ShadowsOfMordor/Builder.Charts.cpp b/Source/Engine/ShadowsOfMordor/Builder.Charts.cpp index cae9b69e7..73b29a0ae 100644 --- a/Source/Engine/ShadowsOfMordor/Builder.Charts.cpp +++ b/Source/Engine/ShadowsOfMordor/Builder.Charts.cpp @@ -1,12 +1,12 @@ // Copyright (c) 2012-2021 Wojciech Figat. All rights reserved. #include "Builder.h" -#include "Engine/Engine/Engine.h" #include "AtlasChartsPacker.h" #include "Engine/Level/Scene/SceneLightmapsData.h" #include "Engine/Core/Math/Math.h" #include "Engine/Core/Collections/Sorting.h" #include "Engine/ContentImporters/ImportTexture.h" +#include "Engine/Graphics/GPUDevice.h" #include "Engine/Level/SceneQuery.h" #include "Engine/Level/Scene/Lightmap.h" diff --git a/Source/Engine/ShadowsOfMordor/Builder.DoWork.cpp b/Source/Engine/ShadowsOfMordor/Builder.DoWork.cpp index 0f7281dd7..fe388c039 100644 --- a/Source/Engine/ShadowsOfMordor/Builder.DoWork.cpp +++ b/Source/Engine/ShadowsOfMordor/Builder.DoWork.cpp @@ -1,11 +1,13 @@ // Copyright (c) 2012-2021 Wojciech Figat. All rights reserved. #include "Builder.h" +#include "Engine/Core/Types/TimeSpan.h" #include "Engine/Core/Math/Math.h" #include "Engine/Level/Actors/BoxBrush.h" #include "Engine/Level/SceneQuery.h" #include "Engine/Renderer/Renderer.h" #include "Engine/Graphics/RenderTargetPool.h" +#include "Engine/Engine/Globals.h" #define STEPS_SLEEP_TIME 20 #define RUN_STEP(handler) handler(); if (checkBuildCancelled()) return true; Platform::Sleep(STEPS_SLEEP_TIME) diff --git a/Source/Engine/ShadowsOfMordor/Builder.Jobs.cpp b/Source/Engine/ShadowsOfMordor/Builder.Jobs.cpp index 20c2fb325..305cc71b8 100644 --- a/Source/Engine/ShadowsOfMordor/Builder.Jobs.cpp +++ b/Source/Engine/ShadowsOfMordor/Builder.Jobs.cpp @@ -1,6 +1,7 @@ // Copyright (c) 2012-2021 Wojciech Figat. All rights reserved. #include "Builder.h" +#include "Engine/Core/Types/TimeSpan.h" #include "Engine/Engine/Engine.h" #include "Engine/Renderer/Renderer.h" #include "Engine/Level/Scene/Lightmap.h" @@ -8,9 +9,10 @@ #include "Engine/Level/Actors/BoxBrush.h" #include "Engine/Level/Scene/Scene.h" #include "Engine/Graphics/GPUContext.h" +#include "Engine/Graphics/GPUBuffer.h" +#include "Engine/Graphics/Shaders/GPUShader.h" #include "Engine/Graphics/Shaders/GPUConstantBuffer.h" #include "Engine/Graphics/RenderTargetPool.h" -#include "Engine/Graphics/PixelFormatExtensions.h" #include "Engine/Terrain/Terrain.h" #include "Engine/Terrain/TerrainPatch.h" #include "Engine/Terrain/TerrainManager.h" diff --git a/Source/Engine/ShadowsOfMordor/Builder.cpp b/Source/Engine/ShadowsOfMordor/Builder.cpp index b9cb57376..6225e36f6 100644 --- a/Source/Engine/ShadowsOfMordor/Builder.cpp +++ b/Source/Engine/ShadowsOfMordor/Builder.cpp @@ -6,10 +6,13 @@ #include "Engine/Level/Level.h" #include "Engine/Content/Content.h" #include "Engine/Engine/EngineService.h" +#include "Engine/Engine/Globals.h" #include "Engine/Threading/ThreadSpawner.h" #include "Engine/Graphics/GPUDevice.h" +#include "Engine/Graphics/GPUBuffer.h" #include "Engine/Graphics/GPUPipelineState.h" #include "Engine/Graphics/RenderTargetPool.h" +#include "Engine/Graphics/Shaders/GPUShader.h" namespace ShadowsOfMordor { diff --git a/Source/Engine/ShadowsOfMordor/Builder.h b/Source/Engine/ShadowsOfMordor/Builder.h index 7d4b9812d..c8c84f5bf 100644 --- a/Source/Engine/ShadowsOfMordor/Builder.h +++ b/Source/Engine/ShadowsOfMordor/Builder.h @@ -9,8 +9,11 @@ #if COMPILE_WITH_GI_BAKING +#include "Engine/Graphics/RenderTask.h" + // Forward declarations #if COMPILE_WITH_ASSETS_IMPORTER + namespace DirectX { class ScratchImage; @@ -20,6 +23,7 @@ class Actor; class Terrain; class Foliage; class StaticModel; +class GPUPipelineState; namespace ShadowsOfMordor { diff --git a/Source/Engine/Streaming/StreamableResource.h b/Source/Engine/Streaming/StreamableResource.h index d0cef9dd5..fab245791 100644 --- a/Source/Engine/Streaming/StreamableResource.h +++ b/Source/Engine/Streaming/StreamableResource.h @@ -26,18 +26,16 @@ protected: public: /// - /// Gets resource group + /// Gets resource group. /// - /// Streaming Group FORCE_INLINE StreamingGroup* GetGroup() const { return _group; } /// - /// Gets value indicating whenever resource can be used in dynamic streaming (otherwise use always the best quality) + /// Gets value indicating whenever resource can be used in dynamic streaming (otherwise use always the best quality). /// - /// Is dynamic streamable FORCE_INLINE bool IsDynamic() const { #if ENABLE_RESOURCES_DYNAMIC_STREAMING @@ -50,35 +48,15 @@ public: /// /// Gets resource streaming quality level /// - /// Streaming Quality level FORCE_INLINE StreamingQuality GetStreamingQuality() const { return _streamingQuality; } - /// - /// Gets resource maximum residency level. - /// - /// Residency - virtual int32 GetMaxResidency() const = 0; - - /// - /// Gets resource current residency level. - /// - /// Residency - virtual int32 GetCurrentResidency() const = 0; - - /// - /// Gets resource allocated residency level. - /// - /// Residency - virtual int32 GetAllocatedResidency() const = 0; - /// /// Gets resource target residency level. /// - /// Residency - int32 GetTargetResidency() const + FORCE_INLINE int32 GetTargetResidency() const { return Streaming.TargetResidency; } @@ -91,6 +69,21 @@ public: return GetAllocatedResidency() != 0; } + /// + /// Gets resource maximum residency level. + /// + virtual int32 GetMaxResidency() const = 0; + + /// + /// Gets resource current residency level. + /// + virtual int32 GetCurrentResidency() const = 0; + + /// + /// Gets resource allocated residency level. + /// + virtual int32 GetAllocatedResidency() const = 0; + public: /// diff --git a/Source/Engine/Terrain/Terrain.cpp b/Source/Engine/Terrain/Terrain.cpp index 502b5c4a5..2ff053432 100644 --- a/Source/Engine/Terrain/Terrain.cpp +++ b/Source/Engine/Terrain/Terrain.cpp @@ -2,7 +2,7 @@ #include "Terrain.h" #include "TerrainPatch.h" -#include "Engine/Content/Assets/RawDataAsset.h" +#include "Engine/Core/Math/Ray.h" #include "Engine/Level/Scene/SceneRendering.h" #include "Engine/Serialization/Serialization.h" #include "Engine/Physics/Physics.h" @@ -10,6 +10,7 @@ #include "Engine/Physics/PhysicalMaterial.h" #include "Engine/Graphics/RenderView.h" #include "Engine/Graphics/RenderTask.h" +#include "Engine/Graphics/Textures/GPUTexture.h" #include "Engine/Profiler/ProfilerCPU.h" #include diff --git a/Source/Engine/Terrain/TerrainChunk.cpp b/Source/Engine/Terrain/TerrainChunk.cpp index 2d0c9cfb1..ee8caf181 100644 --- a/Source/Engine/Terrain/TerrainChunk.cpp +++ b/Source/Engine/Terrain/TerrainChunk.cpp @@ -6,6 +6,8 @@ #include "Terrain.h" #include "TerrainManager.h" #include "Engine/Graphics/RenderView.h" +#include "Engine/Graphics/RenderTask.h" +#include "Engine/Graphics/Textures/GPUTexture.h" #include "Engine/Renderer/RenderList.h" #include "Engine/Core/Math/OrientedBoundingBox.h" #include "Engine/Level/Scene/Scene.h" diff --git a/Source/Engine/Terrain/TerrainPatch.cpp b/Source/Engine/Terrain/TerrainPatch.cpp index 38094fcb7..fb38b77b8 100644 --- a/Source/Engine/Terrain/TerrainPatch.cpp +++ b/Source/Engine/Terrain/TerrainPatch.cpp @@ -3,7 +3,6 @@ #include "TerrainPatch.h" #include "Terrain.h" #include "Engine/Serialization/Serialization.h" -#include "Engine/Graphics/RenderView.h" #include "Engine/Core/Math/Color32.h" #include "Engine/Profiler/ProfilerCPU.h" #include "Engine/Physics/Utilities.h" @@ -15,6 +14,8 @@ #include "Engine/Core/Math/Packed.h" #include "Engine/Graphics/PixelFormatExtensions.h" #include "Engine/Graphics/RenderTools.h" +#include "Engine/Graphics/RenderView.h" +#include "Engine/Graphics/Textures/GPUTexture.h" #include "Engine/Graphics/Textures/TextureData.h" #if USE_EDITOR #include "Editor/Editor.h" diff --git a/Source/Engine/Threading/ConcurrentQueue.h b/Source/Engine/Threading/ConcurrentQueue.h index b4e9d4306..f206a38eb 100644 --- a/Source/Engine/Threading/ConcurrentQueue.h +++ b/Source/Engine/Threading/ConcurrentQueue.h @@ -3,6 +3,7 @@ #pragma once #include "Engine/Core/Memory/Memory.h" +#define MOODYCAMEL_EXCEPTIONS_ENABLED 0 #include /// @@ -42,7 +43,6 @@ public: /// /// Gets an estimate of the total number of elements currently in the queue. /// - /// The items count. FORCE_INLINE int32 Count() const { return static_cast(Base::size_approx()); diff --git a/Source/Engine/Threading/ThreadPool.cpp b/Source/Engine/Threading/ThreadPool.cpp index ffd80d655..f16e5c2a3 100644 --- a/Source/Engine/Threading/ThreadPool.cpp +++ b/Source/Engine/Threading/ThreadPool.cpp @@ -7,11 +7,17 @@ #include "ConcurrentTaskQueue.h" #include "Engine/Core/Log.h" #include "Engine/Core/Math/Math.h" +#include "Engine/Engine/Globals.h" #include "Engine/Engine/EngineService.h" #include "Engine/Platform/ConditionVariable.h" #include "Engine/Platform/CPUInfo.h" #include "Engine/Platform/Thread.h" +FLAXENGINE_API bool IsInMainThread() +{ + return Globals::MainThreadID == Platform::GetCurrentThreadID(); +} + namespace ThreadPoolImpl { volatile int64 ExitFlag = 0; diff --git a/Source/Engine/Threading/Threading.h b/Source/Engine/Threading/Threading.h index 4de78fb28..d982232da 100644 --- a/Source/Engine/Threading/Threading.h +++ b/Source/Engine/Threading/Threading.h @@ -2,18 +2,12 @@ #pragma once -#include "Engine/Platform/Platform.h" #include "Engine/Platform/CriticalSection.h" -#include "Engine/Engine/Globals.h" /// /// Checks if current execution in on the main thread. /// -/// True if running on the main thread, otherwise false. -inline bool IsInMainThread() -{ - return Globals::MainThreadID == Platform::GetCurrentThreadID(); -} +FLAXENGINE_API bool IsInMainThread(); /// /// Scope locker for critical section. @@ -31,20 +25,9 @@ private: public: /// - /// Init, enters critical section + /// Init, enters critical section. /// - /// The synchronization object to manage - ScopeLock(const CriticalSection* section) - : _section(section) - { - ASSERT_LOW_LAYER(_section); - _section->Lock(); - } - - /// - /// Init, enters critical section - /// - /// The synchronization object to manage + /// The synchronization object to lock. ScopeLock(const CriticalSection& section) : _section(§ion) { @@ -52,7 +35,7 @@ public: } /// - /// Destructor, releases critical section + /// Destructor, releases critical section. /// ~ScopeLock() { diff --git a/Source/Engine/Tools/AudioTool/OggVorbisEncoder.cpp b/Source/Engine/Tools/AudioTool/OggVorbisEncoder.cpp index d3f4fb450..3e59e0caf 100644 --- a/Source/Engine/Tools/AudioTool/OggVorbisEncoder.cpp +++ b/Source/Engine/Tools/AudioTool/OggVorbisEncoder.cpp @@ -5,6 +5,7 @@ #include "OggVorbisEncoder.h" #include "Engine/Core/Log.h" #include "Engine/Core/Math/Math.h" +#include "Engine/Core/Collections/Array.h" #include "AudioTool.h" #include diff --git a/Source/Engine/Tools/MaterialGenerator/MaterialGenerator.Layer.cpp b/Source/Engine/Tools/MaterialGenerator/MaterialGenerator.Layer.cpp index 8f01ef271..587afd7a9 100644 --- a/Source/Engine/Tools/MaterialGenerator/MaterialGenerator.Layer.cpp +++ b/Source/Engine/Tools/MaterialGenerator/MaterialGenerator.Layer.cpp @@ -3,6 +3,8 @@ #if COMPILE_WITH_MATERIAL_GRAPH #include "MaterialGenerator.h" +#include "Engine/Core/Math/Vector4.h" +#include "Engine/Core/Math/Matrix.h" #include "Engine/Content/Assets/MaterialInstance.h" #include "Engine/Content/Assets/Material.h" #include "Engine/Serialization/MemoryReadStream.h" @@ -250,7 +252,7 @@ void MaterialGenerator::prepareLayer(MaterialLayer* layer, bool allowVisiblePara break; case VariantType::Vector4: mp.Type = MaterialParameterType::Vector4; - mp.AsVector4 = param->Value.AsVector4(); + *(Vector4*)&mp.AsData = param->Value.AsVector4(); break; case VariantType::Color: mp.Type = MaterialParameterType::Color; @@ -258,7 +260,7 @@ void MaterialGenerator::prepareLayer(MaterialLayer* layer, bool allowVisiblePara break; case VariantType::Matrix: mp.Type = MaterialParameterType::Matrix; - mp.AsMatrix = *(Matrix*)param->Value.AsBlob.Data; + *(Matrix*)&mp.AsData = *(Matrix*)param->Value.AsBlob.Data; break; case VariantType::Asset: if (!param->Type.TypeName) diff --git a/Source/Engine/Tools/MaterialGenerator/MaterialGenerator.cpp b/Source/Engine/Tools/MaterialGenerator/MaterialGenerator.cpp index fa0ae58c5..2669fae79 100644 --- a/Source/Engine/Tools/MaterialGenerator/MaterialGenerator.cpp +++ b/Source/Engine/Tools/MaterialGenerator/MaterialGenerator.cpp @@ -7,6 +7,7 @@ #include "Engine/Platform/File.h" #include "Engine/Graphics/Materials/MaterialShader.h" #include "Engine/Graphics/Materials/MaterialShaderFeatures.h" +#include "Engine/Engine/Globals.h" /// /// Material shader source code template has special marks for generated code. diff --git a/Source/Engine/Tools/ModelTool/ModelTool.cpp b/Source/Engine/Tools/ModelTool/ModelTool.cpp index d452f5f78..4fb9496d4 100644 --- a/Source/Engine/Tools/ModelTool/ModelTool.cpp +++ b/Source/Engine/Tools/ModelTool/ModelTool.cpp @@ -5,6 +5,7 @@ #include "ModelTool.h" #include "Engine/Core/Log.h" #include "Engine/Core/Types/DateTime.h" +#include "Engine/Core/Types/TimeSpan.h" #include "Engine/Core/Types/Pair.h" #include "Engine/Graphics/Models/SkeletonUpdater.h" #include "Engine/Graphics/Models/SkeletonMapping.h" diff --git a/Source/Engine/Tools/TextureTool/TextureTool.cpp b/Source/Engine/Tools/TextureTool/TextureTool.cpp index b5e22c84c..bd8970c59 100644 --- a/Source/Engine/Tools/TextureTool/TextureTool.cpp +++ b/Source/Engine/Tools/TextureTool/TextureTool.cpp @@ -5,6 +5,7 @@ #include "TextureTool.h" #include "Engine/Core/Log.h" #include "Engine/Core/Types/DateTime.h" +#include "Engine/Core/Types/TimeSpan.h" #include "Engine/Core/Math/Packed.h" #include "Engine/Core/Math/Color32.h" #include "Engine/Core/Math/Int2.h" diff --git a/Source/Engine/UI/SpriteRender.cpp b/Source/Engine/UI/SpriteRender.cpp index d2564fc84..e82c523c3 100644 --- a/Source/Engine/UI/SpriteRender.cpp +++ b/Source/Engine/UI/SpriteRender.cpp @@ -7,6 +7,7 @@ #include "Engine/Content/Content.h" #include "Engine/Content/Assets/Model.h" #include "Engine/Content/Assets/MaterialInstance.h" +#include "Engine/Graphics/RenderTask.h" #include "Engine/Level/Actors/Camera.h" #include "Engine/Serialization/Serialization.h" diff --git a/Source/Engine/Utilities/Screenshot.cpp b/Source/Engine/Utilities/Screenshot.cpp index bbf0f52d8..133824e3e 100644 --- a/Source/Engine/Utilities/Screenshot.cpp +++ b/Source/Engine/Utilities/Screenshot.cpp @@ -11,6 +11,7 @@ #include "Engine/Graphics/GPUSwapChain.h" #include "Engine/Engine/Engine.h" #include "Engine/Threading/ThreadPoolTask.h" +#include "Engine/Engine/Globals.h" #if COMPILE_WITH_TEXTURE_TOOL #include "Engine/Tools/TextureTool/TextureTool.h" #endif diff --git a/Source/Engine/Utilities/TextWriter.h b/Source/Engine/Utilities/TextWriter.h index 54f2e996a..4885bfce2 100644 --- a/Source/Engine/Utilities/TextWriter.h +++ b/Source/Engine/Utilities/TextWriter.h @@ -92,7 +92,7 @@ public: template void WriteLine(const CharType* format, const Args& ... args) { - fmt::basic_memory_buffer w; + fmt::basic_memory_buffer> w; format_to(w, format, args...); const int32 len = (int32)w.size(); _buffer.WriteBytes((void*)w.data(), len * sizeof(CharType)); @@ -132,7 +132,7 @@ public: template void Write(const CharType* format, const Args& ... args) { - fmt::basic_memory_buffer w; + fmt::basic_memory_buffer> w; format_to(w, format, args...); const int32 len = (int32)w.size(); _buffer.WriteBytes((void*)w.data(), len * sizeof(CharType)); diff --git a/Source/Engine/Visject/ShaderGraph.h b/Source/Engine/Visject/ShaderGraph.h index fe24602cc..1bcfd747a 100644 --- a/Source/Engine/Visject/ShaderGraph.h +++ b/Source/Engine/Visject/ShaderGraph.h @@ -8,6 +8,7 @@ #include "ShaderGraphValue.h" #include "Engine/Core/Collections/Dictionary.h" #include "Engine/Core/Collections/HashSet.h" +#include "Engine/Core/Math/Vector4.h" #include "Engine/Utilities/TextWriter.h" #include "Engine/Graphics/Materials/MaterialParams.h" #include "Engine/Content/AssetsContainer.h" diff --git a/Source/Engine/Visject/ShaderGraphUtilities.cpp b/Source/Engine/Visject/ShaderGraphUtilities.cpp index 079b6e602..c698164d2 100644 --- a/Source/Engine/Visject/ShaderGraphUtilities.cpp +++ b/Source/Engine/Visject/ShaderGraphUtilities.cpp @@ -5,8 +5,10 @@ #include "ShaderGraphUtilities.h" #include "ShaderGraphValue.h" #include "Engine/Core/Types/StringBuilder.h" +#include "Engine/Core/Math/Vector4.h" #include "Engine/Content/Content.h" #include "Engine/Engine/GameplayGlobals.h" +#include "Engine/Graphics/Config.h" void ShaderGraphUtilities::GenerateShaderConstantBuffer(TextWriterUnicode& writer, Array& parameters) { diff --git a/Source/ThirdParty/concurrentqueue.h b/Source/ThirdParty/concurrentqueue.h index f6c1e8481..82f0d1d59 100644 --- a/Source/ThirdParty/concurrentqueue.h +++ b/Source/ThirdParty/concurrentqueue.h @@ -63,9 +63,8 @@ #include //#include #include -#include #include -#include // for CHAR_BIT +#include // Platform-specific definitions of a numeric thread ID type and an invalid value namespace moodycamel { namespace details { @@ -154,7 +153,7 @@ namespace moodycamel { namespace details { #define MOODYCAMEL_EXCEPTIONS_ENABLED #endif #endif -#ifdef MOODYCAMEL_EXCEPTIONS_ENABLED +#if MOODYCAMEL_EXCEPTIONS_ENABLED #define MOODYCAMEL_TRY try #define MOODYCAMEL_CATCH(...) catch(__VA_ARGS__) #define MOODYCAMEL_RETHROW throw diff --git a/Source/ThirdParty/fmt/core.h b/Source/ThirdParty/fmt/core.h index 77b113a0a..acb7efa6f 100644 --- a/Source/ThirdParty/fmt/core.h +++ b/Source/ThirdParty/fmt/core.h @@ -11,6 +11,7 @@ // Custom configuration for Flax #include "Engine/Platform/Platform.h" #include "Engine/Platform/StringUtils.h" +#include "Engine/Core/Memory/StlWrapper.h" #define FMT_USE_CONSTEXPR11 0 #define FMT_USE_USER_DEFINED_LITERALS 0 #define FMT_USE_WINDOWS_H 0 @@ -38,10 +39,9 @@ namespace fmt { using back_inserter = std::back_inserter<_Container>; }; #else -#include namespace fmt { // std::back_insert_iterator impl to not include -template +template struct iterator { typedef _Category iterator_category; diff --git a/Source/ThirdParty/fmt/format-inl.h b/Source/ThirdParty/fmt/format-inl.h index c4e06f711..092afc77f 100644 --- a/Source/ThirdParty/fmt/format-inl.h +++ b/Source/ThirdParty/fmt/format-inl.h @@ -154,43 +154,6 @@ int safe_strerror( }; return dispatcher(error_code, buffer, buffer_size).run(); } - -void format_error_code(internal::buffer &out, int error_code, - string_view message) FMT_NOEXCEPT { - // Report error code making sure that the output fits into - // inline_buffer_size to avoid dynamic memory allocation and potential - // bad_alloc. - out.resize(0); - static const char SEP[] = ": "; - static const char ERROR_STR[] = "error "; - // Subtract 2 to account for terminating null characters in SEP and ERROR_STR. - std::size_t error_code_size = sizeof(SEP) + sizeof(ERROR_STR) - 2; - typedef internal::int_traits::main_type main_type; - main_type abs_value = static_cast(error_code); - if (internal::is_negative(error_code)) { - abs_value = 0 - abs_value; - ++error_code_size; - } - error_code_size += internal::to_unsigned(internal::count_digits(abs_value)); - writer w(out); - if (message.size() <= inline_buffer_size - error_code_size) { - w.write(message); - w.write(SEP); - } - w.write(ERROR_STR); - w.write(error_code); - FMT_ASSERT(out.size() <= inline_buffer_size, "invalid buffer size"); -} - -void report_error(FormatFunc func, int error_code, - string_view message) FMT_NOEXCEPT { - memory_buffer full_message; - func(full_message, error_code, message); - // Use Writer::data instead of Writer::c_str to avoid potential memory - // allocation. - std::fwrite(full_message.data(), full_message.size(), 1, stderr); - std::fputc('\n', stderr); -} } // namespace FMT_FUNC size_t internal::count_code_points(basic_string_view s) { diff --git a/Source/ThirdParty/fmt/format.h b/Source/ThirdParty/fmt/format.h index 0b35daf4e..dd21d8ff7 100644 --- a/Source/ThirdParty/fmt/format.h +++ b/Source/ThirdParty/fmt/format.h @@ -29,7 +29,6 @@ #define FMT_FORMAT_H_ #include -#include #include #ifdef __clang__ @@ -146,11 +145,6 @@ FMT_END_NAMESPACE # define FMT_USE_TRAILING_RETURN 0 #endif -#ifndef FMT_USE_GRISU -# define FMT_USE_GRISU 0 -//# define FMT_USE_GRISU std::numeric_limits::is_iec559 -#endif - // __builtin_clz is broken in clang with Microsoft CodeGen: // https://github.com/fmtlib/fmt/issues/519 #ifndef _MSC_VER @@ -167,7 +161,10 @@ FMT_END_NAMESPACE // __builtin_clz and __builtin_clzll, so only define FMT_BUILTIN_CLZ using the // MSVC intrinsics if the clz and clzll builtins are not available. #if FMT_MSC_VER && !defined(FMT_BUILTIN_CLZLL) && !defined(_MANAGED) -# include // _BitScanReverse, _BitScanReverse64 +unsigned char _BitScanReverse(unsigned long* Index, unsigned long Mask); +# ifdef _WIN64 +unsigned char _BitScanReverse64(unsigned long* Index, unsigned __int64 Mask); +#endif FMT_BEGIN_NAMESPACE namespace internal { @@ -250,26 +247,9 @@ struct function { struct result { typedef Result type; }; }; -struct dummy_int { - int data[2]; - operator int() const { return 0; } -}; -typedef std::numeric_limits fputil; - -// Dummy implementations of system functions called if the latter are not -// available. -inline dummy_int isinf(...) { return dummy_int(); } -inline dummy_int _finite(...) { return dummy_int(); } -inline dummy_int isnan(...) { return dummy_int(); } -inline dummy_int _isnan(...) { return dummy_int(); } - template typename Allocator::value_type *allocate(Allocator& alloc, std::size_t n) { -#if __cplusplus >= 201103L || FMT_MSC_VER >= 1700 - return std::allocator_traits::allocate(alloc, n); -#else return alloc.allocate(n); -#endif } // A helper function to suppress bogus "conditional expression is constant" @@ -277,40 +257,7 @@ typename Allocator::value_type *allocate(Allocator& alloc, std::size_t n) { template inline T const_check(T value) { return value; } } // namespace internal -FMT_END_NAMESPACE -namespace std { -// Standard permits specialization of std::numeric_limits. This specialization -// is used to resolve ambiguity between isinf and std::isinf in glibc: -// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48891 -// and the same for isnan. -template <> -class numeric_limits : - public std::numeric_limits { - public: - // Portable version of isinf. - template - static bool isinfinity(T x) { - using namespace fmt::internal; - // The resolution "priority" is: - // isinf macro > std::isinf > ::isinf > fmt::internal::isinf - if (const_check(sizeof(isinf(x)) != sizeof(fmt::internal::dummy_int))) - return isinf(x) != 0; - return !_finite(static_cast(x)); - } - - // Portable version of isnan. - template - static bool isnotanumber(T x) { - using namespace fmt::internal; - if (const_check(sizeof(isnan(x)) != sizeof(fmt::internal::dummy_int))) - return isnan(x) != 0; - return _isnan(static_cast(x)) != 0; - } -}; -} // namespace std - -FMT_BEGIN_NAMESPACE template class basic_writer; @@ -346,22 +293,7 @@ class back_insert_range: typedef basic_writer> writer; typedef basic_writer> wwriter; -#if FMT_EXCEPTIONS -/** A formatting error such as invalid format string. */ -class format_error : public std::runtime_error { - public: - explicit format_error(const char *message) - : std::runtime_error(message) {} - -#if FMT_USE_STRING - explicit format_error(const std::string &message) - : std::runtime_error(message) {} -#endif -}; -#define FMT_THROW_FORMAT_ERROR(x) FMT_THROW(format_error(x)) -#else #define FMT_THROW_FORMAT_ERROR(x) FMT_THROW(x) -#endif namespace internal { @@ -447,7 +379,7 @@ enum { inline_buffer_size = 500 }; \endrst */ template > + typename Allocator = std_flax::allocator> class basic_memory_buffer: private Allocator, public internal::basic_buffer { private: T store_[SIZE]; @@ -588,143 +520,9 @@ inline typename std::enable_if< template inline Iterator &reserve(Iterator &it, std::size_t) { return it; } -template -class null_terminating_iterator; - -template -FMT_CONSTEXPR_DECL const Char *pointer_from(null_terminating_iterator it); - -// An output iterator that counts the number of objects written to it and -// discards them. -template -class counting_iterator { - private: - std::size_t count_; - mutable T blackhole_; - - public: - typedef std::output_iterator_tag iterator_category; - typedef T value_type; - typedef std::ptrdiff_t difference_type; - typedef T* pointer; - typedef T& reference; - typedef counting_iterator _Unchecked_type; // Mark iterator as checked. - - counting_iterator(): count_(0) {} - - std::size_t count() const { return count_; } - - counting_iterator& operator++() { - ++count_; - return *this; - } - - counting_iterator operator++(int) { - auto it = *this; - ++*this; - return it; - } - - T &operator*() const { return blackhole_; } -}; - -template -class truncating_iterator_base { - protected: - OutputIt out_; - std::size_t limit_; - std::size_t count_; - - truncating_iterator_base(OutputIt out, std::size_t limit) - : out_(out), limit_(limit), count_(0) {} - - public: - typedef std::output_iterator_tag iterator_category; - typedef void difference_type; - typedef void pointer; - typedef void reference; - typedef truncating_iterator_base _Unchecked_type; // Mark iterator as checked. - - OutputIt base() const { return out_; } - std::size_t count() const { return count_; } -}; - -// An output iterator that truncates the output and counts the number of objects -// written to it. -template ::value_type>::type> -class truncating_iterator; - -template -class truncating_iterator: - public truncating_iterator_base { - typedef std::iterator_traits traits; - - mutable typename traits::value_type blackhole_; - - public: - typedef typename traits::value_type value_type; - - truncating_iterator(OutputIt out, std::size_t limit) - : truncating_iterator_base(out, limit) {} - - truncating_iterator& operator++() { - if (this->count_++ < this->limit_) - ++this->out_; - return *this; - } - - truncating_iterator operator++(int) { - auto it = *this; - ++*this; - return it; - } - - value_type& operator*() const { - return this->count_ < this->limit_ ? *this->out_ : blackhole_; - } -}; - -template -class truncating_iterator: - public truncating_iterator_base { - public: - typedef typename OutputIt::container_type::value_type value_type; - - truncating_iterator(OutputIt out, std::size_t limit) - : truncating_iterator_base(out, limit) {} - - truncating_iterator& operator=(value_type val) { - if (this->count_++ < this->limit_) - this->out_ = val; - return *this; - } - - truncating_iterator& operator++() { return *this; } - truncating_iterator& operator++(int) { return *this; } - truncating_iterator& operator*() { return *this; } -}; - // Returns true if value is negative, false otherwise. -// Same as (value < 0) but doesn't produce warnings if T is an unsigned type. template -FMT_CONSTEXPR typename std::enable_if< - std::numeric_limits::is_signed, bool>::type is_negative(T value) { - return value < 0; -} -template -FMT_CONSTEXPR typename std::enable_if< - !std::numeric_limits::is_signed, bool>::type is_negative(T) { - return false; -} - -template -struct int_traits { - // Smallest of uint32_t and uint64_t that is large enough to represent - // all values of T. - typedef typename std::conditional< - std::numeric_limits::digits <= 32, uint32_t, uint64_t>::type main_type; -}; +FMT_CONSTEXPR bool is_negative(T value) { return value < (T)0; } // Static data is placed in this class template to allow header-only // configuration. @@ -778,10 +576,19 @@ FMT_API size_t count_code_points(basic_string_view s); inline char8_t to_char8_t(char c) { return static_cast(c); } +template +struct iterator_traits { + typedef typename Iterator::value_type value_type; +}; +template +struct iterator_traits { + typedef T value_type; +}; + template struct needs_conversion: std::integral_constant::value_type, char>::value && + typename iterator_traits::value_type, char>::value && std::is_same::value> {}; template @@ -971,7 +778,7 @@ inline Iterator format_decimal( FMT_ASSERT(num_digits >= 0, "invalid digit count"); typedef typename ThousandsSep::char_type char_type; // Buffer should be large enough to hold all digits (<= digits10 + 1). - enum { max_size = std::numeric_limits::digits10 + 1 }; + enum { max_size = 19 + 1 }; FMT_ASSERT(ThousandsSep::size <= 1, "invalid separator"); char_type buffer[max_size + max_size / 3]; auto end = format_decimal(buffer, value, num_digits, sep); @@ -1002,60 +809,11 @@ inline It format_uint(It out, UInt value, int num_digits, bool upper = false) { // Buffer should be large enough to hold all digits (digits / BASE_BITS + 1) // and null. - char buffer[std::numeric_limits::digits / BASE_BITS + 2]; + char buffer[64 / BASE_BITS + 2]; format_uint(buffer, value, num_digits, upper); return internal::copy_str(buffer, buffer + num_digits, out); } -#ifndef _WIN32 -# define FMT_USE_WINDOWS_H 0 -#elif !defined(FMT_USE_WINDOWS_H) -# define FMT_USE_WINDOWS_H 1 -#endif - -// Define FMT_USE_WINDOWS_H to 0 to disable use of windows.h. -// All the functionality that relies on it will be disabled too. -#if FMT_USE_WINDOWS_H -// A converter from UTF-8 to UTF-16. -// It is only provided for Windows since other systems support UTF-8 natively. -class utf8_to_utf16 { - private: - wmemory_buffer buffer_; - - public: - FMT_API explicit utf8_to_utf16(string_view s); - operator wstring_view() const { return wstring_view(&buffer_[0], size()); } - size_t size() const { return buffer_.size() - 1; } - const wchar_t *c_str() const { return &buffer_[0]; } - std::wstring str() const { return std::wstring(&buffer_[0], size()); } -}; - -// A converter from UTF-16 to UTF-8. -// It is only provided for Windows since other systems support UTF-8 natively. -class utf16_to_utf8 { - private: - memory_buffer buffer_; - - public: - utf16_to_utf8() {} - FMT_API explicit utf16_to_utf8(wstring_view s); - operator string_view() const { return string_view(&buffer_[0], size()); } - size_t size() const { return buffer_.size() - 1; } - const char *c_str() const { return &buffer_[0]; } -#if FMT_USE_STRING - std::string str() const { return std::string(&buffer_[0], size()); } -#endif - - // Performs conversion returning a system error code instead of - // throwing exception on conversion error. This method may still throw - // in case of memory allocation error. - FMT_API int convert(wstring_view s); -}; - -FMT_API void format_windows_error(fmt::internal::buffer &out, int error_code, - fmt::string_view message) FMT_NOEXCEPT; -#endif - template struct null {}; } // namespace internal @@ -1444,7 +1202,7 @@ FMT_CONSTEXPR unsigned parse_nonnegative_int( } unsigned value = 0; // Convert to unsigned to prevent a warning. - unsigned max_int = (std::numeric_limits::max)(); + unsigned max_int = MAX_int32; unsigned big = max_int / 10; do { // Check for overflow. @@ -1639,7 +1397,7 @@ FMT_CONSTEXPR void set_dynamic_spec( T &value, basic_format_arg arg, ErrorHandler eh) { unsigned long long big_value = visit_format_arg(Handler(eh), arg); - if (big_value > to_unsigned((std::numeric_limits::max)())) + if (big_value > to_unsigned(MAX_int32)) eh.on_error("number is too big"); value = static_cast(big_value); } @@ -2045,7 +1803,7 @@ class format_string_checker { public: explicit FMT_CONSTEXPR format_string_checker( basic_string_view format_str, ErrorHandler eh) - : arg_id_((std::numeric_limits::max)()), context_(format_str, eh), + : arg_id_(MAX_uint32), context_(format_str, eh), parse_funcs_{&parse_format_specs...} {} FMT_CONSTEXPR void on_text(const Char *, const Char *) {} @@ -2271,7 +2029,7 @@ class basic_writer { // Writes a decimal integer. template void write_decimal(Int value) { - typedef typename internal::int_traits::main_type main_type; + typedef uint64_t main_type; main_type abs_value = static_cast(value); bool is_negative = internal::is_negative(value); if (is_negative) @@ -2286,7 +2044,7 @@ class basic_writer { // The handle_int_type_spec handler that writes an integer. template struct int_writer { - typedef typename internal::int_traits::main_type unsigned_type; + typedef uint64_t unsigned_type; basic_writer &writer; const Spec &spec; @@ -2645,20 +2403,15 @@ void basic_writer::write_double(T value, const format_specs &spec) { // Format NaN and ininity ourselves because sprintf's output is not consistent // across platforms. - if (internal::fputil::isnotanumber(value)) + if (::isnan(value)) return write_inf_or_nan(handler.upper ? "NAN" : "nan"); - if (internal::fputil::isinfinity(value)) + if (::isinf(value)) return write_inf_or_nan(handler.upper ? "INF" : "inf"); memory_buffer buffer; - bool use_grisu = FMT_USE_GRISU && sizeof(T) <= sizeof(double) && - spec.type != 'a' && spec.type != 'A' && - internal::grisu2_format(static_cast(value), buffer, spec); - if (!use_grisu) { - format_specs normalized_spec(spec); - normalized_spec.type = handler.type; - internal::sprintf_format(value, buffer, normalized_spec); - } + format_specs normalized_spec(spec); + normalized_spec.type = handler.type; + internal::sprintf_format(value, buffer, normalized_spec); size_t n = buffer.size(); align_spec as = spec; if (spec.align() == ALIGN_NUMERIC) { @@ -2684,7 +2437,7 @@ class format_int { private: // Buffer should be large enough to hold all digits (digits10 + 1), // a sign and a null character. - enum {BUFFER_SIZE = std::numeric_limits::digits10 + 3}; + enum {BUFFER_SIZE = 19 + 3}; mutable char buffer_[BUFFER_SIZE]; char *str_; @@ -2764,7 +2517,7 @@ class format_int { // write a terminating null character. template inline void format_decimal(char *&buffer, T value) { - typedef typename internal::int_traits::main_type main_type; + typedef uint64_t main_type; main_type abs_value = static_cast(value); if (internal::is_negative(value)) { *buffer++ = '-'; @@ -2861,69 +2614,6 @@ struct formatter< internal::dynamic_format_specs specs_; }; -// A formatter for types known only at run time such as variant alternatives. -// -// Usage: -// typedef std::variant variant; -// template <> -// struct formatter: dynamic_formatter<> { -// void format(buffer &buf, const variant &v, context &ctx) { -// visit([&](const auto &val) { format(buf, val, ctx); }, v); -// } -// }; -template -class dynamic_formatter { - private: - struct null_handler: internal::error_handler { - void on_align(alignment) {} - void on_plus() {} - void on_minus() {} - void on_space() {} - void on_hash() {} - }; - - public: - template - auto parse(ParseContext &ctx) -> decltype(ctx.begin()) { - // Checks are deferred to formatting time when the argument type is known. - internal::dynamic_specs_handler handler(specs_, ctx); - return parse_format_specs(ctx.begin(), ctx.end(), handler); - } - - template - auto format(const T &val, FormatContext &ctx) -> decltype(ctx.out()) { - handle_specs(ctx); - internal::specs_checker - checker(null_handler(), internal::get_type::value); - checker.on_align(specs_.align()); - if (specs_.flags == 0); // Do nothing. - else if (specs_.has(SIGN_FLAG)) - specs_.has(PLUS_FLAG) ? checker.on_plus() : checker.on_space(); - else if (specs_.has(MINUS_FLAG)) - checker.on_minus(); - else if (specs_.has(HASH_FLAG)) - checker.on_hash(); - if (specs_.precision != -1) - checker.end_precision(); - typedef output_range range; - visit_format_arg(arg_formatter(ctx, &specs_), - internal::make_arg(val)); - return ctx.out(); - } - - private: - template - void handle_specs(Context &ctx) { - internal::handle_dynamic_spec( - specs_.width_, specs_.width_ref, ctx); - internal::handle_dynamic_spec( - specs_.precision, specs_.precision_ref, ctx); - } - - internal::dynamic_format_specs specs_; -}; - template typename basic_format_context::format_arg basic_format_context::get_arg( @@ -3002,106 +2692,6 @@ typename Context::iterator vformat_to( return h.context.out(); } -// Casts ``p`` to ``const void*`` for pointer formatting. -// Example: -// auto s = format("{}", ptr(p)); -template -inline const void *ptr(const T *p) { return p; } - -template -struct arg_join { - It begin; - It end; - basic_string_view sep; - - arg_join(It begin, It end, basic_string_view sep) - : begin(begin), end(end), sep(sep) {} -}; - -template -struct formatter, Char>: - formatter::value_type, Char> { - template - auto format(const arg_join &value, FormatContext &ctx) - -> decltype(ctx.out()) { - typedef formatter::value_type, Char> base; - auto it = value.begin; - auto out = ctx.out(); - if (it != value.end) { - out = base::format(*it++, ctx); - while (it != value.end) { - out = internal::copy(value.sep.begin(), value.sep.end(), out); - ctx.advance_to(out); - out = base::format(*it++, ctx); - } - } - return out; - } -}; - -template -arg_join join(It begin, It end, string_view sep) { - return arg_join(begin, end, sep); -} - -template -arg_join join(It begin, It end, wstring_view sep) { - return arg_join(begin, end, sep); -} - -// The following causes ICE in gcc 4.4. -#if FMT_USE_TRAILING_RETURN && (!FMT_GCC_VERSION || FMT_GCC_VERSION >= 405) -template -auto join(const Range &range, string_view sep) - -> arg_join { - return join(internal::begin(range), internal::end(range), sep); -} - -template -auto join(const Range &range, wstring_view sep) - -> arg_join { - return join(internal::begin(range), internal::end(range), sep); -} -#endif - -#if FMT_USE_STRING -/** - \rst - Converts *value* to ``std::string`` using the default format for type *T*. - It doesn't support user-defined types with custom formatters. - - **Example**:: - - #include - - std::string answer = fmt::to_string(42); - \endrst - */ -template -std::string to_string(const T &value) { - std::string str; - internal::container_buffer buf(str); - writer(buf).write(value); - return str; -} - -/** - Converts *value* to ``std::wstring`` using the default format for type *T*. - */ -template -std::wstring to_wstring(const T &value) { - std::wstring str; - internal::container_buffer buf(str); - wwriter(buf).write(value); - return str; -} - -template -std::basic_string to_string(const basic_memory_buffer &buf) { - return std::basic_string(buf.data(), buf.size()); -} -#endif - template typename buffer_context::type::iterator internal::vformat_to( internal::basic_buffer &buf, basic_string_view format_str, @@ -3132,69 +2722,20 @@ inline typename buffer_context::type::iterator format_to( basic_format_args(as)); } -namespace internal { - -// Detect the iterator category of *any* given type in a SFINAE-friendly way. -// Unfortunately, older implementations of std::iterator_traits are not safe -// for use in a SFINAE-context. - -// the gist of C++17's void_t magic -template -struct void_ { typedef void type; }; - -template -struct it_category : std::false_type {}; - -template -struct it_category { typedef std::random_access_iterator_tag type; }; - -template -struct it_category::type> { - typedef typename T::iterator_category type; -}; - -// Detect if *any* given type models the OutputIterator concept. -template -class is_output_iterator { - // Check for mutability because all iterator categories derived from - // std::input_iterator_tag *may* also meet the requirements of an - // OutputIterator, thereby falling into the category of 'mutable iterators' - // [iterator.requirements.general] clause 4. - // The compiler reveals this property only at the point of *actually - // dereferencing* the iterator! - template - static decltype(*(internal::declval())) test(std::input_iterator_tag); - template - static char& test(std::output_iterator_tag); - template - static const char& test(...); - - typedef decltype(test(typename it_category::type{})) type; - typedef typename std::remove_reference::type result; - public: - static const bool value = !std::is_const::value; -}; -} // internal - template -//using format_context_t = basic_format_context; struct format_context_t { typedef basic_format_context type; }; template -//using format_args_t = basic_format_args>; struct format_args_t { typedef basic_format_args< typename format_context_t::type> type; }; template -inline typename std::enable_if::value, - OutputIt>::type - vformat_to(OutputIt out, const String &format_str, +inline OutputIt vformat_to(OutputIt out, const String &format_str, typename format_args_t::type args) { typedef output_range range; - return vformat_to>(range(out), - to_string_view(format_str), args); + return vformat_to>(range(out), to_string_view(format_str), args); } /** @@ -3210,8 +2751,7 @@ inline typename std::enable_if::value, */ template inline FMT_ENABLE_IF_T( - internal::is_string::value && - internal::is_output_iterator::value, OutputIt) + internal::is_string::value, OutputIt) format_to(OutputIt out, const S &format_str, const Args &... args) { internal::check_format_string(format_str); typedef typename format_context_t::type context; @@ -3220,87 +2760,6 @@ inline FMT_ENABLE_IF_T( basic_format_args(as)); } -template -struct format_to_n_result { - /** Iterator past the end of the output range. */ - OutputIt out; - /** Total (not truncated) output size. */ - std::size_t size; -}; - -template -struct format_to_n_context : - format_context_t, Char> {}; - -template -struct format_to_n_args { - typedef basic_format_args< - typename format_to_n_context::type> type; -}; - -template -inline format_arg_store< - typename format_to_n_context::type, Args...> - make_format_to_n_args(const Args &... args) { - return format_arg_store< - typename format_to_n_context::type, Args...>(args...); -} - -template -inline typename std::enable_if< - internal::is_output_iterator::value, - format_to_n_result>::type vformat_to_n( - OutputIt out, std::size_t n, basic_string_view format_str, - typename format_to_n_args::type args) { - typedef internal::truncating_iterator It; - auto it = vformat_to(It(out, n), format_str, args); - return {it.base(), it.count()}; -} - -/** - \rst - Formats arguments, writes up to ``n`` characters of the result to the output - iterator ``out`` and returns the total output size and the iterator past the - end of the output range. - \endrst - */ -template -inline FMT_ENABLE_IF_T( - internal::is_string::value && - internal::is_output_iterator::value, - format_to_n_result) - format_to_n(OutputIt out, std::size_t n, const S &format_str, - const Args &... args) { - internal::check_format_string(format_str); - typedef FMT_CHAR(S) Char; - format_arg_store< - typename format_to_n_context::type, Args...> as(args...); - return vformat_to_n(out, n, to_string_view(format_str), - typename format_to_n_args::type(as)); -} - -#if FMT_USE_STRING -template -inline std::basic_string internal::vformat( - basic_string_view format_str, - basic_format_args::type> args) { - basic_memory_buffer buffer; - internal::vformat_to(buffer, format_str, args); - return fmt::to_string(buffer); -} -#endif - -/** - Returns the number of characters in the output of - ``format(format_str, args...)``. - */ -template -inline std::size_t formatted_size(string_view format_str, - const Args &... args) { - auto it = format_to(internal::counting_iterator(), format_str, args...); - return it.count(); -} - #if FMT_USE_USER_DEFINED_LITERALS namespace internal { @@ -3385,36 +2844,6 @@ operator"" _a(const wchar_t *s, std::size_t) { return {s}; } #endif // FMT_USE_USER_DEFINED_LITERALS FMT_END_NAMESPACE -#define FMT_STRING(s) [] { \ - typedef typename std::remove_cv::type>::type>::type ct; \ - struct str : fmt::compile_string { \ - typedef ct char_type; \ - FMT_CONSTEXPR operator fmt::basic_string_view() const { \ - return {s, sizeof(s) / sizeof(ct) - 1}; \ - } \ - }; \ - return str{}; \ - }() - -#if defined(FMT_STRING_ALIAS) && FMT_STRING_ALIAS -/** - \rst - Constructs a compile-time format string. This macro is disabled by default to - prevent potential name collisions. To enable it define ``FMT_STRING_ALIAS`` to - 1 before including ``fmt/format.h``. - - **Example**:: - - #define FMT_STRING_ALIAS 1 - #include - // A compile-time error because 'd' is an invalid specifier for strings. - std::string s = format(fmt("{:d}"), "foo"); - \endrst - */ -# define fmt(s) FMT_STRING(s) -#endif - #ifdef FMT_HEADER_ONLY # define FMT_FUNC inline # include "format-inl.h" diff --git a/Source/ThirdParty/fmt/ostream.h b/Source/ThirdParty/fmt/ostream.h index 2db98a5dc..d7c930ff5 100644 --- a/Source/ThirdParty/fmt/ostream.h +++ b/Source/ThirdParty/fmt/ostream.h @@ -78,7 +78,7 @@ void write(std::basic_ostream &os, basic_buffer &buf) { typedef std::make_unsigned::type UnsignedStreamSize; UnsignedStreamSize size = buf.size(); UnsignedStreamSize max_size = - internal::to_unsigned((std::numeric_limits::max)()); + internal::to_unsigned(MAX_int32); do { UnsignedStreamSize n = size <= max_size ? size : max_size; os.write(data, static_cast(n)); diff --git a/Source/ThirdParty/rapidjson/document.h b/Source/ThirdParty/rapidjson/document.h index b47115147..a6a6e4d9c 100644 --- a/Source/ThirdParty/rapidjson/document.h +++ b/Source/ThirdParty/rapidjson/document.h @@ -23,7 +23,6 @@ #include "memorystream.h" #include "encodedstream.h" #include // placement new -#include RAPIDJSON_DIAG_PUSH #ifdef _MSC_VER @@ -948,26 +947,6 @@ public: bool IsDouble() const { return (data_.f.flags & kDoubleFlag) != 0; } bool IsString() const { return (data_.f.flags & kStringFlag) != 0; } - // Checks whether a number can be losslessly converted to a double. - bool IsLosslessDouble() const { - if (!IsNumber()) return false; - if (IsUint64()) { - uint64_t u = GetUint64(); - volatile double d = static_cast(u); - return (d >= 0.0) - && (d < static_cast(std::numeric_limits::max())) - && (u == static_cast(d)); - } - if (IsInt64()) { - int64_t i = GetInt64(); - volatile double d = static_cast(i); - return (d >= static_cast(std::numeric_limits::min())) - && (d < static_cast(std::numeric_limits::max())) - && (i == static_cast(d)); - } - return true; // double, int, uint are always lossless - } - // Checks whether a number is a float (possible lossy). bool IsFloat() const { if ((data_.f.flags & kDoubleFlag) == 0) @@ -975,16 +954,6 @@ public: double d = GetDouble(); return d >= -3.4028234e38 && d <= 3.4028234e38; } - // Checks whether a number can be losslessly converted to a float. - bool IsLosslessFloat() const { - if (!IsNumber()) return false; - double a = GetDouble(); - if (a < static_cast(-std::numeric_limits::max()) - || a > static_cast(std::numeric_limits::max())) - return false; - double b = static_cast(static_cast(a)); - return a >= b && a <= b; // Prevent -Wfloat-equal - } //@} diff --git a/Source/ThirdParty/rapidjson/internal/biginteger.h b/Source/ThirdParty/rapidjson/internal/biginteger.h index 9d3e88c99..5e7e61688 100644 --- a/Source/ThirdParty/rapidjson/internal/biginteger.h +++ b/Source/ThirdParty/rapidjson/internal/biginteger.h @@ -18,7 +18,7 @@ #include "../rapidjson.h" #if defined(_MSC_VER) && defined(_M_AMD64) -#include // for _umul128 +#include // for _umul128 #pragma intrinsic(_umul128) #endif diff --git a/Source/ThirdParty/rapidjson/internal/diyfp.h b/Source/ThirdParty/rapidjson/internal/diyfp.h index c9fefdc61..617b07968 100644 --- a/Source/ThirdParty/rapidjson/internal/diyfp.h +++ b/Source/ThirdParty/rapidjson/internal/diyfp.h @@ -22,7 +22,7 @@ #include "../rapidjson.h" #if defined(_MSC_VER) && defined(_M_AMD64) -#include +#include #pragma intrinsic(_BitScanReverse64) #pragma intrinsic(_umul128) #endif diff --git a/Source/ThirdParty/rapidjson/reader.h b/Source/ThirdParty/rapidjson/reader.h index 19f8849b1..a61a94ec5 100644 --- a/Source/ThirdParty/rapidjson/reader.h +++ b/Source/ThirdParty/rapidjson/reader.h @@ -23,7 +23,6 @@ #include "internal/meta.h" #include "internal/stack.h" #include "internal/strtod.h" -#include #if defined(RAPIDJSON_SIMD) && defined(_MSC_VER) #include @@ -1187,10 +1186,10 @@ private: else if ((parseFlags & kParseNanAndInfFlag) && RAPIDJSON_LIKELY((s.Peek() == 'I' || s.Peek() == 'N'))) { useNanOrInf = true; if (RAPIDJSON_LIKELY(Consume(s, 'N') && Consume(s, 'a') && Consume(s, 'N'))) { - d = std::numeric_limits::quiet_NaN(); + d = NAN; } else if (RAPIDJSON_LIKELY(Consume(s, 'I') && Consume(s, 'n') && Consume(s, 'f'))) { - d = (minus ? -std::numeric_limits::infinity() : std::numeric_limits::infinity()); + d = (minus ? -INFINITY : INFINITY); if (RAPIDJSON_UNLIKELY(s.Peek() == 'i' && !(Consume(s, 'i') && Consume(s, 'n') && Consume(s, 'i') && Consume(s, 't') && Consume(s, 'y')))) RAPIDJSON_PARSE_ERROR(kParseErrorValueInvalid, s.Tell());