Comfy-Org/ComfyUI · error · RuntimeError

Ping-pong framebuffer is not complete

Error message

Ping-pong framebuffer is not complete

What it means

Raised in _render_shader_batch() when building the two ping-pong framebuffers used for multi-pass rendering (num_passes > 1): a single RGBA32F texture attached to GL_COLOR_ATTACHMENT0 did not yield a complete framebuffer. Because the main output FBO with the same texture format already succeeded, this almost always means resource exhaustion or texture/FBO id misuse rather than format support.

Source

Thrown at comfy_extras/nodes_glsl.py:495

        if num_passes > 1:
            for _ in range(2):
                pp_tex = gl.glGenTextures(1)
                ping_pong_textures.append(pp_tex)
                gl.glBindTexture(gl.GL_TEXTURE_2D, pp_tex)
                gl.glTexImage2D(gl.GL_TEXTURE_2D, 0, gl.GL_RGBA32F, width, height, 0, gl.GL_RGBA, gl.GL_FLOAT, None)
                gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER, gl.GL_LINEAR)
                gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_LINEAR)
                gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_S, gl.GL_CLAMP_TO_EDGE)
                gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_T, gl.GL_CLAMP_TO_EDGE)

                pp_fbo = gl.glGenFramebuffers(1)
                ping_pong_fbos.append(pp_fbo)
                gl.glBindFramebuffer(gl.GL_FRAMEBUFFER, pp_fbo)
                gl.glFramebufferTexture2D(gl.GL_FRAMEBUFFER, gl.GL_COLOR_ATTACHMENT0, gl.GL_TEXTURE_2D, pp_tex, 0)
                gl.glDrawBuffers(1, [gl.GL_COLOR_ATTACHMENT0])

                if gl.glCheckFramebufferStatus(gl.GL_FRAMEBUFFER) != gl.GL_FRAMEBUFFER_COMPLETE:
                    raise RuntimeError("Ping-pong framebuffer is not complete")

        # Create input textures (reused for all batches)
        for i in range(num_inputs):
            tex = gl.glGenTextures(1)
            input_textures.append(tex)
            gl.glActiveTexture(gl.GL_TEXTURE0 + i)
            gl.glBindTexture(gl.GL_TEXTURE_2D, tex)
            gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER, gl.GL_LINEAR)
            gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_LINEAR)
            gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_S, gl.GL_CLAMP_TO_EDGE)
            gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_T, gl.GL_CLAMP_TO_EDGE)

            loc = gl.glGetUniformLocation(program, f"u_image{i}")
            if loc >= 0:
                gl.glUniform1i(loc, i)

        # Set static uniforms (once for all batches)
        loc = gl.glGetUniformLocation(program, "u_resolution")

View on GitHub (pinned to 1c6d8d45b3)

Solutions

  1. Reduce the output resolution or the number of passes.
  2. Free VRAM before the GLSL stage (unload models, lower batch size) so the ping-pong textures fit.
  3. Split the workflow so the GL render happens before large models are loaded.
  4. If it persists at small sizes, suspect the driver and reproduce with a minimal EGL script.
Defensive patterns

Strategy: validation

Validate before calling

# multi-pass allocates ~2 extra RGBA32F textures: bytes ~= w*h*16*2
w, h, vram_free = 4096, 4096, get_free_vram_bytes()
assert w * h * 16 * 2 < vram_free * 0.5, "ping-pong FBOs may not fit; lower resolution or pass count"

Try / catch

try:
    out = run_glsl_multipass(...)
except RuntimeError as e:
    if "Ping-pong framebuffer is not complete" in str(e):
        out = run_glsl_multipass(width=w // 2, height=h // 2)  # retry smaller
    else:
        raise

Prevention

When it happens

Trigger: Enabling multi-pass rendering at very large resolutions so several 16-byte-per-texel RGBA32F textures plus FBOs exceed VRAM or driver limits; contexts near GL_MAX_RENDERBUFFER_SIZE / texture limits; transient driver failure under memory pressure.

Common situations: 4K+ multi-pass shader chains on small-VRAM GPUs; running alongside a large diffusion model already resident in VRAM.

Related errors


AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14). Data as JSON: /api/errors/c981f0e19f31647d. Report an issue: GitHub.