Rendering Profiler (レンダリングプロファイラー) は、シーンをレンダリングするために CPU と GPU が行う処理に関する統計や情報を表示します。これらの統計情報を利用して、シーンのさまざまな領域のリソース強度を測定し、最適化に役立てることができます。
チャートには、アプリケーションがレンダリングしたバッチ (Batches Count)、SetPass Calls、三角形の数 (Triangles Calls)、頂点数 (Vertices Counts) が表示されます。下のペインには、より多くのレンダリング統計 (ゲームビューの 統計ウィンドウ ウィンドウに表示されているものと同等) が表示されます。
Rendering Profiler モジュールのチャートは、以下の 4 つのカテゴリに分かれています。
チャート | 説明 |
---|---|
Batches Count | そのフレームで処理された バッチ の数。 |
SetPass Calls Count | そのフレームでゲームオブジェクトのレンダリングに使用したシェーダーパスを Unity が切り替えた回数。1 つのシェーダーには複数のシェーダーパスが含まれている場合があり、それぞれのパスでシーンのゲームオブジェクトのレンダリングが異なります。 |
Triangles Count | そのフレームで処理された 三角形 の数。 |
Vertices Count | そのフレームで処理された 頂点 の数。 |
Rendering Profiler モジュールをクリックすると、ウィンドウの下半分にある詳細ペインに詳細なレンダリング統計が表示されます。これらの統計情報は、統計ウィンドウ に表示される統計情報と同様です。
詳細ペインの左上の Open Frame Debugger を選択すると、フレームデバッガー が開き、フレームをレンダリングした個々のドローコールの情報が表示されます。
これらの統計情報は、ProfilerRecorder API や Profiler Module Editor でも入手可能で、カスタム製のProfiler モジュールに追加することができます。
統計 | 説明 | リリースプレイヤーでのアクセス |
---|---|---|
SetPass Calls Count | そのフレームでゲームオブジェクトのレンダリングに使用したシェーダーパスを Unity が切り替えた回数。1 つのシェーダーには複数のシェーダーパスが含まれている場合があり、それぞれのパスでシーンのゲームオブジェクトのレンダリングが異なります。 | はい |
Draw Calls Count | そのフレームで送信されたドローコールの総数。Unity はゲームオブジェクトを画面にレンダリングする際にドローコールを送信します。この数には、バッチ処理形式でないドローコールと、動的および静的なバッチ形式ドローコールが含まれます。 | はい |
Total Batches Count | そのフレームで処理された バッチ の総数。この数には、動的および静的なバッチ形式ドローコールが含まれます。 | はい |
Triangles Count | そのフレームで処理された 三角形 の数。 | はい |
Vertices Count | そのフレームで処理された 頂点 の数。 | はい |
(Dynamic Batching) | このセクションは、動的バッチ に関する統計情報を表示します。 | なし |
Dynamic Batched Draw Calls Count | 動的バッチ処理にまとめられられたドローコールの数。 | なし |
Dynamic Batches Count | そのフレームで処理された動的なバッチ処理の数。 | なし |
Dynamic Batched Triangles Count | 動的バッチ処理に含まれるゲームオブジェクトの三角形の数。 | なし |
Dynamic Batched Vertices Count | 動的バッチ処理に含まれるゲームオブジェクトの頂点数。 | なし |
Dynamic Batching Time | 動的バッチ処理構造の作成に Unity が費やした時間。 | なし |
(Static Batching) | このセクションは、静的バッチ に関する統計情報を表示します。 | なし |
Static Batched Draw Calls Count | 静的バッチ処理にまとめられられたドローコールの数。 | なし |
Static Batches Count | そのフレームで処理された静的なバッチ処理の数。 | なし |
Static Batched Triangles Count | 静的バッチ処理に含まれるゲームオブジェクトの三角形の数。 | なし |
Static Batched Vertices Count | 静的バッチ処理に含まれるゲームオブジェクトの頂点数。 | なし |
(Instancing) | このセクションは、GPU インスタンシング に関する統計情報を表示します。 | なし |
Instanced Batched Draw Calls Count | インスタンスバッチ処理にまとめられられたドローコールの数。 | なし |
Instanced Batches Count | そのフレームでインスタンス化されたゲームオブジェクトをレンダリングするために行われたバッチ処理の数。 | なし |
Instanced Batched Triangles Count | インスタンス化されたゲームオブジェクトの三角形の数。 | なし |
Instanced Batched Vertices Count | インスタンス化されたゲームオブジェクトの頂点数。 | なし |
Used Textures Count Used Textures Bytes |
そのフレームで使用された テクスチャ 数と、そのテクスチャが使用したメモリ量。 | なし |
Render Textures Count Render Textures Bytes |
そのフレームで使用された レンダーテクスチャ 数と、そのレンダーテクスチャが使用したメモリ量。 | はい |
Render Textures Changes Count | そのフレームで Unity が 1 つまたは複数のレンダーテクスチャをレンダーターゲットとして設定した回数。 | はい |
Used Buffers Count Used Buffers Bytes |
GPU バッファとそれに使われたメモリの総数。これには、頂点、インデックス、コンピュートバッファ、レンダリングに必要なすべての内部バッファが含まれます。 | はい |
Vertex Buffer Upload In Frame Count Vertex Buffer Upload In Frame Bytes |
そのフレームで CPU が GPU にアップロードしたジオメトリの量。これは、頂点/法線/TEXCOORD のデータを表します。すでに GPU にジオメトリがある場合もあります。この統計値には、Unity がフレーム内で転送したジオメトリのみが含まれます。 | はい |
Index Buffer Upload In Frame Count Index Buffer Upload In Frame Bytes |
そのフレームで CPU が GPU にアップロードしたジオメトリの量。これは、三角形のインデックスのデータを表します。すでに GPU にジオメトリがある場合もあります。この統計値には、Unity がフレーム内で転送したジオメトリのみが含まれます。 | はい |
Shadow Casters Count | そのフレームで影を作るゲームオブジェクトの数。1 つのゲームオブジェクトが複数の影を作る場合 (複数のライトが照らしているため)、1 つの影につき 1 エントリーされます。 | はい |
Rendering モジュールのプロファイラーカウンターは、プレイヤーでも利用可能です。プレイヤーで Rendering Profiler モジュールの情報にアクセスするには、ProfilerRecorder API を使用します。高レベルのカウンターは、Release Player でも利用できます。
以下の例は、“SetPass Calls Count”、 “Draw Calls Count”、 “Vertices Count” の指標を収集し、それらをテキストエリアとして表示する簡単なスクリプトです。
using System.Text;
using Unity.Profiling;
using UnityEngine;
public class RenderStatsScript : MonoBehaviour
{
string statsText;
ProfilerRecorder setPassCallsRecorder;
ProfilerRecorder drawCallsRecorder;
ProfilerRecorder verticesRecorder;
void OnEnable()
{
setPassCallsRecorder = ProfilerRecorder.StartNew(ProfilerCategory.Render, "SetPass Calls Count");
drawCallsRecorder = ProfilerRecorder.StartNew(ProfilerCategory.Render, "Draw Calls Count");
verticesRecorder = ProfilerRecorder.StartNew(ProfilerCategory.Render, "Vertices Count");
}
void OnDisable()
{
setPassCallsRecorder.Dispose();
drawCallsRecorder.Dispose();
verticesRecorder.Dispose();
}
void Update()
{
var sb = new StringBuilder(500);
if (setPassCallsRecorder.Valid)
sb.AppendLine($"SetPass Calls: {setPassCallsRecorder.LastValue}");
if (drawCallsRecorder.Valid)
sb.AppendLine($"Draw Calls: {drawCallsRecorder.LastValue}");
if (verticesRecorder.Valid)
sb.AppendLine($"Vertices: {verticesRecorder.LastValue}");
statsText = sb.ToString();
}
void OnGUI()
{
GUI.TextArea(new Rect(10, 30, 250, 50), statsText);
}
}
Rendering Profiler モジュールの情報は、ProfilerCategory.Render Profiler のカテゴリに属しています。
カスタムモジュールで選択したレンダリングカウンターを強調表示したい場合は、Module Editor を使用して、チャートと詳細表示を設定します。
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.