Skip to content

Commit e85a3ae

Browse files
committed
major update to latest cogent core version, for achival purposes before removing from core.
1 parent 1d8d5b3 commit e85a3ae

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+2498
-4835
lines changed

README.md

+25-27
Large diffs are not rendered by default.

vgpu/cmds.go cmds.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2022, The Goki Authors. All rights reserved.
1+
// Copyright (c) 2022, Cogent Core. All rights reserved.
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

vgpu/compute.go compute.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2022, The Goki Authors. All rights reserved.
1+
// Copyright (c) 2022, Cogent Core. All rights reserved.
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

@@ -29,12 +29,12 @@ func (sy *System) ComputeCmdBuff() vk.CommandBuffer {
2929

3030
// ComputeResetBindVars adds command to the given
3131
// command buffer, to bind the Vars descriptors,
32-
// for given collection of descriptors descIdx
32+
// for given collection of descriptors descIndex
3333
// (see Vars NDescs for info).
3434
// Required whenever variables have changed their mappings,
3535
// before running a command.
36-
func (sy *System) ComputeResetBindVars(cmd vk.CommandBuffer, descIdx int) {
37-
sy.CmdResetBindVars(cmd, descIdx)
36+
func (sy *System) ComputeResetBindVars(cmd vk.CommandBuffer, descIndex int) {
37+
sy.CmdResetBindVars(cmd, descIndex)
3838
}
3939

4040
// ComputeResetBegin resets and begins the recording of commands
@@ -118,16 +118,16 @@ func (sy *System) ComputeWaitEvents(cmd vk.CommandBuffer, event ...string) error
118118

119119
// ComputeCopyToGPU records command to copy given regions
120120
// in the Storage buffer memory from CPU to GPU, in one call.
121-
// Use SyncRegValIdxFmCPU to get the regions.
121+
// Use SyncRegValueIndexFromCPU to get the regions.
122122
func (sy *System) ComputeCopyToGPU(cmd vk.CommandBuffer, regs ...MemReg) {
123123
sy.Mem.CmdTransferStorageRegsToGPU(cmd, regs)
124124
}
125125

126-
// ComputeCopyFmGPU records command to copy given regions
126+
// ComputeCopyFromGPU records command to copy given regions
127127
// in the Storage buffer memory from GPU to CPU, in one call.
128-
// Use SyncRegValIdxFmCPU to get the regions.
129-
func (sy *System) ComputeCopyFmGPU(cmd vk.CommandBuffer, regs ...MemReg) {
130-
sy.Mem.CmdTransferStorageRegsFmGPU(cmd, regs)
128+
// Use SyncRegValueIndexFromCPU to get the regions.
129+
func (sy *System) ComputeCopyFromGPU(cmd vk.CommandBuffer, regs ...MemReg) {
130+
sy.Mem.CmdTransferStorageRegsFromGPU(cmd, regs)
131131
}
132132

133133
// ComputeWaitMemWriteRead records pipeline barrier ensuring

vgpu/consts.go consts.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2022, The Goki Authors. All rights reserved.
1+
// Copyright (c) 2022, Cogent Core. All rights reserved.
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

vgpu/debug.go debug.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2022, The Goki Authors. All rights reserved.
1+
// Copyright (c) 2022, Cogent Core. All rights reserved.
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

@@ -10,7 +10,7 @@ package vgpu
1010
import (
1111
"bytes"
1212
"fmt"
13-
"io/ioutil"
13+
"os"
1414
"runtime"
1515
"strings"
1616
)
@@ -64,7 +64,7 @@ func (frame *StackFrame) String() string {
6464

6565
// SourceLine gets the line of code (from File and Line) of the original source if possible
6666
func (frame *StackFrame) SourceLine() (string, error) {
67-
data, err := ioutil.ReadFile(frame.File)
67+
data, err := os.ReadFile(frame.File)
6868

6969
if err != nil {
7070
return "", err

vgpu/device.go device.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2022, The Goki Authors. All rights reserved.
1+
// Copyright (c) 2022, Cogent Core. All rights reserved.
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

doc.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2022, The Goki Authors. All rights reserved.
1+
// Copyright (c) 2022, Cogent Core. All rights reserved.
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

@@ -7,7 +7,7 @@ Package vgpu implements a convenient interface to the Vulkan GPU-based
77
graphics and compute framework, in Go, using the
88
https://github.com/goki/vulkan Go bindings.
99
10-
The GoGi GUI framework runs on top if this, replacing the previous
10+
The Cogent Core GUI framework runs on top if this, replacing the previous
1111
OpenGL-based framework, and the compute engine is used for the
1212
emergent neural network simulation framework.
1313
*/

enumgen.go

+420
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vgpu/errors.go errors.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2022, The Goki Authors. All rights reserved.
1+
// Copyright (c) 2022, Cogent Core. All rights reserved.
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

examples/compute1/compute.go

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2022, The Goki Authors. All rights reserved.
1+
// Copyright (c) 2022, Cogent Core. All rights reserved.
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

@@ -9,8 +9,8 @@ import (
99
"math/rand"
1010
"runtime"
1111

12-
"goki.dev/mat32/v2"
13-
"goki.dev/vgpu/v2/vgpu"
12+
"cogentcore.org/core/math32"
13+
"cogentcore.org/core/vgpu"
1414
)
1515

1616
func init() {
@@ -28,7 +28,7 @@ func main() {
2828
gp.Config("compute1")
2929
fmt.Printf("Running on GPU: %s\n", gp.DeviceName)
3030

31-
// gp.PropsString(true) // print
31+
// gp.PropertiesString(true) // print
3232

3333
sy := gp.NewComputeSystem("compute1")
3434
pl := sy.NewPipeline("compute1")
@@ -40,19 +40,19 @@ func main() {
4040
n := 20 // note: not necc to spec up-front, but easier if so
4141

4242
threads := 64
43-
nInt := mat32.IntMultiple(float32(n), float32(threads))
43+
nInt := math32.IntMultiple(float32(n), float32(threads))
4444
n = int(nInt) // enforce optimal n's -- otherwise requires range checking
4545
nGps := n / threads // dispatch n
4646
fmt.Printf("n: %d\n", n)
4747

48-
inv := set.Add("In", vgpu.Float32Vec4, n, vgpu.Storage, vgpu.ComputeShader)
49-
outv := set.Add("Out", vgpu.Float32Vec4, n, vgpu.Storage, vgpu.ComputeShader)
48+
inv := set.Add("In", vgpu.Float32Vector4, n, vgpu.Storage, vgpu.ComputeShader)
49+
outv := set.Add("Out", vgpu.Float32Vector4, n, vgpu.Storage, vgpu.ComputeShader)
5050
_ = outv
5151

52-
set.ConfigVals(1) // one val per var
53-
sy.Config() // configures vars, allocates vals, configs pipelines..
52+
set.ConfigValues(1) // one val per var
53+
sy.Config() // configures vars, allocates vals, configs pipelines..
5454

55-
ivl, _ := inv.Vals.ValByIdxTry(0)
55+
ivl, _ := inv.Values.ValueByIndexTry(0)
5656
idat := ivl.Floats32()
5757
for i := 0; i < n; i++ {
5858
idat[i*4+0] = rand.Float32()
@@ -64,16 +64,16 @@ func main() {
6464

6565
sy.Mem.SyncToGPU()
6666

67-
vars.BindDynValsAllIdx(0)
67+
vars.BindDynValuesAllIndex(0)
6868

6969
cmd := sy.ComputeCmdBuff()
7070
sy.ComputeResetBindVars(cmd, 0)
7171
pl.ComputeDispatch(cmd, nGps, 1, 1)
7272
sy.ComputeCmdEnd(cmd)
7373
sy.ComputeSubmitWait(cmd) // if no wait, faster, but validation complains
7474

75-
sy.Mem.SyncValIdxFmGPU(0, "Out", 0)
76-
_, ovl, _ := vars.ValByIdxTry(0, "Out", 0)
75+
sy.Mem.SyncValueIndexFromGPU(0, "Out", 0)
76+
_, ovl, _ := vars.ValueByIndexTry(0, "Out", 0)
7777

7878
odat := ovl.Floats32()
7979
for i := 0; i < n; i++ {

examples/drawidx/drawidx.go

+32-32
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2022, The Goki Authors. All rights reserved.
1+
// Copyright (c) 2022, Cogent Core. All rights reserved.
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

@@ -13,9 +13,9 @@ import (
1313

1414
vk "github.com/goki/vulkan"
1515

16+
"cogentcore.org/core/math32"
17+
"cogentcore.org/core/vgpu"
1618
"github.com/go-gl/glfw/v3.3/glfw"
17-
"goki.dev/mat32/v2"
18-
"goki.dev/vgpu/v2/vgpu"
1919
)
2020

2121
func init() {
@@ -24,9 +24,9 @@ func init() {
2424
}
2525

2626
type CamView struct {
27-
Model mat32.Mat4
28-
View mat32.Mat4
29-
Prjn mat32.Mat4
27+
Model math32.Matrix4
28+
View math32.Matrix4
29+
Projection math32.Matrix4
3030
}
3131

3232
func main() {
@@ -45,7 +45,7 @@ func main() {
4545
vgpu.Debug = true
4646
gp.Config("drawidx")
4747

48-
// gp.PropsString(true) // print
48+
// gp.PropertiesString(true) // print
4949

5050
surfPtr, err := window.CreateWindowSurface(gp.Instance, nil)
5151
if err != nil {
@@ -83,47 +83,47 @@ func main() {
8383

8484
nPts := 3
8585

86-
posv := vset.Add("Pos", vgpu.Float32Vec3, nPts, vgpu.Vertex, vgpu.VertexShader)
87-
clrv := vset.Add("Color", vgpu.Float32Vec3, nPts, vgpu.Vertex, vgpu.VertexShader)
86+
posv := vset.Add("Pos", vgpu.Float32Vector3, nPts, vgpu.Vertex, vgpu.VertexShader)
87+
clrv := vset.Add("Color", vgpu.Float32Vector3, nPts, vgpu.Vertex, vgpu.VertexShader)
8888
// note: always put indexes last so there isn't a gap in the location indexes!
8989
// just the fact of adding one (and only one) Index type triggers indexed render
9090
idxv := vset.Add("Index", vgpu.Uint16, nPts, vgpu.Index, vgpu.VertexShader)
9191

9292
camv := set.Add("Camera", vgpu.Struct, 1, vgpu.Uniform, vgpu.VertexShader)
93-
camv.SizeOf = vgpu.Float32Mat4.Bytes() * 3 // no padding for these
93+
camv.SizeOf = vgpu.Float32Matrix4.Bytes() * 3 // no padding for these
9494

95-
vset.ConfigVals(1) // one val per var
96-
set.ConfigVals(1) // one val per var
95+
vset.ConfigValues(1) // one val per var
96+
set.ConfigValues(1) // one val per var
9797
sy.Config()
9898

99-
triPos, _ := posv.Vals.ValByIdxTry(0)
99+
triPos, _ := posv.Values.ValueByIndexTry(0)
100100
triPosA := triPos.Floats32()
101101
triPosA.Set(0,
102102
-0.5, 0.5, 0.0,
103103
0.5, 0.5, 0.0,
104104
0.0, -0.5, 0.0) // negative point is UP in native Vulkan
105105
triPos.SetMod()
106106

107-
triClr, _ := clrv.Vals.ValByIdxTry(0)
107+
triClr, _ := clrv.Values.ValueByIndexTry(0)
108108
triClrA := triClr.Floats32()
109109
triClrA.Set(0,
110110
1.0, 0.0, 0.0,
111111
0.0, 1.0, 0.0,
112112
0.0, 0.0, 1.0)
113113
triClr.SetMod()
114114

115-
triIdx, _ := idxv.Vals.ValByIdxTry(0)
115+
triIndex, _ := idxv.Values.ValueByIndexTry(0)
116116
idxs := []uint16{0, 1, 2}
117-
triIdx.CopyFromBytes(unsafe.Pointer(&idxs[0]))
117+
triIndex.CopyFromBytes(unsafe.Pointer(&idxs[0]))
118118

119119
// This is the standard camera view projection computation
120-
cam, _ := camv.Vals.ValByIdxTry(0)
121-
campos := mat32.V3(0, 0, 2)
122-
target := mat32.V3(0, 0, 0)
123-
var lookq mat32.Quat
124-
lookq.SetFromRotationMatrix(mat32.NewLookAt(campos, target, mat32.V3(0, 1, 0)))
125-
scale := mat32.V3(1, 1, 1)
126-
var cview mat32.Mat4
120+
cam, _ := camv.Values.ValueByIndexTry(0)
121+
campos := math32.Vec3(0, 0, 2)
122+
target := math32.Vec3(0, 0, 0)
123+
var lookq math32.Quat
124+
lookq.SetFromRotationMatrix(math32.NewLookAt(campos, target, math32.Vec3(0, 1, 0)))
125+
scale := math32.Vec3(1, 1, 1)
126+
var cview math32.Matrix4
127127
cview.SetTransform(campos, lookq, scale)
128128
view, _ := cview.Inverse()
129129

@@ -132,16 +132,13 @@ func main() {
132132
camo.View.CopyFrom(view)
133133
aspect := float32(sf.Format.Size.X) / float32(sf.Format.Size.Y)
134134
fmt.Printf("aspect: %g\n", aspect)
135-
// VkPerspective version automatically flips Y axis and shifts depth
136-
// into a 0..1 range instead of -1..1, so original GL based geometry
137-
// will render identically here.
138-
camo.Prjn.SetVkPerspective(45, aspect, 0.01, 100)
135+
camo.Projection.SetPerspective(45, aspect, 0.01, 100)
139136

140137
cam.CopyFromBytes(unsafe.Pointer(&camo)) // sets mod
141138

142139
sy.Mem.SyncToGPU()
143140

144-
vars.BindDynVal(0, camv, cam)
141+
vars.BindDynamicValue(0, camv, cam)
145142

146143
frameCount := 0
147144
stTime := time.Now()
@@ -153,12 +150,15 @@ func main() {
153150
cam.CopyFromBytes(unsafe.Pointer(&camo)) // sets mod
154151
sy.Mem.SyncToGPU()
155152

156-
idx := sf.AcquireNextImage()
153+
idx, ok := sf.AcquireNextImage()
154+
if !ok {
155+
return
156+
}
157157
// fmt.Printf("\nacq: %v\n", time.Now().Sub(rt))
158-
descIdx := 0 // if running multiple frames in parallel, need diff sets
158+
descIndex := 0 // if running multiple frames in parallel, need diff sets
159159
cmd := sy.CmdPool.Buff
160-
sy.ResetBeginRenderPass(cmd, sf.Frames[idx], descIdx)
161-
pl.BindDrawVertex(cmd, descIdx)
160+
sy.ResetBeginRenderPass(cmd, sf.Frames[idx], descIndex)
161+
pl.BindDrawVertex(cmd, descIndex)
162162
sy.EndRenderPass(cmd)
163163
// fmt.Printf("cmd %v\n", time.Now().Sub(rt))
164164
sf.SubmitRender(cmd) // this is where it waits for the 16 msec

examples/drawidx/indexed.vert

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ layout(binding = 0) uniform UniformBufferObject {
66
mat4 Proj;
77
} Camera;
88

9-
layout(location = 0) in vec3 Pos;
10-
layout(location = 1) in vec3 Color;
11-
// layout(location = 2) in vec2 TexCoord;
9+
layout(location = 0) in vector3 Pos;
10+
layout(location = 1) in vector3 Color;
11+
// layout(location = 2) in vector2 TexCoord;
1212

13-
layout(location = 0) out vec3 FragColor;
14-
// layout(location = 1) out vec2 FragTexCoord;
13+
layout(location = 0) out vector3 FragColor;
14+
// layout(location = 1) out vector2 FragTexCoord;
1515

1616
void main() {
17-
vec4 pos = vec4(Pos, 1.0);
17+
vector4 pos = vector4(Pos, 1.0);
1818
gl_Position = Camera.Proj * Camera.View * Camera.Model * pos;
1919
FragColor = Color;
2020
// FragTexCoord = TexCoord;

examples/drawidx/vtxcolor.frag

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#version 450
22

3-
layout(location = 0) in vec3 FragColor;
3+
layout(location = 0) in vector3 FragColor;
44

5-
layout(location = 0) out vec4 OutColor;
5+
layout(location = 0) out vector4 OutColor;
66

77
void main() {
8-
OutColor = vec4(FragColor, 1.0);
8+
OutColor = vector4(FragColor, 1.0);
99
}
1010

0 commit comments

Comments
 (0)