Commit 33f11fbc by Geoff Lang Committed by Commit Bot

Initialize gl::Context state on the first call to MakeCurrent.

The constructor of gl::Context creates a bunch of zero and helper objects but it is not current at this time. If the backend if not using virtualized contexts this causes the created objects to be created on the wrong native context. BUG=angleproject:2464 Change-Id: I9718df87d0afeb08729920363d362d5f891061ed Reviewed-on: https://chromium-review.googlesource.com/1048114Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarLuc Ferron <lucferron@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
parent c8fbff3d
...@@ -294,6 +294,8 @@ Context::Context(rx::EGLImplFactory *implFactory, ...@@ -294,6 +294,8 @@ Context::Context(rx::EGLImplFactory *implFactory,
mContextLostForced(false), mContextLostForced(false),
mResetStrategy(GetResetStrategy(attribs)), mResetStrategy(GetResetStrategy(attribs)),
mRobustAccess(GetRobustAccess(attribs)), mRobustAccess(GetRobustAccess(attribs)),
mSurfacelessSupported(displayExtensions.surfacelessContext),
mExplicitContextAvailable(clientExtensions.explicitContext),
mCurrentSurface(static_cast<egl::Surface *>(EGL_NO_SURFACE)), mCurrentSurface(static_cast<egl::Surface *>(EGL_NO_SURFACE)),
mCurrentDisplay(static_cast<egl::Display *>(EGL_NO_DISPLAY)), mCurrentDisplay(static_cast<egl::Display *>(EGL_NO_DISPLAY)),
mWebGLContext(GetWebGLContext(attribs)), mWebGLContext(GetWebGLContext(attribs)),
...@@ -305,11 +307,13 @@ Context::Context(rx::EGLImplFactory *implFactory, ...@@ -305,11 +307,13 @@ Context::Context(rx::EGLImplFactory *implFactory,
// Needed to solve a Clang warning of unused variables. // Needed to solve a Clang warning of unused variables.
ANGLE_UNUSED_VARIABLE(mSavedArgsType); ANGLE_UNUSED_VARIABLE(mSavedArgsType);
ANGLE_UNUSED_VARIABLE(mParamsBuffer); ANGLE_UNUSED_VARIABLE(mParamsBuffer);
}
mImplementation->setMemoryProgramCache(memoryProgramCache); void Context::initialize()
{
mImplementation->setMemoryProgramCache(mMemoryProgramCache);
bool robustResourceInit = GetRobustResourceInit(attribs); initCaps();
initCaps(displayExtensions, clientExtensions, robustResourceInit);
initWorkarounds(); initWorkarounds();
mGLState.initialize(this); mGLState.initialize(this);
...@@ -520,6 +524,7 @@ egl::Error Context::makeCurrent(egl::Display *display, egl::Surface *surface) ...@@ -520,6 +524,7 @@ egl::Error Context::makeCurrent(egl::Display *display, egl::Surface *surface)
if (!mHasBeenCurrent) if (!mHasBeenCurrent)
{ {
initialize();
initRendererString(); initRendererString();
initVersionStrings(); initVersionStrings();
initExtensionStrings(); initExtensionStrings();
...@@ -3019,9 +3024,7 @@ bool Context::hasActiveTransformFeedback(GLuint program) const ...@@ -3019,9 +3024,7 @@ bool Context::hasActiveTransformFeedback(GLuint program) const
return false; return false;
} }
Extensions Context::generateSupportedExtensions(const egl::DisplayExtensions &displayExtensions, Extensions Context::generateSupportedExtensions() const
const egl::ClientExtensions &clientExtensions,
bool robustResourceInit) const
{ {
Extensions supportedExtensions = mImplementation->getNativeExtensions(); Extensions supportedExtensions = mImplementation->getNativeExtensions();
...@@ -3065,7 +3068,7 @@ Extensions Context::generateSupportedExtensions(const egl::DisplayExtensions &di ...@@ -3065,7 +3068,7 @@ Extensions Context::generateSupportedExtensions(const egl::DisplayExtensions &di
supportedExtensions.noError = mSkipValidation; supportedExtensions.noError = mSkipValidation;
// Enable surfaceless to advertise we'll have the correct behavior when there is no default FBO // Enable surfaceless to advertise we'll have the correct behavior when there is no default FBO
supportedExtensions.surfacelessContext = displayExtensions.surfacelessContext; supportedExtensions.surfacelessContext = mSurfacelessSupported;
// Explicitly enable GL_KHR_debug // Explicitly enable GL_KHR_debug
supportedExtensions.debug = true; supportedExtensions.debug = true;
...@@ -3078,7 +3081,7 @@ Extensions Context::generateSupportedExtensions(const egl::DisplayExtensions &di ...@@ -3078,7 +3081,7 @@ Extensions Context::generateSupportedExtensions(const egl::DisplayExtensions &di
supportedExtensions.robustClientMemory = true; supportedExtensions.robustClientMemory = true;
// Determine robust resource init availability from EGL. // Determine robust resource init availability from EGL.
supportedExtensions.robustResourceInitialization = robustResourceInit; supportedExtensions.robustResourceInitialization = mGLState.isRobustResourceInitEnabled();
// mExtensions.robustBufferAccessBehavior is true only if robust access is true and the backend // mExtensions.robustBufferAccessBehavior is true only if robust access is true and the backend
// supports it. // supports it.
...@@ -3089,7 +3092,7 @@ Extensions Context::generateSupportedExtensions(const egl::DisplayExtensions &di ...@@ -3089,7 +3092,7 @@ Extensions Context::generateSupportedExtensions(const egl::DisplayExtensions &di
supportedExtensions.programCacheControl = true; supportedExtensions.programCacheControl = true;
// Enable EGL_ANGLE_explicit_context subextensions // Enable EGL_ANGLE_explicit_context subextensions
if (clientExtensions.explicitContext) if (mExplicitContextAvailable)
{ {
// GL_ANGLE_explicit_context_gles1 // GL_ANGLE_explicit_context_gles1
supportedExtensions.explicitContextGles1 = true; supportedExtensions.explicitContextGles1 = true;
...@@ -3100,14 +3103,11 @@ Extensions Context::generateSupportedExtensions(const egl::DisplayExtensions &di ...@@ -3100,14 +3103,11 @@ Extensions Context::generateSupportedExtensions(const egl::DisplayExtensions &di
return supportedExtensions; return supportedExtensions;
} }
void Context::initCaps(const egl::DisplayExtensions &displayExtensions, void Context::initCaps()
const egl::ClientExtensions &clientExtensions,
bool robustResourceInit)
{ {
mCaps = mImplementation->getNativeCaps(); mCaps = mImplementation->getNativeCaps();
mSupportedExtensions = mSupportedExtensions = generateSupportedExtensions();
generateSupportedExtensions(displayExtensions, clientExtensions, robustResourceInit);
mExtensions = mSupportedExtensions; mExtensions = mSupportedExtensions;
mLimitations = mImplementation->getNativeLimitations(); mLimitations = mImplementation->getNativeLimitations();
......
...@@ -1466,6 +1466,8 @@ class Context final : angle::NonCopyable ...@@ -1466,6 +1466,8 @@ class Context final : angle::NonCopyable
AttributesMask getVertexArraysAttributeMask() const; AttributesMask getVertexArraysAttributeMask() const;
private: private:
void initialize();
Error prepareForDraw(); Error prepareForDraw();
Error prepareForClear(GLbitfield mask); Error prepareForClear(GLbitfield mask);
Error prepareForClearBuffer(GLenum buffer, GLint drawbuffer); Error prepareForClearBuffer(GLenum buffer, GLint drawbuffer);
...@@ -1495,12 +1497,8 @@ class Context final : angle::NonCopyable ...@@ -1495,12 +1497,8 @@ class Context final : angle::NonCopyable
void initVersionStrings(); void initVersionStrings();
void initExtensionStrings(); void initExtensionStrings();
Extensions generateSupportedExtensions(const egl::DisplayExtensions &displayExtensions, Extensions generateSupportedExtensions() const;
const egl::ClientExtensions &clientExtensions, void initCaps();
bool robustResourceInit) const;
void initCaps(const egl::DisplayExtensions &displayExtensions,
const egl::ClientExtensions &clientExtensions,
bool robustResourceInit);
void updateCaps(); void updateCaps();
void initWorkarounds(); void initWorkarounds();
...@@ -1574,11 +1572,13 @@ class Context final : angle::NonCopyable ...@@ -1574,11 +1572,13 @@ class Context final : angle::NonCopyable
mutable GLenum mResetStatus; mutable GLenum mResetStatus;
mutable bool mContextLostForced; mutable bool mContextLostForced;
GLenum mResetStrategy; GLenum mResetStrategy;
bool mRobustAccess; const bool mRobustAccess;
const bool mSurfacelessSupported;
const bool mExplicitContextAvailable;
egl::Surface *mCurrentSurface; egl::Surface *mCurrentSurface;
egl::Display *mCurrentDisplay; egl::Display *mCurrentDisplay;
bool mWebGLContext; const bool mWebGLContext;
bool mExtensionsEnabled; const bool mExtensionsEnabled;
MemoryProgramCache *mMemoryProgramCache; MemoryProgramCache *mMemoryProgramCache;
State::DirtyBits mTexImageDirtyBits; State::DirtyBits mTexImageDirtyBits;
......
...@@ -281,7 +281,8 @@ DynamicDescriptorPool::~DynamicDescriptorPool() ...@@ -281,7 +281,8 @@ DynamicDescriptorPool::~DynamicDescriptorPool()
void DynamicDescriptorPool::destroy(RendererVk *rendererVk) void DynamicDescriptorPool::destroy(RendererVk *rendererVk)
{ {
ASSERT(mCurrentDescriptorSetPool.valid()); // It's possible that mCurrentDescriptorSetPool is not valid if the owning context was never
// made current/initialized
mCurrentDescriptorSetPool.destroy(rendererVk->getDevice()); mCurrentDescriptorSetPool.destroy(rendererVk->getDevice());
} }
......
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