Skip to content

Conversation

ld-kerley
Copy link
Contributor

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

@ld-kerley ld-kerley force-pushed the shadergen/separate-exception-header branch from 287da78 to 066bc88 Compare September 17, 2025 00:48
Copy link
Member

@jstone-lucasfilm jstone-lucasfilm left a 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.

@ld-kerley ld-kerley force-pushed the shadergen/separate-exception-header branch from c46de36 to 3b1e55e Compare September 18, 2025 15:39
@ld-kerley
Copy link
Contributor Author

I think changing .clang-format from

SortIncludes: false

to

SortIncludes: CaseSensitive
IncludeBlocks: Preserve

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
Copy link
Member

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

Copy link
Contributor Author

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.

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

Successfully merging this pull request may close these issues.

2 participants