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

Commit 3ebb1ba5 authored by Alex Sakhartchouk's avatar Alex Sakhartchouk Committed by Android (Google) Code Review
Browse files

Merge "More robust attribute binding Adding attribute and uniform debug...

Merge "More robust attribute binding Adding attribute and uniform debug logging. Checking to see if aniso filtering is available."
parents e17c054d 4378f117
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -278,6 +278,8 @@ void * Context::threadProc(void *vrsc)
     rsc->props.mLogScripts = getProp("debug.rs.script");
     rsc->props.mLogObjects = getProp("debug.rs.object");
     rsc->props.mLogShaders = getProp("debug.rs.shader");
     rsc->props.mLogShadersAttr = getProp("debug.rs.shader.attributes");
     rsc->props.mLogShadersUniforms = getProp("debug.rs.shader.uniforms");
     rsc->props.mLogVisual = getProp("debug.rs.visual");

     ScriptTLSStruct *tlsStruct = new ScriptTLSStruct;
@@ -614,6 +616,11 @@ void Context::setSurface(uint32_t w, uint32_t h, ANativeWindow *sur)
            glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_VECTORS, &mGL.mMaxFragmentUniformVectors);

            mGL.OES_texture_npot = NULL != strstr((const char *)mGL.mExtensions, "GL_OES_texture_npot");
            mGL.EXT_texture_max_aniso = 1.0f;
            bool hasAniso = NULL != strstr((const char *)mGL.mExtensions, "GL_EXT_texture_filter_anisotropic");
            if(hasAniso) {
                glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &mGL.EXT_texture_max_aniso);
            }
        }

    }
+4 −0
Original line number Diff line number Diff line
@@ -158,6 +158,8 @@ public:
        bool mLogScripts;
        bool mLogObjects;
        bool mLogShaders;
        bool mLogShadersAttr;
        bool mLogShadersUniforms;
        bool mLogVisual;
    } props;

@@ -169,6 +171,7 @@ public:
    mutable const ObjectBase * mObjHead;

    bool ext_OES_texture_npot() const {return mGL.OES_texture_npot;}
    float ext_texture_max_aniso() const {return mGL.EXT_texture_max_aniso; }
    uint32_t getMaxFragmentTextures() const {return mGL.mMaxFragmentTextureImageUnits;}
    uint32_t getMaxFragmentUniformVectors() const {return mGL.mMaxFragmentUniformVectors;}
    uint32_t getMaxVertexUniformVectors() const {return mGL.mMaxVertexUniformVectors;}
@@ -209,6 +212,7 @@ protected:
        int32_t mMaxVertexTextureUnits;

        bool OES_texture_npot;
        float EXT_texture_max_aniso;
    } mGL;

    uint32_t mWidth;
+2 −2
Original line number Diff line number Diff line
@@ -575,8 +575,8 @@ void FontState::issueDrawCommand() {
    float *tex = vtx + 3;

    VertexArray va;
    va.add(GL_FLOAT, 3, 20, false, (uint32_t)vtx, "position");
    va.add(GL_FLOAT, 2, 20, false, (uint32_t)tex, "texture0");
    va.add(GL_FLOAT, 3, 20, false, (uint32_t)vtx, "ATTRIB_position");
    va.add(GL_FLOAT, 2, 20, false, (uint32_t)tex, "ATTRIB_texture0");
    va.setupGL2(mRSC, &mRSC->mStateVertexArray, &mRSC->mShaderCache);

    mIndexBuffer->uploadCheck(mRSC);
+33 −8
Original line number Diff line number Diff line
@@ -346,36 +346,61 @@ void Program::setupUserConstants(Context *rsc, ShaderCache *sc, bool isFragment)
                slot = sc->fragUniformSlot(uidx);
            }

            //LOGE("Uniform  slot=%i, offset=%i, constant=%i, field=%i, uidx=%i, name=%s", slot, offset, ct, field, uidx, fieldName);
            if(rsc->props.mLogShadersUniforms) {
                LOGV("Uniform  slot=%i, offset=%i, constant=%i, field=%i, uidx=%i, name=%s", slot, offset, ct, field, uidx, fieldName);
            }
            if (slot >= 0) {
                if(f->getType() == RS_TYPE_MATRIX_4X4) {
                    if(rsc->props.mLogShadersUniforms) {
                        LOGV("Matrix4x4");
                        LOGV("{%f, %f, %f, %f",  fd[0], fd[4], fd[8], fd[12]);
                        LOGV(" %f, %f, %f, %f",  fd[1], fd[5], fd[9], fd[13]);
                        LOGV(" %f, %f, %f, %f",  fd[2], fd[6], fd[10], fd[14]);
                        LOGV(" %f, %f, %f, %f}", fd[3], fd[7], fd[11], fd[15]);
                    }
                    glUniformMatrix4fv(slot, 1, GL_FALSE, fd);
                    /*for(int i = 0; i < 4; i++) {
                        LOGE("Mat = %f %f %f %f", fd[i*4 + 0], fd[i*4 + 1], fd[i*4 + 2], fd[i*4 + 3]);
                    }*/
                }
                else if(f->getType() == RS_TYPE_MATRIX_3X3) {
                    if(rsc->props.mLogShadersUniforms) {
                        LOGV("Matrix3x3");
                        LOGV("{%f, %f, %f",  fd[0], fd[3], fd[6]);
                        LOGV(" %f, %f, %f",  fd[1], fd[4], fd[7]);
                        LOGV(" %f, %f, %f}", fd[2], fd[5], fd[8]);
                    }
                    glUniformMatrix3fv(slot, 1, GL_FALSE, fd);
                }
                else if(f->getType() == RS_TYPE_MATRIX_2X2) {
                    if(rsc->props.mLogShadersUniforms){
                        LOGV("Matrix2x2");
                        LOGV("{%f, %f",  fd[0], fd[2]);
                        LOGV(" %f, %f}", fd[1], fd[3]);
                    }
                    glUniformMatrix2fv(slot, 1, GL_FALSE, fd);
                }
                else {
                    switch(f->getComponent().getVectorSize()) {
                    case 1:
                        //LOGE("Uniform 1 = %f", fd[0]);
                        if(rsc->props.mLogShadersUniforms) {
                            LOGV("Uniform 1 = %f", fd[0]);
                        }
                        glUniform1fv(slot, 1, fd);
                        break;
                    case 2:
                        //LOGE("Uniform 2 = %f %f", fd[0], fd[1]);
                        if(rsc->props.mLogShadersUniforms) {
                            LOGV("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]);
                        if(rsc->props.mLogShadersUniforms) {
                            LOGV("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]);
                        if(rsc->props.mLogShadersUniforms) {
                            LOGV("Uniform 4 = %f %f %f %f", fd[0], fd[1], fd[2], fd[3]);
                        }
                        glUniform4fv(slot, 1, fd);
                        break;
                    default:
+2 −0
Original line number Diff line number Diff line
@@ -26,6 +26,8 @@ namespace renderscript {
class ShaderCache;

#define RS_SHADER_INTERNAL "//rs_shader_internal\n"
#define RS_SHADER_ATTR "ATTRIB_"
#define RS_SHADER_UNI "UNI_"

class Program : public ObjectBase
{
Loading