Files
XCEngine/docs/api/XCEngine/Rendering/RenderResourceCache/GetOrCreateTexture.md

39 lines
1.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# RenderResourceCache::GetOrCreateTexture
获取或创建某个 `Texture` 的 GPU 缓存。
```cpp
const CachedTexture* GetOrCreateTexture(RHI::RHIDevice* device, const Resources::Texture* texture);
```
## 行为说明
当前实现会:
1. 检查 `device``texture``texture->IsValid()`
2. 若缓存已存在,直接返回。
3. 否则把纹理上传成 RHI texture并创建 shader resource view。
4. 把结果放入 `m_textureCache` 并返回。
## 参数
- `device` - 用于创建 GPU 纹理与 SRV 的设备。
- `texture` - 要缓存的纹理资源。
## 返回值
- 成功时返回 `CachedTexture*`
- 失败时返回 `nullptr`
## 当前实现限制
- 当前仅支持很少的纹理格式映射。
- 当前默认创建 `Texture2D` 维度的 SRV。
- 纹理缓存同样不具备内容变更失效机制。
## 相关文档
- [返回类型总览](RenderResourceCache.md)
- [GetOrCreateMesh](GetOrCreateMesh.md)
- [BuiltinForwardPipeline](../Pipelines/BuiltinForwardPipeline/BuiltinForwardPipeline.md)