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)
| 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. |
| 406 | func (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 |
no test coverage detected