Renderer · function

generateMipChain

Fill every level of a texture from the one above it, which is what WebGPU asks for instead of a call.

Explained in Hello world.

function generateMipChain(device: GPUDevice, pipelines: MipPipelines, texture: GPUTexture, format: GPUTextureFormat, levels: number,
import { generateMipChain } from '@driftengine/core';

Parameters

ParameterTypeDescription
deviceGPUDevice
pipelinesMipPipelines
textureGPUTexture
formatGPUTextureFormat
levelsnumber
/** How many array layers to fill
each its own chain. One for a plain texture. */ layers?: number

In depth

gl.generateMipmap is one line and WebGPU has no equivalent at all, so this is the whole of the difference between the two backends for any texture that wants a chain. One encoder, one render pass per level, submitted together, once, at upload.

The source view is a single level, so the sample cannot read the level being written — that would be one texture bound as an attachment and as a resource at once, which is rejected, and rejected quietly enough to matter.

A free function because there are two callers now. A surface texture on a mesh has wanted a chain since it existed; a sprite sheet wanted one the day a consumer baked type into an atlas and drew it at a seventh of its authored size. Writing the blit twice would be two statements of one thing, and the second copy is the one that would quietly disagree about the format.