From c0fa858dd09ebe01fd06531e877612c9515edd9d Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Thu, 19 Oct 2023 14:25:37 +0200 Subject: [PATCH 1/4] Fix warning on missing windows layout file when loading default layout --- Source/Editor/Modules/WindowsModule.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Source/Editor/Modules/WindowsModule.cs b/Source/Editor/Modules/WindowsModule.cs index 1a4f5ce9e..05d72598f 100644 --- a/Source/Editor/Modules/WindowsModule.cs +++ b/Source/Editor/Modules/WindowsModule.cs @@ -237,7 +237,11 @@ namespace FlaxEditor.Modules /// public void LoadDefaultLayout() { - LoadLayout(StringUtils.CombinePaths(Globals.EngineContentFolder, "Editor/LayoutDefault.xml")); + var path = StringUtils.CombinePaths(Globals.EngineContentFolder, "Editor/LayoutDefault.xml"); + if (File.Exists(path)) + { + LoadLayout(path); + } } /// From 6f60218becca4fb7b3818f057d09ee0f718abc3f Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Thu, 19 Oct 2023 15:07:03 +0200 Subject: [PATCH 2/4] Optimize various rendering stages to skip loading shader when effect is disables --- Source/Engine/Renderer/DepthOfFieldPass.cpp | 8 +++----- Source/Engine/Renderer/EyeAdaptationPass.cpp | 7 +------ Source/Engine/Renderer/MotionBlurPass.cpp | 2 +- Source/Engine/Renderer/PostProcessingPass.cpp | 2 +- 4 files changed, 6 insertions(+), 13 deletions(-) diff --git a/Source/Engine/Renderer/DepthOfFieldPass.cpp b/Source/Engine/Renderer/DepthOfFieldPass.cpp index 4c43ccdbf..cd7930f5c 100644 --- a/Source/Engine/Renderer/DepthOfFieldPass.cpp +++ b/Source/Engine/Renderer/DepthOfFieldPass.cpp @@ -202,16 +202,14 @@ GPUTexture* DepthOfFieldPass::getDofBokehShape(DepthOfFieldSettings& dofSettings void DepthOfFieldPass::Render(RenderContext& renderContext, GPUTexture*& frame, GPUTexture*& tmp) { - if (!_platformSupportsDoF || checkIfSkipPass()) + DepthOfFieldSettings& dofSettings = renderContext.List->Settings.DepthOfField; + const bool useDoF = EnumHasAnyFlags(renderContext.View.Flags, ViewFlags::DepthOfField) && dofSettings.Enabled; + if (!useDoF || _platformSupportsDoF || checkIfSkipPass()) return; auto device = GPUDevice::Instance; auto context = device->GetMainContext(); const auto depthBuffer = renderContext.Buffers->DepthBuffer; const auto shader = _shader->GetShader(); - DepthOfFieldSettings& dofSettings = renderContext.List->Settings.DepthOfField; - const bool useDoF = _platformSupportsDoF && EnumHasAnyFlags(renderContext.View.Flags, ViewFlags::DepthOfField) && dofSettings.Enabled; - if (!useDoF) - return; PROFILE_GPU_CPU("Depth Of Field"); context->ResetSR(); diff --git a/Source/Engine/Renderer/EyeAdaptationPass.cpp b/Source/Engine/Renderer/EyeAdaptationPass.cpp index 12b26ea41..3a840ff01 100644 --- a/Source/Engine/Renderer/EyeAdaptationPass.cpp +++ b/Source/Engine/Renderer/EyeAdaptationPass.cpp @@ -35,7 +35,6 @@ PACK_STRUCT(struct EyeAdaptationData { void EyeAdaptationPass::Render(RenderContext& renderContext, GPUTexture* colorBuffer) { - // Cache data auto device = GPUDevice::Instance; auto context = device->GetMainContext(); auto& view = renderContext.View; @@ -45,12 +44,8 @@ void EyeAdaptationPass::Render(RenderContext& renderContext, GPUTexture* colorBu //const float frameDelta = Time::ElapsedGameTime.GetTotalSeconds(); const float frameDelta = time - renderContext.Buffers->LastEyeAdaptationTime; renderContext.Buffers->LastEyeAdaptationTime = 0.0f; - - // Optionally skip the rendering - if (checkIfSkipPass() || (view.Flags & ViewFlags::EyeAdaptation) == ViewFlags::None || settings.Mode == EyeAdaptationMode::None) - { + if ((view.Flags & ViewFlags::EyeAdaptation) == ViewFlags::None || settings.Mode == EyeAdaptationMode::None || checkIfSkipPass()) return; - } PROFILE_GPU_CPU("Eye Adaptation"); diff --git a/Source/Engine/Renderer/MotionBlurPass.cpp b/Source/Engine/Renderer/MotionBlurPass.cpp index d425df80f..2030027ed 100644 --- a/Source/Engine/Renderer/MotionBlurPass.cpp +++ b/Source/Engine/Renderer/MotionBlurPass.cpp @@ -244,7 +244,7 @@ void MotionBlurPass::RenderDebug(RenderContext& renderContext, GPUTextureView* f { auto context = GPUDevice::Instance->GetMainContext(); const auto motionVectors = renderContext.Buffers->MotionVectors; - if (!motionVectors->IsAllocated() || checkIfSkipPass()) + if (!motionVectors || !motionVectors->IsAllocated() || checkIfSkipPass()) { context->Draw(frame); return; diff --git a/Source/Engine/Renderer/PostProcessingPass.cpp b/Source/Engine/Renderer/PostProcessingPass.cpp index 345147b61..006927639 100644 --- a/Source/Engine/Renderer/PostProcessingPass.cpp +++ b/Source/Engine/Renderer/PostProcessingPass.cpp @@ -195,7 +195,7 @@ void PostProcessingPass::Render(RenderContext& renderContext, GPUTexture* input, bool useLensFlares = EnumHasAnyFlags(view.Flags, ViewFlags::LensFlares) && settings.LensFlares.Intensity > 0.0f && useBloom; // Ensure to have valid data and if at least one effect should be applied - if (checkIfSkipPass() || !(useBloom || useToneMapping || useCameraArtifacts)) + if (!(useBloom || useToneMapping || useCameraArtifacts) || checkIfSkipPass()) { // Resources are missing. Do not perform rendering. Just copy raw frame context->SetViewportAndScissors((float)output->Width(), (float)output->Height()); From a989173e2dd0d154845373581dbc89caa16098ea Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Thu, 19 Oct 2023 15:16:14 +0200 Subject: [PATCH 3/4] Fix `UnitsToText` to properly print string with 2 decimal places --- Source/Engine/Core/Utilities.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Engine/Core/Utilities.h b/Source/Engine/Core/Utilities.h index 36339baf5..f8807607b 100644 --- a/Source/Engine/Core/Utilities.h +++ b/Source/Engine/Core/Utilities.h @@ -54,7 +54,7 @@ namespace Utilities dblSUnits = units / static_cast(divider); if (i >= sizes.Length()) i = 0; - return String::Format(TEXT("{0} {1}"), RoundTo2DecimalPlaces(dblSUnits), sizes[i]); + return String::Format(TEXT("{0:.2f} {1}"), RoundTo2DecimalPlaces(dblSUnits), sizes[i]); } // Converts size of the file (in bytes) to the best fitting string From 0ea00a09cabe4bf4c6797d47fd92c25ea4c1d986 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Thu, 19 Oct 2023 15:29:26 +0200 Subject: [PATCH 4/4] Fix regression from 3e7368b1cb31aedfa37d9cdae1d8612b08e99967 to remove scene lock when spawning actors in async #1743 --- Source/Engine/Level/Level.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/Engine/Level/Level.cpp b/Source/Engine/Level/Level.cpp index dfd5786c6..d7659ca1c 100644 --- a/Source/Engine/Level/Level.cpp +++ b/Source/Engine/Level/Level.cpp @@ -975,6 +975,7 @@ bool Level::loadScene(rapidjson_flax::Value& data, int32 engineBuild, Scene** ou SceneObject** objects = sceneObjects->Get(); if (context.Async) { + ScenesLock.Unlock(); // Unlock scenes from Main Thread so Job Threads can use it to safely setup actors hierarchy (see Actor::Deserialize) JobSystem::Execute([&](int32 i) { i++; // Start from 1. at index [0] was scene @@ -992,6 +993,7 @@ bool Level::loadScene(rapidjson_flax::Value& data, int32 engineBuild, Scene** ou else SceneObjectsFactory::HandleObjectDeserializationError(stream); }, objectsCount - 1); + ScenesLock.Lock(); } else {