38 lines
876 B
Markdown
38 lines
876 B
Markdown
# D3D12Common::CreateIndexBufferView
|
||
|
||
```cpp
|
||
inline D3D12_INDEX_BUFFER_VIEW CreateIndexBufferView(
|
||
D3D12_GPU_VIRTUAL_ADDRESS bufferLocation,
|
||
UINT sizeInBytes,
|
||
DXGI_FORMAT format
|
||
)
|
||
```
|
||
|
||
创建索引缓冲区视图。
|
||
|
||
**参数:**
|
||
- `bufferLocation` - 索引缓冲区 GPU 虚拟地址
|
||
- `sizeInBytes` - 缓冲区大小(字节)
|
||
- `format` - 索引格式(DXGI_FORMAT_R16_UINT 或 DXGI_FORMAT_R32_UINT)
|
||
|
||
**返回:** 配置好的 `D3D12_INDEX_BUFFER_VIEW` 结构
|
||
|
||
**线程安全:** ✅(纯函数)
|
||
|
||
**示例:**
|
||
|
||
```cpp
|
||
ID3D12Resource* indexBuffer = ...;
|
||
D3D12_INDEX_BUFFER_VIEW ibView = CreateIndexBufferView(
|
||
indexBuffer->GetGPUVirtualAddress(),
|
||
indexBufferSize,
|
||
DXGI_FORMAT_R16_UINT
|
||
);
|
||
cmdList->IASetIndexBuffer(&ibView);
|
||
```
|
||
|
||
## 相关文档
|
||
|
||
- [D3D12Common 总览](common.md)
|
||
- [CreateVertexBufferView](create-vertex-buffer-view.md)
|