Skip to content

Move the Vulkan wrapped-texture helper out of the GPU surface - #193001

Merged
auto-submit[bot] merged 2 commits into
flutter:masterfrom
jwinarske:pr3/wrap-texture-source
Oct 9, 2026
Merged

auto-submit[bot] merged 2 commits into
flutter:masterfrom
jwinarske:pr3/wrap-texture-source

Conversation

@jwinarske

Copy link
Copy Markdown
Contributor

GPUSurfaceVulkanImpeller carries a private TextureSourceVK subclass that wraps a VkImage the caller owns and creates a view for it. Nothing about it belongs to the root surface, and the embedder needs the same thing to build a render target from a backing store (#187525).

Move it to impeller/renderer/backend/vulkan as WrapTextureSourceVK. No behavior change; the surface loses 53 lines.

Tests

No new ones — this is a move. gpu_surface_unittests covers the surface that now calls it, including the transients-recreation test that exercises the wrapped image path.

Third of six, from #187525. The fifth needs this one. Conflicts textually with the second (same file), so whichever lands second wants a rebase.

@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Sep 18, 2026
@flutter-dashboard

Copy link
Copy Markdown

It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the Vulkan backend by extracting the WrappedTextureSourceVK class into a reusable utility (texture_wrapper_vk.h/cc) and updating GPUSurfaceVulkanImpeller to use it. The review feedback suggests parameterizing the IsSwapchainImage property instead of hardcoding it to true, which will allow the utility to support non-swapchain embedder-provided backing stores.

@github-actions github-actions Bot added engine flutter/engine related. See also e: labels. e: impeller Impeller rendering backend issues and features requests labels Sep 18, 2026
@jwinarske

Copy link
Copy Markdown
Contributor Author

Test exemption: this is a move. Same code, same behavior, no new API — the class goes from a private one in gpu_surface_vulkan_impeller.cc to impeller/renderer/backend/vulkan, and the surface calls it instead of defining it.

Existing coverage follows it: gpu_surface_unittests exercises the surface that calls it, including RecreatesTransientsWhenFrameSizeChanges, which goes through the wrapped image. #193003 is where it gets a second caller and new tests.

@jwinarske
jwinarske force-pushed the pr3/wrap-texture-source branch from 7eb88b4 to b349835 Compare September 18, 2026 20:09
@jwinarske

Copy link
Copy Markdown
Contributor Author

Force-pushed: restacked onto #193000.

This never built standalone. The .cc here uses render_to_surface_, which #193000 declares in the header — I split one file's changes across two PRs and each half needed the other. That is why the failures were on every platform rather than anything Vulkan-specific: one translation unit failing to compile in every config.

Land #193000 first.

@jwinarske
jwinarske force-pushed the pr3/wrap-texture-source branch from b349835 to 9984cd6 Compare September 18, 2026 20:19
@gaaclarke
gaaclarke requested a review from andywolff September 21, 2026 18:13

@andywolff andywolff left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly LGTM

Comment thread engine/src/flutter/shell/gpu/gpu_surface_vulkan_impeller.cc Outdated
andywolff
andywolff previously approved these changes Oct 7, 2026

@andywolff andywolff left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. FYI I pushed a merge to move past a tree breakage so CI can pass for this PR. I imagine you'll want to merge #193000 first and rebase this. Happy to reapprove at that point if needed

jwinarske and others added 2 commits October 8, 2026 06:54
GPUSurfaceVulkanImpeller carries a private TextureSourceVK subclass that
wraps a VkImage the caller owns and creates a view for it. Nothing about it
belongs to the root surface, and the embedder needs the same thing to build
a render target from a backing store (flutter#187525).

Move it to impeller/renderer/backend/vulkan as WrapTextureSourceVK and call
it from the surface. No behavior change; the surface loses 53 lines.
impeller_context_ is a shared_ptr<impeller::Context> handed in by the caller, and
which concrete type it holds depends on the construction path: the
delegate_ == nullptr branch casts it to SurfaceContextVK, the backing-store
branch to ContextVK. DisposeThreadLocalCachedResources runs before that branch,
on both paths, so ContextVK::Cast there is an unchecked downcast whenever the
context is a SurfaceContextVK, which derives from Context rather than ContextVK.
It then locks desc_pool_mutex_ at the wrong offset, pthread_mutex_lock returns
EINVAL, and the process aborts.

DisposeThreadLocalCachedResources, CreateCommandBuffer and GetCommandQueue are
all virtual on Context, and SurfaceContextVK overrides or delegates them, so call
through the base and drop both casts.
@jwinarske

Copy link
Copy Markdown
Contributor Author

@andywolff rebased onto master now that #193000 has landed, which dismissed your approval — sorry for the re-review.

Same change you approved, with one difference worth pointing at. #193000 was squash-merged, so its commit is no longer an ancestor here; I cherry-picked this branch's own two commits onto master and dropped it along with the two master merges. The cast fix therefore carries only its submit-callback half now, because the DisposeThreadLocalCachedResources half arrived with #193000.

Net is 4 files, +124/-56: the helper move plus that one hunk. The remaining casts in gpu_surface_vulkan_impeller.cc are SurfaceContextVK::Cast on the delegate_ == nullptr branch, which is sound, and nothing else.

@andywolff andywolff left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@andywolff andywolff added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 9, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Oct 9, 2026
Merged via the queue into flutter:master with commit b7fbbb1 Oct 9, 2026
24 of 25 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD e: impeller Impeller rendering backend issues and features requests engine flutter/engine related. See also e: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants