renderer

package
v0.0.0-...-e2d5c53 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2024 License: Apache-2.0, MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AaConfig

type AaConfig int
const (
	Area AaConfig = iota
	Msaa8
	Msaa16
)

type BinHeader

type BinHeader struct {
	ElementCount uint32
	ChunkOffset  uint32
	// contains filtered or unexported fields
}

type BindType

type BindType struct {
	Type        BindTypeType
	ImageFormat ImageFormat
}

type BindTypeType

type BindTypeType int
const (
	BindTypeBuffer BindTypeType = iota + 1
	BindTypeBufReadOnly
	BindTypeUniform
	BindTypeImage
	BindTypeImageRead
	BindTypeImageArrayRead
)

type BufferProxy

type BufferProxy struct {
	Size uint64
	ID   ResourceID
	Name string
}

func NewBufferProxy

func NewBufferProxy(size uint64, name string) BufferProxy

func (BufferProxy) Resource

func (p BufferProxy) Resource() ResourceProxy

type BufferSize

type BufferSize[T any] uint32

func NewBufferSize

func NewBufferSize[T any](x uint32) BufferSize[T]

type BufferSizes

type BufferSizes struct {
	// Known size buffers
	PathReduced     BufferSize[PathMonoid]
	PathReduced2    BufferSize[PathMonoid]
	PathReducedScan BufferSize[PathMonoid]
	PathMonoids     BufferSize[PathMonoid]
	PathBboxes      BufferSize[PathBbox]
	DrawReduced     BufferSize[DrawMonoid]
	DrawMonoids     BufferSize[DrawMonoid]
	Info            BufferSize[uint32]
	ClipInps        BufferSize[Clip]
	ClipEls         BufferSize[ClipElement]
	ClipBics        BufferSize[ClipBic]
	ClipBboxes      BufferSize[ClipBbox]
	DrawBboxes      BufferSize[DrawBbox]
	BumpAlloc       BufferSize[BumpAllocators]
	IndirectCount   BufferSize[IndirectCount]
	BinHeaders      BufferSize[BinHeader]
	Paths           BufferSize[Path]
	// Bump allocated buffers
	Lines      BufferSize[LineSoup]
	BinData    BufferSize[uint32]
	Tiles      BufferSize[Tile]
	SegCounts  BufferSize[SegmentCount]
	Segments   BufferSize[PathSegment]
	BlendSpill BufferSize[[4]float32]
	Ptcl       BufferSize[uint32]
}

func NewBufferSizes

func NewBufferSizes(layout *Layout, workgroups *WorkgroupCounts) BufferSizes

type BumpAllocatorMemory

type BumpAllocatorMemory struct {
	Total     uint32
	Binning   BufferSize[uint32]
	Ptcl      BufferSize[uint32]
	Tile      BufferSize[Tile]
	SegCounts BufferSize[SegmentCount]
	Segments  BufferSize[PathSegment]
	Lines     BufferSize[LineSoup]
}

type BumpAllocators

type BumpAllocators struct {
	Failed    uint32
	Binning   uint32
	Ptcl      uint32
	Tile      uint32
	SegCounts uint32
	Segments  uint32
	Blend     uint32
	Lines     uint32
	// contains filtered or unexported fields
}

func (*BumpAllocators) Memory

func (ba *BumpAllocators) Memory() BumpAllocatorMemory

type BumpEstimator

type BumpEstimator struct {
	// contains filtered or unexported fields
}

func (*BumpEstimator) Append

func (be *BumpEstimator) Append(other *BumpEstimator, transform *jmath.Transform)

Append combines the counts of this estimator with other after applying an optional transform.

func (*BumpEstimator) CountPath

func (est *BumpEstimator) CountPath(path curve.BezPath, t jmath.Transform, stroke *curve.Stroke)

func (*BumpEstimator) Reset

func (be *BumpEstimator) Reset()

func (*BumpEstimator) Tally

func (est *BumpEstimator) Tally(transform *jmath.Transform) BumpAllocatorMemory

Tally produces the final total, applying an optional transform to all content.

type Clear

type Clear struct {
	Buffer BufferProxy
	Offset uint64
	Size   int64
}

type Clip

type Clip struct {

	// Index of the draw object.
	Idx uint32
	// This is a packed encoding of an enum with the sign bit as the tag. If positive,
	// this entry is a `BeginClip` and contains the associated path index. If negative,
	// it is an `EndClip` and contains the bitwise-not of the `EndClip` draw object index.
	PathIdx int32
	// contains filtered or unexported fields
}

