summaryrefslogtreecommitdiff
path: root/libs/hwui/renderstate/RenderState.cpp
AgeCommit message (Collapse)Author
2020-01-10Add memory tracing in HWUIStan Iliev
Add ATRACE memory counters to track memory usage at the end of each frame in HWUI. There are 3 catagories: CPU, GPU and Texture memory. There are 3 more counters for memory that can be purged. This CL deletes GpuMemoryTracker class, which implemented similar function for Android O HWUI renderer. Test: Collected systrace with gmail and setting. Test: memory tracing adds ~0.1ms per frame when ATRACE is enabled Bug: 146580770 Change-Id: Icbcc0478bc426dff578e83726fe7c95df171ed93
2018-09-20Refactor RenderState and remove unused functionality.Derek Sollenberger
Test: hwui_unit_tests still pass Change-Id: Ie943671535ab8c5da1bac05985e815e0cb842dc1
2018-09-20Fix crash when EGLSurface is no longer valid.Derek Sollenberger
The EGLSurface stored in the pipeline can become obsolete if the EglManager/RenderThread has to destroy the context. This CL enables the RenderThread to notify all active pipelines that their surface is invalid. Bug: 115290937 Test: hwui_unit_tests Change-Id: Ib3054822273bc35406630b7442229a81b39a2c91
2018-09-05Reland "TextureView Vulkan support and optimized OpenGL draw"Stan Iliev
Fix an issue with incorrect texture matrix, when there is 90/270 rotation. This happened, because after refactoring SkImage has buffer width/height, instead of layer width/height. This reverts commit a683eb3945320f592f58705c3c31b3c044f4bd72. Bug: 113673613 Test: Ran TextureView CTS and lensblur in camera app Change-Id: If3bcf9cd5195de09fd67a753708568a8e3ca3a9a
2018-09-04Revert "Revert "Revert "TextureView Vulkan support and optimized OpenGL draw"""Stan Iliev
This reverts commit 85f9096b5272c9a39e592e2e97cbbe6cb0e767ab. Reason for revert: lensblur broken. Change-Id: I83ac163159fc537bc15936a0f8597a7512ca9d6e
2018-08-31Revert "Revert "TextureView Vulkan support and optimized OpenGL draw""Stan Iliev
This reverts commit 867c43de0544217d26c3ee18f4d6603bb2ea97ce. Reason for revert: Fixed issue with unsupported hardware buffer formats by landing https://skia-review.googlesource.com/c/skia/+/150470 "Support more hardware buffer formats" Bug: 113673613 Change-Id: I1f7c528f138e290160e75833c8d989d9535002ee
2018-08-30Revert "TextureView Vulkan support and optimized OpenGL draw"John Reck
This reverts commit c8e22a653297837da9a80b0ba65f6854c8986c96. Reason for revert: broke camera, b/113555199 Bug: 113555199 Change-Id: Iae9b462694d5de0cd99427afead63b567fb4d71d
2018-08-29TextureView Vulkan support and optimized OpenGL drawStan Iliev
Render TextureView as hardware bitmaps, instead of GL textures. Cache SkImage for each observed GraphicBuffer, which is faster even for GL. Implement C++ SurfaceTexture, which allows Java SurfaceTexture to be used with Vulkan HWUI render thread and application GL. threads. Delete GLLayer and VkLayer classes and texture code from old HWUI pipeline. Test: Ran skiagl and skiavk pipeline with a TextureView app. Test: TextureView CTS tests pass for GL pipeline. Test: Ran Android NDK Native codec sample app. Change-Id: Idc94f864ce2d34fd6ceff4be4fc7d3327e99879c
2018-05-30Remove dead codeJohn Reck
Test: builds Change-Id: I57cf72ca460115463d7759097d5ba598b5ec1775
2018-05-08remove obsolete Glop, Tessellators, Programs, and SkiaShaderMike Reed
Test: make Change-Id: I92f36335830dfc37be72468546637d9986f0baf1
2018-05-04remove BakedOps and much of renderstateMike Reed
Test: make Change-Id: If070b7436b848c6840abfac5f051b0f5b6cb17ce
2018-05-03Delete a bunch of codeJohn Reck
This removes the duality of DisplayList, removing a small amount of overhead Test: buids & hwuiunit passes Change-Id: I8bb3a20e9ead1caec4b4a8a3e9f2c08f717a7096
2018-05-03remove (dead) caches from hwuiMike Reed
Test: make Change-Id: I18bfe51896672272ce7d471eaead69b651399368
2017-11-03Format the world (or just HWUI)John Reck
Test: No code changes, just ran through clang-format Change-Id: Id23aa4ec7eebc0446fe3a30260f33e7fd455bb8c
2017-10-27Switch to a fancy new queueJohn Reck
Test: unit tests & benchmarks pass/faster Change-Id: I9521432172d6dd6039c5280b1265479a36a86247
2017-10-25Don't clear a layerPool that is never initialized.Derek Sollenberger
Test: device now boots in Vulkan without crash Change-Id: Ib0a3d8253a49fbcdb75e9f4edda0c32d06903669
2017-08-18Disable hwui blending for first draw to main FBOArun
bug:34809371 In some applications, the first draw is not opaque - either because the application is misbehaved, or because hwui is not able to reliably tell whether the layer is opaque or translucent. This is undefined behaviour in OpenGL ES and has a significant performance and bandwidth impact on some tiler GPUs as it requires loading the previous frame's color data. This change disables blending in that case and also for effectively opaque blend modes (SRC=GL_ONE, DST=GL_ZERO). It increases performance by ~10% for Leanback CTS on some low-end GPUs (gradient layer that hwui incorrectly believes to be translucent). Test: manual - visual inspection on fugu (nexus player) Change-Id: I2cbf1c76678acae1a36923e72fd18ed55cd89dc2
2017-08-10Delete all ro.hwui.* propsJohn Reck
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 Merged-In: I8b0d210572a246f4fefb076935cf5156a70c274c (cherry picked from commit 8dc02f99d09130ace2ee738c2e689db1b3f33181)
2017-06-01Merge "Optimised hwui rounded corners shader" am: d7287c96eb am: ed7bdd6549Arun
am: 92ef0a59f8 Change-Id: I9f5e6ef057ba6049804226d65f2f2f06594efc69
2017-06-01Optimised hwui rounded corners shaderArun
This is a ~2x performance increase for the rounded corners shader which was previously shader limited even on many high-end GPUs. It simplifies the calculations by pre-dividing by the radius, which also allows to maintain mediump/FP16 precision (this improves performance and might improve image quality on GPUs that don't support highp e.g. Mali-400). It also uses a conditional in the shader to save much of the work on the vast majority of pixels which are not close to the corners. Test: manual - visual inspection on fugu (nexus player) Change-Id: I38f491cfb006e2991ef0b9d6b3d67d2c4d328d44
2017-05-24Merge "Fix null deref crash" into oc-devJohn Reck
am: c1affe14c2 Change-Id: Ib8e4c34fb38400dc748b463c5ab965d57e260fd0
2017-05-23Fix null deref crashJohn Reck
Change-Id: Ic1a64e926b5faa2f4cf8d079a2b67e0261dcecd7 Fixes: 62035692 Test: manual
2017-05-23Merge "Improve time to texture destruction" into oc-devJohn Reck
am: 1bc0286ef8 Change-Id: I93daab53961a018a2cf8d4e2d4d8300b84bb917e
2017-05-22Improve time to texture destructionJohn Reck
Eliminate textureCache.mGarbage which is only cleared in a trimMemory. Instead when we hit ~Bitmap post a message to RenderThread to release the texture immediately Bug: 38258699 Test: manual Change-Id: I962ba275e89afb628ba02f74769287edbab9fed4
2017-05-05Merge "Reduce hwui CPU time by using glDrawRangeElements" am: 057c7c3164 am: ↵Arun
94f4f5e45f am: b5facc7516 Change-Id: I9e96bf83ae5ebd4237fc4d78a58e83793de86aad
2017-05-05Reduce hwui CPU time by using glDrawRangeElementsArun
The CPU overhead of glDrawElements in the GPU driver is significant with client-side vertex data (unique per draw call) as the driver has to calculate the mininimum and maximum indices from the index buffer in order to evaluate the range of vertex data required. This can be avoided by keeping track of the min-max in hwui and passing it with glDrawRangeElements. This requires OpenGL ES3.0 support (which is already checked for elsewhere in hwui). Test: manual - visual inspection on fugu (nexus player) Change-Id: I57bb1ddd239a1032f74f1cd2683bbe0970e84bd9
2017-03-28Convert bitmaps to sRGB/scRGB when they have a color profileRomain Guy
This change also fixes an issue with RGBA16F bitmaps when modulated with a color (for instance by setting an alpha on the Paint object). The color space conversion is currently done entirely in the shader, by doing these operations in order: 1. Sample the texture 2. Un-premultiply alpha 3. Apply the EOTF 4. Multiply by the 3x3 color space matrix 5. Apply the OETF 6. Premultiply alpha Optimizations: - Steps 2 & 6 are skipped for opaque (common) bitmaps - Step 3 is skipped when the color space's EOTF is close to sRGB (Display P3 for instance). Instead, we use a hardware sRGB fetch (when the GPU supports it) - When step 3 is necessary, we use one of four standard EOTF implementations, to save cycles when possible: + Linear (doesn't do anything) + Full parametric (ICC parametric curve type 4 as defined in ICC.1:2004-10, section 10.15) + Limited parametric (ICC parametric curve type 3) + Gamma (ICC parametric curve type 0) Color space conversion could be done using texture samplers instead, for instance 3D LUTs, with or without transfer functions baked in, or 1D LUTs for transfer functions. This would result in dependent texture fetches which may or may not be an advantage over an ALU based implementation. The current solution favor the use of ALUs to save precious bandwidth. Test: CtsUiRenderingTests, CtsGraphicsTests Bug: 32984164 Change-Id: I10bc3db515e13973b45220f129c66b23f0f7f8fe
2017-03-06Add ColorSpace information on BitmapRomain Guy
This is the first step toward interpreting color spaces at render time. Bug: 32984164 Test: BitmapColorSpaceTest in CtsGraphicsTestCases Change-Id: I0164a18f1ed74a745874fe5229168042afe27a04
2017-02-06Clean up deferredLayers only onGpuContextDestroyed.sergeyv
Test: manual bug:34919311 Change-Id: I5488b0845ec3922424f5893943e4f42675dfc9fd
2017-01-30Explicitly destroy Layer in DeferredLayerUpdater on destroyHardwareResources()sergeyv
Change-Id: I0987104eabda9a2a302b9e765213aad48f93aea4 Test: refactoring CL. Existing tests still pass bug:33753499
2017-01-10Add support for dummy draws for Vulkan webview and texture views.Greg Daniel
Test: manual testing Change-Id: Iaec8c3a34367673c281665ff6c6e97d1ce532265
2017-01-10Break Layer class into Gl and Vulkan subclassesGreg Daniel
Test: manual testing Change-Id: Ibd2beed39de3ac6da7448e96496253cfe427dfbb
2016-10-26Add target to texturesergeyv
Test: refactoring cl. bug:32413624 Change-Id: I94b1c31cd4e0712dfcfd7777a0012424c1bf0dca
2016-10-11Linear blending, step 1Romain Guy
NOTE: Linear blending is currently disabled in this CL as the feature is still a work in progress Android currently performs all blending (any kind of linear math on colors really) on gamma-encoded colors. Since Android assumes that the default color space is sRGB, all bitmaps and colors are encoded with the sRGB Opto-Electronic Conversion Function (OECF, which can be approximated with a power function). Since the power curve is not linear, our linear math is incorrect. The result is that we generate colors that tend to be too dark; this affects blending but also anti-aliasing, gradients, blurs, etc. The solution is to convert gamma-encoded colors back to linear space before doing any math on them, using the sRGB Electo-Optical Conversion Function (EOCF). This is achieved in different ways in different parts of the pipeline: - Using hardware conversions when sampling from OpenGL textures or writing into OpenGL frame buffers - Using software conversion functions, to translate app-supplied colors to and from sRGB - Using Skia's color spaces Any type of processing on colors must roughly ollow these steps: [sRGB input]->EOCF->[linear data]->[processing]->OECF->[sRGB output] For the sRGB color space, the conversion functions are defined as follows: OECF(linear) := linear <= 0.0031308 ? linear * 12.92 : (pow(linear, 1/2.4) * 1.055) - 0.055 EOCF(srgb) := srgb <= 0.04045 ? srgb / 12.92 : pow((srgb + 0.055) / 1.055, 2.4) The EOCF is simply the reciprocal of the OECF. While it is highly recommended to use the exact sRGB conversion functions everywhere possible, it is sometimes useful or beneficial to rely on approximations: - pow(x,2.2) and pow(x,1/2.2) - x^2 and sqrt(x) The latter is particularly useful in fragment shaders (for instance to apply dithering in sRGB space), especially if the sqrt() can be replaced with an inversesqrt(). Here is a fairly exhaustive list of modifications implemented in this CL: - Set TARGET_ENABLE_LINEAR_BLENDING := false in BoardConfig.mk to disable linear blending. This is only for GLES 2.0 GPUs with no hardware sRGB support. This flag is currently assumed to be false (see note above) - sRGB writes are disabled when entering a functor (WebView). This will need to be fixed at some point - Skia bitmaps are created with the sRGB color space - Bitmaps using a 565 config are expanded to 888 - Linear blending is disabled when entering a functor - External textures are not properly sampled (see below) - Gradients are interpolated in linear space - Texture-based dithering was replaced with analytical dithering - Dithering is done in the quantization color space, which is why we must do EOCF(OECF(color)+dither) - Text is now gamma corrected differently depending on the luminance of the source pixel. The asumption is that a bright pixel will be blended on a dark background and the other way around. The source alpha is gamma corrected to thicken dark on bright and thin bright on dark to match the intended design of fonts. This also matches the behavior of popular design/drawing applications - Removed the asset atlas. It did not contain anything useful and could not be sampled in sRGB without a yet-to-be-defined GL extension - The last column of color matrices is converted to linear space because its value are added to linear colors Missing features: - Resource qualifier? - Regeneration of goldeng images for automated tests - Handle alpha8/grey8 properly - Disable sRGB write for layers with external textures Test: Manual testing while work in progress Bug: 29940137 Change-Id: I6a07b15ab49b554377cd33a36b6d9971a15e9a0b
2016-07-07Delete old rendering pipelineChris Craik
fixes: 30002246 Change-Id: I45df0e924708526cee045b14c291bd23aa1a92db
2016-05-04Merge "Use LUT for computing final shadow alpha" into nyc-devChris Craik
am: b2e36d7939 * commit 'b2e36d7939610de538a6ec95a821b61b365b3073': Use LUT for computing final shadow alpha Change-Id: Ia17e3b93e9ade0633aee5a1e9edd60b92dd1e062
2016-05-03Use LUT for computing final shadow alphaChris Craik
bug:27415250 Significantly reduces shadow fragment shader computation. Change-Id: Ie9b3c712700754b3734d0ae9cda8751c298fc59e
2016-04-28resolve merge conflicts of 1599b981 to nyc-dev-plus-aospChih-Hung Hsieh
Change-Id: I90807581e10b6a0024515ff634ac8b29eaa5fc9f
2016-04-27Fix google-explicit-constructor warnings.Chih-Hung Hsieh
Bug: 28341362 Change-Id: Ibdd6a210bb7ff228e3624cc319169f77aca3b51e
2016-02-24Cleanup vertex attrib managementChris Craik
bug:27289007 Also removes unused code in MeshState Change-Id: I46116631111cc82e1cdffb5706344bbb6d4c6600
2016-01-29Fix copyLayerIntoJohn Reck
Bug: 26763945 Change-Id: I21ffbd56cf70bad0928416963e6fc254be435af9
2016-01-25Add fine-grained debug layerJohn Reck
Full GLES error checking layer via -include trickery. Change DEBUG_OPENGL to a level system. HIGH = every GL call is error checked MODERATE = checkpointing at interesting spots LOW = only asserts there are no errors at the end of a frame or when the FBO changes NONE = AIN'T GOT NO TIME FOR ERRORS GOTTA GO FAST! Change-Id: Ibe81aae93d942059c4ddf1cbb11c828b7ce4c10b
2016-01-21resolve merge conflicts of 32a95af029 to master.John Reck
Change-Id: I35b7cea1d34cb24f431ba2b76433a5b0ef1cb602
2016-01-21libhwui: fix texture memory leakDohyun Lee
When there is not enough space and we cannot delete any Texture in TextureCache to secure space, a new Texture is created over and over again for the same SkBitmap and there is the case that it is not deleted. This patch avoids such cases. Change-Id: Ic5353995e6d0716c31fe3bb49c60ec1a71574643 Signed-off-by: Dohyun Lee <leedhyun11@gmail.com>
2016-01-19Fix ordering of texture->upload argumentsJohn Reck
Caught by scatter-shotting GL_CHECKPOINTS which seem generally useful to have Bug: 26609444 Change-Id: Ie31d9297d8dae56405126720f338b4256c8bae77
2016-01-14Fix "leak" in FrameBuilder.textureLayer testJohn Reck
DeferredLayerUpdater always did a post to delete itself, which would result in the test thinking it had leaked an object since it wasn't deleted when it returned. Fix this by deleting immediately if we're already on the right thread. Remove RenderState's requireGlContext assert as it's now covered by GpuMemoryTracker, which is also more test friendly. RenderState's assert required an actual EGL context, which we don't mock away in unit tests. Change-Id: Ic23eb54e7151355f7acca483d7464350c9d6a87f
2016-01-14Track texture memory globallyJohn Reck
Also mostly consolidates texture creation Change-Id: Ifea01303afda531dcec99b8fe2a0f64cf2f24420
2015-11-12Recycle OffscreenBuffersChris Craik
Change-Id: Ia2e219026f211a5308ecf8209c5f986bb888aadd
2015-10-26Initial version of clipped saveLayer in new pipelineChris Craik
Additionally disables usage of FBO cache, so FBO destruction safely interacts with renderstate caching. Change-Id: I25c277cb7afec2ca33bf226445d6c8867a15a915
2015-09-28Move ortho matrix out of glopChris Craik
It's fbo-global, so don't bother stashing/restoring it repeatedly. Change-Id: Icb32e3eda5d2086aaae07140f8ff40e038dad5fe