Files
XCEngine/docs/api/rhi/d3d12/shader-resource-view/initialize.md
2026-03-20 02:35:45 +08:00

41 lines
1.1 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.
# D3D12ShaderResourceView::Initialize
## 函数签名
```cpp
void Initialize(ID3D12Device* device, ID3D12Resource* resource, const D3D12_SHADER_RESOURCE_VIEW_DESC* desc = nullptr)
```
## 描述
初始化 D3D12 着色器资源视图。根据提供的资源创建 D3D12 着色器资源视图。
## 参数
| 参数 | 类型 | 描述 |
|------|------|------|
| `device` | `ID3D12Device*` | D3D12 设备指针,用于创建视图 |
| `resource` | `ID3D12Resource*` | D3D12 资源指针 |
| `desc` | `const D3D12_SHADER_RESOURCE_VIEW_DESC*` | 着色器资源视图描述符(可选,默认 nullptr |
## 返回值
## 示例
```cpp
// 创建 SRV使用默认描述符
D3D12ShaderResourceView srv;
srv.Initialize(device, texture, nullptr);
// 创建 SRV使用自定义描述符
D3D12_SHADER_RESOURCE_VIEW_DESC desc = D3D12ShaderResourceView::CreateDesc(Format::R8G8B8A8_UNorm);
srv.Initialize(device, texture, &desc);
```
## 相关文档
- [D3D12ShaderResourceView::InitializeAt](initialize-at.md) - 在指定位置初始化
- [D3D12ShaderResourceView::Shutdown](shutdown.md) - 关闭视图
- [D3D12ShaderResourceView](shader-resource-view.md) - 类总览