1.1 KiB
1.1 KiB
D3D12Buffer::InitializeWithData
函数签名
bool InitializeWithData(ID3D12Device* device, ID3D12GraphicsCommandList* commandList, const void* data, uint64_t size, D3D12_RESOURCE_STATES finalState)
中文描述
创建缓冲区并通过命令列表从内存数据初始化内容。内部会自动创建上传堆、复制数据、转换状态。
参数
| 参数 | 类型 | 描述 |
|---|---|---|
device |
ID3D12Device* |
D3D12 设备指针 |
commandList |
ID3D12GraphicsCommandList* |
命令列表(用于复制操作) |
data |
const void* |
初始数据指针 |
size |
uint64_t |
数据大小(字节) |
finalState |
D3D12_RESOURCE_STATES |
数据复制完成后的目标状态 |
返回值
bool - 初始化是否成功
复杂度
O(n) - 取决于数据大小,内部创建临时上传堆
示例
uint16_t indices[] = { 0, 1, 2, 1, 3, 2 };
D3D12Buffer indexBuffer;
indexBuffer.InitializeWithData(
device,
commandList,
indices,
sizeof(indices),
D3D12_RESOURCE_STATE_INDEX_BUFFER);