diff options
author | clayjohn <claynjohn@gmail.com> | 2024-07-28 22:31:57 -0700 |
---|---|---|
committer | clayjohn <claynjohn@gmail.com> | 2024-07-28 22:31:57 -0700 |
commit | a2f2699208175db1599ba85858e20b4a2a4d6bfd (patch) | |
tree | 4be98434b29a831d91c27b240b1d9886e0bcbc00 | |
parent | 88d9325065a3e00e9e168ffad4ff93e12455a357 (diff) | |
download | redot-engine-a2f2699208175db1599ba85858e20b4a2a4d6bfd.tar.gz |
Restrict sampler hint validation to only screen texture hints
-rw-r--r-- | servers/rendering/shader_language.cpp | 13 | ||||
-rw-r--r-- | servers/rendering/shader_language.h | 1 |
2 files changed, 12 insertions, 2 deletions
diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp index 10c1158d95..0235d72cfa 100644 --- a/servers/rendering/shader_language.cpp +++ b/servers/rendering/shader_language.cpp @@ -4761,6 +4761,15 @@ bool ShaderLanguage::_validate_assign(Node *p_node, const FunctionInfo &p_functi return false; } +ShaderLanguage::ShaderNode::Uniform::Hint ShaderLanguage::_sanitize_hint(ShaderNode::Uniform::Hint p_hint) { + if (p_hint == ShaderNode::Uniform::HINT_SCREEN_TEXTURE || + p_hint == ShaderNode::Uniform::HINT_NORMAL_ROUGHNESS_TEXTURE || + p_hint == ShaderNode::Uniform::HINT_DEPTH_TEXTURE) { + return p_hint; + } + return ShaderNode::Uniform::HINT_NONE; +} + bool ShaderLanguage::_propagate_function_call_sampler_uniform_settings(const StringName &p_name, int p_argument, TextureFilter p_filter, TextureRepeat p_repeat, ShaderNode::Uniform::Hint p_hint) { for (int i = 0; i < shader->vfunctions.size(); i++) { if (shader->vfunctions[i].name == p_name) { @@ -4771,7 +4780,7 @@ bool ShaderLanguage::_propagate_function_call_sampler_uniform_settings(const Str return false; } else if (arg->tex_argument_check) { // Was checked, verify that filter, repeat, and hint are the same. - if (arg->tex_argument_filter == p_filter && arg->tex_argument_repeat == p_repeat && arg->tex_hint == p_hint) { + if (arg->tex_argument_filter == p_filter && arg->tex_argument_repeat == p_repeat && arg->tex_hint == _sanitize_hint(p_hint)) { return true; } else { _set_error(vformat(RTR("Sampler argument %d of function '%s' called more than once using textures that differ in either filter, repeat, or texture hint setting."), p_argument, String(p_name))); @@ -4781,7 +4790,7 @@ bool ShaderLanguage::_propagate_function_call_sampler_uniform_settings(const Str arg->tex_argument_check = true; arg->tex_argument_filter = p_filter; arg->tex_argument_repeat = p_repeat; - arg->tex_hint = p_hint; + arg->tex_hint = _sanitize_hint(p_hint); for (KeyValue<StringName, HashSet<int>> &E : arg->tex_argument_connect) { for (const int &F : E.value) { if (!_propagate_function_call_sampler_uniform_settings(E.key, F, p_filter, p_repeat, p_hint)) { diff --git a/servers/rendering/shader_language.h b/servers/rendering/shader_language.h index 40f524ec9d..4a67c8f2d2 100644 --- a/servers/rendering/shader_language.h +++ b/servers/rendering/shader_language.h @@ -1123,6 +1123,7 @@ private: bool _validate_function_call(BlockNode *p_block, const FunctionInfo &p_function_info, OperatorNode *p_func, DataType *r_ret_type, StringName *r_ret_type_str, bool *r_is_custom_function = nullptr); bool _parse_function_arguments(BlockNode *p_block, const FunctionInfo &p_function_info, OperatorNode *p_func, int *r_complete_arg = nullptr); + ShaderNode::Uniform::Hint _sanitize_hint(ShaderNode::Uniform::Hint p_hint); bool _propagate_function_call_sampler_uniform_settings(const StringName &p_name, int p_argument, TextureFilter p_filter, TextureRepeat p_repeat, ShaderNode::Uniform::Hint p_hint); bool _propagate_function_call_sampler_builtin_reference(const StringName &p_name, int p_argument, const StringName &p_builtin); bool _validate_varying_assign(ShaderNode::Varying &p_varying, String *r_message); |