using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DrawCallTest : MonoBehaviour
{
int stopCount = 100;
public int wantFPS = 60;
List<GameObject> gameObjects = new List<GameObject>();
public Renderer renderTarget;
// Start is called before the first frame update
void Start()
{
renderTarget.gameObject.SetActive(false);
}
float preTime = 0;
// Update is called once per frame
void Update()
{
if (Time.time>3)
{
if (stopCount<=0)
{
return;
}
if (Time.deltaTime > 1f / wantFPS)
{
stopCount--;
}
else
{
}
stopCount=Mathf.Clamp(stopCount, 0, 10);
var wid = (int)Mathf.Sqrt(gameObjects.Count+1);
for (int i = 0; i < 10; i++)
{
var instance = Instantiate(renderTarget.gameObject);
instance.SetActive(true);
gameObjects.Add(instance);
}
}
}
}
-사용된 fbx 파일 -
언릿쉐이더로 진행
드로우콜 테스트
목표치 60fps일경우 6152
목표치 144fps일경우 1112
목표치 60fps일경우 38.3M Tris
목표치 144fps일경우 12.3M Tris
2020에 970으로 쟀을때보다 성능이 많이 좋아졌다
그리고 3050은 최약체라서 목표치를 60으로 잡으면 충분할것 같다
주의점은 위에서 테스트된건 스킨드메쉬가 아니라 메쉬렌더러라서 버텍스 영향을 좀 덜 받으니
버텍스같은 경우에는 5M 초과하지 않도록 여유분을 주자
드로우 콜의 경우에는 내부 CPU 로직이 많으면 떨어지는 경향이 있으니
로직이 복잡한 게임이라면 여유분을 더 크게주고, 결국 어떤 게임을 만드느냐에 따라서도 영향이 있으니까 알아서 판단
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TextureMemoryTest : MonoBehaviour
{
public Renderer renderTarget;
public Texture[] textures;
public int max = 800;
public bool useTexture = false;
// Start is called before the first frame update
void Start()
{
var wid = (int)Mathf.Sqrt(textures.Length);
var i = 0;
foreach (var texture in textures)
{
var instance = Instantiate(renderTarget.gameObject);
if (useTexture)
{
instance.GetComponent<Renderer>().material.SetTexture("_MainTex", texture);
}
var x = i % wid;
var y = i / wid;
instance.transform.position = new Vector3(x * 0.5f, y * 0.5f, i * 0.01f);
i++;
if (i>max)
{
return;
}
}
renderTarget.gameObject.SetActive(false);
}
}
-테스트 환경-
CPU : 라이젠 5 1600
메모리 : 32GB 1333Mhz
GPU : RTX 3050 8GB
사용된 텍스처 메모리는 14GB
있긴 있는데 무시해도 될정도로 작다
밉맵에 걸려서 그런지 드라이버 단에서 로드를 막는건지
텍스처 메모리는 그래픽 카드 메모리를 2배나 됨에도 불구하고
문제가 전혀 발생하지 않는다
처리량이 최소인 언릿에서도 별 차이 없는데
라이트 처리가 들어가는 스탠다드나 툰쉐이더등에서는 차이가 더 적을것이다
오히려 저 많은 텍스처들을 띄우느라 드로우콜이 엄청나게 늘어나는 바람에
일부러 바보같이 프래그단에서 tex2D함수를 수십번씩 호출하거나 밉맵 다 끄고 쓰거나 하지 않는이상이야