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

Commit 2961a0f0 authored by Arne Coucheron's avatar Arne Coucheron Committed by James Sullins
Browse files

surfacetexture: Add option for choosing texture target on old Adrenos

Commit 417d8925 removed a workaround for
old Adreno drivers which are not optimized for GL_TEXTURE_EXTERNAL_OES.
This causes performance issues for some platforms. Add a compile time
option to enable this.

Change-Id: I3389c7c4cc997b21d1ddb445262ac184ff37e598
parent 0a872611
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -141,7 +141,7 @@ public:
    //
    // This call may only be made while the OpenGL ES context to which the
    // target texture belongs is bound to the calling thread.
    status_t updateTexImage();
    status_t updateTexImage(bool isComposition = false);

    // setBufferCountServer set the buffer count. If the client has requested
    // a buffer count using setBufferCount, the server-buffer count will
@@ -506,7 +506,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 DECIDE_TEXTURE_TARGET
    GLenum mTexTarget;
#else
    const GLenum mTexTarget;
#endif

    // mFrameCounter is the free running counter, incremented for every buffer queued
    // with the surface Texture.
+4 −0
Original line number Diff line number Diff line
@@ -46,6 +46,10 @@ ifneq ($(BOARD_NO_ALLOW_DEQUEUE_CURRENT_BUFFER), true)
endif
endif

ifeq ($(BOARD_ADRENO_DECIDE_TEXTURE_TARGET),true)
    LOCAL_CFLAGS += -DDECIDE_TEXTURE_TARGET
endif

include $(BUILD_SHARED_LIBRARY)

ifeq (,$(ONE_SHOT_MAKEFILE))
+12 −1
Original line number Diff line number Diff line
@@ -849,7 +849,7 @@ status_t SurfaceTexture::setScalingMode(int mode) {
    return OK;
}

status_t SurfaceTexture::updateTexImage() {
status_t SurfaceTexture::updateTexImage(bool isComposition) {
    ST_LOGV("updateTexImage");
    Mutex::Autolock lock(mMutex);

@@ -879,6 +879,17 @@ status_t SurfaceTexture::updateTexImage() {
            mSlots[buf].mEglImage = image;
            mSlots[buf].mEglDisplay = dpy;

#ifdef DECIDE_TEXTURE_TARGET
            // 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.
+4 −0
Original line number Diff line number Diff line
@@ -53,6 +53,10 @@ LOCAL_SHARED_LIBRARIES += \
	libnvdispmgr_d
endif

ifeq ($(BOARD_ADRENO_DECIDE_TEXTURE_TARGET),true)
    LOCAL_CFLAGS += -DDECIDE_TEXTURE_TARGET
endif

LOCAL_C_INCLUDES := \
	$(call include-path-for, corecg graphics)

+35 −0
Original line number Diff line number Diff line
@@ -322,29 +322,54 @@ void Layer::onDraw(const Region& clip) const
	    clearWithOpenGL(clip, 0, 0, 0, 1);
        return;
	}

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

    if (!isProtected()) {
#ifdef DECIDE_TEXTURE_TARGET
        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 DECIDE_TEXTURE_TARGET
        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 DECIDE_TEXTURE_TARGET
        glEnable(currentTextureTarget);
#else
        glEnable(GL_TEXTURE_EXTERNAL_OES);
#endif
    } else {
#ifdef DECIDE_TEXTURE_TARGET
        glBindTexture(currentTextureTarget, mFlinger->getProtectedTexName());
#else
        glBindTexture(GL_TEXTURE_2D, mFlinger->getProtectedTexName());
#endif
        glMatrixMode(GL_TEXTURE);
        glLoadIdentity();
        glMatrixMode(GL_MODELVIEW);
#ifdef DECIDE_TEXTURE_TARGET
        glEnable(currentTextureTarget);
#else
        glDisable(GL_TEXTURE_EXTERNAL_OES);
        glEnable(GL_TEXTURE_2D);
#endif
    }

#ifdef QCOM_HARDWARE
@@ -476,7 +501,17 @@ void Layer::lockPageFlip(bool& recomputeVisibleRegions)
            mFlinger->signalEvent();
        }

#ifdef DECIDE_TEXTURE_TARGET
        // While calling updateTexImage() from SurfaceFlinger, let it know
        // by passing an extra parameter
        // This will be true always.

        bool isComposition = true;

        if (mSurfaceTexture->updateTexImage(isComposition) < NO_ERROR) {
#else
        if (mSurfaceTexture->updateTexImage() < NO_ERROR) {
#endif
            // something happened!
            recomputeVisibleRegions = true;
            return;