skia: Add ANGLE with GL backend to nanobench/DM
This will allow us to test this without hacking it in, might be useful for others too. Review URL: https://codereview.chromium.org/1338003002
This commit is contained in:
parent
102081aba2
commit
eddbefb4a5
@ -443,6 +443,7 @@ static void create_configs(SkTDArray<Config>* configs) {
|
||||
GPU_CONFIG(nullgpu, kNull_GLContextType, 0, false)
|
||||
#ifdef SK_ANGLE
|
||||
GPU_CONFIG(angle, kANGLE_GLContextType, 0, false)
|
||||
GPU_CONFIG(angle-gl, kANGLE_GL_GLContextType, 0, false)
|
||||
#endif
|
||||
#ifdef SK_COMMAND_BUFFER
|
||||
GPU_CONFIG(commandbuffer, kCommandBuffer_GLContextType, 0, false)
|
||||
|
@ -566,6 +566,7 @@ static Sink* create_sink(const char* tag) {
|
||||
SINK("nvprmsaa16", GPUSink, Gr::kNVPR_GLContextType, api, 16, true, FLAGS_gpu_threading);
|
||||
#if SK_ANGLE
|
||||
SINK("angle", GPUSink, Gr::kANGLE_GLContextType, api, 0, false, FLAGS_gpu_threading);
|
||||
SINK("angle-gl", GPUSink, Gr::kANGLE_GL_GLContextType, api, 0, false, FLAGS_gpu_threading);
|
||||
#endif
|
||||
#if SK_COMMAND_BUFFER
|
||||
SINK("commandbuffer", GPUSink, Gr::kCommandBuffer_GLContextType, api, 0, false, FLAGS_gpu_threading);
|
||||
|
@ -65,6 +65,7 @@ public:
|
||||
typedef int GLContextType;
|
||||
|
||||
static const GLContextType kANGLE_GLContextType = 0,
|
||||
kANGLE_GL_GLContextType = 0,
|
||||
kCommandBuffer_GLContextType = 0,
|
||||
kDebug_GLContextType = 0,
|
||||
kMESA_GLContextType = 0,
|
||||
|
@ -16,11 +16,11 @@ class SkANGLEGLContext : public SkGLContext {
|
||||
public:
|
||||
~SkANGLEGLContext() override;
|
||||
|
||||
static SkANGLEGLContext* Create(GrGLStandard forcedGpuAPI) {
|
||||
static SkANGLEGLContext* Create(GrGLStandard forcedGpuAPI, bool useGLBackend) {
|
||||
if (kGL_GrGLStandard == forcedGpuAPI) {
|
||||
return NULL;
|
||||
}
|
||||
SkANGLEGLContext* ctx = new SkANGLEGLContext;
|
||||
SkANGLEGLContext* ctx = new SkANGLEGLContext(useGLBackend);
|
||||
if (!ctx->isValid()) {
|
||||
delete ctx;
|
||||
return NULL;
|
||||
@ -29,10 +29,10 @@ public:
|
||||
}
|
||||
|
||||
// The param is an EGLNativeDisplayType and the return is an EGLDispay.
|
||||
static void* GetD3DEGLDisplay(void* nativeDisplay);
|
||||
static void* GetD3DEGLDisplay(void* nativeDisplay, bool useGLBackend);
|
||||
|
||||
private:
|
||||
SkANGLEGLContext();
|
||||
SkANGLEGLContext(bool preferGLBackend);
|
||||
void destroyGLContext();
|
||||
|
||||
void onPlatformMakeCurrent() const override;
|
||||
|
@ -43,7 +43,10 @@ GrContext* GrContextFactory::get(GLContextType type, GrGLStandard forcedGpuAPI)
|
||||
break;
|
||||
#ifdef SK_ANGLE
|
||||
case kANGLE_GLContextType:
|
||||
glCtx.reset(SkANGLEGLContext::Create(forcedGpuAPI));
|
||||
glCtx.reset(SkANGLEGLContext::Create(forcedGpuAPI, false));
|
||||
break;
|
||||
case kANGLE_GL_GLContextType:
|
||||
glCtx.reset(SkANGLEGLContext::Create(forcedGpuAPI, true));
|
||||
break;
|
||||
#endif
|
||||
#ifdef SK_COMMAND_BUFFER
|
||||
|
@ -33,6 +33,7 @@ public:
|
||||
kNative_GLContextType,
|
||||
#if SK_ANGLE
|
||||
kANGLE_GLContextType,
|
||||
kANGLE_GL_GLContextType,
|
||||
#endif
|
||||
#if SK_COMMAND_BUFFER
|
||||
kCommandBuffer_GLContextType,
|
||||
@ -70,6 +71,8 @@ public:
|
||||
#if SK_ANGLE
|
||||
case kANGLE_GLContextType:
|
||||
return "angle";
|
||||
case kANGLE_GL_GLContextType:
|
||||
return "angle-gl";
|
||||
#endif
|
||||
#if SK_COMMAND_BUFFER
|
||||
case kCommandBuffer_GLContextType:
|
||||
|
@ -15,8 +15,9 @@
|
||||
#define EGL_PLATFORM_ANGLE_TYPE_ANGLE 0x3203
|
||||
#define EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE 0x3207
|
||||
#define EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE 0x3208
|
||||
#define EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE 0x320D
|
||||
|
||||
void* SkANGLEGLContext::GetD3DEGLDisplay(void* nativeDisplay) {
|
||||
void* SkANGLEGLContext::GetD3DEGLDisplay(void* nativeDisplay, bool useGLBackend) {
|
||||
PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXT;
|
||||
eglGetPlatformDisplayEXT =
|
||||
(PFNEGLGETPLATFORMDISPLAYEXTPROC)eglGetProcAddress("eglGetPlatformDisplayEXT");
|
||||
@ -25,29 +26,44 @@ void* SkANGLEGLContext::GetD3DEGLDisplay(void* nativeDisplay) {
|
||||
return eglGetDisplay(static_cast<EGLNativeDisplayType>(nativeDisplay));
|
||||
}
|
||||
|
||||
// Try for an ANGLE D3D11 context, fall back to D3D9.
|
||||
EGLint attribs[2][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
|
||||
}
|
||||
};
|
||||
|
||||
EGLDisplay display = EGL_NO_DISPLAY;
|
||||
for (int i = 0; i < 2 && display == EGL_NO_DISPLAY; ++i) {
|
||||
if (useGLBackend) {
|
||||
// Try for an ANGLE D3D11 context, fall back to D3D9.
|
||||
EGLint attribs[3] = {
|
||||
EGL_PLATFORM_ANGLE_TYPE_ANGLE,
|
||||
EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE,
|
||||
EGL_NONE
|
||||
};
|
||||
display = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE,
|
||||
nativeDisplay, attribs[i]);
|
||||
nativeDisplay, attribs);
|
||||
} else {
|
||||
// Try for an ANGLE D3D11 context, fall back to D3D9, and finally GL.
|
||||
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
|
||||
},
|
||||
{
|
||||
EGL_PLATFORM_ANGLE_TYPE_ANGLE,
|
||||
EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE,
|
||||
EGL_NONE
|
||||
}
|
||||
};
|
||||
for (int i = 0; i < 3 && display == EGL_NO_DISPLAY; ++i) {
|
||||
display = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE,
|
||||
nativeDisplay, attribs[i]);
|
||||
}
|
||||
}
|
||||
return display;
|
||||
}
|
||||
|
||||
SkANGLEGLContext::SkANGLEGLContext()
|
||||
SkANGLEGLContext::SkANGLEGLContext(bool useGLBackend)
|
||||
: fContext(EGL_NO_CONTEXT)
|
||||
, fDisplay(EGL_NO_DISPLAY)
|
||||
, fSurface(EGL_NO_SURFACE) {
|
||||
@ -63,7 +79,7 @@ SkANGLEGLContext::SkANGLEGLContext()
|
||||
EGL_NONE
|
||||
};
|
||||
|
||||
fDisplay = GetD3DEGLDisplay(EGL_DEFAULT_DISPLAY);
|
||||
fDisplay = GetD3DEGLDisplay(EGL_DEFAULT_DISPLAY, useGLBackend);
|
||||
if (EGL_NO_DISPLAY == fDisplay) {
|
||||
SkDebugf("Could not create EGL display!");
|
||||
return;
|
||||
|
@ -418,7 +418,7 @@ bool create_ANGLE(EGLNativeWindowType hWnd,
|
||||
EGL_NONE, EGL_NONE
|
||||
};
|
||||
|
||||
EGLDisplay display = SkANGLEGLContext::GetD3DEGLDisplay(GetDC(hWnd));
|
||||
EGLDisplay display = SkANGLEGLContext::GetD3DEGLDisplay(GetDC(hWnd), false);
|
||||
|
||||
if (EGL_NO_DISPLAY == display) {
|
||||
SkDebugf("Could not create ANGLE egl display!\n");
|
||||
|
@ -260,7 +260,6 @@ static SkString make_png_name(const char* filename) {
|
||||
typedef GrContextFactory::GLContextType GLContextType;
|
||||
#ifdef SK_BUILD_FOR_WIN
|
||||
static const GLContextType kAngle = GrContextFactory::kANGLE_GLContextType;
|
||||
static const GLContextType kCommandBuffer = GrContextFactory::kCommandBuffer_GLContextType;
|
||||
#else
|
||||
static const GLContextType kNative = GrContextFactory::kNative_GLContextType;
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user