Every so often in Pedro Almodóvar’s sublime “Pain and Glory,” Salvador Mallo (Antonio Banderas) closes his eyes and drifts away. A celebrated Spanish filmmaker, Salvador has lost his bearings. He’s gravely depressed, and his body seems to have permanently surrendered to his maladies, to his bad back, migraines, asthma and fits of terrifying, mysterious choking. When a friend offers him some heroin to smoke, Salvador readily lights up and disappears. His nagging pains suddenly give way to images from his childhood, idylls that brighten the screen like beacons in a fog.

A story of memory and creation, youth and its loss, “Pain and Glory” circles around the idea of art as self-creation. The precipitating event — the thing that nudges Salvador and the movie forward — is the screening of an early triumph, a 1980s film called “Sabor.” (Its poster is suitably Almodóvarian: a strawberry-like tongue licking its luscious red lips.) Uneasy about the screening, Salvador reaches out to one of its actors , Alberto ( Asier Etxeandia ), a debauched looker with dangerous habits and a thing for skulls. The men haven’t spoken for years, but slip into a thorny intimacy that’s almost domestic, pushing and pulling at each other while picking at old scabs.

The screening turns into a mild farce, but it stirs something in Salvador, lighting a small fire. The grinning face of death hangs over “Pain and Glory,” but it soon emerges that Salvador’s most debilitating issue is that he is a man without desire. He’s alone and hasn’t made movie in a while, and a new one doesn’t seem on the horizon. Yet even as he idles, his will to create — to dream, share stories, make drama — remains intact. He may not be shooting a film, but it’s telling how much his life seems like a melodrama or a comedy or even, as in a gritty scene with slashing knives and blood, a thriller.