Don't know how you all do it in Texas, but here's how it works where I practice:
1) Doubt is raised over the competency of a defendant
2) Criminal Proceedings are suspended for "restoration of competency." Defendant is sent to a lockdown mental hospital and can remain there for up to 3 years.
3) If, after 3 years (or sooner if max punishment on the charges is under 3 years), it does not appear that the defendant will be restored to competency, the case can be dismissed OR the state can try for a Conservatorship in which the defendant can be sent to a lockdown mental hospital, potentially for life.
1a) If defense tries for the "not guilty by reason of insanity defense" then even if the jury/judge returns with a "NGI" verdict, the defendant is sent to a lockdown mental hospital until sanity can be restored; or until the defendant reaches the maximum exposure. In practice, an NGI defense can provide false hope for a defendant as they often spend longer in a locked facility than they would had they simply taken a plea deal for prison.