type ClipBbox

type ClipBbox struct {
	Bbox [4]float32
	// contains filtered or unexported fields
}

type ClipBic

type ClipBic struct {

	// When interpreted as a stack operation, the number of pop operations.
	A uint32
	// When interpreted as a stack operation, the number of push operations.
	B uint32
	// contains filtered or unexported fields
}

func (ClipBic) Combine

func (cb ClipBic) Combine(other ClipBic) ClipBic

type ClipElement

type ClipElement struct {
	ParentIdx uint32

	Bbox [4]float32
	// contains filtered or unexported fields
}

type Command

type Command interface {
	// contains filtered or unexported methods
}

type ConfigUniform

type ConfigUniform struct {

	// Width of the scene in tiles.
	WidthInTiles uint32
	// Height of the scene in tiles.
	HeightInTiles uint32
	// Width of the target in pixels.
	TargetWidth uint32
	// Height of the target in pixels.
	TargetHeight uint32
	// The base background color applied to the target before any blends.
	BaseColor [4]float32
	// Layout of packed scene data.
	Layout Layout
	// Size of line soup buffer allocation (in [`LineSoup`]s)
	LinesSize uint32
	// Size of binning buffer allocation (in `uint32`s).
	BinningSize uint32
	// Size of tile buffer allocation (in [`Tile`]s).
	TilesSize uint32
	// Size of segment count buffer allocation (in [`SegmentCount`]s).
	SegCountsSize uint32
	// Size of segment buffer allocation (in [`PathSegment`]s).
	SegmentsSize uint32
	// Size of blend spill buffer (in `u32` pixels)
	// TODO: Maybe store in TILE_WIDTH * TILE_HEIGHT blocks of pixels instead?
	BlendSize uint32
	// Size of per-tile command list buffer allocation (in `uint32`s).
	PtclSize uint32
	// contains filtered or unexported fields
}

ConfigUniform contains uniform render configuration data used by all GPU stages.

This data structure must be kept in sync with the definition in `shaders/shared/config.wgsl`.

type Dispatch

type Dispatch struct {
	Shader        ShaderID
	WorkgroupSize [3]uint32
	Bindings      []ResourceProxy
}

type DispatchIndirect

type DispatchIndirect struct {
	Shader   ShaderID
	Buffer   BufferProxy
	Offset   uint64
	Bindings []ResourceProxy
}

type Download

type Download struct {
	Buffer BufferProxy
}

type DrawBbox

type DrawBbox struct {
	Bbox [4]float32
	// contains filtered or unexported fields
}

type DrawMonoid

type DrawMonoid struct {

	// The number of paths preceding this draw object.
	PathIdx uint32
	// The number of clip operations preceding this draw object.
	ClipIdx uint32
	// The offset of the encoded draw object in the scene (u32s).
	SceneOffset uint32
	// The offset of the associated info.
	InfoOffset uint32
	// contains filtered or unexported fields
}

func NewDrawMonoid

func NewDrawMonoid(tag encoding.DrawTag) DrawMonoid

func (DrawMonoid) Combine

func (m DrawMonoid) Combine(other DrawMonoid) DrawMonoid

type FreeBuffer

type FreeBuffer struct {
	Buffer BufferProxy
}

type FreeImage

type FreeImage struct {
	Image ImageProxy
}

type FullShaders

type FullShaders struct {
	PathtagReduce    ShaderID
	PathtagReduce2   ShaderID
	PathtagScan1     ShaderID
	PathtagScanSmall ShaderID
	PathtagScanLarge ShaderID
	BboxClear        ShaderID
	Flatten          ShaderID
	DrawReduce       ShaderID
	DrawLeaf         ShaderID
	ClipReduce       ShaderID
	ClipLeaf         ShaderID
	Binning          ShaderID
	TileAlloc        ShaderID
	BackdropDyn      ShaderID
	PathCountSetup   ShaderID
	PathCount        ShaderID
	Coarse           ShaderID
	PathTilingSetup  ShaderID
	PathTiling       ShaderID
	FineArea         ShaderID
	FineMSAA8        ShaderID
	FineMSAA16       ShaderID
	// 2-level dispatch works for CPU pathtag scan even for large
	// inputs 3-level is not yet implemented.
	PathtagIsCPU bool
}

type ImageFormat

type ImageFormat int
const (
	Rgba8 ImageFormat = iota
	Rgba8Srgb
	Bgra8
	Rgba16Float
)

type ImageProxy

type ImageProxy struct {
	Width  uint32
	Height uint32
	Format ImageFormat
	ID     ResourceID
}

