From 7dcb7d2d82cc18266aeed8d92c7c35ec8a32f821 Mon Sep 17 00:00:00 2001 From: Alec Mouri Date: Fri, 26 Jul 2024 13:41:04 +0000 Subject: Resample gainmaps during region decoding. Implicitly, region decoding is a cropping operation, which previously was introducing quality issues when decoding a gainmapped image. For instance: (a) Consider a 48x48 image with a 12x12 gainmap. (b) Consider decoding a 10x10 region of the image. The decoder must choose to either decode a 2x2 or 3x3 region of the gainmap, which does not match the 4x scale ratio of the source, so either we decode too much or too little of the image (c) When displaying the image, we bilinearly scale both the image and the gainmap to the destination, then apply the gainmap. But, because of (b), the gainmap is misaligned with the base image, introducing haloing artifacts. To fix this, we change (b) by always decoding a slightly larger region (in the examplar case, either a decode a 3x3 or 4x4 region), but retain information about the "logical" region we intended. Then, we resample from the "logical" region up to the decoded bounds. In the above example, this means that we decode a 3x3 or 4x4 bitmap, that holds the logical 2.5x2.5 region of the gainmap, ensuring that (0, 0) in the resulting bitmap maps to (0, 0) in the bitmap for the decoded region from the base image, so that the gainmap content lines up with the base image after the gainmap is upsampled during rendering. We do the actual resampling inside of the recycling allocator, since we sometimes perform a bitmap copy there anyways, so we can resample during the copy. Hide this behind a flag, since I broke decoding in about 5 different ways before settling on this. Bug: 352847821 Flag: com.android.graphics.hwui.flags.resample_gainmap_regions Test: Decoding works in Photos, Files, and modified SilkFX Change-Id: Ic21d44011858619273b11c20ee746614a1749a73 --- libs/hwui/Properties.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'libs/hwui/Properties.cpp') diff --git a/libs/hwui/Properties.cpp b/libs/hwui/Properties.cpp index d184f64b1c2c..1217b47664dd 100644 --- a/libs/hwui/Properties.cpp +++ b/libs/hwui/Properties.cpp @@ -42,6 +42,9 @@ constexpr bool hdr_10bit_plus() { constexpr bool initialize_gl_always() { return false; } +constexpr bool resample_gainmap_regions() { + return false; +} } // namespace hwui_flags #endif @@ -100,6 +103,7 @@ float Properties::maxHdrHeadroomOn8bit = 5.f; // TODO: Refine this number bool Properties::clipSurfaceViews = false; bool Properties::hdr10bitPlus = false; +bool Properties::resampleGainmapRegions = false; int Properties::timeoutMultiplier = 1; @@ -175,6 +179,8 @@ bool Properties::load() { clipSurfaceViews = base::GetBoolProperty("debug.hwui.clip_surfaceviews", hwui_flags::clip_surfaceviews()); hdr10bitPlus = hwui_flags::hdr_10bit_plus(); + resampleGainmapRegions = base::GetBoolProperty("debug.hwui.resample_gainmap_regions", + hwui_flags::resample_gainmap_regions()); timeoutMultiplier = android::base::GetIntProperty("ro.hw_timeout_multiplier", 1); -- cgit v1.2.3-59-g8ed1b From 102ba1284e1ebcd4989b25dea429306af8f10349 Mon Sep 17 00:00:00 2001 From: Tom Murphy Date: Thu, 25 Jul 2024 12:50:46 +0000 Subject: Skip eglCreateContext telemetry for HWUI contexts We want eglCreateContext telemetry to give us insights into how developers use EGL. Including HWUI telemetry in this pollutes this telemetry. Skip recording of the creation of this context using the new Egl extension. Currently this only disables the passing of GpuStatsInfo::Stats::CREATED_GLES_CONTEXT to the gpu stats. Test: Checked the code path executed correctly with the flag enabled/disabled using logging Bug: 347911216 Flag: com.android.graphics.hwui.flags.skip_eglmanager_telemetry Change-Id: Ifcadd5af263f26388026bcd70ec8dc9c2914cd0a --- libs/hwui/Android.bp | 1 + libs/hwui/Properties.cpp | 8 ++++++++ libs/hwui/Properties.h | 3 +++ libs/hwui/aconfig/hwui_flags.aconfig | 7 +++++++ libs/hwui/renderthread/EglManager.cpp | 5 +++++ 5 files changed, 24 insertions(+) (limited to 'libs/hwui/Properties.cpp') diff --git a/libs/hwui/Android.bp b/libs/hwui/Android.bp index d71f3b6884ae..23cd3ce965ff 100644 --- a/libs/hwui/Android.bp +++ b/libs/hwui/Android.bp @@ -143,6 +143,7 @@ cc_defaults { "aconfig_text_flags_c_lib", "server_configurable_flags", "libaconfig_storage_read_api_cc", + "libgraphicsenv", ], static_libs: [ "libEGL_blobCache", diff --git a/libs/hwui/Properties.cpp b/libs/hwui/Properties.cpp index 1217b47664dd..b6476c9d466f 100644 --- a/libs/hwui/Properties.cpp +++ b/libs/hwui/Properties.cpp @@ -42,6 +42,11 @@ constexpr bool hdr_10bit_plus() { constexpr bool initialize_gl_always() { return false; } + +constexpr bool skip_eglmanager_telemetry() { + return false; +} + constexpr bool resample_gainmap_regions() { return false; } @@ -103,6 +108,7 @@ float Properties::maxHdrHeadroomOn8bit = 5.f; // TODO: Refine this number bool Properties::clipSurfaceViews = false; bool Properties::hdr10bitPlus = false; +bool Properties::skipTelemetry = false; bool Properties::resampleGainmapRegions = false; int Properties::timeoutMultiplier = 1; @@ -183,6 +189,8 @@ bool Properties::load() { hwui_flags::resample_gainmap_regions()); timeoutMultiplier = android::base::GetIntProperty("ro.hw_timeout_multiplier", 1); + skipTelemetry = base::GetBoolProperty(PROPERTY_SKIP_EGLMANAGER_TELEMETRY, + hwui_flags::skip_eglmanager_telemetry()); return (prevDebugLayersUpdates != debugLayersUpdates) || (prevDebugOverdraw != debugOverdraw); } diff --git a/libs/hwui/Properties.h b/libs/hwui/Properties.h index 73e80ce4afd0..db471527b861 100644 --- a/libs/hwui/Properties.h +++ b/libs/hwui/Properties.h @@ -234,6 +234,8 @@ enum DebugLevel { */ #define PROPERTY_INITIALIZE_GL_ALWAYS "debug.hwui.initialize_gl_always" +#define PROPERTY_SKIP_EGLMANAGER_TELEMETRY "debug.hwui.skip_eglmanager_telemetry" + /////////////////////////////////////////////////////////////////////////////// // Misc /////////////////////////////////////////////////////////////////////////////// @@ -342,6 +344,7 @@ public: static bool clipSurfaceViews; static bool hdr10bitPlus; + static bool skipTelemetry; static bool resampleGainmapRegions; static int timeoutMultiplier; diff --git a/libs/hwui/aconfig/hwui_flags.aconfig b/libs/hwui/aconfig/hwui_flags.aconfig index 13c0b00daa21..a1f51687b077 100644 --- a/libs/hwui/aconfig/hwui_flags.aconfig +++ b/libs/hwui/aconfig/hwui_flags.aconfig @@ -98,6 +98,13 @@ flag { bug: "335172671" } +flag { + name: "skip_eglmanager_telemetry" + namespace: "core_graphics" + description: "Skip telemetry in EglManager's calls to eglCreateContext to avoid polluting telemetry" + bug: "347911216" +} + flag { name: "resample_gainmap_regions" namespace: "core_graphics" diff --git a/libs/hwui/renderthread/EglManager.cpp b/libs/hwui/renderthread/EglManager.cpp index 708b0113e13e..60104452f4c0 100644 --- a/libs/hwui/renderthread/EglManager.cpp +++ b/libs/hwui/renderthread/EglManager.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -366,6 +367,10 @@ void EglManager::createContext() { contextAttributes.push_back(EGL_CONTEXT_PRIORITY_LEVEL_IMG); contextAttributes.push_back(Properties::contextPriority); } + if (Properties::skipTelemetry) { + contextAttributes.push_back(EGL_TELEMETRY_HINT_ANDROID); + contextAttributes.push_back(android::GpuStatsInfo::SKIP_TELEMETRY); + } contextAttributes.push_back(EGL_NONE); mEglContext = eglCreateContext( mEglDisplay, EglExtensions.noConfigContext ? ((EGLConfig) nullptr) : mEglConfig, -- cgit v1.2.3-59-g8ed1b