本文整理汇总了C++中TRefCountPtr::GetResource方法的典型用法代码示例。如果您正苦于以下问题:C++ TRefCountPtr::GetResource方法的具体用法?C++ TRefCountPtr::GetResource怎么用?C++ TRefCountPtr::GetResource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TRefCountPtr
的用法示例。
在下文中一共展示了TRefCountPtr::GetResource方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Execute
void Execute(FRHICommandListBase& CmdList)
{
FD3D12DynamicRHI::GetD3DRHI()->UpdateBuffer(Destination->GetResource(), Destination->GetOffset(), Source->GetResource(), Source->GetOffset(), NumBytes);
}
示例2: ScopeResourceBarrierSource
void* FD3D12DynamicRHI::LockBuffer(FRHICommandListImmediate* RHICmdList, BufferType* Buffer, uint32 Offset, uint32 Size, EResourceLockMode LockMode)
{
FD3D12LockedData LockedData;
// Determine whether the buffer is dynamic or not.
const bool bIsDynamic = (Buffer->GetUsage() & BUF_AnyDynamic) ? true : false;
void* Data = nullptr;
if (bIsDynamic)
{
check(LockMode == RLM_WriteOnly);
TRefCountPtr<FD3D12ResourceLocation> newLocation = new FD3D12ResourceLocation(GetRHIDevice());
// Allocate a new resource
Data = GetRHIDevice()->GetDefaultUploadHeapAllocator().AllocUploadResource(Buffer->ResourceLocation->GetEffectiveBufferSize(), Buffer->BufferAlignment, newLocation);
// If on the RenderThread, queue up a command on the RHIThread to rename this buffer at the correct time
if (ShouldDeferBufferLockOperation(RHICmdList))
{
new (RHICmdList->AllocCommand<FRHICommandRenameUploadBuffer<BufferType>>()) FRHICommandRenameUploadBuffer<BufferType>(Buffer, newLocation);
}
else
{
Buffer->Rename(newLocation);
}
}
else
{
FD3D12Resource* pResource = Buffer->ResourceLocation->GetResource();
// Locking for read must occur immediately so we can't queue up the operations later.
if (LockMode == RLM_ReadOnly)
{
// If the static buffer is being locked for reading, create a staging buffer.
TRefCountPtr<FD3D12Resource> StagingBuffer;
VERIFYD3D11RESULT(GetRHIDevice()->GetResourceHelper().CreateBuffer(D3D12_HEAP_TYPE_READBACK, Offset + Size, StagingBuffer.GetInitReference()));
LockedData.StagingResource = StagingBuffer;
// Copy the contents of the buffer to the staging buffer.
{
const auto& pfnCopyContents = [&]()
{
FD3D12CommandContext& DefaultContext = GetRHIDevice()->GetDefaultCommandContext();
FD3D12CommandListHandle& hCommandList = DefaultContext.CommandListHandle;
FScopeResourceBarrier ScopeResourceBarrierSource(hCommandList, pResource, pResource->GetDefaultResourceState(), D3D12_RESOURCE_STATE_COPY_SOURCE, 0);
// Don't need to transition upload heaps
DefaultContext.numCopies++;
hCommandList->CopyBufferRegion(
StagingBuffer->GetResource(),
0,
pResource->GetResource(),
Offset, Size);
DefaultContext.FlushCommands(true);
};
if (ShouldDeferBufferLockOperation(RHICmdList))
{
// Sync when in the render thread implementation
check(IsInRHIThread() == false);
RHICmdList->ImmediateFlush(EImmediateFlushType::FlushRHIThread);
pfnCopyContents();
}
else
{
check(IsInRHIThread());
pfnCopyContents();
}
}
// Map the staging buffer's memory for reading.
VERIFYD3D11RESULT(StagingBuffer->GetResource()->Map(0, nullptr, &Data));
}
else
{
// If the static buffer is being locked for writing, allocate memory for the contents to be written to.
TRefCountPtr<FD3D12ResourceLocation> UploadBufferLocation = new FD3D12ResourceLocation(GetRHIDevice());
Data = GetRHIDevice()->GetDefaultFastAllocator().Allocate(Offset + Size, D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT, UploadBufferLocation);
// Keep track of the underlying resource for the upload heap so it can be referenced during Unmap.
LockedData.UploadHeapLocation = UploadBufferLocation;
}
}
check(Data);
// Add the lock to the lock map.
LockedData.SetData(Data);
LockedData.Pitch = Offset + Size;
// Add the lock to the lock map.
FD3D12LockedKey LockedKey(Buffer);
AddToOutstandingLocks(LockedKey, LockedData);
// Return the offset pointer
return (void*)((uint8*)LockedData.GetData() + Offset);
//.........这里部分代码省略.........