func NewImageProxy

func NewImageProxy(width, height uint32, format ImageFormat) ImageProxy

func (ImageProxy) Resource

func (p ImageProxy) Resource() ResourceProxy

type IndirectCount

type IndirectCount struct {
	X uint32
	Y uint32
	Z uint32
	// contains filtered or unexported fields
}

IndirectCount stores indirect dispatch size values.

The original plan was to reuse BumpAllocators, but the WebGPU compatible usage list rules forbid that being used as indirect counts while also bound as writable.

type Layout

type Layout struct {

	// Number of draw objects.
	NumDrawObjects uint32
	// Number of paths.
	NumPaths uint32
	// Number of clips.
	NumClips uint32
	// Start of binning data.
	BinDataStart uint32
	// Start of path tag stream.
	PathTagBase uint32
	// Start of path data stream.
	PathDataBase uint32
	// Start of draw tag stream.
	DrawTagBase uint32
	// Start of draw data stream.
	DrawDataBase uint32
	// Start of transform stream.
	TransformBase uint32
	// Start of style stream.
	StyleBase uint32
	// contains filtered or unexported fields
}

type LineSoup

type LineSoup struct {
	PathIdx uint32

	P0 [2]float32
	P1 [2]float32
	// contains filtered or unexported fields
}

type Path

type Path struct {
	Bbox  [4]uint32
	Tiles uint32
	// contains filtered or unexported fields
}

type PathBbox

type PathBbox struct {

	// Minimum x value.
	X0 int32
	// Minimum y value.
	Y0 int32
	// Maximum x value.
	X1 int32
	// Maximum y value.
	Y1 int32
	// Style flags
	DrawFlags uint32
	// Index into the transform stream.
	TransIdx uint32
	// contains filtered or unexported fields
}

type PathMonoid

type PathMonoid struct {

	// Index into transform stream.
	TransIdx uint32
	// Path segment index.
	PathSegIdx uint32
	// Offset into path segment stream.
	PathSegOffset uint32
	// Index into style stream.
	StyleIdx uint32
	// Index of containing path.
	PathIdx uint32
	// contains filtered or unexported fields
}

func NewPathMonoid

func NewPathMonoid(tagWord uint32) PathMonoid

func (PathMonoid) Combine

func (m PathMonoid) Combine(other PathMonoid) PathMonoid

type PathSegment

type PathSegment struct {
	Point0 [2]float32
	Point1 [2]float32
	YEdge  float32
	// contains filtered or unexported fields
}

type Ramps

type Ramps struct {
	Data   [][4]jmath.Float16
	Width  uint32
	Height uint32
}

type Recording

type Recording struct {
	Commands []Command
}

func (*Recording) ClearAll

func (rec *Recording) ClearAll(arena *mem.Arena, buf BufferProxy)

func (*Recording) Dispatch

func (rec *Recording) Dispatch(arena *mem.Arena, shader ShaderID, wgSize [3]uint32, resources []ResourceProxy)

func (*Recording) DispatchIndirect

func (rec *Recording) DispatchIndirect(
	arena *mem.Arena,
	shader ShaderID,
	buf BufferProxy,
	offset uint64,
	resources []ResourceProxy,
)

func (*Recording) Download

func (rec *Recording) Download(arena *mem.Arena, buf BufferProxy)

func (*Recording) FreeBuffer

func (rec *Recording) FreeBuffer(arena *mem.Arena, buf BufferProxy)

func (*Recording) FreeImage

func (rec *Recording) FreeImage(arena *mem.Arena, image ImageProxy)

func (*Recording) FreeResource

func (rec *Recording) FreeResource(arena *mem.Arena, resource ResourceProxy)

func (*Recording) Upload

func (rec *Recording) Upload(arena *mem.Arena, name string, data []byte) BufferProxy

func (*Recording) UploadImage

func (rec *Recording) UploadImage(arena *mem.Arena, width, height uint32, format ImageFormat, data []byte) ImageProxy

func (*Recording) UploadUniform

func (rec *Recording) UploadUniform(arena *mem.Arena, name string, data []byte) BufferProxy

type Render

type Render struct {
	// contains filtered or unexported fields
}

func (*Render) OutImage

func (r *Render) OutImage() ImageProxy

type RenderConfig

type RenderConfig struct {
	// contains filtered or unexported fields
}

func NewRenderConfig

func NewRenderConfig(arena *mem.Arena, layout *Layout, width, height uint32, baseColor *color.Color) *RenderConfig

type RenderParams

