diff options
Diffstat (limited to 'libs/rs/rsProgramVertex.cpp')
-rw-r--r-- | libs/rs/rsProgramVertex.cpp | 90 |
1 files changed, 57 insertions, 33 deletions
diff --git a/libs/rs/rsProgramVertex.cpp b/libs/rs/rsProgramVertex.cpp index aee4133..8468e26 100644 --- a/libs/rs/rsProgramVertex.cpp +++ b/libs/rs/rsProgramVertex.cpp @@ -146,13 +146,24 @@ void ProgramVertex::createShader() // Cannot be complex rsAssert(!f->getFieldCount()); - switch(f->getComponent().getVectorSize()) { - case 1: mShader.append("uniform float UNI_"); break; - case 2: mShader.append("uniform vec2 UNI_"); break; - case 3: mShader.append("uniform vec3 UNI_"); break; - case 4: mShader.append("uniform vec4 UNI_"); break; - default: - rsAssert(0); + if(f->getType() == RS_TYPE_MATRIX_4X4) { + mShader.append("uniform mat4 UNI_"); + } + else if(f->getType() == RS_TYPE_MATRIX_3X3) { + mShader.append("uniform mat3 UNI_"); + } + else if(f->getType() == RS_TYPE_MATRIX_2X2) { + mShader.append("uniform mat2 UNI_"); + } + else { + switch(f->getComponent().getVectorSize()) { + case 1: mShader.append("uniform float UNI_"); break; + case 2: mShader.append("uniform vec2 UNI_"); break; + case 3: mShader.append("uniform vec3 UNI_"); break; + case 4: mShader.append("uniform vec4 UNI_"); break; + default: + rsAssert(0); + } } mShader.append(fn); @@ -250,41 +261,53 @@ void ProgramVertex::setupGL2(const Context *rsc, ProgramVertexState *state, Shad const Element *f = e->getField(field); uint32_t offset = e->getFieldOffsetBytes(field); int32_t slot = sc->vtxUniformSlot(uidx); + const char *fieldName = e->getFieldName(field); const float *fd = reinterpret_cast<const float *>(&data[offset]); - //LOGE("Uniform slot=%i, offset=%i, constant=%i, field=%i, uidx=%i", slot, offset, ct, field, uidx); + // If this field is padding, skip it + if(fieldName[0] == '#') { + continue; + } + + //LOGE("Uniform slot=%i, offset=%i, constant=%i, field=%i, uidx=%i, name=%s", slot, offset, ct, field, uidx, fieldName); if (slot >= 0) { - switch(f->getComponent().getVectorSize()) { - case 1: - //LOGE("Uniform 1 = %f", fd[0]); - glUniform1fv(slot, 1, fd); - break; - case 2: - //LOGE("Uniform 2 = %f %f", fd[0], fd[1]); - glUniform2fv(slot, 1, fd); - break; - case 3: - //LOGE("Uniform 3 = %f %f %f", fd[0], fd[1], fd[2]); - glUniform3fv(slot, 1, fd); - break; - case 4: - //LOGE("Uniform 4 = %f %f %f %f", fd[0], fd[1], fd[2], fd[3]); - glUniform4fv(slot, 1, fd); - break; - default: - rsAssert(0); + if(f->getType() == RS_TYPE_MATRIX_4X4) { + glUniformMatrix4fv(slot, 1, GL_FALSE, fd); + } + else if(f->getType() == RS_TYPE_MATRIX_3X3) { + glUniformMatrix3fv(slot, 1, GL_FALSE, fd); + } + else if(f->getType() == RS_TYPE_MATRIX_2X2) { + glUniformMatrix2fv(slot, 1, GL_FALSE, fd); + } + else { + switch(f->getComponent().getVectorSize()) { + case 1: + //LOGE("Uniform 1 = %f", fd[0]); + glUniform1fv(slot, 1, fd); + break; + case 2: + //LOGE("Uniform 2 = %f %f", fd[0], fd[1]); + glUniform2fv(slot, 1, fd); + break; + case 3: + //LOGE("Uniform 3 = %f %f %f", fd[0], fd[1], fd[2]); + glUniform3fv(slot, 1, fd); + break; + case 4: + //LOGE("Uniform 4 = %f %f %f %f", fd[0], fd[1], fd[2], fd[3]); + glUniform4fv(slot, 1, fd); + break; + default: + rsAssert(0); + } } } uidx ++; } } - for (uint32_t ct=0; ct < mConstantCount; ct++) { - uint32_t glSlot = sc->vtxUniformSlot(ct + 1); - - } - state->mLast.set(this); rsc->checkError("ProgramVertex::setupGL2"); } @@ -340,7 +363,8 @@ void ProgramVertex::initAddUserElement(const Element *e, String8 *names, uint32_ const Element *ce = e->getField(ct); if (ce->getFieldCount()) { initAddUserElement(ce, names, count, prefix); - } else { + } + else if(e->getFieldName(ct)[0] != '#') { String8 tmp(prefix); tmp.append(e->getFieldName(ct)); names[*count].setTo(tmp.string()); |