当前位置:网站首页>Unity3D中DrawCall、Batches、SetPassCall
Unity3D中DrawCall、Batches、SetPassCall
2022-06-12 02:31:00 【罗修之神】
DrawCall,一帧当中CPU调用GPU渲染指令接口的次数。
本文测试用的是Unity3D - 2020.3.8版本
在Unity3D编辑器中,通过Window->Analysis->Profiler打开Profiler页面,然后选中Rendering栏,如下所示
在这里就可以看到drawcall的数量了,在stats界面是看不到DrawCall数目的,对于DrawCall的定义如下:
**DrawCall:**CPU每次调用图像编程接口 glDrawElements(OpenGl中的图元渲染函数)或者 DrawIndexedPrimitive(DirectX中的顶点绘制方法)命令GPU渲染的操作称为一次Draw Call,调用会传入图元模式、顶点数目、索引值类型以及指向索引数组的指针。
Batches, 一帧当中CPU给GPU传输顶点数据以及渲染状态的次数。
查看Batches,在编辑器中查看方式,首先切换到Game界面,然后点States选项,如下所示:
Batch,就是批次的意思,当CPU和GPU通信的时候,会把需要传递的数据传给GPU,例如渲染状态,用什么Shader、用那些材质等,一个Batch至少会包含一次DrawCall(一般是一次,特殊情况:当这个批次的定点数目过多,就得分成两次或者多次去调用DrawCall),我们在Unity中测试的时候,通常会发现Batches和DrawCall是一样的。通常我们说合批能能够提高游戏的性能,一般可以这么说,但是Batches高并不是游戏帧率低的直接原因,而是batch太多导致切换渲染状态太频繁,切换渲染状态是比较耗时的,比如在Shader常见的是否关闭深度写入,开启模板测试等。
SetPassCall, 和shader的Pass有关,unity的解释是Shader中的Pass被切换的次数。
数值查看在unity编辑器里面的位置如下所示:
简单来说,就是一帧中,要切换shader中pass的次数,比如一个Shader中有两个pass,那么这个Shader一次就增加两次SetPassCall,如果前后两次drawcall中,shader没变,那么SetPassCall的值是不会增加的,应该可以这么去间的的验证下,在Unity编辑器中,打开FrameDebug,如下:
通过切换第一个红框中的不同帧,可以看到不同的shader的切换,最后总次数应该是等于我们看到的SetPassCall值。
边栏推荐
- WPS表格 学习笔记 - 高亮显示重复值
- 力扣解法汇总面试题 01.05. 一次编辑
- Several common instructions for virsh to create / shut down / stop virtual machines
- Pydub MP3 to WAV
- Android HTML5 page load cache optimization
- RPC 入门
- Force deduction solution summary interview question 01.05 Edit once
- 力扣解法汇总473-火柴拼正方形
- 2022 western style pastry (technician) recurrent training question bank and online simulated examination
- 力扣解法汇总面试题 17.11-单词距离
猜你喜欢

博创智能冲刺科创板:年营收11亿 应收账款账面价值3亿

Proxy and reflection (II)

DbNull if statement - DbNull if statement

ozzanimation-基於sse的動作系統

Master of a famous school has been working hard for 5 years. AI has no paper. How can the tutor free range?

How WPS inserts a directory and the operating steps for quickly inserting a directory

Is there a female Bluetooth headset suitable for girls? 38 Bluetooth headsets worth getting started

The program actively carries out telephone short message alarm, and customizes telephone, short message and nail alarm notifications

A single quarter of educational technology revenue of 230million: a year-on-year decrease of 51% and a sharp narrowing of net loss

Maya Front Office Rendering plug - in Mel script Tool
随机推荐
Red's deleted number
Acl2022 | DCSR: a sentence aware contrastive learning method for open domain paragraph retrieval
Add sequence number column to MySQL query result set
消防栓监测系统毕业设计---论文(附加最全面的从硬件电路设计->驱动程序设计->阿里云物联网搭建->安卓APP设计)
力扣解法汇总713- 乘积小于 K 的子数组
Force deduction solution summary 713- subarray with product less than k
力扣解法汇总386-字典序排数
力扣解法汇总462-最少移动次数使数组元素相等 II
Bochuang smart sprint technology innovation board: annual revenue of RMB 1.1 billion, book value of accounts receivable of RMB 300million
Force deduction solution summary 905- array sorted by parity
Hypergraph tilted data is merged into root node and transferred to 3dfiles
Intel case
博创智能冲刺科创板:年营收11亿 应收账款账面价值3亿
打包一个包含手表端应用的手机端APK应用—Ticwear
A single quarter of educational technology revenue of 230million: a year-on-year decrease of 51% and a sharp narrowing of net loss
Force deduction solution summary 386 dictionary order
力扣解法汇总883-三维形体投影面积
Force deduction solution summary interview question 17.11- word distance
Force deduction solution summary 396 rotation function
力扣解法汇总1037-有效的回旋镖