Merge remote-tracking branch 'origin/master' into 1.13

# Conflicts:
#	Content/Shaders/Editor/Grid.flax
#	Content/Shaders/GBuffer.flax
#	Content/Shaders/GlobalSignDistanceField.flax
#	Content/Shaders/ProbesFilter.flax
#	Content/Shaders/SSR.flax
#	Content/Shaders/VolumetricFog.flax
#	Development/Documentation/mono.md
#	Source/Editor/Modules/ContentDatabaseModule.cs
This commit is contained in:
2026-08-30 22:23:31 +02:00
34 changed files with 604 additions and 269 deletions
@@ -26,6 +26,8 @@
#if USE_EDITOR
#define COMPILE_WITH_ASSETS_IMPORTER 1 // Hack to use shaders importing in this module
#include "Engine/ContentImporters/AssetsImportingManager.h"
#include "Engine/Content/Storage/ContentStorageManager.h"
#include "Engine/Utilities/Encryption.h"
#include "Engine/Platform/FileSystemWatcher.h"
#include "Engine/Platform/FileSystem.h"
#include "Engine/Platform/File.h"
@@ -499,6 +501,37 @@ String ShadersCompilation::CompactShaderPath(StringView path)
#if USE_EDITOR
bool ShadersCompilation::IsShaderSourceAssetUpToDate(const StringView& sourcePath, const StringView& assetPath)
{
PROFILE_CPU();
StringAnsi source;
if (File::ReadAllText(sourcePath, source))
return false;
if (!source.HasChars() || source[source.Length() - 1] != '\n')
source.Append('\n');
const auto storage = ContentStorageManager::GetStorage(assetPath);
AssetInitData data;
if (!storage
|| storage->GetEntriesCount() != 1
|| storage->GetEntry(0).TypeName != Shader::TypeName
|| storage->LoadAssetHeader(0, data)
|| data.SerializedVersion != Shader::SerializedVersion)
return false;
FlaxChunk* sourceChunk = data.Header.Chunks[SHADER_FILE_CHUNK_SOURCE];
if (!sourceChunk || storage->LoadAssetChunk(sourceChunk) || !sourceChunk->Data.IsValid())
return false;
BytesContainer embeddedSource;
embeddedSource.Copy(sourceChunk->Data);
if (embeddedSource.Length() != source.Length() + 1)
return false;
Encryption::DecryptBytes(embeddedSource.Get(), embeddedSource.Length());
embeddedSource.Get()[embeddedSource.Length() - 1] = 0;
return Platform::MemoryCompare(embeddedSource.Get(), source.Get(), source.Length()) == 0;
}
namespace
{
Array<FileSystemWatcher*> ShadersSourcesWatchers;
@@ -515,6 +548,13 @@ namespace
return result;
}
bool ImportShaderIfChanged(const StringView& sourcePath, const StringView& assetPath, Guid& assetId)
{
if (ShadersCompilation::IsShaderSourceAssetUpToDate(sourcePath, assetPath))
return false;
return AssetsImportingManager::Import(sourcePath, assetPath, assetId);
}
void OnWatcherShadersEvent(const String& path, FileSystemAction action)
{
if (action == FileSystemAction::Delete || !path.EndsWith(TEXT(".shader")))
@@ -538,7 +578,7 @@ namespace
const String name = StringUtils::GetPathWithoutExtension(localPath);
const String outputPath = shadersAssetsPath / name + ASSET_FILES_EXTENSION_WITH_DOT;
Guid id = GetShaderAssetId(name);
AssetsImportingManager::ImportIfEdited(path, outputPath, id);
ImportShaderIfChanged(path, outputPath, id);
}
void RegisterShaderWatchers(const ProjectInfo* project, HashSet<const ProjectInfo*>& projects)
@@ -567,7 +607,7 @@ namespace
const String name = StringUtils::GetPathWithoutExtension(localPath);
const String outputPath = shadersAssetsPath / name + ASSET_FILES_EXTENSION_WITH_DOT;
Guid id = GetShaderAssetId(name);
AssetsImportingManager::ImportIfEdited(path, outputPath, id);
ImportShaderIfChanged(path, outputPath, id);
}
}