How much of Italy's WWII 'Side-Switching' was driven by pragmatism vs. anti-fascist sentiment?

The popular narrative of Italy during WWII, often focuses around the idea that many Italians 'switched sides' and joined the Allies simply because they were losing the war, as if they were opportunistically abandoning the fascist cause. How much of this is actually true?

Did most Italians who fought with the Allies do so out of pure pragmatism, or was there already a significant amount of internal opposition within the military to Mussolini and fascism that just needed the right catalyst to come to the surface?

Was the shift from fighting for the fascists to supporting the Allies mostly about realizing the war was lost, or were there deeper ideological divides within the Italian military (and society at large, besides the resistance) that had been brewing for a long time?

In short, how much of Italy’s change of sides was based on a genuine rejection of fascism versus a response to the practicalities of defeat – is it fair to assume that most were motivated by military pragmatism, or were there individual stories that suggest a deeper rejection of fascism?