gputest

package
v1.16.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2026 License: BSD-3-Clause Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package gputest has what the display tests of the GPU renderers share: the scenes the renderers are compared on, the comparison with the software renderer's image, and its tolerance. It is test support and has no Flutter counterpart.

Index

Constants

View Source
const (
	ScrolledWidth     = 800
	ScrolledHeight    = 600
	ScrolledRowHeight = 48
)

The size of the viewport of ScrolledList, and the height of one of its rows.

View Source
const EffectSize = 128

EffectSize is the width and height of the surface of the effect scenes.

View Source
const ShapeSize = 128

ShapeSize is the width and height of the surface of the shape scenes.

View Source
const TextureSize = 8

TextureSize is the side of the textures of the texture tests, in texels.

View Source
const TextureWindow = 128

TextureWindow is the side of the window of the texture tests, in pixels.

Variables

View Source
var ProofTolerances = map[string]Tolerance{
	"shapes-basic": {Over8Permille: 20, Over32Permille: 5},
	"shapes-clips": {Over8Permille: 30, Over32Permille: 3},
	"gradients":    {Over8Permille: 10, Over32Permille: 3},
	"blend-modes":  {Over8Permille: 15, Over32Permille: 5},
	"effects":      {Over8Permille: 1},
	"text-tour":    {Over8Permille: 1},

	"decorations":    {Over8Permille: 3, Over32Permille: 1},
	"rendering-tour": {Over8Permille: 1},
}

ProofTolerances is how far the GPU renderers may be from the software renderer in each proof scene (the scenes are the goldens of the proof tool, SPEC §9.2). A scene that is registered without an entry here fails the parity tests, so a step that adds one states its tolerance.

Flutter: no counterpart

View Source
var ScenesTolerance = Tolerance{Over8Permille: 12, Over32Permille: 6, Over96: 40}

ScenesTolerance is how far the picture of a scene of internal/scenetest (viewport3d, SPEC §27.12) on a backend may be from its golden, which Vulkan on lavapipe made: the backends compile the shaders in their own ways and place the samples of the multisampling in their own ways, so the edges differ a little.

Functions

func CanvasScene

func CanvasScene(fn func(c *ui.Canvas)) *ui.Scene

CanvasScene is a scene of one picture: a white background, then what fn draws.

func DamagePicture

func DamagePicture(rect ui.Rect) *ui.Picture

DamagePicture is a picture of one rectangle, for the tests of damage tracking.

Flutter: no counterpart

func DamageScene

func DamageScene(pics ...*ui.Picture) *ui.Scene

DamageScene is a scene of the pictures, in order.

Flutter: no counterpart

func EvenStops

func EvenStops(n int) []float64

EvenStops are n color stops evenly spaced from 0 to 1.

func FillPaint

func FillPaint(argb uint32) *ui.Paint

FillPaint is an anti-aliased paint of the color.

func ImageScene

func ImageScene(pix []byte, quality ui.FilterQuality) *ui.Scene

ImageScene draws the pixels as an image in the layers of the tests: what TextureScene must look like.

func Pattern

func Pattern(n int) *ui.Image

Pattern is an n x n image of a color gradient with a grid and a transparent corner, to show orientation, filtering and alpha.

func PictureOf

func PictureOf(fn func(c *ui.Canvas)) *ui.Picture

PictureOf records a picture of drawing.

func RetainedFrames

func RetainedFrames(n int, clip func(b *ui.SceneBuilder)) []*ui.Scene

RetainedFrames makes the scenes of a retained layer: the layer is built in the first and added again in the others, as a RepaintBoundary that does not change.

Flutter: no counterpart

func Scale4

func Scale4(s float32) *ui.Matrix4

Scale4 is a uniform scale of the x and y axes.

func ScrolledList

func ScrolledList(rows int, scroll float64) *ui.Scene

ScrolledList is a tall list drawn through a viewport: rows rows of ScrolledRowHeight pixels, each with an icon made of curves (filled), a stroked outline with round joins, an arc and a dotted line, the way a page of icons and SVG pictures draws, clipped to the viewport of ScrolledWidth x ScrolledHeight pixels and moved up by scroll pixels. Only the rows in the viewport are visible; the rest are what a renderer must skip cheaply. It is for the benchmarks and the culling tests of the GPU renderers.

Flutter: no counterpart

func ShaderPaint

func ShaderPaint(sh ui.Shader) *ui.Paint

ShaderPaint is a paint with a shader.

func StarPath

func StarPath() *ui.Path

StarPath is a five-pointed star in a 128 x 128 box.

func StripesAndDisc

func StripesAndDisc(c *ui.Canvas)

StripesAndDisc is something with an edge and a gradient to put layers over.

func StrokePaint

