diff options
author | John Reck <jreck@google.com> | 2017-07-17 09:55:02 -0700 |
---|---|---|
committer | John Reck <jreck@google.com> | 2017-07-19 17:24:03 -0700 |
commit | 8dc02f99d09130ace2ee738c2e689db1b3f33181 (patch) | |
tree | fc3ea85ec012dd56ddad8791460352c7d1e6d7c1 | |
parent | e3a9b8a3505e127143075de876de5e13d3677e46 (diff) |
Delete all ro.hwui.* props
Remove all ro.hwui.* tuning props and instead
calculate them from the screen resolution.
Or just hardcode them to what all devices
were hardcoding them to anyway.
Bug: 63741221
Test: Check cache size results on sailfish
Change-Id: I8b0d210572a246f4fefb076935cf5156a70c274c
-rw-r--r-- | libs/hwui/Caches.cpp | 10 | ||||
-rw-r--r-- | libs/hwui/Caches.h | 7 | ||||
-rw-r--r-- | libs/hwui/DeviceInfo.cpp | 12 | ||||
-rw-r--r-- | libs/hwui/DeviceInfo.h | 13 | ||||
-rw-r--r-- | libs/hwui/FboCache.cpp | 2 | ||||
-rw-r--r-- | libs/hwui/FontRenderer.cpp | 23 | ||||
-rw-r--r-- | libs/hwui/GradientCache.cpp | 7 | ||||
-rw-r--r-- | libs/hwui/GradientCache.h | 2 | ||||
-rw-r--r-- | libs/hwui/PatchCache.cpp | 2 | ||||
-rw-r--r-- | libs/hwui/PathCache.cpp | 17 | ||||
-rw-r--r-- | libs/hwui/ProgramCache.cpp | 2 | ||||
-rw-r--r-- | libs/hwui/ProgramCache.h | 2 | ||||
-rw-r--r-- | libs/hwui/Properties.cpp | 38 | ||||
-rw-r--r-- | libs/hwui/Properties.h | 89 | ||||
-rw-r--r-- | libs/hwui/RenderBufferCache.cpp | 10 | ||||
-rw-r--r-- | libs/hwui/TessellationCache.cpp | 2 | ||||
-rw-r--r-- | libs/hwui/TextDropShadowCache.cpp | 2 | ||||
-rw-r--r-- | libs/hwui/TextureCache.cpp | 10 | ||||
-rw-r--r-- | libs/hwui/font/FontUtil.h | 5 | ||||
-rw-r--r-- | libs/hwui/renderstate/OffscreenBufferPool.cpp | 4 | ||||
-rw-r--r-- | libs/hwui/renderstate/RenderState.cpp | 13 | ||||
-rw-r--r-- | libs/hwui/renderstate/RenderState.h | 4 | ||||
-rw-r--r-- | libs/hwui/renderstate/Stencil.cpp | 2 | ||||
-rw-r--r-- | libs/hwui/tests/unit/OffscreenBufferPoolTests.cpp | 4 |
24 files changed, 92 insertions, 190 deletions
diff --git a/libs/hwui/Caches.cpp b/libs/hwui/Caches.cpp index 2fdfcd42a1e1..0700d1fb9f70 100644 --- a/libs/hwui/Caches.cpp +++ b/libs/hwui/Caches.cpp @@ -50,9 +50,9 @@ Caches* Caches::sInstance = nullptr; /////////////////////////////////////////////////////////////////////////////// Caches::Caches(RenderState& renderState) - : gradientCache(mExtensions) + : gradientCache(extensions()) , patchCache(renderState) - , programCache(mExtensions) + , programCache(extensions()) , mRenderState(&renderState) , mInitialized(false) { INIT_LOGD("Creating OpenGL renderer caches"); @@ -80,7 +80,7 @@ bool Caches::init() { } void Caches::initExtensions() { - if (mExtensions.hasDebugMarker()) { + if (extensions().hasDebugMarker()) { eventMark = glInsertEventMarkerEXT; startMark = glPushGroupMarkerEXT; @@ -93,12 +93,12 @@ void Caches::initExtensions() { } void Caches::initConstraints() { - glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize); + maxTextureSize = DeviceInfo::get()->maxTextureSize(); } void Caches::initStaticProperties() { // OpenGL ES 3.0+ specific features - gpuPixelBuffersEnabled = mExtensions.hasPixelBufferObjects() + gpuPixelBuffersEnabled = extensions().hasPixelBufferObjects() && property_get_bool(PROPERTY_ENABLE_GPU_PIXEL_BUFFERS, true); } diff --git a/libs/hwui/Caches.h b/libs/hwui/Caches.h index 19063e3768cd..29eddde1e42b 100644 --- a/libs/hwui/Caches.h +++ b/libs/hwui/Caches.h @@ -16,6 +16,7 @@ #pragma once +#include "DeviceInfo.h" #include "Extensions.h" #include "FboCache.h" #include "GammaFontRenderer.h" @@ -145,10 +146,6 @@ public: // Misc GLint maxTextureSize; -private: - // Declared before gradientCache and programCache which need this to initialize. - // TODO: cleanup / move elsewhere - Extensions mExtensions; public: TextureCache textureCache; RenderBufferCache renderBufferCache; @@ -174,7 +171,7 @@ public: void setProgram(const ProgramDescription& description); void setProgram(Program* program); - const Extensions& extensions() const { return mExtensions; } + const Extensions& extensions() const { return DeviceInfo::get()->extensions(); } Program& program() { return *mProgram; } PixelBufferState& pixelBufferState() { return *mPixelBufferState; } TextureState& textureState() { return *mTextureState; } diff --git a/libs/hwui/DeviceInfo.cpp b/libs/hwui/DeviceInfo.cpp index d180ba51b304..37965daf9a8d 100644 --- a/libs/hwui/DeviceInfo.cpp +++ b/libs/hwui/DeviceInfo.cpp @@ -16,7 +16,8 @@ #include <DeviceInfo.h> -#include "Extensions.h" +#include <gui/ISurfaceComposer.h> +#include <gui/SurfaceComposerClient.h> #include <thread> #include <mutex> @@ -46,13 +47,22 @@ void DeviceInfo::initialize() { void DeviceInfo::initialize(int maxTextureSize) { std::call_once(sInitializedFlag, [maxTextureSize]() { sDeviceInfo = new DeviceInfo(); + sDeviceInfo->loadDisplayInfo(); sDeviceInfo->mMaxTextureSize = maxTextureSize; }); } void DeviceInfo::load() { + loadDisplayInfo(); glGetIntegerv(GL_MAX_TEXTURE_SIZE, &mMaxTextureSize); } +void DeviceInfo::loadDisplayInfo() { + sp<IBinder> dtoken(SurfaceComposerClient::getBuiltInDisplay( + ISurfaceComposer::eDisplayIdMain)); + status_t status = SurfaceComposerClient::getDisplayInfo(dtoken, &mDisplayInfo); + LOG_ALWAYS_FATAL_IF(status, "Failed to get display info, error %d", status); +} + } /* namespace uirenderer */ } /* namespace android */ diff --git a/libs/hwui/DeviceInfo.h b/libs/hwui/DeviceInfo.h index aff84b02d85a..5bd7b14b156d 100644 --- a/libs/hwui/DeviceInfo.h +++ b/libs/hwui/DeviceInfo.h @@ -16,7 +16,10 @@ #ifndef DEVICEINFO_H #define DEVICEINFO_H +#include <ui/DisplayInfo.h> + #include "utils/Macros.h" +#include "Extensions.h" namespace android { namespace uirenderer { @@ -35,14 +38,24 @@ public: static void initialize(int maxTextureSize); int maxTextureSize() const { return mMaxTextureSize; } + const DisplayInfo& displayInfo() const { return mDisplayInfo; } + const Extensions& extensions() const { return mExtensions; } + + static uint32_t multiplyByResolution(uint32_t in) { + auto di = DeviceInfo::get()->displayInfo(); + return di.w * di.h * in; + } private: DeviceInfo() {} ~DeviceInfo() {} void load(); + void loadDisplayInfo(); int mMaxTextureSize; + DisplayInfo mDisplayInfo; + Extensions mExtensions; }; } /* namespace uirenderer */ diff --git a/libs/hwui/FboCache.cpp b/libs/hwui/FboCache.cpp index b2181b60054f..a39e49f82eb0 100644 --- a/libs/hwui/FboCache.cpp +++ b/libs/hwui/FboCache.cpp @@ -28,7 +28,7 @@ namespace uirenderer { /////////////////////////////////////////////////////////////////////////////// FboCache::FboCache() - : mMaxSize(Properties::fboCacheSize) {} + : mMaxSize(0) {} FboCache::~FboCache() { clear(); diff --git a/libs/hwui/FontRenderer.cpp b/libs/hwui/FontRenderer.cpp index ee99018fb652..bc4181075319 100644 --- a/libs/hwui/FontRenderer.cpp +++ b/libs/hwui/FontRenderer.cpp @@ -32,7 +32,6 @@ #include "utils/Timing.h" #include <algorithm> -#include <cutils/properties.h> #include <RenderScript.h> #include <SkGlyph.h> #include <SkUtils.h> @@ -99,22 +98,14 @@ FontRenderer::FontRenderer(const uint8_t* gammaTable) INIT_LOGD("Creating FontRenderer"); } - mSmallCacheWidth = property_get_int32(PROPERTY_TEXT_SMALL_CACHE_WIDTH, - DEFAULT_TEXT_SMALL_CACHE_WIDTH); - mSmallCacheHeight = property_get_int32(PROPERTY_TEXT_SMALL_CACHE_HEIGHT, - DEFAULT_TEXT_SMALL_CACHE_HEIGHT); + auto deviceInfo = DeviceInfo::get(); + int maxTextureSize = deviceInfo->maxTextureSize(); - mLargeCacheWidth = property_get_int32(PROPERTY_TEXT_LARGE_CACHE_WIDTH, - DEFAULT_TEXT_LARGE_CACHE_WIDTH); - mLargeCacheHeight = property_get_int32(PROPERTY_TEXT_LARGE_CACHE_HEIGHT, - DEFAULT_TEXT_LARGE_CACHE_HEIGHT); - - uint32_t maxTextureSize = (uint32_t) Caches::getInstance().maxTextureSize; - - mSmallCacheWidth = std::min(mSmallCacheWidth, maxTextureSize); - mSmallCacheHeight = std::min(mSmallCacheHeight, maxTextureSize); - mLargeCacheWidth = std::min(mLargeCacheWidth, maxTextureSize); - mLargeCacheHeight = std::min(mLargeCacheHeight, maxTextureSize); + // TODO: Most devices are hardcoded with this configuration, does it need to be dynamic? + mSmallCacheWidth = std::min(1024, maxTextureSize); + mSmallCacheHeight = std::min(1024, maxTextureSize); + mLargeCacheWidth = std::min(2048, maxTextureSize); + mLargeCacheHeight = std::min(1024, maxTextureSize); if (sLogFontRendererCreate) { INIT_LOGD(" Text cache sizes, in pixels: %i x %i, %i x %i, %i x %i, %i x %i", diff --git a/libs/hwui/GradientCache.cpp b/libs/hwui/GradientCache.cpp index d4d0c997be11..20262349dda4 100644 --- a/libs/hwui/GradientCache.cpp +++ b/libs/hwui/GradientCache.cpp @@ -20,6 +20,7 @@ #include "Debug.h" #include "GradientCache.h" #include "Properties.h" +#include "DeviceInfo.h" #include <cutils/properties.h> @@ -62,14 +63,14 @@ int GradientCacheEntry::compare(const GradientCacheEntry& lhs, const GradientCac // Constructors/destructor /////////////////////////////////////////////////////////////////////////////// -GradientCache::GradientCache(Extensions& extensions) +GradientCache::GradientCache(const Extensions& extensions) : mCache(LruCache<GradientCacheEntry, Texture*>::kUnlimitedCapacity) , mSize(0) - , mMaxSize(Properties::gradientCacheSize) + , mMaxSize(MB(1)) , mUseFloatTexture(extensions.hasFloatTextures()) , mHasNpot(extensions.hasNPot()) , mHasLinearBlending(extensions.hasLinearBlending()) { - glGetIntegerv(GL_MAX_TEXTURE_SIZE, &mMaxTextureSize); + mMaxTextureSize = DeviceInfo::get()->maxTextureSize(); mCache.setOnEntryRemovedListener(this); } diff --git a/libs/hwui/GradientCache.h b/libs/hwui/GradientCache.h index f299a40e994f..d95589c514eb 100644 --- a/libs/hwui/GradientCache.h +++ b/libs/hwui/GradientCache.h @@ -105,7 +105,7 @@ inline hash_t hash_type(const GradientCacheEntry& entry) { */ class GradientCache: public OnEntryRemoved<GradientCacheEntry, Texture*> { public: - explicit GradientCache(Extensions& extensions); + explicit GradientCache(const Extensions& extensions); ~GradientCache(); /** diff --git a/libs/hwui/PatchCache.cpp b/libs/hwui/PatchCache.cpp index 983c17e92266..78c7eb9ad809 100644 --- a/libs/hwui/PatchCache.cpp +++ b/libs/hwui/PatchCache.cpp @@ -32,7 +32,7 @@ namespace uirenderer { PatchCache::PatchCache(RenderState& renderState) : mRenderState(renderState) - , mMaxSize(Properties::patchCacheSize) + , mMaxSize(KB(128)) , mSize(0) , mCache(LruCache<PatchDescription, Patch*>::kUnlimitedCapacity) , mMeshBuffer(0) diff --git a/libs/hwui/PathCache.cpp b/libs/hwui/PathCache.cpp index cc96de71df82..8d4ae1b6622a 100644 --- a/libs/hwui/PathCache.cpp +++ b/libs/hwui/PathCache.cpp @@ -38,6 +38,8 @@ namespace android { namespace uirenderer { +static constexpr size_t PATH_CACHE_COUNT_LIMIT = 256; + template <class T> static bool compareWidthHeight(const T& lhs, const T& rhs) { return (lhs.mWidth == rhs.mWidth) && (lhs.mHeight == rhs.mHeight); @@ -179,13 +181,9 @@ static sk_sp<Bitmap> drawPath(const SkPath* path, const SkPaint* paint, PathText PathCache::PathCache() : mCache(LruCache<PathDescription, PathTexture*>::kUnlimitedCapacity) , mSize(0) - , mMaxSize(Properties::pathCacheSize) { + , mMaxSize(DeviceInfo::multiplyByResolution(4)) { mCache.setOnEntryRemovedListener(this); - - GLint maxTextureSize; - glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize); - mMaxTextureSize = maxTextureSize; - + mMaxTextureSize = DeviceInfo::get()->maxTextureSize(); mDebugEnabled = Properties::debugLevel & kDebugCaches; } @@ -259,12 +257,7 @@ void PathCache::purgeCache(uint32_t width, uint32_t height) { } void PathCache::trim() { - // 25 is just an arbitrary lower bound to ensure we aren't in weird edge cases - // of things like a cap of 0 or 1 as that's going to break things. - // It does not represent a reasonable minimum value - static_assert(DEFAULT_PATH_TEXTURE_CAP > 25, "Path cache texture cap is too small"); - - while (mSize > mMaxSize || mCache.size() > DEFAULT_PATH_TEXTURE_CAP) { + while (mSize > mMaxSize || mCache.size() > PATH_CACHE_COUNT_LIMIT) { LOG_ALWAYS_FATAL_IF(!mCache.size(), "Inconsistent mSize! Ran out of items to remove!" " mSize = %u, mMaxSize = %u", mSize, mMaxSize); mCache.removeOldest(); diff --git a/libs/hwui/ProgramCache.cpp b/libs/hwui/ProgramCache.cpp index 8cc0aa7b414c..b767046f1a4f 100644 --- a/libs/hwui/ProgramCache.cpp +++ b/libs/hwui/ProgramCache.cpp @@ -505,7 +505,7 @@ const char* gBlendOps[18] = { // Constructors/destructors /////////////////////////////////////////////////////////////////////////////// -ProgramCache::ProgramCache(Extensions& extensions) +ProgramCache::ProgramCache(const Extensions& extensions) : mHasES3(extensions.getMajorGlVersion() >= 3) , mHasLinearBlending(extensions.hasLinearBlending()) { } diff --git a/libs/hwui/ProgramCache.h b/libs/hwui/ProgramCache.h index cedd854bb48b..ee76f22f35d4 100644 --- a/libs/hwui/ProgramCache.h +++ b/libs/hwui/ProgramCache.h @@ -40,7 +40,7 @@ namespace uirenderer { */ class ProgramCache { public: - explicit ProgramCache(Extensions& extensions); + explicit ProgramCache(const Extensions& extensions); ~ProgramCache(); Program* get(const ProgramDescription& description); diff --git a/libs/hwui/Properties.cpp b/libs/hwui/Properties.cpp index b5872485b136..acc75393ebcf 100644 --- a/libs/hwui/Properties.cpp +++ b/libs/hwui/Properties.cpp @@ -16,6 +16,7 @@ #include "Properties.h" #include "Debug.h" +#include "DeviceInfo.h" #include <algorithm> #include <cstdlib> @@ -36,20 +37,6 @@ bool Properties::skipEmptyFrames = true; bool Properties::useBufferAge = true; bool Properties::enablePartialUpdates = true; -float Properties::textGamma = DEFAULT_TEXT_GAMMA; - -int Properties::fboCacheSize = DEFAULT_FBO_CACHE_SIZE; -int Properties::gradientCacheSize = MB(DEFAULT_GRADIENT_CACHE_SIZE); -int Properties::layerPoolSize = MB(DEFAULT_LAYER_CACHE_SIZE); -int Properties::patchCacheSize = KB(DEFAULT_PATCH_CACHE_SIZE); -int Properties::pathCacheSize = MB(DEFAULT_PATH_CACHE_SIZE); -int Properties::renderBufferCacheSize = MB(DEFAULT_RENDER_BUFFER_CACHE_SIZE); -int Properties::tessellationCacheSize = MB(DEFAULT_VERTEX_CACHE_SIZE); -int Properties::textDropShadowCacheSize = MB(DEFAULT_DROP_SHADOW_CACHE_SIZE); -int Properties::textureCacheSize = MB(DEFAULT_TEXTURE_CACHE_SIZE); - -float Properties::textureCacheFlushRate = DEFAULT_TEXTURE_CACHE_FLUSH_RATE; - DebugLevel Properties::debugLevel = kDebugDisabled; OverdrawColorSet Properties::overdrawColorSet = OverdrawColorSet::Default; StencilClipDebug Properties::debugStencilClip = StencilClipDebug::Hide; @@ -80,15 +67,6 @@ static int property_get_int(const char* key, int defaultValue) { return defaultValue; } -static float property_get_float(const char* key, float defaultValue) { - char buf[PROPERTY_VALUE_MAX] = {'\0',}; - - if (property_get(key, buf, "") > 0) { - return atof(buf); - } - return defaultValue; -} - bool Properties::load() { char property[PROPERTY_VALUE_MAX]; bool prevDebugLayersUpdates = debugLayersUpdates; @@ -147,20 +125,6 @@ bool Properties::load() { useBufferAge = property_get_bool(PROPERTY_USE_BUFFER_AGE, true); enablePartialUpdates = property_get_bool(PROPERTY_ENABLE_PARTIAL_UPDATES, true); - textGamma = property_get_float(PROPERTY_TEXT_GAMMA, DEFAULT_TEXT_GAMMA); - - fboCacheSize = property_get_int(PROPERTY_FBO_CACHE_SIZE, DEFAULT_FBO_CACHE_SIZE); - gradientCacheSize = MB(property_get_float(PROPERTY_GRADIENT_CACHE_SIZE, DEFAULT_GRADIENT_CACHE_SIZE)); - layerPoolSize = MB(property_get_float(PROPERTY_LAYER_CACHE_SIZE, DEFAULT_LAYER_CACHE_SIZE)); - patchCacheSize = KB(property_get_float(PROPERTY_PATCH_CACHE_SIZE, DEFAULT_PATCH_CACHE_SIZE)); - pathCacheSize = MB(property_get_float(PROPERTY_PATH_CACHE_SIZE, DEFAULT_PATH_CACHE_SIZE)); - renderBufferCacheSize = MB(property_get_float(PROPERTY_RENDER_BUFFER_CACHE_SIZE, DEFAULT_RENDER_BUFFER_CACHE_SIZE)); - tessellationCacheSize = MB(property_get_float(PROPERTY_VERTEX_CACHE_SIZE, DEFAULT_VERTEX_CACHE_SIZE)); - textDropShadowCacheSize = MB(property_get_float(PROPERTY_DROP_SHADOW_CACHE_SIZE, DEFAULT_DROP_SHADOW_CACHE_SIZE)); - textureCacheSize = MB(property_get_float(PROPERTY_TEXTURE_CACHE_SIZE, DEFAULT_TEXTURE_CACHE_SIZE)); - textureCacheFlushRate = std::max(0.0f, std::min(1.0f, - property_get_float(PROPERTY_TEXTURE_CACHE_FLUSH_RATE, DEFAULT_TEXTURE_CACHE_FLUSH_RATE))); - filterOutTestOverhead = property_get_bool(PROPERTY_FILTER_TEST_OVERHEAD, false); return (prevDebugLayersUpdates != debugLayersUpdates) diff --git a/libs/hwui/Properties.h b/libs/hwui/Properties.h index 91b4a2d440e2..47ae9e912127 100644 --- a/libs/hwui/Properties.h +++ b/libs/hwui/Properties.h @@ -153,79 +153,16 @@ enum DebugLevel { #define PROPERTY_FILTER_TEST_OVERHEAD "debug.hwui.filter_test_overhead" /** - * Allows to set rendering pipeline mode to OpenGL (default), Skia OpenGL - * or Vulkan. - */ -#define PROPERTY_RENDERER "debug.hwui.renderer" - -/////////////////////////////////////////////////////////////////////////////// -// Runtime configuration properties -/////////////////////////////////////////////////////////////////////////////// - -/** - * Used to enable/disable scissor optimization. The accepted values are - * "true" and "false". The default value is "false". - * - * When scissor optimization is enabled, libhwui will attempt to - * minimize the use of scissor by selectively enabling and disabling the - * GL scissor test. - * When the optimization is disabled, OpenGLRenderer will keep the GL - * scissor test enabled and change the scissor rect as needed. - * Some GPUs (for instance the SGX 540) perform better when changing - * the scissor rect often than when enabling/disabling the scissor test - * often. - */ -#define PROPERTY_DISABLE_SCISSOR_OPTIMIZATION "ro.hwui.disable_scissor_opt" - -/** * Indicates whether PBOs can be used to back pixel buffers. * Accepted values are "true" and "false". Default is true. */ -#define PROPERTY_ENABLE_GPU_PIXEL_BUFFERS "ro.hwui.use_gpu_pixel_buffers" - -// These properties are defined in mega-bytes -#define PROPERTY_TEXTURE_CACHE_SIZE "ro.hwui.texture_cache_size" -#define PROPERTY_LAYER_CACHE_SIZE "ro.hwui.layer_cache_size" -#define PROPERTY_RENDER_BUFFER_CACHE_SIZE "ro.hwui.r_buffer_cache_size" -#define PROPERTY_GRADIENT_CACHE_SIZE "ro.hwui.gradient_cache_size" -#define PROPERTY_PATH_CACHE_SIZE "ro.hwui.path_cache_size" -#define PROPERTY_VERTEX_CACHE_SIZE "ro.hwui.vertex_cache_size" -#define PROPERTY_PATCH_CACHE_SIZE "ro.hwui.patch_cache_size" -#define PROPERTY_DROP_SHADOW_CACHE_SIZE "ro.hwui.drop_shadow_cache_size" -#define PROPERTY_FBO_CACHE_SIZE "ro.hwui.fbo_cache_size" - -// These properties are defined in percentage (range 0..1) -#define PROPERTY_TEXTURE_CACHE_FLUSH_RATE "ro.hwui.texture_cache_flushrate" - -// These properties are defined in pixels -#define PROPERTY_TEXT_SMALL_CACHE_WIDTH "ro.hwui.text_small_cache_width" -#define PROPERTY_TEXT_SMALL_CACHE_HEIGHT "ro.hwui.text_small_cache_height" -#define PROPERTY_TEXT_LARGE_CACHE_WIDTH "ro.hwui.text_large_cache_width" -#define PROPERTY_TEXT_LARGE_CACHE_HEIGHT "ro.hwui.text_large_cache_height" - -// Gamma (>= 1.0, <= 3.0) -#define PROPERTY_TEXT_GAMMA "hwui.text_gamma" - -/////////////////////////////////////////////////////////////////////////////// -// Default property values -/////////////////////////////////////////////////////////////////////////////// - -#define DEFAULT_TEXTURE_CACHE_SIZE 24.0f -#define DEFAULT_LAYER_CACHE_SIZE 16.0f -#define DEFAULT_RENDER_BUFFER_CACHE_SIZE 2.0f -#define DEFAULT_PATH_CACHE_SIZE 4.0f -#define DEFAULT_VERTEX_CACHE_SIZE 1.0f -#define DEFAULT_PATCH_CACHE_SIZE 128.0f // in kB -#define DEFAULT_GRADIENT_CACHE_SIZE 0.5f -#define DEFAULT_DROP_SHADOW_CACHE_SIZE 2.0f -#define DEFAULT_FBO_CACHE_SIZE 0 - -#define DEFAULT_TEXTURE_CACHE_FLUSH_RATE 0.6f +#define PROPERTY_ENABLE_GPU_PIXEL_BUFFERS "debug.hwui.use_gpu_pixel_buffers" -#define DEFAULT_TEXT_GAMMA 1.45f // Match design tools - -// cap to 256 to limite paths in the path cache -#define DEFAULT_PATH_TEXTURE_CAP 256 +/** + * Allows to set rendering pipeline mode to OpenGL (default), Skia OpenGL + * or Vulkan. + */ +#define PROPERTY_RENDERER "debug.hwui.renderer" /////////////////////////////////////////////////////////////////////////////// // Misc @@ -279,18 +216,8 @@ public: static bool useBufferAge; static bool enablePartialUpdates; - static float textGamma; - - static int fboCacheSize; - static int gradientCacheSize; - static int layerPoolSize; - static int patchCacheSize; - static int pathCacheSize; - static int renderBufferCacheSize; - static int tessellationCacheSize; - static int textDropShadowCacheSize; - static int textureCacheSize; - static float textureCacheFlushRate; + // TODO: Move somewhere else? + static constexpr float textGamma = 1.45f; static DebugLevel debugLevel; static OverdrawColorSet overdrawColorSet; diff --git a/libs/hwui/RenderBufferCache.cpp b/libs/hwui/RenderBufferCache.cpp index 1ac57cdbac0c..2f8ddfe6d660 100644 --- a/libs/hwui/RenderBufferCache.cpp +++ b/libs/hwui/RenderBufferCache.cpp @@ -17,6 +17,7 @@ #include "Debug.h" #include "Properties.h" #include "RenderBufferCache.h" +#include "DeviceInfo.h" #include <utils/Log.h> @@ -36,13 +37,20 @@ namespace uirenderer { #define RENDER_BUFFER_LOGD(...) #endif +static uint32_t calculateRboCacheSize() { + // TODO: Do we need to use extensions().has4BitStencil() here? + // The tuning guide recommends it, but all real devices are configured + // with a larger cache than necessary by 4x, so keep the 2x for now regardless + return DeviceInfo::multiplyByResolution(2); +} + /////////////////////////////////////////////////////////////////////////////// // Constructors/destructor /////////////////////////////////////////////////////////////////////////////// RenderBufferCache::RenderBufferCache() : mSize(0) - , mMaxSize(Properties::renderBufferCacheSize) {} + , mMaxSize(calculateRboCacheSize()) {} RenderBufferCache::~RenderBufferCache() { clear(); diff --git a/libs/hwui/TessellationCache.cpp b/libs/hwui/TessellationCache.cpp index 91e7ac39af90..01582ce8f007 100644 --- a/libs/hwui/TessellationCache.cpp +++ b/libs/hwui/TessellationCache.cpp @@ -290,7 +290,7 @@ public: /////////////////////////////////////////////////////////////////////////////// TessellationCache::TessellationCache() - : mMaxSize(Properties::tessellationCacheSize) + : mMaxSize(MB(1)) , mCache(LruCache<Description, Buffer*>::kUnlimitedCapacity) , mShadowCache(LruCache<ShadowDescription, Task<vertexBuffer_pair_t*>*>::kUnlimitedCapacity) { mCache.setOnEntryRemovedListener(&mBufferRemovedListener); diff --git a/libs/hwui/TextDropShadowCache.cpp b/libs/hwui/TextDropShadowCache.cpp index e1f0b2a20172..c521892c69df 100644 --- a/libs/hwui/TextDropShadowCache.cpp +++ b/libs/hwui/TextDropShadowCache.cpp @@ -94,7 +94,7 @@ int ShadowText::compare(const ShadowText& lhs, const ShadowText& rhs) { /////////////////////////////////////////////////////////////////////////////// TextDropShadowCache::TextDropShadowCache() - : TextDropShadowCache(Properties::textDropShadowCacheSize) {} + : TextDropShadowCache(DeviceInfo::multiplyByResolution(2)) {} TextDropShadowCache::TextDropShadowCache(uint32_t maxByteSize) : mCache(LruCache<ShadowText, ShadowTexture*>::kUnlimitedCapacity) diff --git a/libs/hwui/TextureCache.cpp b/libs/hwui/TextureCache.cpp index 710cdd9286e8..6fe3606a7576 100644 --- a/libs/hwui/TextureCache.cpp +++ b/libs/hwui/TextureCache.cpp @@ -24,6 +24,7 @@ #include "Properties.h" #include "utils/TraceUtils.h" #include "hwui/Bitmap.h" +#include "DeviceInfo.h" namespace android { namespace uirenderer { @@ -35,13 +36,10 @@ namespace uirenderer { TextureCache::TextureCache() : mCache(LruCache<uint32_t, Texture*>::kUnlimitedCapacity) , mSize(0) - , mMaxSize(Properties::textureCacheSize) - , mFlushRate(Properties::textureCacheFlushRate) { + , mMaxSize(DeviceInfo::multiplyByResolution(4 * 6)) // 6 screen-sized RGBA_8888 bitmaps + , mFlushRate(.4f) { mCache.setOnEntryRemovedListener(this); - - glGetIntegerv(GL_MAX_TEXTURE_SIZE, &mMaxTextureSize); - INIT_LOGD(" Maximum texture dimension is %d pixels", mMaxTextureSize); - + mMaxTextureSize = DeviceInfo::get()->maxTextureSize(); mDebugEnabled = Properties::debugLevel & kDebugCaches; } diff --git a/libs/hwui/font/FontUtil.h b/libs/hwui/font/FontUtil.h index 07e8b34ac66f..d4b4ff949f5a 100644 --- a/libs/hwui/font/FontUtil.h +++ b/libs/hwui/font/FontUtil.h @@ -25,11 +25,6 @@ // Defines /////////////////////////////////////////////////////////////////////////////// -#define DEFAULT_TEXT_SMALL_CACHE_WIDTH 1024 -#define DEFAULT_TEXT_SMALL_CACHE_HEIGHT 512 -#define DEFAULT_TEXT_LARGE_CACHE_WIDTH 2048 -#define DEFAULT_TEXT_LARGE_CACHE_HEIGHT 512 - #ifdef TEXTURE_BORDER_SIZE #if TEXTURE_BORDER_SIZE != 1 #error TEXTURE_BORDER_SIZE other than 1 is not currently supported diff --git a/libs/hwui/renderstate/OffscreenBufferPool.cpp b/libs/hwui/renderstate/OffscreenBufferPool.cpp index 90b27c8d8fb0..ffe7bd14cbc5 100644 --- a/libs/hwui/renderstate/OffscreenBufferPool.cpp +++ b/libs/hwui/renderstate/OffscreenBufferPool.cpp @@ -17,7 +17,6 @@ #include "OffscreenBufferPool.h" #include "Caches.h" -#include "Properties.h" #include "renderstate/RenderState.h" #include "utils/FatVector.h" #include "utils/TraceUtils.h" @@ -118,7 +117,8 @@ OffscreenBuffer::~OffscreenBuffer() { /////////////////////////////////////////////////////////////////////////////// OffscreenBufferPool::OffscreenBufferPool() - : mMaxSize(Properties::layerPoolSize) { + // 4 screen-sized RGBA_8888 textures + : mMaxSize(DeviceInfo::multiplyByResolution(4 * 4)) { } OffscreenBufferPool::~OffscreenBufferPool() { diff --git a/libs/hwui/renderstate/RenderState.cpp b/libs/hwui/renderstate/RenderState.cpp index 2c92924cc12c..ededffb0f4bb 100644 --- a/libs/hwui/renderstate/RenderState.cpp +++ b/libs/hwui/renderstate/RenderState.cpp @@ -53,6 +53,11 @@ void RenderState::onGLContextCreated() { mScissor = new Scissor(); mStencil = new Stencil(); + // Deferred because creation needs GL context for texture limits + if (!mLayerPool) { + mLayerPool = new OffscreenBufferPool(); + } + // This is delayed because the first access of Caches makes GL calls if (!mCaches) { mCaches = &Caches::createInstance(*this); @@ -67,7 +72,7 @@ static void layerLostGlContext(Layer* layer) { } void RenderState::onGLContextDestroyed() { - mLayerPool.clear(); + mLayerPool->clear(); // TODO: reset all cached state in state objects std::for_each(mActiveLayers.begin(), mActiveLayers.end(), layerLostGlContext); @@ -100,7 +105,7 @@ static void layerDestroyedVkContext(Layer* layer) { } void RenderState::onVkContextDestroyed() { - mLayerPool.clear(); + mLayerPool->clear(); std::for_each(mActiveLayers.begin(), mActiveLayers.end(), layerDestroyedVkContext); GpuMemoryTracker::onGpuContextDestroyed(); } @@ -116,10 +121,10 @@ void RenderState::flush(Caches::FlushMode mode) { case Caches::FlushMode::Moderate: // fall through case Caches::FlushMode::Layers: - mLayerPool.clear(); + if (mLayerPool) mLayerPool->clear(); break; } - mCaches->flush(mode); + if (mCaches) mCaches->flush(mode); } void RenderState::onBitmapDestroyed(uint32_t pixelRefId) { diff --git a/libs/hwui/renderstate/RenderState.h b/libs/hwui/renderstate/RenderState.h index 4b7a86580621..df81e864a0b5 100644 --- a/libs/hwui/renderstate/RenderState.h +++ b/libs/hwui/renderstate/RenderState.h @@ -113,7 +113,7 @@ public: Scissor& scissor() { return *mScissor; } Stencil& stencil() { return *mStencil; } - OffscreenBufferPool& layerPool() { return mLayerPool; } + OffscreenBufferPool& layerPool() { return *mLayerPool; } GrContext* getGrContext() const; @@ -136,7 +136,7 @@ private: Scissor* mScissor = nullptr; Stencil* mStencil = nullptr; - OffscreenBufferPool mLayerPool; + OffscreenBufferPool* mLayerPool = nullptr; std::set<Layer*> mActiveLayers; std::set<DeferredLayerUpdater*> mActiveLayerUpdaters; diff --git a/libs/hwui/renderstate/Stencil.cpp b/libs/hwui/renderstate/Stencil.cpp index d25ad514e892..f59442196af1 100644 --- a/libs/hwui/renderstate/Stencil.cpp +++ b/libs/hwui/renderstate/Stencil.cpp @@ -47,7 +47,7 @@ uint8_t Stencil::getStencilSize() { */ GLenum Stencil::getLayerStencilFormat() { #if !DEBUG_STENCIL - const Extensions& extensions = Caches::getInstance().extensions(); + const Extensions& extensions = DeviceInfo::get()->extensions(); if (extensions.has4BitStencil()) { return GL_STENCIL_INDEX4_OES; } diff --git a/libs/hwui/tests/unit/OffscreenBufferPoolTests.cpp b/libs/hwui/tests/unit/OffscreenBufferPoolTests.cpp index 919852f6b2d7..308fef303740 100644 --- a/libs/hwui/tests/unit/OffscreenBufferPoolTests.cpp +++ b/libs/hwui/tests/unit/OffscreenBufferPoolTests.cpp @@ -74,8 +74,8 @@ RENDERTHREAD_TEST(OffscreenBufferPool, construct) { OffscreenBufferPool pool; EXPECT_EQ(0u, pool.getCount()) << "pool must be created empty"; EXPECT_EQ(0u, pool.getSize()) << "pool must be created empty"; - EXPECT_EQ((uint32_t) Properties::layerPoolSize, pool.getMaxSize()) - << "pool must read size from Properties"; + // TODO: Does this really make sense as a test? + EXPECT_EQ(DeviceInfo::multiplyByResolution(4 * 4), pool.getMaxSize()); } RENDERTHREAD_OPENGL_PIPELINE_TEST(OffscreenBufferPool, getPutClear) { |