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

Commit 6c15ffa1 authored by Chris Craik's avatar Chris Craik
Browse files

Refactoring of Program ownership/lifecycle, and WIP Glop rendering path

Change-Id: I2549032790bddbc048b0bccc224ed8f386b4517c
parent 44eb2c00
Loading
Loading
Loading
Loading
+18 −3
Original line number Diff line number Diff line
@@ -72,9 +72,8 @@ bool Caches::init() {

    ATRACE_NAME("Caches::init");


    mRegionMesh = nullptr;
    currentProgram = nullptr;
    mProgram = nullptr;

    mFunctorsCount = 0;

@@ -200,7 +199,7 @@ void Caches::terminate() {
    fboCache.clear();

    programCache.clear();
    currentProgram = nullptr;
    setProgram(nullptr);

    patchCache.clear();

@@ -213,6 +212,22 @@ void Caches::terminate() {
    mInitialized = false;
}

void Caches::setProgram(const ProgramDescription& description) {
    setProgram(programCache.get(description));
}

void Caches::setProgram(Program* program) {
    if (!program || !program->isInUse()) {
        if (mProgram) {
            mProgram->remove();
        }
        if (program) {
            program->use();
        }
        mProgram = program;
    }
}

///////////////////////////////////////////////////////////////////////////////
// Debug
///////////////////////////////////////////////////////////////////////////////
+10 −6
Original line number Diff line number Diff line
@@ -162,8 +162,6 @@ public:
    void registerFunctors(uint32_t functorCount);
    void unregisterFunctors(uint32_t functorCount);

    Program* currentProgram;

    bool drawDeferDisabled;
    bool drawReorderDisabled;

@@ -219,6 +217,10 @@ public:
    int propertyAmbientShadowStrength;
    int propertySpotShadowStrength;

    void setProgram(const ProgramDescription& description);
    void setProgram(Program* program);

    Program& program() { return *mProgram; }
    PixelBufferState& pixelBufferState() { return *mPixelBufferState; }
    TextureState& textureState() { return *mTextureState; }

@@ -246,10 +248,6 @@ private:
    }

    RenderState* mRenderState;

    PixelBufferState* mPixelBufferState = nullptr; // TODO: move to RenderState
    TextureState* mTextureState = nullptr; // TODO: move to RenderState

    Extensions& mExtensions;

    // Used to render layers
@@ -264,6 +262,12 @@ private:
    uint32_t mFunctorsCount;

    OverdrawColorSet mOverdrawDebugColorSet;

    // TODO: move below to RenderState
    PixelBufferState* mPixelBufferState = nullptr;
    TextureState* mTextureState = nullptr;
    Program* mProgram = nullptr; // note: object owned by ProgramCache

}; // class Caches

}; // namespace uirenderer
+2 −2
Original line number Diff line number Diff line
@@ -89,13 +89,13 @@ void Dither::clear() {
// Program management
///////////////////////////////////////////////////////////////////////////////

void Dither::setupProgram(Program* program, GLuint* textureUnit) {
void Dither::setupProgram(Program& program, GLuint* textureUnit) {
    GLuint textureSlot = (*textureUnit)++;
    mCaches.textureState().activateTexture(textureSlot);

    bindDitherTexture();

    glUniform1i(program->getUniform("ditherSampler"), textureSlot);
    glUniform1i(program.getUniform("ditherSampler"), textureSlot);
}

}; // namespace uirenderer
+1 −1
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ public:
    Dither(Caches& caches);

    void clear();
    void setupProgram(Program* program, GLuint* textureUnit);
    void setupProgram(Program& program, GLuint* textureUnit);

private:
    void bindDitherTexture();
+2 −3
Original line number Diff line number Diff line
@@ -516,9 +516,8 @@ void FontRenderer::issueDrawCommand(Vector<CacheTexture*>& cacheTextures) {

            TextureVertex* mesh = texture->mesh();
            MeshState& meshState = renderState.meshState();
            Program* program = caches.currentProgram;
            meshState.bindPositionVertexPointer(program, forceRebind, &mesh[0].x);
            meshState.bindTexCoordsVertexPointer(program, forceRebind, &mesh[0].u);
            meshState.bindPositionVertexPointer(forceRebind, &mesh[0].x);
            meshState.bindTexCoordsVertexPointer(forceRebind, &mesh[0].u);

            glDrawElements(GL_TRIANGLES, texture->meshElementCount(),
                    GL_UNSIGNED_SHORT, texture->indices());
Loading