10 Commits

Author SHA1 Message Date
269e8963e8 Add support for Zed code editor
Some checks failed
Build Android / Game (Android, Release ARM64) (push) Has been cancelled
Build iOS / Game (iOS, Release ARM64) (push) Has been cancelled
Build Linux / Editor (Linux, Development x64) (push) Has been cancelled
Build Linux / Game (Linux, Release x64) (push) Has been cancelled
Build macOS / Editor (Mac, Development ARM64) (push) Has been cancelled
Build macOS / Game (Mac, Release ARM64) (push) Has been cancelled
Build Windows / Editor (Windows, Development x64) (push) Has been cancelled
Build Windows / Game (Windows, Release x64) (push) Has been cancelled
Cooker / Cook (Mac) (push) Has been cancelled
Tests / Tests (Linux) (push) Has been cancelled
Tests / Tests (Windows) (push) Has been cancelled
2025-10-29 20:16:05 +02:00
Wojtek Figat
d24bd7dfd0 Merge branch 'GoaLitiuM-dotnet_define_fix' 2025-10-29 07:40:11 +01:00
2c8c9b1637 Fix .NET version preprocessor definitions 2025-10-29 08:26:39 +02:00
Wojtek Figat
05a8c841da Fix color grading lut to be refreshed when shader gets reloaded 2025-10-28 23:19:51 +01:00
Wojtek Figat
c4fcaa999c Fix asset thumbnails to be stable with FXAA instead of TAA 2025-10-28 22:23:15 +01:00
Wojtek Figat
70c9dd6608 Fix eye adaptation in Manual mode 2025-10-28 21:36:28 +01:00
Wojtek Figat
802e2ac7c2 Fix compiling stb texture tool on Windows 2025-10-28 21:25:30 +01:00
Wojtek Figat
0ca60062d9 Fix crash on leftover physic contact collision processing 2025-10-28 16:17:48 +01:00
Wojtek Figat
22515c37b5 Fix crash regression in D3D12 UAV bindings code 2025-10-27 22:38:47 +01:00
Wojtek Figat
38a48cf1d4 Update build number 2025-10-27 16:48:52 +01:00
19 changed files with 276 additions and 24 deletions

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

Binary file not shown.

View File

@@ -4,7 +4,7 @@
"Major": 1,
"Minor": 11,
"Revision": 0,
"Build": 6801
"Build": 6802
},
"Company": "Flax",
"Copyright": "Copyright (c) 2012-2025 Wojciech Figat. All rights reserved.",

View File

@@ -130,6 +130,11 @@ namespace FlaxEditor.Content
eyeAdaptation.Mode = EyeAdaptationMode.None;
eyeAdaptation.OverrideFlags |= EyeAdaptationSettingsOverride.Mode;
preview.PostFxVolume.EyeAdaptation = eyeAdaptation;
var antiAliasing = preview.PostFxVolume.AntiAliasing;
antiAliasing.Mode = AntialiasingMode.FastApproximateAntialiasing;
antiAliasing.OverrideFlags |= AntiAliasingSettingsOverride.Mode;
preview.PostFxVolume.AntiAliasing = antiAliasing;
}
}
}

View File

@@ -40,10 +40,11 @@ namespace FlaxEditor.Modules.SourceCodeEditing
var codeEditing = Editor.Instance.CodeEditing;
var vsCode = codeEditing.GetInBuildEditor(CodeEditorTypes.VSCode);
var rider = codeEditing.GetInBuildEditor(CodeEditorTypes.Rider);
var zed = codeEditing.GetInBuildEditor(CodeEditorTypes.Zed);
#if PLATFORM_WINDOW
// Favor the newest Visual Studio
for (int i = (int)CodeEditorTypes.VS2019; i >= (int)CodeEditorTypes.VS2008; i--)
for (int i = (int)CodeEditorTypes.VS2026; i >= (int)CodeEditorTypes.VS2008; i--)
{
var visualStudio = codeEditing.GetInBuildEditor((CodeEditorTypes)i);
if (visualStudio != null)
@@ -66,6 +67,8 @@ namespace FlaxEditor.Modules.SourceCodeEditing
_currentEditor = vsCode;
else if (rider != null)
_currentEditor = rider;
else if (zed != null)
_currentEditor = zed;
else
_currentEditor = codeEditing.GetInBuildEditor(CodeEditorTypes.SystemDefault);
}