func StrokePaint(argb uint32, width float64, cap ui.StrokeCap, join ui.StrokeJoin) *ui.Paint

StrokePaint is a stroking paint of the color with the width, cap and join.

func TextureScene

func TextureScene(id int64, quality ui.FilterQuality) *ui.Scene

TextureScene shows the registered texture in the layers of the tests.

Types

type CullShape

type CullShape struct {
	Name string
	// Atlas says that the renderers draw the shape from the coverage atlas, so that drawing it in
	// view asks the atlas for tiles.
	Atlas bool
	Draw  func(c *ui.Canvas, r ui.Rect, p *ui.Paint)
}

CullShape is one kind of shape command for the culling tests of the GPU renderers: Draw draws a shape that fits the rectangle with the paint.

func CullShapes

func CullShapes() []CullShape

CullShapes are the kinds of shape commands that culling decides about.

type CullTransform

type CullTransform struct {
	Name  string
	Apply func(c *ui.Canvas)
}

CullTransform is a transform the culling tests draw under.

func CullTransforms

func CullTransforms() []CullTransform

CullTransforms are a translation, a scale and a rotation (and no transform).

type Diff

type Diff struct {
	Pixels, Over8, Over32, Over96, Max int
}

Diff compares two images inside a rectangle: the number of pixels whose largest channel difference is above each threshold, and the largest difference.

func DiffRect

func DiffRect(a, b *image.RGBA, r image.Rectangle) Diff

DiffRect compares the images a and b inside r.

type EffectScene

type EffectScene struct {
	Name      string
	Tolerance Tolerance
	// Build makes the scene, EffectSize pixels square.
	Build func() *ui.Scene
}

EffectScene is a drawing of the paint shaders, color filters, blend modes and layers, with the tolerance the GPU renderers are held to against the software renderer.

func EffectScenes

func EffectScenes() []EffectScene

EffectScenes returns the drawings of gradients, image shaders, color filters, blend modes, vertices and layers that both GPU renderers are compared with the software renderer on.

type ShapeScene

type ShapeScene struct {
	Name string
	// Over8Permille, Over32Permille and Over96 are the Tolerance.
	Over8Permille, Over32Permille, Over96 int
	Draw                                  func(c *ui.Canvas)
}

ShapeScene is a drawing of analytic shapes on a surface of ShapeSize pixels, with the tolerance the GPU renderers are held to against the software renderer.

func ShapeScenes

func ShapeScenes() []ShapeScene

ShapeScenes returns the drawings of shapes, clips and the blend modes of the blend unit that both GPU renderers are compared with the software renderer on.

func (ShapeScene) Tolerance

func (s ShapeScene) Tolerance() Tolerance

Tolerance returns the scene's tolerance.

type TextureCase

type TextureCase struct {
	Name      string
	Kind      TextureKind
	Quality   ui.FilterQuality
	Tolerance Tolerance
	// Texels is the content of the texture, in the layout of its format.
	Texels []byte
	// Reference is the same picture as sRGB-encoded RGBA8 pixels, which the software renderer draws as an image.
	Reference []byte
}

TextureCase is one texture of the tests, how it is sampled, and how far the GPU may be from the software image.

func TextureCases

func TextureCases() []TextureCase

TextureCases returns the textures of the tests.

type TextureKind

type TextureKind int

TextureKind says how a texture of the tests stores its texels.

const (
	// TextureRGBA8 is RGBA8Unorm with sRGB-encoded values.
	TextureRGBA8 TextureKind = iota
	// TextureBGRA8 is BGRA8Unorm with sRGB-encoded values.
	TextureBGRA8
	// TextureRGBA16F is RGBA16Float with linear values.
	TextureRGBA16F
)

The kinds of texture of the tests.

func (TextureKind) TexelBytes

func (k TextureKind) TexelBytes() int

TexelBytes is the size of a texel of the kind.

type Tolerance

type Tolerance struct{ Over8Permille, Over32Permille, Over96 int }

Tolerance is how far a GPU image may be from the software renderer's in a region: of its pixels, at most Over8Permille differ by more than 8 levels (the edges, where the distance field and the exact area differ a little), at most Over32Permille by more than 32, and at most Over96 pixels by more than 96.

func (Tolerance) Check

func (tol Tolerance) Check(t testing.TB, label string, s Diff)

Check logs the difference and fails the test when it is more than the tolerance.

Directories

Path Synopsis
Package editorscene makes the scenes of a frame in which only the caret of a text editor blinks, for the allocation tests and benchmarks of the renderers (SPEC §15, step 29.15).
Package editorscene makes the scenes of a frame in which only the caret of a text editor blinks, for the allocation tests and benchmarks of the renderers (SPEC §15, step 29.15).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL