X Tutup
Skip to content

Remove transitive rendering includes from node.h#111405

Merged
Repiteo merged 1 commit intogodotengine:masterfrom
Ivorforce:node-no-mesh
Oct 9, 2025
Merged

Remove transitive rendering includes from node.h#111405
Repiteo merged 1 commit intogodotengine:masterfrom
Ivorforce:node-no-mesh

Conversation

@Ivorforce
Copy link
Member

@Ivorforce Ivorforce commented Oct 8, 2025

This PR reduces total compile time by 3% (going by a single test). Further, it will benefit rendering contributors because changes to rendering files will no longer cause a recompilation of almost all compile units.

Explanation

node.h is a giant include hub. Most of our compile units include it in some way.
It currently has an include path to rendering (mesh.h, shader.h, rendering_server.h). However, most Node users don't interact with rendering at all.

This PR removes this include path (by removing the mesh.h include scene_tree.h), simply by forward-declaring ArrayMesh.

The cascading changes are individually simple and logical:

  • Explicit includes in headers to previously transitively included headers.
  • Explicit includes to mesh.h in cpp files that have meshes of their own.
  • Forward declarations of other mesh types in headers that only use them internally.

Further, I'm making use of STATIC_ASSERT_INCOMPLETE_TYPE to prevent regression of this PR.

@Ivorforce Ivorforce requested review from a team as code owners October 8, 2025 10:10
@Ivorforce Ivorforce requested a review from a team October 8, 2025 10:10
@Ivorforce Ivorforce requested review from a team October 8, 2025 10:10
@Ivorforce Ivorforce requested review from a team and removed request for a team October 8, 2025 10:13
@Ivorforce Ivorforce added this to the 4.x milestone Oct 8, 2025

#undef Window

class ArrayMesh;
Copy link
Member

Choose a reason for hiding this comment

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

Worth noting that this is the main fix, not changes to node.h.

Should scene_tree.cpp also have the STATIC_ASSERT_INCOMPLETE_TYPE calls?

Copy link
Member Author

@Ivorforce Ivorforce Oct 9, 2025

Choose a reason for hiding this comment

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

I considered it, but didn't add them since scene_tree.cpp isn't the "main include hub", but node.h is. So it's more important that node.h doesn't regress. But I'm happy to add it if you think we should.

Copy link
Member

Choose a reason for hiding this comment

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

I guess it's fine as is, scene_tree.h doesn't seem to be included much explicitly outside node.h and main/platform entry points.

Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

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

That's a great improvement!

@akien-mga akien-mga modified the milestones: 4.x, 4.6 Oct 9, 2025
@Repiteo Repiteo merged commit 4ab2202 into godotengine:master Oct 9, 2025
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Oct 9, 2025

Thanks!

@Ivorforce Ivorforce deleted the node-no-mesh branch October 9, 2025 17:00
@AThousandShips
Copy link
Member

AThousandShips commented Oct 10, 2025

This broke debug builds again 🙃 making a fix

I think for any future reworks like they have to be built with debug builds to ensure they are actually not breaking them as we don't have debug templates break, unsure if it's 3D-disable related specifically (just testing one template) but we are getting at least one regression a week right now so some higher due diligence is really needed

@Ivorforce
Copy link
Member Author

@AThousandShips Agreed, and sorry. I'm currently only making dev builds for these PRs. I'll start making debug and release builds for future include change PRs.

@AThousandShips
Copy link
Member

Thank you! It seems to be specifically the 2D only build as some of the 3D includes have transitive includes

It all works out, and I think I was just a bit frustrated at the lack of checks in CI getting in the way, but for major restructures it'd be appreciated testing some specific things to avoid errors

As I build these regularly I can also see about building some things locally if people need and don't have things cached!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

X Tutup