View File

@@ -66,6 +66,9 @@ namespace FlaxEditor.Modules.SourceCodeEditing
case CodeEditorTypes.Rider:
Name = "Rider";
break;
case CodeEditorTypes.Zed:
Name = "Zed";
break;
default: throw new ArgumentOutOfRangeException(nameof(type), type, null);
}
}
@@ -83,6 +86,7 @@ namespace FlaxEditor.Modules.SourceCodeEditing
case CodeEditorTypes.VSCodeInsiders:
case CodeEditorTypes.VSCode: return "-vscode -vs2022";
case CodeEditorTypes.Rider: return "-vs2022";
case CodeEditorTypes.Zed: return "-vs2022";
default: return null;
}
}

View File

@@ -6,6 +6,7 @@
#include "ScriptsBuilder.h"
#include "CodeEditors/VisualStudioCodeEditor.h"
#include "CodeEditors/RiderCodeEditor.h"
#include "CodeEditors/ZedEditor.h"
#if USE_VISUAL_STUDIO_DTE
#include "CodeEditors/VisualStudio/VisualStudioEditor.h"
#endif
@@ -241,6 +242,7 @@ bool CodeEditingManagerService::Init()
#endif
VisualStudioCodeEditor::FindEditors(&CodeEditors);
RiderCodeEditor::FindEditors(&CodeEditors);
ZedEditor::FindEditors(&CodeEditors);
CodeEditors.Add(New<SystemDefaultCodeEditor>());
return false;

View File

@@ -77,6 +77,11 @@ API_ENUM(Namespace="FlaxEditor", Attributes="HideInEditor") enum class CodeEdito
/// </summary>
VSCodeInsiders,
/// <summary>
/// Zed
/// </summary>
Zed,
/// <summary>
/// Rider
/// </summary>

View File

