Help us shape the future of Go! Take the 2026 Go Developer Survey

performance

package
v0.0.16 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 6 Imported by: 0

README

Binary performance profiles

Config and Profile are the shared cartridge/runtime performance contract. Default supplies the high, medium, low and potato ladder. Normalize overlays authored settings; Encode writes a resolved ladder and Decode validates it.

Candidate SDK 0.0.11 keeps custom section karty.performance.v1 and selects binary version 2. The header is KTPF, u16 version 2, u16 reserved zero, followed by target FPS f64, a u32-length UTF-8 default profile, and u32 profile count 4. Each profile carries a length-prefixed name, render scale f64, minimum/maximum window widths int32, and one optional reflection flag (0 absent, 1 false, 2 true). All numeric fields are little-endian. JSON, unknown flags, bad bounds, nonfinite values, trailing data and incomplete ladders are rejected. Decode allocates at most four profiles from validated counts. Existing scale and FPS rules remain unchanged; the CLI owns TOML authoring.

Width bounds are inclusive, and zero means unbounded. The resolved ladder must cover every positive window width: adjacent intervals are accepted, but even a single uncovered pixel width is rejected by normalization, encoding and decoding. An individual default profile may be ineligible at a width; the host selects an eligible alternative. This corrects candidate SDK 0.0.11 validation without changing binary version 2 or its serialized layout.

Documentation

Overview

Package performance owns the versioned cartridge contract for adaptive presentation profiles. It intentionally stays independent of renderer state.

Index

Constants

View Source
const (
	SectionName = "karty.performance.v1"
	MaxConfig   = 64 * 1024
)
View Source
const BinaryVersion = uint16(2)

Variables

View Source
var ErrConfig = errors.New("game performance profile configuration is invalid")

Functions

func Encode

func Encode(config Config) ([]byte, error)

Encode resolves authored defaults and creates a canonical binary profile ladder.

func Validate

func Validate(config Config) error

Types

type Config

type Config struct {
	TargetFPS      float64   `toml:"target_fps"`
	DefaultProfile string    `toml:"default_profile"`
	Profiles       []Profile `toml:"profiles"`
}

Config uses the binary cartridge contract in SectionName. Profiles are ordered from highest to lowest quality; width bounds are inclusive window pixels.

func Decode

func Decode(data []byte) (Config, error)

Decode rejects JSON and validates all lengths before the bounded profile allocation.

func Default

func Default() Config

func Normalize

func Normalize(authored Config) (Config, error)

Normalize overlays explicitly authored profile values on the built-in ladder.

type Profile

type Profile struct {
	Name             string  `toml:"name"`
	RenderScale      float64 `toml:"render_scale"`
	MinWindowWidth   int     `toml:"min_window_width,omitempty"`
	MaxWindowWidth   int     `toml:"max_window_width,omitempty"`
	FloorReflections *bool   `toml:"floor_reflections,omitempty"`
}

Jump to

Keyboard shortcuts

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