The Tx. Code of criminal procedure states that an inmate is ENTITLED to credit for all time served pending disposition of that case. It is possible to waive that credit through a plea bargain, which can be as simple as the State neglecting to list your jail credit on the judgment and you and your attorney not catching it. Other than by agreement, the State cannot deny you credit under any circumstances.
It is important to realize however that credit only accrues on a charge when you are actually being held on that charge. For instance, if you bond out on an assault and then get rearrested on a new offense, your prior bond on the assault might not be revoked and you are only accruing credit on the new charge. In this instance the State is not required to give you any of that time on the original assault charge, though they often will anyway.