Commit 78a51911 by Jonah Ryan-Davis Committed by Commit Bot

Clean up and expose frontend features to egl.

gl::Workarounds was used to hold frontend features. Change ownership of this struct from Context to Display, so it can be exposed to egl. Also rename to features and clean up for consistency. Bug: angleproject:1621 Change-Id: I82e98e53873abb7a402c93e60f8a662a7263e0d5 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1655772 Commit-Queue: Jonah Ryan-Davis <jonahr@google.com> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 94eb189b
......@@ -39,7 +39,6 @@
#include "libANGLE/Texture.h"
#include "libANGLE/TransformFeedback.h"
#include "libANGLE/VertexArray.h"
#include "libANGLE/Workarounds.h"
#include "libANGLE/formatutils.h"
#include "libANGLE/queryconversions.h"
#include "libANGLE/queryutils.h"
......@@ -337,7 +336,12 @@ void Context::initialize()
mImplementation->setMemoryProgramCache(mMemoryProgramCache);
initCaps();
initWorkarounds();
if (mDisplay->getFrontendFeatures().syncFramebufferBindingsOnTexImage.enabled)
{
mTexImageDirtyBits.set(State::DIRTY_BIT_READ_FRAMEBUFFER_BINDING);
mTexImageDirtyBits.set(State::DIRTY_BIT_DRAW_FRAMEBUFFER_BINDING);
}
mState.initialize(this);
......@@ -3475,24 +3479,6 @@ void Context::updateCaps()
mStateCache.initialize(this);
}
void Context::initWorkarounds()
{
// Apply back-end workarounds.
mImplementation->applyNativeWorkarounds(&mWorkarounds);
// Lose the context upon out of memory error if the application is
// expecting to watch for those events.
mWorkarounds.loseContextOnOutOfMemory.enabled =
(mResetStrategy == GL_LOSE_CONTEXT_ON_RESET_EXT);
if (mWorkarounds.syncFramebufferBindingsOnTexImage.enabled)
{
// Update the Framebuffer bindings on TexImage to work around an Intel bug.
mTexImageDirtyBits.set(State::DIRTY_BIT_READ_FRAMEBUFFER_BINDING);
mTexImageDirtyBits.set(State::DIRTY_BIT_DRAW_FRAMEBUFFER_BINDING);
}
}
bool Context::noopDrawInstanced(PrimitiveMode mode, GLsizei count, GLsizei instanceCount)
{
return (instanceCount == 0) || noopDraw(mode, count);
......@@ -5064,11 +5050,6 @@ void Context::attachShader(GLuint program, GLuint shader)
programObject->attachShader(shaderObject);
}
const Workarounds &Context::getWorkarounds() const
{
return mWorkarounds;
}
void Context::copyBufferSubData(BufferBinding readTarget,
BufferBinding writeTarget,
GLintptr readOffset,
......@@ -8126,6 +8107,11 @@ Shader *Context::getShader(GLuint handle) const
return mState.mShaderProgramManager->getShader(handle);
}
const FrontendFeatures &Context::getFrontendFeatures() const
{
return mDisplay->getFrontendFeatures();
}
bool Context::isRenderbufferGenerated(GLuint renderbuffer) const
{
return mState.mRenderbufferManager->isHandleGenerated(renderbuffer);
......@@ -8333,7 +8319,8 @@ void ErrorSet::handleError(GLenum errorCode,
unsigned int line)
{
if (errorCode == GL_OUT_OF_MEMORY &&
mContext->getWorkarounds().loseContextOnOutOfMemory.enabled)
mContext->getGraphicsResetStrategy() == GL_LOSE_CONTEXT_ON_RESET_EXT &&
mContext->getDisplay()->getFrontendFeatures().loseContextOnOutOfMemory.enabled)
{
mContext->markContextLost(GraphicsResetStatus::UnknownContextReset);
}
......
......@@ -27,7 +27,6 @@
#include "libANGLE/ResourceMap.h"
#include "libANGLE/State.h"
#include "libANGLE/VertexAttribute.h"
#include "libANGLE/Workarounds.h"
#include "libANGLE/WorkerThread.h"
#include "libANGLE/angletypes.h"
......@@ -51,6 +50,7 @@ class Buffer;
class Compiler;
class FenceNV;
class Framebuffer;
struct FrontendFeatures;
class GLES1Renderer;
class MemoryProgramCache;
class MemoryObject;
......@@ -1772,6 +1772,7 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl
bool isContextLost() const { return mContextLost; }
GLenum getGraphicsResetStatus();
GLenum getGraphicsResetStrategy() const { return mResetStrategy; }
bool isResetNotificationEnabled();
const egl::Config *getConfig() const;
......@@ -1788,7 +1789,6 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl
size_t getRequestableExtensionStringCount() const;
rx::ContextImpl *getImplementation() const { return mImplementation.get(); }
const Workarounds &getWorkarounds() const;
ANGLE_NO_DISCARD bool getScratchBuffer(size_t requestedSizeBytes,
angle::MemoryBuffer **scratchBufferOut) const;
......@@ -1885,6 +1885,8 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl
bool isBufferAccessValidationEnabled() const { return mBufferAccessValidationEnabled; }
const FrontendFeatures &getFrontendFeatures() const;
private:
void initialize();
......@@ -1930,7 +1932,6 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl
Extensions generateSupportedExtensions() const;
void initCaps();
void updateCaps();
void initWorkarounds();
gl::LabeledObject *getLabeledObject(GLenum identifier, GLuint name) const;
gl::LabeledObject *getLabeledObjectFromPtr(const void *ptr) const;
......@@ -2020,8 +2021,6 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl
State::DirtyObjects mComputeDirtyObjects;
State::DirtyObjects mCopyImageDirtyObjects;
Workarounds mWorkarounds;
// Binding to container objects that use dependent state updates.
angle::ObserverBinding mVertexArrayObserverBinding;
angle::ObserverBinding mDrawFramebufferObserverBinding;
......
......@@ -564,7 +564,10 @@ Error Display::initialize()
config.second.renderableType |= EGL_OPENGL_ES_BIT;
}
initializeFrontendFeatures();
mFeatures.clear();
mFrontendFeatures.populateFeatureList(&mFeatures);
mImplementation->populateFeatureList(&mFeatures);
initDisplayExtensions();
......@@ -1341,6 +1344,16 @@ void Display::initVendorString()
mVendorString = mImplementation->getVendorString();
}
void Display::initializeFrontendFeatures()
{
// Enable on all Impls
mFrontendFeatures.loseContextOnOutOfMemory.enabled = true;
mImplementation->initializeFrontendFeatures(&mFrontendFeatures);
rx::OverrideFeaturesWithDisplayState(&mFrontendFeatures, mState);
}
const DisplayExtensions &Display::getExtensions() const
{
return mDisplayExtensions;
......
......@@ -20,6 +20,7 @@
#include "libANGLE/Config.h"
#include "libANGLE/Debug.h"
#include "libANGLE/Error.h"
#include "libANGLE/FrontendFeatures.h"
#include "libANGLE/LoggingAnnotator.h"
#include "libANGLE/MemoryProgramCache.h"
#include "libANGLE/Version.h"
......@@ -193,6 +194,8 @@ class Display final : public LabeledObject, angle::NonCopyable
typedef std::set<gl::Context *> ContextSet;
const ContextSet &getContextSet() { return mContextSet; }
const gl::FrontendFeatures &getFrontendFeatures() { return mFrontendFeatures; }
const angle::FeatureList &getFeatures() const { return mFeatures; }
const char *queryStringi(const EGLint name, const EGLint index);
......@@ -208,6 +211,7 @@ class Display final : public LabeledObject, angle::NonCopyable
void initDisplayExtensions();
void initVendorString();
void initializeFrontendFeatures();
DisplayState mState;
rx::DisplayImpl *mImplementation;
......@@ -247,6 +251,8 @@ class Display final : public LabeledObject, angle::NonCopyable
gl::MemoryProgramCache mMemoryProgramCache;
size_t mGlobalTextureShareGroupUsers;
gl::FrontendFeatures mFrontendFeatures;
angle::FeatureList mFeatures;
};
......
......@@ -15,10 +15,10 @@
namespace gl
{
struct Workarounds : angle::FeatureSetBase
struct FrontendFeatures : angle::FeatureSetBase
{
Workarounds();
~Workarounds();
FrontendFeatures();
~FrontendFeatures();
// Force the context to be lost (via KHR_robustness) if a GL_OUT_OF_MEMORY error occurs. The
// driver may be in an inconsistent state if this happens, and some users of ANGLE rely on this
......@@ -46,8 +46,8 @@ struct Workarounds : angle::FeatureSetBase
&members};
};
inline Workarounds::Workarounds() = default;
inline Workarounds::~Workarounds() = default;
inline FrontendFeatures::FrontendFeatures() = default;
inline FrontendFeatures::~FrontendFeatures() = default;
} // namespace gl
......
......@@ -19,6 +19,7 @@
#include "common/version.h"
#include "compiler/translator/blocklayout.h"
#include "libANGLE/Context.h"
#include "libANGLE/FrontendFeatures.h"
#include "libANGLE/MemoryProgramCache.h"
#include "libANGLE/ProgramLinkedResources.h"
#include "libANGLE/ResourceManager.h"
......@@ -1481,7 +1482,7 @@ void Program::resolveLinkImpl(const Context *context)
// Save to the program cache.
auto *cache = linkingState->context->getMemoryProgramCache();
if (cache && (mState.mLinkedTransformFeedbackVaryings.empty() ||
!linkingState->context->getWorkarounds()
!linkingState->context->getFrontendFeatures()
.disableProgramCachingForTransformFeedback.enabled))
{
cache->putProgram(linkingState->programHash, linkingState->context, this);
......@@ -4461,7 +4462,7 @@ void Program::serialize(const Context *context, angle::MemoryBuffer *binaryOut)
// Warn the app layer if saving a binary with unsupported transform feedback.
if (!mState.getLinkedTransformFeedbackVaryings().empty() &&
context->getWorkarounds().disableProgramCachingForTransformFeedback.enabled)
context->getFrontendFeatures().disableProgramCachingForTransformFeedback.enabled)
{
WARN() << "Saving program binary with transform feedback, which is not supported on this "
"driver.";
......@@ -4680,7 +4681,7 @@ angle::Result Program::deserialize(const Context *context,
// Reject programs that use transform feedback varyings if the hardware cannot support them.
if (transformFeedbackVaryingCount > 0 &&
context->getWorkarounds().disableProgramCachingForTransformFeedback.enabled)
context->getFrontendFeatures().disableProgramCachingForTransformFeedback.enabled)
{
infoLog << "Current driver does not support transform feedback in binary programs.";
return angle::Result::Incomplete;
......
......@@ -179,8 +179,6 @@ class ContextImpl : public GLImplFactory
virtual const gl::Extensions &getNativeExtensions() const = 0;
virtual const gl::Limitations &getNativeLimitations() const = 0;
virtual void applyNativeWorkarounds(gl::Workarounds *workarounds) const {}
virtual angle::Result dispatchCompute(const gl::Context *context,
GLuint numGroupsX,
GLuint numGroupsY,
......
......@@ -36,6 +36,7 @@ class Thread;
namespace gl
{
class Context;
struct FrontendFeatures;
}
namespace rx
......@@ -90,6 +91,8 @@ class DisplayImpl : public EGLImplFactory
void setBlobCache(egl::BlobCache *blobCache) { mBlobCache = blobCache; }
egl::BlobCache *getBlobCache() const { return mBlobCache; }
virtual void initializeFrontendFeatures(gl::FrontendFeatures *features) const {}
virtual void populateFeatureList(angle::FeatureList *features) = 0;
const egl::DisplayState &getState() const { return mState; }
......
......@@ -571,11 +571,6 @@ const gl::Limitations &ContextGL::getNativeLimitations() const
return mRenderer->getNativeLimitations();
}
void ContextGL::applyNativeWorkarounds(gl::Workarounds *workarounds) const
{
return mRenderer->applyNativeWorkarounds(workarounds);
}
StateManagerGL *ContextGL::getStateManager()
{
return mRenderer->getStateManager();
......
......@@ -216,8 +216,6 @@ class ContextGL : public ContextImpl
const gl::Extensions &getNativeExtensions() const override;
const gl::Limitations &getNativeLimitations() const override;
void applyNativeWorkarounds(gl::Workarounds *workarounds) const override;
// Handle helpers
ANGLE_INLINE const FunctionsGL *getFunctions() const { return mRenderer->getFunctions(); }
......
......@@ -557,10 +557,10 @@ MultiviewImplementationTypeGL RendererGL::getMultiviewImplementationType() const
return mMultiviewImplementationType;
}
void RendererGL::applyNativeWorkarounds(gl::Workarounds *workarounds) const
void RendererGL::initializeFrontendFeatures(gl::FrontendFeatures *features) const
{
ensureCapsInitialized();
nativegl_gl::ApplyWorkarounds(mFunctions.get(), workarounds);
nativegl_gl::InitializeFrontendFeatures(mFunctions.get(), features);
}
angle::Result RendererGL::dispatchCompute(const gl::Context *context,
......
......@@ -24,7 +24,7 @@ namespace gl
struct IndexRange;
class Path;
class State;
struct Workarounds;
struct FrontendFeatures;
} // namespace gl
namespace egl
......@@ -170,7 +170,7 @@ class RendererGL : angle::NonCopyable
const gl::TextureCapsMap &getNativeTextureCaps() const;
const gl::Extensions &getNativeExtensions() const;
const gl::Limitations &getNativeLimitations() const;
void applyNativeWorkarounds(gl::Workarounds *workarounds) const;
void initializeFrontendFeatures(gl::FrontendFeatures *features) const;
angle::Result dispatchCompute(const gl::Context *context,
GLuint numGroupsX,
......
......@@ -74,6 +74,8 @@ class DisplayCGL : public DisplayGL
WorkerContext *createWorkerContext(std::string *infoLog);
void initializeFrontendFeatures(gl::FrontendFeatures *features) const override;
void populateFeatureList(angle::FeatureList *features) override;
// Support for dual-GPU MacBook Pros. If the context was created
......
......@@ -427,6 +427,11 @@ void DisplayCGL::unreferenceDiscreteGPU()
}
}
void DisplayCGL::initializeFrontendFeatures(gl::FrontendFeatures *features) const
{
mRenderer->initializeFrontendFeatures(features);
}
void DisplayCGL::populateFeatureList(angle::FeatureList *features)
{
mRenderer->getWorkarounds().populateFeatureList(features);
......
......@@ -690,6 +690,11 @@ WorkerContext *DisplayAndroid::createWorkerContext(std::string *infoLog,
return new WorkerContextAndroid(context, mEGL, mDummyPbuffer);
}
void DisplayAndroid::initializeFrontendFeatures(gl::FrontendFeatures *features) const
{
mRenderer->initializeFrontendFeatures(features);
}
void DisplayAndroid::populateFeatureList(angle::FeatureList *features)
{
mRenderer->getWorkarounds().populateFeatureList(features);
......
......@@ -82,6 +82,8 @@ class DisplayAndroid : public DisplayEGL
EGLContext sharedContext,
const native_egl::AttributeVector workerAttribs) override;
void initializeFrontendFeatures(gl::FrontendFeatures *features) const override;
void populateFeatureList(angle::FeatureList *features) override;
private:
......
......@@ -1073,6 +1073,11 @@ WorkerContext *DisplayOzone::createWorkerContext(std::string *infoLog,
return new WorkerContextOzone(context, mEGL);
}
void DisplayOzone::initializeFrontendFeatures(gl::FrontendFeatures *features) const
{
mRenderer->initializeFrontendFeatures(features);
}
void DisplayOzone::populateFeatureList(angle::FeatureList *features)
{
mRenderer->getWorkarounds().populateFeatureList(features);
......
......@@ -160,6 +160,8 @@ class DisplayOzone final : public DisplayEGL
EGLContext sharedContext,
const native_egl::AttributeVector workerAttribs) override;
void initializeFrontendFeatures(gl::FrontendFeatures *features) const override;
void populateFeatureList(angle::FeatureList *features) override;
private:
......
......@@ -991,6 +991,11 @@ WorkerContext *DisplayGLX::createWorkerContext(std::string *infoLog)
return new WorkerContextGLX(context, &mGLX, workerPbuffer);
}
void DisplayGLX::initializeFrontendFeatures(gl::FrontendFeatures *features) const
{
mRenderer->initializeFrontendFeatures(features);
}
void DisplayGLX::populateFeatureList(angle::FeatureList *features)
{
mRenderer->getWorkarounds().populateFeatureList(features);
......
......@@ -100,6 +100,8 @@ class DisplayGLX : public DisplayGL
WorkerContext *createWorkerContext(std::string *infoLog);
void initializeFrontendFeatures(gl::FrontendFeatures *features) const override;
void populateFeatureList(angle::FeatureList *features) override;
private:
......
......@@ -16,7 +16,7 @@
#include "libANGLE/Buffer.h"
#include "libANGLE/Caps.h"
#include "libANGLE/Context.h"
#include "libANGLE/Workarounds.h"
#include "libANGLE/FrontendFeatures.h"
#include "libANGLE/formatutils.h"
#include "libANGLE/queryconversions.h"
#include "libANGLE/renderer/gl/ContextGL.h"
......@@ -1477,13 +1477,12 @@ void GenerateWorkarounds(const FunctionsGL *functions, WorkaroundsGL *workaround
(IsWindows() && (IsIntel(vendor) || IsAMD(vendor))) || (IsLinux() && IsNvidia(vendor));
}
void ApplyWorkarounds(const FunctionsGL *functions, gl::Workarounds *workarounds)
void InitializeFrontendFeatures(const FunctionsGL *functions, gl::FrontendFeatures *features)
{
VendorID vendor = GetVendorID(functions);
workarounds->disableProgramCachingForTransformFeedback.enabled =
IsAndroid() && IsQualcomm(vendor);
workarounds->syncFramebufferBindingsOnTexImage.enabled = IsWindows() && IsIntel(vendor);
features->disableProgramCachingForTransformFeedback.enabled = IsAndroid() && IsQualcomm(vendor);
features->syncFramebufferBindingsOnTexImage.enabled = IsWindows() && IsIntel(vendor);
}
} // namespace nativegl_gl
......
......@@ -25,7 +25,7 @@ struct Caps;
class TextureCapsMap;
struct Extensions;
struct Version;
struct Workarounds;
struct FrontendFeatures;
} // namespace gl
namespace rx
......@@ -63,7 +63,7 @@ void GenerateCaps(const FunctionsGL *functions,
MultiviewImplementationTypeGL *multiviewImplementationType);
void GenerateWorkarounds(const FunctionsGL *functions, WorkaroundsGL *workarounds);
void ApplyWorkarounds(const FunctionsGL *functions, gl::Workarounds *workarounds);
void InitializeFrontendFeatures(const FunctionsGL *functions, gl::FrontendFeatures *features);
} // namespace nativegl_gl
namespace nativegl
......
......@@ -1058,6 +1058,11 @@ WorkerContext *DisplayWGL::createWorkerContext(std::string *infoLog,
return new WorkerContextWGL(mFunctionsWGL, workerPbuffer, workerDeviceContext, workerContext);
}
void DisplayWGL::initializeFrontendFeatures(gl::FrontendFeatures *features) const
{
mRenderer->initializeFrontendFeatures(features);
}
void DisplayWGL::populateFeatureList(angle::FeatureList *features)
{
mRenderer->getWorkarounds().populateFeatureList(features);
......
......@@ -85,6 +85,8 @@ class DisplayWGL : public DisplayGL
HGLRC sharedContext,
const std::vector<int> &workerContextAttribs);
void initializeFrontendFeatures(gl::FrontendFeatures *features) const override;
void populateFeatureList(angle::FeatureList *features) override;
private:
......
......@@ -198,6 +198,7 @@ libangle_sources = [
"src/libANGLE/Framebuffer.h",
"src/libANGLE/FramebufferAttachment.cpp",
"src/libANGLE/FramebufferAttachment.h",
"src/libANGLE/FrontendFeatures.h",
"src/libANGLE/GLES1Renderer.cpp",
"src/libANGLE/GLES1Renderer.h",
"src/libANGLE/GLES1Shaders.inc",
......@@ -268,7 +269,6 @@ libangle_sources = [
"src/libANGLE/VertexAttribute.cpp",
"src/libANGLE/VertexAttribute.h",
"src/libANGLE/VertexAttribute.inc",
"src/libANGLE/Workarounds.h",
"src/libANGLE/WorkerThread.cpp",
"src/libANGLE/WorkerThread.h",
"src/libANGLE/angletypes.cpp",
......
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