Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[ImpellerC] Write a depfile when --shader-bundle is in use#186341

Merged
bdero merged 2 commits into
flutter:masterfrom
bdero:bdero/impellerc-shaderbundle-depfile
May 12, 2026
Merged

[ImpellerC] Write a depfile when --shader-bundle is in use#186341
bdero merged 2 commits into
flutter:masterfrom
bdero:bdero/impellerc-shaderbundle-depfile

Conversation

@bdero
Copy link
Copy Markdown
Member

@bdero bdero commented May 11, 2026

Fixes #186340

When impellerc is invoked with both --depfile=<path> and --shader-bundle=<json>, the depfile is silently dropped. impellerc_main.cc takes an early return into GenerateShaderBundle(switches) when --shader-bundle is set, and the depfile-writing branch only runs on the non-bundle path. Build systems consuming impellerc for shader bundles (notably Dart's hooks framework, which flutter_gpu_shaders's buildShaderBundleJson goes through) have no way to discover which source files and transitive #include headers contributed to the produced bundle, and therefore cannot rerun the bundle build when any input changes. The user-visible effect is that editing a .frag referenced by a shader bundle manifest does not invalidate the cached bundle output until flutter clean is run, which makes shader iteration painful and confuses new users.

This change threads an optional std::set<std::string>* out_dependencies parameter through GenerateShaderBundleFlatbuffer, GenerateShaderFB, and GenerateShaderBackendFB. Each Compiler instance reports its GetIncludedFileNames() plus the primary shader source file into the set, which dedupes naturally across the five target-platform compiles per shader. After successful bundle generation, GenerateShaderBundle emits a Ninja-style depfile when --depfile is set, mirroring the format produced by Compiler::CreateDepfileContents on the single-shader compile path.

Manually verified end to end against a real bundle whose only shader transitively #includes a header: the resulting depfile lists both files. The new unit tests cover both the explicit-collector path (set contains the primary source files) and the null-collector path (callers that don't pass a set get exactly today's behaviour). Existing shader-bundle unit tests continue to pass unchanged.

Pre-launch Checklist

Threads a dependency-collecting set through GenerateShaderBundleFlatbuffer,
GenerateShaderFB, and GenerateShaderBackendFB. Each Compiler reports its
included file names plus the primary shader source file into the set,
which dedupes naturally across the five target-platform compiles per
shader. After successful bundle generation, GenerateShaderBundle emits a
Ninja-style depfile when --depfile is set, mirroring the format produced
by Compiler::CreateDepfileContents on the single-shader compile path.

Previously, --depfile was silently dropped in --shader-bundle mode
because the early return into GenerateShaderBundle bypassed OutputDepfile.
Build systems consuming impellerc for shader bundles (notably Dart's
hooks framework, which flutter_gpu_shaders goes through) had no way to
discover which source files and transitive #include headers contributed
to the bundle, and therefore couldn't rerun the bundle build when any
input changed.

Tests confirm the dependency set contains the primary source files. Both
the explicit-collector and null-collector paths are exercised. Existing
shader bundle tests continue to pass unchanged.

Fixes flutter#186340
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label May 11, 2026
@github-actions github-actions Bot added engine flutter/engine related. See also e: labels. e: impeller Impeller rendering backend issues and features requests labels May 11, 2026
Copy link
Copy Markdown
Contributor

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

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 implements Ninja-style depfile generation for shader bundles by tracking source files and transitive includes during compilation. It updates the compilation pipeline to collect these dependencies, adds a utility to write them to disk, and includes unit tests to verify the new functionality. Review feedback recommends resolving paths relative to the specified working directory, simplifying string conversions in file operations, and using UTF-8 encoding for target paths to ensure cross-platform compatibility.

Comment thread engine/src/flutter/impeller/compiler/shader_bundle.cc Outdated
Comment thread engine/src/flutter/impeller/compiler/shader_bundle.cc Outdated
Comment thread engine/src/flutter/impeller/compiler/shader_bundle.cc Outdated
@github-actions github-actions Bot removed the CICD Run CI/CD label May 11, 2026
@github-project-automation github-project-automation Bot moved this to 🤔 Needs Triage in Flutter GPU May 11, 2026
@bdero bdero changed the title [Impeller] Write a depfile when --shader-bundle is in use [ImpellerC] Write a depfile when --shader-bundle is in use May 11, 2026
@bdero bdero moved this from 🤔 Needs Triage to ⚙️ In Progress in Flutter GPU May 11, 2026
@bdero bdero added the CICD Run CI/CD label May 11, 2026
@bdero bdero requested a review from gaaclarke May 11, 2026 09:38
Copy link
Copy Markdown
Member

@gaaclarke gaaclarke left a comment

Choose a reason for hiding this comment

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

lgtm, thanks!

@bdero bdero enabled auto-merge May 11, 2026 22:13
@bdero bdero added this pull request to the merge queue May 11, 2026
Merged via the queue into flutter:master with commit 037b916 May 12, 2026
202 of 203 checks passed
@bdero bdero deleted the bdero/impellerc-shaderbundle-depfile branch May 12, 2026 00:07
@github-project-automation github-project-automation Bot moved this from ⚙️ In Progress to ✅ Done in Flutter GPU May 12, 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. flutter-gpu

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

[Impeller] impellerc --depfile is silently ignored in --shader-bundle mode

2 participants