buffer

package
v0.0.0-...-8e5a076 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2024 License: GPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidFree = errors.New("illegal free() call")
View Source
var ErrOutOfMemory = errors.New("out of memory")

Functions

func Align

func Align(offset, align int) int

func GetBufferLimits

func GetBufferLimits(device *device.Device, usage core1_0.BufferUsageFlags) (align, max int)

func NewBlockAllocator

func NewBlockAllocator(buf T) *blockAlloc

Types

type Allocator

type Allocator interface {
	Alloc(size int) (Block, error)
	Free(b Block) error
}

type Args

type Args struct {
	Key    string
	Size   int
	Usage  core1_0.BufferUsageFlags
	Memory device.MemoryType
}

type Array

type Array[K any] struct {
	T
	// contains filtered or unexported fields
}

func NewArray

func NewArray[K any](device *device.Device, args Args) *Array[K]

NewArray creates a new typed array buffer. When allocating arrays, the Size argument is the number of elements

func (*Array[K]) Count

func (a *Array[K]) Count() int

func (*Array[K]) Set

func (a *Array[K]) Set(index int, data K)

func (*Array[K]) SetRange

func (a *Array[K]) SetRange(offset int, data []K)

func (*Array[K]) Stride

func (a *Array[K]) Stride() int

type Block

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

func EntireBuffer

func EntireBuffer(buffer T) Block

func (*Block) Address

func (b *Block) Address() device.Address

func (*Block) Buffer

func (b *Block) Buffer() T

func (*Block) Offset

func (b *Block) Offset() int

func (*Block) Size

func (b *Block) Size() int

type Buffer

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

func New

func New(device *device.Device, args Args) *Buffer

func NewCpuLocal

func NewCpuLocal(dev *device.Device, key string, size int) *Buffer

func NewGpuLocal

func NewGpuLocal(dev *device.Device, key string, size int, flags core1_0.BufferUsageFlags) *Buffer

func NewShared

func NewShared(dev *device.Device, key string, size int) *Buffer

func (*Buffer) Address

func (b *Buffer) Address() device.Address

Returns a GPU address for the buffer

func (*Buffer) Destroy

func (b *Buffer) Destroy()

func (*Buffer) Flush

func (b *Buffer) Flush()

func (*Buffer) Memory

func (b *Buffer) Memory() *device.Memory

func (*Buffer) Ptr

func (b *Buffer) Ptr() core1_0.Buffer

func (*Buffer) Read

func (b *Buffer) Read(offset int, data any) int

func (*Buffer) Size

func (b *Buffer) Size() int

func (*Buffer) Write

func (b *Buffer) Write(offset int, data any) int

type Item

type Item[K any] struct {
	T
}

func NewItem

func NewItem[K any](device *device.Device, args Args) *Item[K]

NewItem creates a new typed single-item buffer. When allocating items, the Size argument is ignored

func (*Item[K]) Set

func (i *Item[K]) Set(data K)

type T

type T interface {
	device.Resource[core1_0.Buffer]

	// Size returns the total allocation size of the buffer in bytes
	Size() int

	// Read directly from the buffer at the given offset
	Read(offset int, data any) int

	// Write directly to the buffer at the given offset
	Write(offset int, data any) int

	Flush()

	// Memory returns a handle to the underlying memory block
	Memory() *device.Memory

	Address() device.Address
}

Jump to

Keyboard shortcuts

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