Merge "Delete all ro.hwui.* props"
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace uirenderer {
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
FboCache::FboCache()
|
||||
: mMaxSize(Properties::fboCacheSize) {}
|
||||
: mMaxSize(0) {}
|
||||
|
||||
FboCache::~FboCache() {
|
||||
clear();
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
/**
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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()) {
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace uirenderer {
|
||||
*/
|
||||
class ProgramCache {
|
||||
public:
|
||||
explicit ProgramCache(Extensions& extensions);
|
||||
explicit ProgramCache(const Extensions& extensions);
|
||||
~ProgramCache();
|
||||
|
||||
Program* get(const ProgramDescription& description);
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -152,81 +152,18 @@ enum DebugLevel {
|
||||
|
||||
#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
|
||||
* 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 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
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user