Although Hitler suffered from a number of mental problems, it had nothing to do with his racism; in fact racism was endemic in German society at the time. As did many other young men, Hitler had read the work of Count Arthur de Gobineau, the father of Scientific Racism. He was an avid fan of the composer, Richard Wagner, who was also apologetically anti-Semitic. As a teenager, Hitler often read a magazine known as Ostara which was pornographic in nature, and often contained anti-Semitic references and articles. It is a mistake to assume that the persecution of Jews during Hitler's control of Germany was all his idea. It had been around for a long time; he simply became the leader of the movement that put it into action.
As far as his mental state, Hitler did not smoke or drink, and was rather prudish in his views about romantic relationships. He only had one mistress at a time; but the relationships were apparently quite perverse, as they all died by suicide. He was something of a hypochondriac who feared that he had cancer, and often had himself injected with vitamin shots and other drugs by his doctor to keep himself going. He was somewhat tortured by the fact that his paternal grandfather was unknown (his father had been illegitimate.) There was speculation that the grandfather might have been a Jew for whom his grandmother was a housekeeper. The thought that he might have Jewish blood kept him in turmoil.
An excellent source on Hitler is The Psychopathic God by R.G.L. Waite.