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
VideoCommon/ShaderGenCommon: Convert helper functions over to fmt where applicable #8532
Conversation
9743c99
to
90bd825
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code seems good in general, untested. Ctor remark is ignorable (since I'm pretty sure you know better)
|
|
||
| std::unique_ptr<VideoCommon::ShaderCache> g_shader_cache; | ||
|
|
||
| namespace VideoCommon | ||
| { | ||
| ShaderCache::ShaderCache() = default; | ||
| ShaderCache::ShaderCache() : m_api_type{APIType::Nothing} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feels a bit weird to go from direct member initialization and default ctor to one that's typed out just to have a forward-declared enum class in the header instead. Is this really worth it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't particularly see anything unusual about it in this case, given if anyone was concerned about the final state of the internal member variables after construction, then one would need to see what the constructor is doing anyways. I can revert this portion of the change if it's not desirable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, was mainly wondering since for the most part, the suggestion is to do the reverse (get rid of the ctor and move it to the members themselves; so it isn't forgotten if another ctor is added).
Just wanting to wrap my head around it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think in this case it's more readable to keep it in the header - it doesn't seem to remove any includes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't remove any includes in the header because the code was relying on an indirect include previously
90bd825
to
e43f9a0
Compare
|
@stenzek Whenever you have the time, can you look this over? |
e43f9a0
to
c682805
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems fine to me, apart from the constructor initialization nitpick. FifoCI also says it's fine, but doesn't test for ubershaders, so after merging we should probably quickly check those.
|
|
||
| std::unique_ptr<VideoCommon::ShaderCache> g_shader_cache; | ||
|
|
||
| namespace VideoCommon | ||
| { | ||
| ShaderCache::ShaderCache() = default; | ||
| ShaderCache::ShaderCache() : m_api_type{APIType::Nothing} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think in this case it's more readable to keep it in the header - it doesn't seem to remove any includes?
A very trivial conversion, this simply converts calls to Write over to WriteFmt and adjusts the formatting specifiers as necessary. This also allows the const char* parameters to become std::string_view instances, allowing for ease of use with other string types.
These are only ever used with ShaderCode instances and nothing else. Given that, we can convert these helper functions to expect that type of object as an argument and remove the need for templates, improving compiler throughput a marginal amount, as the template instantiation process doesn't need to be performed. We can also move the definitions of these functions into the cpp file, which allows us to remove a few inclusions from the ShaderGenCommon header. This uncovered a few instances of indirect inclusions being relied upon in other source files. One other benefit is this allows changes to be made to the definitions of the functions without needing to recompile all translation units that make use of these functions, making change testing a little quicker. Moving the definitions into the cpp file also allows us to completely hide DefineOutputMember() from external view, given it's only ever used inside of GenerateVSOutputMembers().
c682805
to
86f8768
Compare
These helper functions are fairly trivial to convert over: no fancy formatting, just simple renaming
Writeover toWriteFmtand converting formatting specifiers over to{}. This'll make it more straightforward when converting over the shader generators, sincestd::string_viewcan now be used with these functions without needing to call.data().While we're in the same area, we can also convert several template functions into normal functions, given the type of their argument is always the same type (
ShaderCode&). This allows hiding details within the translation unit, allowing changes to the implementation of the functions without needing to recompile every single shader generator translation unit. This also uncovered quite a few indirect inclusions in the process, which have also been amended.I've separated the formatting changes and the changes that migrate the template functions to regular functions to make reviewing the two changes nicer on the reader.