ubo

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package ubo provides uniform buffer object utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetermineUniformBlockSize

func DetermineUniformBlockSize(api render.API, blockSize int) int

DetermineUniformBlockSize returns the size of the uniform block in case multiple ones need to be aligned inside a buffer.

Types

type UniformBlockBuffer

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

UniformBlockBuffer represents a shared uniform buffer that can be used for storing multiple uniform block types.

func NewUniformBlockBuffer

func NewUniformBlockBuffer(api render.API, capacity int) *UniformBlockBuffer

NewUniformBlockBuffer creates a new uniform block buffer that can be used to store multiple uniform block types.

NOTE: This does not do automatic resize so the proper capacity needs to be figured out beforehand.

func (*UniformBlockBuffer) Placement

func (b *UniformBlockBuffer) Placement(uniformSize uint32) UniformPlacement

Placement returns a UniformPlacement that can be used to write a uniform of the specified size.

func (*UniformBlockBuffer) Release

func (b *UniformBlockBuffer) Release()

Release releases the resources associated with the uniform block buffer.

func (*UniformBlockBuffer) Reset

func (b *UniformBlockBuffer) Reset()

Reset resets the uniform block buffer so that it can be reused.

func (*UniformBlockBuffer) Upload

func (b *UniformBlockBuffer) Upload()

Upload uploads the data that has been written to the uniform block buffer to the GPU.

type UniformPlacement

type UniformPlacement struct {
	Buffer  render.Buffer
	Plotter *blob.Plotter
	Offset  uint32
	Size    uint32
}

UniformPlacement contains information on the positioning of a uniform within a uniform buffer.

func WriteUniform

func WriteUniform[T UniformType](blockBuffer *UniformBlockBuffer, uniform T) UniformPlacement

WriteUniform writes the specified uniform to the specified uniform block buffer. The returned placement can be used to retrieve the uniform's position within the buffer.

type UniformType

type UniformType interface {
	Std140Plot(plotter *blob.Plotter)
	Std140Size() uint32
}

UniformType represents a type that can be written to a uniform buffer.

Jump to

Keyboard shortcuts

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