Dawn: submit all command buffers in a single call.
All command buffers are now appended to a single vector, and submitted
submitted in onFinishFlush() in a single submit.
In order to do this, implement a centralized command encoder for copies.
This command encoder is used for buffer-to-buffer, buffer-to-texture and
texture-to-buffer copies.
Change-Id: If1092ae4edbe03c995d4cb80e0dc124516d63dad
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/235826
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
diff --git a/src/gpu/dawn/GrDawnTexture.cpp b/src/gpu/dawn/GrDawnTexture.cpp
index 1fc6e0a..ee9df7d 100644
--- a/src/gpu/dawn/GrDawnTexture.cpp
+++ b/src/gpu/dawn/GrDawnTexture.cpp
@@ -124,13 +124,14 @@
return GrBackendTexture(this->width(), this->height(), fInfo);
}
-void GrDawnTexture::upload(const GrMipLevel texels[], int mipLevels) {
- upload(texels, mipLevels, SkIRect::MakeWH(width(), height()));
+void GrDawnTexture::upload(const GrMipLevel texels[], int mipLevels,
+ dawn::CommandEncoder copyEncoder) {
+ this->upload(texels, mipLevels, SkIRect::MakeWH(width(), height()), copyEncoder);
}
-void GrDawnTexture::upload(const GrMipLevel texels[], int mipLevels, const SkIRect& rect) {
+void GrDawnTexture::upload(const GrMipLevel texels[], int mipLevels, const SkIRect& rect,
+ dawn::CommandEncoder copyEncoder) {
dawn::Device device = this->getDawnGpu()->device();
- dawn::Queue queue = this->getDawnGpu()->queue();
uint32_t x = rect.x();
uint32_t y = rect.y();
@@ -200,11 +201,7 @@
dstTexture.origin = {x, y, 0};
dawn::Extent3D copySize = {width, height, 1};
- dawn::CommandEncoder encoder = device.CreateCommandEncoder();
- encoder.CopyBufferToTexture(&srcBuffer, &dstTexture, ©Size);
- dawn::CommandBuffer copy = encoder.Finish();
- queue.Submit(1, ©);
-
+ copyEncoder.CopyBufferToTexture(&srcBuffer, &dstTexture, ©Size);
x /= 2;
y /= 2;
width /= 2;