BabylonJS/Babylon.js · error

FrameGraphGenerateMipMapsTask ${this.name}: targetTexture is

Error message

FrameGraphGenerateMipMapsTask ${this.name}: targetTexture is required

What it means

FrameGraphGenerateMipMapsTask.record() needs a targetTexture handle to know which texture's mip chain to generate and to resolve its outputTexture handle. Without it, the task cannot set up its pass, so it throws during record.

Source

Thrown at packages/dev/core/src/FrameGraph/Tasks/Texture/generateMipMapsTask.ts:35

    /**
     * Constructs a new FrameGraphGenerateMipMapsTask.
     * @param name The name of the task.
     * @param frameGraph The frame graph the task belongs to.
     */
    constructor(name: string, frameGraph: FrameGraph) {
        super(name, frameGraph);

        this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();
    }

    public override getClassName(): string {
        return "FrameGraphGenerateMipMapsTask";
    }

    public record() {
        if (this.targetTexture === undefined) {
            throw new Error(`FrameGraphGenerateMipMapsTask ${this.name}: targetTexture is required`);
        }

        this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, this.targetTexture);

        const outputTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.targetTexture);

        if (!outputTextureDescription.options.createMipMaps) {
            throw new Error(`FrameGraphGenerateMipMapsTask ${this.name}: targetTexture must have createMipMaps set to true`);
        }

        const pass = this._frameGraph.addRenderPass(this.name);

        pass.setRenderTarget(this.outputTexture);
        pass.setExecuteFunc((context) => {
            context.generateMipMaps();
        });

        const passDisabled = this._frameGraph.addRenderPass(this.name + "_disabled", true);

View on GitHub (pinned to 0592b347b8)

Solutions

  1. Assign task.targetTexture to the output texture handle of the texture that needs mipmaps before build().
  2. Ensure that texture was created (or imported) via frameGraph texture manager so the handle is valid.
  3. Skip adding the mipmap task when the pipeline config does not request mipmaps.

Example fix

// before
const mips = new FrameGraphGenerateMipMapsTask('mips');
fg.addTask(mips);
// after
const mips = new FrameGraphGenerateMipMapsTask('mips');
mips.targetTexture = copyTask.outputTexture;
fg.addTask(mips);
Defensive patterns

Strategy: validation

Validate before calling

if (mipTask.targetTexture === undefined) {
  throw new Error('mipTask.targetTexture must be set before frameGraph.build()');
}

Type guard

function hasTarget(t: FrameGraphGenerateMipMapsTask): t is FrameGraphGenerateMipMapsTask & { targetTexture: FrameGraphTextureHandle } {
  return t.targetTexture !== undefined;
}

Prevention

When it happens

Trigger: Adding FrameGenerateMipMapsTask to the frame graph and calling build() without assigning task.targetTexture (the handle of the texture that should receive mipmaps).

Common situations: Forgetting to wire the texture created by a preceding render/copy task into the mipmap task; creating the mipmap task in a generic pipeline builder that skips input assignment when a config key is absent.

Related errors


AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30). Data as JSON: /api/errors/99d058b23f78b45a. Report an issue: GitHub.