Documentation ¶
Index ¶
- func Init1x1GLFW() (terminate func(), err error)
- func NormalsCentralDiff(s SDF3, pos []ms3.Vec, normals []ms3.Vec, step float32, userData any) error
- type BlockCachedSDF3
- func (c3 *BlockCachedSDF3) Bounds() ms3.Box
- func (c3 *BlockCachedSDF3) CacheHits() uint64
- func (c3 *BlockCachedSDF3) Evaluate(pos []ms3.Vec, dist []float32, userData any) error
- func (c3 *BlockCachedSDF3) Evaluations() uint64
- func (c3 *BlockCachedSDF3) Reset(sdf SDF3, resX, resY, resZ float32) error
- func (c3 *BlockCachedSDF3) VecPool() *VecPool
- type ComputeConfig
- type DisplaceMulti2D
- type Lines2DGPU
- type PolygonGPU
- type SDF2
- type SDF2CPU
- type SDF2Compute
- type SDF3
- type SDF3CPU
- type SDF3Compute
- type VecPool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Init1x1GLFW ¶
func Init1x1GLFW() (terminate func(), err error)
Init1x1GLFW starts a 1x1 sized GLFW so that user can start working with GPU. It returns a termination function that should be called when user is done running loads on GPU.
func NormalsCentralDiff ¶
NormalsCentralDiff uses central differences algorithm for normal calculation, which are stored in normals for each position. The returned normals are not normalized (converted to unit length).
Types ¶
type BlockCachedSDF3 ¶
type BlockCachedSDF3 struct {
// contains filtered or unexported fields
}
func (*BlockCachedSDF3) Bounds ¶
func (c3 *BlockCachedSDF3) Bounds() ms3.Box
Bounds returns the SDF's bounding box such that all of the shape is contained within.
func (*BlockCachedSDF3) CacheHits ¶
func (c3 *BlockCachedSDF3) CacheHits() uint64
CacheHits returns total amount of cached evalutions done throughout the SDF's lifetime.
func (*BlockCachedSDF3) Evaluations ¶
func (c3 *BlockCachedSDF3) Evaluations() uint64
Evaluations returns total evaluations performed succesfully during sdf's lifetime, including cached.
func (*BlockCachedSDF3) Reset ¶
func (c3 *BlockCachedSDF3) Reset(sdf SDF3, resX, resY, resZ float32) error
Reset resets the SDF3 and reuses the underlying buffers for future SDF evaluations. It also resets statistics such as evaluations and cache hits.
func (*BlockCachedSDF3) VecPool ¶
func (c3 *BlockCachedSDF3) VecPool() *VecPool
type ComputeConfig ¶
type ComputeConfig struct { // InvocX represents the size of the worker group in warps/invocations as configured in the shader. // This is configured in a declaration of the following style in the shader: // layout(local_size_x = <InvocX>, local_size_y = 1, local_size_z = 1) in; InvocX int // ShaderObjects contains buffer data and definitions required by shader for correct evaluation. ShaderObjects []glbuild.ShaderObject }
type DisplaceMulti2D ¶
PolygonGPU implements a direct polygon evaluation via GPU.
func (*DisplaceMulti2D) Bounds ¶
func (disp *DisplaceMulti2D) Bounds() ms2.Box
func (*DisplaceMulti2D) Configure ¶
func (disp *DisplaceMulti2D) Configure(programmer *glbuild.Programmer, element glbuild.Shader2D, cfg ComputeConfig) error
type Lines2DGPU ¶
type Lines2DGPU struct { Lines [][2]ms2.Vec Width float32 // contains filtered or unexported fields }
PolygonGPU implements a direct polygon evaluation via GPU.
func (*Lines2DGPU) Bounds ¶
func (lines *Lines2DGPU) Bounds() ms2.Box
func (*Lines2DGPU) Configure ¶
func (lines *Lines2DGPU) Configure(cfg ComputeConfig) error
type PolygonGPU ¶
PolygonGPU implements a direct polygon evaluation via GPU.
func (*PolygonGPU) Bounds ¶
func (poly *PolygonGPU) Bounds() ms2.Box
func (*PolygonGPU) Configure ¶
func (poly *PolygonGPU) Configure(cfg ComputeConfig) error
type SDF2 ¶
type SDF2 interface { // Evaluate evaluates the signed distance field over pos positions. // dist and pos must be of same length. Resulting distances are stored // in dist. // // userData facilitates getting data to the evaluators for use in processing, such as [VecPool]. Evaluate(pos []ms2.Vec, dist []float32, userData any) error // Bounds returns the SDF's bounding box such that all of the shape is contained within. Bounds() ms2.Box }
SDF2 implements a 2D signed distance field in vectorized form suitable for running on GPU.
func AssertSDF2 ¶
AssertSDF2 asserts the argument as a SDF2 implementation and returns the raw result. It provides readable errors beyond simply converting the interface.
type SDF2CPU ¶
type SDF2CPU struct { SDF SDF2 // contains filtered or unexported fields }
func NewCPUSDF2 ¶
NewCPUSDF2 checks if the shader implements CPU evaluation and returns a SDF2CPU ready for evaluation, taking care of the buffers for evaluating the SDF correctly.
The returned SDF2 should only require a gleval.VecPool as a userData argument, this is automatically taken care of if a nil userData is passed in.
func (*SDF2CPU) Evaluations ¶
Evaluations returns total evaluations performed succesfully during sdf's lifetime.
type SDF2Compute ¶
type SDF2Compute struct {
// contains filtered or unexported fields
}
func NewComputeGPUSDF2 ¶
func NewComputeGPUSDF2(glglSourceCode io.Reader, bb ms2.Box, cfg ComputeConfig) (*SDF2Compute, error)
NewComputeGPUSDF2 instantiates a SDF2 that runs on the GPU.
func (*SDF2Compute) Bounds ¶
func (sdf *SDF2Compute) Bounds() ms2.Box
func (*SDF2Compute) Evaluations ¶
func (sdf *SDF2Compute) Evaluations() uint64
Evaluations returns total evaluations performed succesfully during sdf's lifetime.
type SDF3 ¶
type SDF3 interface { // Evaluate evaluates the signed distance field over pos positions. // dist and pos must be of same length. Resulting distances are stored // in dist. // // userData facilitates getting data to the evaluators for use in processing, such as [VecPool]. Evaluate(pos []ms3.Vec, dist []float32, userData any) error // Bounds returns the SDF's bounding box such that all of the shape is contained within. Bounds() ms3.Box }
SDF3 implements a 3D signed distance field in vectorized form suitable for running on GPU.
func AssertSDF3 ¶
AssertSDF3 asserts the Shader3D as a SDF3 implementation and returns the raw result. It provides readable errors beyond simply converting the interface.
type SDF3CPU ¶
type SDF3CPU struct { SDF SDF3 // contains filtered or unexported fields }
func NewCPUSDF3 ¶
NewCPUSDF2 checks if the shader implements CPU evaluation and returns a *SDF3CPU ready for evaluation, taking care of the buffers for evaluating the SDF correctly.
The returned SDF3 should only require a VecPool as a userData argument, this is automatically taken care of if a nil userData is passed in.
func (*SDF3CPU) Evaluations ¶
Evaluations returns total evaluations performed succesfully during sdf's lifetime.
type SDF3Compute ¶
type SDF3Compute struct {
// contains filtered or unexported fields
}
func NewComputeGPUSDF3 ¶
func NewComputeGPUSDF3(glglSourceCode io.Reader, bb ms3.Box, cfg ComputeConfig) (*SDF3Compute, error)
NewComputeGPUSDF3 instantiates a SDF3 that runs on the GPU.
func (*SDF3Compute) Bounds ¶
func (sdf *SDF3Compute) Bounds() ms3.Box
func (*SDF3Compute) Evaluations ¶
func (sdf *SDF3Compute) Evaluations() uint64
Evaluations returns total evaluations performed succesfully during sdf's lifetime.
type VecPool ¶
VecPool serves as a pool of Vec3 and float32 slices for evaluating SDFs on the CPU while reducing garbage generation. It also aids in calculation of memory usage.
func GetVecPool ¶
GetVecPool asserts the userData as a VecPool. If assert fails then an error is returned with information on what went wrong.
func (*VecPool) AssertAllReleased ¶
AssertAllReleased checks all buffers are not in use. Should be called after ending a run to find memory leaks.
func (*VecPool) SetMinAllocationLen ¶
SetMinAllocationLen sets the minimum length allocated when creating a new buffer for all buffer pools.