From 078cf3e3b2d97a9c0c50aad6c9433cc3b6425831 Mon Sep 17 00:00:00 2001 From: John Rosasco Date: Thu, 31 Oct 2019 16:21:39 -0700 Subject: [PATCH] Fully delineate GL usage w/ skia_use_gl Change-Id: I17424d2235c7a54c4cda036f01a0b99dadc4b632 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/252085 Commit-Queue: Mike Klein Reviewed-by: Brian Salomon --- BUILD.gn | 7 +- gn/BUILDCONFIG.gn | 2 +- gn/gpu.gni | 139 +++++++++++++++-------------- gn/skia.gni | 1 + gn/tests.gni | 2 - src/gpu/GrBackendSurface.cpp | 29 ++++-- src/gpu/GrLegacyDirectContext.cpp | 6 +- tests/DeferredDisplayListTest.cpp | 6 +- tests/EGLImageTest.cpp | 4 + tests/GrGLExtensionsTest.cpp | 4 + tests/ProxyTest.cpp | 4 + tests/RectangleTextureTest.cpp | 6 ++ tests/SurfaceSemaphoreTest.cpp | 6 ++ tests/TextureBindingsResetTest.cpp | 4 + tests/TraceMemoryDumpTest.cpp | 4 + tests/VkHardwareBufferTest.cpp | 31 +++++-- tools/gpu/GrContextFactory.cpp | 6 ++ tools/skqp/src/skqp.cpp | 4 + 18 files changed, 170 insertions(+), 95 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 901a7c175b..67e1a352bb 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -6,7 +6,6 @@ import("gn/flutter_defines.gni") import("gn/fuchsia_defines.gni") import("gn/shared_sources.gni") - import("gn/skia.gni") if (skia_use_dawn) { @@ -515,9 +514,6 @@ optional("gpu") { sources += [ "src/gpu/GrPathRendering_none.cpp" ] } - # These paths need to be absolute to match the ones produced by shared_sources.gni. - sources -= get_path_info([ "src/gpu/gl/GrGLMakeNativeInterface_none.cpp" ], - "abspath") libs = [] if (is_android) { sources += [ "src/gpu/gl/egl/GrGLMakeNativeInterface_egl.cpp" ] @@ -553,7 +549,7 @@ optional("gpu") { public_defines += [ "SK_ENABLE_VK_LAYERS" ] } if (is_fuchsia) { - if (using_fuchsia_sdk) { + if (skia_using_fuchsia_sdk) { public_deps += [ "$fuchsia_sdk_root/pkg:vulkan" ] } else { public_deps += [ "//src/graphics/lib/vulkan" ] @@ -1298,6 +1294,7 @@ if (skia_enable_tools) { "tools/gpu/gl/command_buffer/GLTestContext_command_buffer.cpp", "tools/gpu/mock/MockTestContext.cpp", ] + libs = [] if (is_android || skia_use_egl) { diff --git a/gn/BUILDCONFIG.gn b/gn/BUILDCONFIG.gn index 5d05f39477..0d54914bc1 100644 --- a/gn/BUILDCONFIG.gn +++ b/gn/BUILDCONFIG.gn @@ -81,7 +81,7 @@ if (current_cpu == "") { is_clang = is_android || is_ios || is_mac || (cc == "clang" && cxx == "clang++") || clang_win != "" if (!is_clang && !is_win) { - is_clang = exec_script("gn/is_clang.py", + is_clang = exec_script("//gn/is_clang.py", [ cc, cxx, diff --git a/gn/gpu.gni b/gn/gpu.gni index 21a1b246ea..9840f1f136 100644 --- a/gn/gpu.gni +++ b/gn/gpu.gni @@ -7,6 +7,66 @@ _src = get_path_info("../src", "abspath") _include = get_path_info("../include", "abspath") +skia_gl_sources = [ + "$_include/gpu/gl/GrGLAssembleInterface.h", + "$_include/gpu/gl/GrGLConfig.h", + "$_include/gpu/gl/GrGLExtensions.h", + "$_include/gpu/gl/GrGLFunctions.h", + "$_include/gpu/gl/GrGLInterface.h", + "$_include/gpu/gl/GrGLTypes.h", + + "$_src/gpu/gl/GrGLAssembleGLESInterfaceAutogen.cpp", + "$_src/gpu/gl/GrGLAssembleGLInterfaceAutogen.cpp", + "$_src/gpu/gl/GrGLAssembleHelpers.cpp", + "$_src/gpu/gl/GrGLAssembleInterface.cpp", + "$_src/gpu/gl/GrGLAssembleWebGLInterfaceAutogen.cpp", + "$_src/gpu/gl/GrGLBuffer.cpp", + "$_src/gpu/gl/GrGLBuffer.h", + "$_src/gpu/gl/GrGLCaps.cpp", + "$_src/gpu/gl/GrGLCaps.h", + "$_src/gpu/gl/GrGLContext.cpp", + "$_src/gpu/gl/GrGLContext.h", + "$_src/gpu/gl/GrGLDefines.h", + "$_src/gpu/gl/GrGLGLSL.cpp", + "$_src/gpu/gl/GrGLGLSL.h", + "$_src/gpu/gl/GrGLGpu.cpp", + "$_src/gpu/gl/GrGLGpu.h", + "$_src/gpu/gl/GrGLGpuProgramCache.cpp", + "$_src/gpu/gl/GrGLExtensions.cpp", + "$_src/gpu/gl/GrGLInterfaceAutogen.cpp", + "$_src/gpu/gl/GrGLOpsRenderPass.cpp", + "$_src/gpu/gl/GrGLOpsRenderPass.h", + "$_src/gpu/gl/GrGLProgram.cpp", + "$_src/gpu/gl/GrGLProgram.h", + "$_src/gpu/gl/GrGLProgramDataManager.cpp", + "$_src/gpu/gl/GrGLProgramDataManager.h", + "$_src/gpu/gl/GrGLRenderTarget.cpp", + "$_src/gpu/gl/GrGLRenderTarget.h", + "$_src/gpu/gl/GrGLSemaphore.cpp", + "$_src/gpu/gl/GrGLSemaphore.h", + "$_src/gpu/gl/GrGLStencilAttachment.cpp", + "$_src/gpu/gl/GrGLStencilAttachment.h", + "$_src/gpu/gl/GrGLTexture.cpp", + "$_src/gpu/gl/GrGLTexture.h", + "$_src/gpu/gl/GrGLTextureRenderTarget.cpp", + "$_src/gpu/gl/GrGLTextureRenderTarget.h", + "$_src/gpu/gl/GrGLTypesPriv.cpp", + "$_src/gpu/gl/GrGLUtil.cpp", + "$_src/gpu/gl/GrGLUtil.h", + "$_src/gpu/gl/GrGLUniformHandler.cpp", + "$_src/gpu/gl/GrGLUniformHandler.h", + "$_src/gpu/gl/GrGLVaryingHandler.cpp", + "$_src/gpu/gl/GrGLVaryingHandler.h", + "$_src/gpu/gl/GrGLVertexArray.cpp", + "$_src/gpu/gl/GrGLVertexArray.h", + + # Files for building GLSL shaders + "$_src/gpu/gl/builders/GrGLProgramBuilder.cpp", + "$_src/gpu/gl/builders/GrGLProgramBuilder.h", + "$_src/gpu/gl/builders/GrGLShaderStringBuilder.cpp", + "$_src/gpu/gl/builders/GrGLShaderStringBuilder.h", +] + skia_gpu_sources = [ "$_include/gpu/GrBackendDrawableInfo.h", "$_include/gpu/GrBackendSemaphore.h", @@ -21,13 +81,6 @@ skia_gpu_sources = [ "$_include/gpu/GrTexture.h", "$_include/gpu/GrTypes.h", - "$_include/gpu/gl/GrGLAssembleInterface.h", - "$_include/gpu/gl/GrGLConfig.h", - "$_include/gpu/gl/GrGLExtensions.h", - "$_include/gpu/gl/GrGLFunctions.h", - "$_include/gpu/gl/GrGLInterface.h", - "$_include/gpu/gl/GrGLTypes.h", - # Private includes "$_include/private/GrContext_Base.h", "$_include/private/GrGLTypesPriv.h", @@ -130,10 +183,10 @@ skia_gpu_sources = [ "$_src/gpu/GrOpsTask.h", "$_src/gpu/GrPaint.cpp", "$_src/gpu/GrPaint.h", - "$_src/gpu/GrPathRendererChain.cpp", - "$_src/gpu/GrPathRendererChain.h", "$_src/gpu/GrPathRenderer.cpp", "$_src/gpu/GrPathRenderer.h", + "$_src/gpu/GrPathRendererChain.cpp", + "$_src/gpu/GrPathRendererChain.h", "$_src/gpu/GrPipeline.cpp", "$_src/gpu/GrPipeline.h", "$_src/gpu/GrPrimitiveProcessor.cpp", @@ -449,58 +502,6 @@ skia_gpu_sources = [ "$_src/gpu/text/GrTextBlobVertexRegenerator.cpp", "$_src/gpu/text/GrTextTarget.h", - "$_src/gpu/gl/GrGLAssembleGLESInterfaceAutogen.cpp", - "$_src/gpu/gl/GrGLAssembleGLInterfaceAutogen.cpp", - "$_src/gpu/gl/GrGLAssembleHelpers.cpp", - "$_src/gpu/gl/GrGLAssembleInterface.cpp", - "$_src/gpu/gl/GrGLAssembleWebGLInterfaceAutogen.cpp", - "$_src/gpu/gl/GrGLBuffer.cpp", - "$_src/gpu/gl/GrGLBuffer.h", - "$_src/gpu/gl/GrGLCaps.cpp", - "$_src/gpu/gl/GrGLCaps.h", - "$_src/gpu/gl/GrGLContext.cpp", - "$_src/gpu/gl/GrGLContext.h", - "$_src/gpu/gl/GrGLMakeNativeInterface_none.cpp", - "$_src/gpu/gl/GrGLDefines.h", - "$_src/gpu/gl/GrGLGLSL.cpp", - "$_src/gpu/gl/GrGLGLSL.h", - "$_src/gpu/gl/GrGLGpu.cpp", - "$_src/gpu/gl/GrGLGpu.h", - "$_src/gpu/gl/GrGLGpuProgramCache.cpp", - "$_src/gpu/gl/GrGLExtensions.cpp", - "$_src/gpu/gl/GrGLInterfaceAutogen.cpp", - "$_src/gpu/gl/GrGLOpsRenderPass.cpp", - "$_src/gpu/gl/GrGLOpsRenderPass.h", - "$_src/gpu/gl/GrGLProgram.cpp", - "$_src/gpu/gl/GrGLProgram.h", - "$_src/gpu/gl/GrGLProgramDataManager.cpp", - "$_src/gpu/gl/GrGLProgramDataManager.h", - "$_src/gpu/gl/GrGLRenderTarget.cpp", - "$_src/gpu/gl/GrGLRenderTarget.h", - "$_src/gpu/gl/GrGLSemaphore.cpp", - "$_src/gpu/gl/GrGLSemaphore.h", - "$_src/gpu/gl/GrGLStencilAttachment.cpp", - "$_src/gpu/gl/GrGLStencilAttachment.h", - "$_src/gpu/gl/GrGLTexture.cpp", - "$_src/gpu/gl/GrGLTexture.h", - "$_src/gpu/gl/GrGLTextureRenderTarget.cpp", - "$_src/gpu/gl/GrGLTextureRenderTarget.h", - "$_src/gpu/gl/GrGLTypesPriv.cpp", - "$_src/gpu/gl/GrGLUtil.cpp", - "$_src/gpu/gl/GrGLUtil.h", - "$_src/gpu/gl/GrGLUniformHandler.cpp", - "$_src/gpu/gl/GrGLUniformHandler.h", - "$_src/gpu/gl/GrGLVaryingHandler.cpp", - "$_src/gpu/gl/GrGLVaryingHandler.h", - "$_src/gpu/gl/GrGLVertexArray.cpp", - "$_src/gpu/gl/GrGLVertexArray.h", - - # Files for building GLSL shaders - "$_src/gpu/gl/builders/GrGLProgramBuilder.cpp", - "$_src/gpu/gl/builders/GrGLProgramBuilder.h", - "$_src/gpu/gl/builders/GrGLShaderStringBuilder.cpp", - "$_src/gpu/gl/builders/GrGLShaderStringBuilder.h", - # GLSL "$_src/gpu/glsl/GrGLSL.cpp", "$_src/gpu/glsl/GrGLSL.h", @@ -607,16 +608,16 @@ skia_ccpr_sources = [ ] skia_nvpr_sources = [ + "$_src/gpu/gl/GrGLPath.cpp", + "$_src/gpu/gl/GrGLPath.h", + "$_src/gpu/gl/GrGLPathRendering.cpp", + "$_src/gpu/gl/GrGLPathRendering.h", "$_src/gpu/GrPath.cpp", "$_src/gpu/GrPath.h", "$_src/gpu/GrPathProcessor.cpp", "$_src/gpu/GrPathProcessor.h", "$_src/gpu/GrPathRendering.cpp", "$_src/gpu/GrPathRendering.h", - "$_src/gpu/gl/GrGLPath.cpp", - "$_src/gpu/gl/GrGLPath.h", - "$_src/gpu/gl/GrGLPathRendering.cpp", - "$_src/gpu/gl/GrGLPathRendering.h", "$_src/gpu/ops/GrDrawPathOp.cpp", "$_src/gpu/ops/GrDrawPathOp.h", "$_src/gpu/ops/GrStencilAndCoverPathRenderer.cpp", @@ -625,10 +626,16 @@ skia_nvpr_sources = [ "$_src/gpu/ops/GrStencilPathOp.h", ] +if (!is_fuchsia) { + skia_gpu_sources += skia_gl_sources +} + skia_gpu_sources += skia_ccpr_sources skia_gpu_sources += skia_nvpr_sources -skia_null_gpu_sources = [] +skia_null_gpu_sources = [ + "$_src/gpu/gl/GrGLMakeNativeInterface_none.cpp", +] skia_vk_sources = [ "$_include/gpu/vk/GrVkBackendContext.h", diff --git a/gn/skia.gni b/gn/skia.gni index 398d61f65b..176d5450c0 100644 --- a/gn/skia.gni +++ b/gn/skia.gni @@ -48,6 +48,7 @@ declare_args() { skia_use_fonthost_mac = is_mac skia_use_freetype = is_android || is_fuchsia || is_linux skia_use_harfbuzz = true + skia_use_gl = !is_fuchsia skia_use_icu = !is_fuchsia && !is_ios skia_use_libheif = is_skia_dev_build skia_use_libjpeg_turbo = true diff --git a/gn/tests.gni b/gn/tests.gni index 608e8c969d..c29c1ac11d 100644 --- a/gn/tests.gni +++ b/gn/tests.gni @@ -99,7 +99,6 @@ tests_sources = [ "$_tests/GrContextAbandonTest.cpp", "$_tests/GrContextFactoryTest.cpp", "$_tests/GrFinishedFlushTest.cpp", - "$_tests/GrGLExtensionsTest.cpp", "$_tests/GrMemoryPoolTest.cpp", "$_tests/GrMeshTest.cpp", "$_tests/GrMipMappedTest.cpp", @@ -286,7 +285,6 @@ tests_sources = [ "$_tests/TestUtils.h", "$_tests/TextBlobCacheTest.cpp", "$_tests/TextBlobTest.cpp", - "$_tests/TextureBindingsResetTest.cpp", "$_tests/TextureProxyTest.cpp", "$_tests/TextureStripAtlasManagerTest.cpp", "$_tests/Time.cpp", diff --git a/src/gpu/GrBackendSurface.cpp b/src/gpu/GrBackendSurface.cpp index e10b79e8d6..1b1d1f27a1 100644 --- a/src/gpu/GrBackendSurface.cpp +++ b/src/gpu/GrBackendSurface.cpp @@ -62,6 +62,7 @@ GrBackendFormat::GrBackendFormat(const GrBackendFormat& that) } } +#ifdef SK_GL GrBackendFormat::GrBackendFormat(GrGLenum format, GrGLenum target) : fBackend(GrBackendApi::kOpenGL) , fValid(true) @@ -90,6 +91,7 @@ GrGLFormat GrBackendFormat::asGLFormat() const { } return GrGLFormat::kUnknown; } +#endif GrBackendFormat GrBackendFormat::MakeVk(const GrVkYcbcrConversionInfo& ycbcrInfo) { SkASSERT(ycbcrInfo.isValid()); @@ -202,24 +204,27 @@ bool GrBackendFormat::operator==(const GrBackendFormat& that) const { } switch (fBackend) { +#ifdef SK_GL case GrBackendApi::kOpenGL: return fGLFormat == that.fGLFormat; - case GrBackendApi::kVulkan: + break; +#endif #ifdef SK_VULKAN + case GrBackendApi::kVulkan: return fVk.fFormat == that.fVk.fFormat && fVk.fYcbcrConversionInfo == that.fVk.fYcbcrConversionInfo; -#endif break; +#endif #ifdef SK_METAL case GrBackendApi::kMetal: return fMtlFormat == that.fMtlFormat; -#endif break; - case GrBackendApi::kDawn: +#endif #ifdef SK_DAWN + case GrBackendApi::kDawn: return fDawnFormat == that.fDawnFormat; -#endif break; +#endif case GrBackendApi::kMock: return fMockColorType == that.fMockColorType; default: @@ -347,6 +352,7 @@ GrBackendTexture::GrBackendTexture(int width, , fMtlInfo(mtlInfo) {} #endif +#ifdef SK_GL GrBackendTexture::GrBackendTexture(int width, int height, GrMipMapped mipMapped, @@ -355,6 +361,7 @@ GrBackendTexture::GrBackendTexture(int width, // Make no assumptions about client's texture's parameters. this->glTextureParametersModified(); } +#endif GrBackendTexture::GrBackendTexture(int width, int height, @@ -691,6 +698,7 @@ GrBackendRenderTarget::GrBackendRenderTarget(int width, , fMtlInfo(mtlInfo) {} #endif +#ifdef SK_GL GrBackendRenderTarget::GrBackendRenderTarget(int width, int height, int sampleCnt, @@ -704,6 +712,7 @@ GrBackendRenderTarget::GrBackendRenderTarget(int width, , fGLInfo(glInfo) { fIsValid = SkToBool(glInfo.fFormat); // the glInfo must have a valid format } +#endif GrBackendRenderTarget::GrBackendRenderTarget(int width, int height, @@ -749,14 +758,16 @@ GrBackendRenderTarget& GrBackendRenderTarget::operator=(const GrBackendRenderTar fBackend = that.fBackend; switch (that.fBackend) { +#ifdef SK_GL case GrBackendApi::kOpenGL: fGLInfo = that.fGLInfo; break; - case GrBackendApi::kVulkan: -#ifdef SK_VULKAN - fVkInfo.assign(that.fVkInfo, this->isValid()); #endif +#ifdef SK_VULKAN + case GrBackendApi::kVulkan: + fVkInfo.assign(that.fVkInfo, this->isValid()); break; +#endif #ifdef SK_DAWN case GrBackendApi::kDawn: fDawnInfo = that.fDawnInfo; @@ -824,6 +835,7 @@ bool GrBackendRenderTarget::getMtlTextureInfo(GrMtlTextureInfo* outInfo) const { } #endif +#ifdef SK_GL bool GrBackendRenderTarget::getGLFramebufferInfo(GrGLFramebufferInfo* outInfo) const { if (this->isValid() && GrBackendApi::kOpenGL == fBackend) { *outInfo = fGLInfo; @@ -831,6 +843,7 @@ bool GrBackendRenderTarget::getGLFramebufferInfo(GrGLFramebufferInfo* outInfo) c } return false; } +#endif GrBackendFormat GrBackendRenderTarget::getBackendFormat() const { if (!this->isValid()) { diff --git a/src/gpu/GrLegacyDirectContext.cpp b/src/gpu/GrLegacyDirectContext.cpp index afba0b9cdc..13530014da 100644 --- a/src/gpu/GrLegacyDirectContext.cpp +++ b/src/gpu/GrLegacyDirectContext.cpp @@ -122,6 +122,7 @@ private: typedef GrContext INHERITED; }; +#ifdef SK_GL sk_sp GrContext::MakeGL(sk_sp interface) { GrContextOptions defaultOptions; return MakeGL(std::move(interface), defaultOptions); @@ -150,6 +151,7 @@ sk_sp GrContext::MakeGL(sk_sp interface, } return context; } +#endif sk_sp GrContext::MakeMock(const GrMockOptions* mockOptions) { GrContextOptions defaultOptions; @@ -222,12 +224,12 @@ sk_sp GrContext::MakeMetal(void* device, void* queue, const GrContext #endif #ifdef SK_DAWN -sk_sp GrContext::MakeDawn(const wgpu::Device& device) { +sk_sp GrContext::MakeDawn(const dawn::Device& device) { GrContextOptions defaultOptions; return MakeDawn(device, defaultOptions); } -sk_sp GrContext::MakeDawn(const wgpu::Device& device, const GrContextOptions& options) { +sk_sp GrContext::MakeDawn(const dawn::Device& device, const GrContextOptions& options) { sk_sp context(new GrLegacyDirectContext(GrBackendApi::kDawn, options)); context->fGpu = GrDawnGpu::Make(device, options, context.get()); diff --git a/tests/DeferredDisplayListTest.cpp b/tests/DeferredDisplayListTest.cpp index e816ba67aa..dd96958f31 100644 --- a/tests/DeferredDisplayListTest.cpp +++ b/tests/DeferredDisplayListTest.cpp @@ -880,8 +880,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DDLSkSurfaceFlush, reporter, ctxInfo) { GrBackendTexture backendTexture; - if (!CreateBackendTexture(context, &backendTexture, ii, SkColors::kCyan, GrMipMapped::kNo, - GrRenderable::kNo)) { + if (!CreateBackendTexture(context, &backendTexture, ii, SkColors::kCyan, + GrMipMapped::kNo, GrRenderable::kNo)) { REPORTER_ASSERT(reporter, false); return; } @@ -998,6 +998,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DDLMultipleDDLs, reporter, ctxInfo) { } } +#ifdef SK_GL //////////////////////////////////////////////////////////////////////////////// // Check that the texture-specific flags (i.e., for external & rectangle textures) work // for promise images. As such, this is a GL-only test. @@ -1043,6 +1044,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(DDLTextureFlagsTest, reporter, ctxInfo) { } } } +#endif // SK_GL //////////////////////////////////////////////////////////////////////////////// // Test colorType and pixelConfig compatibility. diff --git a/tests/EGLImageTest.cpp b/tests/EGLImageTest.cpp index 7f4c6f87d0..80497c0840 100644 --- a/tests/EGLImageTest.cpp +++ b/tests/EGLImageTest.cpp @@ -21,6 +21,8 @@ #include "tools/gpu/GrContextFactory.h" #include "tools/gpu/gl/GLTestContext.h" +#ifdef SK_GL + using sk_gpu_test::GLTestContext; static void cleanup(GLTestContext* glctx0, GrGLuint texID0, GLTestContext* glctx1, @@ -197,3 +199,5 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(EGLImageTest, reporter, ctxInfo) { cleanup(glCtx0, externalTexture.fID, glCtx1.get(), context1, &backendTexture1, image); } + +#endif // SK_GL diff --git a/tests/GrGLExtensionsTest.cpp b/tests/GrGLExtensionsTest.cpp index 480e624a25..4c95706202 100644 --- a/tests/GrGLExtensionsTest.cpp +++ b/tests/GrGLExtensionsTest.cpp @@ -11,6 +11,8 @@ #include "src/gpu/gl/GrGLDefines.h" #include "tests/Test.h" +#ifdef SK_GL + const GrGLubyte* simpleGetString(GrGLenum name) { return (const GrGLubyte*)(name == GR_GL_VERSION ? "3.0" : ""); } @@ -46,3 +48,5 @@ DEF_TEST(GrGLExtensionsTest_remove, reporter) { REPORTER_ASSERT(reporter, ext.remove("test_extension_1")); REPORTER_ASSERT(reporter, !ext.has("test_extension_1")); } + +#endif // SK_GL diff --git a/tests/ProxyTest.cpp b/tests/ProxyTest.cpp index 28eb8d68fe..5a83ccd05d 100644 --- a/tests/ProxyTest.cpp +++ b/tests/ProxyTest.cpp @@ -20,8 +20,10 @@ #include "src/gpu/GrSurfaceProxyPriv.h" #include "src/gpu/GrTextureProxy.h" #include "src/gpu/SkGr.h" +#ifdef SK_GL #include "src/gpu/gl/GrGLDefines.h" #include "src/gpu/gl/GrGLUtil.h" +#endif // Check that the surface proxy's member vars are set as expected static void check_surface(skiatest::Reporter* reporter, @@ -258,6 +260,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) { continue; } +#ifdef SK_GL // Test wrapping FBO 0 (with made up properties). This tests sample count and the // special case where FBO 0 doesn't support window rectangles. if (GrBackendApi::kOpenGL == ctxInfo.backend()) { @@ -278,6 +281,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) { sProxy->asRenderTargetProxy(), supportedNumSamples, SkBackingFit::kExact, 0); } +#endif // Tests wrapBackendRenderTarget with a GrBackendTexture { diff --git a/tests/RectangleTextureTest.cpp b/tests/RectangleTextureTest.cpp index f1f9102fdc..886cff37e8 100644 --- a/tests/RectangleTextureTest.cpp +++ b/tests/RectangleTextureTest.cpp @@ -17,10 +17,14 @@ #include "src/gpu/GrSurfacePriv.h" #include "src/gpu/GrTexturePriv.h" #include "src/gpu/SkGr.h" +#ifdef SK_GL #include "src/gpu/gl/GrGLGpu.h" #include "src/gpu/gl/GrGLUtil.h" +#endif #include "tools/gpu/ProxyUtils.h" +#ifdef SK_GL #include "tools/gpu/gl/GLTestContext.h" +#endif // skbug.com/5932 static void test_basic_draw_as_src(skiatest::Reporter* reporter, GrContext* context, @@ -117,6 +121,7 @@ static void test_copy_to_surface(skiatest::Reporter* reporter, } } +#ifdef SK_GL DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(RectangleTexture, reporter, ctxInfo) { GrContext* context = ctxInfo.grContext(); GrProxyProvider* proxyProvider = context->priv().proxyProvider(); @@ -201,3 +206,4 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(RectangleTexture, reporter, ctxInfo) { GR_GL_CALL(glContext->gl(), DeleteTextures(1, &rectTexID)); } } +#endif diff --git a/tests/SurfaceSemaphoreTest.cpp b/tests/SurfaceSemaphoreTest.cpp index 6d6a1fe564..5e7fc05b87 100644 --- a/tests/SurfaceSemaphoreTest.cpp +++ b/tests/SurfaceSemaphoreTest.cpp @@ -16,8 +16,10 @@ #include "include/gpu/GrBackendSemaphore.h" #include "include/gpu/GrBackendSurface.h" +#ifdef SK_GL #include "src/gpu/gl/GrGLGpu.h" #include "src/gpu/gl/GrGLUtil.h" +#endif #ifdef SK_VULKAN #include "include/gpu/vk/GrVkTypes.h" @@ -182,6 +184,7 @@ void surface_semaphore_test(skiatest::Reporter* reporter, draw_child(reporter, childInfo2, backendTexture, semaphores[1]); } +#ifdef SK_GL DEF_GPUTEST(SurfaceSemaphores, reporter, options) { #if defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_WIN) || defined(SK_BUILD_FOR_MAC) static constexpr auto kNativeGLType = sk_gpu_test::GrContextFactory::kGL_ContextType; @@ -222,6 +225,7 @@ DEF_GPUTEST(SurfaceSemaphores, reporter, options) { } } } +#endif DEF_GPUTEST_FOR_RENDERING_CONTEXTS(EmptySurfaceSemaphoreTest, reporter, ctxInfo) { GrContext* ctx = ctxInfo.grContext(); @@ -243,6 +247,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(EmptySurfaceSemaphoreTest, reporter, ctxInfo) GrSemaphoresSubmitted submitted = mainSurface->flushAndSignalSemaphores(1, &semaphore); REPORTER_ASSERT(reporter, GrSemaphoresSubmitted::kYes == submitted); +#ifdef SK_GL if (GrBackendApi::kOpenGL == ctxInfo.backend()) { GrGLGpu* gpu = static_cast(ctx->priv().getGpu()); const GrGLInterface* interface = gpu->glInterface(); @@ -252,6 +257,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(EmptySurfaceSemaphoreTest, reporter, ctxInfo) GR_GL_CALL_RET(interface, result, IsSync(sync)); REPORTER_ASSERT(reporter, result); } +#endif #ifdef SK_VULKAN if (GrBackendApi::kVulkan == ctxInfo.backend()) { diff --git a/tests/TextureBindingsResetTest.cpp b/tests/TextureBindingsResetTest.cpp index 04602fface..1703a34eae 100644 --- a/tests/TextureBindingsResetTest.cpp +++ b/tests/TextureBindingsResetTest.cpp @@ -12,6 +12,8 @@ #include "src/gpu/gl/GrGLUtil.h" #include "tests/Test.h" +#ifdef SK_GL + DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(TextureBindingsResetTest, reporter, ctxInfo) { #define GL(F) GR_GL_CALL(ctxInfo.glContext()->gl(), F) @@ -164,3 +166,5 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(TextureBindingsResetTest, reporter, ctxInf #undef GL } + +#endif // SK_GL diff --git a/tests/TraceMemoryDumpTest.cpp b/tests/TraceMemoryDumpTest.cpp index 16096a2098..42e2c47f17 100644 --- a/tests/TraceMemoryDumpTest.cpp +++ b/tests/TraceMemoryDumpTest.cpp @@ -12,9 +12,11 @@ #include "include/gpu/GrTexture.h" #include "src/gpu/GrContextPriv.h" #include "src/gpu/GrRenderTarget.h" +#ifdef SK_GL #include "src/gpu/gl/GrGLBuffer.h" #include "src/gpu/gl/GrGLDefines.h" #include "src/gpu/gl/GrGLGpu.h" +#endif /* * Build test for SkTraceMemoryDump. @@ -71,6 +73,7 @@ void ValidateMemoryDumps(skiatest::Reporter* reporter, GrContext* context, size_ } } +#ifdef SK_GL DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SkTraceMemoryDump_ownedGLBuffer, reporter, ctxInfo) { GrContext* context = ctxInfo.grContext(); GrGLGpu* gpu = static_cast(context->priv().getGpu()); @@ -157,3 +160,4 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SkTraceMemoryDump_unownedGLRenderTarget, r ValidateMemoryDumps(reporter, context, rt->gpuMemorySize(), false /* isOwned */); } +#endif // SK_GL diff --git a/tests/VkHardwareBufferTest.cpp b/tests/VkHardwareBufferTest.cpp index 07563cb063..cfe453b95d 100644 --- a/tests/VkHardwareBufferTest.cpp +++ b/tests/VkHardwareBufferTest.cpp @@ -70,6 +70,7 @@ protected: int fFdHandle = 0; }; +#ifdef SK_GL class EGLTestHelper : public BaseTestHelper { public: EGLTestHelper(const GrContextOptions& options) : fFactory(options) {} @@ -362,6 +363,7 @@ void EGLTestHelper::doClientSync() { fenceSync->waitFence(fence); fenceSync->deleteFence(fence); } +#endif // SK_GL #define DECLARE_VK_PROC(name) PFN_vk##name fVk##name @@ -1078,7 +1080,11 @@ void run_test(skiatest::Reporter* reporter, const GrContextOptions& options, if (SrcType::kVulkan == srcType) { srcHelper.reset(new VulkanTestHelper()); } else if (SrcType::kEGL == srcType) { +#ifdef SK_GL srcHelper.reset(new EGLTestHelper(options)); +#else + SkASSERT(false, "SrcType::kEGL used without OpenGL support."); +#endif } if (srcHelper) { if (!srcHelper->init(reporter)) { @@ -1090,8 +1096,12 @@ void run_test(skiatest::Reporter* reporter, const GrContextOptions& options, if (DstType::kVulkan == dstType) { dstHelper.reset(new VulkanTestHelper()); } else { +#ifdef SK_GL SkASSERT(DstType::kEGL == dstType); dstHelper.reset(new EGLTestHelper(options)); +#else + SkASSERT(false, "DstType::kEGL used without OpenGL support."); +#endif } if (dstHelper) { if (!dstHelper->init(reporter)) { @@ -1275,14 +1285,19 @@ DEF_GPUTEST(VulkanHardwareBuffer_CPU_Vulkan, reporter, options) { run_test(reporter, options, SrcType::kCPU, DstType::kVulkan, false); } -DEF_GPUTEST(VulkanHardwareBuffer_EGL_Vulkan, reporter, options) { - run_test(reporter, options, SrcType::kEGL, DstType::kVulkan, false); -} - DEF_GPUTEST(VulkanHardwareBuffer_Vulkan_Vulkan, reporter, options) { run_test(reporter, options, SrcType::kVulkan, DstType::kVulkan, false); } +DEF_GPUTEST(VulkanHardwareBuffer_Vulkan_Vulkan_Syncs, reporter, options) { + run_test(reporter, options, SrcType::kVulkan, DstType::kVulkan, true); +} + +#if defined(SK_GL) +DEF_GPUTEST(VulkanHardwareBuffer_EGL_Vulkan, reporter, options) { + run_test(reporter, options, SrcType::kEGL, DstType::kVulkan, false); +} + DEF_GPUTEST(VulkanHardwareBuffer_CPU_EGL, reporter, options) { run_test(reporter, options, SrcType::kCPU, DstType::kEGL, false); } @@ -1306,10 +1321,8 @@ DEF_GPUTEST(VulkanHardwareBuffer_Vulkan_EGL_Syncs, reporter, options) { DEF_GPUTEST(VulkanHardwareBuffer_EGL_Vulkan_Syncs, reporter, options) { run_test(reporter, options, SrcType::kEGL, DstType::kVulkan, true); } - -DEF_GPUTEST(VulkanHardwareBuffer_Vulkan_Vulkan_Syncs, reporter, options) { - run_test(reporter, options, SrcType::kVulkan, DstType::kVulkan, true); -} - #endif +#endif // SK_SUPPORT_GPU && defined(SK_BUILD_FOR_ANDROID) && + // __ANDROID_API__ >= 26 && defined(SK_VULKAN) + diff --git a/tools/gpu/GrContextFactory.cpp b/tools/gpu/GrContextFactory.cpp index d0defdc6e9..be33802f17 100644 --- a/tools/gpu/GrContextFactory.cpp +++ b/tools/gpu/GrContextFactory.cpp @@ -8,7 +8,9 @@ #include "src/gpu/GrContextPriv.h" #include "tools/gpu/GrContextFactory.h" +#ifdef SK_GL #include "tools/gpu/gl/GLTestContext.h" +#endif #if SK_ANGLE #include "tools/gpu/gl/angle/GLTestContext_angle.h" @@ -152,6 +154,7 @@ ContextInfo GrContextFactory::getContextInfoInternal(ContextType type, ContextOv std::unique_ptr testCtx; GrBackendApi backend = ContextTypeBackend(type); switch (backend) { +#ifdef SK_GL case GrBackendApi::kOpenGL: { GLTestContext* glShareContext = masterContext ? static_cast(masterContext->fTestContext) : nullptr; @@ -199,6 +202,7 @@ ContextInfo GrContextFactory::getContextInfoInternal(ContextType type, ContextOv testCtx.reset(glCtx); break; } +#endif // SK_GL #ifdef SK_VULKAN case GrBackendApi::kVulkan: { VkTestContext* vkSharedContext = masterContext @@ -209,6 +213,7 @@ ContextInfo GrContextFactory::getContextInfoInternal(ContextType type, ContextOv return ContextInfo(); } +#ifdef SK_GL // There is some bug (either in Skia or the NV Vulkan driver) where VkDevice // destruction will hang occaisonally. For some reason having an existing GL // context fixes this. @@ -218,6 +223,7 @@ ContextInfo GrContextFactory::getContextInfoInternal(ContextType type, ContextOv fSentinelGLContext.reset(CreatePlatformGLTestContext(kGLES_GrGLStandard)); } } +#endif break; } #endif diff --git a/tools/skqp/src/skqp.cpp b/tools/skqp/src/skqp.cpp index 04f0369be6..ac08a5eee6 100644 --- a/tools/skqp/src/skqp.cpp +++ b/tools/skqp/src/skqp.cpp @@ -22,8 +22,12 @@ #include "src/utils/SkOSPath.h" #include "tests/Test.h" #include "tools/fonts/TestFontMgr.h" +#ifdef SK_GL #include "tools/gpu/gl/GLTestContext.h" +#endif +#ifdef SK_VULKAN #include "tools/gpu/vk/VkTestContext.h" +#endif #include #include