Skip to content

Commit a2f2699

Browse files
committed
Restrict sampler hint validation to only screen texture hints
1 parent 88d9325 commit a2f2699

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

servers/rendering/shader_language.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4761,6 +4761,15 @@ bool ShaderLanguage::_validate_assign(Node *p_node, const FunctionInfo &p_functi
47614761
return false;
47624762
}
47634763

4764+
ShaderLanguage::ShaderNode::Uniform::Hint ShaderLanguage::_sanitize_hint(ShaderNode::Uniform::Hint p_hint) {
4765+
if (p_hint == ShaderNode::Uniform::HINT_SCREEN_TEXTURE ||
4766+
p_hint == ShaderNode::Uniform::HINT_NORMAL_ROUGHNESS_TEXTURE ||
4767+
p_hint == ShaderNode::Uniform::HINT_DEPTH_TEXTURE) {
4768+
return p_hint;
4769+
}
4770+
return ShaderNode::Uniform::HINT_NONE;
4771+
}
4772+
47644773
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) {
47654774
for (int i = 0; i < shader->vfunctions.size(); i++) {
47664775
if (shader->vfunctions[i].name == p_name) {
@@ -4771,7 +4780,7 @@ bool ShaderLanguage::_propagate_function_call_sampler_uniform_settings(const Str
47714780
return false;
47724781
} else if (arg->tex_argument_check) {
47734782
// Was checked, verify that filter, repeat, and hint are the same.
4774-
if (arg->tex_argument_filter == p_filter && arg->tex_argument_repeat == p_repeat && arg->tex_hint == p_hint) {
4783+
if (arg->tex_argument_filter == p_filter && arg->tex_argument_repeat == p_repeat && arg->tex_hint == _sanitize_hint(p_hint)) {
47754784
return true;
47764785
} else {
47774786
_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
47814790
arg->tex_argument_check = true;
47824791
arg->tex_argument_filter = p_filter;
47834792
arg->tex_argument_repeat = p_repeat;
4784-
arg->tex_hint = p_hint;
4793+
arg->tex_hint = _sanitize_hint(p_hint);
47854794
for (KeyValue<StringName, HashSet<int>> &E : arg->tex_argument_connect) {
47864795
for (const int &F : E.value) {
47874796
if (!_propagate_function_call_sampler_uniform_settings(E.key, F, p_filter, p_repeat, p_hint)) {

servers/rendering/shader_language.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,6 +1123,7 @@ class ShaderLanguage {
11231123

11241124
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);
11251125
bool _parse_function_arguments(BlockNode *p_block, const FunctionInfo &p_function_info, OperatorNode *p_func, int *r_complete_arg = nullptr);
1126+
ShaderNode::Uniform::Hint _sanitize_hint(ShaderNode::Uniform::Hint p_hint);
11261127
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);
11271128
bool _propagate_function_call_sampler_builtin_reference(const StringName &p_name, int p_argument, const StringName &p_builtin);
11281129
bool _validate_varying_assign(ShaderNode::Varying &p_varying, String *r_message);

0 commit comments

Comments
 (0)