Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Profiler.Begin()/End()をMeshImporterに仕込んだ #1222

Merged
merged 2 commits into from
Sep 14, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
MeshImporterにProfiler.BeginSample/EndSampleを仕込む
  • Loading branch information
notargs committed Sep 13, 2021
commit 1a1e3be4f2fcbd5042d86babc5d6c06b02aaf2df
10 changes: 10 additions & 0 deletions Assets/UniGLTF/Runtime/UniGLTF/IO/MeshIO/MeshImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.Profiling;
using VRMShaders;

namespace UniGLTF
Expand Down Expand Up @@ -628,6 +629,8 @@ await awaitCaller.Run(() =>
positions = blendShape.Positions.ToArray();
normals = blendShape.Normals.ToArray();
});

Profiler.BeginSample("MeshImporter.BuildBlendShapeAsync");
if (blendShape.Positions.Count > 0)
{
if (blendShape.Positions.Count == mesh.vertexCount)
Expand All @@ -653,11 +656,14 @@ await awaitCaller.Run(() =>
null
);
}
Profiler.EndSample();
}

public static async Task<MeshWithMaterials> BuildMeshAsync(IAwaitCaller awaitCaller, Func<int, Material> ctx, MeshImporter.MeshContext meshContext)
{
Profiler.BeginSample("MeshImporter._BuildMesh");
var (mesh, recalculateTangents) = _BuildMesh(meshContext);
Profiler.EndSample();

if (recalculateTangents)
{
Expand All @@ -676,14 +682,18 @@ public static async Task<MeshWithMaterials> BuildMeshAsync(IAwaitCaller awaitCal
await awaitCaller.NextFrame();
if (meshContext.BlendShapes.Count > 0)
{
Profiler.BeginSample("Mesh.UploadMeshData");
var emptyVertices = new Vector3[mesh.vertexCount];
foreach (var blendShape in meshContext.BlendShapes)
{
await BuildBlendShapeAsync(awaitCaller, mesh, meshContext, blendShape, emptyVertices);
}
Profiler.EndSample();
}

Profiler.BeginSample("Mesh.UploadMeshData");
mesh.UploadMeshData(false);
Profiler.EndSample();

return result;
}
Expand Down