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

Define shader language project settings before creation of TextShaderEditor object. #73588

Conversation

smosages
Copy link
Contributor

@smosages smosages commented Feb 19, 2023

Fix #73336

Preamble: this is my first contribution. From the description and the comment from @Calinou , I have moved the GLOBAL_DEF for shader_language settings into the ProjectSettings contstructor.

@smosages smosages requested review from a team as code owners February 19, 2023 14:46
@Chaosus Chaosus changed the title #73336: Define shader language project settings before creation of TextShaderEditor object Define shader language project settings before creation of TextShaderEditor object. Feb 19, 2023
@Chaosus Chaosus added this to the 4.x milestone Feb 19, 2023
Copy link
Member

@clayjohn clayjohn left a comment

Choose a reason for hiding this comment

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

Looks like you are getting a few errors connected to ShaderWarning not being available. Note that ShaderWarning is only defined when DEBUG_ENABLED is defined (i.e. in editor builds). So any code referencing it outside of editor classes needs to be wrapped in an #ifdef DEBUG_ENABLED conditional.

Further, core classes like ProjectSettings should not rely on non-core code like shader_warnings.cpp. The definitions, should likely be moved to rendering_server.cpp

void RenderingServer::init() {

@smosages
Copy link
Contributor Author

thanks. I've moved these definitions into rendering_servers. Why is this the right place for them? It's necessary to wrap ShaderWarning in an #ifdef in rendering_server.cpp? I don't see any other definitions in rendering_server.cpp using #ifdef DEBUG_ENABLED. Why is that?

@smosages
Copy link
Contributor Author

@clayjohn , this? or wrap all GLOBAL_DEF inside DEBUG_ENABLED?

void RenderingServer::init() {
        ...
        ...
	GLOBAL_DEF("debug/shader_language/warnings/enable", true);
	GLOBAL_DEF("debug/shader_language/warnings/treat_warnings_as_errors", false);

#ifdef DEBUG_ENABLED
	for (int i = 0; i < (int)ShaderWarning::WARNING_MAX; i++) {
		GLOBAL_DEF("debug/shader_language/warnings/" + ShaderWarning::get_name_from_code((ShaderWarning::Code)i).to_lower(), true);
	}
#endif
}

@clayjohn
Copy link
Member

thanks. I've moved these definitions into rendering_servers. Why is this the right place for them?

Its a class that is always initialized and it allows you to keep rendering server features within the rendering_server. We have a chain of allowed dependencies that goes like this Core < Servers < Scene < Editor. You can include stuff from the left but not the right. So anything can depend on Core, but core shouldn't depend on servers, scene, or editor.

The ShaderWarnings class is in Servers, so it shouldn't be referenced in Core, but it is okay to be referenced in rendering_server.

It's necessary to wrap ShaderWarning in an #ifdef in rendering_server.cpp? I don't see any other definitions in rendering_server.cpp using #ifdef DEBUG_ENABLED. Why is that?

None of the other definitions rely on a class that is conditionally compiled. The issue here is that ShaderWarning is only compiled when DEBUG_ENABLED is defined. before it was okay without the #ifdef because the code was in the editor (which is always wrapped in #ifdef DEBUG_ENABLED)

@clayjohn , this? or wrap all GLOBAL_DEF inside DEBUG_ENABLED?

void RenderingServer::init() {
        ...
        ...
	GLOBAL_DEF("debug/shader_language/warnings/enable", true);
	GLOBAL_DEF("debug/shader_language/warnings/treat_warnings_as_errors", false);

#ifdef DEBUG_ENABLED
	for (int i = 0; i < (int)ShaderWarning::WARNING_MAX; i++) {
		GLOBAL_DEF("debug/shader_language/warnings/" + ShaderWarning::get_name_from_code((ShaderWarning::Code)i).to_lower(), true);
	}
#endif
}

This looks fine. You just need it around the sections referencing ShaderWarning

@smosages smosages requested a review from a team as a code owner February 23, 2023 09:58
@clayjohn clayjohn modified the milestones: 4.x, 4.1 Feb 23, 2023
Copy link
Member

@clayjohn clayjohn left a comment

Choose a reason for hiding this comment

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

Just some comments on formatting changes

editor/plugins/text_shader_editor.cpp Outdated Show resolved Hide resolved
editor/plugins/text_shader_editor.cpp Outdated Show resolved Hide resolved
@clayjohn
Copy link
Member

Looks great! The final step before merging is to squash all the commits together so that the whole PR only contains 1 big commit with all your changes. We like to merge one commit at a time to keep the git history clean and navigable.

If you don't know how to do that, we have a helpful tutorial in the official documentation https://docs.godotengine.org/en/latest/community/contributing/pr_workflow.html#the-interactive-rebase

@smosages smosages force-pushed the resolve-display-shader-settings-in-settings-editor branch from 1601a49 to 786ad51 Compare February 25, 2023 11:15
@brno32
Copy link
Contributor

brno32 commented May 2, 2023

@clayjohn the commits are squashed. Can this be merged?

Copy link
Member

@clayjohn clayjohn left a comment

Choose a reason for hiding this comment

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

Looks great now! Sorry for the slow re-review

@akien-mga akien-mga merged commit de14109 into godotengine:master May 9, 2023
@akien-mga
Copy link
Member

akien-mga commented May 9, 2023

Thanks! And congrats for your first merged Godot contribution 🎉

@AThousandShips
Copy link
Member

This appears to break CI

@AThousandShips
Copy link
Member

Making a fix

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.

Shader project settings not showing until shader editor is open
6 participants