MCPcopy Create free account
hub / github.com/cogentcore/core / Config

Method Config

vgpu/varset.go:113–157  ·  view source on GitHub ↗

Config must be called after all variables have been added. configures binding / location for all vars based on sequential order. also does validation and returns error message.

(dev vk.Device)

Source from the content-addressed store, hash-verified

111// configures binding / location for all vars based on sequential order.
112// also does validation and returns error message.
113func (st *VarSet) Config(dev vk.Device) error {
114 st.RoleMap = make(map[VarRoles][]*Var)
115 var cerr error
116 bloc := 0
117 for _, vr := range st.Vars {
118 if st.Set == VertexSet && vr.Role > Index {
119 err := fmt.Errorf("vgpu.VarSet:Config VertexSet cannot contain variables of role: %s var: %s", vr.Role.String(), vr.Name)
120 cerr = err
121 if Debug {
122 log.Println(err)
123 }
124 continue
125 }
126 if st.Set >= 0 && vr.Role <= Index {
127 err := fmt.Errorf("vgpu.VarSet:Config Vertex or Index Vars must be located in a VertexSet! Use AddVertexSet() method instead of AddSet()")
128 cerr = err
129 if Debug {
130 log.Println(err)
131 }
132 }
133 rl := st.RoleMap[vr.Role]
134 rl = append(rl, vr)
135 st.RoleMap[vr.Role] = rl
136 if vr.Role == Index && len(rl) > 1 {
137 err := fmt.Errorf("vgpu.VarSet:Config VertexSet should not contain multiple Index variables: %v", rl)
138 cerr = err
139 if Debug {
140 log.Println(err)
141 }
142 }
143 if vr.Role > Storage && (len(st.RoleMap[Uniform]) > 0 || len(st.RoleMap[Storage]) > 0) {
144 err := fmt.Errorf("vgpu.VarSet:Config Set with dynamic Uniform or Storage variables should not contain static variables (e.g., textures): %s", vr.Role.String())
145 cerr = err
146 if Debug {
147 log.Println(err)
148 }
149 }
150 vr.BindLoc = bloc
151 if vr.Role == TextureRole {
152 vr.SetTextureDev(dev)
153 }
154 bloc++
155 }
156 return cerr
157}
158
159// ConfigValues configures the Values for the vars in this set, allocating
160// nvals per variable. There must be a unique value available for each

Callers

nothing calls this directly

Calls 4

PrintlnMethod · 0.80
SetTextureDevMethod · 0.80
ErrorfMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected