Optimization and tweaks

This commit is contained in:
Wojtek Figat
2021-04-29 23:20:37 +02:00
parent e2789214ae
commit 05f919c50f
36 changed files with 100 additions and 133 deletions

View File

@@ -38,9 +38,10 @@ void Asset::OnDeleteObject()
if (!IsInternalType())
Content::AssetDisposing(this);
// Cache data
const bool wasMarkedToDelete = _deleteFileOnUnload != 0;
#if USE_EDITOR
const String path = wasMarkedToDelete ? GetPath() : String::Empty;
#endif
const Guid id = GetID();
// Fire unload event (every object referencing this asset or it's data should release reference so later actions are safe)
@@ -66,7 +67,7 @@ void Asset::OnDeleteObject()
// Base (after it `this` is invalid)
ManagedScriptingObject::OnDeleteObject();
// Check if asset was marked to delete
#if USE_EDITOR
if (wasMarkedToDelete)
{
LOG(Info, "Deleting asset '{0}':{1}.", path, id.ToString());
@@ -77,6 +78,7 @@ void Asset::OnDeleteObject()
// Delete file
Content::deleteFileSafety(path, id);
}
#endif
}
void Asset::CreateManaged()
@@ -131,6 +133,20 @@ void Asset::ChangeID(const Guid& newId)
CRASH;
}
bool Asset::LastLoadFailed() const
{
return _loadFailed != 0;
}
#if USE_EDITOR
bool Asset::ShouldDeleteFileOnUnload() const
{
return _deleteFileOnUnload != 0;
}
#endif
void Asset::Reload()
{
// It's better to call it from the main thread
@@ -335,7 +351,7 @@ void Asset::startLoading()
bool Asset::onLoad(LoadAssetTask* task)
{
// It may fail when task is cancelled and new one is created later (don't crash but just end with an error)
if (task->GetAsset() != this || _loadingTask == nullptr)
if (task->Asset.Get() != this || _loadingTask == nullptr)
return true;
Locker.Lock();

View File

@@ -82,7 +82,6 @@ public:
/// <summary>
/// Gets asset's reference count. Asset will be automatically unloaded when this reaches zero.
/// </summary>
/// <returns>The amount of references to that asset.</returns>
API_PROPERTY() int32 GetReferencesCount() const
{
return (int32)Platform::AtomicRead(const_cast<int64 volatile*>(&_refCount));
@@ -109,19 +108,16 @@ public:
/// <summary>
/// Gets the path to the asset storage.
/// </summary>
/// <returns>The asset file.</returns>
API_PROPERTY() virtual const String& GetPath() const = 0;
/// <summary>
/// Gets the asset type name.
/// </summary>
/// <returns>The typename.</returns>
virtual const String& GetTypeName() const = 0;
/// <summary>
/// Returns true if asset is loaded, otherwise false.
/// </summary>
/// <returns><c>true</c> if this asset is loaded; otherwise, <c>false</c>.</returns>
API_PROPERTY() FORCE_INLINE bool IsLoaded() const
{
return _isLoaded != 0;
@@ -130,16 +126,11 @@ public:
/// <summary>
/// Returns true if last asset loading failed, otherwise false.
/// </summary>
/// <returns><c>true</c> if last asset loading failed; otherwise, <c>false</c>.</returns>
API_PROPERTY() FORCE_INLINE bool LastLoadFailed() const
{
return _loadFailed != 0;
}
API_PROPERTY() bool LastLoadFailed() const;
/// <summary>
/// Determines whether this asset is virtual (generated or temporary, has no storage so it won't be saved).
/// </summary>
/// <returns><c>true</c> if this asset is virtual; otherwise, <c>false</c>.</returns>
API_PROPERTY() FORCE_INLINE bool IsVirtual() const
{
return _isVirtual != 0;
@@ -150,11 +141,7 @@ public:
/// <summary>
/// Determines whether this asset was marked to be deleted on unload.
/// </summary>
/// <returns><c>true</c> if this asset file was marked to be deleted on asset unload; otherwise, <c>false</c>.</returns>
API_PROPERTY() FORCE_INLINE bool ShouldDeleteFileOnUnload() const
{
return _deleteFileOnUnload != 0;
}
API_PROPERTY() bool ShouldDeleteFileOnUnload() const;
#endif

View File

@@ -74,7 +74,7 @@ BytesContainer AnimationGraph::LoadSurface()
return result;
}
LOG(Warning, "Animation Graph \'{0}\' surface data is missing.", GetPath());
LOG(Warning, "Animation Graph \'{0}\' surface data is missing.", ToString());
return BytesContainer();
}

View File

@@ -311,7 +311,12 @@ Asset::LoadResult Material::load()
{
// Load material (load shader from cache, load params, setup pipeline stuff)
MemoryReadStream shaderCacheStream(shaderCache.Data.Get(), shaderCache.Data.Length());
_materialShader = MaterialShader::Create(GetPath(), shaderCacheStream, _shaderHeader.Material.Info);
#if GPU_ENABLE_RESOURCE_NAMING
const StringView name(GetPath());
#else
const StringView name;
#endif
_materialShader = MaterialShader::Create(name, shaderCacheStream, _shaderHeader.Material.Info);
if (_materialShader == nullptr)
{
LOG(Warning, "Cannot load material.");
@@ -483,7 +488,7 @@ BytesContainer Material::LoadSurface(bool createDefaultIfMissing)
}
}
LOG(Warning, "Material \'{0}\' surface data is missing.", GetPath());
LOG(Warning, "Material \'{0}\' surface data is missing.", ToString());
#if COMPILE_WITH_MATERIAL_GRAPH

View File

@@ -821,7 +821,7 @@ Asset::LoadResult Model::load()
const auto thisSS = LODs[lodIndex].ScreenSize;
if (prevSS <= thisSS)
{
LOG(Warning, "Model LOD {0} has invalid screen size compared to LOD {1} (asset: {2})", lodIndex, lodIndex - 1, GetPath());
LOG(Warning, "Model LOD {0} has invalid screen size compared to LOD {1} (asset: {2})", lodIndex, lodIndex - 1, ToString());
}
}
#endif

View File

@@ -2132,7 +2132,7 @@ BytesContainer VisualScript::LoadSurface()
return result;
}
LOG(Warning, "\'{0}\' surface data is missing.", GetPath());
LOG(Warning, "\'{0}\' surface data is missing.", ToString());
return BytesContainer();
}

