flutter3d
Showcase Changelog 38 packages API reference

The software rasteriser

since 0.2.0 Backends

Every page in this showcase, including this one, is proven on a device with no GPU behind it at all: a rasteriser written in Dart, sharing nothing with either hardware backend. This is the reason the golden pictures the engine is checked against can be recorded in seconds under a plain dart test rather than a twelve-minute run of a real application.

Step 1: Why a third, unrelated backend #

Two backends that agree prove less than they seem to when both are hardware rasterisers driven by a C API underneath. The software backend shares no driver, no shading language and no command buffer with either, so whatever the interface still quietly assumed about graphics hardware has to show up here, where there is no hardware to hide behind.

String _report(GraphicsDevice device) =>
    'preferred sample count: ${device.preferredSampleCount}\n'
    'offscreen MSAA: ${device.supportsOffscreenMsaa}\n'
    'wireframe: ${device.supportsWireframe}\n'
    'stencil: ${device.supportsStencil}\n'
    'mip maps: ${device.supportsMipmaps}';

Step 2: What it says about itself #

Reading the device rather than its name works exactly the same way here as on every other backend page: it is a GraphicsDevice, and it answers the same questions.

String _report(GraphicsDevice device) =>
    'preferred sample count: ${device.preferredSampleCount}\n'
    'offscreen MSAA: ${device.supportsOffscreenMsaa}\n'
    'wireframe: ${device.supportsWireframe}\n'
    'stencil: ${device.supportsStencil}\n'
    'mip maps: ${device.supportsMipmaps}';

Note. preferredSampleCount answers one and supportsOffscreenMsaa answers false: this backend never multisamples, and says so rather than quietly drawing a picture that looks like it did.

Step 3: A fact that has to hold #

A backend that answers "no multisampling" and then multisamples anyway would be exactly the silent substitution capability questions exist to prevent. This page checks that its own two answers agree with each other.

void _checkNoMultisampling() {
  if (_device.preferredSampleCount != 1 || _device.supportsOffscreenMsaa) {
    throw StateError(
      'the software rasteriser answering anything but "no multisampling" '
      'would be a silent difference from the picture a hardware backend '
      'draws',
    );
  }
}