diff options
-rw-r--r-- | drivers/gles3/shaders/stdlib_inc.glsl | 18 | ||||
-rw-r--r-- | modules/gdscript/gdscript_vm.cpp | 5 | ||||
-rw-r--r-- | scene/2d/navigation_agent_2d.cpp | 14 | ||||
-rw-r--r-- | scene/2d/navigation_agent_2d.h | 10 | ||||
-rw-r--r-- | scene/3d/navigation_agent_3d.cpp | 12 | ||||
-rw-r--r-- | scene/3d/navigation_agent_3d.h | 12 | ||||
-rw-r--r-- | scene/resources/visual_shader_nodes.cpp | 7 | ||||
-rw-r--r-- | servers/rendering/shader_language.cpp | 8 |
8 files changed, 58 insertions, 28 deletions
diff --git a/drivers/gles3/shaders/stdlib_inc.glsl b/drivers/gles3/shaders/stdlib_inc.glsl index 8d4a24cc1f..0b76c4334a 100644 --- a/drivers/gles3/shaders/stdlib_inc.glsl +++ b/drivers/gles3/shaders/stdlib_inc.glsl @@ -2,13 +2,23 @@ #ifdef USE_GLES_OVER_GL // Floating point pack/unpack functions are part of the GLSL ES 300 specification used by web and mobile. uint float2half(uint f) { - return ((f >> uint(16)) & uint(0x8000)) | - ((((f & uint(0x7f800000)) - uint(0x38000000)) >> uint(13)) & uint(0x7c00)) | - ((f >> uint(13)) & uint(0x03ff)); + uint e = f & uint(0x7f800000); + if (e <= uint(0x38000000)) { + return uint(0); + } else { + return ((f >> uint(16)) & uint(0x8000)) | + (((e - uint(0x38000000)) >> uint(13)) & uint(0x7c00)) | + ((f >> uint(13)) & uint(0x03ff)); + } } uint half2float(uint h) { - return ((h & uint(0x8000)) << uint(16)) | (((h & uint(0x7c00)) + uint(0x1c000)) << uint(13)) | ((h & uint(0x03ff)) << uint(13)); + uint h_e = h & uint(0x7c00); + if (h_e == uint(0x0000)) { + return uint(0); + } else { + return ((h & uint(0x8000)) << uint(16)) | ((h_e + uint(0x1c000)) << uint(13)) | ((h & uint(0x03ff)) << uint(13)); + } } uint packHalf2x16(vec2 v) { diff --git a/modules/gdscript/gdscript_vm.cpp b/modules/gdscript/gdscript_vm.cpp index b99f5d2685..6c26e226a5 100644 --- a/modules/gdscript/gdscript_vm.cpp +++ b/modules/gdscript/gdscript_vm.cpp @@ -3427,7 +3427,10 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a String message_str; if (_code_ptr[ip + 2] != 0) { GET_VARIANT_PTR(message, 1); - message_str = *message; + Variant message_var = *message; + if (message->get_type() != Variant::NIL) { + message_str = message_var; + } } if (message_str.is_empty()) { err_text = "Assertion failed."; diff --git a/scene/2d/navigation_agent_2d.cpp b/scene/2d/navigation_agent_2d.cpp index 85f6840fde..6f1df7afd3 100644 --- a/scene/2d/navigation_agent_2d.cpp +++ b/scene/2d/navigation_agent_2d.cpp @@ -108,7 +108,6 @@ void NavigationAgent2D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "time_horizon", PROPERTY_HINT_RANGE, "0.1,10,0.01,suffix:s"), "set_time_horizon", "get_time_horizon"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "max_speed", PROPERTY_HINT_RANGE, "0.1,10000,0.01,suffix:px/s"), "set_max_speed", "get_max_speed"); -#ifdef DEBUG_ENABLED ClassDB::bind_method(D_METHOD("set_debug_enabled", "enabled"), &NavigationAgent2D::set_debug_enabled); ClassDB::bind_method(D_METHOD("get_debug_enabled"), &NavigationAgent2D::get_debug_enabled); ClassDB::bind_method(D_METHOD("set_debug_use_custom", "enabled"), &NavigationAgent2D::set_debug_use_custom); @@ -126,7 +125,6 @@ void NavigationAgent2D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::COLOR, "debug_path_custom_color"), "set_debug_path_custom_color", "get_debug_path_custom_color"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "debug_path_custom_point_size", PROPERTY_HINT_RANGE, "1,50,1,suffix:px"), "set_debug_path_custom_point_size", "get_debug_path_custom_point_size"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "debug_path_custom_line_width", PROPERTY_HINT_RANGE, "1,50,1,suffix:px"), "set_debug_path_custom_line_width", "get_debug_path_custom_line_width"); -#endif // DEBUG_ENABLED ADD_SIGNAL(MethodInfo("path_changed")); ADD_SIGNAL(MethodInfo("target_reached")); @@ -670,14 +668,15 @@ void NavigationAgent2D::_check_distance_to_target() { ////////DEBUG//////////////////////////////////////////////////////////// -#ifdef DEBUG_ENABLED void NavigationAgent2D::set_debug_enabled(bool p_enabled) { +#ifdef DEBUG_ENABLED if (debug_enabled == p_enabled) { return; } debug_enabled = p_enabled; debug_path_dirty = true; +#endif // DEBUG_ENABLED } bool NavigationAgent2D::get_debug_enabled() const { @@ -685,12 +684,14 @@ bool NavigationAgent2D::get_debug_enabled() const { } void NavigationAgent2D::set_debug_use_custom(bool p_enabled) { +#ifdef DEBUG_ENABLED if (debug_use_custom == p_enabled) { return; } debug_use_custom = p_enabled; debug_path_dirty = true; +#endif // DEBUG_ENABLED } bool NavigationAgent2D::get_debug_use_custom() const { @@ -698,12 +699,14 @@ bool NavigationAgent2D::get_debug_use_custom() const { } void NavigationAgent2D::set_debug_path_custom_color(Color p_color) { +#ifdef DEBUG_ENABLED if (debug_path_custom_color == p_color) { return; } debug_path_custom_color = p_color; debug_path_dirty = true; +#endif // DEBUG_ENABLED } Color NavigationAgent2D::get_debug_path_custom_color() const { @@ -711,12 +714,14 @@ Color NavigationAgent2D::get_debug_path_custom_color() const { } void NavigationAgent2D::set_debug_path_custom_point_size(float p_point_size) { +#ifdef DEBUG_ENABLED if (Math::is_equal_approx(debug_path_custom_point_size, p_point_size)) { return; } debug_path_custom_point_size = MAX(0.1, p_point_size); debug_path_dirty = true; +#endif // DEBUG_ENABLED } float NavigationAgent2D::get_debug_path_custom_point_size() const { @@ -724,18 +729,21 @@ float NavigationAgent2D::get_debug_path_custom_point_size() const { } void NavigationAgent2D::set_debug_path_custom_line_width(float p_line_width) { +#ifdef DEBUG_ENABLED if (Math::is_equal_approx(debug_path_custom_line_width, p_line_width)) { return; } debug_path_custom_line_width = p_line_width; debug_path_dirty = true; +#endif // DEBUG_ENABLED } float NavigationAgent2D::get_debug_path_custom_line_width() const { return debug_path_custom_line_width; } +#ifdef DEBUG_ENABLED void NavigationAgent2D::_navigation_debug_changed() { debug_path_dirty = true; } diff --git a/scene/2d/navigation_agent_2d.h b/scene/2d/navigation_agent_2d.h index 5278c81f66..1614c70229 100644 --- a/scene/2d/navigation_agent_2d.h +++ b/scene/2d/navigation_agent_2d.h @@ -73,14 +73,16 @@ class NavigationAgent2D : public Node { // No initialized on purpose uint32_t update_frame_id = 0; -#ifdef DEBUG_ENABLED + // Debug properties for exposed bindings bool debug_enabled = false; - bool debug_path_dirty = true; - RID debug_path_instance; float debug_path_custom_point_size = 4.0; float debug_path_custom_line_width = 1.0; bool debug_use_custom = false; Color debug_path_custom_color = Color(1.0, 1.0, 1.0, 1.0); +#ifdef DEBUG_ENABLED + // Debug properties internal only + bool debug_path_dirty = true; + RID debug_path_instance; private: void _navigation_debug_changed(); @@ -182,7 +184,6 @@ public: PackedStringArray get_configuration_warnings() const override; -#ifdef DEBUG_ENABLED void set_debug_enabled(bool p_enabled); bool get_debug_enabled() const; @@ -197,7 +198,6 @@ public: void set_debug_path_custom_line_width(float p_line_width); float get_debug_path_custom_line_width() const; -#endif // DEBUG_ENABLED private: void update_navigation(); diff --git a/scene/3d/navigation_agent_3d.cpp b/scene/3d/navigation_agent_3d.cpp index 524304425c..47c68721d4 100644 --- a/scene/3d/navigation_agent_3d.cpp +++ b/scene/3d/navigation_agent_3d.cpp @@ -121,7 +121,6 @@ void NavigationAgent3D::_bind_methods() { ADD_SIGNAL(MethodInfo("navigation_finished")); ADD_SIGNAL(MethodInfo("velocity_computed", PropertyInfo(Variant::VECTOR3, "safe_velocity"))); -#ifdef DEBUG_ENABLED ClassDB::bind_method(D_METHOD("set_debug_enabled", "enabled"), &NavigationAgent3D::set_debug_enabled); ClassDB::bind_method(D_METHOD("get_debug_enabled"), &NavigationAgent3D::get_debug_enabled); ClassDB::bind_method(D_METHOD("set_debug_use_custom", "enabled"), &NavigationAgent3D::set_debug_use_custom); @@ -136,7 +135,6 @@ void NavigationAgent3D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "debug_use_custom"), "set_debug_use_custom", "get_debug_use_custom"); ADD_PROPERTY(PropertyInfo(Variant::COLOR, "debug_path_custom_color"), "set_debug_path_custom_color", "get_debug_path_custom_color"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "debug_path_custom_point_size", PROPERTY_HINT_RANGE, "1,50,1,suffix:px"), "set_debug_path_custom_point_size", "get_debug_path_custom_point_size"); -#endif // DEBUG_ENABLED } void NavigationAgent3D::_notification(int p_what) { @@ -696,14 +694,15 @@ void NavigationAgent3D::_check_distance_to_target() { ////////DEBUG//////////////////////////////////////////////////////////// -#ifdef DEBUG_ENABLED void NavigationAgent3D::set_debug_enabled(bool p_enabled) { +#ifdef DEBUG_ENABLED if (debug_enabled == p_enabled) { return; } debug_enabled = p_enabled; debug_path_dirty = true; +#endif // DEBUG_ENABLED } bool NavigationAgent3D::get_debug_enabled() const { @@ -711,12 +710,14 @@ bool NavigationAgent3D::get_debug_enabled() const { } void NavigationAgent3D::set_debug_use_custom(bool p_enabled) { +#ifdef DEBUG_ENABLED if (debug_use_custom == p_enabled) { return; } debug_use_custom = p_enabled; debug_path_dirty = true; +#endif // DEBUG_ENABLED } bool NavigationAgent3D::get_debug_use_custom() const { @@ -724,12 +725,14 @@ bool NavigationAgent3D::get_debug_use_custom() const { } void NavigationAgent3D::set_debug_path_custom_color(Color p_color) { +#ifdef DEBUG_ENABLED if (debug_path_custom_color == p_color) { return; } debug_path_custom_color = p_color; debug_path_dirty = true; +#endif // DEBUG_ENABLED } Color NavigationAgent3D::get_debug_path_custom_color() const { @@ -737,18 +740,21 @@ Color NavigationAgent3D::get_debug_path_custom_color() const { } void NavigationAgent3D::set_debug_path_custom_point_size(float p_point_size) { +#ifdef DEBUG_ENABLED if (Math::is_equal_approx(debug_path_custom_point_size, p_point_size)) { return; } debug_path_custom_point_size = p_point_size; debug_path_dirty = true; +#endif // DEBUG_ENABLED } float NavigationAgent3D::get_debug_path_custom_point_size() const { return debug_path_custom_point_size; } +#ifdef DEBUG_ENABLED void NavigationAgent3D::_navigation_debug_changed() { debug_path_dirty = true; } diff --git a/scene/3d/navigation_agent_3d.h b/scene/3d/navigation_agent_3d.h index 209b2a0989..072ca1d3e8 100644 --- a/scene/3d/navigation_agent_3d.h +++ b/scene/3d/navigation_agent_3d.h @@ -75,14 +75,16 @@ class NavigationAgent3D : public Node { // No initialized on purpose uint32_t update_frame_id = 0; -#ifdef DEBUG_ENABLED + // Debug properties for exposed bindings bool debug_enabled = false; - bool debug_path_dirty = true; - RID debug_path_instance; - Ref<ArrayMesh> debug_path_mesh; float debug_path_custom_point_size = 4.0; bool debug_use_custom = false; Color debug_path_custom_color = Color(1.0, 1.0, 1.0, 1.0); +#ifdef DEBUG_ENABLED + // Debug properties internal only + bool debug_path_dirty = true; + RID debug_path_instance; + Ref<ArrayMesh> debug_path_mesh; Ref<StandardMaterial3D> debug_agent_path_line_custom_material; Ref<StandardMaterial3D> debug_agent_path_point_custom_material; @@ -196,7 +198,6 @@ public: PackedStringArray get_configuration_warnings() const override; -#ifdef DEBUG_ENABLED void set_debug_enabled(bool p_enabled); bool get_debug_enabled() const; @@ -208,7 +209,6 @@ public: void set_debug_path_custom_point_size(float p_point_size); float get_debug_path_custom_point_size() const; -#endif // DEBUG_ENABLED private: void update_navigation(); diff --git a/scene/resources/visual_shader_nodes.cpp b/scene/resources/visual_shader_nodes.cpp index 0695492e7f..7550f598f8 100644 --- a/scene/resources/visual_shader_nodes.cpp +++ b/scene/resources/visual_shader_nodes.cpp @@ -3349,10 +3349,10 @@ String VisualShaderNodeUVFunc::generate_code(Shader::Mode p_mode, VisualShader:: switch (func) { case FUNC_PANNING: { - code += vformat(" %s = fma(%s, %s, %s);\n", p_output_vars[0], offset_pivot, scale, uv); + code += vformat(" %s = %s * %s + %s;\n", p_output_vars[0], offset_pivot, scale, uv); } break; case FUNC_SCALING: { - code += vformat(" %s = fma((%s - %s), %s, %s);\n", p_output_vars[0], uv, offset_pivot, scale, offset_pivot); + code += vformat(" %s = (%s - %s) * %s + %s;\n", p_output_vars[0], uv, offset_pivot, scale, offset_pivot); } break; default: break; @@ -7482,6 +7482,9 @@ String VisualShaderNodeMultiplyAdd::get_output_port_name(int p_port) const { } String VisualShaderNodeMultiplyAdd::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { + if (OS::get_singleton()->get_current_rendering_method() == "gl_compatibility") { + return " " + p_output_vars[0] + " = (" + p_input_vars[0] + " * " + p_input_vars[1] + ") + " + p_input_vars[2] + ";\n"; + } return " " + p_output_vars[0] + " = fma(" + p_input_vars[0] + ", " + p_input_vars[1] + ", " + p_input_vars[2] + ");\n"; } diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp index 2dc1c70064..e9c13f88ca 100644 --- a/servers/rendering/shader_language.cpp +++ b/servers/rendering/shader_language.cpp @@ -2901,10 +2901,10 @@ const ShaderLanguage::BuiltinFuncDef ShaderLanguage::builtin_func_defs[] = { // Modern functions. // fma - { "fma", TYPE_FLOAT, { TYPE_FLOAT, TYPE_FLOAT, TYPE_FLOAT, TYPE_VOID }, { "a", "b", "c" }, TAG_GLOBAL, false }, - { "fma", TYPE_VEC2, { TYPE_VEC2, TYPE_VEC2, TYPE_VEC2, TYPE_VOID }, { "a", "b", "c" }, TAG_GLOBAL, false }, - { "fma", TYPE_VEC3, { TYPE_VEC3, TYPE_VEC3, TYPE_VEC3, TYPE_VOID }, { "a", "b", "c" }, TAG_GLOBAL, false }, - { "fma", TYPE_VEC4, { TYPE_VEC4, TYPE_VEC4, TYPE_VEC4, TYPE_VOID }, { "a", "b", "c" }, TAG_GLOBAL, false }, + { "fma", TYPE_FLOAT, { TYPE_FLOAT, TYPE_FLOAT, TYPE_FLOAT, TYPE_VOID }, { "a", "b", "c" }, TAG_GLOBAL, true }, + { "fma", TYPE_VEC2, { TYPE_VEC2, TYPE_VEC2, TYPE_VEC2, TYPE_VOID }, { "a", "b", "c" }, TAG_GLOBAL, true }, + { "fma", TYPE_VEC3, { TYPE_VEC3, TYPE_VEC3, TYPE_VEC3, TYPE_VOID }, { "a", "b", "c" }, TAG_GLOBAL, true }, + { "fma", TYPE_VEC4, { TYPE_VEC4, TYPE_VEC4, TYPE_VEC4, TYPE_VOID }, { "a", "b", "c" }, TAG_GLOBAL, true }, // Packing/Unpacking functions. |