“Pain and Glory” marks Pedro Almodóvar’s 21st movie. And, like any 21-year-old with a handle of Smirnoff, the Spanish director is taking bigger risks than ever.

The most major? He’s made a film about himself — and it’s no hagiography.

When he presented “Pain and Glory” at the New York Film Festival, 70-year-old Almodóvar was careful to say that, although inspired by his life, not all moments of the flick should be taken literally. Fine. You can still feel his tears staining every page of the script.

The sublime drama, sprinkled with moments of lightness, jumps back and forth between his alter ego Salvador’s childhood in rural Spain with his struggling mom (Penelope Cruz) and his somewhat stagnant adulthood in Madrid. Visually, it’s a stark difference, from village women washing pastel-colored linens in the river to a sterile, modern apartment that might’ve been furnished by IKEA.

The older Salvador (Antonio Banderas) is a movie director, who had a major hit years earlier. For its 20th anniversary, he reunites with the film’s star Alberto (Asier Etxeandia) — a hot mess — and, thanks to a poor decision, starts using heroin.

It’s not an addiction movie, though, or a friendship film or a romance. It’s a tender tale of a life lived. In flashbacks, we see stoic little Salvador (Asier Flores, already skilled) gradually figuring out that he’s gay and, simultaneously, becoming a budding culture savant. Later on as an adult, he unexpectedly reunites with a former lover in a subtle scene that’s some of Banderas’ best work ever.

Meant in the most flattering way possible, the actor seems genuinely exhausted here — drained of life’s inspiration, contending with past demons and using drugs to cope with it all. He has a deep connection to the character, which is fitting. Almodóvar gave him some of his earliest roles, starting with 1982’s “Labyrinth of Passion.”

In a way, casting Banderas is yet another special piece of Almodóvar’s biography he’s added into this highly personal film. Just don’t take the film literally.