LoginSignup
3
0

More than 1 year has passed since last update.

[Unity] SRP Batcher を検証してみました

Last updated at Posted at 2021-12-15

本記事はCraft Egg Advent Calendar 2021の12/16の記事です。
前回の記事は@ce_gassyさんの 新卒エンジニアが業務を行う上で意識したこと でした。

◆ 概要

  • Built-in な RP, URP, SRP Batcherの適用とで比較検証を行ってみました。

◆ 環境

  • Unity : 2020.3.24f1
  • Universal RP(com.unity.render-pipelines.universal) : 10.7.0
    • 依存パッケージ
    • com.unity.render-pipelines.core : 10.7.0
    • com.unity.shadergraph : 10.7.0
    • com.unity.mathematics : 1.1.0
    • 簡易的な測定を行うためにGraphyを利用しています。
  • ほか
    • Windows11
    • Core i9-10900F
    • GeForce GTX 1050 Ti

◆ 検証の流れ

  1. Build-in な Render Pipeline で測定環境を構築し測定する。
    1. Unlit Shaderをメニューから生成する。
    2. MeshRendererを持つ Prefab(Sphere) と 生成したシェーダを参照する Materialを用意する。
    3. MonoBehaviour.Start で指定数分 Prefabと Materialを Instantiateさせる。(雑に30000オブジェクトほど Instantiateしてみています)
  2. URPに切り替えるのみの対応を施し測定する。
    1. UniversalRenderPipelineAssetをメニューから生成する。
    2. 生成した UniversalRenderPipelineAssetをデフォルトのまま Graphics設定に反映する。
  3. Unlit Shaderに対して URPならびに SRP Batcher対応を行い計測する。

◆ 検証結果

  • 対応前のベース状態 : 約15fps

    • Render.OpaqueGeometryに大きく時間がかかっている状態。(41.2msほど) LegacyRPProfiler.png LegacyRP.png
  • URPに切り替えるのみ : 約15fps

    • DrawOpaqueObjectsに大きく時間がかかっている状態。(44.6msほど) URPProfiler.png URP.png
  • SRP Batcher対応 : 約30fps

    • URPへ切り替えただけと比べDrawOpaqueObjectsの負荷が大幅に軽減されている。(9.8msほど)   SRPBatcher2Profiler.png   SRPBatcher2.png

◆ 対応内容

◆ まとめ

  • 今回はひとまずPCエディタ上で測定しました。
  • 検証条件を整理、見直した上でモバイルも測定し効果的であることが実証されたなら、まだ対応していないシェーダーの対応検証を進めようと思います。

明日は@Tomy_0331の記事です!

3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0