Skip to content
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

LightingShaderGen/VertexShaderGen: Migrate over to fmt #8981

Merged
merged 2 commits into from Oct 19, 2020

Conversation

lioncash
Copy link
Member

@lioncash lioncash commented Jul 24, 2020

Continues the fmt migration by migrating these two generators over. Both were done at the same time, since the vertex shader generator relied on some defines that the lighting shader generator used.

Copy link
Contributor

@iwubcode iwubcode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Untested

@Tilka
Copy link
Member

Tilka commented Aug 8, 2020

What's the advantage of using fmt here? Personally I find %u more obvious than {} because it shows that a number is being written.

@lioncash
Copy link
Member Author

lioncash commented Aug 9, 2020

Because it handles all types natively with one specifier. People also routinely keep getting %u and %d mixed up with types and it leads to compiler warnings. With fmt, you cannot get the specifiers wrong, because it properly handles their types. For types that cannot be printed, it will give you a compiler error instead of blindly trying to format the type anyway. It also handles C++ types out of the box like std::string and std::string_view in a straightforward manner (literally just passing the variable into the formatting call). Feel free to see the standard paper on its drawbacks.

This isn't a particularly bespoke formatting specifier choice, the syntax was borrowed from Python, Rust, and several of the .NET languages.

fmt is also on average faster than printf. It's also standardized as std::format in C++20.

@lioncash lioncash merged commit cec47b9 into dolphin-emu:master Oct 19, 2020
10 checks passed
@lioncash lioncash deleted the vtx-fmt branch October 19, 2020 11:52
@brujo5
Copy link

brujo5 commented Oct 19, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants