summaryrefslogtreecommitdiff
path: root/libs/rs/rsVertexArray.cpp
diff options
context:
space:
mode:
author Alex Sakhartchouk <alexst@google.com> 2010-12-13 15:24:20 -0800
committer Android (Google) Code Review <android-gerrit@google.com> 2010-12-13 15:24:20 -0800
commit271290dc4645b4d3e78f1555888d8683e45c3bba (patch)
tree3dfebfc6adaeb20f707fa6323f7d85a44aa5b937 /libs/rs/rsVertexArray.cpp
parentc0734f6c8d67deab00b10bd0bb75516cd1502dc0 (diff)
parent6b5222dd5334ebd8c8b641fa507776714505d198 (diff)
Merge "Perf test"
Diffstat (limited to 'libs/rs/rsVertexArray.cpp')
-rw-r--r--libs/rs/rsVertexArray.cpp30
1 files changed, 24 insertions, 6 deletions
diff --git a/libs/rs/rsVertexArray.cpp b/libs/rs/rsVertexArray.cpp
index 8a9fafea1963..d9393fe303af 100644
--- a/libs/rs/rsVertexArray.cpp
+++ b/libs/rs/rsVertexArray.cpp
@@ -81,8 +81,12 @@ void VertexArray::setupGL2(const Context *rsc,
class VertexArrayState *state,
ShaderCache *sc) const {
rsc->checkError("VertexArray::setupGL2 start");
- for (uint32_t ct=1; ct <= state->mLastEnableCount; ct++) {
- glDisableVertexAttribArray(ct);
+ uint32_t maxAttrs = state->mAttrsEnabledSize;
+ for (uint32_t ct=1; ct < maxAttrs; ct++) {
+ if(state->mAttrsEnabled[ct]) {
+ glDisableVertexAttribArray(ct);
+ state->mAttrsEnabled[ct] = false;
+ }
}
rsc->checkError("VertexArray::setupGL2 disabled");
@@ -91,10 +95,11 @@ void VertexArray::setupGL2(const Context *rsc,
if (rsc->props.mLogShadersAttr) {
logAttrib(ct, slot);
}
- if (slot < 0) {
+ if (slot < 0 || slot >= (int32_t)maxAttrs) {
continue;
}
glEnableVertexAttribArray(slot);
+ state->mAttrsEnabled[slot] = true;
glBindBuffer(GL_ARRAY_BUFFER, mAttribs[ct].buffer);
glVertexAttribPointer(slot,
mAttribs[ct].size,
@@ -103,12 +108,25 @@ void VertexArray::setupGL2(const Context *rsc,
mAttribs[ct].stride,
mAttribs[ct].ptr + mAttribs[ct].offset);
}
- state->mLastEnableCount = mCount;
rsc->checkError("VertexArray::setupGL2 done");
}
////////////////////////////////////////////
+VertexArrayState::VertexArrayState() {
+ mAttrsEnabled = NULL;
+ mAttrsEnabledSize = 0;
+}
-void VertexArrayState::init(Context *) {
- mLastEnableCount = 0;
+VertexArrayState::~VertexArrayState() {
+ if (mAttrsEnabled) {
+ delete[] mAttrsEnabled;
+ mAttrsEnabled = NULL;
+ }
+}
+void VertexArrayState::init(Context *rsc) {
+ mAttrsEnabledSize = rsc->getMaxVertexAttributes();
+ mAttrsEnabled = new bool[mAttrsEnabledSize];
+ for (uint32_t ct = 0; ct < mAttrsEnabledSize; ct++) {
+ mAttrsEnabled[ct] = false;
+ }
}