Merge remote-tracking branch 'origin/1.5' into dotnet7

# Conflicts:
#	Content/Shaders/GI/DDGI.flax
#	Content/Shaders/TAA.flax
This commit is contained in:
Wojciech Figat
2022-12-30 09:24:10 +01:00
31 changed files with 167 additions and 50 deletions

Binary file not shown.

Binary file not shown.

BIN
Content/Editor/Icons/Textures/Decal.flax (Stored with Git LFS)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
Content/Editor/Icons/Textures/Skybox.flax (Stored with Git LFS)

Binary file not shown.

BIN
Content/Shaders/GI/GlobalSurfaceAtlas.flax (Stored with Git LFS)

Binary file not shown.

BIN
Content/Shaders/VolumetricFog.flax (Stored with Git LFS)

Binary file not shown.

View File

@@ -29,6 +29,7 @@ enum class IconTypes
DirectionalLight, DirectionalLight,
EnvironmentProbe, EnvironmentProbe,
Skybox, Skybox,
SkyLight,
AudioListener, AudioListener,
AudioSource, AudioSource,
Decal, Decal,
@@ -155,6 +156,7 @@ bool ViewportIconsRendererService::Init()
INIT(DirectionalLight, "Editor/Icons/DirectionalLight"); INIT(DirectionalLight, "Editor/Icons/DirectionalLight");
INIT(EnvironmentProbe, "Editor/Icons/EnvironmentProbe"); INIT(EnvironmentProbe, "Editor/Icons/EnvironmentProbe");
INIT(Skybox, "Editor/Icons/Skybox"); INIT(Skybox, "Editor/Icons/Skybox");
INIT(SkyLight, "Editor/Icons/SkyLight");
INIT(AudioListener, "Editor/Icons/AudioListener"); INIT(AudioListener, "Editor/Icons/AudioListener");
INIT(AudioSource, "Editor/Icons/AudioSource"); INIT(AudioSource, "Editor/Icons/AudioSource");
INIT(Decal, "Editor/Icons/Decal"); INIT(Decal, "Editor/Icons/Decal");
@@ -173,7 +175,7 @@ bool ViewportIconsRendererService::Init()
MAP_TYPE(SceneAnimationPlayer, SceneAnimationPlayer); MAP_TYPE(SceneAnimationPlayer, SceneAnimationPlayer);
MAP_TYPE(ExponentialHeightFog, Skybox); MAP_TYPE(ExponentialHeightFog, Skybox);
MAP_TYPE(Sky, Skybox); MAP_TYPE(Sky, Skybox);
MAP_TYPE(SkyLight, PointLight); MAP_TYPE(SkyLight, SkyLight);
MAP_TYPE(SpotLight, PointLight); MAP_TYPE(SpotLight, PointLight);
#undef MAP_TYPE #undef MAP_TYPE

View File

