diff options
-rw-r--r-- | src/gpu/GrGpu.h | 6 | ||||
-rw-r--r-- | src/gpu/gl/GrGLGpu.cpp | 4 | ||||
-rw-r--r-- | src/gpu/gl/GrGLGpu.h | 2 | ||||
-rw-r--r-- | src/gpu/mock/GrMockGpu.h | 2 | ||||
-rw-r--r-- | src/gpu/mtl/GrMtlGpu.h | 2 | ||||
-rw-r--r-- | src/gpu/vk/GrVkGpu.cpp | 4 | ||||
-rw-r--r-- | src/gpu/vk/GrVkGpu.h | 2 | ||||
-rw-r--r-- | tests/GrMipMappedTest.cpp | 11 | ||||
-rw-r--r-- | tests/ImageTest.cpp | 10 |
9 files changed, 28 insertions, 15 deletions
diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h index b06b0d7481..0c794e2eff 100644 --- a/src/gpu/GrGpu.h +++ b/src/gpu/GrGpu.h @@ -468,6 +468,12 @@ public: */ virtual void deleteTestingOnlyBackendTexture(GrBackendTexture*) = 0; + /** + * Flushes all work to the gpu and forces the GPU to wait until all the gpu work has completed. + * This is for testing purposes only. + */ + virtual void testingOnly_flushGpuAndSync() = 0; + // width and height may be larger than rt (if underlying API allows it). // Returns nullptr if compatible sb could not be created, otherwise the caller owns the ref on // the GrStencilAttachment. diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index 2a1d403cea..82be0d1a97 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -4438,6 +4438,10 @@ void GrGLGpu::resetShaderCacheForTesting() const { fProgramCache->abandon(); } +void GrGLGpu::testingOnly_flushGpuAndSync() { + GL_CALL(Finish()); +} + /////////////////////////////////////////////////////////////////////////////// GrGLAttribArrayState* GrGLGpu::HWVertexArrayState::bindInternalVertexArray(GrGLGpu* gpu, diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h index 81c15f0c54..3a67958d5f 100644 --- a/src/gpu/gl/GrGLGpu.h +++ b/src/gpu/gl/GrGLGpu.h @@ -158,6 +158,8 @@ public: void resetShaderCacheForTesting() const override; + void testingOnly_flushGpuAndSync() override; + GrFence SK_WARN_UNUSED_RESULT insertFence() override; bool waitFence(GrFence, uint64_t timeout) override; void deleteFence(GrFence) const override; diff --git a/src/gpu/mock/GrMockGpu.h b/src/gpu/mock/GrMockGpu.h index e44cc36922..d3e665c2e4 100644 --- a/src/gpu/mock/GrMockGpu.h +++ b/src/gpu/mock/GrMockGpu.h @@ -126,6 +126,8 @@ private: bool isTestingOnlyBackendTexture(const GrBackendTexture&) const override; void deleteTestingOnlyBackendTexture(GrBackendTexture*) override; + void testingOnly_flushGpuAndSync() override {} + static int NextInternalTextureID(); static int NextExternalTextureID(); diff --git a/src/gpu/mtl/GrMtlGpu.h b/src/gpu/mtl/GrMtlGpu.h index 5bc9c0636c..9907e95d29 100644 --- a/src/gpu/mtl/GrMtlGpu.h +++ b/src/gpu/mtl/GrMtlGpu.h @@ -145,6 +145,8 @@ private: bool isTestingOnlyBackendTexture(const GrBackendTexture&) const override { return false; } void deleteTestingOnlyBackendTexture(GrBackendTexture*) override {} + void testingOnly_flushGpuAndSync() override {} + sk_sp<GrMtlCaps> fMtlCaps; id<MTLDevice> fDevice; diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp index 64ba71f24a..b6268a7a65 100644 --- a/src/gpu/vk/GrVkGpu.cpp +++ b/src/gpu/vk/GrVkGpu.cpp @@ -1509,6 +1509,10 @@ void GrVkGpu::deleteTestingOnlyBackendTexture(GrBackendTexture* tex) { } } +void GrVkGpu::testingOnly_flushGpuAndSync() { + this->submitCommandBuffer(kForce_SyncQueue); +} + //////////////////////////////////////////////////////////////////////////////// void GrVkGpu::addMemoryBarrier(VkPipelineStageFlags srcStageMask, diff --git a/src/gpu/vk/GrVkGpu.h b/src/gpu/vk/GrVkGpu.h index e622d573de..4d1685eb29 100644 --- a/src/gpu/vk/GrVkGpu.h +++ b/src/gpu/vk/GrVkGpu.h @@ -76,6 +76,8 @@ public: bool isTestingOnlyBackendTexture(const GrBackendTexture&) const override; void deleteTestingOnlyBackendTexture(GrBackendTexture*) override; + void testingOnly_flushGpuAndSync() override; + GrStencilAttachment* createStencilAttachmentForRenderTarget(const GrRenderTarget*, int width, int height) override; diff --git a/tests/GrMipMappedTest.cpp b/tests/GrMipMappedTest.cpp index 1462648a78..484b7bfd4f 100644 --- a/tests/GrMipMappedTest.cpp +++ b/tests/GrMipMappedTest.cpp @@ -203,14 +203,9 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrBackendTextureImageMipMappedTest, reporter, } // Must make sure the uses of the backend texture have finished (we possibly have a - // queued up copy) before we delete the backend texture. Thus we use readPixels here - // just to force the synchronization. - sk_sp<GrSurfaceContext> surfContext = - context->contextPriv().makeWrappedSurfaceContext(genProxy); - - SkBitmap bitmap; - bitmap.allocPixels(imageInfo); - surfContext->readPixels(imageInfo, bitmap.getPixels(), 0, 0, 0, 0); + // queued up copy) before we delete the backend texture. + context->flush(); + gpu->testingOnly_flushGpuAndSync(); gpu->deleteTestingOnlyBackendTexture(&backendTex); } diff --git a/tests/ImageTest.cpp b/tests/ImageTest.cpp index 619b52d6e2..49ab65b6a7 100644 --- a/tests/ImageTest.cpp +++ b/tests/ImageTest.cpp @@ -939,13 +939,9 @@ static void test_cross_context_image(skiatest::Reporter* reporter, const GrConte otherTestContext->makeCurrent(); canvas->flush(); - // This readPixels call is needed for Vulkan to make sure the ReleaseProc is called. - // Even though we flushed above, this does not guarantee the command buffer will finish - // which is when we call the ReleaseProc. The readPixels forces a CPU sync so we know - // that the command buffer has finished and we've called the ReleaseProc. - SkBitmap bitmap; - bitmap.allocPixels(info); - canvas->readPixels(bitmap, 0, 0); + // This is specifically here for vulkan to guarantee the command buffer will finish + // which is when we call the ReleaseProc. + otherCtx->contextPriv().getGpu()->testingOnly_flushGpuAndSync(); } // Case #6: Verify that only one context can be using the image at a time |