[Impeller] Add golden harness support to the renderer test layer#186735
Conversation
Add a render-pass OpenPlaygroundHere overload to GoldenPlaygroundTest that renders a callback into an offscreen target and screenshots it, reusing the existing screenshotters and golden upload path. Add renderer_golden_unittests.cc with one ported triangle test, so renderer goldens can be opted in per test rather than all at once.
There was a problem hiding this comment.
Code Review
This pull request introduces a new overload for OpenPlaygroundHere in GoldenPlaygroundTest that accepts a SinglePassCallback, enabling golden testing for the low-level renderer API. It also includes a new test file, renderer_golden_unittests.cc, with a test case for rendering a basic triangle. Feedback suggests resetting the host_buffer within the render callback to maintain consistency across the multiple passes executed by the test harness.
The renderer golden test added in this PR covers the same scene.
Addresses review: the harness runs the callback twice.
gaaclarke
left a comment
There was a problem hiding this comment.
The CI failure looks apropos. I'll refrain from reviewing until CI passes:
[----------] 4 tests from Play/RendererGoldenTest
[ RUN ] Play/RendererGoldenTest.BabysFirstTriangle/Metal
-[MTLDebugRenderCommandEncoder setRenderPipelineState:]:1616: failed assertion `Set Render Pipeline State Validation
For stencil attachment, the renderPipelineState pixelFormat must be MTLPixelFormatInvalid, as no texture is set.
'
[ERROR:flutter/fml/backtrace.cc(108)] Caught signal SIGABRT during program execution.
Frame 0: 0x18688fc18 err
Frame 1: 0x191f27cb0 MTLGetEnvCase<>()
Frame 2: 0x191efcd70 MTLReportFailure
Frame 3: 0x191ef2930 _MTLMessageContextEnd
Frame 4: 0x1872dd8c8 -[MTLDebugRenderCommandEncoder setRenderPipelineState:]
Frame 5: 0x1046a7054 impeller::PassBindingsCacheMTL::SetRenderPipelineState()
Frame 6: 0x1046ad93c impeller::RenderPassMTL::SetPipeline()
Frame 7: 0x104287294 std::__fl::__function::__func<>::operator()()
Frame 8: 0x10473d914 impeller::GoldenPlaygroundTest::OpenPlaygroundHere()
Frame 9: 0x10427a230 impeller::testing::RendererGoldenTest_BabysFirstTriangle_Test::TestBody()
Frame 10: 0x1047524fc testing::Test::Run()
Frame 11: 0x10475369c testing::TestInfo::Run()
Frame 12: 0x10475442c testing::TestSuite::Run()
Frame 13: 0x104764710 testing::internal::UnitTestImpl::RunAllTests()
Frame 14: 0x104763fb4 testing::UnitTest::Run()
Frame 15: 0x10409b210 main
Frame 16: 0x1865e6b98 start
The harness offscreen target has no stencil texture but SetStencilAttachmentDescriptors(nullopt) leaves the pipeline's stencil pixel format set, which trips Metal API Validation on the release-mode CI builders. Switch to ClearStencilAttachments(), which clears both the descriptors and the pixel format. Also tighten the harness docstring so future golden tests do not hit this.
|
Whoops, wrong stencil clear util in the test. Hopefully it'll be good to go now. |
| namespace testing { | ||
|
|
||
| using RendererGoldenTest = GoldenPlaygroundTest; | ||
| INSTANTIATE_PLAYGROUND_SUITE(RendererGoldenTest); |
There was a problem hiding this comment.
Went for the approach of adding a new TU in order to incrementally land new goldens for features and regressions. But it might be a good idea for us to preen through all of the other playgrounds within renderer_unittests.cc at some point and decide which ones are worth golden-izing.
Some are simple static renders that might still make for good verifications, and some are more like... sentimental easter eggs.
…yout RenderPassVK::OnBeginRenderPass unconditionally tracked the color attachment as VK_IMAGE_LAYOUT_GENERAL post-pass, but the Vulkan render pass finalLayout (per ComputeFinalLayout in render_pass_builder_vk.cc) transitions non-swapchain, single-sampled color attachments to VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL. The mismatch produced an incorrect oldLayout on the next barrier and tripped Vulkan validation VUID-vkCmdDraw-None-09600 the first time anything (e.g. the screenshot blit) operated on the texture after the pass. Aiks targets are MSAA so the bug stayed latent until the renderer golden harness landed a non-MSAA offscreen path. Validated locally with the Vulkan SDK and SwiftShader: BabysFirstTriangle/Vulkan now passes and the 435 AiksTest Vulkan goldens still pass with validation on.
…den_unittests clang-tidy does not recognise gtest's ASSERT_TRUE as flow-affecting, so desc-> accesses after ASSERT_TRUE(desc.has_value()) trip bugprone-unchecked-optional-access. Use the same NOLINTBEGIN/NOLINTEND block as renderer_unittests.cc, referencing the same tracking issue.
855c701 to
1ba148f
Compare
|
Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change). If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
@gaaclarke Thanks for the review. Can you approve the new goldens please? I do not have permission. |
Roll Flutter from e03b91f1fe34 to f3a4b9897834 (63 revisions) flutter/flutter@e03b91f...f3a4b98 2026-05-26 47866232+chunhtai@users.noreply.github.com Update batch release doc to reflect latest workflow (flutter/flutter#186979) 2026-05-26 engine-flutter-autoroll@skia.org Roll Skia from 0442274cc696 to 27a819894f7c (5 revisions) (flutter/flutter#187094) 2026-05-26 bkonyi@google.com [Tool Robustness] Gracefully handle asynchronous subprocess crashes and connection timeouts (flutter/flutter#186964) 2026-05-26 bkonyi@google.com [pubspec] Bump Dart SDK constraint to ^3.13.0 (flutter/flutter#186957) 2026-05-26 engine-flutter-autoroll@skia.org Roll Dart SDK from 7eb54169841d to 00e625453c43 (1 revision) (flutter/flutter#187086) 2026-05-26 bdero@google.com [Impeller] Retire Y-coord-scale plumbing by flipping GLES at the vertex stage (flutter/flutter#186556) 2026-05-26 engine-flutter-autoroll@skia.org Roll Skia from f4f294bdf98d to 0442274cc696 (2 revisions) (flutter/flutter#187079) 2026-05-26 kevmoo@users.noreply.github.com [flutter_tools] Fix version cache poisoning from git environment variables (flutter/flutter#186595) 2026-05-26 bkonyi@google.com [Tool] Handle DTD connection failures gracefully in widget-preview (flutter/flutter#186952) 2026-05-25 engine-flutter-autoroll@skia.org Roll Skia from 9d1adb5f2427 to f4f294bdf98d (1 revision) (flutter/flutter#187056) 2026-05-25 engine-flutter-autoroll@skia.org Roll Skia from 4dd78179e6ec to 9d1adb5f2427 (1 revision) (flutter/flutter#187048) 2026-05-25 engine-flutter-autoroll@skia.org Roll Skia from 1f26101197bf to 4dd78179e6ec (4 revisions) (flutter/flutter#187044) 2026-05-24 engine-flutter-autoroll@skia.org Roll Skia from bbe9ccc2bdbf to 1f26101197bf (1 revision) (flutter/flutter#187016) 2026-05-24 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from nsgcNDlZOuweOvy3Q... to Itd2Jq_ZIABH2rW7B... (flutter/flutter#187032) 2026-05-23 engine-flutter-autoroll@skia.org Roll Dart SDK from 7e0f28eb5315 to 7eb54169841d (1 revision) (flutter/flutter#187005) 2026-05-23 engine-flutter-autoroll@skia.org Roll Dart SDK from 90e55fa88456 to 7e0f28eb5315 (1 revision) (flutter/flutter#186990) 2026-05-23 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from 6T6BY9PTftoG3vP_1... to nsgcNDlZOuweOvy3Q... (flutter/flutter#186984) 2026-05-23 chris@bracken.jp iOS] Migrate VSyncClient to a pure Obj-C implementation (#186166) (flutter/flutter#186935) 2026-05-23 30870216+gaaclarke@users.noreply.github.com Disables embedder_tests.cm for fuchsia (flutter/flutter#186969) 2026-05-23 engine-flutter-autoroll@skia.org Roll Dart SDK from b8414c46f6c7 to 90e55fa88456 (2 revisions) (flutter/flutter#186977) 2026-05-22 engine-flutter-autoroll@skia.org Roll Skia from 6fdb013d1953 to bbe9ccc2bdbf (1 revision) (flutter/flutter#186980) 2026-05-22 mdebbar@google.com [web] Fix cutoff text in WebParagraph (flutter/flutter#186819) 2026-05-22 1961493+harryterkelsen@users.noreply.github.com fix(web): Removes the iterative downscaling hack (flutter/flutter#186914) 2026-05-22 30870216+gaaclarke@users.noreply.github.com opts the linux embedder into sdf rendering (flutter/flutter#186909) 2026-05-22 engine-flutter-autoroll@skia.org Roll Skia from dae8778ca40d to 6fdb013d1953 (5 revisions) (flutter/flutter#186970) 2026-05-22 dacoharkes@google.com Fix hooks inputs outputs rebuilt (flutter/flutter#186701) 2026-05-22 30870216+gaaclarke@users.noreply.github.com adds linux impeller integration test for external textures (flutter/flutter#186759) 2026-05-22 kevmoo@users.noreply.github.com fix(flutter_tools): defensively catch DWDS unregistered service extension errors (flutter/flutter#186896) 2026-05-22 bdero@google.com [Impeller] Add golden harness support to the renderer test layer (flutter/flutter#186735) 2026-05-22 mdebbar@google.com [web] Remove image codecs from canvaskit_chromium (flutter/flutter#178133) 2026-05-22 30870216+gaaclarke@users.noreply.github.com opts all macos into wide gamut (flutter/flutter#186277) 2026-05-22 engine-flutter-autoroll@skia.org Roll Skia from 356185490a75 to dae8778ca40d (9 revisions) (flutter/flutter#186949) 2026-05-22 1598289+lukemmtt@users.noreply.github.com Filter out SwiftPM schemes when fetching schemes (flutter/flutter#186006) 2026-05-22 engine-flutter-autoroll@skia.org Roll Packages from 3754d04 to 69cf959 (1 revision) (flutter/flutter#186950) 2026-05-22 engine-flutter-autoroll@skia.org Roll Dart SDK from eca46bec956d to b8414c46f6c7 (2 revisions) (flutter/flutter#186944) 2026-05-22 30870216+gaaclarke@users.noreply.github.com Saves a DeviceHolderVK with the CommandPoolVK (flutter/flutter#186749) 2026-05-22 engine-flutter-autoroll@skia.org Roll Dart SDK from e0d509fd676e to eca46bec956d (1 revision) (flutter/flutter#186922) 2026-05-22 bkonyi@google.com [ Tool ] Stop generating widget preview scaffold under $TMP (flutter/flutter#186476) 2026-05-21 737941+loic-sharma@users.noreply.github.com Fix typo in StretchingOverscrollIndicator docs (flutter/flutter#186897) 2026-05-21 engine-flutter-autoroll@skia.org Roll Dart SDK from 28c7cb5a8e8d to e0d509fd676e (1 revision) (flutter/flutter#186903) 2026-05-21 jason-simmons@users.noreply.github.com Fix some issues in the integration between EmbedderExternalViewEmbedder and Impeller (flutter/flutter#184905) 2026-05-21 jason-simmons@users.noreply.github.com Fix a potential buffer overflow in the animated PNG decoder when parsing malformed fdAT chunks (flutter/flutter#186700) 2026-05-21 engine-flutter-autoroll@skia.org Roll Skia from 2ff20950975d to 356185490a75 (5 revisions) (flutter/flutter#186892) 2026-05-21 flar@google.com Add primitive shadows to rendering benchmark (flutter/flutter#186779) 2026-05-21 15619084+vashworth@users.noreply.github.com Move prefetchSwiftPackages to be per platform (flutter/flutter#186468) 2026-05-21 okorohelijah@google.com Upgrade iOS version (flutter/flutter#186889) ...
Renderer-layer unittests (
impeller/renderer/renderer_unittests.cc) open an interactive playground but never produce a checked image, so renderer-level rendering has no automated golden coverage.This adds golden support to that layer:
GoldenPlaygroundTestgets a render-passOpenPlaygroundHereoverload that renders a callback into an offscreen target and screenshots it, reusing the existing screenshotters and Skia Gold upload path.renderer_golden_unittests.ccholds renderer golden tests, so they are opted in one at a time rather than all at once. It starts with a single triangle test ported fromrenderer_unittests.cc.This is test infrastructure with no dedicated tracking issue. The need came up in #186653, where a renderer-layer instancing test had no golden coverage.
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.