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

Method CmdBindTextureVarIndex

vgpu/system.go:406–423  ·  view source on GitHub ↗

CmdBindTextureVarIndex returns the txIndex needed to select the given Texture value at valIndex in given variable in given set index, for use in a shader (i.e., pass txIndex as a push constant to the shader to select this texture). If there are more than MaxTexturesPerSet textures, then it may need

(cmd vk.CommandBuffer, setIndex int, varNm string, valIndex int)

Source from the content-addressed store, hash-verified

404// that is not necessarily the case, so other steps might need to be taken.
405// If the texture is not valid, a -1 is returned for txIndex, and an error is logged.
406func (sy *System) CmdBindTextureVarIndex(cmd vk.CommandBuffer, setIndex int, varNm string, valIndex int) (txIndex, descIndex int, switched bool, err error) {
407 vars := sy.Vars()
408 txv, _, _ := vars.ValueByIndexTry(setIndex, varNm, valIndex)
409
410 descIndex = valIndex / MaxTexturesPerSet
411 if descIndex != vars.BindDescIndex {
412 sy.CmdBindVars(cmd, descIndex)
413 vars.BindDescIndex = descIndex
414 switched = true
415 }
416 stIndex := descIndex * MaxTexturesPerSet
417 txIndex = txv.TextureValidIndex(stIndex, valIndex)
418 if txIndex < 0 {
419 err = fmt.Errorf("vgpu.CmdBindTextureVarIndex: Texture var %s image val at index %d (starting at idx: %d) is not valid", varNm, valIndex, stIndex)
420 log.Println(err) // this is always bad
421 }
422 return
423}
424
425// CmdResetBindVars adds command to the given command buffer
426// to bind the Vars descriptors, for given collection of descriptors descIndex

Callers 2

RenderTextureMethod · 0.80
DrawMethod · 0.80

Calls 6

VarsMethod · 0.95
CmdBindVarsMethod · 0.95
TextureValidIndexMethod · 0.80
PrintlnMethod · 0.80
ErrorfMethod · 0.65
ValueByIndexTryMethod · 0.45

Tested by

no test coverage detected