Playing defiantly against type, James McAvoy truly lets rip with a ferociously committed, full-throttle performance as the dirtiest of dirty cops in this darkly comic adaptation of Irvine Welsh’s bestselling novel.

McAvoy’s drink-and-drug addled, self-destructive and thoroughly corrupt Edinburgh detective leaves havoc in his wake as he angles for a promotion, sabotaging his colleagues (who include Jamie Bell and Imogen Poots) and ignoring the murder case he is supposed to be investigating.

Writer-director Jon S Baird pulls out all the stops, too, depicting his anti-hero’s toxic behaviour and mental unravelling with gob-smacking abandon.

Some viewers will find the character’s excesses too repugnant to stomach, but those who hang on for the ride will be rewarded by a furiously funny and, at times, exuberantly surreal tale.

McAvoy’s bravura performance dominates the film, yet a gallery of British actors, including Jim Broadbent, Shirley Henderson and Eddie Marsan, deliver striking supporting turns, and there’s even a startling cameo by a singing David Soul.