type RenderParams struct {
	BaseColor          color.Color
	Width              uint32
	Height             uint32
	AntialiasingMethod AaConfig
}

type Renderer

type Renderer struct {
	// contains filtered or unexported fields
}

func New

func New() *Renderer

func (*Renderer) RecordFine

func (rd *Renderer) RecordFine(arena *mem.Arena, r *Render, shaders *FullShaders, recording Recording, pgroup profiler.ProfilerGroup) Recording

func (*Renderer) RenderEncodingCoarse

func (rd *Renderer) RenderEncodingCoarse(
	arena *mem.Arena,
	r *Render,
	encoding *encoding.Encoding,
	resolver *Resolver,
	shaders *FullShaders,
	params *RenderParams,
	robust bool,
	pgroup profiler.ProfilerGroup,
) Recording

func (*Renderer) RenderFull

func (rd *Renderer) RenderFull(
	arena *mem.Arena,
	enc *encoding.Encoding,
	resolver *Resolver,
	shaders *FullShaders,
	params *RenderParams,
	pgroup profiler.ProfilerGroup,
) (Recording, ResourceProxy)

type ResolvedPatch

type ResolvedPatch struct {
	Kind  ResolvedPatchKind
	Ramp  ResolvedPatchRamp
	Image ResolvedPatchImage
}

type ResolvedPatchImage

type ResolvedPatchImage struct {
	// index of image in array
	Index uint32
	Image gfx.Image
	// offset to the index in the draw data stream
	DrawDataOffset int
}

type ResolvedPatchKind

type ResolvedPatchKind int
const (
	ResolvedPatchKindRamp ResolvedPatchKind = iota + 1
	ResolvedPatchKindImage
)

type ResolvedPatchRamp

type ResolvedPatchRamp struct {
	DrawDataOffset int
	RampID         uint32
	Extend         gfx.Extend
}

type Resolver

type Resolver struct {
	// contains filtered or unexported fields
}

func NewResolver

func NewResolver() *Resolver

func (*Resolver) Resolve

func (r *Resolver) Resolve(arena *mem.Arena, enc *encoding.Encoding) (Layout, Ramps, []gfx.Image, []byte)

type ResourceID

type ResourceID uint64

type ResourceProxy

type ResourceProxy struct {
	Kind ResourceProxyKind
	BufferProxy
	ImageProxy
	ImageArray []ImageProxy
}

type ResourceProxyKind

type ResourceProxyKind int
const (
	ResourceProxyKindBuffer ResourceProxyKind = iota + 1
	ResourceProxyKindImage
	ResourceProxyKindImageArray
)

type SegmentCount

type SegmentCount struct {
	LineIdx uint32
	Counts  uint32
	// contains filtered or unexported fields
}

type ShaderID

type ShaderID int

type Tile

type Tile struct {
	Backdrop          int32
	SegmentCountOrIdx uint32
	// contains filtered or unexported fields
}

type Upload

type Upload struct {
	Buffer BufferProxy
	Data   []byte
}

type UploadImage

type UploadImage struct {
	Proxy ImageProxy
	Data  []byte
}

type UploadUniform

type UploadUniform struct {
	Buffer BufferProxy
	Data   []byte
}

type WorkgroupCounts

type WorkgroupCounts struct {
	UseLargePathScan bool
	PathReduce       WorkgroupSize
	PathReduce2      WorkgroupSize
	PathScan1        WorkgroupSize
	PathScan         WorkgroupSize
	BboxClear        WorkgroupSize
	Flatten          WorkgroupSize
	DrawReduce       WorkgroupSize
	DrawLeaf         WorkgroupSize
	ClipReduce       WorkgroupSize
	ClipLeaf         WorkgroupSize
	Binning          WorkgroupSize
	TileAlloc        WorkgroupSize
	PathCountSetup   WorkgroupSize
	// Note `pathCount` must use an indirect dispatch
	Backdrop        WorkgroupSize
	Coarse          WorkgroupSize
	PathTilingSetup WorkgroupSize
	// Note `pathTiling` must use an indirect dispatch
	Fine WorkgroupSize
}

func NewWorkgroupCounts

func NewWorkgroupCounts(
	layout *Layout,
	widthInTiles uint32,
	heightInTiles uint32,
	numPathTags uint32,
) WorkgroupCounts

type WorkgroupSize

type WorkgroupSize [3]uint32

type WriteImage

type WriteImage struct {
	Proxy  ImageProxy
	Coords [4]uint32
	Image  image.Image
}

Jump to

Keyboard shortcuts

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