本文整理汇总了C++中std::unique_ptr::AllocateSpaceInBuffer方法的典型用法代码示例。如果您正苦于以下问题:C++ unique_ptr::AllocateSpaceInBuffer方法的具体用法?C++ unique_ptr::AllocateSpaceInBuffer怎么用?C++ unique_ptr::AllocateSpaceInBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::unique_ptr
的用法示例。
在下文中一共展示了unique_ptr::AllocateSpaceInBuffer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Bind
void BBox::Bind()
{
if (!s_bbox_buffer)
{
return;
}
if (s_bbox_cpu_dirty)
{
s_bbox_stream_buffer->AllocateSpaceInBuffer(BBOX_BUFFER_SIZE, BBOX_BUFFER_SIZE);
// Allocate temporary bytes in upload buffer, then copy to real buffer.
memcpy(s_bbox_stream_buffer->GetCPUAddressOfCurrentAllocation(), s_bbox_shadow_copy, BBOX_BUFFER_SIZE);
D3D::ResourceBarrier(D3D::current_command_list, s_bbox_buffer, s_current_bbox_state, D3D12_RESOURCE_STATE_COPY_DEST, 0);
s_current_bbox_state = D3D12_RESOURCE_STATE_COPY_DEST;
D3D::current_command_list->CopyBufferRegion(s_bbox_buffer, 0, s_bbox_stream_buffer->GetBuffer(), s_bbox_stream_buffer->GetOffsetOfCurrentAllocation(), BBOX_BUFFER_SIZE);
s_bbox_cpu_dirty = false;
}
D3D::ResourceBarrier(D3D::current_command_list, s_bbox_buffer, s_current_bbox_state, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, 0);
s_current_bbox_state = D3D12_RESOURCE_STATE_UNORDERED_ACCESS;
D3D::current_command_list->SetGraphicsRootDescriptorTable(DESCRIPTOR_TABLE_PS_UAV, s_bbox_descriptor_handle);
s_bbox_gpu_dirty = true;
}
示例2: Set
void BBox::Set(int index, int value)
{
// If the buffer is currently mapped, compare the value, and update the staging buffer.
if (s_bbox_staging_buffer_map)
{
int current_value;
memcpy(¤t_value, reinterpret_cast<u8*>(s_bbox_staging_buffer_map) + (index * sizeof(int)), sizeof(int));
if (current_value == value)
{
// Value hasn't changed. So skip updating completely.
return;
}
memcpy(reinterpret_cast<u8*>(s_bbox_staging_buffer_map) + (index * sizeof(int)), &value, sizeof(int));
}
s_bbox_stream_buffer->AllocateSpaceInBuffer(sizeof(int), sizeof(int));
// Allocate temporary bytes in upload buffer, then copy to real buffer.
memcpy(s_bbox_stream_buffer->GetCPUAddressOfCurrentAllocation(), &value, sizeof(int));
D3D::ResourceBarrier(D3D::current_command_list, s_bbox_buffer, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COPY_DEST, 0);
D3D::current_command_list->CopyBufferRegion(s_bbox_buffer, index * sizeof(int), s_bbox_stream_buffer->GetBuffer(), s_bbox_stream_buffer->GetOffsetOfCurrentAllocation(), sizeof(int));
D3D::ResourceBarrier(D3D::current_command_list, s_bbox_buffer, D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, 0);
}