Documentation
¶
Overview ¶
Package scenetest has the scenes that the display tests of viewport3d draw on each backend (SPEC §27.12): meshes made by plain code, the scenes, and a function that draws one into a texture and reads the pixels back. Tests import it; no program does.
Flutter: no counterpart
Index ¶
- Constants
- Variables
- func Box(w, h, d float32) *viewport3d.Mesh
- func BoxNoNormals(w, h, d float32) *viewport3d.Mesh
- func Cylinder(r, h float32, segments int) *viewport3d.Mesh
- func InstancedScene(w, h int) (*viewport3d.Scene, *viewport3d.Camera)
- func Isometric(scene *viewport3d.Scene, w, h int) *viewport3d.Camera
- func MorphSphere(r float32, segments, rings int) *viewport3d.Mesh
- func Part() []*viewport3d.Item
- func PartCamera(scene *viewport3d.Scene, w, h int) *viewport3d.Camera
- func Points(points ...[3]float32) *viewport3d.Mesh
- func Polyline(points ...[3]float32) *viewport3d.Mesh
- func Render(d *gpu.Device, wait func(done func() bool), c Case) (*image.RGBA, error)
- func RenderAsking(d *gpu.Device, wait func(done func() bool), c Case, ...) (*image.RGBA, error)
- func RunPickCheck(d *gpu.Device, wait func(done func() bool), c PickCheck) (string, error)
- func Segments(points ...[3]float32) *viewport3d.Mesh
- func SeparateScene(w, h int) (*viewport3d.Scene, *viewport3d.Camera)
- func SkinnedBar() *viewport3d.Mesh
- func Sphere(r float32, segments, rings int) *viewport3d.Mesh
- func TerraceScene(w, h int) (*viewport3d.Scene, *viewport3d.Camera)
- func Terraces(n, block int) *viewport3d.Mesh
- func Torus(ring, tube float32, segments, rings int) *viewport3d.Mesh
- type BenchReport
- type Case
- type PickCheck
Constants ¶
const ( BenchWidth = 1920 BenchHeight = 1080 )
BenchWidth and BenchHeight are the size of the frames of the benchmarks of SPEC §27.10 (with 4x multisampling).
const ( W = 400 H = 300 )
Size of the pictures of the cases, in pixels.
const TagReadbackFailed = "SceneReadbackFailed"
TagReadbackFailed is the tag of the error of Render when the picture was not read back by the time wait returned.
Variables ¶
var FarOrigin = vecmath.Vec3{X: 50000, Y: -50000, Z: 30000}
FarOrigin is where the part of the far cases is: 50 km from the origin in each axis.
Functions ¶
func Box ¶
func Box(w, h, d float32) *viewport3d.Mesh
Box makes a box of the sizes centered on the origin, with a normal and texture coordinates for each of its 24 vertices.
func BoxNoNormals ¶
func BoxNoNormals(w, h, d float32) *viewport3d.Mesh
BoxNoNormals is a box of 8 shared vertices with no normals, drawn flat; its edges are where it is not flat.
func Cylinder ¶
func Cylinder(r, h float32, segments int) *viewport3d.Mesh
Cylinder makes a cylinder along y, of the radius and height, centered on the origin, with its caps. Each side and each cap has its own vertices, so that the edge between them is sharp.
func InstancedScene ¶
func InstancedScene(w, h int) (*viewport3d.Scene, *viewport3d.Camera)
InstancedScene is the scene of ten thousand items that share a mesh and a material (one draw), in a square of 100 x 100.
func Isometric ¶
func Isometric(scene *viewport3d.Scene, w, h int) *viewport3d.Camera
Isometric returns a perspective camera that shows the whole scene from the corner of the front, right and top.
func MorphSphere ¶
func MorphSphere(r float32, segments, rings int) *viewport3d.Mesh
MorphSphere is a sphere of the radius that has one morph target: the change to a squashed ellipsoid.
func Part ¶
func Part() []*viewport3d.Item
Part is a part of the display mode cases: a box (8 shared vertices, no normals: flat), a cylinder through it and a sphere.
func PartCamera ¶
func PartCamera(scene *viewport3d.Scene, w, h int) *viewport3d.Camera
PartCamera is Isometric turned a little, so that the three faces of a box are not lit alike by the light at the camera (an isometric view sees them all at the same angle).
func Polyline ¶
func Polyline(points ...[3]float32) *viewport3d.Mesh
Polyline makes a mesh of the segments between consecutive points.
func Render ¶
Render draws a case with a renderer into a texture of its size on the device, and reads the picture back. wait runs the work that the device posted until done says the read has finished, or it gives up (a test makes it from the app's RunPosted, and a browser's reads finish in later tasks, so it sleeps between the calls); it is called after the commands are submitted and the read is asked for.
func RenderAsking ¶
func RenderAsking(d *gpu.Device, wait func(done func() bool), c Case, ask func(r *viewport3d.Renderer, scene *viewport3d.Scene, cam *viewport3d.Camera) (settled func() bool)) (*image.RGBA, error)
RenderAsking is Render for a test that makes picks: ask is called with the renderer, the scene and the camera before the frame is drawn, makes the picks, and returns a function that says when their results have come (they come while wait runs).
func RunPickCheck ¶
RunPickCheck draws the check's scene with its picks and returns what is wrong ("" when nothing is). wait is as in Render.
func Segments ¶
func Segments(points ...[3]float32) *viewport3d.Mesh
Segments makes a mesh of line segments from pairs of points.
func SeparateScene ¶
func SeparateScene(w, h int) (*viewport3d.Scene, *viewport3d.Camera)
SeparateScene is the scene of ten thousand items that each have a mesh of their own (a box of its own size), so that no two can be one draw.
func SkinnedBar ¶
func SkinnedBar() *viewport3d.Mesh
SkinnedBar is a square bar along x, from 0 to 2, with a skin of two joints (the first at x = 0, the second at x = 1) and the weights blended between x = 0.75 and x = 1.25.
func Sphere ¶
func Sphere(r float32, segments, rings int) *viewport3d.Mesh
Sphere makes a sphere of the radius around the origin, with the poles on y, a normal and texture coordinates for each vertex.
func TerraceScene ¶
func TerraceScene(w, h int) (*viewport3d.Scene, *viewport3d.Camera)
TerraceScene is the scene of the benchmark of a million triangles: one item that holds the surface of Terraces(708, 12), drawn with its edges, and the camera that sees all of it from above at an angle.
func Terraces ¶
func Terraces(n, block int) *viewport3d.Mesh
Terraces makes a surface of n x n cells, two triangles each (2*n*n in all), whose height steps by block cells: a stepped surface has the edges of a real part (a crease at each step) and a smooth normal on each tread. n = 708 makes 1,002,528 triangles.
Types ¶
type BenchReport ¶
type BenchReport struct {
// Frames is the number of frames measured, Draws the draws of one of them.
Frames int `json:"frames"`
Draws int `json:"draws"`
// FPS is the frames a second, with at most two frames in flight, so that the GPU's time is in it.
FPS float64 `json:"fps"`
// CPUMs is the time of a frame on the calling goroutine in milliseconds: Draw, Finish and Submit. In a browser it is
// the wall time of the main thread, which runs nothing else meanwhile.
CPUMs float64 `json:"cpuMs"`
// Error says what failed; the numbers are then not set.
Error string `json:"error"`
}
BenchReport is what RunBench measured.
func RunBench ¶
func RunBench(d *gpu.Device, poll func(), scene *viewport3d.Scene, cam *viewport3d.Camera, frames int) BenchReport
RunBench draws frames frames of the scene at BenchWidth x BenchHeight with 4x multisampling into textures of its own, as the display benchmarks of viewport3d do, and measures them (step 67.11: the million triangles in the browsers). poll hands over what the device finished (the page apps' frames of their renderer and their posted functions); between two polls the loop sleeps a millisecond, which gives a browser its event loop. The first three frames, which make the pipelines, the buffers and the edges, are not measured.
type Case ¶
type Case struct {
Name string
Width, Height int
// Samples is 1 or 4; the default is 4.
Samples int
// Depth is the format of the depth target: Depth32Float (the default) or Depth24PlusStencil8, which the caps of a section
// need.
Depth gpu.TextureFormat
// Build makes the scene and its camera, and a function that releases what it made on the device (nil for none).
Build func(d *gpu.Device) (*viewport3d.Scene, *viewport3d.Camera, func())
// Steps are changes of the scene, each with a frame before it: the picture is the one after the last. Without them the first
// frame is the picture.
Steps []func(s *viewport3d.Scene, cam *viewport3d.Camera)
}
Case is a scene that the display tests draw: a name for its golden image, the size of the picture in pixels, and how to make the scene and its camera for a device (a texture needs one).
func Cases ¶
func Cases() []Case
Cases are the scenes of the display tests. Each is drawn with 4 samples unless it says otherwise.
func GridPartAt ¶
GridPartAt is the part on a grid, as the part of grid-iso is, but at a place: the part, the grid's plane and the camera's target are moved by origin, so that with FarOrigin the picture is the one at the world's origin if the grid is exact (SPEC §27.8, D30).
type PickCheck ¶
type PickCheck struct {
Name string
Case Case
// Ask makes the picks before the frame is drawn, and returns a function that says when their results have come and one that
// says what is wrong with them ("" for nothing).
Ask func(r *viewport3d.Renderer, scene *viewport3d.Scene, cam *viewport3d.Camera) (settled func() bool, verdict func() string)
}
PickCheck is a scene, a pick on it and what the pick must find (SPEC §27.8, "Picking"): the display tests of each backend run them, so that every backend picks the same.