-
-
Notifications
You must be signed in to change notification settings - Fork 10k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix blurry fonts in GLFW backend when using -ffast-math #6529
base: master
Are you sure you want to change the base?
Fix blurry fonts in GLFW backend when using -ffast-math #6529
Conversation
That seems surprising. |
I would imagine |
This is indeed a very-visible thing as it indirectly affects the projection matrix. My issue is that am 100% confident many other things would be affected, and I am not exactly looking forward to having to debug and fix obscure bugs that are related to this. Switching to double - even occasionally - in some low-level computation may not be a desirable solution and I can generally envision debugging fast-math related issues to be extremely time consuming. So I think it is a great "feature" that the projection matrix gets broken so visibly in order to deter people from using that. My suggestion would be:
|
That is fair, I don't think it's feasible to find every spot that might be broken by For anyone reading this in the future, I found which file produced the visual bug by selectively turning |
Issue: Fonts look blurry when using the GLFW backend with
-ffast-math
/-Ofast
//fp:fast
due to a reciprocal divide optimization introducing error in the scale calculation.Solution: Compute the scale with higher precision.
Before:
![imgui_before](https://cdn.statically.io/img/private-user-images.githubusercontent.com/26562606/246649170-238e62db-8b5c-45f4-8826-9cb6665950bc.PNG?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjE0MzQyMTEsIm5iZiI6MTcyMTQzMzkxMSwicGF0aCI6Ii8yNjU2MjYwNi8yNDY2NDkxNzAtMjM4ZTYyZGItOGI1Yy00NWY0LTg4MjYtOWNiNjY2NTk1MGJjLlBORz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MjAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzIwVDAwMDUxMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWJlMGZjYWNjNzhjYTRjYjE0ZmQzMzI4ZTg4YmVjODZjMjVkNWE2YjE0OGZmZGNkNWY1ZTRmNzczMDI4MGI5NWYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.RakCkF07IRdBxaYQryBIgyNRPzQHcYagbCEnDeFmiMw)
After:
![imgui_after](https://cdn.statically.io/img/private-user-images.githubusercontent.com/26562606/246649178-cd188e9d-b5b3-4251-a4bb-1562a1c3c6d0.PNG?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjE0MzQyMTEsIm5iZiI6MTcyMTQzMzkxMSwicGF0aCI6Ii8yNjU2MjYwNi8yNDY2NDkxNzgtY2QxODhlOWQtYjViMy00MjUxLWE0YmItMTU2MmExYzNjNmQwLlBORz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MjAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzIwVDAwMDUxMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTVlNzBmNGFiYjdjMjQ5OGYxNmQ3MmVhNTAxMmVjYzY3NzBkNWI2MjM0NTVhNWU0NWIwYjc3MzUyODdiYTFiOTYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.meziHw-OH79I-LEBZaitonxKjzjz64bsRExdDuYJuqs)
I'm not sure this is the best solution in general, but it's a lot more portable than anything else I could think of (inline asm, compiler specific optimization
#pragmas
/attributes).