-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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
Tweak shader compilation error messages #95495
base: master
Are you sure you want to change the base?
Tweak shader compilation error messages #95495
Conversation
drivers/gles3/shader_gles3.cpp
Outdated
@@ -716,7 +716,7 @@ void ShaderGLES3::_initialize_version(Version *p_version) { | |||
|
|||
void ShaderGLES3::version_set_code(RID p_version, const HashMap<String, String> &p_code, const String &p_uniforms, const String &p_vertex_globals, const String &p_fragment_globals, const Vector<String> &p_custom_defines, const LocalVector<ShaderGLES3::TextureUniformData> &p_texture_uniforms, bool p_initialize) { | |||
Version *version = version_owner.get_or_null(p_version); | |||
ERR_FAIL_NULL(version); | |||
ERR_FAIL_NULL_MSG(version, "Shader compilation failed (most likely due to a syntax error). Shader code has been printed above for troubleshooting."); |
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 think this is correct. I can't find any code path where this would be reached with a null version
due to failing to compile. If compilation fails, the engine won't attempt to set the code on the version.
The error in the bug report comes from version_get_shader()
ERR_FAIL_NULL_V(version, RID()); |
It happens when you try to use a shader that previously failed compilation
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've changed the message accordingly for version_set_code()
in all rendering methods. Not sure if we can make it much more specific than what I put:
Can't use a shader that previously failed compilation.
6c6a7d5
to
7ee15df
Compare
7ee15df
to
4b6fded
Compare
@@ -167,7 +167,7 @@ class ShaderRD { | |||
ERR_FAIL_COND_V(!variants_enabled[p_variant], RID()); | |||
|
|||
Version *version = version_owner.get_or_null(p_version); | |||
ERR_FAIL_NULL_V(version, RID()); | |||
ERR_FAIL_NULL_V_MSG(version, RID(), "Shader compilation failed (most likely due to a syntax error). Shader code has been printed nearby for troubleshooting."); |
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 has the same problem as before. This isn't a shader compilation error.
@@ -651,7 +651,7 @@ void ShaderRD::version_set_compute_code(RID p_version, const HashMap<String, Str | |||
ERR_FAIL_COND(!is_compute); | |||
|
|||
Version *version = version_owner.get_or_null(p_version); | |||
ERR_FAIL_NULL(version); | |||
ERR_FAIL_NULL_MSG(version, "Compute shader compilation failed (most likely due to a syntax error). Shader code has been printed nearby for troubleshooting."); |
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.
Same as above. This isn't a compilation error
@@ -616,7 +616,7 @@ void ShaderRD::version_set_code(RID p_version, const HashMap<String, String> &p_ | |||
ERR_FAIL_COND(is_compute); | |||
|
|||
Version *version = version_owner.get_or_null(p_version); | |||
ERR_FAIL_NULL(version); | |||
ERR_FAIL_NULL_MSG(version, "Can't use a shader that previously failed compilation."); |
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.
As per my last review, this isn't a compile error. Failing to compile is just one reason why this case may be hit. The message is misleading
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've reworded all 3 messages somewhat. The concept of "shader version" isn't something that is obvious to most users though (unless you look at the native shader source inspector), so I'm not sure how we could clarify 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.
Ideally this is an error that users would never see. It's meant to be totally internal
7eef8a9
to
a3e1672
Compare
- Mention the shader type that failed compilation. - Mention the most common cause for this error (which are syntax errors). - Mention that the shader code is printed nearby for troubleshooting.
a3e1672
to
90d6b1c
Compare
and Visual shader plugin complains about missing version and category #95443.
Testing project: test_shader_error.zip
Preview
Note
ERROR: not enough arguments for format string
is not introduced by this PR; it also occurs inmaster
with the MRPand is likely due to a script error in that MRP (check line 142 of
VSSimplexNoise3D.gd
,%
arguments are missing).Forward+
Mobile
Compatibility