-
Notifications
You must be signed in to change notification settings - Fork 402
Separate Shader Generation Exception header #2563
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
base: main
Are you sure you want to change the base?
Separate Shader Generation Exception header #2563
Conversation
287da78
to
066bc88
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.
This looks like a good proposal to me, thanks @ld-kerley, and I had just minor notes about maintaining existing conventions for include order.
…uces the dependency on the shader generator module.
c46de36
to
3b1e55e
Compare
I think changing .clang-format from
to
would perform the sorting that I think you're outlining. I also think it would be really helpful if these coding conventions were either enforced rigorously by clang-format or that they were documented somewhere. |
IndentWidth: 4 | ||
LambdaBodyIndentation: OuterScope | ||
PointerAlignment: Left | ||
SortIncludes: false |
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'd probably recommend against changing this line in clang-format
, as I've run into cases where it will have unintended side effects that affect compilation.
Here's one example from MaterialXFormat/File.cpp
, where the current include order correctly places windows.h
and unistd.h
first in their respective blocks:
#if defined(_WIN32)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <direct.h>
#else
#include <unistd.h>
#include <sys/stat.h>
#include <dirent.h>
#endif
But with SortIncludes
set to true
, this gets reformatted to the following:
#if defined(_WIN32)
#define WIN32_LEAN_AND_MEAN
#include <direct.h>
#include <windows.h>
#else
#include <dirent.h>
#include <sys/stat.h>
#include <unistd.h>
#endif
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 would still like to find a path forwards to being able to use clang-format. A lot of reviews get hung up on formatting issues that could be avoided if we could use the tools to enforce the formatting. As well as if we use a formatting tool, it makes rebasing really old branches a LOT easier.
for cases like this - we could easily wrap the section of includes - or any other small part of the code - we don't want auto-formatted in the comments that disable the formatter.
// clang-format off
<code that is not reformatted>
// clang-format on
This would theoretically give us the best of both worlds.
Create separate header for the shader generation exception. This reduces the dependency on the shader generator header.
Note - the exception header is still included in the main shader generation header for backwards compatibility