diff options
author | Jason Sams <rjsams@android.com> | 2010-09-16 18:18:29 -0700 |
---|---|---|
committer | Jason Sams <rjsams@android.com> | 2010-09-16 18:18:29 -0700 |
commit | d081fffab58b4cb8a36b7a083ab7793585bc1510 (patch) | |
tree | 2d4ea330edfd21499546fc0a9ae9d647d7a1ee0e | |
parent | a8bf9429b29743b3489817feb21bde2416acc465 (diff) | |
download | frameworks_base-d081fffab58b4cb8a36b7a083ab7793585bc1510.zip frameworks_base-d081fffab58b4cb8a36b7a083ab7793585bc1510.tar.gz frameworks_base-d081fffab58b4cb8a36b7a083ab7793585bc1510.tar.bz2 |
Cleanup GL setup code and remove legacy 1.1 paths.
Reset pointers to NULL when allocations are unbound.
Change-Id: Ifaba634ecbb154970b7fb47faa8e6475d16d2f66
-rw-r--r-- | libs/rs/rsAllocation.cpp | 5 | ||||
-rw-r--r-- | libs/rs/rsAllocation.h | 1 | ||||
-rw-r--r-- | libs/rs/rsContext.cpp | 25 | ||||
-rw-r--r-- | libs/rs/rsContext.h | 3 | ||||
-rw-r--r-- | libs/rs/rsProgramFragment.cpp | 11 | ||||
-rw-r--r-- | libs/rs/rsProgramFragment.h | 1 | ||||
-rw-r--r-- | libs/rs/rsProgramRaster.cpp | 46 | ||||
-rw-r--r-- | libs/rs/rsProgramRaster.h | 1 | ||||
-rw-r--r-- | libs/rs/rsProgramStore.cpp | 35 | ||||
-rw-r--r-- | libs/rs/rsProgramStore.h | 1 | ||||
-rw-r--r-- | libs/rs/rsProgramVertex.cpp | 5 | ||||
-rw-r--r-- | libs/rs/rsProgramVertex.h | 1 | ||||
-rw-r--r-- | libs/rs/rsSampler.cpp | 10 | ||||
-rw-r--r-- | libs/rs/rsSampler.h | 2 | ||||
-rw-r--r-- | libs/rs/rsScriptC.cpp | 11 | ||||
-rw-r--r-- | libs/rs/rsVertexArray.h | 1 |
16 files changed, 31 insertions, 128 deletions
diff --git a/libs/rs/rsAllocation.cpp b/libs/rs/rsAllocation.cpp index 60998c3..87c4f2b 100644 --- a/libs/rs/rsAllocation.cpp +++ b/libs/rs/rsAllocation.cpp @@ -724,10 +724,7 @@ RsAllocation rsi_AllocationCreateFromBitmap(Context *rsc, uint32_t w, uint32_t h const Element *src = static_cast<const Element *>(_src); const Element *dst = static_cast<const Element *>(_dst); - // Check for pow2 on pre es 2.0 versions. - rsAssert(rsc->checkVersion2_0() || (!(w & (w-1)) && !(h & (h-1)))); - - //LOGE("rsi_AllocationCreateFromBitmap %i %i %i %i %i", w, h, dstFmt, srcFmt, genMips); + //LOGE("%p rsi_AllocationCreateFromBitmap %i %i %i", rsc, w, h, genMips); rsi_TypeBegin(rsc, _dst); rsi_TypeAdd(rsc, RS_DIMENSION_X, w); rsi_TypeAdd(rsc, RS_DIMENSION_Y, h); diff --git a/libs/rs/rsAllocation.h b/libs/rs/rsAllocation.h index b6b5d2f..ce5372f 100644 --- a/libs/rs/rsAllocation.h +++ b/libs/rs/rsAllocation.h @@ -90,6 +90,7 @@ public: void decRefs(const void *ptr, size_t ct) const; void sendDirty() const; + bool getHasGraphicsMipmaps() const {return mTextureGenMipmap;} protected: ObjectBaseRef<const Type> mType; diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp index 5327aac..3dbdbfb 100644 --- a/libs/rs/rsContext.cpp +++ b/libs/rs/rsContext.cpp @@ -232,23 +232,15 @@ void Context::timerPrint() bool Context::setupCheck() { - if (checkVersion2_0()) { - if (!mShaderCache.lookup(this, mVertex.get(), mFragment.get())) { - LOGE("Context::setupCheck() 1 fail"); - return false; - } - - mFragmentStore->setupGL2(this, &mStateFragmentStore); - mFragment->setupGL2(this, &mStateFragment, &mShaderCache); - mRaster->setupGL2(this, &mStateRaster); - mVertex->setupGL2(this, &mStateVertex, &mShaderCache); - - } else { - mFragmentStore->setupGL(this, &mStateFragmentStore); - mFragment->setupGL(this, &mStateFragment); - mRaster->setupGL(this, &mStateRaster); - mVertex->setupGL(this, &mStateVertex); + if (!mShaderCache.lookup(this, mVertex.get(), mFragment.get())) { + LOGE("Context::setupCheck() 1 fail"); + return false; } + + mFragmentStore->setupGL2(this, &mStateFragmentStore); + mFragment->setupGL2(this, &mStateFragment, &mShaderCache); + mRaster->setupGL2(this, &mStateRaster); + mVertex->setupGL2(this, &mStateVertex, &mShaderCache); return true; } @@ -940,6 +932,7 @@ RsContext rsContextCreateGL(RsDevice vdev, uint32_t version, bool useDepth) LOGV("rsContextCreateGL %p, %i", vdev, useDepth); Device * dev = static_cast<Device *>(vdev); Context *rsc = new Context(dev, true, useDepth); + LOGV("rsContextCreateGL ret %p ", rsc); return rsc; } diff --git a/libs/rs/rsContext.h b/libs/rs/rsContext.h index 6d1a41d..e38ba55 100644 --- a/libs/rs/rsContext.h +++ b/libs/rs/rsContext.h @@ -153,9 +153,6 @@ public: void timerPrint(); void timerFrame(); - bool checkVersion1_1() const {return (mGL.mMajorVersion > 1) || (mGL.mMinorVersion >= 1); } - bool checkVersion2_0() const {return mGL.mMajorVersion >= 2; } - struct { bool mLogTimes; bool mLogScripts; diff --git a/libs/rs/rsProgramFragment.cpp b/libs/rs/rsProgramFragment.cpp index 3174e82..9817fca 100644 --- a/libs/rs/rsProgramFragment.cpp +++ b/libs/rs/rsProgramFragment.cpp @@ -103,13 +103,8 @@ void ProgramFragment::setConstantColor(float r, float g, float b, float a) mDirty = true; } -void ProgramFragment::setupGL(const Context *rsc, ProgramFragmentState *state) -{ -} - void ProgramFragment::setupGL2(const Context *rsc, ProgramFragmentState *state, ShaderCache *sc) { - //LOGE("sgl2 frag1 %x", glGetError()); if ((state->mLast.get() == this) && !mDirty) { return; @@ -131,12 +126,12 @@ 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, mTextures[ct]->getType()->getIsNp2()); + mSamplers[ct]->setupGL(rsc, mTextures[ct].get()); } else { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); rsc->checkError("ProgramFragment::setupGL2 tex env"); } diff --git a/libs/rs/rsProgramFragment.h b/libs/rs/rsProgramFragment.h index f08bb25..fb78b3f 100644 --- a/libs/rs/rsProgramFragment.h +++ b/libs/rs/rsProgramFragment.h @@ -34,7 +34,6 @@ public: uint32_t paramLength); virtual ~ProgramFragment(); - virtual void setupGL(const Context *, ProgramFragmentState *); virtual void setupGL2(const Context *, ProgramFragmentState *, ShaderCache *sc); virtual void createShader(); diff --git a/libs/rs/rsProgramRaster.cpp b/libs/rs/rsProgramRaster.cpp index 5b69370..62d060d 100644 --- a/libs/rs/rsProgramRaster.cpp +++ b/libs/rs/rsProgramRaster.cpp @@ -61,52 +61,6 @@ void ProgramRaster::setCullMode(RsCullMode mode) mDirty = true; } -void ProgramRaster::setupGL(const Context *rsc, ProgramRasterState *state) -{ - if (state->mLast.get() == this && !mDirty) { - return; - } - state->mLast.set(this); - mDirty = false; - - if (mPointSmooth) { - glEnable(GL_POINT_SMOOTH); - } else { - glDisable(GL_POINT_SMOOTH); - } - - glLineWidth(mLineWidth); - if (mLineSmooth) { - glEnable(GL_LINE_SMOOTH); - } else { - glDisable(GL_LINE_SMOOTH); - } - - if (rsc->checkVersion1_1()) { -#ifndef ANDROID_RS_BUILD_FOR_HOST - if (mPointSprite) { - glEnable(GL_POINT_SPRITE_OES); - } else { - glDisable(GL_POINT_SPRITE_OES); - } -#endif //ANDROID_RS_BUILD_FOR_HOST - } - - switch(mCull) { - case RS_CULL_BACK: - glEnable(GL_CULL_FACE); - glCullFace(GL_BACK); - break; - case RS_CULL_FRONT: - glEnable(GL_CULL_FACE); - glCullFace(GL_FRONT); - break; - case RS_CULL_NONE: - glDisable(GL_CULL_FACE); - break; - } -} - void ProgramRaster::setupGL2(const Context *rsc, ProgramRasterState *state) { if (state->mLast.get() == this && !mDirty) { diff --git a/libs/rs/rsProgramRaster.h b/libs/rs/rsProgramRaster.h index 801ab2a..d5ed686 100644 --- a/libs/rs/rsProgramRaster.h +++ b/libs/rs/rsProgramRaster.h @@ -34,7 +34,6 @@ public: bool pointSprite); virtual ~ProgramRaster(); - virtual void setupGL(const Context *, ProgramRasterState *); virtual void setupGL2(const Context *, ProgramRasterState *); virtual void serialize(OStream *stream) const; virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_PROGRAM_RASTER; } diff --git a/libs/rs/rsProgramStore.cpp b/libs/rs/rsProgramStore.cpp index e741c0a..3f90d7a 100644 --- a/libs/rs/rsProgramStore.cpp +++ b/libs/rs/rsProgramStore.cpp @@ -56,41 +56,6 @@ ProgramStore::~ProgramStore() { } -void ProgramStore::setupGL(const Context *rsc, ProgramStoreState *state) -{ - if (state->mLast.get() == this) { - return; - } - state->mLast.set(this); - - glColorMask(mColorRWriteEnable, - mColorGWriteEnable, - mColorBWriteEnable, - mColorAWriteEnable); - if (mBlendEnable) { - glEnable(GL_BLEND); - glBlendFunc(mBlendSrc, mBlendDst); - } else { - glDisable(GL_BLEND); - } - - //LOGE("pfs %i, %i, %x", mDepthWriteEnable, mDepthTestEnable, mDepthFunc); - - glDepthMask(mDepthWriteEnable); - if(mDepthTestEnable || mDepthWriteEnable) { - glEnable(GL_DEPTH_TEST); - glDepthFunc(mDepthFunc); - } else { - glDisable(GL_DEPTH_TEST); - } - - if (mDitherEnable) { - glEnable(GL_DITHER); - } else { - glDisable(GL_DITHER); - } -} - void ProgramStore::setupGL2(const Context *rsc, ProgramStoreState *state) { if (state->mLast.get() == this) { diff --git a/libs/rs/rsProgramStore.h b/libs/rs/rsProgramStore.h index fe8d78e..95bcf3c 100644 --- a/libs/rs/rsProgramStore.h +++ b/libs/rs/rsProgramStore.h @@ -32,7 +32,6 @@ public: ProgramStore(Context *); virtual ~ProgramStore(); - virtual void setupGL(const Context *, ProgramStoreState *); virtual void setupGL2(const Context *, ProgramStoreState *); void setDepthFunc(RsDepthFunc); diff --git a/libs/rs/rsProgramVertex.cpp b/libs/rs/rsProgramVertex.cpp index 28084d7..6446b55 100644 --- a/libs/rs/rsProgramVertex.cpp +++ b/libs/rs/rsProgramVertex.cpp @@ -68,11 +68,6 @@ static void logMatrix(const char *txt, const float *f) LOGV("%6.4f, %6.4f, %6.4f, %6.4f", f[3], f[7], f[11], f[15]); } -void ProgramVertex::setupGL(const Context *rsc, ProgramVertexState *state) -{ - assert(0); -} - void ProgramVertex::loadShader(Context *rsc) { Program::loadShader(rsc, GL_VERTEX_SHADER); } diff --git a/libs/rs/rsProgramVertex.h b/libs/rs/rsProgramVertex.h index d6b3f5a..65ce541 100644 --- a/libs/rs/rsProgramVertex.h +++ b/libs/rs/rsProgramVertex.h @@ -35,7 +35,6 @@ public: ProgramVertex(Context *, bool texMat); virtual ~ProgramVertex(); - virtual void setupGL(const Context *rsc, ProgramVertexState *state); virtual void setupGL2(const Context *rsc, ProgramVertexState *state, ShaderCache *sc); diff --git a/libs/rs/rsSampler.cpp b/libs/rs/rsSampler.cpp index 47b8a61..c6a848c 100644 --- a/libs/rs/rsSampler.cpp +++ b/libs/rs/rsSampler.cpp @@ -59,7 +59,7 @@ Sampler::~Sampler() { } -void Sampler::setupGL(const Context *rsc, bool npot) +void Sampler::setupGL(const Context *rsc, const Allocation *tex) { GLenum trans[] = { GL_NEAREST, //RS_SAMPLER_NEAREST, @@ -77,13 +77,17 @@ void Sampler::setupGL(const Context *rsc, bool npot) GL_CLAMP_TO_EDGE, //RS_SAMPLER_CLAMP }; - if (!rsc->ext_OES_texture_npot() && npot) { + if (!rsc->ext_OES_texture_npot() && tex->getType()->getIsNp2()) { 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]); + if (tex->getHasGraphicsMipmaps()) { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, trans[mMinFilter]); + } else { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, transNP[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]); diff --git a/libs/rs/rsSampler.h b/libs/rs/rsSampler.h index 3786439..32a8efd 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 *, bool npot); + void setupGL(const Context *, const Allocation *); void bindToContext(SamplerState *, uint32_t slot); void unbindFromContext(SamplerState *); diff --git a/libs/rs/rsScriptC.cpp b/libs/rs/rsScriptC.cpp index 662791d..cbc5df9 100644 --- a/libs/rs/rsScriptC.cpp +++ b/libs/rs/rsScriptC.cpp @@ -56,9 +56,16 @@ void ScriptC::setupScript(Context *rsc) = nanoseconds_to_milliseconds(systemTime(SYSTEM_TIME_MONOTONIC)); for (uint32_t ct=0; ct < mEnviroment.mFieldCount; ct++) { - if (!mSlots[ct].get()) + if (mSlots[ct].get() && !mTypes[ct].get()) { + mTypes[ct].set(mSlots[ct]->getType()); + } + + if (!mTypes[ct].get()) continue; - void *ptr = mSlots[ct]->getPtr(); + void *ptr = NULL; + if (mSlots[ct].get()) { + ptr = mSlots[ct]->getPtr(); + } void **dest = ((void ***)mEnviroment.mFieldAddress)[ct]; //LOGE("setupScript %i %p = %p %p %i", ct, dest, ptr, mSlots[ct]->getType(), mSlots[ct]->getType()->getDimX()); diff --git a/libs/rs/rsVertexArray.h b/libs/rs/rsVertexArray.h index 7c609b2..bd76d87 100644 --- a/libs/rs/rsVertexArray.h +++ b/libs/rs/rsVertexArray.h @@ -65,7 +65,6 @@ public: //void addLegacy(uint32_t type, uint32_t size, uint32_t stride, bool normalized, uint32_t offset); void add(uint32_t type, uint32_t size, uint32_t stride, bool normalized, uint32_t offset, const char *name); - void setupGL(const Context *rsc, class VertexArrayState *) const; void setupGL2(const Context *rsc, class VertexArrayState *, ShaderCache *) const; void logAttrib(uint32_t idx, uint32_t slot) const; |