They serve a notice of termination. After the notice period is over, they will Not pay the salary and may not let you inside the premises of the office.
You should see whats the notice period the company will give.
In many companies, the termination notice period is month but the resignation notice period is 3 months(like in my case - its a large pvt sector bank)
So resigning will effectively give you more time and a honourable exit.
I think if the company has decided to lay you off, mostly you won’t have any other option to go.
You can try switching to other posts where the engineers are being retained, if you have relevant skills. But usually its a very rare case especially if the company is huge.
So you should definitely start applying.