class GpuTransferBufferHelper

Helper that manages automatic creation and submission of transfer command buffers.

Primarily used for buffer/texture read/write operations, in case the user doesn't provide an explicit command buffer to perform them on.

Thread safe.

Public

Constructors

GpuTransferBufferHelper

GpuTransferBufferHelper(GpuDevice &device, GpuQueueId targetQueue)

Creates a transfer buffer helper for the specified device and target queue.

device
GPU device this helper belongs to.
targetQueue
Queue that transfer command buffers will be submitted to.

Methods

~GpuTransferBufferHelper

~GpuTransferBufferHelper()

GetOrCreateTransferCommandBuffer

const SPtr<render::GpuCommandBuffer> &GetOrCreateTransferCommandBuffer()

Returns a command buffer for transfer operations on the current thread.

If no command buffer exists for this thread, one is created. The command buffer will be submitted to the configured target queue.

This is a helper method that creates a transient transfer command buffer under the hood.

Returns: Transfer command buffer for the current thread.

SubmitTransferCommandBuffer

void SubmitTransferCommandBuffer(bool wait = false)

Submits the active transfer command buffer for the current thread.

After submission, the command buffer is invalidated and a new one will be created on the next GetOrCreate call.

wait
If true, blocks until the command buffer finishes executing on the GPU.

EndFrame

void EndFrame()

Advances all transfer command buffer pool rings to the next frame.

Called at the end of each frame by the renderer.

Private

Methods

RegisterCurrentThreadIfNeeded

ThreadData *RegisterCurrentThreadIfNeeded()

Registers the current thread if not already registered.

Returns the thread data.

GetCurrentThreadData

ThreadData *GetCurrentThreadData()

Gets the thread data for the current thread, or nullptr if not registered.

Fields

mGpuDevice

GpuDevice & mGpuDevice

mTargetQueueType

GpuQueueType mTargetQueueType

mTargetQueueIndex

u32 mTargetQueueIndex

mRegistryMutex

Mutex mRegistryMutex

mThreadRegistry

Vector<UPtr<ThreadData>> mThreadRegistry