class BatchGpuUploader
Defined at line 43 of file ../../src/ui/lib/escher/renderer/batch_gpu_uploader.h
Provides host-accessible GPU memory for clients to upload Images and Buffers
to the GPU. Offers the ability to batch uploads 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 BatchGpuUploader should manually enforce that the
BatchGpuUploader waits on other BatchGpuUploader or gfx::Engine if they write
to the images / buffers the BatchGpuUploader 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 synchronization of reads and writes on the same
Resource.
Public Methods
std::unique_ptr<BatchGpuUploader> New (EscherWeakPtr weak_escher, uint64_t frame_trace_number)
Defined at line 27 of file ../../src/ui/lib/escher/renderer/batch_gpu_uploader.cc
void BatchGpuUploader (EscherWeakPtr weak_escher, uint64_t frame_trace_number)
Defined at line 37 of file ../../src/ui/lib/escher/renderer/batch_gpu_uploader.cc
void ~BatchGpuUploader ()
Defined at line 45 of file ../../src/ui/lib/escher/renderer/batch_gpu_uploader.cc
void ScheduleWriteBuffer (const BufferPtr & target, DataProviderCallback write_function, vk::DeviceSize target_offset, vk::DeviceSize copy_size)
Schedule a buffer-to-buffer copy that will be submitted when Submit()
is called. Reference will be retained in |resources_| until we call
Submit(), where we keep the resources alive until submitted CommandBuffer
is retired.
|target_offset| is the starting offset in bytes from the start of the
target buffer.
|copy_size| is the size to be copied to the buffer.
These arguments are used to build VkBufferCopy struct. See the Vulkan specs
VkBufferCopy for more details.
|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 50 of file ../../src/ui/lib/escher/renderer/batch_gpu_uploader.cc
bool HasContentToUpload ()
Returns true if the BatchGPUUploader has content to upload on the GPU.
Defined at line 52 of file ../../src/ui/lib/escher/renderer/batch_gpu_uploader.h
bool NeedsCommandBuffer ()
Returns true if BatchGpuUploader needs a command buffer, i.e. it needs to
uploading images/buffers, or it needs to wait on/signal semaphores.
Defined at line 56 of file ../../src/ui/lib/escher/renderer/batch_gpu_uploader.h
void ScheduleWriteImage (const ImagePtr & target, DataProviderCallback write_function, vk::ImageLayout final_layout, vk::BufferImageCopy region)
Schedule a buffer-to-image copy that will be submitted when Submit()
is called. Reference will be retained in |resources_| until we call
Submit(), where we keep the resources alive until submitted CommandBuffer
is retired.
|region| specifies the buffer region which will be copied to the target
image.
|region.bufferOffset| should be set to zero since the src 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 writes to the color data of an image
of 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 72 of file ../../src/ui/lib/escher/renderer/batch_gpu_uploader.cc
template <class T>
void ScheduleWriteBuffer (const BufferPtr & target, std::vector<T> host_data, vk::DeviceSize target_offset, vk::DeviceSize copy_size)
Schedule a buffer-to-buffer copy that will be submitted when Submit()
is called. Reference will be retained in |resources_| until we call
Submit(), where we keep the resources alive until submitted CommandBuffer
is retired.
|target_offset| is the starting offset in bytes from the start of the
target buffer.
|copy_size| is the size to be copied to the buffer.
This argument is used to build VkBufferCopy struct. See the Vulkan specs
VkBufferCopy for more details.
|host_data| will be kept until GenerateCommands() where we copy the data
to the host-visible buffer.
Defined at line 96 of file ../../src/ui/lib/escher/renderer/batch_gpu_uploader.h
void GenerateCommands (CommandBuffer * cmds)
Submits all pending work to the given CommandBuffer. Users need to call
cmds->Submit() after calling this function.
CommandBuffer cannot be empty if there is any pending work, including
writing to buffer/images, waiting on/signaling semaphores.
Defined at line 122 of file ../../src/ui/lib/escher/renderer/batch_gpu_uploader.cc
template <class T>
void ScheduleWriteImage (const ImagePtr & target, std::vector<T> host_data, vk::ImageLayout final_layout, vk::BufferImageCopy region)
Schedule a buffer-to-image copy that will be submitted when Submit()
is called. Reference will be retained in |resources_| until we call
Submit(), where we keep the resources alive until submitted CommandBuffer
is retired.
|region| specifies the buffer region which will be copied to the target
image.
|region.bufferOffset| should be set to zero since the src 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 writes to the color data of an image
of one mipmap layer.
|host_data| will be kept until GenerateCommands() where we copy the data
to the host-visible buffer.
Defined at line 149 of file ../../src/ui/lib/escher/renderer/batch_gpu_uploader.h
void Submit (fit::function<void ()> callback)
Submits all pending work to the given CommandBuffer.
Callback function will be called after all work is done.
Note that Submit must be called on all BatchGpuUploaders, even if no work was scheduled.
TODO(https://fxbug.dev/42151479): Remove this restriction.
Defined at line 200 of file ../../src/ui/lib/escher/renderer/batch_gpu_uploader.cc
void AddWaitSemaphore (SemaphorePtr sema, vk::PipelineStageFlags flags)
Submit() and GenerateCommands() will wait on all semaphores added by
AddWaitSemaphore().
Defined at line 231 of file ../../src/ui/lib/escher/renderer/batch_gpu_uploader.cc
void AddSignalSemaphore (SemaphorePtr sema)
Submit() and GenerateCommands() will signal all semaphores added by
AddSignalSemaphore().
Defined at line 235 of file ../../src/ui/lib/escher/renderer/batch_gpu_uploader.cc