Exhausting in its relentless depravity, “Filth” nevertheless is reminiscent of a much better movie also adapted from a novel by Irvine Welsh: Danny Boyle’s 1996 “Trainspotting.”

Where that movie achieved a weird grace through its characters’ uncompromising determination to remain addict-outlaws, “Filth,” the second feature directed by Jon S. Baird, plunges to ever-greater depths of madness and cruelty for reasons that sound like psychobabble.

A soundtrack that includes a cover of Radiohead’s “Creep” to tell you how to feel about the story’s monstrous antihero is pure pandering.

The one element that keeps a viewer interested in “Filth” is the unexpectedly unhinged performance by James McAvoy, whose wildly corrupt Edinburgh police detective, Bruce, certainly seems nothing like the actor’s more appealing roles (“X-Men: Days of Future Past,” “Atonement”).

Unlimited Digital Access. $1 for 4 weeks.

Constantly crazed by booze, pills and cocaine, Bruce is a demon given to playing everyone he knows until he gets exactly what he wants.

That’s usually sex or psychological domination over friends and enemies alike. When an open position for inspector at the office has him on overdrive — convinced he’ll get the job — he is so obviously falling apart that the thought of advancement is ludicrous.

Helping to make “Filth” bearable is the supporting cast, which includes Jamie Bell, Jim Broadbent, Joanne Froggatt, Eddie Marsan, Imogen Poots and Shirley Henderson. The latter’s appearance in “Trainspotting” all those years ago is a good memory that doesn’t help “Filth” look any better.

Tom Keogh: tomwkeogh@yahoo.com