Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 45863f5f authored by Jorim Jaggi's avatar Jorim Jaggi Committed by Android (Google) Code Review
Browse files

Merge "Enable IMG_context_priority depending on availability"

parents b20e00a1 5b15ef66
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -106,6 +106,9 @@ void GLExtensions::initWithEGLStrings(char const* eglVersion, char const* eglExt
    if (hasEGLExtension("EGL_EXT_protected_content")) {
        mHasProtectedContent = true;
    }
    if (hasEGLExtension("EGL_IMG_context_priority")) {
        mHasContextPriority = true;
    }
}

char const* GLExtensions::getEGLVersion() const {
+2 −0
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ class GLExtensions : public Singleton<GLExtensions> {
    bool mHasWaitSync = false;
    bool mHasImageCrop = false;
    bool mHasProtectedContent = false;
    bool mHasContextPriority = false;

    String8 mVendor;
    String8 mRenderer;
@@ -67,6 +68,7 @@ public:
    bool hasWaitSync() const { return mHasWaitSync; }
    bool hasImageCrop() const { return mHasImageCrop; }
    bool hasProtectedContent() const { return mHasProtectedContent; }
    bool hasContextPriority() const { return mHasContextPriority; }

    void initWithGLStrings(GLubyte const* vendor, GLubyte const* renderer, GLubyte const* version,
                           GLubyte const* extensions);
+20 −4
Original line number Diff line number Diff line
@@ -27,6 +27,12 @@
#include <SurfaceFlinger.h>
#include <vector>

#include <android/hardware/configstore/1.0/ISurfaceFlingerConfigs.h>
#include <configstore/Utils.h>

using namespace android::hardware::configstore;
using namespace android::hardware::configstore::V1_0;

extern "C" EGLAPI const char* eglQueryStringImplementationANDROID(EGLDisplay dpy, EGLint name);

// ---------------------------------------------------------------------------
@@ -70,13 +76,11 @@ std::unique_ptr<RenderEngine> RenderEngine::create(int hwcFormat, uint32_t featu
    contextAttributes.reserve(6);
    contextAttributes.push_back(EGL_CONTEXT_CLIENT_VERSION);
    contextAttributes.push_back(contextClientVersion);
#ifdef EGL_IMG_context_priority
    if (SurfaceFlinger::useContextPriority) {
    bool useContextPriority = overrideUseContextPriorityFromConfig(extensions.hasContextPriority());
    if (useContextPriority) {
        contextAttributes.push_back(EGL_CONTEXT_PRIORITY_LEVEL_IMG);
        contextAttributes.push_back(EGL_CONTEXT_PRIORITY_HIGH_IMG);
    }
#endif
    contextAttributes.push_back(EGL_NONE);
    contextAttributes.push_back(EGL_NONE);

    EGLContext ctxt = eglCreateContext(display, config, nullptr, contextAttributes.data());
@@ -131,6 +135,18 @@ std::unique_ptr<RenderEngine> RenderEngine::create(int hwcFormat, uint32_t featu
    return engine;
}

bool RenderEngine::overrideUseContextPriorityFromConfig(bool useContextPriority) {
    OptionalBool ret;
    ISurfaceFlingerConfigs::getService()->useContextPriority([&ret](OptionalBool b) {
        ret = b;
    });
    if (ret.specified) {
        return ret.value;
    } else {
        return useContextPriority;
    }
}

RenderEngine::RenderEngine()
      : mEGLDisplay(EGL_NO_DISPLAY), mEGLConfig(nullptr), mEGLContext(EGL_NO_CONTEXT) {}

+2 −0
Original line number Diff line number Diff line
@@ -66,6 +66,8 @@ class RenderEngine {
                                        uint32_t* status) = 0;
    virtual void unbindFramebuffer(uint32_t texName, uint32_t fbName) = 0;

    static bool overrideUseContextPriorityFromConfig(bool useContextPriority);

protected:
    RenderEngine();

+0 −5
Original line number Diff line number Diff line
@@ -129,7 +129,6 @@ const String16 sDump("android.permission.DUMP");
// ---------------------------------------------------------------------------
int64_t SurfaceFlinger::vsyncPhaseOffsetNs;
int64_t SurfaceFlinger::sfVsyncPhaseOffsetNs;
bool SurfaceFlinger::useContextPriority;
int64_t SurfaceFlinger::dispSyncPresentTimeOffset;
bool SurfaceFlinger::useHwcForRgbToYuv;
uint64_t SurfaceFlinger::maxVirtualDisplaySize;
@@ -207,9 +206,6 @@ SurfaceFlinger::SurfaceFlinger()
    hasSyncFramework = getBool< ISurfaceFlingerConfigs,
            &ISurfaceFlingerConfigs::hasSyncFramework>(true);

    useContextPriority = getBool< ISurfaceFlingerConfigs,
            &ISurfaceFlingerConfigs::useContextPriority>(false);

    dispSyncPresentTimeOffset = getInt64< ISurfaceFlingerConfigs,
            &ISurfaceFlingerConfigs::presentTimeOffsetFromVSyncNs>(0);

@@ -3692,7 +3688,6 @@ void SurfaceFlinger::logFrameStats() {
void SurfaceFlinger::appendSfConfigString(String8& result) const
{
    result.append(" [sf");
    result.appendFormat(" HAS_CONTEXT_PRIORITY=%d", useContextPriority);

    if (isLayerTripleBufferingDisabled())
        result.append(" DISABLE_TRIPLE_BUFFERING");
Loading