Mac Miller has officially been slapped with a DUI charge after his scary accident earlier this year ... TMZ has learned.

The L.A. City Attorney's Office filed charges against Mac stemming from his May car wreck. He's facing two counts of DUI -- one for driving under the influence and another for driving with a BAC at 0.08 or higher. He wasn't charged with hit and run, for which he was originally booked.

We broke the story ... MM was arrested in May for DUI and hit and run after cops found his 2016 G-Wagon smashed against a utility pole in the San Fernando Valley. Based on video of the scene, it's a miracle Mac wasn't seriously hurt ... 'cause it was bad.

AFTERMATH
RMG News\/MEGA

Cops say they showed up to Mac's house after the fact and had him use a breathalyzer ... we're told he blew twice the legal limit. Officers cuffed him and hauled him off to jail, but did note he was incredibly polite.

If convicted ... he faces up to 6 months in jail and a $1,000 fine ... but that's only theoretical -- almost every first offender gets off with probation, community service and a license suspension.

It's been a rough year for the dude ... his DUI arrest -- and now subsequent charges -- follows a breakup with Ariana Grande ... who's now engaged to Pete Davidson