Files
XCEngine/docs/api/rhi/device/create-texture.md

39 lines
919 B
Markdown
Raw Normal View History

# RHIDevice::CreateTexture
```cpp
virtual RHITexture* CreateTexture(const TextureDesc& desc) = 0;
```
创建 GPU 纹理资源。
**参数:**
- `desc` - 纹理描述符,包含尺寸、格式、纹理类型等
**返回:** 新创建的纹理指针,失败返回 `nullptr`
**复杂度:** O(1)
**示例:**
```cpp
TextureDesc textureDesc;
textureDesc.width = 1024;
textureDesc.height = 1024;
textureDesc.depth = 1;
textureDesc.mipLevels = 1;
textureDesc.arraySize = 1;
textureDesc.format = (uint32_t)Format::R8G8B8A8_UNorm;
textureDesc.textureType = (uint32_t)TextureType::Texture2D;
textureDesc.sampleCount = 1;
textureDesc.sampleQuality = 0;
textureDesc.flags = 0;
RHITexture* texture = device->CreateTexture(textureDesc);
```
## 相关文档
- [RHIDevice 总览](device.md) - 返回类总览
- [RHITexture](../texture/texture.md) - 纹理类
- [TextureDesc](../types/types.md) - 纹理描述结构体