@@ -198,6 +198,7 @@ namespace FlaxEditor.Viewport.Previews
// Preview LOD // Preview LOD
{ {
var previewLOD = ViewWidgetButtonMenu.AddButton("Preview LOD"); var previewLOD = ViewWidgetButtonMenu.AddButton("Preview LOD");
previewLOD.CloseMenuOnClick = false;
var previewLODValue = new IntValueBox(-1, 90, 2, 70.0f, -1, 10, 0.02f) var previewLODValue = new IntValueBox(-1, 90, 2, 70.0f, -1, 10, 0.02f)
{ {
Parent = previewLOD Parent = previewLOD

View File

@@ -62,6 +62,7 @@ namespace FlaxEditor.Viewport.Previews
// Preview LOD // Preview LOD
{ {
var previewLOD = ViewWidgetButtonMenu.AddButton("Preview LOD"); var previewLOD = ViewWidgetButtonMenu.AddButton("Preview LOD");
previewLOD.CloseMenuOnClick = false;
var previewLODValue = new IntValueBox(-1, 90, 2, 70.0f, -1, 10, 0.02f) var previewLODValue = new IntValueBox(-1, 90, 2, 70.0f, -1, 10, 0.02f)
{ {
Parent = previewLOD Parent = previewLOD

View File

@@ -201,6 +201,7 @@ namespace FlaxEditor.Viewport.Previews
// Preview LOD // Preview LOD
{ {
var previewLOD = ViewWidgetButtonMenu.AddButton("Preview LOD"); var previewLOD = ViewWidgetButtonMenu.AddButton("Preview LOD");
previewLOD.CloseMenuOnClick = false;
var previewLODValue = new IntValueBox(-1, 90, 2, 70.0f, -1, 10, 0.02f) var previewLODValue = new IntValueBox(-1, 90, 2, 70.0f, -1, 10, 0.02f)
{ {
Parent = previewLOD Parent = previewLOD

View File

@@ -67,6 +67,7 @@ namespace FlaxEditor.Viewport.Previews
if (useWidgets) if (useWidgets)
{ {
var playbackDuration = ViewWidgetButtonMenu.AddButton("Duration"); var playbackDuration = ViewWidgetButtonMenu.AddButton("Duration");
playbackDuration.CloseMenuOnClick = false;
var playbackDurationValue = new FloatValueBox(_playbackDuration, 90, 2, 70.0f, 0.1f, 1000000.0f, 0.1f) var playbackDurationValue = new FloatValueBox(_playbackDuration, 90, 2, 70.0f, 0.1f, 1000000.0f, 0.1f)
{ {
Parent = playbackDuration Parent = playbackDuration

View File

@@ -204,6 +204,7 @@ namespace FlaxEditor.Windows
showFileExtensionsButton.AutoCheck = true; showFileExtensionsButton.AutoCheck = true;
var viewScale = menu.AddButton("View Scale"); var viewScale = menu.AddButton("View Scale");
viewScale.CloseMenuOnClick = false;
var scaleValue = new FloatValueBox(1, 75, 2, 50.0f, 0.3f, 3.0f, 0.01f) var scaleValue = new FloatValueBox(1, 75, 2, 50.0f, 0.3f, 3.0f, 0.01f)
{ {
Parent = viewScale Parent = viewScale

View File

@@ -353,6 +353,7 @@ namespace FlaxEditor.Windows
// Viewport Brightness // Viewport Brightness
{ {
var brightness = menu.AddButton("Viewport Brightness"); var brightness = menu.AddButton("Viewport Brightness");
brightness.CloseMenuOnClick = false;
var brightnessValue = new FloatValueBox(_viewport.Brightness, 140, 2, 50.0f, 0.001f, 10.0f, 0.001f) var brightnessValue = new FloatValueBox(_viewport.Brightness, 140, 2, 50.0f, 0.001f, 10.0f, 0.001f)
{ {
Parent = brightness Parent = brightness
@@ -363,6 +364,7 @@ namespace FlaxEditor.Windows
// Viewport Resolution // Viewport Resolution
{ {
var resolution = menu.AddButton("Viewport Resolution"); var resolution = menu.AddButton("Viewport Resolution");
resolution.CloseMenuOnClick = false;
var resolutionValue = new FloatValueBox(_viewport.ResolutionScale, 140, 2, 50.0f, 0.1f, 4.0f, 0.001f) var resolutionValue = new FloatValueBox(_viewport.ResolutionScale, 140, 2, 50.0f, 0.1f, 4.0f, 0.001f)
{ {
Parent = resolution Parent = resolution
@@ -381,6 +383,7 @@ namespace FlaxEditor.Windows
// Show GUI // Show GUI
{ {
var button = menu.AddButton("Show GUI"); var button = menu.AddButton("Show GUI");
button.CloseMenuOnClick = false;
var checkbox = new CheckBox(140, 2, ShowGUI) { Parent = button }; var checkbox = new CheckBox(140, 2, ShowGUI) { Parent = button };
checkbox.StateChanged += x => ShowGUI = x.Checked; checkbox.StateChanged += x => ShowGUI = x.Checked;
} }
@@ -388,6 +391,7 @@ namespace FlaxEditor.Windows
// Show Debug Draw // Show Debug Draw
{ {
var button = menu.AddButton("Show Debug Draw"); var button = menu.AddButton("Show Debug Draw");
button.CloseMenuOnClick = false;
var checkbox = new CheckBox(140, 2, ShowDebugDraw) { Parent = button }; var checkbox = new CheckBox(140, 2, ShowDebugDraw) { Parent = button };
checkbox.StateChanged += x => ShowDebugDraw = x.Checked; checkbox.StateChanged += x => ShowDebugDraw = x.Checked;
} }

View File

@@ -126,7 +126,7 @@ Asset::LoadResult Material::load()
FlaxChunk* materialParamsChunk; FlaxChunk* materialParamsChunk;
// Wait for the GPU Device to be ready (eg. case when loading material before GPU init) // Wait for the GPU Device to be ready (eg. case when loading material before GPU init)
#define IS_GPU_NOT_READY() (GPUDevice::Instance == nullptr || GPUDevice::Instance->GetState() != GPUDevice::DeviceState::Ready || GPUDevice::Instance->QuadShader == nullptr) #define IS_GPU_NOT_READY() (GPUDevice::Instance == nullptr || GPUDevice::Instance->GetState() != GPUDevice::DeviceState::Ready)
if (!IsInMainThread() && IS_GPU_NOT_READY()) if (!IsInMainThread() && IS_GPU_NOT_READY())
{ {
int32 timeout = 1000; int32 timeout = 1000;

View File

@@ -22,11 +22,10 @@ namespace ObjectsRemovalServiceImpl
using namespace ObjectsRemovalServiceImpl; using namespace ObjectsRemovalServiceImpl;
class ObjectsRemovalServiceService : public EngineService class ObjectsRemoval : public EngineService
{ {
public: public:
ObjectsRemoval()
ObjectsRemovalServiceService()
: EngineService(TEXT("Objects Removal Service"), -1000) : EngineService(TEXT("Objects Removal Service"), -1000)
{ {
} }
@@ -36,7 +35,7 @@ public:
void Dispose() override; void Dispose() override;
}; };
ObjectsRemovalServiceService ObjectsRemovalServiceServiceInstance; ObjectsRemoval ObjectsRemovalInstance;
bool ObjectsRemovalService::IsInPool(Object* obj) bool ObjectsRemovalService::IsInPool(Object* obj)
{ {
@@ -63,7 +62,6 @@ bool ObjectsRemovalService::HasNewItemsForFlush()
NewItemsLocker.Lock(); NewItemsLocker.Lock();
const bool result = NewItemsPool.HasItems(); const bool result = NewItemsPool.HasItems();
NewItemsLocker.Unlock(); NewItemsLocker.Unlock();
return result; return result;
} }
@@ -95,6 +93,8 @@ void ObjectsRemovalService::Add(Object* obj, float timeToLive, bool useGameTime)
void ObjectsRemovalService::Flush(float dt, float gameDelta) void ObjectsRemovalService::Flush(float dt, float gameDelta)
{ {
PROFILE_CPU();
// Add new items // Add new items
{ {
ScopeLock lock(NewItemsLocker); ScopeLock lock(NewItemsLocker);
@@ -173,14 +173,14 @@ void ObjectsRemovalService::Flush(float dt, float gameDelta)
} }
} }
bool ObjectsRemovalServiceService::Init() bool ObjectsRemoval::Init()
{ {
LastUpdate = DateTime::NowUTC(); LastUpdate = DateTime::NowUTC();
LastUpdateGameTime = 0; LastUpdateGameTime = 0;
return false; return false;
} }
void ObjectsRemovalServiceService::LateUpdate() void ObjectsRemoval::LateUpdate()
{ {
PROFILE_CPU(); PROFILE_CPU();
@@ -194,7 +194,7 @@ void ObjectsRemovalServiceService::LateUpdate()
LastUpdate = now; LastUpdate = now;
} }
void ObjectsRemovalServiceService::Dispose() void ObjectsRemoval::Dispose()
{ {
// Collect new objects // Collect new objects
ObjectsRemovalService::Flush(); ObjectsRemovalService::Flush();

View File

@@ -10,7 +10,6 @@
class FLAXENGINE_API ObjectsRemovalService class FLAXENGINE_API ObjectsRemovalService
{ {
public: public:
/// <summary> /// <summary>
/// Determines whether object has been registered in the pool for the removing. /// Determines whether object has been registered in the pool for the removing.
/// </summary> /// </summary>

View File

@@ -320,7 +320,7 @@ GPUSampler* Streaming::GetTextureGroupSampler(int32 index)
{ {
FallbackSampler = GPUSampler::New(); FallbackSampler = GPUSampler::New();
#if GPU_ENABLE_RESOURCE_NAMING #if GPU_ENABLE_RESOURCE_NAMING
sampler->SetName(TEXT("FallbackSampler")); FallbackSampler->SetName(TEXT("FallbackSampler"));
#endif #endif
FallbackSampler->Init(GPUSamplerDescription::New(GPUSamplerFilter::Trilinear)); FallbackSampler->Init(GPUSamplerDescription::New(GPUSamplerFilter::Trilinear));
} }

View File

@@ -0,0 +1,40 @@
// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved.
#include "TestScripting.h"
#include "Engine/Scripting/Scripting.h"
#include <ThirdParty/catch2/catch.hpp>
TestClassNative::TestClassNative(const SpawnParams& params)
: ScriptingObject(params)
{
}
TEST_CASE("Scripting")
{
SECTION("Test Class")
{
// Test native class
ScriptingTypeHandle type = Scripting::FindScriptingType("FlaxEngine.TestClassNative");
CHECK(type == TestClassNative::TypeInitializer);
ScriptingObject* object = Scripting::NewObject(type.GetType().ManagedClass);
CHECK(object);
CHECK(object->Is<TestClassNative>());
TestClassNative* testClass = (TestClassNative*)object;
CHECK(testClass->SimpleField == 1);
int32 methodResult = testClass->Test(TEXT("123"));
CHECK(methodResult == 3);
// Test managed class
type = Scripting::FindScriptingType("FlaxEngine.TestClassManaged");
CHECK(type);
object = Scripting::NewObject(type.GetType().ManagedClass);
CHECK(object);
CHECK(object->Is<TestClassNative>());
testClass = (TestClassNative*)object;
MObject* managed = testClass->GetOrCreateManagedInstance(); // Ensure to create C# object and run it's ctor
CHECK(managed);
CHECK(testClass->SimpleField == 2);
methodResult = testClass->Test(TEXT("123"));
CHECK(methodResult == 6);
}
}

View File

@@ -0,0 +1,23 @@
// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved.
#if FLAX_TESTS
namespace FlaxEngine
{
/// <summary>
/// Test class.
/// </summary>
public class TestClassManaged : TestClassNative
{
TestClassManaged()
{
SimpleField = 2;
}
/// <inheritdoc />
public override int Test(string str)
{
return str.Length + base.Test(str);
}
}
}
#endif

View File

@@ -0,0 +1,23 @@
// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved.
#pragma once
#include "Engine/Core/ISerializable.h"
#include "Engine/Scripting/ScriptingObject.h"
// Test class.
API_CLASS() class TestClassNative : public ScriptingObject, public ISerializable
{
API_AUTO_SERIALIZATION();
DECLARE_SCRIPTING_TYPE(TestClassNative);
public:
// Test value
API_FIELD() int32 SimpleField = 1;
// Test virtual method
API_FUNCTION() virtual int32 Test(const String& str)
{
return str.Length();
}
};

View File

@@ -45,6 +45,8 @@ public class FlaxTestsTarget : FlaxEditor
{ {
base.SetupTargetEnvironment(options); base.SetupTargetEnvironment(options);
options.ScriptingAPI.Defines.Add("FLAX_TESTS");
// Produce console program // Produce console program
options.LinkEnv.LinkAsConsoleProgram = true; options.LinkEnv.LinkAsConsoleProgram = true;
} }

View File

@@ -1360,7 +1360,8 @@ namespace Flax.Build.Bindings
thunkCall += GenerateCppWrapperNativeToBox(buildData, parameterInfo.Type, classInfo, parameterInfo.Name); thunkCall += GenerateCppWrapperNativeToBox(buildData, parameterInfo.Type, classInfo, parameterInfo.Name);
} }
if (functionInfo.ReturnType.IsVoid) var returnType = functionInfo.ReturnType;
if (returnType.IsVoid)
{ {
contents.AppendLine($" typedef void (*Thunk)(void* instance{thunkParams}, MonoObject** exception);"); contents.AppendLine($" typedef void (*Thunk)(void* instance{thunkParams}, MonoObject** exception);");
contents.AppendLine(" const auto thunk = (Thunk)method->GetThunk();"); contents.AppendLine(" const auto thunk = (Thunk)method->GetThunk();");
@@ -1378,18 +1379,30 @@ namespace Flax.Build.Bindings
contents.AppendLine(" if (exception)"); contents.AppendLine(" if (exception)");
contents.AppendLine(" DebugLog::LogException(exception);"); contents.AppendLine(" DebugLog::LogException(exception);");
if (!functionInfo.ReturnType.IsVoid) if (!returnType.IsVoid)
{ {
if (functionInfo.ReturnType.IsRef) if (returnType.IsRef)
throw new NotSupportedException($"Passing return value by reference is not supported for virtual API methods. Used on method '{functionInfo}'."); throw new NotSupportedException($"Passing return value by reference is not supported for virtual API methods. Used on method '{functionInfo}'.");
switch (functionInfo.ReturnType.Type) switch (returnType.Type)
{ {
case "bool": case "bool":
contents.AppendLine($" return __result != 0;"); contents.AppendLine(" return __result != 0;");
break;
case "int8":
case "int16":
case "int32":
case "int64":
contents.AppendLine($" return ({returnType.Type})(intptr)__result;");
break;
case "uint8":
case "uint16":
case "uint32":
case "uint64":
contents.AppendLine($" return ({returnType.Type})(uintptr)__result;");
break; break;
default: default:
contents.AppendLine($" return MUtils::Unbox<{functionInfo.ReturnType}>(__result);"); contents.AppendLine($" return MUtils::Unbox<{returnType}>(__result);");
break; break;
} }
} }

View File

@@ -28,7 +28,7 @@ namespace Flax.Build.Platforms
} }
// Visual Studio 2017+ supported only // Visual Studio 2017+ supported only
var visualStudio = VisualStudioInstance.GetInstances().FirstOrDefault(x => x.Version == VisualStudioVersion.VisualStudio2017 || x.Version == VisualStudioVersion.VisualStudio2019); var visualStudio = VisualStudioInstance.GetInstances().FirstOrDefault(x => x.Version == VisualStudioVersion.VisualStudio2017 || x.Version == VisualStudioVersion.VisualStudio2019 || x.Version == VisualStudioVersion.VisualStudio2022);
if (visualStudio == null) if (visualStudio == null)
_hasRequiredSDKsInstalled = false; _hasRequiredSDKsInstalled = false;
@@ -43,10 +43,8 @@ namespace Flax.Build.Platforms
if (!toolsets.ContainsKey(WindowsPlatformToolset.v141) && if (!toolsets.ContainsKey(WindowsPlatformToolset.v141) &&
!toolsets.ContainsKey(WindowsPlatformToolset.v142) && !toolsets.ContainsKey(WindowsPlatformToolset.v142) &&
!toolsets.ContainsKey(WindowsPlatformToolset.v143)) !toolsets.ContainsKey(WindowsPlatformToolset.v143))
{
_hasRequiredSDKsInstalled = false; _hasRequiredSDKsInstalled = false;
} }
}
/// <inheritdoc /> /// <inheritdoc />
protected override Toolchain CreateToolchain(TargetArchitecture architecture) protected override Toolchain CreateToolchain(TargetArchitecture architecture)

View File

@@ -29,7 +29,7 @@ namespace Flax.Build.Platforms
public UWPToolchain(UWPPlatform platform, TargetArchitecture architecture, WindowsPlatformToolset toolsetVer = WindowsPlatformToolset.Latest, WindowsPlatformSDK sdkVer = WindowsPlatformSDK.Latest) public UWPToolchain(UWPPlatform platform, TargetArchitecture architecture, WindowsPlatformToolset toolsetVer = WindowsPlatformToolset.Latest, WindowsPlatformSDK sdkVer = WindowsPlatformSDK.Latest)
: base(platform, architecture, toolsetVer, sdkVer) : base(platform, architecture, toolsetVer, sdkVer)
{ {
var visualStudio = VisualStudioInstance.GetInstances().FirstOrDefault(x => x.Version == VisualStudioVersion.VisualStudio2017 || x.Version == VisualStudioVersion.VisualStudio2019); var visualStudio = VisualStudioInstance.GetInstances().FirstOrDefault(x => x.Version == VisualStudioVersion.VisualStudio2017 || x.Version == VisualStudioVersion.VisualStudio2019 || x.Version == VisualStudioVersion.VisualStudio2022);
if (visualStudio == null) if (visualStudio == null)
throw new Exception("Missing Visual Studio 2017 or newer. It's required to build for UWP."); throw new Exception("Missing Visual Studio 2017 or newer. It's required to build for UWP.");
_usingDirs.Add(Path.Combine(visualStudio.Path, "VC", "vcpackages")); _usingDirs.Add(Path.Combine(visualStudio.Path, "VC", "vcpackages"));
@@ -45,6 +45,14 @@ namespace Flax.Build.Platforms
_usingDirs.Add(Path.Combine(sdk10, "UnionMetadata", sdk10Ver)); _usingDirs.Add(Path.Combine(sdk10, "UnionMetadata", sdk10Ver));
} }
/// <inheritdoc />
public override void LogInfo()
{
base.LogInfo();
Log.Error("UWP (Windows Store) platform has been deprecated and soon will be removed!");
}
/// <inheritdoc /> /// <inheritdoc />
protected override void SetupCompileCppFilesArgs(TaskGraph graph, BuildOptions options, List<string> args) protected override void SetupCompileCppFilesArgs(TaskGraph graph, BuildOptions options, List<string> args)
{ {