Repository navigation
Conversation
…lace on OpenGLES - Add `Texture::ResizeStorage(ISize)` virtual hook implemented on `TextureGLES` via `glTexImage2D` in-place reallocation while preserving the GL texture ID and `cached_fbo_`, re-attaching color/depth/stencil attachments via `InitializeContentsIfNecessary()` when an existing cached FBO is live. - Update `RenderTargetCache::CreateOffscreen` and `CreateOffscreenMSAA` to adopt and grow undersized unused cached `RenderTarget` entries (`entry.size <= target.size`, high-water-mark policy) instead of allocating a fresh texture and FBO per size step. - Quantize non-backdrop `Canvas::SaveLayer` offscreen bounds up to 32-pixel multiples (`kSubpassSizeQuantum = 32`) when transforming local content bounds on `SaveLayer`. - Add unit tests in `RenderTargetCacheTest` verifying in-place growth, high-water-mark reuse without shrinking, and multi-target best-fit adoption.
…target-inplace-resize
…zation, and add MockGLES ResizeStorage test
This was referenced Oct 13, 2026
Member
|
This isn't something we're interested in doing. It's actually an antipattern with respect to using opengles and will likely negatively affect android opengles. It's kind of hacking around overhead incurred by emscripten when creating new objects by mutating an existing object. I'd be more interested in a fix that addresses this for all backend. We've investigated quantizing render targets but it doesn't' play well with how our fragment shaders are authored. It's a nontrivial change. |
4 of 11 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reuses cached offscreen
RenderTargetentries acrossSaveLayerandFilterContentssubpasses on OpenGL ES by resizing backing texture and renderbuffer storage in place instead of allocating a new GL texture and framebuffer object (FBO) on every subpass size change.Rationale
RenderTargetCache::CreateOffscreenandCreateOffscreenMSAApreviously required an exactISizematch (other_config == config) to reuse a retainedRenderTarget. On animatedSaveLayer,BackdropFilter, andImageFilterworkloads where subpass bounds change by 1–2 pixels per frame, every size change missed the cache—allocating a freshTextureGLESandglGenFramebuffershandle during the frame and destroying the previous set afterkeep_alive_frame_count_expiry (346glCreateTextureand440glCreateRenderbuffercalls on a64-nodeSaveLayer+ImageFilter.blurworkload).Summary of Changes
engine/src/flutter/impeller/core/texture.h&engine/src/flutter/impeller/renderer/backend/gles/texture_gles.{h,cc}: Add a virtualTexture::ResizeStorage(ISize)hook (defaulting tofalse) implemented onTextureGLESfor non-wrapped textures and renderbuffers. When the texture was previously initialized or has a valid cached FBO (cached_fbo_.IsValid()),ResizeStorageupdatesTextureDescriptor::sizeand reallocates backing storage in place viaInitializeContentsIfNecessary()while preserving both the GL texture/renderbuffer handle andcached_fbo_.engine/src/flutter/impeller/renderer/render_target.{h,cc}&engine/src/flutter/impeller/entity/render_target_cache.cc: AddPixelFormat color_formattoRenderTargetConfig(operator==andHash()) so cached targets with different pixel formats are kept distinct, and updateRenderTargetCache::CreateOffscreen/CreateOffscreenMSAAonBackendType::kOpenGLESto reuse an unused entry with matching(mip_count, has_msaa, has_depth_stencil, color_format)whenResizeStorage(size)succeeds on its attachments.engine/src/flutter/impeller/entity/render_target_cache_unittests.cc&engine/src/flutter/impeller/renderer/backend/gles/test/texture_gles_unittests.cc: AddRenderTargetCacheTest.RecyclesAndResizesCachedTexturesInPlaceOnGLES,RenderTargetCacheTest.SeparatesCachedTargetsByColorFormat, andTextureGLESMockTest.ResizeStorageReallocatesInPlace.Performance & WebGL 2.0 Call Reduction
1280x720,bouncy_multipass@64SaveLayer+ImageFilter.blur+ColorFiltered)glCreateTexture/glDeleteTexture/ frame3460-100%glCreateRenderbuffer/glDeleteRenderbuffer/ frame4400-100%glBindFramebuffercalls / frame1,747637-63.5%RenderTargetCache::CreateOffscreenMSAACPU self-time (V8profile)109.36 ms14.49 ms-86.7%(7.55xfaster)rasterTimeMs(AMD Radeon 780M,wimp_st/wimp_mt)9.71 ms/22.24 ms5.28 ms/12.19 ms-45.6%(1.84x) /-45.2%(1.83x)Verification
host_debug_unopt:impeller_unittests --gtest_filter="*TextureGLESMockTest*:*RenderTargetCache*/*OpenGLES*"locally (17/17passed).wasm_release:skwasm/wimp.jsand verified WebGL2 texture/renderbuffer/FBO call counts and rendering parity on[email protected].Towards #174980
Related to #192147
Pre-launch Checklist
///).