View File

@@ -301,7 +301,12 @@ bool BinaryAsset::LoadChunks(AssetChunksFlag chunks)
#if USE_EDITOR
bool BinaryAsset::SaveAsset(const StringView& path, AssetInitData& data, bool silentMode)
bool BinaryAsset::SaveAsset(AssetInitData& data, bool silentMode) const
{
return SaveAsset(GetPath(), data, silentMode);
}
bool BinaryAsset::SaveAsset(const StringView& path, AssetInitData& data, bool silentMode) const
{
data.Header = _header;
data.Metadata.Link(Metadata);

View File

@@ -270,10 +270,7 @@ public:
/// <param name="data">Asset data.</param>
/// <param name="silentMode">In silent mode don't reload opened storage container that is using target file.</param>
/// <returns>True if failed, otherwise false.</returns>
FORCE_INLINE bool SaveAsset(AssetInitData& data, bool silentMode = false)
{
return SaveAsset(GetPath(), data, silentMode);
}
bool SaveAsset(AssetInitData& data, bool silentMode = false) const;
/// <summary>
/// Saves this asset to the file.
@@ -282,7 +279,7 @@ public:
/// <param name="path">Asset path (will be used to override the asset or create a new one).</param>
/// <param name="silentMode">In silent mode don't reload opened storage container that is using target file.</param>
/// <returns>True if failed, otherwise false.</returns>
bool SaveAsset(const StringView& path, AssetInitData& data, bool silentMode = false);
bool SaveAsset(const StringView& path, AssetInitData& data, bool silentMode = false) const;
/// <summary>
/// Saves asset data to the storage container. Asset unique ID is handled by auto.

View File

@@ -15,19 +15,13 @@
bool BinaryAssetFactoryBase::Init(BinaryAsset* asset)
{
ASSERT(asset && asset->Storage);
// Prepare
auto storage = asset->Storage;
AssetInfo info;
info.ID = asset->GetID();
info.TypeName = asset->GetTypeName();
info.Path = storage->GetPath();
// Load serialized asset data
AssetInitData initData;
if (storage->LoadAssetHeader(info.ID, initData))
if (storage->LoadAssetHeader(asset->GetID(), initData))
{
LOG(Error, "Cannot load asset header.\nInfo: {0}", info.ToString());
LOG(Error, "Cannot load asset header.\nInfo: {0}", AssetInfo(asset->GetID(), asset->GetTypeName(), storage->GetPath()).ToString());
return true;
}
@@ -37,6 +31,7 @@ bool BinaryAssetFactoryBase::Init(BinaryAsset* asset)
if (storage->AllowDataModifications() && upgrader && upgrader->ShouldUpgrade(initData.SerializedVersion))
{
const auto startTime = DateTime::NowUTC();
const AssetInfo info(asset->GetID(), asset->GetTypeName(), storage->GetPath());
LOG(Info, "Starting asset \'{0}\' conversion", info.Path);
// Backup source file (in case of conversion failure)
@@ -100,14 +95,14 @@ bool BinaryAssetFactoryBase::Init(BinaryAsset* asset)
// Check if serialized asset version is supported
if (!IsVersionSupported(initData.SerializedVersion))
{
LOG(Warning, "Asset version {1} is not supported.\nInfo: {0}", info.ToString(), initData.SerializedVersion);
LOG(Warning, "Asset version {1} is not supported.\nInfo: {0}", AssetInfo(asset->GetID(), asset->GetTypeName(), storage->GetPath()).ToString(), initData.SerializedVersion);
return true;
}
// Initialize asset
if (asset->Init(initData))
{
LOG(Error, "Cannot initialize asset.\nInfo: {0}", info.ToString());
LOG(Error, "Cannot initialize asset.\nInfo: {0}", AssetInfo(asset->GetID(), asset->GetTypeName(), storage->GetPath()).ToString());
return true;
}

View File

@@ -1,10 +1,11 @@
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#include "JsonAsset.h"
#include "Storage/ContentStorageManager.h"
#include "Engine/Threading/Threading.h"
#if USE_EDITOR
#include "Engine/Platform/File.h"
#else
#include "Storage/ContentStorageManager.h"
#endif
#include "FlaxEngine.Gen.h"
#include "Engine/Core/Log.h"

View File

@@ -13,10 +13,6 @@
/// </summary>
class LoadAssetTask : public ContentLoadTask
{
private:
WeakAssetReference<Asset> _asset;
public:
/// <summary>
@@ -25,27 +21,20 @@ public:
/// <param name="asset">The asset to load.</param>
LoadAssetTask(Asset* asset)
: ContentLoadTask(Type::LoadAsset)
, _asset(asset)
, Asset(asset)
{
}
public:
/// <summary>
/// Gets the asset.
/// </summary>
/// <returns>The asset.</returns>
FORCE_INLINE Asset* GetAsset() const
{
return _asset.Get();
}
WeakAssetReference<Asset> Asset;
public:
// [ContentLoadTask]
bool HasReference(Object* obj) const override
{
return obj == _asset;
return obj == Asset;
}
protected:
@@ -55,7 +44,8 @@ protected:
{
PROFILE_CPU();
AssetReference<Asset> ref = _asset.Get();
// Keep valid ref to the asset
AssetReference<::Asset> ref = Asset.Get();
if (ref == nullptr)
return Result::MissingReferences;
@@ -68,7 +58,7 @@ protected:
void OnEnd() override
{
_asset = nullptr;
Asset = nullptr;
// Base
ContentLoadTask::OnEnd();

View File

@@ -31,7 +31,7 @@ bool JsonStorageProxy::GetAssetInfo(const StringView& path, Guid& resultId, Stri
document.Parse((const char*)fileData.Get(), fileData.Count());
if (document.HasParseError())
{
Log::JsonParseException(document.GetParseError(), document.GetErrorOffset(), String(path));
Log::JsonParseException(document.GetParseError(), document.GetErrorOffset(), path);
return false;
}
@@ -94,7 +94,7 @@ bool JsonStorageProxy::ChangeId(const StringView& path, const Guid& newId)
document.Parse((const char*)fileData.Get(), fileData.Count());
if (document.HasParseError())
{
Log::JsonParseException(document.GetParseError(), document.GetErrorOffset(), String(path));
Log::JsonParseException(document.GetParseError(), document.GetErrorOffset(), path);
return false;
}

View File

@@ -332,7 +332,7 @@ bool AssetsImportingManager::Create(const Function<CreateAssetResult(CreateAsset
else
{
// Ensure that path exists
const String outputDirectory = StringUtils::GetDirectoryName(*outputPath);
const String outputDirectory = StringUtils::GetDirectoryName(outputPath);
if (FileSystem::CreateDirectory(outputDirectory))
{
LOG(Warning, "Cannot create directory '{0}'", outputDirectory);

View File

@@ -26,10 +26,7 @@ namespace AllocatorExt
return nullptr;
}
if (!ptr)
{
return Allocator::Allocate(newSize);
}
void* result = Allocator::Allocate(newSize);
if (result)
{
@@ -55,14 +52,9 @@ namespace AllocatorExt
return nullptr;
}
if (!ptr)
{
return Allocator::Allocate(newSize);
}
if (newSize <= oldSize)
{
return ptr;
}
void* result = Allocator::Allocate(newSize);
if (result)
{

View File

@@ -25,7 +25,7 @@ namespace Log
/// <param name="error">Parsing error code.</param>
/// <param name="offset">Parsing error location.</param>
JsonParseException(ErrorCode error, size_t offset)
: JsonParseException(error, offset, String::Empty)
: JsonParseException(error, offset, StringView::Empty)
{
}
@@ -35,7 +35,7 @@ namespace Log
/// <param name="error">Parsing error code.</param>
/// <param name="offset">Parsing error location.</param>
/// <param name="additionalInfo">Additional information that help describe error</param>
JsonParseException(ErrorCode error, size_t offset, const String& additionalInfo)
JsonParseException(ErrorCode error, size_t offset, const StringView& additionalInfo)
: Exception(String::Format(TEXT("Parsing Json failed with error code {0} (offset {2}). {1}"), static_cast<int32>(error), GetParseError_En(error), offset), additionalInfo)
{
}

View File

@@ -33,7 +33,7 @@ public:
/// Init
/// </summary>
/// <param name="name">Material resource name</param>
DecalMaterialShader(const String& name)
DecalMaterialShader(const StringView& name)
: MaterialShader(name)
{
}

View File

@@ -56,7 +56,7 @@ private:
public:
DeferredMaterialShader(const String& name)
DeferredMaterialShader(const StringView& name)
: MaterialShader(name)
{
}

View File

@@ -44,7 +44,7 @@ private:
public:
DeformableMaterialShader(const String& name)
DeformableMaterialShader(const StringView& name)
: MaterialShader(name)
{
}

View File

@@ -58,7 +58,7 @@ public:
/// Init
/// </summary>
/// <param name="name">Material resource name</param>
ForwardMaterialShader(const String& name)
ForwardMaterialShader(const StringView& name)
: MaterialShader(name)
{
}

View File

@@ -33,7 +33,7 @@ public:
/// Init
/// </summary>
/// <param name="name">Material resource name</param>
GUIMaterialShader(const String& name)
GUIMaterialShader(const StringView& name)
: MaterialShader(name)
{
}

View File

@@ -54,7 +54,7 @@ GPUPipelineState* MaterialShader::PipelineStateCache::InitPS(CullMode mode, bool
return ps;
}
MaterialShader::MaterialShader(const String& name)
MaterialShader::MaterialShader(const StringView& name)
: _isLoaded(false)
, _shader(nullptr)
{
@@ -68,7 +68,7 @@ MaterialShader::~MaterialShader()
SAFE_DELETE_GPU_RESOURCE(_shader);
}
MaterialShader* MaterialShader::Create(const String& name, MemoryReadStream& shaderCacheStream, const MaterialInfo& info)
MaterialShader* MaterialShader::Create(const StringView& name, MemoryReadStream& shaderCacheStream, const MaterialInfo& info)
{
MaterialShader* material;
switch (info.Domain)

View File

@@ -72,7 +72,7 @@ protected:
/// Init
/// </summary>
/// <param name="name">Material resource name</param>
MaterialShader(const String& name);
MaterialShader(const StringView& name);
public:
@@ -90,7 +90,7 @@ public:
/// <param name="shaderCacheStream">Stream with compiled shader data</param>
/// <param name="info">Loaded material info structure</param>
/// <returns>The created and loaded material or null if failed.</returns>
static MaterialShader* Create(const String& name, MemoryReadStream& shaderCacheStream, const MaterialInfo& info);
static MaterialShader* Create(const StringView& name, MemoryReadStream& shaderCacheStream, const MaterialInfo& info);
/// <summary>
/// Creates the dummy material used by the Null rendering backend to mock object but not perform any rendering.

View File

@@ -54,7 +54,7 @@ public:
/// Init
/// </summary>
/// <param name="name">Material resource name</param>
ParticleMaterialShader(const String& name)
ParticleMaterialShader(const StringView& name)
: MaterialShader(name)
{
}

View File

@@ -31,7 +31,7 @@ public:
/// Init
/// </summary>
/// <param name="name">Material resource name</param>
PostFxMaterialShader(const String& name)
PostFxMaterialShader(const StringView& name)
: MaterialShader(name)
{
}

View File

@@ -48,7 +48,7 @@ public:
/// Init
/// </summary>
/// <param name="name">Material resource name</param>
TerrainMaterialShader(const String& name)
TerrainMaterialShader(const StringView& name)
: MaterialShader(name)
{
}

View File

@@ -19,7 +19,7 @@ public:
/// Init
/// </summary>
/// <param name="name">Material resource name</param>
VolumeParticleMaterialShader(const String& name)
VolumeParticleMaterialShader(const StringView& name)
: MaterialShader(name)
{
}

View File

@@ -39,7 +39,12 @@ bool GPUParticles::Init(ParticleEmitter* owner, MemoryReadStream& shaderCacheStr
// Load shader
ASSERT(GPUDevice::Instance);
_shader = GPUDevice::Instance->CreateShader(owner->GetPath());
#if GPU_ENABLE_RESOURCE_NAMING
const StringView name(owner->GetPath());
#else
const StringView name;
#endif
_shader = GPUDevice::Instance->CreateShader(name);
if (_shader->Create(shaderCacheStream))
{
LOG(Warning, "Failed to load shader.");

View File

@@ -77,16 +77,6 @@ int32 CalculateDpi(HMODULE shCoreDll)
return (dpiX + dpiY) / 2;
}
int32 CalculateDpi()
{
if (const HMODULE shCoreDll = LoadLibraryW(L"Shcore.dll"))
{
return CalculateDpi(shCoreDll);
}
return 96;
}
LONG GetStringRegKey(HKEY hKey, const Char* strValueName, String& strValue, const String& strDefaultValue)
{
strValue = strDefaultValue;

View File

@@ -7,7 +7,7 @@
#include "Engine/Threading/ThreadRegistry.h"
THREADLOCAL ProfilerCPU::Thread* ProfilerCPU::Thread::Current = nullptr;
Array<ProfilerCPU::Thread*> ProfilerCPU::Threads(64);
Array<ProfilerCPU::Thread*, InlinedAllocation<64>> ProfilerCPU::Threads;
bool ProfilerCPU::Enabled = false;
void ProfilerCPU::EventBuffer::Extract(Array<Event>& data, bool withRemove)

View File

@@ -318,7 +318,7 @@ public:
/// <summary>
/// The registered threads.
/// </summary>
static Array<Thread*> Threads;
static Array<Thread*, InlinedAllocation<64>> Threads;
/// <summary>
/// The profiling tools usage flag. Can be used to disable profiler. Engine turns it down before the exit and before platform startup.

View File

@@ -55,6 +55,13 @@ int32 ProfilerGPU::EventBuffer::Add(const Event& e)
return index;
}
void ProfilerGPU::EventBuffer::Clear()
{
_data.Clear();
_isResolved = false;
FrameIndex = 0;
}
GPUTimerQuery* ProfilerGPU::GetTimerQuery()
{
GPUTimerQuery* result;

View File

@@ -62,21 +62,9 @@ public:
{
private:
bool _isResolved;
bool _isResolved = true;
Array<Event> _data;
public:
EventBuffer()
: _data(256)
{
_isResolved = true;
}
~EventBuffer()
{
}
public:
/// <summary>
@@ -87,7 +75,6 @@ public:
/// <summary>
/// Determines whether this buffer has ready data (resolved and not empty).
/// </summary>
/// <returns><c>true</c> if this buffer has data; otherwise, <c>false</c>.</returns>
FORCE_INLINE bool HasData() const
{
return _isResolved && _data.HasItems();
@@ -134,12 +121,7 @@ public:
/// <summary>
/// Clears this buffer.
/// </summary>
void Clear()
{
_data.Clear();
_isResolved = false;
FrameIndex = 0;
}
void Clear();
};
private:

View File

@@ -9,7 +9,7 @@
#include "Engine/Graphics/GPUDevice.h"
ProfilingTools::MainStats ProfilingTools::Stats;
Array<ProfilingTools::ThreadStats> ProfilingTools::EventsCPU(128);
Array<ProfilingTools::ThreadStats, InlinedAllocation<64>> ProfilingTools::EventsCPU;
Array<ProfilerGPU::Event> ProfilingTools::EventsGPU;
class ProfilingToolsService : public EngineService

View File

@@ -116,7 +116,7 @@ public:
/// <summary>
/// The CPU threads profiler events.
/// </summary>
API_FIELD(ReadOnly) static Array<ThreadStats> EventsCPU;
API_FIELD(ReadOnly) static Array<ThreadStats, InlinedAllocation<64>> EventsCPU;
/// <summary>
/// The GPU rendering profiler events.

View File

@@ -13,7 +13,6 @@
#include "FlaxEngine.Gen.h"
#include "MException.h"
#include "Scripting.h"
#include "StdTypesContainer.h"
#include "Events.h"
Dictionary<Pair<ScriptingTypeHandle, StringView>, void(*)(ScriptingObject*, void*, bool)> ScriptingEvents::EventsTable;
@@ -332,14 +331,13 @@ ScriptingTypeInitializer::ScriptingTypeInitializer(BinaryModule* module, const S
// Script
module->Types.AddUninitialized();
new(module->Types.Get() + TypeIndex)ScriptingType(fullname, module, size, initRuntime, spawn, baseType, setupScriptVTable, setupScriptObjectVTable, interfaces);
const MString typeName(fullname.Get(), fullname.Length());
#if BUILD_DEBUG
if (module->TypeNameToTypeIndex.ContainsKey(typeName))
if (module->TypeNameToTypeIndex.ContainsKey(fullname))
{
LOG(Error, "Duplicated native typename {0} from module {1}.", String(fullname), String(module->GetName()));
}
#endif
module->TypeNameToTypeIndex[typeName] = TypeIndex;
module->TypeNameToTypeIndex[fullname] = TypeIndex;
}
ScriptingTypeInitializer::ScriptingTypeInitializer(BinaryModule* module, const StringAnsiView& fullname, int32 size, ScriptingType::InitRuntimeHandler initRuntime, ScriptingType::Ctor ctor, ScriptingType::Dtor dtor, ScriptingTypeInitializer* baseType, const ScriptingType::InterfaceImplementation* interfaces)
@@ -348,14 +346,13 @@ ScriptingTypeInitializer::ScriptingTypeInitializer(BinaryModule* module, const S
// Class
module->Types.AddUninitialized();
new(module->Types.Get() + TypeIndex)ScriptingType(fullname, module, size, initRuntime, ctor, dtor, baseType, interfaces);
const MString typeName(fullname.Get(), fullname.Length());
#if BUILD_DEBUG
if (module->TypeNameToTypeIndex.ContainsKey(typeName))
if (module->TypeNameToTypeIndex.ContainsKey(fullname))
{
LOG(Error, "Duplicated native typename {0} from module {1}.", String(fullname), String(module->GetName()));
}
#endif
module->TypeNameToTypeIndex[typeName] = TypeIndex;
module->TypeNameToTypeIndex[fullname] = TypeIndex;
}
ScriptingTypeInitializer::ScriptingTypeInitializer(BinaryModule* module, const StringAnsiView& fullname, int32 size, ScriptingType::InitRuntimeHandler initRuntime, ScriptingType::Ctor ctor, ScriptingType::Dtor dtor, ScriptingType::Copy copy, ScriptingType::Box box, ScriptingType::Unbox unbox, ScriptingType::GetField getField, ScriptingType::SetField setField, ScriptingTypeInitializer* baseType, const ScriptingType::InterfaceImplementation* interfaces)
@@ -364,14 +361,13 @@ ScriptingTypeInitializer::ScriptingTypeInitializer(BinaryModule* module, const S
// Structure
module->Types.AddUninitialized();
new(module->Types.Get() + TypeIndex)ScriptingType(fullname, module, size, initRuntime, ctor, dtor, copy, box, unbox, getField, setField, baseType, interfaces);
const MString typeName(fullname.Get(), fullname.Length());
#if BUILD_DEBUG
if (module->TypeNameToTypeIndex.ContainsKey(typeName))
if (module->TypeNameToTypeIndex.ContainsKey(fullname))
{
LOG(Error, "Duplicated native typename {0} from module {1}.", String(fullname), String(module->GetName()));
}
#endif
module->TypeNameToTypeIndex[typeName] = TypeIndex;
module->TypeNameToTypeIndex[fullname] = TypeIndex;
}
ScriptingTypeInitializer::ScriptingTypeInitializer(BinaryModule* module, const StringAnsiView& fullname, ScriptingType::InitRuntimeHandler initRuntime, ScriptingTypeInitializer* baseType, const ScriptingType::InterfaceImplementation* interfaces)
@@ -380,14 +376,13 @@ ScriptingTypeInitializer::ScriptingTypeInitializer(BinaryModule* module, const S
// Interface
module->Types.AddUninitialized();
new(module->Types.Get() + TypeIndex)ScriptingType(fullname, module, initRuntime, baseType, interfaces);
const MString typeName(fullname.Get(), fullname.Length());
#if BUILD_DEBUG
if (module->TypeNameToTypeIndex.ContainsKey(typeName))
if (module->TypeNameToTypeIndex.ContainsKey(fullname))
{
LOG(Error, "Duplicated native typename {0} from module {1}.", String(fullname), String(module->GetName()));
}
#endif
module->TypeNameToTypeIndex[typeName] = TypeIndex;
module->TypeNameToTypeIndex[fullname] = TypeIndex;
}
BinaryModule::BinaryModulesList& BinaryModule::GetModules()
@@ -1075,9 +1070,9 @@ void NativeOnlyBinaryModule::Destroy(bool isReloading)
}
}
Array<GetBinaryModuleFunc>& StaticallyLinkedBinaryModuleInitializer::GetStaticallyLinkedBinaryModules()
Array<GetBinaryModuleFunc, InlinedAllocation<64>>& StaticallyLinkedBinaryModuleInitializer::GetStaticallyLinkedBinaryModules()
{
static Array<GetBinaryModuleFunc> modules;
static Array<GetBinaryModuleFunc, InlinedAllocation<64>> modules;
return modules;
}

View File

@@ -396,7 +396,7 @@ private:
public:
static Array<GetBinaryModuleFunc>& GetStaticallyLinkedBinaryModules();
static Array<GetBinaryModuleFunc, InlinedAllocation<64>>& GetStaticallyLinkedBinaryModules();
explicit StaticallyLinkedBinaryModuleInitializer(GetBinaryModuleFunc getter);
~StaticallyLinkedBinaryModuleInitializer();
};