No - he lost votes because of it if I recall correctly
I think it is pretty difficult to determine whether a single policy gains or loses you votes in a general election, because even for those that might tell opinion polls that they are more or less likely to vote for a party due to a single issue, when there is finally a choice at a general election based on a range of policies and personalities the importance of that single issue often fades.
So I doubt very much that Cameron's decision to back equal marriage would have been 'political' - i.e. calculated to gain votes. And certainly he got a lot of flack from a very vocal 'anti' minority of reactionaries within his own party.
So I genuinely think he supported equal marriage on principle, because he recognised it to be the right thing to do, rather than for narrow partisan political gain.
I suspect that history will think pretty poorly of Cameron as PM, but there will be probably 2 highlights, one political and the other changing the social landscape.
The political being winning a second general election with an increased vote share having been PM for a full term - that's pretty well unprecedented.
And the social change - well of course allowing gay couples to marry, which I have no doubt in years to come society will look back in horror at a time when gay couples were banned from getting married.