class BatchGpuDownloader

Defined at line 43 of file ../../src/ui/lib/escher/renderer/batch_gpu_downloader.h

Provides host-accessible GPU memory for clients to download Images and

Buffers from the GPU to host memory. Offers the ability to batch downloads

into consolidated submissions to the GPU driver.

About synchronization:

We use semaphore (usually generated by ChainedSemaphoreGenerator) for

synchronization between BatchGpuDownloader/Uploader and other gfx components,

so we only need the barrier to synchronize all transfer-related commands.

Currently users of BatchGpuDownloader should manually enforce that

the BatchGpuDownloader waits on other BatchGpuUploader or gfx::Engine if they

write to the images / buffers the BatchGpuDownloader reads from, by using

AddWaitSemaphore() function. Also, Submit() function will return a semaphore

being signaled when command buffer finishes execution, which can be used for

synchronization.

TODO(https://fxbug.dev/42098594) Add memory barriers so the BatchGpuUploader and

BatchGpuDownloader can handle synchronzation of reads and writes on the same

Resource.

Public Methods

std::unique_ptr<BatchGpuDownloader> New (EscherWeakPtr weak_escher, CommandBuffer::Type command_buffer_type, uint64_t frame_trace_number)

Defined at line 29 of file ../../src/ui/lib/escher/renderer/batch_gpu_downloader.cc

void BatchGpuDownloader (EscherWeakPtr weak_escher, CommandBuffer::Type command_buffer_type, uint64_t frame_trace_number)

Defined at line 41 of file ../../src/ui/lib/escher/renderer/batch_gpu_downloader.cc

void ~BatchGpuDownloader ()

Defined at line 52 of file ../../src/ui/lib/escher/renderer/batch_gpu_downloader.cc

void ScheduleReadBuffer (const BufferPtr & source, Callback callback, vk::DeviceSize source_offset, vk::DeviceSize copy_size)

Schedule a buffer-to-buffer copy that will be submitted when Submit()

is called. Retains a reference to the source until the submission's

CommandBuffer is retired.

|source_offset| is the starting offset in bytes from the start of the

source buffer.

|copy_size| is the size to be copied to the buffer.

These arguments are used to build VkBufferCopy struct. See the Vulkan

specs of VkBufferCopy for more details. If copy_size is set to 0 by

default, it copies all the contents from source.

Defined at line 57 of file ../../src/ui/lib/escher/renderer/batch_gpu_downloader.cc

bool HasContentToDownload ()

Returns true if the BatchGpuDownloader has work to do on the GPU.

Defined at line 60 of file ../../src/ui/lib/escher/renderer/batch_gpu_downloader.h

bool NeedsCommandBuffer ()

Returns true if BatchGpuDownloader needs a command buffer, i.e. it needs to

downloading images/buffers, or it needs to wait on/signal semaphores.

Defined at line 64 of file ../../src/ui/lib/escher/renderer/batch_gpu_downloader.h

void ScheduleReadImage (const ImagePtr & source, Callback callback, vk::BufferImageCopy region)

Schedule a image-to-buffer copy that will be submitted when Submit()

is called. Retains a reference to the source until the submission's

CommandBuffer is retired.

|region| specifies the buffer region which will be copied to the target

image.

|region.bufferOffset| should be set to zero since target buffer is

managed internally by the uploader; currently |imageOffset| requires to

be zero and |imageExtent| requires to be the whole image.

The default value of |region| is vk::BufferImageCopy(), in which case we

create a default copy region which reads the color data from the whole

image with only one mipmap layer.

|write_function| is a callback function which will be called at

GenerateCommands(), where we copy our data to the host-visible buffer.

Defined at line 76 of file ../../src/ui/lib/escher/renderer/batch_gpu_downloader.cc

CommandBufferFinishedCallback GenerateCommands (CommandBuffer * cmds)

Submits all pending work to the given CommandBuffer. Users need to call

cmds->Submit() after calling this function. Returns a lambda function

which calls all the callback functions we passed in to ScheduleReadBuffer

and ScheduleReadImage functions; this function should be called after the

command buffer has finished execution, typically by passing it to

cmds->Submit().

After this function is called, all the contents in |copy_info_records|,

staged |resources_| and semaphores will be moved to the lambda function

and the downloader will be cleaned and ready for reuse.

The argument |cmds| cannot be nullptr if there is any pending work,

including writing to buffer/images and waiting on/signaling semaphores.

Defined at line 104 of file ../../src/ui/lib/escher/renderer/batch_gpu_downloader.cc

void AddWaitSemaphore (SemaphorePtr sema, vk::PipelineStageFlags flags)

Submit() and GenerateCommands() will wait on all semaphores added by

AddWaitSemaphore().

Defined at line 127 of file ../../src/ui/lib/escher/renderer/batch_gpu_downloader.h

void AddSignalSemaphore (SemaphorePtr sema)

Submit() and GenerateCommands() will signals all semaphores added by

AddSignalSemaphore().

Defined at line 133 of file ../../src/ui/lib/escher/renderer/batch_gpu_downloader.h

void Submit (CommandBufferFinishedCallback client_callback)

Submits all pending work to the GPU.

The function |callback|, and all callback functions the user passed to

ScheduleReadBuffer and ScheduleReadImage, will be called after all work

is done.

After this function is called, all the contents in |copy_info_records|,

staged |resources_| and semaphores will be moved to the lambda function

and the downloader will be cleaned and ready for reuse.

Defined at line 196 of file ../../src/ui/lib/escher/renderer/batch_gpu_downloader.cc