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

Commit f9f0016b authored by Romain Guy's avatar Romain Guy
Browse files

Enable GPU pixel buffers on OpenGL ES 3.0 devices

Change-Id: I164d72ccd7a9bf6ae0e3f79dfef50083558937ba
parent 36e337f9
Loading
Loading
Loading
Loading
+13 −0
Original line number Original line Diff line number Diff line
@@ -52,6 +52,7 @@ Caches::Caches(): Singleton<Caches>(), mExtensions(Extensions::getInstance()), m
    initFont();
    initFont();
    initConstraints();
    initConstraints();
    initProperties();
    initProperties();
    initStaticProperties();
    initExtensions();
    initExtensions();


    mDebugLevel = readDebugLevel();
    mDebugLevel = readDebugLevel();
@@ -137,6 +138,18 @@ void Caches::initConstraints() {
    glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
    glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
}
}


void Caches::initStaticProperties() {
    gpuPixelBuffersEnabled = false;

    // OpenGL ES 3.0+ specific features
    if (mExtensions.getMajorGlVersion() >= 3) {
        char property[PROPERTY_VALUE_MAX];
        if (property_get(PROPERTY_ENABLE_GPU_PIXEL_BUFFERS, property, "true") > 0) {
            gpuPixelBuffersEnabled = !strcmp(property, "true");
        }
    }
}

bool Caches::initProperties() {
bool Caches::initProperties() {
    bool prevDebugLayersUpdates = debugLayersUpdates;
    bool prevDebugLayersUpdates = debugLayersUpdates;
    bool prevDebugOverdraw = debugOverdraw;
    bool prevDebugOverdraw = debugOverdraw;
+3 −0
Original line number Original line Diff line number Diff line
@@ -302,6 +302,8 @@ public:


    AssetAtlas assetAtlas;
    AssetAtlas assetAtlas;


    bool gpuPixelBuffersEnabled;

    // Debug methods
    // Debug methods
    PFNGLINSERTEVENTMARKEREXTPROC eventMark;
    PFNGLINSERTEVENTMARKEREXTPROC eventMark;
    PFNGLPUSHGROUPMARKEREXTPROC startMark;
    PFNGLPUSHGROUPMARKEREXTPROC startMark;
@@ -314,6 +316,7 @@ private:
    void initFont();
    void initFont();
    void initExtensions();
    void initExtensions();
    void initConstraints();
    void initConstraints();
    void initStaticProperties();


    static void eventMarkNull(GLsizei length, const GLchar* marker) { }
    static void eventMarkNull(GLsizei length, const GLchar* marker) { }
    static void startMarkNull(GLsizei length, const GLchar* marker) { }
    static void startMarkNull(GLsizei length, const GLchar* marker) { }
+2 −8
Original line number Original line Diff line number Diff line
@@ -147,15 +147,9 @@ void GpuPixelBuffer::upload(uint32_t x, uint32_t y, uint32_t width, uint32_t hei
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////


PixelBuffer* PixelBuffer::create(GLenum format, uint32_t width, uint32_t height, BufferType type) {
PixelBuffer* PixelBuffer::create(GLenum format, uint32_t width, uint32_t height, BufferType type) {
    bool gpuBuffer = type == kBufferType_Auto && Extensions::getInstance().getMajorGlVersion() >= 3;
    if (type == kBufferType_Auto && Caches::getInstance().gpuPixelBuffersEnabled) {
    if (gpuBuffer) {
        char property[PROPERTY_VALUE_MAX];
        if (property_get(PROPERTY_ENABLE_GPU_PIXEL_BUFFERS, property, "false") > 0) {
            if (!strcmp(property, "true")) {
        return new GpuPixelBuffer(format, width, height);
        return new GpuPixelBuffer(format, width, height);
    }
    }
        }
    }
    return new CpuPixelBuffer(format, width, height);
    return new CpuPixelBuffer(format, width, height);
}
}


+2 −2
Original line number Original line Diff line number Diff line
@@ -123,9 +123,9 @@ enum DebugLevel {


/**
/**
 * Indicates whether PBOs can be used to back pixel buffers.
 * Indicates whether PBOs can be used to back pixel buffers.
 * Accepted values are "true" and "false".
 * Accepted values are "true" and "false". Default is true.
 */
 */
#define PROPERTY_ENABLE_GPU_PIXEL_BUFFERS "hwui.use_gpu_pixel_buffers"
#define PROPERTY_ENABLE_GPU_PIXEL_BUFFERS "ro.hwui.use_gpu_pixel_buffers"


// These properties are defined in mega-bytes
// These properties are defined in mega-bytes
#define PROPERTY_TEXTURE_CACHE_SIZE "ro.hwui.texture_cache_size"
#define PROPERTY_TEXTURE_CACHE_SIZE "ro.hwui.texture_cache_size"