cache

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: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend[K Key, V Value] interface {
	// Instantiate the resource referred to by Key.
	// Must execute on a background goroutine
	Instantiate(K, func(V))

	Delete(V)
	Destroy()
	Name() string
}

type GpuMesh

type GpuMesh struct {
	Vertices buffer.Block
	Indices  buffer.Block

	IndexCount   int
	IndexOffset  int
	VertexOffset int
	// contains filtered or unexported fields
}

Represents a mesh stored in a (sub)region of vertex/index buffers

func (*GpuMesh) Bind

func (m *GpuMesh) Bind(cmd *command.Buffer)

func (*GpuMesh) Bounds

func (m *GpuMesh) Bounds() shape.Sphere

func (*GpuMesh) Draw

func (m *GpuMesh) Draw(cmd command.DrawIndexedBuffer, instanceOffset int)

func (*GpuMesh) DrawInstanced

func (m *GpuMesh) DrawInstanced(cmd command.DrawIndexedBuffer, instanceOffset, instanceCount int)

func (*GpuMesh) Key

func (m *GpuMesh) Key() string

func (*GpuMesh) Version

func (m *GpuMesh) Version() int

type Key

type Key interface {
	Key() string
	Version() int
}

type Keyed

type Keyed interface {
	Key() string
}

type MeshCache

type MeshCache T[assets.Mesh, *GpuMesh]

func NewMeshBlockCache

func NewMeshBlockCache(device *device.Device, worker command.Worker, vtxSize, idxSize int) MeshCache

func NewMeshCache

func NewMeshCache(device *device.Device, worker command.Worker) MeshCache

type Pipeline

type Pipeline struct {
	ID    material.ID
	Slots []texture.Slot
	// contains filtered or unexported fields
}

func (*Pipeline) Bind

func (m *Pipeline) Bind(cmd *command.Buffer)

func (*Pipeline) Destroy

func (m *Pipeline) Destroy()

type PipelineCache

type PipelineCache T[*material.Def, *Pipeline]

func NewPipelineCache

func NewPipelineCache(dev *device.Device, shaders ShaderCache, pass *renderpass.Renderpass, layout *pipeline.Layout) PipelineCache

type SamplerCache

type SamplerCache interface {
	T[assets.Texture, *SamplerHandle]

	// Assign a handle to a texture directly
	Assign(*texture.Texture) *SamplerHandle

	// Writes descriptor values to the given Sampler Array.
	Flush(*descriptor.SamplerArray)

	// Size returns the maximum number of samplers in the cache.
	Size() int
}

func NewSamplerCache

func NewSamplerCache(textures TextureCache, size int) SamplerCache

type SamplerHandle

type SamplerHandle struct {
	ID      int
	Texture *texture.Texture
	// contains filtered or unexported fields
}

type ShaderCache

type ShaderCache T[assets.Shader, *shader.Shader]

func NewShaderCache

func NewShaderCache(dev *device.Device) ShaderCache

type T

type T[K Key, V Value] interface {
	// TryFetch returns a value if it exists and is ready to use.
	// Resets the age of the cache line
	// Returns a bool indicating whether the value exists.
	TryFetch(K) (V, bool)

	// Fetch returns a value, waiting until its becomes available if it does not yet exist
	// Resets the age of the cache line
	Fetch(K) V

	// MaxAge returns the number of ticks until unused lines are evicted
	MaxAge() int

	// Tick increments the age of all cache lines, and evicts those
	// that have not been accessed in maxAge ticks or more.
	Tick()

	// Destroy the cache and all data held in it.
	Destroy()
}

func New

func New[K Key, V Value](backend Backend[K, V]) T[K, V]

type TextureCache

type TextureCache T[assets.Texture, *texture.Texture]

func NewTextureCache

func NewTextureCache(device *device.Device, worker command.Worker) TextureCache

type Value

type Value interface{}

Jump to

Keyboard shortcuts

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