Commit 83107970 by Régis Fénéon Committed by Jamie Madill

Implement eglQueryContext

BUG=angle:895 Change-Id: I5e709f772d6222cdb7b5d7c060830a75eac9f815 Reviewed-on: https://chromium-review.googlesource.com/246490Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 959ad9a8
...@@ -29,6 +29,7 @@ Jacek Caban ...@@ -29,6 +29,7 @@ Jacek Caban
Mark Callow Mark Callow
Ginn Chen Ginn Chen
Tibor den Ouden Tibor den Ouden
Régis Fénéon
James Hauxwell James Hauxwell
Sam Hocevar Sam Hocevar
Pierre Leveille Pierre Leveille
......
...@@ -84,6 +84,7 @@ Mark Banner (standard8mbp) ...@@ -84,6 +84,7 @@ Mark Banner (standard8mbp)
David Kilzer David Kilzer
Jacek Caban Jacek Caban
Tibor den Ouden Tibor den Ouden
Régis Fénéon
Microsoft Corporation Microsoft Corporation
Cooper Partin Cooper Partin
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "common/platform.h" #include "common/platform.h"
#include "libANGLE/Compiler.h" #include "libANGLE/Compiler.h"
#include "libANGLE/Buffer.h" #include "libANGLE/Buffer.h"
#include "libANGLE/Config.h"
#include "libANGLE/Display.h" #include "libANGLE/Display.h"
#include "libANGLE/Fence.h" #include "libANGLE/Fence.h"
#include "libANGLE/Framebuffer.h" #include "libANGLE/Framebuffer.h"
...@@ -36,7 +37,7 @@ ...@@ -36,7 +37,7 @@
namespace gl namespace gl
{ {
Context::Context(int clientVersion, const Context *shareContext, rx::Renderer *renderer, bool notifyResets, bool robustAccess) Context::Context(const egl::Config *config, int clientVersion, const Context *shareContext, rx::Renderer *renderer, bool notifyResets, bool robustAccess)
: mRenderer(renderer) : mRenderer(renderer)
{ {
ASSERT(robustAccess == false); // Unimplemented ASSERT(robustAccess == false); // Unimplemented
...@@ -46,6 +47,10 @@ Context::Context(int clientVersion, const Context *shareContext, rx::Renderer *r ...@@ -46,6 +47,10 @@ Context::Context(int clientVersion, const Context *shareContext, rx::Renderer *r
mClientVersion = clientVersion; mClientVersion = clientVersion;
mConfigID = config->configID;
mClientType = EGL_OPENGL_ES_API;
mRenderBuffer = EGL_NONE;
mFenceNVHandleAllocator.setBaseHandle(0); mFenceNVHandleAllocator.setBaseHandle(0);
if (shareContext != NULL) if (shareContext != NULL)
...@@ -186,6 +191,8 @@ void Context::makeCurrent(egl::Surface *surface) ...@@ -186,6 +191,8 @@ void Context::makeCurrent(egl::Surface *surface)
mRenderer->createDefaultAttachment(GL_STENCIL, surface)); mRenderer->createDefaultAttachment(GL_STENCIL, surface));
setFramebufferZero(framebufferZero); setFramebufferZero(framebufferZero);
mRenderBuffer = surface->getRenderBuffer();
} }
// NOTE: this function should not assume that this context is current! // NOTE: this function should not assume that this context is current!
...@@ -1274,6 +1281,21 @@ int Context::getClientVersion() const ...@@ -1274,6 +1281,21 @@ int Context::getClientVersion() const
return mClientVersion; return mClientVersion;
} }
EGLint Context::getConfigID() const
{
return mConfigID;
}
EGLenum Context::getClientType() const
{
return mClientType;
}
EGLenum Context::getRenderBuffer() const
{
return mRenderBuffer;
}
const Caps &Context::getCaps() const const Caps &Context::getCaps() const
{ {
return mCaps; return mCaps;
......
...@@ -34,6 +34,7 @@ class Renderer; ...@@ -34,6 +34,7 @@ class Renderer;
namespace egl namespace egl
{ {
class Surface; class Surface;
struct Config;
} }
namespace gl namespace gl
...@@ -57,7 +58,7 @@ class TransformFeedback; ...@@ -57,7 +58,7 @@ class TransformFeedback;
class Context class Context
{ {
public: public:
Context(int clientVersion, const Context *shareContext, rx::Renderer *renderer, bool notifyResets, bool robustAccess); Context(const egl::Config *config, int clientVersion, const Context *shareContext, rx::Renderer *renderer, bool notifyResets, bool robustAccess);
virtual ~Context(); virtual ~Context();
...@@ -179,6 +180,10 @@ class Context ...@@ -179,6 +180,10 @@ class Context
virtual int getClientVersion() const; virtual int getClientVersion() const;
EGLint getConfigID() const;
EGLenum getClientType() const;
EGLenum getRenderBuffer() const;
const Caps &getCaps() const; const Caps &getCaps() const;
const TextureCapsMap &getTextureCaps() const; const TextureCapsMap &getTextureCaps() const;
const Extensions &getExtensions() const; const Extensions &getExtensions() const;
...@@ -225,6 +230,10 @@ class Context ...@@ -225,6 +230,10 @@ class Context
int mClientVersion; int mClientVersion;
EGLint mConfigID;
EGLenum mClientType;
EGLenum mRenderBuffer;
TextureMap mZeroTextures; TextureMap mZeroTextures;
typedef std::map<GLuint, Framebuffer*> FramebufferMap; typedef std::map<GLuint, Framebuffer*> FramebufferMap;
......
...@@ -147,7 +147,7 @@ egl::Error DisplayD3D::createContext(const egl::Config *config, const gl::Contex ...@@ -147,7 +147,7 @@ egl::Error DisplayD3D::createContext(const egl::Config *config, const gl::Contex
bool notifyResets = (attribs.get(EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT, EGL_NO_RESET_NOTIFICATION_EXT) == EGL_LOSE_CONTEXT_ON_RESET_EXT); bool notifyResets = (attribs.get(EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT, EGL_NO_RESET_NOTIFICATION_EXT) == EGL_LOSE_CONTEXT_ON_RESET_EXT);
bool robustAccess = (attribs.get(EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT, EGL_FALSE) == EGL_TRUE); bool robustAccess = (attribs.get(EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT, EGL_FALSE) == EGL_TRUE);
*outContext = new gl::Context(clientVersion, shareContext, mRenderer, notifyResets, robustAccess); *outContext = new gl::Context(config, clientVersion, shareContext, mRenderer, notifyResets, robustAccess);
return egl::Error(EGL_SUCCESS); return egl::Error(EGL_SUCCESS);
} }
......
...@@ -624,10 +624,27 @@ EGLBoolean EGLAPIENTRY QueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attri ...@@ -624,10 +624,27 @@ EGLBoolean EGLAPIENTRY QueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attri
return EGL_FALSE; return EGL_FALSE;
} }
UNIMPLEMENTED(); // FIXME switch (attribute)
{
case EGL_CONFIG_ID:
*value = context->getConfigID();
break;
case EGL_CONTEXT_CLIENT_TYPE:
*value = context->getClientType();
break;
case EGL_CONTEXT_CLIENT_VERSION:
*value = context->getClientVersion();
break;
case EGL_RENDER_BUFFER:
*value = context->getRenderBuffer();
break;
default:
SetGlobalError(Error(EGL_BAD_ATTRIBUTE));
return EGL_FALSE;
}
SetGlobalError(Error(EGL_SUCCESS)); SetGlobalError(Error(EGL_SUCCESS));
return 0; return EGL_TRUE;
} }
EGLBoolean EGLAPIENTRY WaitGL(void) EGLBoolean EGLAPIENTRY WaitGL(void)
......
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
'<(angle_path)/tests/angle_tests/VertexAttributeTest.cpp', '<(angle_path)/tests/angle_tests/VertexAttributeTest.cpp',
'<(angle_path)/tests/angle_tests/ViewportTest.cpp', '<(angle_path)/tests/angle_tests/ViewportTest.cpp',
'<(angle_path)/tests/standalone_tests/EGLThreadTest.cpp', '<(angle_path)/tests/standalone_tests/EGLThreadTest.cpp',
'<(angle_path)/tests/standalone_tests/EGLQueryContextTest.cpp',
], ],
}, },
'dependencies': 'dependencies':
......
//
// Copyright (c) 2015 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include "gtest/gtest.h"
template <int clientVersion>
class EGLQueryContextTest : public testing::Test
{
public:
virtual void SetUp()
{
PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXT = reinterpret_cast<PFNEGLGETPLATFORMDISPLAYEXTPROC>(eglGetProcAddress("eglGetPlatformDisplayEXT"));
EXPECT_TRUE(eglGetPlatformDisplayEXT != NULL);
EGLint dispattrs[] =
{
EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE,
EGL_NONE
};
mDisplay = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, EGL_DEFAULT_DISPLAY, dispattrs);
EXPECT_TRUE(mDisplay != EGL_NO_DISPLAY);
EXPECT_TRUE(eglInitialize(mDisplay, NULL, NULL) != EGL_FALSE);
EGLint ncfg;
EGLint cfgattrs[] =
{
EGL_RED_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_BLUE_SIZE, 8,
EGL_RENDERABLE_TYPE, clientVersion == 3 ? EGL_OPENGL_ES3_BIT : EGL_OPENGL_ES2_BIT,
EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
EGL_NONE
};
EXPECT_TRUE(eglChooseConfig(mDisplay, cfgattrs, &mConfig, 1, &ncfg) != EGL_FALSE);
EXPECT_TRUE(ncfg == 1);
EGLint ctxattrs[] =
{
EGL_CONTEXT_CLIENT_VERSION, clientVersion,
EGL_NONE
};
mContext = eglCreateContext(mDisplay, mConfig, NULL, ctxattrs);
EXPECT_TRUE(mContext != EGL_NO_CONTEXT);
EGLint surfattrs[] =
{
EGL_WIDTH, 16,
EGL_HEIGHT, 16,
EGL_NONE
};
mSurface = eglCreatePbufferSurface(mDisplay, mConfig, surfattrs);
EXPECT_TRUE(mSurface != EGL_NO_SURFACE);
}
virtual void TearDown()
{
eglMakeCurrent(mDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
eglDestroyContext(mDisplay, mContext);
eglDestroySurface(mDisplay, mSurface);
eglTerminate(mDisplay);
}
EGLDisplay mDisplay;
EGLConfig mConfig;
EGLContext mContext;
EGLSurface mSurface;
};
typedef EGLQueryContextTest<2> EGLQueryContextTestES2;
typedef EGLQueryContextTest<3> EGLQueryContextTestES3;
TEST_F(EGLQueryContextTestES2, GetConfigID)
{
EGLint configId, contextConfigId;
EXPECT_TRUE(eglGetConfigAttrib(mDisplay, mConfig, EGL_CONFIG_ID, &configId) != EGL_FALSE);
EXPECT_TRUE(eglQueryContext(mDisplay, mContext, EGL_CONFIG_ID, &contextConfigId) != EGL_FALSE);
EXPECT_TRUE(configId == contextConfigId);
}
TEST_F(EGLQueryContextTestES2, GetClientType)
{
EGLint clientType;
EXPECT_TRUE(eglQueryContext(mDisplay, mContext, EGL_CONTEXT_CLIENT_TYPE, &clientType) != EGL_FALSE);
EXPECT_TRUE(clientType == EGL_OPENGL_ES_API);
}
TEST_F(EGLQueryContextTestES2, GetClientVersion)
{
EGLint clientVersion;
EXPECT_TRUE(eglQueryContext(mDisplay, mContext, EGL_CONTEXT_CLIENT_VERSION, &clientVersion) != EGL_FALSE);
EXPECT_TRUE(clientVersion == 2);
}
TEST_F(EGLQueryContextTestES2, GetRenderBufferNoSurface)
{
EGLint renderBuffer;
EXPECT_TRUE(eglQueryContext(mDisplay, mContext, EGL_RENDER_BUFFER, &renderBuffer) != EGL_FALSE);
EXPECT_TRUE(renderBuffer == EGL_NONE);
}
TEST_F(EGLQueryContextTestES2, GetRenderBufferBoundSurface)
{
EGLint renderBuffer, contextRenderBuffer;
EXPECT_TRUE(eglQuerySurface(mDisplay, mSurface, EGL_RENDER_BUFFER, &renderBuffer) != EGL_FALSE);
EXPECT_TRUE(eglMakeCurrent(mDisplay, mSurface, mSurface, mContext) != EGL_FALSE);
EXPECT_TRUE(eglQueryContext(mDisplay, mContext, EGL_RENDER_BUFFER, &contextRenderBuffer) != EGL_FALSE);
EXPECT_TRUE(renderBuffer == contextRenderBuffer);
}
TEST_F(EGLQueryContextTestES2, BadDisplay)
{
EGLint val;
EXPECT_TRUE(eglQueryContext(EGL_NO_DISPLAY, mContext, EGL_CONTEXT_CLIENT_TYPE, &val) == EGL_FALSE);
EXPECT_TRUE(eglGetError() == EGL_BAD_DISPLAY);
}
TEST_F(EGLQueryContextTestES2, NotInitialized)
{
EGLint val;
eglTerminate(mDisplay);
EXPECT_TRUE(eglQueryContext(mDisplay, mContext, EGL_CONTEXT_CLIENT_TYPE, &val) == EGL_FALSE);
EXPECT_TRUE(eglGetError() == EGL_NOT_INITIALIZED);
}
TEST_F(EGLQueryContextTestES2, BadContext)
{
EGLint val;
EXPECT_TRUE(eglQueryContext(mDisplay, EGL_NO_CONTEXT, EGL_CONTEXT_CLIENT_TYPE, &val) == EGL_FALSE);
EXPECT_TRUE(eglGetError() == EGL_BAD_CONTEXT);
}
TEST_F(EGLQueryContextTestES2, BadAttribute)
{
EGLint val;
EXPECT_TRUE(eglQueryContext(mDisplay, mContext, EGL_HEIGHT, &val) == EGL_FALSE);
EXPECT_TRUE(eglGetError() == EGL_BAD_ATTRIBUTE);
}
TEST_F(EGLQueryContextTestES3, GetClientVersion)
{
EGLint clientVersion;
EXPECT_TRUE(eglQueryContext(mDisplay, mContext, EGL_CONTEXT_CLIENT_VERSION, &clientVersion) != EGL_FALSE);
EXPECT_TRUE(clientVersion == 3);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment