Files
XCEngine/docs/api/resources/shader/release.md

35 lines
777 B
Markdown
Raw Normal View History

2026-03-20 02:35:35 +08:00
# Shader::Release
```cpp
void Release()
```
释放着色器持有的所有资源。
此方法继承自 `IResource` 接口。调用后:
- 清空源码字符串 (`m_sourceCode`)
- 清空编译后的二进制数据 (`m_compiledBinary`)
- 清空 Uniform 列表 (`m_uniforms`)
- 清空 Attribute 列表 (`m_attributes`)
- 释放 RHI 着色器资源指针 (`m_rhiResource`)
-`m_isValid` 标记为 `false`
**返回:** 无
**线程安全:** ❌ 非线程安全
**复杂度:** O(n) - 取决于列表中元素数量
**示例:**
```cpp
// 使用完 shader 后释放
ResourceHandle<Shader> vs = ResourceManager::Get().Load<Shader>("shaders/vertex.glsl");
// ... 使用着色器 ...
vs->Release();
```
## 相关文档
- [Shader 总览](shader.md) - 返回类总览