Merge "Delete all ro.hwui.* props" into oc-mr1-dev

This commit is contained in:
John Reck
2017-08-10 21:57:02 +00:00
committed by Android (Google) Code Review
24 changed files with 92 additions and 190 deletions

View File

@@ -50,9 +50,9 @@ Caches* Caches::sInstance = nullptr;
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
Caches::Caches(RenderState& renderState) Caches::Caches(RenderState& renderState)
: gradientCache(mExtensions) : gradientCache(extensions())
, patchCache(renderState) , patchCache(renderState)
, programCache(mExtensions) , programCache(extensions())
, mRenderState(&renderState) , mRenderState(&renderState)
, mInitialized(false) { , mInitialized(false) {
INIT_LOGD("Creating OpenGL renderer caches"); INIT_LOGD("Creating OpenGL renderer caches");
@@ -80,7 +80,7 @@ bool Caches::init() {
} }
void Caches::initExtensions() { void Caches::initExtensions() {
if (mExtensions.hasDebugMarker()) { if (extensions().hasDebugMarker()) {
eventMark = glInsertEventMarkerEXT; eventMark = glInsertEventMarkerEXT;
startMark = glPushGroupMarkerEXT; startMark = glPushGroupMarkerEXT;
@@ -93,12 +93,12 @@ void Caches::initExtensions() {
} }
void Caches::initConstraints() { void Caches::initConstraints() {
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize); maxTextureSize = DeviceInfo::get()->maxTextureSize();
} }
void Caches::initStaticProperties() { void Caches::initStaticProperties() {
// OpenGL ES 3.0+ specific features // OpenGL ES 3.0+ specific features
gpuPixelBuffersEnabled = mExtensions.hasPixelBufferObjects() gpuPixelBuffersEnabled = extensions().hasPixelBufferObjects()
&& property_get_bool(PROPERTY_ENABLE_GPU_PIXEL_BUFFERS, true); && property_get_bool(PROPERTY_ENABLE_GPU_PIXEL_BUFFERS, true);
} }

View File

@@ -16,6 +16,7 @@
#pragma once #pragma once
#include "DeviceInfo.h"
#include "Extensions.h" #include "Extensions.h"
#include "FboCache.h" #include "FboCache.h"
#include "GammaFontRenderer.h" #include "GammaFontRenderer.h"
@@ -145,10 +146,6 @@ public:
// Misc // Misc
GLint maxTextureSize; GLint maxTextureSize;
private:
// Declared before gradientCache and programCache which need this to initialize.
// TODO: cleanup / move elsewhere
Extensions mExtensions;
public: public:
TextureCache textureCache; TextureCache textureCache;
RenderBufferCache renderBufferCache; RenderBufferCache renderBufferCache;
@@ -174,7 +171,7 @@ public:
void setProgram(const ProgramDescription& description); void setProgram(const ProgramDescription& description);
void setProgram(Program* program); void setProgram(Program* program);
const Extensions& extensions() const { return mExtensions; } const Extensions& extensions() const { return DeviceInfo::get()->extensions(); }
Program& program() { return *mProgram; } Program& program() { return *mProgram; }
PixelBufferState& pixelBufferState() { return *mPixelBufferState; } PixelBufferState& pixelBufferState() { return *mPixelBufferState; }
TextureState& textureState() { return *mTextureState; } TextureState& textureState() { return *mTextureState; }

View File

@@ -16,7 +16,8 @@
#include <DeviceInfo.h> #include <DeviceInfo.h>
#include "Extensions.h" #include <gui/ISurfaceComposer.h>
#include <gui/SurfaceComposerClient.h>
#include <thread> #include <thread>
#include <mutex> #include <mutex>
@@ -46,13 +47,22 @@ void DeviceInfo::initialize() {
void DeviceInfo::initialize(int maxTextureSize) { void DeviceInfo::initialize(int maxTextureSize) {
std::call_once(sInitializedFlag, [maxTextureSize]() { std::call_once(sInitializedFlag, [maxTextureSize]() {
sDeviceInfo = new DeviceInfo(); sDeviceInfo = new DeviceInfo();
sDeviceInfo->loadDisplayInfo();
sDeviceInfo->mMaxTextureSize = maxTextureSize; sDeviceInfo->mMaxTextureSize = maxTextureSize;
}); });
} }
void DeviceInfo::load() { void DeviceInfo::load() {
loadDisplayInfo();
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &mMaxTextureSize); 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 uirenderer */
} /* namespace android */ } /* namespace android */

View File

@@ -16,7 +16,10 @@
#ifndef DEVICEINFO_H #ifndef DEVICEINFO_H
#define DEVICEINFO_H #define DEVICEINFO_H
#include <ui/DisplayInfo.h>
#include "utils/Macros.h" #include "utils/Macros.h"
#include "Extensions.h"
namespace android { namespace android {
namespace uirenderer { namespace uirenderer {
@@ -35,14 +38,24 @@ public:
static void initialize(int maxTextureSize); static void initialize(int maxTextureSize);
int maxTextureSize() const { return mMaxTextureSize; } 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: private:
DeviceInfo() {} DeviceInfo() {}
~DeviceInfo() {} ~DeviceInfo() {}
void load(); void load();
void loadDisplayInfo();
int mMaxTextureSize; int mMaxTextureSize;
DisplayInfo mDisplayInfo;
Extensions mExtensions;
}; };
} /* namespace uirenderer */ } /* namespace uirenderer */

View File

@@ -28,7 +28,7 @@ namespace uirenderer {
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
FboCache::FboCache() FboCache::FboCache()
: mMaxSize(Properties::fboCacheSize) {} : mMaxSize(0) {}
FboCache::~FboCache() { FboCache::~FboCache() {
clear(); clear();

View File

@@ -32,7 +32,6 @@
#include "utils/Timing.h" #include "utils/Timing.h"
#include <algorithm> #include <algorithm>
#include <cutils/properties.h>
#include <RenderScript.h> #include <RenderScript.h>
#include <SkGlyph.h> #include <SkGlyph.h>
#include <SkUtils.h> #include <SkUtils.h>
@@ -99,22 +98,14 @@ FontRenderer::FontRenderer(const uint8_t* gammaTable)
INIT_LOGD("Creating FontRenderer"); INIT_LOGD("Creating FontRenderer");
} }
mSmallCacheWidth = property_get_int32(PROPERTY_TEXT_SMALL_CACHE_WIDTH, auto deviceInfo = DeviceInfo::get();
DEFAULT_TEXT_SMALL_CACHE_WIDTH); int maxTextureSize = deviceInfo->maxTextureSize();
mSmallCacheHeight = property_get_int32(PROPERTY_TEXT_SMALL_CACHE_HEIGHT,
DEFAULT_TEXT_SMALL_CACHE_HEIGHT);
mLargeCacheWidth = property_get_int32(PROPERTY_TEXT_LARGE_CACHE_WIDTH, // TODO: Most devices are hardcoded with this configuration, does it need to be dynamic?
DEFAULT_TEXT_LARGE_CACHE_WIDTH); mSmallCacheWidth = std::min(1024, maxTextureSize);
mLargeCacheHeight = property_get_int32(PROPERTY_TEXT_LARGE_CACHE_HEIGHT, mSmallCacheHeight = std::min(1024, maxTextureSize);
DEFAULT_TEXT_LARGE_CACHE_HEIGHT); mLargeCacheWidth = std::min(2048, maxTextureSize);
mLargeCacheHeight = std::min(1024, maxTextureSize);
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);
if (sLogFontRendererCreate) { if (sLogFontRendererCreate) {
INIT_LOGD(" Text cache sizes, in pixels: %i x %i, %i x %i, %i x %i, %i x %i", INIT_LOGD(" Text cache sizes, in pixels: %i x %i, %i x %i, %i x %i, %i x %i",

View File

@@ -20,6 +20,7 @@
#include "Debug.h" #include "Debug.h"
#include "GradientCache.h" #include "GradientCache.h"
#include "Properties.h" #include "Properties.h"
#include "DeviceInfo.h"
#include <cutils/properties.h> #include <cutils/properties.h>
@@ -62,14 +63,14 @@ int GradientCacheEntry::compare(const GradientCacheEntry& lhs, const GradientCac
// Constructors/destructor // Constructors/destructor
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
GradientCache::GradientCache(Extensions& extensions) GradientCache::GradientCache(const Extensions& extensions)
: mCache(LruCache<GradientCacheEntry, Texture*>::kUnlimitedCapacity) : mCache(LruCache<GradientCacheEntry, Texture*>::kUnlimitedCapacity)
, mSize(0) , mSize(0)
, mMaxSize(Properties::gradientCacheSize) , mMaxSize(MB(1))
, mUseFloatTexture(extensions.hasFloatTextures()) , mUseFloatTexture(extensions.hasFloatTextures())
, mHasNpot(extensions.hasNPot()) , mHasNpot(extensions.hasNPot())
, mHasLinearBlending(extensions.hasLinearBlending()) { , mHasLinearBlending(extensions.hasLinearBlending()) {
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &mMaxTextureSize); mMaxTextureSize = DeviceInfo::get()->maxTextureSize();
mCache.setOnEntryRemovedListener(this); mCache.setOnEntryRemovedListener(this);
} }

View File

@@ -105,7 +105,7 @@ inline hash_t hash_type(const GradientCacheEntry& entry) {
*/ */
class GradientCache: public OnEntryRemoved<GradientCacheEntry, Texture*> { class GradientCache: public OnEntryRemoved<GradientCacheEntry, Texture*> {
public: public:
explicit GradientCache(Extensions& extensions); explicit GradientCache(const Extensions& extensions);
~GradientCache(); ~GradientCache();
/** /**

View File

@@ -32,7 +32,7 @@ namespace uirenderer {
PatchCache::PatchCache(RenderState& renderState) PatchCache::PatchCache(RenderState& renderState)
: mRenderState(renderState) : mRenderState(renderState)
, mMaxSize(Properties::patchCacheSize) , mMaxSize(KB(128))
, mSize(0) , mSize(0)
, mCache(LruCache<PatchDescription, Patch*>::kUnlimitedCapacity) , mCache(LruCache<PatchDescription, Patch*>::kUnlimitedCapacity)
, mMeshBuffer(0) , mMeshBuffer(0)

View File

@@ -38,6 +38,8 @@
namespace android { namespace android {
namespace uirenderer { namespace uirenderer {
static constexpr size_t PATH_CACHE_COUNT_LIMIT = 256;
template <class T> template <class T>
static bool compareWidthHeight(const T& lhs, const T& rhs) { static bool compareWidthHeight(const T& lhs, const T& rhs) {
return (lhs.mWidth == rhs.mWidth) && (lhs.mHeight == rhs.mHeight); 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() PathCache::PathCache()
: mCache(LruCache<PathDescription, PathTexture*>::kUnlimitedCapacity) : mCache(LruCache<PathDescription, PathTexture*>::kUnlimitedCapacity)
, mSize(0) , mSize(0)
, mMaxSize(Properties::pathCacheSize) { , mMaxSize(DeviceInfo::multiplyByResolution(4)) {
mCache.setOnEntryRemovedListener(this); mCache.setOnEntryRemovedListener(this);
mMaxTextureSize = DeviceInfo::get()->maxTextureSize();
GLint maxTextureSize;
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
mMaxTextureSize = maxTextureSize;
mDebugEnabled = Properties::debugLevel & kDebugCaches; mDebugEnabled = Properties::debugLevel & kDebugCaches;
} }
@@ -259,12 +257,7 @@ void PathCache::purgeCache(uint32_t width, uint32_t height) {
} }
void PathCache::trim() { void PathCache::trim() {
// 25 is just an arbitrary lower bound to ensure we aren't in weird edge cases while (mSize > mMaxSize || mCache.size() > PATH_CACHE_COUNT_LIMIT) {
// 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) {
LOG_ALWAYS_FATAL_IF(!mCache.size(), "Inconsistent mSize! Ran out of items to remove!" LOG_ALWAYS_FATAL_IF(!mCache.size(), "Inconsistent mSize! Ran out of items to remove!"
" mSize = %u, mMaxSize = %u", mSize, mMaxSize); " mSize = %u, mMaxSize = %u", mSize, mMaxSize);
mCache.removeOldest(); mCache.removeOldest();

View File

@@ -505,7 +505,7 @@ const char* gBlendOps[18] = {
// Constructors/destructors // Constructors/destructors
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
ProgramCache::ProgramCache(Extensions& extensions) ProgramCache::ProgramCache(const Extensions& extensions)
: mHasES3(extensions.getMajorGlVersion() >= 3) : mHasES3(extensions.getMajorGlVersion() >= 3)
, mHasLinearBlending(extensions.hasLinearBlending()) { , mHasLinearBlending(extensions.hasLinearBlending()) {
} }

View File

@@ -40,7 +40,7 @@ namespace uirenderer {
*/ */
class ProgramCache { class ProgramCache {
public: public:
explicit ProgramCache(Extensions& extensions); explicit ProgramCache(const Extensions& extensions);
~ProgramCache(); ~ProgramCache();
Program* get(const ProgramDescription& description); Program* get(const ProgramDescription& description);

View File

@@ -16,6 +16,7 @@
#include "Properties.h" #include "Properties.h"
#include "Debug.h" #include "Debug.h"
#include "DeviceInfo.h"
#include <algorithm> #include <algorithm>
#include <cstdlib> #include <cstdlib>
@@ -36,20 +37,6 @@ bool Properties::skipEmptyFrames = true;
bool Properties::useBufferAge = true; bool Properties::useBufferAge = true;
bool Properties::enablePartialUpdates = 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; DebugLevel Properties::debugLevel = kDebugDisabled;
OverdrawColorSet Properties::overdrawColorSet = OverdrawColorSet::Default; OverdrawColorSet Properties::overdrawColorSet = OverdrawColorSet::Default;
StencilClipDebug Properties::debugStencilClip = StencilClipDebug::Hide; StencilClipDebug Properties::debugStencilClip = StencilClipDebug::Hide;
@@ -80,15 +67,6 @@ static int property_get_int(const char* key, int defaultValue) {
return 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() { bool Properties::load() {
char property[PROPERTY_VALUE_MAX]; char property[PROPERTY_VALUE_MAX];
bool prevDebugLayersUpdates = debugLayersUpdates; bool prevDebugLayersUpdates = debugLayersUpdates;
@@ -147,20 +125,6 @@ bool Properties::load() {
useBufferAge = property_get_bool(PROPERTY_USE_BUFFER_AGE, true); useBufferAge = property_get_bool(PROPERTY_USE_BUFFER_AGE, true);
enablePartialUpdates = property_get_bool(PROPERTY_ENABLE_PARTIAL_UPDATES, 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); filterOutTestOverhead = property_get_bool(PROPERTY_FILTER_TEST_OVERHEAD, false);
return (prevDebugLayersUpdates != debugLayersUpdates) return (prevDebugLayersUpdates != debugLayersUpdates)

View File

@@ -152,81 +152,18 @@ enum DebugLevel {
#define PROPERTY_FILTER_TEST_OVERHEAD "debug.hwui.filter_test_overhead" #define PROPERTY_FILTER_TEST_OVERHEAD "debug.hwui.filter_test_overhead"
/**
* 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 "debug.hwui.use_gpu_pixel_buffers"
/** /**
* Allows to set rendering pipeline mode to OpenGL (default), Skia OpenGL * Allows to set rendering pipeline mode to OpenGL (default), Skia OpenGL
* or Vulkan. * or Vulkan.
*/ */
#define PROPERTY_RENDERER "debug.hwui.renderer" #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 DEFAULT_TEXT_GAMMA 1.45f // Match design tools
// cap to 256 to limite paths in the path cache
#define DEFAULT_PATH_TEXTURE_CAP 256
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Misc // Misc
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@@ -279,18 +216,8 @@ public:
static bool useBufferAge; static bool useBufferAge;
static bool enablePartialUpdates; static bool enablePartialUpdates;
static float textGamma; // TODO: Move somewhere else?
static constexpr float textGamma = 1.45f;
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;
static DebugLevel debugLevel; static DebugLevel debugLevel;
static OverdrawColorSet overdrawColorSet; static OverdrawColorSet overdrawColorSet;

View File

@@ -17,6 +17,7 @@
#include "Debug.h" #include "Debug.h"
#include "Properties.h" #include "Properties.h"
#include "RenderBufferCache.h" #include "RenderBufferCache.h"
#include "DeviceInfo.h"
#include <utils/Log.h> #include <utils/Log.h>
@@ -36,13 +37,20 @@ namespace uirenderer {
#define RENDER_BUFFER_LOGD(...) #define RENDER_BUFFER_LOGD(...)
#endif #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 // Constructors/destructor
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
RenderBufferCache::RenderBufferCache() RenderBufferCache::RenderBufferCache()
: mSize(0) : mSize(0)
, mMaxSize(Properties::renderBufferCacheSize) {} , mMaxSize(calculateRboCacheSize()) {}
RenderBufferCache::~RenderBufferCache() { RenderBufferCache::~RenderBufferCache() {
clear(); clear();

View File

@@ -290,7 +290,7 @@ public:
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
TessellationCache::TessellationCache() TessellationCache::TessellationCache()
: mMaxSize(Properties::tessellationCacheSize) : mMaxSize(MB(1))
, mCache(LruCache<Description, Buffer*>::kUnlimitedCapacity) , mCache(LruCache<Description, Buffer*>::kUnlimitedCapacity)
, mShadowCache(LruCache<ShadowDescription, Task<vertexBuffer_pair_t*>*>::kUnlimitedCapacity) { , mShadowCache(LruCache<ShadowDescription, Task<vertexBuffer_pair_t*>*>::kUnlimitedCapacity) {
mCache.setOnEntryRemovedListener(&mBufferRemovedListener); mCache.setOnEntryRemovedListener(&mBufferRemovedListener);

View File

@@ -94,7 +94,7 @@ int ShadowText::compare(const ShadowText& lhs, const ShadowText& rhs) {
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
TextDropShadowCache::TextDropShadowCache() TextDropShadowCache::TextDropShadowCache()
: TextDropShadowCache(Properties::textDropShadowCacheSize) {} : TextDropShadowCache(DeviceInfo::multiplyByResolution(2)) {}
TextDropShadowCache::TextDropShadowCache(uint32_t maxByteSize) TextDropShadowCache::TextDropShadowCache(uint32_t maxByteSize)
: mCache(LruCache<ShadowText, ShadowTexture*>::kUnlimitedCapacity) : mCache(LruCache<ShadowText, ShadowTexture*>::kUnlimitedCapacity)

View File

@@ -24,6 +24,7 @@
#include "Properties.h" #include "Properties.h"
#include "utils/TraceUtils.h" #include "utils/TraceUtils.h"
#include "hwui/Bitmap.h" #include "hwui/Bitmap.h"
#include "DeviceInfo.h"
namespace android { namespace android {
namespace uirenderer { namespace uirenderer {
@@ -35,13 +36,10 @@ namespace uirenderer {
TextureCache::TextureCache() TextureCache::TextureCache()
: mCache(LruCache<uint32_t, Texture*>::kUnlimitedCapacity) : mCache(LruCache<uint32_t, Texture*>::kUnlimitedCapacity)
, mSize(0) , mSize(0)
, mMaxSize(Properties::textureCacheSize) , mMaxSize(DeviceInfo::multiplyByResolution(4 * 6)) // 6 screen-sized RGBA_8888 bitmaps
, mFlushRate(Properties::textureCacheFlushRate) { , mFlushRate(.4f) {
mCache.setOnEntryRemovedListener(this); mCache.setOnEntryRemovedListener(this);
mMaxTextureSize = DeviceInfo::get()->maxTextureSize();
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &mMaxTextureSize);
INIT_LOGD(" Maximum texture dimension is %d pixels", mMaxTextureSize);
mDebugEnabled = Properties::debugLevel & kDebugCaches; mDebugEnabled = Properties::debugLevel & kDebugCaches;
} }

View File

@@ -25,11 +25,6 @@
// Defines // 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 #ifdef TEXTURE_BORDER_SIZE
#if TEXTURE_BORDER_SIZE != 1 #if TEXTURE_BORDER_SIZE != 1
#error TEXTURE_BORDER_SIZE other than 1 is not currently supported #error TEXTURE_BORDER_SIZE other than 1 is not currently supported

View File

@@ -17,7 +17,6 @@
#include "OffscreenBufferPool.h" #include "OffscreenBufferPool.h"
#include "Caches.h" #include "Caches.h"
#include "Properties.h"
#include "renderstate/RenderState.h" #include "renderstate/RenderState.h"
#include "utils/FatVector.h" #include "utils/FatVector.h"
#include "utils/TraceUtils.h" #include "utils/TraceUtils.h"
@@ -118,7 +117,8 @@ OffscreenBuffer::~OffscreenBuffer() {
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
OffscreenBufferPool::OffscreenBufferPool() OffscreenBufferPool::OffscreenBufferPool()
: mMaxSize(Properties::layerPoolSize) { // 4 screen-sized RGBA_8888 textures
: mMaxSize(DeviceInfo::multiplyByResolution(4 * 4)) {
} }
OffscreenBufferPool::~OffscreenBufferPool() { OffscreenBufferPool::~OffscreenBufferPool() {

View File

@@ -53,6 +53,11 @@ void RenderState::onGLContextCreated() {
mScissor = new Scissor(); mScissor = new Scissor();
mStencil = new Stencil(); 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 // This is delayed because the first access of Caches makes GL calls
if (!mCaches) { if (!mCaches) {
mCaches = &Caches::createInstance(*this); mCaches = &Caches::createInstance(*this);
@@ -67,7 +72,7 @@ static void layerLostGlContext(Layer* layer) {
} }
void RenderState::onGLContextDestroyed() { void RenderState::onGLContextDestroyed() {
mLayerPool.clear(); mLayerPool->clear();
// TODO: reset all cached state in state objects // TODO: reset all cached state in state objects
std::for_each(mActiveLayers.begin(), mActiveLayers.end(), layerLostGlContext); std::for_each(mActiveLayers.begin(), mActiveLayers.end(), layerLostGlContext);
@@ -100,7 +105,7 @@ static void layerDestroyedVkContext(Layer* layer) {
} }
void RenderState::onVkContextDestroyed() { void RenderState::onVkContextDestroyed() {
mLayerPool.clear(); mLayerPool->clear();
std::for_each(mActiveLayers.begin(), mActiveLayers.end(), layerDestroyedVkContext); std::for_each(mActiveLayers.begin(), mActiveLayers.end(), layerDestroyedVkContext);
GpuMemoryTracker::onGpuContextDestroyed(); GpuMemoryTracker::onGpuContextDestroyed();
} }
@@ -116,10 +121,10 @@ void RenderState::flush(Caches::FlushMode mode) {
case Caches::FlushMode::Moderate: case Caches::FlushMode::Moderate:
// fall through // fall through
case Caches::FlushMode::Layers: case Caches::FlushMode::Layers:
mLayerPool.clear(); if (mLayerPool) mLayerPool->clear();
break; break;
} }
mCaches->flush(mode); if (mCaches) mCaches->flush(mode);
} }
void RenderState::onBitmapDestroyed(uint32_t pixelRefId) { void RenderState::onBitmapDestroyed(uint32_t pixelRefId) {

View File

@@ -113,7 +113,7 @@ public:
Scissor& scissor() { return *mScissor; } Scissor& scissor() { return *mScissor; }
Stencil& stencil() { return *mStencil; } Stencil& stencil() { return *mStencil; }
OffscreenBufferPool& layerPool() { return mLayerPool; } OffscreenBufferPool& layerPool() { return *mLayerPool; }
GrContext* getGrContext() const; GrContext* getGrContext() const;
@@ -136,7 +136,7 @@ private:
Scissor* mScissor = nullptr; Scissor* mScissor = nullptr;
Stencil* mStencil = nullptr; Stencil* mStencil = nullptr;
OffscreenBufferPool mLayerPool; OffscreenBufferPool* mLayerPool = nullptr;
std::set<Layer*> mActiveLayers; std::set<Layer*> mActiveLayers;
std::set<DeferredLayerUpdater*> mActiveLayerUpdaters; std::set<DeferredLayerUpdater*> mActiveLayerUpdaters;

View File

@@ -47,7 +47,7 @@ uint8_t Stencil::getStencilSize() {
*/ */
GLenum Stencil::getLayerStencilFormat() { GLenum Stencil::getLayerStencilFormat() {
#if !DEBUG_STENCIL #if !DEBUG_STENCIL
const Extensions& extensions = Caches::getInstance().extensions(); const Extensions& extensions = DeviceInfo::get()->extensions();
if (extensions.has4BitStencil()) { if (extensions.has4BitStencil()) {
return GL_STENCIL_INDEX4_OES; return GL_STENCIL_INDEX4_OES;
} }

View File

@@ -74,8 +74,8 @@ RENDERTHREAD_TEST(OffscreenBufferPool, construct) {
OffscreenBufferPool pool; OffscreenBufferPool pool;
EXPECT_EQ(0u, pool.getCount()) << "pool must be created empty"; EXPECT_EQ(0u, pool.getCount()) << "pool must be created empty";
EXPECT_EQ(0u, pool.getSize()) << "pool must be created empty"; EXPECT_EQ(0u, pool.getSize()) << "pool must be created empty";
EXPECT_EQ((uint32_t) Properties::layerPoolSize, pool.getMaxSize()) // TODO: Does this really make sense as a test?
<< "pool must read size from Properties"; EXPECT_EQ(DeviceInfo::multiplyByResolution(4 * 4), pool.getMaxSize());
} }
RENDERTHREAD_OPENGL_PIPELINE_TEST(OffscreenBufferPool, getPutClear) { RENDERTHREAD_OPENGL_PIPELINE_TEST(OffscreenBufferPool, getPutClear) {