diff options
author | Jason Sams <rjsams@android.com> | 2010-01-27 14:41:43 -0800 |
---|---|---|
committer | Jason Sams <rjsams@android.com> | 2010-01-27 14:41:43 -0800 |
commit | 5dbfe93b3f15f3a837836d024958635fd8f9ad14 (patch) | |
tree | 7a86155c3054d0b7fe0d655e2f2dd21754b05330 /libs | |
parent | 445cc0e4bfd5b9460fb1cdccd22d8d54a49e5da1 (diff) | |
download | frameworks_base-5dbfe93b3f15f3a837836d024958635fd8f9ad14.zip frameworks_base-5dbfe93b3f15f3a837836d024958635fd8f9ad14.tar.gz frameworks_base-5dbfe93b3f15f3a837836d024958635fd8f9ad14.tar.bz2 |
Fix some minor bugs with GL state setup that were exposed by Droids driver.
Diffstat (limited to 'libs')
-rw-r--r-- | libs/rs/rsProgramFragment.cpp | 11 | ||||
-rw-r--r-- | libs/rs/rsProgramVertex.cpp | 2 | ||||
-rw-r--r-- | libs/rs/rsSampler.cpp | 9 | ||||
-rw-r--r-- | libs/rs/rsSampler.h | 4 | ||||
-rw-r--r-- | libs/rs/rsSimpleMesh.cpp | 2 | ||||
-rw-r--r-- | libs/rs/rsVertexArray.cpp | 8 | ||||
-rw-r--r-- | libs/rs/rsVertexArray.h | 1 |
7 files changed, 24 insertions, 13 deletions
diff --git a/libs/rs/rsProgramFragment.cpp b/libs/rs/rsProgramFragment.cpp index 00f19ae..15f3269 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(); + mSamplers[ct]->setupGL(rsc); } else { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); @@ -141,32 +141,35 @@ 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; } state->mLast.set(this); + rsc->checkError("ProgramFragment::setupGL2 start"); for (uint32_t ct=0; ct < MAX_TEXTURE; ct++) { glActiveTexture(GL_TEXTURE0 + ct); if (!(mTextureEnableMask & (1 << ct)) || !mTextures[ct].get()) { - glDisable(GL_TEXTURE_2D); continue; } mTextures[ct]->uploadCheck(rsc); glBindTexture(GL_TEXTURE_2D, mTextures[ct]->getTextureID()); + rsc->checkError("ProgramFragment::setupGL2 tex bind"); if (mSamplers[ct].get()) { - mSamplers[ct]->setupGL(); + mSamplers[ct]->setupGL(rsc); } 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); + rsc->checkError("ProgramFragment::setupGL2 tex env"); } - glEnable(GL_TEXTURE_2D); glUniform1i(sc->fragUniformSlot(ct), ct); + rsc->checkError("ProgramFragment::setupGL2 uniforms"); } glActiveTexture(GL_TEXTURE0); diff --git a/libs/rs/rsProgramVertex.cpp b/libs/rs/rsProgramVertex.cpp index 2c9bdaa..28f13d4 100644 --- a/libs/rs/rsProgramVertex.cpp +++ b/libs/rs/rsProgramVertex.cpp @@ -204,6 +204,7 @@ void ProgramVertex::setupGL2(const Context *rsc, ProgramVertexState *state, Shad //return; } + rsc->checkError("ProgramVertex::setupGL2 start"); glVertexAttrib4f(1, state->color[0], state->color[1], state->color[2], state->color[3]); const float *f = static_cast<const float *>(mConstants[0]->getPtr()); @@ -220,6 +221,7 @@ void ProgramVertex::setupGL2(const Context *rsc, ProgramVertexState *state, Shad &f[RS_PROGRAM_VERTEX_TEXTURE_OFFSET]); } + rsc->checkError("ProgramVertex::setupGL2 begin uniforms"); uint32_t uidx = 1; for (uint32_t ct=0; ct < mConstantCount; ct++) { Allocation *alloc = mConstants[ct+1].get(); diff --git a/libs/rs/rsSampler.cpp b/libs/rs/rsSampler.cpp index f9bdb2e..7552d54 100644 --- a/libs/rs/rsSampler.cpp +++ b/libs/rs/rsSampler.cpp @@ -53,7 +53,7 @@ Sampler::~Sampler() { } -void Sampler::setupGL() +void Sampler::setupGL(const Context *rsc) { GLenum trans[] = { GL_NEAREST, //RS_SAMPLER_NEAREST, @@ -69,6 +69,7 @@ void Sampler::setupGL() 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"); } void Sampler::bindToContext(SamplerState *ss, uint32_t slot) @@ -83,18 +84,18 @@ void Sampler::unbindFromContext(SamplerState *ss) mBoundSlot = -1; ss->mSamplers[slot].clear(); } - +/* void SamplerState::setupGL() { for (uint32_t ct=0; ct < RS_MAX_SAMPLER_SLOT; ct++) { Sampler *s = mSamplers[ct].get(); if (s) { - s->setupGL(); + s->setupGL(rsc); } else { glBindTexture(GL_TEXTURE_2D, 0); } } -} +}*/ //////////////////////////////// diff --git a/libs/rs/rsSampler.h b/libs/rs/rsSampler.h index ccf9b4d..9e20a2f 100644 --- a/libs/rs/rsSampler.h +++ b/libs/rs/rsSampler.h @@ -41,7 +41,7 @@ public: virtual ~Sampler(); void bind(Allocation *); - void setupGL(); + void setupGL(const Context *); void bindToContext(SamplerState *, uint32_t slot); void unbindFromContext(SamplerState *); @@ -74,7 +74,7 @@ public: ObjectBaseRef<Sampler> mSamplers[RS_MAX_SAMPLER_SLOT]; - void setupGL(); + //void setupGL(); }; diff --git a/libs/rs/rsSimpleMesh.cpp b/libs/rs/rsSimpleMesh.cpp index a819c07..53ce5cd 100644 --- a/libs/rs/rsSimpleMesh.cpp +++ b/libs/rs/rsSimpleMesh.cpp @@ -63,7 +63,7 @@ void SimpleMesh::renderRange(Context *rsc, uint32_t start, uint32_t len) const va.setActiveBuffer(mVertexBuffers[ct]->getBufferObjectID()); mVertexTypes[ct]->enableGLVertexBuffer2(&va); } - va.setupGL2(rsc, 0, &rsc->mShaderCache); + va.setupGL2(rsc, &rsc->mStateVertexArray, &rsc->mShaderCache); } else { for (uint32_t ct=0; ct < mVertexTypeCount; ct++) { mVertexBuffers[ct]->uploadCheck(rsc); diff --git a/libs/rs/rsVertexArray.cpp b/libs/rs/rsVertexArray.cpp index a1fd744..d0c0414 100644 --- a/libs/rs/rsVertexArray.cpp +++ b/libs/rs/rsVertexArray.cpp @@ -180,10 +180,12 @@ void VertexArray::setupGL(const Context *rsc, class VertexArrayState *state) con void VertexArray::setupGL2(const Context *rsc, class VertexArrayState *state, ShaderCache *sc) const { - for (int ct=1; ct < RS_MAX_ATTRIBS; ct++) { + rsc->checkError("VertexArray::setupGL2 start"); + for (uint32_t ct=1; ct <= state->mLastEnableCount; ct++) { glDisableVertexAttribArray(ct); } + rsc->checkError("VertexArray::setupGL2 disabled"); for (uint32_t ct=0; ct < mCount; ct++) { uint32_t slot = 0; if (sc->isUserVertexProgram()) { @@ -203,10 +205,12 @@ void VertexArray::setupGL2(const Context *rsc, class VertexArrayState *state, Sh mAttribs[ct].stride, (void *)mAttribs[ct].offset); } - rsc->checkError("VertexArray::setupGL2"); + state->mLastEnableCount = mCount; + rsc->checkError("VertexArray::setupGL2 done"); } //////////////////////////////////////////// void VertexArrayState::init(Context *) { + mLastEnableCount = 0; } diff --git a/libs/rs/rsVertexArray.h b/libs/rs/rsVertexArray.h index 66b3ab0..3904cb6 100644 --- a/libs/rs/rsVertexArray.h +++ b/libs/rs/rsVertexArray.h @@ -73,6 +73,7 @@ class VertexArrayState { public: void init(Context *); + uint32_t mLastEnableCount; //VertexArray::Attrib mAttribs[VertexArray::_LAST]; }; |