Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6286953e authored by Jason Sams's avatar Jason Sams
Browse files

Change user attribs to look for empty slot rather than using them in order. ...

Change user attribs to look for empty slot rather than using them in order.  Prevents conflict with numbered legacy slots.
parent edc5189c
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -56,10 +56,10 @@ ProgramVertex::~ProgramVertex()
static void logMatrix(const char *txt, const float *f)
{
    LOGV("Matrix %s, %p", txt, f);
    LOGV("%6.2f, %6.2f, %6.2f, %6.2f", f[0], f[4], f[8], f[12]);
    LOGV("%6.2f, %6.2f, %6.2f, %6.2f", f[1], f[5], f[9], f[13]);
    LOGV("%6.2f, %6.2f, %6.2f, %6.2f", f[2], f[6], f[10], f[14]);
    LOGV("%6.2f, %6.2f, %6.2f, %6.2f", f[3], f[7], f[11], f[15]);
    LOGV("%6.4f, %6.4f, %6.4f, %6.4f", f[0], f[4], f[8], f[12]);
    LOGV("%6.4f, %6.4f, %6.4f, %6.4f", f[1], f[5], f[9], f[13]);
    LOGV("%6.4f, %6.4f, %6.4f, %6.4f", f[2], f[6], f[10], f[14]);
    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)
+8 −8
Original line number Diff line number Diff line
@@ -26,7 +26,6 @@ using namespace android::renderscript;
VertexArray::VertexArray()
{
    mActiveBuffer = 0;
    mUserCount = 0;
}

VertexArray::~VertexArray()
@@ -40,7 +39,6 @@ void VertexArray::clearAll()
        mAttribs[ct].clear();
    }
    mActiveBuffer = 0;
    mUserCount = 0;
}

VertexArray::Attrib::Attrib()
@@ -127,10 +125,13 @@ void VertexArray::setTexture(uint32_t size, uint32_t type, uint32_t stride, uint

void VertexArray::setUser(const Attrib &a, uint32_t stride)
{
    mAttribs[mUserCount].set(a);
    mAttribs[mUserCount].buffer = mActiveBuffer;
    mAttribs[mUserCount].stride = stride;
    mUserCount ++;
    // Find empty slot, some may be taken by legacy 1.1 slots.
    uint32_t slot = 0;
    while (mAttribs[slot].size) slot++;
    rsAssert(slot < RS_MAX_ATTRIBS);
    mAttribs[slot].set(a);
    mAttribs[slot].buffer = mActiveBuffer;
    mAttribs[slot].stride = stride;
}

void VertexArray::logAttrib(uint32_t idx, uint32_t slot) const {
@@ -215,9 +216,8 @@ void VertexArray::setupGL2(const Context *rsc, class VertexArrayState *state, Sh
    }

    for (uint32_t ct=0; ct < RS_MAX_ATTRIBS; ct++) {
        if (mAttribs[ct].size) {
        if (mAttribs[ct].size && (sc->vtxAttribSlot(ct) >= 0)) {
            //logAttrib(ct, sc->vtxAttribSlot(ct));
            rsAssert(sc->vtxAttribSlot(ct) >= 0);
            glEnableVertexAttribArray(sc->vtxAttribSlot(ct));
            glBindBuffer(GL_ARRAY_BUFFER, mAttribs[ct].buffer);

+0 −1
Original line number Diff line number Diff line
@@ -76,7 +76,6 @@ public:

protected:
    uint32_t mActiveBuffer;
    uint32_t mUserCount;
    Attrib mAttribs[RS_MAX_ATTRIBS];
};