DescLayout creates the DescriptorSetLayout in DescLayout for given set. Only for non-VertexSet sets. Must have set NValuesPer for any TextureRole vars, which require separate descriptors per.
(dev vk.Device, vs *Vars)
| 186 | // Only for non-VertexSet sets. |
| 187 | // Must have set NValuesPer for any TextureRole vars, which require separate descriptors per. |
| 188 | func (st *VarSet) DescLayout(dev vk.Device, vs *Vars) { |
| 189 | st.DestroyLayout(dev) |
| 190 | st.NTextures = 0 |
| 191 | var descLayout vk.DescriptorSetLayout |
| 192 | var binds []vk.DescriptorSetLayoutBinding |
| 193 | dyno := len(vs.DynOffs[0]) |
| 194 | var flags vk.DescriptorSetLayoutCreateFlags |
| 195 | var dbf []vk.DescriptorBindingFlags |
| 196 | nvar := len(st.Vars) |
| 197 | nVarDesc := 0 |
| 198 | st.NTextureDescs = 1 |
| 199 | for vi, vr := range st.Vars { |
| 200 | bd := vk.DescriptorSetLayoutBinding{ |
| 201 | Binding: uint32(vr.BindLoc), |
| 202 | DescriptorType: vr.Role.VkDescriptor(), |
| 203 | DescriptorCount: 1, |
| 204 | StageFlags: vk.ShaderStageFlags(vr.Shaders), |
| 205 | } |
| 206 | if vs.StaticVars { |
| 207 | bd.DescriptorType = vr.Role.VkDescriptorStatic() |
| 208 | } |
| 209 | if vr.Role > Storage { |
| 210 | vals := vr.Values.ActiveValues() |
| 211 | nvals := len(vals) |
| 212 | st.NTextures += nvals |
| 213 | nVarDesc = min(nvals, MaxTexturesPerSet) // per desc |
| 214 | |
| 215 | if nvals > MaxTexturesPerSet { |
| 216 | st.NTextureDescs = NDescForTextures(nvals) |
| 217 | if st.NTextureDescs > vs.NDescs { |
| 218 | fmt.Printf("vgpu.VarSet: Texture %s NValues: %d requires NDescs = %d, but it is only: %d -- this probably won't end well, but can't be fixed here\n", vr.Name, nvals, st.NTextureDescs, vs.NDescs) |
| 219 | } |
| 220 | } |
| 221 | bd.DescriptorCount = uint32(nVarDesc) |
| 222 | dbfFlags := vk.DescriptorBindingPartiallyBoundBit |
| 223 | // | vk.DescriptorBindingUpdateAfterBindBit | vk.DescriptorBindingUpdateUnusedWhilePendingBit |
| 224 | if vi == nvar-1 { |
| 225 | dbfFlags |= vk.DescriptorBindingVariableDescriptorCountBit // can only be for last one |
| 226 | } |
| 227 | dbf = append(dbf, vk.DescriptorBindingFlags(dbfFlags)) |
| 228 | // flags = vk.DescriptorSetLayoutCreateFlags(vk.DescriptorSetLayoutCreateUpdateAfterBindPoolBit) |
| 229 | } |
| 230 | binds = append(binds, bd) |
| 231 | if !vs.StaticVars { |
| 232 | if vr.Role == Uniform || vr.Role == Storage { |
| 233 | vr.BindValueIndex = make([]int, vs.NDescs) |
| 234 | vr.DynOffIndex = dyno |
| 235 | vs.AddDynOff() |
| 236 | dyno++ |
| 237 | } |
| 238 | } |
| 239 | } |
| 240 | |
| 241 | // https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VkDescriptorSetLayoutBindingFlagsCreateInfo.html |
| 242 | |
| 243 | // PNext of following contains |
| 244 | dslci := &vk.DescriptorSetLayoutCreateInfo{ |
| 245 | SType: vk.StructureTypeDescriptorSetLayoutCreateInfo, |
nothing calls this directly
no test coverage detected