This commit is contained in:
zzzisfunnyboy
2025-10-09 23:10:00 +08:00
13 changed files with 147 additions and 2 deletions

View File

@@ -1 +1,7 @@
---
tags:
- Batch
---
把数据加载到显存设置渲染状态CPU调用GPU渲染的过程称之为一个Batch。这其实就是渲染流程的运用阶段最终输出一个渲染图元(点、线、面等)再传递给GPU进行几何阶段和光栅化阶段的渲染显示。一个Batch必然会触发一次或多次DrawCal目包含了该对象的所有的网格和顶点数据以及材质信息。把数据加载到显存是指把清染所蛋的数据从硬盘加载到内存(RAM),再将网格和纹理等加载到显卡 VRAM),这一步比较释时。设置清染状态就是设置场景中的网格的顶点 Verex)片元(Fragment)着色器光源属性材质等。Unitv提供的动态合批(Dvnamic Batching)合并的就是这一过程,将清染状态相同的对象合并成-个Batch减少DrawCall。

View File

@@ -1 +1,7 @@
---
tags:
- DrawCall
---
CPU每次调用图像编程接口 glDrawElements(0penGl日中的图元清染函数)或者 DrawIndexedPrimitive(Direct中的顶点绘制方法)命令GPU渲染的操作称为一次Draw CalDraw Cal就是一次渲染命令的调用它指向一个需要被渲染的图元(primitive)列表不包含任何材质信息glDrawElements 或者 DrawIndexedPrimitive 函数的作用是将CPU准备好的顶点数据渲染出来.

View File

@@ -1 +1,7 @@
---
tags:
- DrawCall
---
Shader脚本中一个Pass语义块就是一个完整的渲染流程一个着色器可以包含多个Pass语义块每当GPU运行-个Pass之前就会产生一个SetPassCall所以可以理解为一次完整的染流程次数。

View File

@@ -0,0 +1,68 @@
---
tags:
- Texture
- Texture2D
- RenderTexture
---
### Texture Texture2D RenderTexture
三者关系与差别如下:
---
### 一、继承与本质关系
|类型|基类|存储位置|用途|
|---|---|---|---|
|**Texture**|基类|GPU|所有纹理的抽象基类|
|**Texture2D**|派生自 Texture|GPU|常规 2D 纹理,可读写像素|
|**RenderTexture**|派生自 Texture|GPU|可作为渲染目标的纹理|
---
### 二、功能差异
| 特性 | Texture2D | RenderTexture |
| -------------------- | --------------------------------------- | -------------------------------------------- |
| 是否可被采样(用于材质) | ✔ | ✔ |
| 是否可写入CPU端 | ✔(`SetPixels`/`LoadRawTextureData` | ✖仅GPU写 |
| 是否可作为渲染目标 | ✖ | ✔Camera/Graphics.Blit可直接输出 |
| 是否支持MipMap | ✔ | ✔(可选) |
| 是否可用于ComputeShader读写 | 读可用(`Texture2D` <br>写需`RWTexture2D`绑定 | 读写都可(`RenderTexture.enableRandomWrite=true` |
| 是否可保存为文件 | ✔(`EncodeToPNG`/`ReadPixels` | 需先复制到`Texture2D`再保存 |
---
### 三、常见交互流程
1. **GPU渲染到RenderTexture → 读取像素到Texture2D**
```CSharp
RenderTexture rt = new RenderTexture(512, 512, 0); Camera.main.targetTexture = rt; Camera.main.Render(); Texture2D tex = new Texture2D(512, 512, TextureFormat.RGBA32, false); RenderTexture.active = rt; tex.ReadPixels(new Rect(0, 0, 512, 512), 0, 0); tex.Apply(); RenderTexture.active = null;
```
此流程用于截图或生成贴图资产。
2. **Texture2D 复制内容到 RenderTexture**
`Graphics.Blit(texture2D, renderTexture);`
仅在shader中使用时保留GPU端数据不经CPU拷贝。
3. **RenderTexture 作为材质输入:**
`material.SetTexture("_MainTex", renderTexture);`
---
### 四、性能与使用建议
- `Texture2D` 适合静态资源贴图、UI图标、字体图集
- `RenderTexture` 适合动态生成后期处理、离屏渲染、动态阴影、SDF生成
- CPU访问`RenderTexture`代价高,应尽量避免频繁`ReadPixels`。
- 若仅GPU间数据流转用`RenderTexture`或`ComputeBuffer`,不要回读。

View File

@@ -1,2 +1,10 @@
---
tags:
- 性能优化
- 内存优化
- 内存碎片
---
- 大对象尽量复用,比如数组,可以在开头就分配好空间
- new int\[1000]

View File

@@ -1,6 +1,9 @@
---
参考链接: "[ASTC图片压缩技术浅析 - 知乎](https://zhuanlan.zhihu.com/p/1898042738022285491)"
参考链接2: "[深入理解ASTC](https://zhuanlan.zhihu.com/p/707250800)"
tags:
- ASTC
- 压缩
---
# 浅析

View File

@@ -1,3 +1,8 @@
---
tags:
- 多线程
- SIMD
---
- 一个普通加法指令,一次只能对两个数执行一个加法操作。

View File

@@ -0,0 +1,6 @@
---
tags:
- 多线程
- GPU
- ComputeShader
---

View File

@@ -1,3 +1,8 @@
---
tags:
- SIMT
- 多线程
---
单指令多线程

View File

@@ -12,4 +12,6 @@ tags:
- 代码优化
- 池化
- 复用
- GC
- GC
- UWA蓝皮书
- https://blog.uwa4d.com/archives/BlueBook_2025.html