Add various profiler events to analyze models importing workflow
This commit is contained in:
@@ -562,6 +562,7 @@ bool FlaxStorage::Reload()
|
|||||||
{
|
{
|
||||||
if (!IsLoaded())
|
if (!IsLoaded())
|
||||||
return false;
|
return false;
|
||||||
|
PROFILE_CPU();
|
||||||
|
|
||||||
OnReloading(this);
|
OnReloading(this);
|
||||||
|
|
||||||
@@ -776,6 +777,8 @@ FlaxChunk* FlaxStorage::AllocateChunk()
|
|||||||
|
|
||||||
bool FlaxStorage::Create(const StringView& path, const AssetInitData* data, int32 dataCount, bool silentMode, const CustomData* customData)
|
bool FlaxStorage::Create(const StringView& path, const AssetInitData* data, int32 dataCount, bool silentMode, const CustomData* customData)
|
||||||
{
|
{
|
||||||
|
PROFILE_CPU();
|
||||||
|
ZoneText(*path, path.Length());
|
||||||
LOG(Info, "Creating package at \'{0}\'. Silent Mode: {1}", path, silentMode);
|
LOG(Info, "Creating package at \'{0}\'. Silent Mode: {1}", path, silentMode);
|
||||||
|
|
||||||
// Prepare to have access to the file
|
// Prepare to have access to the file
|
||||||
|
|||||||
@@ -306,6 +306,8 @@ bool AssetsImportingManager::ImportIfEdited(const StringView& inputPath, const S
|
|||||||
|
|
||||||
bool AssetsImportingManager::Create(const Function<CreateAssetResult(CreateAssetContext&)>& callback, const StringView& inputPath, const StringView& outputPath, Guid& assetId, void* arg)
|
bool AssetsImportingManager::Create(const Function<CreateAssetResult(CreateAssetContext&)>& callback, const StringView& inputPath, const StringView& outputPath, Guid& assetId, void* arg)
|
||||||
{
|
{
|
||||||
|
PROFILE_CPU();
|
||||||
|
ZoneText(*outputPath, outputPath.Length());
|
||||||
const auto startTime = Platform::GetTimeSeconds();
|
const auto startTime = Platform::GetTimeSeconds();
|
||||||
|
|
||||||
// Pick ID if not specified
|
// Pick ID if not specified
|
||||||
@@ -369,7 +371,7 @@ bool AssetsImportingManager::Create(const Function<CreateAssetResult(CreateAsset
|
|||||||
if (result == CreateAssetResult::Ok)
|
if (result == CreateAssetResult::Ok)
|
||||||
{
|
{
|
||||||
// Register asset
|
// Register asset
|
||||||
Content::GetRegistry()->RegisterAsset(context.Data.Header, outputPath);
|
Content::GetRegistry()->RegisterAsset(context.Data.Header, context.TargetAssetPath);
|
||||||
|
|
||||||
// Done
|
// Done
|
||||||
const auto endTime = Platform::GetTimeSeconds();
|
const auto endTime = Platform::GetTimeSeconds();
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
#include "Engine/Content/Content.h"
|
#include "Engine/Content/Content.h"
|
||||||
#include "Engine/Platform/FileSystem.h"
|
#include "Engine/Platform/FileSystem.h"
|
||||||
#include "Engine/Utilities/RectPack.h"
|
#include "Engine/Utilities/RectPack.h"
|
||||||
|
#include "Engine/Profiler/ProfilerCPU.h"
|
||||||
#include "AssetsImportingManager.h"
|
#include "AssetsImportingManager.h"
|
||||||
|
|
||||||
bool ImportModel::TryGetImportOptions(const StringView& path, Options& options)
|
bool ImportModel::TryGetImportOptions(const StringView& path, Options& options)
|
||||||
@@ -437,6 +438,7 @@ CreateAssetResult ImportModel::Create(CreateAssetContext& context)
|
|||||||
|
|
||||||
CreateAssetResult ImportModel::CreateModel(CreateAssetContext& context, ModelData& modelData, const Options* options)
|
CreateAssetResult ImportModel::CreateModel(CreateAssetContext& context, ModelData& modelData, const Options* options)
|
||||||
{
|
{
|
||||||
|
PROFILE_CPU();
|
||||||
IMPORT_SETUP(Model, Model::SerializedVersion);
|
IMPORT_SETUP(Model, Model::SerializedVersion);
|
||||||
|
|
||||||
// Save model header
|
// Save model header
|
||||||
@@ -487,6 +489,7 @@ CreateAssetResult ImportModel::CreateModel(CreateAssetContext& context, ModelDat
|
|||||||
|
|
||||||
CreateAssetResult ImportModel::CreateSkinnedModel(CreateAssetContext& context, ModelData& modelData, const Options* options)
|
CreateAssetResult ImportModel::CreateSkinnedModel(CreateAssetContext& context, ModelData& modelData, const Options* options)
|
||||||
{
|
{
|
||||||
|
PROFILE_CPU();
|
||||||
IMPORT_SETUP(SkinnedModel, SkinnedModel::SerializedVersion);
|
IMPORT_SETUP(SkinnedModel, SkinnedModel::SerializedVersion);
|
||||||
|
|
||||||
// Save skinned model header
|
// Save skinned model header
|
||||||
@@ -528,6 +531,7 @@ CreateAssetResult ImportModel::CreateSkinnedModel(CreateAssetContext& context, M
|
|||||||
|
|
||||||
CreateAssetResult ImportModel::CreateAnimation(CreateAssetContext& context, ModelData& modelData, const Options* options)
|
CreateAssetResult ImportModel::CreateAnimation(CreateAssetContext& context, ModelData& modelData, const Options* options)
|
||||||
{
|
{
|
||||||
|
PROFILE_CPU();
|
||||||
IMPORT_SETUP(Animation, Animation::SerializedVersion);
|
IMPORT_SETUP(Animation, Animation::SerializedVersion);
|
||||||
|
|
||||||
// Save animation data
|
// Save animation data
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#include "Engine/Core/Collections/BitArray.h"
|
#include "Engine/Core/Collections/BitArray.h"
|
||||||
#include "Engine/Tools/ModelTool/ModelTool.h"
|
#include "Engine/Tools/ModelTool/ModelTool.h"
|
||||||
#include "Engine/Tools/ModelTool/VertexTriangleAdjacency.h"
|
#include "Engine/Tools/ModelTool/VertexTriangleAdjacency.h"
|
||||||
|
#include "Engine/Profiler/ProfilerCPU.h"
|
||||||
#include "Engine/Platform/Platform.h"
|
#include "Engine/Platform/Platform.h"
|
||||||
#define USE_MIKKTSPACE 1
|
#define USE_MIKKTSPACE 1
|
||||||
#include "ThirdParty/MikkTSpace/mikktspace.h"
|
#include "ThirdParty/MikkTSpace/mikktspace.h"
|
||||||
@@ -78,6 +79,7 @@ void RemapArrayHelper(Array<T>& target, const std::vector<uint32_t>& remap)
|
|||||||
|
|
||||||
bool MeshData::GenerateLightmapUVs()
|
bool MeshData::GenerateLightmapUVs()
|
||||||
{
|
{
|
||||||
|
PROFILE_CPU();
|
||||||
#if PLATFORM_WINDOWS
|
#if PLATFORM_WINDOWS
|
||||||
// Prepare
|
// Prepare
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
@@ -235,6 +237,7 @@ void RemapBuffer(Array<T>& src, Array<T>& dst, const Array<int32>& mapping, int3
|
|||||||
|
|
||||||
void MeshData::BuildIndexBuffer()
|
void MeshData::BuildIndexBuffer()
|
||||||
{
|
{
|
||||||
|
PROFILE_CPU();
|
||||||
const auto startTime = Platform::GetTimeSeconds();
|
const auto startTime = Platform::GetTimeSeconds();
|
||||||
|
|
||||||
const int32 vertexCount = Positions.Count();
|
const int32 vertexCount = Positions.Count();
|
||||||
@@ -341,6 +344,7 @@ bool MeshData::GenerateNormals(float smoothingAngle)
|
|||||||
LOG(Warning, "Missing vertex or index data to generate normals.");
|
LOG(Warning, "Missing vertex or index data to generate normals.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
PROFILE_CPU();
|
||||||
|
|
||||||
const auto startTime = Platform::GetTimeSeconds();
|
const auto startTime = Platform::GetTimeSeconds();
|
||||||
|
|
||||||
@@ -520,6 +524,7 @@ bool MeshData::GenerateTangents(float smoothingAngle)
|
|||||||
LOG(Warning, "Missing normals or texcoors data to generate tangents.");
|
LOG(Warning, "Missing normals or texcoors data to generate tangents.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
PROFILE_CPU();
|
||||||
|
|
||||||
const auto startTime = Platform::GetTimeSeconds();
|
const auto startTime = Platform::GetTimeSeconds();
|
||||||
const int32 vertexCount = Positions.Count();
|
const int32 vertexCount = Positions.Count();
|
||||||
@@ -706,6 +711,7 @@ void MeshData::ImproveCacheLocality()
|
|||||||
|
|
||||||
if (Positions.IsEmpty() || Indices.IsEmpty() || Positions.Count() <= VertexCacheSize)
|
if (Positions.IsEmpty() || Indices.IsEmpty() || Positions.Count() <= VertexCacheSize)
|
||||||
return;
|
return;
|
||||||
|
PROFILE_CPU();
|
||||||
|
|
||||||
const auto startTime = Platform::GetTimeSeconds();
|
const auto startTime = Platform::GetTimeSeconds();
|
||||||
|
|
||||||
@@ -886,6 +892,7 @@ void MeshData::ImproveCacheLocality()
|
|||||||
|
|
||||||
float MeshData::CalculateTrianglesArea() const
|
float MeshData::CalculateTrianglesArea() const
|
||||||
{
|
{
|
||||||
|
PROFILE_CPU();
|
||||||
float sum = 0;
|
float sum = 0;
|
||||||
// TODO: use SIMD
|
// TODO: use SIMD
|
||||||
for (int32 i = 0; i + 2 < Indices.Count(); i += 3)
|
for (int32 i = 0; i + 2 < Indices.Count(); i += 3)
|
||||||
|
|||||||
@@ -7,10 +7,12 @@
|
|||||||
#include "Engine/Graphics/Async/GPUTask.h"
|
#include "Engine/Graphics/Async/GPUTask.h"
|
||||||
#include "Engine/Graphics/Models/MeshBase.h"
|
#include "Engine/Graphics/Models/MeshBase.h"
|
||||||
#include "Engine/Threading/Threading.h"
|
#include "Engine/Threading/Threading.h"
|
||||||
|
#include "Engine/Profiler/ProfilerCPU.h"
|
||||||
#include "Engine/Core/Log.h"
|
#include "Engine/Core/Log.h"
|
||||||
|
|
||||||
bool CollisionCooking::CookCollision(const Argument& arg, CollisionData::SerializedOptions& outputOptions, BytesContainer& outputData)
|
bool CollisionCooking::CookCollision(const Argument& arg, CollisionData::SerializedOptions& outputOptions, BytesContainer& outputData)
|
||||||
{
|
{
|
||||||
|
PROFILE_CPU();
|
||||||
int32 convexVertexLimit = Math::Clamp(arg.ConvexVertexLimit, CONVEX_VERTEX_MIN, CONVEX_VERTEX_MAX);
|
int32 convexVertexLimit = Math::Clamp(arg.ConvexVertexLimit, CONVEX_VERTEX_MIN, CONVEX_VERTEX_MAX);
|
||||||
if (arg.ConvexVertexLimit == 0)
|
if (arg.ConvexVertexLimit == 0)
|
||||||
convexVertexLimit = CONVEX_VERTEX_MAX;
|
convexVertexLimit = CONVEX_VERTEX_MAX;
|
||||||
|
|||||||
@@ -961,6 +961,7 @@ void PhysicalMaterial::UpdatePhysicsMaterial()
|
|||||||
|
|
||||||
bool CollisionCooking::CookConvexMesh(CookingInput& input, BytesContainer& output)
|
bool CollisionCooking::CookConvexMesh(CookingInput& input, BytesContainer& output)
|
||||||
{
|
{
|
||||||
|
PROFILE_CPU();
|
||||||
ENSURE_CAN_COOK;
|
ENSURE_CAN_COOK;
|
||||||
if (input.VertexCount == 0)
|
if (input.VertexCount == 0)
|
||||||
LOG(Warning, "Empty mesh data for collision cooking.");
|
LOG(Warning, "Empty mesh data for collision cooking.");
|
||||||
@@ -1004,6 +1005,7 @@ bool CollisionCooking::CookConvexMesh(CookingInput& input, BytesContainer& outpu
|
|||||||
|
|
||||||
bool CollisionCooking::CookTriangleMesh(CookingInput& input, BytesContainer& output)
|
bool CollisionCooking::CookTriangleMesh(CookingInput& input, BytesContainer& output)
|
||||||
{
|
{
|
||||||
|
PROFILE_CPU();
|
||||||
ENSURE_CAN_COOK;
|
ENSURE_CAN_COOK;
|
||||||
if (input.VertexCount == 0 || input.IndexCount == 0)
|
if (input.VertexCount == 0 || input.IndexCount == 0)
|
||||||
LOG(Warning, "Empty mesh data for collision cooking.");
|
LOG(Warning, "Empty mesh data for collision cooking.");
|
||||||
@@ -1038,6 +1040,7 @@ bool CollisionCooking::CookTriangleMesh(CookingInput& input, BytesContainer& out
|
|||||||
|
|
||||||
bool CollisionCooking::CookHeightField(int32 cols, int32 rows, const PhysicsBackend::HeightFieldSample* data, WriteStream& stream)
|
bool CollisionCooking::CookHeightField(int32 cols, int32 rows, const PhysicsBackend::HeightFieldSample* data, WriteStream& stream)
|
||||||
{
|
{
|
||||||
|
PROFILE_CPU();
|
||||||
ENSURE_CAN_COOK;
|
ENSURE_CAN_COOK;
|
||||||
|
|
||||||
PxHeightFieldDesc heightFieldDesc;
|
PxHeightFieldDesc heightFieldDesc;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "Engine/Core/Collections/Sorting.h"
|
#include "Engine/Core/Collections/Sorting.h"
|
||||||
#include "Engine/Platform/FileSystem.h"
|
#include "Engine/Platform/FileSystem.h"
|
||||||
#include "Engine/Tools/TextureTool/TextureTool.h"
|
#include "Engine/Tools/TextureTool/TextureTool.h"
|
||||||
|
#include "Engine/Profiler/ProfilerCPU.h"
|
||||||
#include "Engine/Platform/File.h"
|
#include "Engine/Platform/File.h"
|
||||||
|
|
||||||
#define OPEN_FBX_CONVERT_SPACE 1
|
#define OPEN_FBX_CONVERT_SPACE 1
|
||||||
@@ -425,7 +426,7 @@ Matrix GetOffsetMatrix(OpenFbxImporterData& data, const ofbx::Mesh* mesh, const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//return Matrix::Identity;
|
//return Matrix::Identity;
|
||||||
return ToMatrix(node->getGlobalTransform());
|
return ToMatrix(node->getGlobalTransform());
|
||||||
#else
|
#else
|
||||||
Matrix t = Matrix::Identity;
|
Matrix t = Matrix::Identity;
|
||||||
@@ -523,7 +524,9 @@ bool ImportBones(OpenFbxImporterData& data, String& errorMsg)
|
|||||||
|
|
||||||
bool ProcessMesh(ModelData& result, OpenFbxImporterData& data, const ofbx::Mesh* aMesh, MeshData& mesh, String& errorMsg, int32 triangleStart, int32 triangleEnd)
|
bool ProcessMesh(ModelData& result, OpenFbxImporterData& data, const ofbx::Mesh* aMesh, MeshData& mesh, String& errorMsg, int32 triangleStart, int32 triangleEnd)
|
||||||
{
|
{
|
||||||
// Prepare
|
PROFILE_CPU();
|
||||||
|
mesh.Name = aMesh->name;
|
||||||
|
ZoneText(*mesh.Name, mesh.Name.Length());
|
||||||
const int32 firstVertexOffset = triangleStart * 3;
|
const int32 firstVertexOffset = triangleStart * 3;
|
||||||
const int32 lastVertexOffset = triangleEnd * 3;
|
const int32 lastVertexOffset = triangleEnd * 3;
|
||||||
const ofbx::Geometry* aGeometry = aMesh->getGeometry();
|
const ofbx::Geometry* aGeometry = aMesh->getGeometry();
|
||||||
@@ -538,7 +541,6 @@ bool ProcessMesh(ModelData& result, OpenFbxImporterData& data, const ofbx::Mesh*
|
|||||||
const ofbx::BlendShape* blendShape = aGeometry->getBlendShape();
|
const ofbx::BlendShape* blendShape = aGeometry->getBlendShape();
|
||||||
|
|
||||||
// Properties
|
// Properties
|
||||||
mesh.Name = aMesh->name;
|
|
||||||
const ofbx::Material* aMaterial = nullptr;
|
const ofbx::Material* aMaterial = nullptr;
|
||||||
if (aMesh->getMaterialCount() > 0)
|
if (aMesh->getMaterialCount() > 0)
|
||||||
{
|
{
|
||||||
@@ -842,7 +844,7 @@ bool ProcessMesh(ModelData& result, OpenFbxImporterData& data, const ofbx::Mesh*
|
|||||||
mesh.OriginTranslation = scale * Vector3(translation.X, translation.Y, -translation.Z);
|
mesh.OriginTranslation = scale * Vector3(translation.X, translation.Y, -translation.Z);
|
||||||
else
|
else
|
||||||
mesh.OriginTranslation = scale * Vector3(translation.X, translation.Y, translation.Z);
|
mesh.OriginTranslation = scale * Vector3(translation.X, translation.Y, translation.Z);
|
||||||
|
|
||||||
auto rot = aMesh->getLocalRotation();
|
auto rot = aMesh->getLocalRotation();
|
||||||
auto quat = Quaternion::Euler(-(float)rot.x, -(float)rot.y, -(float)rot.z);
|
auto quat = Quaternion::Euler(-(float)rot.x, -(float)rot.y, -(float)rot.z);
|
||||||
mesh.OriginOrientation = quat;
|
mesh.OriginOrientation = quat;
|
||||||
@@ -854,6 +856,8 @@ bool ProcessMesh(ModelData& result, OpenFbxImporterData& data, const ofbx::Mesh*
|
|||||||
|
|
||||||
bool ImportMesh(ModelData& result, OpenFbxImporterData& data, const ofbx::Mesh* aMesh, String& errorMsg, int32 triangleStart, int32 triangleEnd)
|
bool ImportMesh(ModelData& result, OpenFbxImporterData& data, const ofbx::Mesh* aMesh, String& errorMsg, int32 triangleStart, int32 triangleEnd)
|
||||||
{
|
{
|
||||||
|
PROFILE_CPU();
|
||||||
|
|
||||||
// Find the parent node
|
// Find the parent node
|
||||||
int32 nodeIndex = data.FindNode(aMesh);
|
int32 nodeIndex = data.FindNode(aMesh);
|
||||||
|
|
||||||
@@ -1128,7 +1132,11 @@ bool ModelTool::ImportDataOpenFBX(const char* path, ModelData& data, Options& op
|
|||||||
{
|
{
|
||||||
loadFlags |= (ofbx::u64)ofbx::LoadFlags::IGNORE_GEOMETRY | (ofbx::u64)ofbx::LoadFlags::IGNORE_BLEND_SHAPES;
|
loadFlags |= (ofbx::u64)ofbx::LoadFlags::IGNORE_GEOMETRY | (ofbx::u64)ofbx::LoadFlags::IGNORE_BLEND_SHAPES;
|
||||||
}
|
}
|
||||||
ofbx::IScene* scene = ofbx::load(fileData.Get(), fileData.Count(), loadFlags);
|
ofbx::IScene* scene;
|
||||||
|
{
|
||||||
|
PROFILE_CPU_NAMED("ofbx::load");
|
||||||
|
scene = ofbx::load(fileData.Get(), fileData.Count(), loadFlags);
|
||||||
|
}
|
||||||
if (!scene)
|
if (!scene)
|
||||||
{
|
{
|
||||||
errorMsg = ofbx::getError();
|
errorMsg = ofbx::getError();
|
||||||
|
|||||||
@@ -444,6 +444,8 @@ void RemoveNamespace(String& name)
|
|||||||
|
|
||||||
bool ModelTool::ImportData(const String& path, ModelData& data, Options& options, String& errorMsg)
|
bool ModelTool::ImportData(const String& path, ModelData& data, Options& options, String& errorMsg)
|
||||||
{
|
{
|
||||||
|
PROFILE_CPU();
|
||||||
|
|
||||||
// Validate options
|
// Validate options
|
||||||
options.Scale = Math::Clamp(options.Scale, 0.0001f, 100000.0f);
|
options.Scale = Math::Clamp(options.Scale, 0.0001f, 100000.0f);
|
||||||
options.SmoothingNormalsAngle = Math::Clamp(options.SmoothingNormalsAngle, 0.0f, 175.0f);
|
options.SmoothingNormalsAngle = Math::Clamp(options.SmoothingNormalsAngle, 0.0f, 175.0f);
|
||||||
@@ -782,6 +784,7 @@ String GetAdditionalImportPath(const String& autoImportOutput, Array<String>& im
|
|||||||
|
|
||||||
bool ModelTool::ImportModel(const String& path, ModelData& data, Options& options, String& errorMsg, const String& autoImportOutput)
|
bool ModelTool::ImportModel(const String& path, ModelData& data, Options& options, String& errorMsg, const String& autoImportOutput)
|
||||||
{
|
{
|
||||||
|
PROFILE_CPU();
|
||||||
LOG(Info, "Importing model from \'{0}\'", path);
|
LOG(Info, "Importing model from \'{0}\'", path);
|
||||||
const auto startTime = DateTime::NowUTC();
|
const auto startTime = DateTime::NowUTC();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user