Saudi criminal laws aren’t codified. In theory, the Quran is the source of law, with various royal decrees layered on top. In the Quran, it’s actual homosexual acts that are the crime. So simply being homosexual should not, in theory, get you in trouble. But in practice, the CPVPV has wide latitude. People have been arrested for flying a rainbow flag: https://www.google.com/amp/www.independent.co.uk/news/world/.... People have also been arrested for their social media activity: https://www.google.com/amp/www.washingtonblade.com/2016/03/2...
As a person who visited SA I know for a fact that even among muslims who have homosexual inclinations, that it's not a problem unless one acts upon it or tries to 'propagate' against the established and accepted moral foundations. Not sure about the specifics of the visit rules tho, but I doubt that they would ask you about that, instead they would ask you about your religion.
Keep in mind realities of class and power exist in Saudi Arabia as well. As a guest of the World Chess Championship, you'll be given much more leeway than a regular Saudi citizen.
How rich and/or successful do you have to be to not be imprisoned for being gay in KSA? Is there a specific level of achievement or do you fill out a waiver application?
Apparently, there is no level to avoid being imprisoned, but if you are suitably wealthy, you will be held at the Ritz-Carlton Hotel and Detainment Facility.