Skip to content

Commit 92ef791

Browse files
committed
finish renaming SSBO ocurrences to Objects
1 parent 61c0b36 commit 92ef791

File tree

9 files changed

+122
-121
lines changed

9 files changed

+122
-121
lines changed

examples/test/glsdf3test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ func visualize(sdf glbuild.Shader3D, filename string) error {
735735
if err != nil {
736736
return err
737737
} else if len(ssbos) > 0 {
738-
return errors.New("ssbos unsupported in frag visualizer")
738+
return errors.New("objectsunsupported in frag visualizer")
739739
}
740740
stat, err := fp.Stat()
741741
if err != nil {
@@ -905,8 +905,8 @@ func makeGPUSDF3(s glbuild.Shader3D) *gleval.SDF3Compute {
905905
}
906906
invocX, _, _ := programmer.ComputeInvocations()
907907
sdfgpu, err := gleval.NewComputeGPUSDF3(&source, s.Bounds(), gleval.ComputeConfig{
908-
InvocX: invocX,
909-
SSBOs: ssbos,
908+
InvocX: invocX,
909+
ShaderObjects: ssbos,
910910
})
911911
if err != nil {
912912
panic(err)
@@ -928,8 +928,8 @@ func makeGPUSDF2(s glbuild.Shader2D) gleval.SDF2 {
928928
}
929929
invocX, _, _ := programmer.ComputeInvocations()
930930
sdfgpu, err := gleval.NewComputeGPUSDF2(&source, s.Bounds(), gleval.ComputeConfig{
931-
InvocX: invocX,
932-
SSBOs: ssbos,
931+
InvocX: invocX,
932+
ShaderObjects: ssbos,
933933
})
934934
if err != nil {
935935
panic(err)

forge/threads/threads.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ func Screw(length float32, thread Threader) (glbuild.Shader3D, error) {
9494
return &s, nil
9595
}
9696

97-
func (s *screw) AppendShaderObjects(ssbos []glbuild.ShaderObject) []glbuild.ShaderObject {
98-
return ssbos
97+
func (s *screw) AppendShaderObjects(objects []glbuild.ShaderObject) []glbuild.ShaderObject {
98+
return objects
9999
}
100100

101101
func (s *screw) ForEachChild(any, func(any, *glbuild.Shader3D) error) error {

gleval/gpu.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ type ComputeConfig struct {
6464
// This is configured in a declaration of the following style in the shader:
6565
// layout(local_size_x = <InvocX>, local_size_y = 1, local_size_z = 1) in;
6666
InvocX int
67-
// SSBOs contains buffer data and definitions required by shader for correct evaluation.
68-
SSBOs []glbuild.ShaderObject
67+
// ShaderObjects contains buffer data and definitions required by shader for correct evaluation.
68+
ShaderObjects []glbuild.ShaderObject
6969
}
7070

7171
func (sdf *SDF3Compute) Bounds() ms3.Box {
@@ -107,20 +107,20 @@ func NewComputeGPUSDF2(glglSourceCode io.Reader, bb ms2.Box, cfg ComputeConfig)
107107
return nil, errors.New(string(combinedSource.Compute) + "\n" + err.Error())
108108
}
109109
sdf := SDF2Compute{
110-
prog: glprog,
111-
bb: bb,
112-
invocX: cfg.InvocX,
113-
ssbos: cfg.SSBOs,
110+
prog: glprog,
111+
bb: bb,
112+
invocX: cfg.InvocX,
113+
objects: cfg.ShaderObjects,
114114
}
115115
return &sdf, nil
116116
}
117117

118118
type SDF2Compute struct {
119-
prog glgl.Program
120-
bb ms2.Box
121-
evals uint64
122-
invocX int
123-
ssbos []glbuild.ShaderObject
119+
prog glgl.Program
120+
bb ms2.Box
121+
evals uint64
122+
invocX int
123+
objects []glbuild.ShaderObject
124124
}
125125

126126
func (sdf *SDF2Compute) Evaluate(pos []ms2.Vec, dist []float32, userData any) error {
@@ -130,7 +130,7 @@ func (sdf *SDF2Compute) Evaluate(pos []ms2.Vec, dist []float32, userData any) er
130130
if err != nil {
131131
return fmt.Errorf("binding SDF2Compute program: %w", err)
132132
}
133-
err = computeEvaluate(pos, dist, sdf.invocX, sdf.ssbos)
133+
err = computeEvaluate(pos, dist, sdf.invocX, sdf.objects)
134134
if err != nil {
135135
return err
136136
}
@@ -358,7 +358,7 @@ func (disp *DisplaceMulti2D) Configure(programmer *glbuild.Programmer, element g
358358
} else if n != buf.Len() {
359359
return errors.New("length written mismatch")
360360
} else if len(ssbos) > 0 {
361-
return errors.New("ssbos unsupported for displace multi")
361+
return errors.New("objectsunsupported for displace multi")
362362
}
363363
disp.elemBB = element.Bounds()
364364
disp.invocX = cfg.InvocX

gleval/gpu_cgo.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ func copySSBO[T any](dst []T, ssbo uint32) error {
159159
return glgl.Err()
160160
}
161161

162-
func computeEvaluate[T ms2.Vec | ms3.Vec](pos []T, dist []float32, invocX int, ssbos []glbuild.ShaderObject) (err error) {
162+
func computeEvaluate[T ms2.Vec | ms3.Vec](pos []T, dist []float32, invocX int, objects []glbuild.ShaderObject) (err error) {
163163
if len(pos) != len(dist) {
164164
return errors.New("positional and distance buffers not equal in length")
165165
} else if len(dist) == 0 {
@@ -169,13 +169,14 @@ func computeEvaluate[T ms2.Vec | ms3.Vec](pos []T, dist []float32, invocX int, s
169169
}
170170

171171
var p runtime.Pinner
172-
if len(ssbos) > 0 {
173-
ssbosIDs := make([]uint32, len(ssbos))
172+
if len(objects) > 0 {
173+
// Assume all objects are SSBOs for now.
174+
ssbosIDs := make([]uint32, len(objects))
174175
p.Pin(&ssbosIDs[0])
175176
gl.GenBuffers(int32(len(ssbosIDs)), &ssbosIDs[0])
176177
defer gl.DeleteBuffers(int32(len(ssbosIDs)), &ssbosIDs[0])
177178
for i, id := range ssbosIDs {
178-
ssbo := ssbos[i]
179+
ssbo := objects[i]
179180
gl.BindBuffer(gl.SHADER_STORAGE_BUFFER, id)
180181
gl.BufferData(gl.SHADER_STORAGE_BUFFER, ssbo.Size, ssbo.Data, gl.STATIC_DRAW)
181182
gl.BindBufferBase(gl.SHADER_STORAGE_BUFFER, uint32(ssbo.Binding), id)

glrender/octree.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ func (oc *Octree) debugVisual(filename string, lvlDescent int, merge glbuild.Sha
418418
if err != nil {
419419
return err
420420
} else if len(ssbos) > 0 {
421-
return errors.New("ssbos unsupported for visual output")
421+
return errors.New("objectsunsupported for visual output")
422422
}
423423
return nil
424424
}

gsdf2d.go

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ func (u *OpUnion2D) AppendShaderBody(b []byte) []byte {
9090
}
9191

9292
// AppendShaderObjects implements [glbuild.Shader]. This method returns the argument buffer with no modifications. See [glbuild.Shader] for more information.
93-
func (u *OpUnion2D) AppendShaderObjects(ssbos []glbuild.ShaderObject) []glbuild.ShaderObject {
93+
func (u *OpUnion2D) AppendShaderObjects(objects []glbuild.ShaderObject) []glbuild.ShaderObject {
9494
u.mustValidate()
95-
return ssbos
95+
return objects
9696
}
9797

9898
func (u *OpUnion2D) mustValidate() {
@@ -153,8 +153,8 @@ func (l *line2D) ForEach2DChild(userData any, fn func(userData any, s *glbuild.S
153153
return nil
154154
}
155155

156-
func (u *line2D) AppendShaderObjects(ssbos []glbuild.ShaderObject) []glbuild.ShaderObject {
157-
return ssbos
156+
func (u *line2D) AppendShaderObjects(objects []glbuild.ShaderObject) []glbuild.ShaderObject {
157+
return objects
158158
}
159159

160160
// NewLines2D creates sequential straight lines between the argument points.
@@ -225,12 +225,12 @@ func (l *lines2D) ForEach2DChild(userData any, fn func(userData any, s *glbuild.
225225
return nil
226226
}
227227

228-
func (u *lines2D) AppendShaderObjects(ssbos []glbuild.ShaderObject) []glbuild.ShaderObject {
228+
func (u *lines2D) AppendShaderObjects(objects []glbuild.ShaderObject) []glbuild.ShaderObject {
229229
ssbo, err := glbuild.MakeShaderBufferReadOnly(u.bufName, u.points)
230230
if err != nil {
231231
panic(err)
232232
}
233-
return append(ssbos, ssbo)
233+
return append(objects, ssbo)
234234
}
235235

236236
// NewArc returns a 2D arc centered at the origin (x,y)=(0,0) for a given radius and arc angle and thickness of the arc.
@@ -282,8 +282,8 @@ func (a *arc2D) ForEach2DChild(userData any, fn func(userData any, s *glbuild.Sh
282282
return nil
283283
}
284284

285-
func (u *arc2D) AppendShaderObjects(ssbos []glbuild.ShaderObject) []glbuild.ShaderObject {
286-
return ssbos
285+
func (u *arc2D) AppendShaderObjects(objects []glbuild.ShaderObject) []glbuild.ShaderObject {
286+
return objects
287287
}
288288

289289
type circle2D struct {
@@ -319,8 +319,8 @@ func (c *circle2D) ForEach2DChild(userData any, fn func(userData any, s *glbuild
319319
return nil
320320
}
321321

322-
func (u *circle2D) AppendShaderObjects(ssbos []glbuild.ShaderObject) []glbuild.ShaderObject {
323-
return ssbos
322+
func (u *circle2D) AppendShaderObjects(objects []glbuild.ShaderObject) []glbuild.ShaderObject {
323+
return objects
324324
}
325325

326326
type equilateralTri2d struct {
@@ -367,8 +367,8 @@ func (t *equilateralTri2d) ForEach2DChild(userData any, fn func(userData any, s
367367
return nil
368368
}
369369

370-
func (u *equilateralTri2d) AppendShaderObjects(ssbos []glbuild.ShaderObject) []glbuild.ShaderObject {
371-
return ssbos
370+
func (u *equilateralTri2d) AppendShaderObjects(objects []glbuild.ShaderObject) []glbuild.ShaderObject {
371+
return objects
372372
}
373373

374374
type rect2D struct {
@@ -410,8 +410,8 @@ func (c *rect2D) ForEach2DChild(userData any, fn func(userData any, s *glbuild.S
410410
return nil
411411
}
412412

413-
func (u *rect2D) AppendShaderObjects(ssbos []glbuild.ShaderObject) []glbuild.ShaderObject {
414-
return ssbos
413+
func (u *rect2D) AppendShaderObjects(objects []glbuild.ShaderObject) []glbuild.ShaderObject {
414+
return objects
415415
}
416416

417417
type hex2D struct {
@@ -451,8 +451,8 @@ func (c *hex2D) ForEach2DChild(userData any, fn func(userData any, s *glbuild.Sh
451451
return nil
452452
}
453453

454-
func (u *hex2D) AppendShaderObjects(ssbos []glbuild.ShaderObject) []glbuild.ShaderObject {
455-
return ssbos
454+
func (u *hex2D) AppendShaderObjects(objects []glbuild.ShaderObject) []glbuild.ShaderObject {
455+
return objects
456456
}
457457

458458
type ellipse2D struct {
@@ -522,8 +522,8 @@ func (c *ellipse2D) ForEach2DChild(userData any, fn func(userData any, s *glbuil
522522
return nil
523523
}
524524

525-
func (u *ellipse2D) AppendShaderObjects(ssbos []glbuild.ShaderObject) []glbuild.ShaderObject {
526-
return ssbos
525+
func (u *ellipse2D) AppendShaderObjects(objects []glbuild.ShaderObject) []glbuild.ShaderObject {
526+
return objects
527527
}
528528

529529
type poly2D struct {
@@ -599,8 +599,8 @@ func (c *poly2D) ForEach2DChild(userData any, fn func(userData any, s *glbuild.S
599599
return nil
600600
}
601601

602-
func (u *poly2D) AppendShaderObjects(ssbos []glbuild.ShaderObject) []glbuild.ShaderObject {
603-
return ssbos // TODO: implement shader buffer storage here!
602+
func (u *poly2D) AppendShaderObjects(objects []glbuild.ShaderObject) []glbuild.ShaderObject {
603+
return objects // TODO: implement shader buffer storage here!
604604
}
605605

606606
// Extrude converts a 2D SDF into a 3D extrusion. Extrudes in both positive and negative Z direction, half of h both ways.
@@ -633,8 +633,8 @@ func (e *extrusion) ForEach2DChild(userData any, fn func(userData any, s *glbuil
633633
func (e *extrusion) ForEachChild(userData any, fn func(userData any, s *glbuild.Shader3D) error) error {
634634
return nil
635635
}
636-
func (u *extrusion) AppendShaderObjects(ssbos []glbuild.ShaderObject) []glbuild.ShaderObject {
637-
return ssbos
636+
func (u *extrusion) AppendShaderObjects(objects []glbuild.ShaderObject) []glbuild.ShaderObject {
637+
return objects
638638
}
639639

640640
func (e *extrusion) AppendShaderName(b []byte) []byte {
@@ -681,8 +681,8 @@ func (r *revolution) ForEach2DChild(userData any, fn func(userData any, s *glbui
681681
func (r *revolution) ForEachChild(userData any, fn func(userData any, s *glbuild.Shader3D) error) error {
682682
return nil
683683
}
684-
func (u *revolution) AppendShaderObjects(ssbos []glbuild.ShaderObject) []glbuild.ShaderObject {
685-
return ssbos
684+
func (u *revolution) AppendShaderObjects(objects []glbuild.ShaderObject) []glbuild.ShaderObject {
685+
return objects
686686
}
687687

688688
func (r *revolution) AppendShaderName(b []byte) []byte {
@@ -739,8 +739,8 @@ func (s *diff2D) AppendShaderBody(b []byte) []byte {
739739
b = append(b, "(p));"...)
740740
return b
741741
}
742-
func (u *diff2D) AppendShaderObjects(ssbos []glbuild.ShaderObject) []glbuild.ShaderObject {
743-
return ssbos
742+
func (u *diff2D) AppendShaderObjects(objects []glbuild.ShaderObject) []glbuild.ShaderObject {
743+
return objects
744744
}
745745

746746
// Intersection2D is the SDF intersection of a ^ b. Does not produce an exact SDF.
@@ -783,8 +783,8 @@ func (s *intersect2D) AppendShaderBody(b []byte) []byte {
783783
b = append(b, "(p));"...)
784784
return b
785785
}
786-
func (u *intersect2D) AppendShaderObjects(ssbos []glbuild.ShaderObject) []glbuild.ShaderObject {
787-
return ssbos
786+
func (u *intersect2D) AppendShaderObjects(objects []glbuild.ShaderObject) []glbuild.ShaderObject {
787+
return objects
788788
}
789789

790790
// Xor2D is the mutually exclusive boolean operation and results in an exact SDF.
@@ -825,8 +825,8 @@ func (s *xor2D) AppendShaderBody(b []byte) []byte {
825825
b = append(b, "return max(min(d1,d2),-max(d1,d2));"...)
826826
return b
827827
}
828-
func (u *xor2D) AppendShaderObjects(ssbos []glbuild.ShaderObject) []glbuild.ShaderObject {
829-
return ssbos
828+
func (u *xor2D) AppendShaderObjects(objects []glbuild.ShaderObject) []glbuild.ShaderObject {
829+
return objects
830830
}
831831

832832
// Array is the domain repetition operation. It repeats domain centered around (x,y)=(0,0).
@@ -904,8 +904,8 @@ return d;`, s.d.X, s.d.Y,
904904
b = append(b, body...)
905905
return b
906906
}
907-
func (u *array2D) AppendShaderObjects(ssbos []glbuild.ShaderObject) []glbuild.ShaderObject {
908-
return ssbos
907+
func (u *array2D) AppendShaderObjects(objects []glbuild.ShaderObject) []glbuild.ShaderObject {
908+
return objects
909909
}
910910

911911
// Offset2D adds sdfAdd to the entire argument SDF. If sdfAdd is negative this will
@@ -953,8 +953,8 @@ func (s *offset2D) AppendShaderBody(b []byte) []byte {
953953
b = append(b, ')', ';')
954954
return b
955955
}
956-
func (u *offset2D) AppendShaderObjects(ssbos []glbuild.ShaderObject) []glbuild.ShaderObject {
957-
return ssbos
956+
func (u *offset2D) AppendShaderObjects(objects []glbuild.ShaderObject) []glbuild.ShaderObject {
957+
return objects
958958
}
959959

960960
// Translate2D moves the SDF s in the given direction.
@@ -991,8 +991,8 @@ func (s *translate2D) AppendShaderBody(b []byte) []byte {
991991
b = append(b, "(p-t);"...)
992992
return b
993993
}
994-
func (u *translate2D) AppendShaderObjects(ssbos []glbuild.ShaderObject) []glbuild.ShaderObject {
995-
return ssbos
994+
func (u *translate2D) AppendShaderObjects(objects []glbuild.ShaderObject) []glbuild.ShaderObject {
995+
return objects
996996
}
997997

998998
// Rotate2D returns the argument shape rotated around the origin by theta (radians).
@@ -1051,8 +1051,8 @@ func (r *rotation2D) AppendShaderBody(b []byte) []byte {
10511051
return b
10521052
}
10531053

1054-
func (u *rotation2D) AppendShaderObjects(ssbos []glbuild.ShaderObject) []glbuild.ShaderObject {
1055-
return ssbos
1054+
func (u *rotation2D) AppendShaderObjects(objects []glbuild.ShaderObject) []glbuild.ShaderObject {
1055+
return objects
10561056
}
10571057

10581058
// Symmetry reflects the SDF around x or y (or both) axis.
@@ -1103,8 +1103,8 @@ func (s *symmetry2D) AppendShaderBody(b []byte) []byte {
11031103
return b
11041104
}
11051105

1106-
func (u *symmetry2D) AppendShaderObjects(ssbos []glbuild.ShaderObject) []glbuild.ShaderObject {
1107-
return ssbos
1106+
func (u *symmetry2D) AppendShaderObjects(objects []glbuild.ShaderObject) []glbuild.ShaderObject {
1107+
return objects
11081108
}
11091109

11101110
// Annulus makes a 2D shape annular by emptying it's center. It is the equivalent of the 3D Shell operation but in 2D.
@@ -1144,8 +1144,8 @@ func (s *annulus2D) AppendShaderBody(b []byte) []byte {
11441144
return b
11451145
}
11461146

1147-
func (u *annulus2D) AppendShaderObjects(ssbos []glbuild.ShaderObject) []glbuild.ShaderObject {
1148-
return ssbos
1147+
func (u *annulus2D) AppendShaderObjects(objects []glbuild.ShaderObject) []glbuild.ShaderObject {
1148+
return objects
11491149
}
11501150

11511151
// CircularArray2D is the circular domain repetition operation around the origin (x,y)=(0,0).
@@ -1225,6 +1225,6 @@ func (ca *circarray2D) AppendShaderBody(b []byte) []byte {
12251225
return b
12261226
}
12271227

1228-
func (u *circarray2D) AppendShaderObjects(ssbos []glbuild.ShaderObject) []glbuild.ShaderObject {
1229-
return ssbos
1228+
func (u *circarray2D) AppendShaderObjects(objects []glbuild.ShaderObject) []glbuild.ShaderObject {
1229+
return objects
12301230
}

0 commit comments

Comments
 (0)