37 lines
876 B
Markdown
37 lines
876 B
Markdown
|
|
# D3D12Device::CreateTexture
|
||
|
|
|
||
|
|
```cpp
|
||
|
|
RHITexture* CreateTexture(const TextureDesc& desc) override;
|
||
|
|
```
|
||
|
|
|
||
|
|
创建 D3D12 纹理资源。
|
||
|
|
|
||
|
|
**参数:**
|
||
|
|
- `desc` - 纹理描述符,包含维度、格式、分辨率等
|
||
|
|
|
||
|
|
**返回:** 新创建的纹理指针,失败返回 `nullptr`
|
||
|
|
|
||
|
|
**复杂度:** O(1)
|
||
|
|
|
||
|
|
**示例:**
|
||
|
|
|
||
|
|
```cpp
|
||
|
|
TextureDesc texDesc;
|
||
|
|
texDesc.textureType = (uint32_t)D3D12_RESOURCE_DIMENSION_TEXTURE2D;
|
||
|
|
texDesc.width = 1920;
|
||
|
|
texDesc.height = 1080;
|
||
|
|
texDesc.depth = 1;
|
||
|
|
texDesc.mipLevels = 1;
|
||
|
|
texDesc.format = (uint32_t)DXGI_FORMAT_R8G8B8A8_UNORM;
|
||
|
|
texDesc.sampleCount = 1;
|
||
|
|
texDesc.sampleQuality = 0;
|
||
|
|
|
||
|
|
RHITexture* texture = device->CreateTexture(texDesc);
|
||
|
|
```
|
||
|
|
|
||
|
|
## 相关文档
|
||
|
|
|
||
|
|
- [D3D12Device 总览](device.md) - 返回类总览
|
||
|
|
- [RHIDevice::CreateTexture](../../device/create-texture.md) - 基类方法
|
||
|
|
- [D3D12Texture](../../texture/texture.md) - D3D12 纹理实现
|