Skip to content

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

Description

@bdero

What

When invoking `impellerc` with both `--depfile=` and `--shader-bundle=`, the resulting depfile is never written.

`impeller/compiler/impellerc_main.cc:211` takes an early return into `GenerateShaderBundle(switches)` when `--shader-bundle` is set. The depfile-writing branch (`OutputDepfile` at line 310) only runs on the non-bundle path. The user-visible result is that consumers of `--shader-bundle` have no way to learn which source files (the manifest entries plus their transitive `#include`s) contributed to the generated bundle.

Why it matters

Build systems that consume `impellerc` for shader bundles (notably Dart's `hooks` framework, which `flutter_gpu_shaders`' `buildShaderBundleJson` uses) need this information to rerun the bundle build when any contributing source file changes. Without it, the typical user workflow is:

  1. Author a `.frag` shader.
  2. Reference it from a manifest JSON file.
  3. Add the manifest to a `flutter_gpu_shaders` build hook.
  4. Edit the `.frag`.
  5. Notice that `flutter run` doesn't rebuild the shader bundle.
  6. Manually `flutter clean` and rerun.

Adding depfile support in shader-bundle mode lets build hooks declare the right dependency set and avoid the manual clean.

Repro

```
mkdir -p /tmp/depfile_test/shaders
cat > /tmp/depfile_test/shaders/test.frag <<'GLSL'
#version 460 core
#include "common.glsl"
out vec4 frag_color;
void main() { frag_color = COMMON_COLOR; }
GLSL
cat > /tmp/depfile_test/shaders/common.glsl <<'GLSL'
#define COMMON_COLOR vec4(1, 0, 0, 1)
GLSL
cd /tmp/depfile_test
impellerc --sl=out.shaderbundle \
--depfile=out.shaderbundle.d \
--include=shaders \
--shader-bundle='{"Test":{"type":"fragment","file":"shaders/test.frag"}}'
ls -la out.shaderbundle.d # File does not exist.
```

Fix

PR coming shortly: thread an optional `std::setstd::string* out_dependencies` parameter through `GenerateShaderBundleFlatbuffer` / `GenerateShaderFB` / `GenerateShaderBackendFB`. Each `Compiler` instance reports its `GetIncludedFileNames()` plus the primary source file path into the set (deduplicated across the 5 target-platform compiles of each shader). After bundle generation, write a Ninja-style depfile mirroring the one `Compiler::CreateDepfileContents` already emits for single-shader compiles.

Metadata

Metadata

Assignees

Labels

e: impellerImpeller rendering backend issues and features requestsengineflutter/engine related. See also e: labels.flutter-gpuhas reproducible stepsThe issue has been confirmed reproducible and is ready to work onteam-fluttergpuOwned by Flutter GPU team

Type

No type
No fields configured for issues without a type.

Projects

Status
✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions