aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/gpu
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2016-09-29 10:07:22 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-09-29 10:07:22 -0700
commit7c2213ba61c61ab76117019f95705639e2f01de8 (patch)
tree7d43758e0c433f03b7c1915f873bdcb5a5b63302 /tools/gpu
parent50094fb489543655df026be4e4f99e09e57a1f49 (diff)
Revert of Explicit control in tools of ANGLE frontend and backend (patchset #6 id:90001 of https://codereview.chromium.org/2381033002/ )
Reason for revert: Broke bots Original issue's description: > Explicit control in tools of ANGLE frontend and backend > > Update the ANGLE test GL context, GrContextFactory, and config parsing to allow explicit control of ANGLE front/backend. > > This will allow us to explicitly test ES2 vs ES3 interfaces to ANGLE as well as D3D9, D3D11, and OpenGL backends. > > Also makes the angle api types valid in all builds (but will just fail when SK_ANGLE=1 or not on windows for the d3d backends). > > BUG=skia:5804 > GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2381033002 > > Committed: https://skia.googlesource.com/skia/+/50094fb489543655df026be4e4f99e09e57a1f49 TBR=brianosman@google.com # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia:5804 Review-Url: https://codereview.chromium.org/2384483003
Diffstat (limited to 'tools/gpu')
-rw-r--r--tools/gpu/GrContextFactory.cpp23
-rw-r--r--tools/gpu/GrContextFactory.h44
-rw-r--r--tools/gpu/gl/angle/GLTestContext_angle.cpp93
-rw-r--r--tools/gpu/gl/angle/GLTestContext_angle.h22
4 files changed, 104 insertions, 78 deletions
diff --git a/tools/gpu/GrContextFactory.cpp b/tools/gpu/GrContextFactory.cpp
index 4f189942bd..5e6494f778 100644
--- a/tools/gpu/GrContextFactory.cpp
+++ b/tools/gpu/GrContextFactory.cpp
@@ -117,24 +117,13 @@ ContextInfo GrContextFactory::getContextInfo(ContextType type, ContextOptions op
glCtx = CreatePlatformGLTestContext(kGLES_GrGLStandard);
break;
#if SK_ANGLE
- case kANGLE_D3D9_ES2_ContextType:
- glCtx = CreateANGLETestContext(ANGLEBackend::kD3D9, ANGLEContextVersion::kES2);
+# ifdef SK_BUILD_FOR_WIN
+ case kANGLE_ContextType:
+ glCtx = CreateANGLEDirect3DGLTestContext();
break;
- 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);
+# endif
+ case kANGLE_GL_ContextType:
+ glCtx = CreateANGLEOpenGLGLTestContext();
break;
#endif
case kCommandBuffer_ContextType:
diff --git a/tools/gpu/GrContextFactory.h b/tools/gpu/GrContextFactory.h
index d6baffc0ea..a822ac7868 100644
--- a/tools/gpu/GrContextFactory.h
+++ b/tools/gpu/GrContextFactory.h
@@ -68,18 +68,15 @@ 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_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
+ 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
kLastContextType = kVulkan_ContextType
};
@@ -130,6 +127,29 @@ 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 186e70e054..8cc6f99c9f 100644
--- a/tools/gpu/gl/angle/GLTestContext_angle.cpp
+++ b/tools/gpu/gl/angle/GLTestContext_angle.cpp
@@ -26,9 +26,6 @@
#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;
@@ -48,7 +45,7 @@ static GrGLFuncPtr angle_get_gl_proc(void* ctx, const char name[]) {
return eglGetProcAddress(name);
}
-void* get_angle_egl_display(void* nativeDisplay, ANGLEBackend type) {
+void* get_angle_egl_display(void* nativeDisplay, bool useGLBackend) {
PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXT;
eglGetPlatformDisplayEXT =
(PFNEGLGETPLATFORMDISPLAYEXTPROC)eglGetProcAddress("eglGetPlatformDisplayEXT");
@@ -58,25 +55,38 @@ void* get_angle_egl_display(void* nativeDisplay, ANGLEBackend type) {
return EGL_NO_DISPLAY;
}
- 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;
+ 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]);
+ }
}
- const EGLint attribs[] = { EGL_PLATFORM_ANGLE_TYPE_ANGLE, typeNum, EGL_NONE };
- return eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, nativeDisplay, attribs);
+ return display;
}
class ANGLEGLContext : public sk_gpu_test::GLTestContext {
public:
- ANGLEGLContext(ANGLEBackend, ANGLEContextVersion);
+ ANGLEGLContext(bool preferGLBackend);
~ANGLEGLContext() override;
GrEGLImage texture2DToEGLImage(GrGLuint texID) const override;
@@ -91,19 +101,16 @@ private:
void onPlatformSwapBuffers() const override;
GrGLFuncPtr onPlatformGetProcAddress(const char* name) const override;
- void* fContext;
- void* fDisplay;
- void* fSurface;
- ANGLEBackend fType;
- ANGLEContextVersion fVersion;
+ void* fContext;
+ void* fDisplay;
+ void* fSurface;
+ bool fIsGLBackend;
};
-ANGLEGLContext::ANGLEGLContext(ANGLEBackend type, ANGLEContextVersion version)
+ANGLEGLContext::ANGLEGLContext(bool useGLBackend)
: fContext(EGL_NO_CONTEXT)
, fDisplay(EGL_NO_DISPLAY)
- , fSurface(EGL_NO_SURFACE)
- , fType(type)
- , fVersion(version) {
+ , fSurface(EGL_NO_SURFACE) {
EGLint numConfigs;
static const EGLint configAttribs[] = {
@@ -116,7 +123,8 @@ ANGLEGLContext::ANGLEGLContext(ANGLEBackend type, ANGLEContextVersion version)
EGL_NONE
};
- fDisplay = get_angle_egl_display(EGL_DEFAULT_DISPLAY, type);
+ fIsGLBackend = useGLBackend;
+ fDisplay = get_angle_egl_display(EGL_DEFAULT_DISPLAY, useGLBackend);
if (EGL_NO_DISPLAY == fDisplay) {
SkDebugf("Could not create EGL display!");
return;
@@ -129,9 +137,8 @@ ANGLEGLContext::ANGLEGLContext(ANGLEBackend type, ANGLEContextVersion version)
EGLConfig surfaceConfig;
eglChooseConfig(fDisplay, configAttribs, &surfaceConfig, 1, &numConfigs);
- int versionNum = ANGLEContextVersion::kES2 == version ? 2 : 3;
- const EGLint contextAttribs[] = {
- EGL_CONTEXT_CLIENT_VERSION, versionNum,
+ static const EGLint contextAttribs[] = {
+ EGL_CONTEXT_CLIENT_VERSION, 2,
EGL_NONE
};
fContext = eglCreateContext(fDisplay, surfaceConfig, nullptr, contextAttribs);
@@ -217,7 +224,13 @@ GrGLuint ANGLEGLContext::eglImageToExternalTexture(GrEGLImage image) const {
}
sk_gpu_test::GLTestContext* ANGLEGLContext::createNew() const {
- sk_gpu_test::GLTestContext* ctx = sk_gpu_test::CreateANGLETestContext(fType, fVersion);
+#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
if (ctx) {
ctx->makeCurrent();
}
@@ -286,9 +299,19 @@ const GrGLInterface* CreateANGLEGLInterface() {
return GrGLAssembleGLESInterface(&gLibs, angle_get_gl_proc);
}
-GLTestContext* CreateANGLETestContext(ANGLEBackend type,
- ANGLEContextVersion version) {
- ANGLEGLContext* ctx = new ANGLEGLContext(type, version);
+#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);
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 0da747f30f..0140477a54 100644
--- a/tools/gpu/gl/angle/GLTestContext_angle.h
+++ b/tools/gpu/gl/angle/GLTestContext_angle.h
@@ -13,24 +13,18 @@
namespace sk_gpu_test {
/**
- * Creates a GrGLInterface for the current ANGLE GLES Context. Here current means bound in ANGLE's
- * implementation of EGL.
+ * Creates a GrGLInterface for the currently ANGLE GL context currently bound in ANGLE's EGL
+ * implementation.
*/
const GrGLInterface* CreateANGLEGLInterface();
-enum class ANGLEBackend {
- kD3D9,
- kD3D11,
- kOpenGL
-};
-
-enum class ANGLEContextVersion {
- kES2,
- kES3
-};
+#ifdef SK_BUILD_FOR_WIN
+/** Creates a GLTestContext backed by ANGLE's Direct3D backend. */
+GLTestContext* CreateANGLEDirect3DGLTestContext();
+#endif
-/** Creates a GLTestContext backed by ANGLE. */
-GLTestContext* CreateANGLETestContext(ANGLEBackend, ANGLEContextVersion);
+/** Creates a GLTestContext backed by ANGLE's OpenGL backend. */
+GLTestContext* CreateANGLEOpenGLGLTestContext();
} // namespace sk_gpu_test
#endif