Merge "beging np2 extension check work."
This commit is contained in:
@@ -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");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
@@ -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 *);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user