createCubeRenderTarget method

  1. @override
TextureHandle? createCubeRenderTarget({
  1. required int size,
  2. required TextureFormat format,
  3. int mipLevels = 1,
})
override

Allocates a cube texture a pass can draw into, face by face and level by level, with nothing in it yet.

The counterpart of createCubeTextureFromPixels for a cube the device fills itself. That one uploads a chain built on the host and refuses render-target usage, because until reflection probes nothing rendered into a face; this one is device-private, holds mipLevels levels counting the base, and is named as an attachment through ColorTarget.face and ColorTarget.mipLevel. Its contents start undefined, as createTexture's do — a pass clears what it draws into.

format is what a probe wants: the HDR colour format, so a reflected sun keeps its range. A depth attachment for a face is an ordinary 2D texture of the face's size from createTexture, not part of the cube.

Null when the device cannot make cubes — ask supportsCubeTextures — and a chain longer than the device will allocate is trimmed to what it will, the same rule the upload path follows. Ask supportsRenderToMip before drawing into any level but the base.

Not from the render target pool, and deliberately: RenderTargetSpec is the pool's key and carries no shape, so a cube in the pool would be lent out in a 2D target's place — see TextureHandle.type. Probes are few and long-lived, and the renderer holds them itself.

Implementation

@override
TextureHandle? createCubeRenderTarget({
  required int size,
  required TextureFormat format,
  int mipLevels = 1,
}) {
  createdCubeRenderTargets.add((
    size: size,
    format: format,
    mipLevels: mipLevels,
  ));
  return TextureHandle(
    backend: 'fake cube ${_serial++}',
    width: size,
    height: size,
    format: format,
    type: TextureType.textureCube,
  );
}