diff options
author | Jason Sams <rjsams@android.com> | 2010-02-22 15:37:51 -0800 |
---|---|---|
committer | Jason Sams <rjsams@android.com> | 2010-02-22 15:37:51 -0800 |
commit | 2978bfc6ad79c8f1138d34a704ce5b3d3d70d2c1 (patch) | |
tree | e87e3477880e64454f57cbc00cf22aea71e762a4 /libs/rs | |
parent | 33285c37abee6d95d0ac55cd7e9889cdc8d96d14 (diff) | |
download | frameworks_base-2978bfc6ad79c8f1138d34a704ce5b3d3d70d2c1.zip frameworks_base-2978bfc6ad79c8f1138d34a704ce5b3d3d70d2c1.tar.gz frameworks_base-2978bfc6ad79c8f1138d34a704ce5b3d3d70d2c1.tar.bz2 |
beging np2 extension check work.
Diffstat (limited to 'libs/rs')
-rw-r--r-- | libs/rs/rsContext.cpp | 2 | ||||
-rw-r--r-- | libs/rs/rsContext.h | 4 | ||||
-rw-r--r-- | libs/rs/rsProgramFragment.cpp | 4 | ||||
-rw-r--r-- | libs/rs/rsSampler.cpp | 14 | ||||
-rw-r--r-- | libs/rs/rsSampler.h | 2 | ||||
-rw-r--r-- | libs/rs/rsType.cpp | 18 | ||||
-rw-r--r-- | libs/rs/rsType.h | 2 |
7 files changed, 41 insertions, 5 deletions
diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp index dec993a..cc3a74f 100644 --- a/libs/rs/rsContext.cpp +++ b/libs/rs/rsContext.cpp @@ -546,6 +546,8 @@ void Context::setSurface(uint32_t w, uint32_t h, android_native_window_t *sur) glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &mGL.mMaxFragmentTextureImageUnits); glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_VECTORS, &mGL.mMaxFragmentUniformVectors); + + mGL.OES_texture_npot = NULL != strstr((const char *)mGL.mExtensions, "GL_OES_texture_npot"); } } diff --git a/libs/rs/rsContext.h b/libs/rs/rsContext.h index 03e65f1..04bd748 100644 --- a/libs/rs/rsContext.h +++ b/libs/rs/rsContext.h @@ -163,6 +163,8 @@ public: mutable const ObjectBase * mObjHead; + bool ext_OES_texture_npot() const {return mGL.OES_texture_npot;} + protected: Device *mDev; @@ -196,6 +198,8 @@ protected: int32_t mMaxVertexAttribs; int32_t mMaxVertexUniformVectors; int32_t mMaxVertexTextureUnits; + + bool OES_texture_npot; } mGL; uint32_t mWidth; diff --git a/libs/rs/rsProgramFragment.cpp b/libs/rs/rsProgramFragment.cpp index 15f3269..c17b94c 100644 --- a/libs/rs/rsProgramFragment.cpp +++ b/libs/rs/rsProgramFragment.cpp @@ -109,7 +109,7 @@ void ProgramFragment::setupGL(const Context *rsc, ProgramFragmentState *state) } if (mSamplers[ct].get()) { - mSamplers[ct]->setupGL(rsc); + mSamplers[ct]->setupGL(rsc, mTextures[ct]->getType()->getIsNp2()); } else { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); @@ -159,7 +159,7 @@ void ProgramFragment::setupGL2(const Context *rsc, ProgramFragmentState *state, glBindTexture(GL_TEXTURE_2D, mTextures[ct]->getTextureID()); rsc->checkError("ProgramFragment::setupGL2 tex bind"); if (mSamplers[ct].get()) { - mSamplers[ct]->setupGL(rsc); + mSamplers[ct]->setupGL(rsc, mTextures[ct]->getType()->getIsNp2()); } else { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); diff --git a/libs/rs/rsSampler.cpp b/libs/rs/rsSampler.cpp index 7552d54..71f508f 100644 --- a/libs/rs/rsSampler.cpp +++ b/libs/rs/rsSampler.cpp @@ -53,7 +53,7 @@ Sampler::~Sampler() { } -void Sampler::setupGL(const Context *rsc) +void Sampler::setupGL(const Context *rsc, bool npot) { GLenum trans[] = { GL_NEAREST, //RS_SAMPLER_NEAREST, @@ -64,11 +64,21 @@ void Sampler::setupGL(const Context *rsc) }; - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, trans[mMinFilter]); + 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); + } 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"); } diff --git a/libs/rs/rsSampler.h b/libs/rs/rsSampler.h index 9e20a2f..0506081 100644 --- a/libs/rs/rsSampler.h +++ b/libs/rs/rsSampler.h @@ -41,7 +41,7 @@ public: virtual ~Sampler(); void bind(Allocation *); - void setupGL(const Context *); + void setupGL(const Context *, bool npot); void bindToContext(SamplerState *, uint32_t slot); void unbindFromContext(SamplerState *); diff --git a/libs/rs/rsType.cpp b/libs/rs/rsType.cpp index 9d24c6c..c09e979 100644 --- a/libs/rs/rsType.cpp +++ b/libs/rs/rsType.cpp @@ -283,6 +283,24 @@ void Type::dumpLOGV(const char *prefix) const mElement->dumpLOGV(buf); } +bool Type::getIsNp2() const +{ + uint32_t x = getDimX(); + uint32_t y = getDimY(); + uint32_t z = getDimZ(); + + if (x && (x & (x-1))) { + return true; + } + if (y && (y & (y-1))) { + return true; + } + if (z && (z & (z-1))) { + return true; + } + return false; +} + ////////////////////////////////////////////////// // diff --git a/libs/rs/rsType.h b/libs/rs/rsType.h index 28e6274..c25577c 100644 --- a/libs/rs/rsType.h +++ b/libs/rs/rsType.h @@ -56,6 +56,7 @@ public: uint32_t getLODOffset(uint32_t lod, uint32_t x, uint32_t y, uint32_t z) const; uint32_t getLODCount() const {return mLODCount;} + bool getIsNp2() const; void setElement(const Element *e) {mElement.set(e);} @@ -65,6 +66,7 @@ public: void setDimFaces(bool v) {mFaces = v;} void setDimLOD(bool v) {mDimLOD = v;} + void clear(); void compute(); |