wgsltypes

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Field

type Field struct {
	// Name is the name of the field in the Go struct.
	Name string

	// Offset is the offset (in bytes) of the field in the Go struct.
	Offset uintptr

	// WGSLType is the corresponding WGSL type to use.
	WGSLType Type
}

A Field provides information about a particular field in a Go struct.

type Struct

type Struct struct {
	// Name is the name of the struct as it appears in Go.
	Name string
	// Size of the structure, in bytes.
	Size int

	// Fields is a slice of the struct's fields, in declaration order.
	Fields []string
	// FieldMap maps field names to Fields.
	FieldMap map[string]Field
}

A Struct provides information about a Go struct.

func MustNewStruct

func MustNewStruct[T any](name string) Struct

func NewStruct

func NewStruct[T any](name string) (Struct, error)

func (*Struct) MustOffsetOf

func (s *Struct) MustOffsetOf(fieldName string) int

MustOffsetOf returns the offset of the specified field. Panics if the field is not found.

func (Struct) String

func (s Struct) String() string

func (Struct) ToWGSL

func (s Struct) ToWGSL() string

ToWGSL returns a string representing the Go struct as a WGSL struct definition.

type Type

type Type struct {
	// Name of the WGSL type.
	Name TypeName
	// Alignment of the WGSL type (see https://www.w3.org/TR/WGSL/#alignof).
	AlignOf int
	// Size if the WGSL type (see https://www.w3.org/TR/WGSL/#sizeof).
	SizeOf int
}

type TypeName

type TypeName string

TypeName is the name of a WGSL type.

Jump to

Keyboard shortcuts

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