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

Commit cfc04366 authored by Jason Sams's avatar Jason Sams
Browse files

Fix partial NP2 support and restrict mipmaps and clamp

modes on HW that does not support proper NP2
bug 2965170

Change-Id: If9a3ac45264861fc75b9616e98957e12a5464411
parent 213fc950
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -784,14 +784,14 @@ nScriptBindAllocation(JNIEnv *_env, jobject _this, RsContext con, jint script, j
static void
nScriptSetVarI(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slot, jint val)
{
    LOG_API("nScriptSetVarI, con(%p), s(%p), slot(%i), val(%i), b(%f), a(%f)", con, (void *)script, slot, val);
    LOG_API("nScriptSetVarI, con(%p), s(%p), slot(%i), val(%i)", con, (void *)script, slot, val);
    rsScriptSetVarI(con, (RsScript)script, slot, val);
}

static void
nScriptSetVarF(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slot, float val)
{
    LOG_API("nScriptSetVarI, con(%p), s(%p), slot(%i), val(%i), b(%f), a(%f)", con, (void *)script, slot, val);
    LOG_API("nScriptSetVarI, con(%p), s(%p), slot(%i), val(%f)", con, (void *)script, slot, val);
    rsScriptSetVarF(con, (RsScript)script, slot, val);
}

+7 −7
Original line number Diff line number Diff line
@@ -88,7 +88,7 @@ void Context::initEGL(bool useGL2)
    configAttribsPtr[0] = EGL_NONE;
    rsAssert(configAttribsPtr < (configAttribs + (sizeof(configAttribs) / sizeof(EGLint))));

    LOGV("initEGL start");
    LOGV("%p initEGL start", this);
    mEGL.mDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
    checkEglError("eglGetDisplay");

@@ -97,7 +97,7 @@ void Context::initEGL(bool useGL2)

    status_t err = EGLUtils::selectConfigForNativeWindow(mEGL.mDisplay, configAttribs, mWndSurface, &mEGL.mConfig);
    if (err) {
       LOGE("couldn't find an EGLConfig matching the screen format\n");
       LOGE("%p, couldn't find an EGLConfig matching the screen format\n", this);
    }
    //eglChooseConfig(mEGL.mDisplay, configAttribs, &mEGL.mConfig, 1, &mEGL.mNumConfigs);

@@ -109,14 +109,14 @@ void Context::initEGL(bool useGL2)
    }
    checkEglError("eglCreateContext");
    if (mEGL.mContext == EGL_NO_CONTEXT) {
        LOGE("eglCreateContext returned EGL_NO_CONTEXT");
        LOGE("%p, eglCreateContext returned EGL_NO_CONTEXT", this);
    }
    gGLContextCount++;
}

void Context::deinitEGL()
{
    LOGV("deinitEGL");
    LOGV("%p, deinitEGL", this);
    setSurface(0, 0, NULL);
    eglDestroyContext(mEGL.mDisplay, mEGL.mContext);
    checkEglError("eglDestroyContext");
@@ -150,7 +150,7 @@ void Context::checkError(const char *msg) const
{
    GLenum err = glGetError();
    if (err != GL_NO_ERROR) {
        LOGE("GL Error, 0x%x, from %s", err, msg);
        LOGE("%p, GL Error, 0x%x, from %s", this, err, msg);
    }
}

@@ -348,7 +348,7 @@ void * Context::threadProc(void *vrsc)
         }
     }

     LOGV("RS Thread exiting");
     LOGV("%p, RS Thread exiting", rsc);
     if (rsc->mIsGraphicsContext) {
         rsc->mRaster.clear();
         rsc->mFragment.clear();
@@ -370,7 +370,7 @@ void * Context::threadProc(void *vrsc)
         pthread_mutex_unlock(&gInitMutex);
     }

     LOGV("RS Thread exited");
     LOGV("%p, RS Thread exited", rsc);
     return NULL;
}

+16 −12
Original line number Diff line number Diff line
@@ -67,25 +67,29 @@ void Sampler::setupGL(const Context *rsc, bool npot)
        GL_LINEAR_MIPMAP_LINEAR, //RS_SAMPLER_LINEAR_MIP_LINEAR,
        GL_REPEAT, //RS_SAMPLER_WRAP,
        GL_CLAMP_TO_EDGE, //RS_SAMPLER_CLAMP
    };

    GLenum transNP[] = {
        GL_NEAREST, //RS_SAMPLER_NEAREST,
        GL_LINEAR, //RS_SAMPLER_LINEAR,
        GL_LINEAR, //RS_SAMPLER_LINEAR_MIP_LINEAR,
        GL_CLAMP_TO_EDGE, //RS_SAMPLER_WRAP,
        GL_CLAMP_TO_EDGE, //RS_SAMPLER_CLAMP
    };

    bool forceNonMip = false;
    if (!rsc->ext_OES_texture_npot() && npot) {
        forceNonMip = true;
    }

    if ((mMinFilter == RS_SAMPLER_LINEAR_MIP_LINEAR) && forceNonMip) {
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, transNP[mMinFilter]);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, transNP[mMagFilter]);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, transNP[mWrapS]);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, transNP[mWrapT]);
    } else {
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, trans[mMinFilter]);
    }
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, trans[mMagFilter]);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, trans[mWrapS]);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, trans[mWrapT]);
    }


    rsc->checkError("ProgramFragment::setupGL2 tex env");
    rsc->checkError("Sampler::setupGL2 tex env");
}

void Sampler::bindToContext(SamplerState *ss, uint32_t slot)