diff options
Diffstat (limited to 'tools/gpu')
-rw-r--r-- | tools/gpu/GrContextFactory.cpp | 23 | ||||
-rw-r--r-- | tools/gpu/GrContextFactory.h | 44 | ||||
-rw-r--r-- | tools/gpu/gl/angle/GLTestContext_angle.cpp | 93 | ||||
-rw-r--r-- | tools/gpu/gl/angle/GLTestContext_angle.h | 22 |
4 files changed, 78 insertions, 104 deletions
diff --git a/tools/gpu/GrContextFactory.cpp b/tools/gpu/GrContextFactory.cpp index 5e6494f778..4f189942bd 100644 --- a/tools/gpu/GrContextFactory.cpp +++ b/tools/gpu/GrContextFactory.cpp @@ -117,13 +117,24 @@ ContextInfo GrContextFactory::getContextInfo(ContextType type, ContextOptions op glCtx = CreatePlatformGLTestContext(kGLES_GrGLStandard); break; #if SK_ANGLE -# ifdef SK_BUILD_FOR_WIN - case kANGLE_ContextType: - glCtx = CreateANGLEDirect3DGLTestContext(); + case kANGLE_D3D9_ES2_ContextType: + glCtx = CreateANGLETestContext(ANGLEBackend::kD3D9, ANGLEContextVersion::kES2); break; -# endif - case kANGLE_GL_ContextType: - glCtx = CreateANGLEOpenGLGLTestContext(); + case kANGLE_D3D11_ES2_ContextType: + glCtx = CreateANGLETestContext(ANGLEBackend::kD3D11, + ANGLEContextVersion::kES2); + break; + case kANGLE_D3D11_ES3_ContextType: + glCtx = CreateANGLETestContext(ANGLEBackend::kD3D11, + ANGLEContextVersion::kES3); + break; + case kANGLE_GL_ES2_ContextType: + glCtx = CreateANGLETestContext(ANGLEBackend::kOpenGL, + ANGLEContextVersion::kES2); + break; + case kANGLE_GL_ES3_ContextType: + glCtx = CreateANGLETestContext(ANGLEBackend::kOpenGL, + ANGLEContextVersion::kES3); break; #endif case kCommandBuffer_ContextType: diff --git a/tools/gpu/GrContextFactory.h b/tools/gpu/GrContextFactory.h index a822ac7868..d6baffc0ea 100644 --- a/tools/gpu/GrContextFactory.h +++ b/tools/gpu/GrContextFactory.h @@ -68,15 +68,18 @@ public: // The availability of context types is subject to platform and build configuration // restrictions. enum ContextType { - kGL_ContextType, //! OpenGL context. - kGLES_ContextType, //! OpenGL ES context. - kANGLE_ContextType, //! ANGLE on DirectX OpenGL ES context. - kANGLE_GL_ContextType, //! ANGLE on OpenGL OpenGL ES context. - kCommandBuffer_ContextType, //! Chromium command buffer OpenGL ES context. - kMESA_ContextType, //! MESA OpenGL context - kNullGL_ContextType, //! Non-rendering OpenGL mock context. - kDebugGL_ContextType, //! Non-rendering, state verifying OpenGL context. - kVulkan_ContextType, //! Vulkan + kGL_ContextType, //! OpenGL context. + kGLES_ContextType, //! OpenGL ES context. + kANGLE_D3D9_ES2_ContextType, //! ANGLE on Direct3D9 OpenGL ES 2 context. + kANGLE_D3D11_ES2_ContextType,//! ANGLE on Direct3D11 OpenGL ES 2 context. + kANGLE_D3D11_ES3_ContextType,//! ANGLE on Direct3D11 OpenGL ES 3 context. + kANGLE_GL_ES2_ContextType, //! ANGLE on OpenGL OpenGL ES 2 context. + kANGLE_GL_ES3_ContextType, //! ANGLE on OpenGL OpenGL ES 3 context. + kCommandBuffer_ContextType, //! Chromium command buffer OpenGL ES context. + kMESA_ContextType, //! MESA OpenGL context + kNullGL_ContextType, //! Non-rendering OpenGL mock context. + kDebugGL_ContextType, //! Non-rendering, state verifying OpenGL context. + kVulkan_ContextType, //! Vulkan kLastContextType = kVulkan_ContextType }; @@ -127,29 +130,6 @@ public: } } - static const char* ContextTypeName(ContextType type) { - switch (type) { - case kGL_ContextType: - return "gl"; - case kGLES_ContextType: - return "gles"; - case kANGLE_ContextType: - return "angle"; - case kANGLE_GL_ContextType: - return "angle-gl"; - case kCommandBuffer_ContextType: - return "commandbuffer"; - case kMESA_ContextType: - return "mesa"; - case kNullGL_ContextType: - return "nullgl"; - case kDebugGL_ContextType: - return "debuggl"; - case kVulkan_ContextType: - return "vulkan"; - } - } - explicit GrContextFactory(const GrContextOptions& opts); GrContextFactory(); diff --git a/tools/gpu/gl/angle/GLTestContext_angle.cpp b/tools/gpu/gl/angle/GLTestContext_angle.cpp index 8cc6f99c9f..186e70e054 100644 --- a/tools/gpu/gl/angle/GLTestContext_angle.cpp +++ b/tools/gpu/gl/angle/GLTestContext_angle.cpp @@ -26,6 +26,9 @@ #define EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE 0x3208 #define EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE 0x320D +using sk_gpu_test::ANGLEBackend; +using sk_gpu_test::ANGLEContextVersion; + namespace { struct Libs { void* fGLLib; @@ -45,7 +48,7 @@ static GrGLFuncPtr angle_get_gl_proc(void* ctx, const char name[]) { return eglGetProcAddress(name); } -void* get_angle_egl_display(void* nativeDisplay, bool useGLBackend) { +void* get_angle_egl_display(void* nativeDisplay, ANGLEBackend type) { PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXT; eglGetPlatformDisplayEXT = (PFNEGLGETPLATFORMDISPLAYEXTPROC)eglGetProcAddress("eglGetPlatformDisplayEXT"); @@ -55,38 +58,25 @@ void* get_angle_egl_display(void* nativeDisplay, bool useGLBackend) { return EGL_NO_DISPLAY; } - EGLDisplay display = EGL_NO_DISPLAY; - if (useGLBackend) { - EGLint attribs[3] = { - EGL_PLATFORM_ANGLE_TYPE_ANGLE, - EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE, - EGL_NONE - }; - display = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, nativeDisplay, attribs); - } else { - // Try for an ANGLE D3D11 context, fall back to D3D9. - EGLint attribs[3][3] = { - { - EGL_PLATFORM_ANGLE_TYPE_ANGLE, - EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, - EGL_NONE - }, - { - EGL_PLATFORM_ANGLE_TYPE_ANGLE, - EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE, - EGL_NONE - }, - }; - for (int i = 0; i < 3 && display == EGL_NO_DISPLAY; ++i) { - display = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE,nativeDisplay, attribs[i]); - } + EGLint typeNum; + switch (type) { + case ANGLEBackend::kD3D9: + typeNum = EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE; + break; + case ANGLEBackend::kD3D11: + typeNum = EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE; + break; + case ANGLEBackend::kOpenGL: + typeNum = EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE; + break; } - return display; + const EGLint attribs[] = { EGL_PLATFORM_ANGLE_TYPE_ANGLE, typeNum, EGL_NONE }; + return eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, nativeDisplay, attribs); } class ANGLEGLContext : public sk_gpu_test::GLTestContext { public: - ANGLEGLContext(bool preferGLBackend); + ANGLEGLContext(ANGLEBackend, ANGLEContextVersion); ~ANGLEGLContext() override; GrEGLImage texture2DToEGLImage(GrGLuint texID) const override; @@ -101,16 +91,19 @@ private: void onPlatformSwapBuffers() const override; GrGLFuncPtr onPlatformGetProcAddress(const char* name) const override; - void* fContext; - void* fDisplay; - void* fSurface; - bool fIsGLBackend; + void* fContext; + void* fDisplay; + void* fSurface; + ANGLEBackend fType; + ANGLEContextVersion fVersion; }; -ANGLEGLContext::ANGLEGLContext(bool useGLBackend) +ANGLEGLContext::ANGLEGLContext(ANGLEBackend type, ANGLEContextVersion version) : fContext(EGL_NO_CONTEXT) , fDisplay(EGL_NO_DISPLAY) - , fSurface(EGL_NO_SURFACE) { + , fSurface(EGL_NO_SURFACE) + , fType(type) + , fVersion(version) { EGLint numConfigs; static const EGLint configAttribs[] = { @@ -123,8 +116,7 @@ ANGLEGLContext::ANGLEGLContext(bool useGLBackend) EGL_NONE }; - fIsGLBackend = useGLBackend; - fDisplay = get_angle_egl_display(EGL_DEFAULT_DISPLAY, useGLBackend); + fDisplay = get_angle_egl_display(EGL_DEFAULT_DISPLAY, type); if (EGL_NO_DISPLAY == fDisplay) { SkDebugf("Could not create EGL display!"); return; @@ -137,8 +129,9 @@ ANGLEGLContext::ANGLEGLContext(bool useGLBackend) EGLConfig surfaceConfig; eglChooseConfig(fDisplay, configAttribs, &surfaceConfig, 1, &numConfigs); - static const EGLint contextAttribs[] = { - EGL_CONTEXT_CLIENT_VERSION, 2, + int versionNum = ANGLEContextVersion::kES2 == version ? 2 : 3; + const EGLint contextAttribs[] = { + EGL_CONTEXT_CLIENT_VERSION, versionNum, EGL_NONE }; fContext = eglCreateContext(fDisplay, surfaceConfig, nullptr, contextAttribs); @@ -224,13 +217,7 @@ GrGLuint ANGLEGLContext::eglImageToExternalTexture(GrEGLImage image) const { } sk_gpu_test::GLTestContext* ANGLEGLContext::createNew() const { -#ifdef SK_BUILD_FOR_WIN - sk_gpu_test::GLTestContext* ctx = fIsGLBackend - ? sk_gpu_test::CreateANGLEOpenGLGLTestContext() - : sk_gpu_test::CreateANGLEDirect3DGLTestContext(); -#else - sk_gpu_test::GLTestContext* ctx = sk_gpu_test::CreateANGLEOpenGLGLTestContext(); -#endif + sk_gpu_test::GLTestContext* ctx = sk_gpu_test::CreateANGLETestContext(fType, fVersion); if (ctx) { ctx->makeCurrent(); } @@ -299,19 +286,9 @@ const GrGLInterface* CreateANGLEGLInterface() { return GrGLAssembleGLESInterface(&gLibs, angle_get_gl_proc); } -#ifdef SK_BUILD_FOR_WIN -GLTestContext* CreateANGLEDirect3DGLTestContext() { - ANGLEGLContext* ctx = new ANGLEGLContext(false); - if (!ctx->isValid()) { - delete ctx; - return NULL; - } - return ctx; - } -#endif - -GLTestContext* CreateANGLEOpenGLGLTestContext() { - ANGLEGLContext* ctx = new ANGLEGLContext(true); +GLTestContext* CreateANGLETestContext(ANGLEBackend type, + ANGLEContextVersion version) { + ANGLEGLContext* ctx = new ANGLEGLContext(type, version); if (!ctx->isValid()) { delete ctx; return NULL; diff --git a/tools/gpu/gl/angle/GLTestContext_angle.h b/tools/gpu/gl/angle/GLTestContext_angle.h index 0140477a54..0da747f30f 100644 --- a/tools/gpu/gl/angle/GLTestContext_angle.h +++ b/tools/gpu/gl/angle/GLTestContext_angle.h @@ -13,18 +13,24 @@ namespace sk_gpu_test { /** - * Creates a GrGLInterface for the currently ANGLE GL context currently bound in ANGLE's EGL - * implementation. + * Creates a GrGLInterface for the current ANGLE GLES Context. Here current means bound in ANGLE's + * implementation of EGL. */ const GrGLInterface* CreateANGLEGLInterface(); -#ifdef SK_BUILD_FOR_WIN -/** Creates a GLTestContext backed by ANGLE's Direct3D backend. */ -GLTestContext* CreateANGLEDirect3DGLTestContext(); -#endif +enum class ANGLEBackend { + kD3D9, + kD3D11, + kOpenGL +}; + +enum class ANGLEContextVersion { + kES2, + kES3 +}; -/** Creates a GLTestContext backed by ANGLE's OpenGL backend. */ -GLTestContext* CreateANGLEOpenGLGLTestContext(); +/** Creates a GLTestContext backed by ANGLE. */ +GLTestContext* CreateANGLETestContext(ANGLEBackend, ANGLEContextVersion); } // namespace sk_gpu_test #endif |