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

Commit 82876a4d authored by Neti Ravi Kumar's avatar Neti Ravi Kumar Committed by Giulio Cervera
Browse files

Select texture target based on pixel format

Adreno is not optimized for GL_TEXTURE_EXTERNAL_OES, making GPU
utilization (and power), high with GL_TEXTURE_EXTERNAL_OES for
RGB formats.

Change texture target from GL_EXTERNAL_TEXTURE_OES to dynamically
select between GL_EXTERNAL_TEXTURE_OES, and GL_TEXTURE_2D based
on the pixel format.

This change is done to reduce the composition time for 8x55

Change-Id: I89ab1d60b23eef55442a9fd338b2a05b3304ce61
CRs-fixed: 328074
parent 5681005d
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -150,7 +150,7 @@ public:
    // GPU for composition). During these times "avoidBindTexture" can be
    // set to true. This will avoid binding textures for formats that are
    // not directly supported in hardware.
    status_t updateTexImage(bool avoidBindTexture = false);
    status_t updateTexImage(bool avoidBindTexture = false, bool isComposition  = false);
#endif

    // setBufferCountServer set the buffer count. If the client has requested
@@ -516,7 +516,11 @@ private:
    // glCopyTexSubImage to read from the texture.  This is a hack to work
    // around a GL driver limitation on the number of FBO attachments, which the
    // browser's tile cache exceeds.
#ifdef QCOM_HARDWARE
    GLenum mTexTarget;
#else
    const GLenum mTexTarget;
#endif

    // mFrameCounter is the free running counter, incremented for every buffer queued
    // with the surface Texture.
+13 −1
Original line number Diff line number Diff line
@@ -835,7 +835,7 @@ status_t SurfaceTexture::setScalingMode(int mode) {
}

#ifdef QCOM_HARDWARE
status_t SurfaceTexture::updateTexImage(bool avoidBindTexture) {
status_t SurfaceTexture::updateTexImage(bool avoidBindTexture, bool isComposition) {
#else
status_t SurfaceTexture::updateTexImage() {
#endif
@@ -869,6 +869,18 @@ status_t SurfaceTexture::updateTexImage() {
            image = createImage(dpy, mSlots[buf].mGraphicBuffer);
            mSlots[buf].mEglImage = image;
            mSlots[buf].mEglDisplay = dpy;

#ifdef QCOM_HARDWARE
                // GPU is not efficient in handling GL_TEXTURE_EXTERNAL_OES
                // texture target. Depending on the image format, decide,
                // the texture target to be used

                if (isComposition) {
                mTexTarget =
                   decideTextureTarget (mSlots[buf].mGraphicBuffer->format);
                }
#endif

            if (image == EGL_NO_IMAGE_KHR) {
                // NOTE: if dpy was invalid, createImage() is guaranteed to
                // fail. so we'd end up here.
+30 −1
Original line number Diff line number Diff line
@@ -311,29 +311,52 @@ void Layer::onDraw(const Region& clip) const
	    clearWithOpenGL(clip, 0, 0, 0, 1);
        return;
	}

    GLuint currentTextureTarget = mSurfaceTexture->getCurrentTextureTarget();
#endif

    if (!isProtected()) {
#ifdef QCOM_HARDWARE
        glBindTexture(currentTextureTarget, mTextureName);
#else
        glBindTexture(GL_TEXTURE_EXTERNAL_OES, mTextureName);
#endif
        GLenum filter = GL_NEAREST;
        if (getFiltering() || needsFiltering() || isFixedSize() || isCropped()) {
            // TODO: we could be more subtle with isFixedSize()
            filter = GL_LINEAR;
        }
#ifdef QCOM_HARDWARE
        glTexParameterx(currentTextureTarget, GL_TEXTURE_MAG_FILTER, filter);
        glTexParameterx(currentTextureTarget, GL_TEXTURE_MIN_FILTER, filter);
#else
        glTexParameterx(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, filter);
        glTexParameterx(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, filter);
#endif
        glMatrixMode(GL_TEXTURE);
        glLoadMatrixf(mTextureMatrix);
        glMatrixMode(GL_MODELVIEW);
        glDisable(GL_TEXTURE_2D);
#ifdef QCOM_HARDWARE
        glEnable(currentTextureTarget);
#else
        glEnable(GL_TEXTURE_EXTERNAL_OES);
#endif
    } else {
#ifdef QCOM_HARDWARE
        glBindTexture(currentTextureTarget, mFlinger->getProtectedTexName());
#else
        glBindTexture(GL_TEXTURE_2D, mFlinger->getProtectedTexName());
#endif
        glMatrixMode(GL_TEXTURE);
        glLoadIdentity();
        glMatrixMode(GL_MODELVIEW);
#ifdef QCOM_HARDWARE
        glEnable(currentTextureTarget);
#else
        glDisable(GL_TEXTURE_EXTERNAL_OES);
        glEnable(GL_TEXTURE_2D);
#endif
    }

    drawWithOpenGL(clip);
@@ -454,7 +477,13 @@ void Layer::lockPageFlip(bool& recomputeVisibleRegions)
        bool avoidTex = (hw.getFlags() & DisplayHardware::MDP_COMPOSITION) ?
                          true : false;

        if (mSurfaceTexture->updateTexImage(avoidTex) < NO_ERROR) {
        // While calling updateTexImage() from SurfaceFlinger, let it know
        // by passing an extra parameter
        // This will be true always.

        bool isComposition = true;

        if (mSurfaceTexture->updateTexImage(avoidTex, isComposition) < NO_ERROR) {
#else
        if (mSurfaceTexture->updateTexImage() < NO_ERROR) {
#endif