Fix partial NP2 support and restrict mipmaps and clamp
modes on HW that does not support proper NP2
bug 2965170
Change-Id: If9a3ac45264861fc75b9616e98957e12a5464411
diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp
index f67a9d5..5327aac 100644
--- a/libs/rs/rsContext.cpp
+++ b/libs/rs/rsContext.cpp
@@ -88,7 +88,7 @@
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 @@
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 @@
}
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 @@
{
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 @@
}
}
- LOGV("RS Thread exiting");
+ LOGV("%p, RS Thread exiting", rsc);
if (rsc->mIsGraphicsContext) {
rsc->mRaster.clear();
rsc->mFragment.clear();
@@ -370,7 +370,7 @@
pthread_mutex_unlock(&gInitMutex);
}
- LOGV("RS Thread exited");
+ LOGV("%p, RS Thread exited", rsc);
return NULL;
}
diff --git a/libs/rs/rsSampler.cpp b/libs/rs/rsSampler.cpp
index f41f295..47b8a61 100644
--- a/libs/rs/rsSampler.cpp
+++ b/libs/rs/rsSampler.cpp
@@ -67,25 +67,29 @@
GL_LINEAR_MIPMAP_LINEAR, //RS_SAMPLER_LINEAR_MIP_LINEAR,
GL_REPEAT, //RS_SAMPLER_WRAP,
GL_CLAMP_TO_EDGE, //RS_SAMPLER_CLAMP
-
};
- bool forceNonMip = false;
- if (!rsc->ext_OES_texture_npot() && npot) {
- forceNonMip = true;
- }
+ 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
+ };
- if ((mMinFilter == RS_SAMPLER_LINEAR_MIP_LINEAR) && forceNonMip) {
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ if (!rsc->ext_OES_texture_npot() && npot) {
+ 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]);
}
- 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)
@@ -103,7 +107,7 @@
void Sampler::serialize(OStream *stream) const
{
-
+
}
Sampler *Sampler::createFromStream(Context *rsc, IStream *stream)