@@ -0,0 +1,171 @@
// Copyright (c) Wojciech Figat. All rights reserved.
#include "ZedEditor.h"
#include "Engine/Platform/FileSystem.h"
#include "Engine/Platform/CreateProcessSettings.h"
#include "Engine/Core/Log.h"
#include "Editor/Editor.h"
#include "Editor/ProjectInfo.h"
#include "Editor/Scripting/ScriptsBuilder.h"
#include "Engine/Engine/Globals.h"
#if PLATFORM_LINUX
#include <stdio.h>
#elif PLATFORM_WINDOWS
#include "Engine/Platform/Win32/IncludeWindowsHeaders.h"
#elif PLATFORM_MAC
#include "Engine/Platform/Apple/AppleUtils.h"
#include <AppKit/AppKit.h>
#endif
ZedEditor::ZedEditor(const String& execPath)
: _execPath(execPath)
, _workspacePath(Globals::ProjectFolder)
{
}
void ZedEditor::FindEditors(Array<CodeEditor*>* output)
{
#if PLATFORM_WINDOWS
String cmd;
if (Platform::ReadRegValue(HKEY_CURRENT_USER, TEXT("SOFTWARE\\Classes\\Applications\\Zed.exe\\shell\\open\\command"), TEXT(""), &cmd) || cmd.IsEmpty())
{
if (Platform::ReadRegValue(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Classes\\Applications\\Zed.exe\\shell\\open\\command"), TEXT(""), &cmd) || cmd.IsEmpty())
{
// No hits in registry, try default path instead
}
}
String path;
if (cmd.IsEmpty())
{
path = cmd.Substring(1, cmd.Length() - String(TEXT("\" \"%1\"")).Length() - 1);
}
else
{
String localAppDataPath;
FileSystem::GetSpecialFolderPath(SpecialFolder::LocalAppData, localAppDataPath);
path = localAppDataPath / TEXT("Programs/Zed/Zed.exe");
}
if (FileSystem::FileExists(path))
{
output->Add(New<ZedEditor>(path));
}
#elif PLATFORM_LINUX
char buffer[128];
FILE* pipe = popen("/bin/bash -c \"type -p code\"", "r");
if (pipe)
{
StringAnsi pathAnsi;
while (fgets(buffer, sizeof(buffer), pipe) != NULL)
pathAnsi += buffer;
pclose(pipe);
const String path(pathAnsi.Get(), pathAnsi.Length() != 0 ? pathAnsi.Length() - 1 : 0);
if (FileSystem::FileExists(path))
{
output->Add(New<VisualStudioCodeEditor>(path, false));
return;
}
}
{
const String path(TEXT("/usr/bin/code"));
if (FileSystem::FileExists(path))
{
output->Add(New<VisualStudioCodeEditor>(path, false));
return;
}
}
// Detect Flatpak installations
{
CreateProcessSettings procSettings;
procSettings.FileName = TEXT("/bin/bash -c \"flatpak list --app --columns=application | grep com.visualstudio.code -c\"");
procSettings.HiddenWindow = true;
if (Platform::CreateProcess(procSettings) == 0)
{
const String runPath(TEXT("flatpak run com.visualstudio.code"));
output->Add(New<VisualStudioCodeEditor>(runPath, false));
return;
}
}
#elif PLATFORM_MAC
// System installed app
NSURL* AppURL = [[NSWorkspace sharedWorkspace]URLForApplicationWithBundleIdentifier:@"com.microsoft.VSCode"];
if (AppURL != nullptr)
{
const String path = AppleUtils::ToString((CFStringRef)[AppURL path]);
output->Add(New<VisualStudioCodeEditor>(path, false));
return;
}
// Predefined locations
String userFolder;
FileSystem::GetSpecialFolderPath(SpecialFolder::Documents, userFolder);
String paths[3] =
{
TEXT("/Applications/Visual Studio Code.app"),
userFolder + TEXT("/../Visual Studio Code.app"),
userFolder + TEXT("/../Downloads/Visual Studio Code.app"),
};
for (const String& path : paths)
{
if (FileSystem::DirectoryExists(path))
{
output->Add(New<VisualStudioCodeEditor>(path, false));
break;
}
}
#endif
}
CodeEditorTypes ZedEditor::GetType() const
{
return CodeEditorTypes::Zed;
}
String ZedEditor::GetName() const
{
return TEXT("Zed");
}
void ZedEditor::OpenFile(const String& path, int32 line)
{
// Generate VS solution files for intellisense
if (!FileSystem::FileExists(Globals::ProjectFolder / Editor::Project->Name + TEXT(".sln")))
{
ScriptsBuilder::GenerateProject(TEXT("-vs2022"));
}
// Open file
line = line > 0 ? line : 1;
CreateProcessSettings procSettings;
procSettings.FileName = _execPath;
procSettings.Arguments = String::Format(TEXT("\"{0}\" \"{1}:{2}\""), _workspacePath, path, line);
procSettings.HiddenWindow = false;
procSettings.WaitForEnd = false;
procSettings.LogOutput = false;
procSettings.ShellExecute = true;
Platform::CreateProcess(procSettings);
}
void ZedEditor::OpenSolution()
{
// Generate VS solution files for intellisense
if (!FileSystem::FileExists(Globals::ProjectFolder / Editor::Project->Name + TEXT(".sln")))
{
ScriptsBuilder::GenerateProject(TEXT("-vs2022"));
}
// Open solution
CreateProcessSettings procSettings;
procSettings.FileName = _execPath;
procSettings.Arguments = String::Format(TEXT("\"{0}\""), _workspacePath);
procSettings.HiddenWindow = false;
procSettings.WaitForEnd = false;
procSettings.LogOutput = false;
procSettings.ShellExecute = true;
Platform::CreateProcess(procSettings);
}
bool ZedEditor::UseAsyncForOpen() const
{
return false;
}

View File

@@ -0,0 +1,41 @@
// Copyright (c) Wojciech Figat. All rights reserved.
#pragma once
#include "Editor/Scripting/CodeEditor.h"
/// <summary>
/// Implementation of code editor utility that is using Microsoft Visual Studio Code.
/// </summary>
class ZedEditor : public CodeEditor
{
private:
String _execPath;
String _workspacePath;
public:
/// <summary>
/// Initializes a new instance of the <see cref="VisualStudioEditor"/> class.
/// </summary>
/// <param name="execPath">Executable file path</param>
ZedEditor(const String& execPath);
public:
/// <summary>
/// Tries to find installed Visual Studio Code instance. Adds them to the result list.
/// </summary>
/// <param name="output">The output editors.</param>
static void FindEditors(Array<CodeEditor*>* output);
public:
// [CodeEditor]
CodeEditorTypes GetType() const override;
String GetName() const override;
void OpenFile(const String& path, int32 line) override;
void OpenSolution() override;
bool UseAsyncForOpen() const override;
};

View File

@@ -491,7 +491,7 @@ void GPUContextDX12::flushUAVs()
ASSERT(uaCount <= GPU_MAX_UA_BINDED);
// Fill table with source descriptors
DxShaderHeader& header = _currentCompute ? ((GPUShaderProgramCSDX12*)_currentCompute)->Header : _currentState->Header;
DxShaderHeader& header = _isCompute ? ((GPUShaderProgramCSDX12*)_currentCompute)->Header : _currentState->Header;
D3D12_CPU_DESCRIPTOR_HANDLE srcDescriptorRangeStarts[GPU_MAX_UA_BINDED];
for (uint32 i = 0; i < uaCount; i++)
{

View File

@@ -1969,6 +1969,7 @@ void PhysicsBackend::EndSimulateScene(void* scene)
scenePhysX->EventsCallback.SendTriggerEvents();
scenePhysX->EventsCallback.SendCollisionEvents();
scenePhysX->EventsCallback.SendJointEvents();
scenePhysX->EventsCallback.Clear();
}
// Clear delta after simulation ended
@@ -4466,14 +4467,14 @@ void PhysicsBackend::FlushRequests(void* scene)
}
if (scenePhysX->RemoveColliders.HasItems())
{
for (int32 i = 0; i < scenePhysX->RemoveColliders.Count(); i++)
scenePhysX->EventsCallback.OnColliderRemoved(scenePhysX->RemoveColliders[i]);
for (PhysicsColliderActor* e : scenePhysX->RemoveColliders)
scenePhysX->EventsCallback.OnColliderRemoved(e);
scenePhysX->RemoveColliders.Clear();
}
if (scenePhysX->RemoveJoints.HasItems())
{
for (int32 i = 0; i < scenePhysX->RemoveJoints.Count(); i++)
scenePhysX->EventsCallback.OnJointRemoved(scenePhysX->RemoveJoints[i]);
for (Joint* e : scenePhysX->RemoveJoints)
scenePhysX->EventsCallback.OnJointRemoved(e);
scenePhysX->RemoveJoints.Clear();
}

View File

@@ -47,6 +47,9 @@ public:
Data CachedData;
ToneMappingMode Mode = ToneMappingMode::None;
Texture* LutTexture = nullptr;
#if COMPILE_WITH_DEV_ENV
uint64 FrameRendered = 0;
#endif
~ColorGradingCustomBuffer()
{
@@ -54,6 +57,17 @@ public:
}
};
#if COMPILE_WITH_DEV_ENV
void ColorGradingPass::OnShaderReloading(Asset* obj)
{
_psLut.Release();
invalidateResources();
_reloadedFrame = Engine::FrameCount;
}
#endif
String ColorGradingPass::ToString() const
{
return TEXT("ColorGradingPass");
@@ -194,6 +208,9 @@ GPUTexture* ColorGradingPass::RenderLUT(RenderContext& renderContext)
// Check if LUT parameter hasn't been changed since the last time
if (Platform::MemoryCompare(&colorGradingBuffer.CachedData , &data, sizeof(Data)) == 0 &&
colorGradingBuffer.Mode == toneMapping.Mode &&
#if COMPILE_WITH_DEV_ENV
colorGradingBuffer.FrameRendered > _reloadedFrame &&
#endif
Engine::FrameCount > 30 && // Skip caching when engine is starting TODO: find why this hack is needed
colorGradingBuffer.LutTexture == lutTexture)
{
@@ -203,6 +220,9 @@ GPUTexture* ColorGradingPass::RenderLUT(RenderContext& renderContext)
colorGradingBuffer.CachedData = data;
colorGradingBuffer.Mode = toneMapping.Mode;
colorGradingBuffer.LutTexture = lutTexture;
#if COMPILE_WITH_DEV_ENV
colorGradingBuffer.FrameRendered = Engine::FrameCount;
#endif
// Render LUT
PROFILE_GPU("Color Grading LUT");

View File

@@ -25,11 +25,8 @@ public:
private:
#if COMPILE_WITH_DEV_ENV
void OnShaderReloading(Asset* obj)
{
_psLut.Release();
invalidateResources();
}
uint64 _reloadedFrame = 0;
void OnShaderReloading(Asset* obj);
#endif
public:

View File

@@ -98,6 +98,7 @@ void EyeAdaptationPass::Render(RenderContext& renderContext, GPUTexture* colorBu
if (mode == EyeAdaptationMode::Manual)
{
// Apply fixed manual exposure
context->ResetSR();
context->SetRenderTarget(*colorBuffer);
context->SetViewportAndScissors((float)colorBuffer->Width(), (float)colorBuffer->Height());
context->SetState(_psManual);

View File

@@ -32,7 +32,7 @@ public class Scripting : EngineModule
options.ScriptingAPI.Defines.Add("NET");
AddFrameworkDefines("NET{0}_{1}", dotnetSdk.Version.Major, 0); // "NET7_0"
for (int i = 5; i <= dotnetSdk.Version.Major; i++)
AddFrameworkDefines("NET{0}_{1}_OR_GREATER", dotnetSdk.Version.Major, 0); // "NET7_0_OR_GREATER"
AddFrameworkDefines("NET{0}_{1}_OR_GREATER", i, 0); // "NET7_0_OR_GREATER"
options.ScriptingAPI.Defines.Add("NETCOREAPP");
AddFrameworkDefines("NETCOREAPP{0}_{1}_OR_GREATER", 3, 1); // "NETCOREAPP3_1_OR_GREATER"
AddFrameworkDefines("NETCOREAPP{0}_{1}_OR_GREATER", 2, 2);

View File

@@ -65,6 +65,8 @@
#endif
#undef MessageBox
static void stbWrite(void* context, void* data, int size)
{
auto file = (FileWriteStream*)context;

View File

@@ -164,16 +164,14 @@ float3 TonemapACES(float3 linearColor)
// The code was originally written by Stephen Hill (@self_shadow).
// sRGB => XYZ => D65_2_D60 => AP1 => RRT_SAT
static const float3x3 ACESInputMat =
{
static const float3x3 ACESInputMat = {
{0.59719, 0.35458, 0.04823},
{0.07600, 0.90834, 0.01566},
{0.02840, 0.13383, 0.83777}
};
// ODT_SAT => XYZ => D60_2_D65 => sRGB
static const float3x3 ACESOutputMat =
{
static const float3x3 ACESOutputMat = {
{ 1.60475, -0.53108, -0.07367},
{-0.10208, 1.10813, -0.00605},
{-0.00327, -0.07276, 1.07602}
@@ -188,6 +186,7 @@ float3 TonemapACES(float3 linearColor)
color = a / b;
color = mul(ACESOutputMat, color);
return saturate(color);
}

View File

@@ -37,7 +37,7 @@ float4 FastTonemapInvert(float4 c)
return float4(FastTonemapInvert(c.rgb), c.a);
}
float LinearToSrgbChannel(float linearColor)
float LinearToSrgb(float linearColor)
{
if (linearColor < 0.00313067)
return linearColor * 12.92;
@@ -46,10 +46,7 @@ float LinearToSrgbChannel(float linearColor)
float3 LinearToSrgb(float3 linearColor)
{
return float3(
LinearToSrgbChannel(linearColor.r),
LinearToSrgbChannel(linearColor.g),
LinearToSrgbChannel(linearColor.b));
return float3(LinearToSrgb(linearColor.r), LinearToSrgb(linearColor.g), LinearToSrgb(linearColor.b));
}
float3 sRGBToLinear(float3 color)

View File

@@ -72,7 +72,11 @@ __BEGIN_DECLS
#include <stdint.h>
#include <stdbool.h>
#if defined(_MSC_VER)
#define DETEX_INLINE_ONLY __forceinline
#else
#define DETEX_INLINE_ONLY __attribute__((always_inline)) inline
#endif
#define DETEX_RESTRICT __restrict
/* Maximum uncompressed block size in bytes. */