Combine GPU flush with semaphore API
Bug: skia: Change-Id: I5f388760d43b19755b2767d95d32065f6d0f926e Reviewed-on: https://skia-review.googlesource.com/14646 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
This commit is contained in:
parent
736a9cc88d
commit
dc87c95382
@ -385,13 +385,9 @@ public:
|
||||
virtual void deleteFence(GrFence) const = 0;
|
||||
|
||||
virtual sk_sp<GrSemaphore> SK_WARN_UNUSED_RESULT makeSemaphore() = 0;
|
||||
virtual void insertSemaphore(sk_sp<GrSemaphore> semaphore) = 0;
|
||||
virtual void insertSemaphore(sk_sp<GrSemaphore> semaphore, bool flush = false) = 0;
|
||||
virtual void waitSemaphore(sk_sp<GrSemaphore> semaphore) = 0;
|
||||
|
||||
// Ensures that all queued up driver-level commands have been sent to the GPU. For example, on
|
||||
// OpenGL, this calls glFlush.
|
||||
virtual void flush() = 0;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Debugging and Stats
|
||||
|
||||
|
@ -4492,12 +4492,16 @@ sk_sp<GrSemaphore> SK_WARN_UNUSED_RESULT GrGLGpu::makeSemaphore() {
|
||||
return GrGLSemaphore::Make(this);
|
||||
}
|
||||
|
||||
void GrGLGpu::insertSemaphore(sk_sp<GrSemaphore> semaphore) {
|
||||
void GrGLGpu::insertSemaphore(sk_sp<GrSemaphore> semaphore, bool flush) {
|
||||
GrGLSemaphore* glSem = static_cast<GrGLSemaphore*>(semaphore.get());
|
||||
|
||||
GrGLsync sync;
|
||||
GL_CALL_RET(sync, FenceSync(GR_GL_SYNC_GPU_COMMANDS_COMPLETE, 0));
|
||||
glSem->setSync(sync);
|
||||
|
||||
if (flush) {
|
||||
GL_CALL(Flush());
|
||||
}
|
||||
}
|
||||
|
||||
void GrGLGpu::waitSemaphore(sk_sp<GrSemaphore> semaphore) {
|
||||
@ -4509,7 +4513,3 @@ void GrGLGpu::waitSemaphore(sk_sp<GrSemaphore> semaphore) {
|
||||
void GrGLGpu::deleteSync(GrGLsync sync) const {
|
||||
GL_CALL(DeleteSync(sync));
|
||||
}
|
||||
|
||||
void GrGLGpu::flush() {
|
||||
GL_CALL(Flush());
|
||||
}
|
||||
|
@ -147,13 +147,11 @@ public:
|
||||
void deleteFence(GrFence) const override;
|
||||
|
||||
sk_sp<GrSemaphore> SK_WARN_UNUSED_RESULT makeSemaphore() override;
|
||||
void insertSemaphore(sk_sp<GrSemaphore> semaphore) override;
|
||||
void insertSemaphore(sk_sp<GrSemaphore> semaphore, bool flush) override;
|
||||
void waitSemaphore(sk_sp<GrSemaphore> semaphore) override;
|
||||
|
||||
void deleteSync(GrGLsync) const;
|
||||
|
||||
void flush() override;
|
||||
|
||||
private:
|
||||
GrGLGpu(GrGLContext* ctx, GrContext* context);
|
||||
|
||||
|
@ -122,8 +122,7 @@ std::unique_ptr<GrExternalTextureData> GrGLTexture::detachBackendTexture() {
|
||||
|
||||
// Set up a semaphore to be signaled once the data is ready, and flush GL
|
||||
sk_sp<GrSemaphore> semaphore = this->getContext()->resourceProvider()->makeSemaphore();
|
||||
this->getGpu()->insertSemaphore(semaphore);
|
||||
this->getGpu()->flush();
|
||||
this->getGpu()->insertSemaphore(semaphore, true);
|
||||
|
||||
// Make a copy of our GL-specific information
|
||||
auto data = skstd::make_unique<GrGLExternalTextureData>(fInfo, std::move(semaphore),
|
||||
|
@ -1924,9 +1924,10 @@ sk_sp<GrSemaphore> SK_WARN_UNUSED_RESULT GrVkGpu::makeSemaphore() {
|
||||
return GrVkSemaphore::Make(this);
|
||||
}
|
||||
|
||||
void GrVkGpu::insertSemaphore(sk_sp<GrSemaphore> semaphore) {
|
||||
void GrVkGpu::insertSemaphore(sk_sp<GrSemaphore> semaphore, bool /*flush*/) {
|
||||
GrVkSemaphore* vkSem = static_cast<GrVkSemaphore*>(semaphore.get());
|
||||
|
||||
// We *always* flush, so ignore that parameter
|
||||
this->submitCommandBuffer(kSkip_SyncQueue, vkSem->getResource());
|
||||
}
|
||||
|
||||
@ -1937,7 +1938,3 @@ void GrVkGpu::waitSemaphore(sk_sp<GrSemaphore> semaphore) {
|
||||
resource->ref();
|
||||
fSemaphoresToWaitOn.push_back(resource);
|
||||
}
|
||||
|
||||
void GrVkGpu::flush() {
|
||||
// We submit the command buffer to the queue whenever Ganesh is flushed, so nothing is needed
|
||||
}
|
||||
|
@ -133,11 +133,9 @@ public:
|
||||
void deleteFence(GrFence) const override;
|
||||
|
||||
sk_sp<GrSemaphore> SK_WARN_UNUSED_RESULT makeSemaphore() override;
|
||||
void insertSemaphore(sk_sp<GrSemaphore> semaphore) override;
|
||||
void insertSemaphore(sk_sp<GrSemaphore> semaphore, bool flush) override;
|
||||
void waitSemaphore(sk_sp<GrSemaphore> semaphore) override;
|
||||
|
||||
void flush() override;
|
||||
|
||||
void generateMipmap(GrVkTexture* tex);
|
||||
|
||||
bool updateBuffer(GrVkBuffer* buffer, const void* src, VkDeviceSize offset, VkDeviceSize size);
|
||||
|
@ -330,10 +330,9 @@ public:
|
||||
GrFence SK_WARN_UNUSED_RESULT insertFence() override { return 0; }
|
||||
bool waitFence(GrFence, uint64_t) override { return true; }
|
||||
void deleteFence(GrFence) const override {}
|
||||
void flush() override {}
|
||||
|
||||
sk_sp<GrSemaphore> SK_WARN_UNUSED_RESULT makeSemaphore() override { return nullptr; }
|
||||
void insertSemaphore(sk_sp<GrSemaphore> semaphore) override {}
|
||||
void insertSemaphore(sk_sp<GrSemaphore> semaphore, bool flush) override {}
|
||||
void waitSemaphore(sk_sp<GrSemaphore> semaphore) override {}
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user