Okay, you can't apply for permanent residence off ANY visa (the kind you border bounce on to get another 90 day stamp) it has to be on yearly extensions of stays and they cannot be broken during the 3 years prior to you applying.
Also you can't ever qualify for permanent residence on what's called a "retirement visa" because you can't hold a work permit and legally work on one.
If you are married to a thai, legally working here you can after a period of years apply directly for thai citizenship and totally skip the permanent residence process.
This is a LONG but good topic about how to acquire permanent residence
**********************************************************************************************
*****
-cameratas-guide-to-the-permanent-residence-process/