Involved in photosynthetic carbon assimilation. Catalyzes the NAD(P)-dependent oxidative phosphorylation of glyceraldehyde 3-phosphate (G3P) to 1,3-bisphosphoglycerate (BPG). The first reaction step involves the formation of a hemiacetal intermediate between G3P and a cysteine residue, and this hemiacetal intermediate is then oxidized to a thioester, with concomitant reduction of NAD to NADH. The reduced NADH is then exchanged with the second NAD, and the thioester is attacked by a nucleophilic inorganic phosphate to produce BPG. It can use both NADP and NAD