From c1547d1337096c89c28fb93eaa4f2bb9293ae044 Mon Sep 17 00:00:00 2001 From: Jakub Marcowski <01158831@pw.edu.pl> Date: Tue, 6 Feb 2024 14:37:29 +0100 Subject: [PATCH 1/8] Fully initialize all members of structs `IdentifierActions`, `GeneratedCode` and `DefaultIdentifierActions` (cherry picked from commit b38ac30fe09eec4de40ffd19d7c8a64363b6c181) --- servers/rendering/shader_compiler.h | 34 ++++++++++++++--------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/servers/rendering/shader_compiler.h b/servers/rendering/shader_compiler.h index 2d58be72616f..e0ec42a4d117 100644 --- a/servers/rendering/shader_compiler.h +++ b/servers/rendering/shader_compiler.h @@ -52,38 +52,38 @@ class ShaderCompiler { HashMap usage_flag_pointers; HashMap write_flag_pointers; - HashMap *uniforms; + HashMap *uniforms = nullptr; }; struct GeneratedCode { Vector defines; struct Texture { StringName name; - ShaderLanguage::DataType type; - ShaderLanguage::ShaderNode::Uniform::Hint hint; + ShaderLanguage::DataType type = ShaderLanguage::DataType::TYPE_VOID; + ShaderLanguage::ShaderNode::Uniform::Hint hint = ShaderLanguage::ShaderNode::Uniform::Hint::HINT_NONE; bool use_color = false; - ShaderLanguage::TextureFilter filter; - ShaderLanguage::TextureRepeat repeat; - bool global; - int array_size; + ShaderLanguage::TextureFilter filter = ShaderLanguage::TextureFilter::FILTER_DEFAULT; + ShaderLanguage::TextureRepeat repeat = ShaderLanguage::TextureRepeat::REPEAT_DEFAULT; + bool global = false; + int array_size = 0; }; Vector texture_uniforms; Vector uniform_offsets; - uint32_t uniform_total_size; + uint32_t uniform_total_size = 0; String uniforms; String stage_globals[STAGE_MAX]; HashMap code; - bool uses_global_textures; - bool uses_fragment_time; - bool uses_vertex_time; - bool uses_screen_texture_mipmaps; - bool uses_screen_texture; - bool uses_depth_texture; - bool uses_normal_roughness_texture; + bool uses_global_textures = false; + bool uses_fragment_time = false; + bool uses_vertex_time = false; + bool uses_screen_texture_mipmaps = false; + bool uses_screen_texture = false; + bool uses_depth_texture = false; + bool uses_normal_roughness_texture = false; }; struct DefaultIdentifierActions { @@ -91,8 +91,8 @@ class ShaderCompiler { HashMap render_mode_defines; HashMap usage_defines; HashMap custom_samplers; - ShaderLanguage::TextureFilter default_filter; - ShaderLanguage::TextureRepeat default_repeat; + ShaderLanguage::TextureFilter default_filter = ShaderLanguage::TextureFilter::FILTER_DEFAULT; + ShaderLanguage::TextureRepeat default_repeat = ShaderLanguage::TextureRepeat::REPEAT_DEFAULT; int base_texture_binding_index = 0; int texture_layout_set = 0; String base_uniform_string; From 79b7dc7f943c6a5dad4d24bafc2a203daf5831fa Mon Sep 17 00:00:00 2001 From: jsjtxietian Date: Thu, 29 Feb 2024 11:01:56 +0800 Subject: [PATCH 2/8] Change shader compiler default setting to avoid doctool error (cherry picked from commit 0ed341cd1e5c9cd3feb4a812946f8a2f06f92a0f) --- servers/rendering/shader_compiler.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/servers/rendering/shader_compiler.h b/servers/rendering/shader_compiler.h index e0ec42a4d117..66106d7eb734 100644 --- a/servers/rendering/shader_compiler.h +++ b/servers/rendering/shader_compiler.h @@ -91,8 +91,8 @@ class ShaderCompiler { HashMap render_mode_defines; HashMap usage_defines; HashMap custom_samplers; - ShaderLanguage::TextureFilter default_filter = ShaderLanguage::TextureFilter::FILTER_DEFAULT; - ShaderLanguage::TextureRepeat default_repeat = ShaderLanguage::TextureRepeat::REPEAT_DEFAULT; + ShaderLanguage::TextureFilter default_filter = ShaderLanguage::TextureFilter::FILTER_NEAREST; + ShaderLanguage::TextureRepeat default_repeat = ShaderLanguage::TextureRepeat::REPEAT_DISABLE; int base_texture_binding_index = 0; int texture_layout_set = 0; String base_uniform_string; From 7eb90a35d472f76bdeead1bfcb41256d50b6aff2 Mon Sep 17 00:00:00 2001 From: jsjtxietian Date: Tue, 20 Feb 2024 12:01:05 +0800 Subject: [PATCH 3/8] Fail early if shader mode is invalid in dummy renderer (cherry picked from commit a382e9539b328f02a1f553a36a4c74457a7aa591) --- servers/rendering/dummy/storage/material_storage.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/servers/rendering/dummy/storage/material_storage.cpp b/servers/rendering/dummy/storage/material_storage.cpp index 5a2c135ff541..64f6b55172cb 100644 --- a/servers/rendering/dummy/storage/material_storage.cpp +++ b/servers/rendering/dummy/storage/material_storage.cpp @@ -81,6 +81,7 @@ void MaterialStorage::shader_set_code(RID p_shader, const String &p_code) { new_mode = RS::SHADER_FOG; } else { new_mode = RS::SHADER_MAX; + ERR_FAIL_MSG("Shader type " + mode_string + " not supported in Dummy renderer."); } ShaderCompiler::IdentifierActions actions; actions.uniforms = &shader->uniforms; From a7c4d3bc08cb57ebe5654d942904be7bd95382bf Mon Sep 17 00:00:00 2001 From: clayjohn Date: Fri, 19 Jan 2024 17:21:55 -0800 Subject: [PATCH 4/8] Add basic multimesh data needed for headless export to the Dummy rendering server (cherry picked from commit ed2b3d358d3883b98f741cbfc1ca3d7aa4fcbb7b) --- .../rendering/dummy/storage/mesh_storage.cpp | 30 +++++++++++++++++++ .../rendering/dummy/storage/mesh_storage.h | 16 ++++++---- 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/servers/rendering/dummy/storage/mesh_storage.cpp b/servers/rendering/dummy/storage/mesh_storage.cpp index ab27711d6e1d..0b7ade176287 100644 --- a/servers/rendering/dummy/storage/mesh_storage.cpp +++ b/servers/rendering/dummy/storage/mesh_storage.cpp @@ -63,3 +63,33 @@ void MeshStorage::mesh_clear(RID p_mesh) { m->surfaces.clear(); } + +RID MeshStorage::multimesh_allocate() { + return multimesh_owner.allocate_rid(); +} + +void MeshStorage::multimesh_initialize(RID p_rid) { + multimesh_owner.initialize_rid(p_rid, DummyMultiMesh()); +} + +void MeshStorage::multimesh_free(RID p_rid) { + DummyMultiMesh *multimesh = multimesh_owner.get_or_null(p_rid); + ERR_FAIL_NULL(multimesh); + + multimesh_owner.free(p_rid); +} + +void MeshStorage::multimesh_set_buffer(RID p_multimesh, const Vector &p_buffer) { + DummyMultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh); + ERR_FAIL_NULL(multimesh); + multimesh->buffer.resize(p_buffer.size()); + float *cache_data = multimesh->buffer.ptrw(); + memcpy(cache_data, p_buffer.ptr(), p_buffer.size() * sizeof(float)); +} + +Vector MeshStorage::multimesh_get_buffer(RID p_multimesh) const { + DummyMultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh); + ERR_FAIL_NULL_V(multimesh, Vector()); + + return multimesh->buffer; +} diff --git a/servers/rendering/dummy/storage/mesh_storage.h b/servers/rendering/dummy/storage/mesh_storage.h index d287a1c3874b..a7351655bd7b 100644 --- a/servers/rendering/dummy/storage/mesh_storage.h +++ b/servers/rendering/dummy/storage/mesh_storage.h @@ -50,6 +50,12 @@ class MeshStorage : public RendererMeshStorage { mutable RID_Owner mesh_owner; + struct DummyMultiMesh { + PackedFloat32Array buffer; + }; + + mutable RID_Owner multimesh_owner; + public: static MeshStorage *get_singleton() { return singleton; } @@ -132,9 +138,9 @@ class MeshStorage : public RendererMeshStorage { /* MULTIMESH API */ - virtual RID multimesh_allocate() override { return RID(); } - virtual void multimesh_initialize(RID p_rid) override {} - virtual void multimesh_free(RID p_rid) override {} + virtual RID multimesh_allocate() override; + virtual void multimesh_initialize(RID p_rid) override; + virtual void multimesh_free(RID p_rid) override; virtual void multimesh_allocate_data(RID p_multimesh, int p_instances, RS::MultimeshTransformFormat p_transform_format, bool p_use_colors = false, bool p_use_custom_data = false) override {} virtual int multimesh_get_instance_count(RID p_multimesh) const override { return 0; } @@ -152,8 +158,8 @@ class MeshStorage : public RendererMeshStorage { virtual Transform2D multimesh_instance_get_transform_2d(RID p_multimesh, int p_index) const override { return Transform2D(); } virtual Color multimesh_instance_get_color(RID p_multimesh, int p_index) const override { return Color(); } virtual Color multimesh_instance_get_custom_data(RID p_multimesh, int p_index) const override { return Color(); } - virtual void multimesh_set_buffer(RID p_multimesh, const Vector &p_buffer) override {} - virtual Vector multimesh_get_buffer(RID p_multimesh) const override { return Vector(); } + virtual void multimesh_set_buffer(RID p_multimesh, const Vector &p_buffer) override; + virtual Vector multimesh_get_buffer(RID p_multimesh) const override; virtual void multimesh_set_visible_instances(RID p_multimesh, int p_visible) override {} virtual int multimesh_get_visible_instances(RID p_multimesh) const override { return 0; } From a7099ce88013c0dbf12c49e82b4cb070a12d5f21 Mon Sep 17 00:00:00 2001 From: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> Date: Mon, 29 Jan 2024 18:48:47 +0100 Subject: [PATCH 5/8] Free dummy renderer objects These leaked during tests etc. (cherry picked from commit 666daf47c31307c50a9f0eb08fc5146d0a3e5f32) --- servers/rendering/dummy/storage/material_storage.h | 2 ++ servers/rendering/dummy/storage/mesh_storage.h | 2 ++ servers/rendering/dummy/storage/utilities.h | 7 +++++++ 3 files changed, 11 insertions(+) diff --git a/servers/rendering/dummy/storage/material_storage.h b/servers/rendering/dummy/storage/material_storage.h index dc2babc0e2e0..957fb1fc435e 100644 --- a/servers/rendering/dummy/storage/material_storage.h +++ b/servers/rendering/dummy/storage/material_storage.h @@ -77,6 +77,8 @@ class MaterialStorage : public RendererMaterialStorage { /* SHADER API */ + bool owns_shader(RID p_rid) { return shader_owner.owns(p_rid); } + virtual RID shader_allocate() override; virtual void shader_initialize(RID p_rid) override; virtual void shader_free(RID p_rid) override; diff --git a/servers/rendering/dummy/storage/mesh_storage.h b/servers/rendering/dummy/storage/mesh_storage.h index a7351655bd7b..ce0e80e8c8fe 100644 --- a/servers/rendering/dummy/storage/mesh_storage.h +++ b/servers/rendering/dummy/storage/mesh_storage.h @@ -138,6 +138,8 @@ class MeshStorage : public RendererMeshStorage { /* MULTIMESH API */ + bool owns_multimesh(RID p_rid) { return multimesh_owner.owns(p_rid); } + virtual RID multimesh_allocate() override; virtual void multimesh_initialize(RID p_rid) override; virtual void multimesh_free(RID p_rid) override; diff --git a/servers/rendering/dummy/storage/utilities.h b/servers/rendering/dummy/storage/utilities.h index 72327fbf4df4..2497451fdc93 100644 --- a/servers/rendering/dummy/storage/utilities.h +++ b/servers/rendering/dummy/storage/utilities.h @@ -31,6 +31,7 @@ #ifndef UTILITIES_DUMMY_H #define UTILITIES_DUMMY_H +#include "material_storage.h" #include "mesh_storage.h" #include "servers/rendering/storage/utilities.h" #include "texture_storage.h" @@ -63,6 +64,12 @@ class Utilities : public RendererUtilities { } else if (RendererDummy::MeshStorage::get_singleton()->owns_mesh(p_rid)) { RendererDummy::MeshStorage::get_singleton()->mesh_free(p_rid); return true; + } else if (RendererDummy::MeshStorage::get_singleton()->owns_multimesh(p_rid)) { + RendererDummy::MeshStorage::get_singleton()->multimesh_free(p_rid); + return true; + } else if (RendererDummy::MaterialStorage::get_singleton()->owns_shader(p_rid)) { + RendererDummy::MaterialStorage::get_singleton()->shader_free(p_rid); + return true; } return false; } From 0f6403f7197c8c806f718da47c65e63705dd009f Mon Sep 17 00:00:00 2001 From: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> Date: Thu, 8 Feb 2024 12:15:26 +0100 Subject: [PATCH 6/8] Fix missing instance type in dummy renderer (cherry picked from commit 406d7e6d3720d0e5c7b0afe29fda806358e1ba55) --- servers/rendering/dummy/storage/utilities.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/servers/rendering/dummy/storage/utilities.h b/servers/rendering/dummy/storage/utilities.h index 2497451fdc93..4a640f9594f4 100644 --- a/servers/rendering/dummy/storage/utilities.h +++ b/servers/rendering/dummy/storage/utilities.h @@ -53,6 +53,8 @@ class Utilities : public RendererUtilities { virtual RS::InstanceType get_base_type(RID p_rid) const override { if (RendererDummy::MeshStorage::get_singleton()->owns_mesh(p_rid)) { return RS::INSTANCE_MESH; + } else if (RendererDummy::MeshStorage::get_singleton()->owns_multimesh(p_rid)) { + return RS::INSTANCE_MULTIMESH; } return RS::INSTANCE_NONE; } From 219517f6b8ade461cad22a35e64842782dec2a51 Mon Sep 17 00:00:00 2001 From: Mikael Hermansson Date: Tue, 9 Apr 2024 11:20:43 +0200 Subject: [PATCH 7/8] Add `--import` command-line flag (cherry picked from commit 9d01793dfff8d6d6db6ec953cb704f45e582c2c9) --- editor/editor_file_system.h | 1 + main/main.cpp | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/editor/editor_file_system.h b/editor/editor_file_system.h index 0d558c84c529..088960d6f516 100644 --- a/editor/editor_file_system.h +++ b/editor/editor_file_system.h @@ -304,6 +304,7 @@ class EditorFileSystem : public Node { EditorFileSystemDirectory *get_filesystem(); bool is_scanning() const; bool is_importing() const { return importing; } + bool doing_first_scan() const { return first_scan; } float get_scanning_progress() const; void scan(); void scan_changes(); diff --git a/main/main.cpp b/main/main.cpp index 3a803ffab9c8..dd256da0e87a 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -89,6 +89,7 @@ #include "editor/debugger/editor_debugger_node.h" #include "editor/doc_data_class_path.gen.h" #include "editor/doc_tools.h" +#include "editor/editor_file_system.h" #include "editor/editor_help.h" #include "editor/editor_node.h" #include "editor/editor_paths.h" @@ -179,6 +180,7 @@ static OS::ProcessID editor_pid = 0; static bool found_project = false; static bool auto_build_solutions = false; static String debug_server_uri; +static bool wait_for_import = false; #ifndef DISABLE_DEPRECATED static int converter_max_kb_file = 4 * 1024; // 4MB static int converter_max_line_length = 100000; @@ -505,6 +507,7 @@ void Main::print_help(const char *p_binary) { OS::get_singleton()->print(" --main-loop Run a MainLoop specified by its global class name.\n"); OS::get_singleton()->print(" --check-only Only parse for errors and quit (use with --script).\n"); #ifdef TOOLS_ENABLED + OS::get_singleton()->print(" --import Starts the editor, waits for any resources to be imported, and then quits.\n"); OS::get_singleton()->print(" --export-release Export the project in release mode using the given preset and output path. The preset name should match one defined in export_presets.cfg.\n"); OS::get_singleton()->print(" should be absolute or relative to the project directory, and include the filename for the binary (e.g. 'builds/game.exe').\n"); OS::get_singleton()->print(" The target directory must exist.\n"); @@ -1288,12 +1291,17 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph OS::get_singleton()->print("Missing file to load argument after --validate-extension-api, aborting."); goto error; } - + } else if (I->get() == "--import") { + editor = true; + cmdline_tool = true; + wait_for_import = true; + quit_after = 1; } else if (I->get() == "--export-release" || I->get() == "--export-debug" || I->get() == "--export-pack") { // Export project // Actually handling is done in start(). editor = true; cmdline_tool = true; + wait_for_import = true; main_args.push_back(I->get()); #ifndef DISABLE_DEPRECATED } else if (I->get() == "--export") { // For users used to 3.x syntax. @@ -3746,6 +3754,12 @@ bool Main::iteration() { exit = true; } +#ifdef TOOLS_ENABLED + if (wait_for_import && EditorFileSystem::get_singleton()->doing_first_scan()) { + exit = false; + } +#endif + if (fixed_fps != -1) { return exit; } From e57244edc67eb25edd2d574d45f50261c26c5513 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Tue, 16 Apr 2024 09:21:26 +0200 Subject: [PATCH 8/8] Update changelog for 4.2.2 --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 704ef46e31d7..f4b575b74496 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -347,6 +347,7 @@ branches, and linked at the [end of this file](#Past-releases). - Properly calculate binormal when creating SurfaceTool from arrays ([GH-88725](https://github.com/godotengine/godot/pull/88725)). - Multiple fixes for compressed meshes ([GH-88738](https://github.com/godotengine/godot/pull/88738)). - Fix wrong indexing when generating dummy tangents in GLTF import ([GH-88931](https://github.com/godotengine/godot/pull/88931)). +- Add `--import` command-line flag ([GH-90431](https://github.com/godotengine/godot/pull/90431)). #### Input @@ -449,11 +450,14 @@ branches, and linked at the [end of this file](#Past-releases). - Fix 2D normals for transposed texture ([GH-87225](https://github.com/godotengine/godot/pull/87225)). - Disable scissor test after rendering batches in compatibility renderer ([GH-87489](https://github.com/godotengine/godot/pull/87489)). - Significantly improve the speed of shader compilation in compatibility backend ([GH-87553](https://github.com/godotengine/godot/pull/87553)). +- Free dummy renderer objects ([GH-87710](https://github.com/godotengine/godot/pull/87710)). - Do not reflect the origin lines in a mirror ([GH-87757](https://github.com/godotengine/godot/pull/87757)). +- Fix missing instance type in dummy renderer ([GH-88097](https://github.com/godotengine/godot/pull/88097)). - Make `RID_Owner` threadsafe in `TextureStorage` for GLES3 ([GH-88205](https://github.com/godotengine/godot/pull/88205)). - Disable ReShade in the editor and project manager (if run via Vulkan) ([GH-88316](https://github.com/godotengine/godot/pull/88316)). - Make dummy rendering server appear as a high end platform to fix vulkan shader compile error when exporting ([GH-88409](https://github.com/godotengine/godot/pull/88409)). - Fix shader cache with transform feedback on some Android devices ([GH-88573](https://github.com/godotengine/godot/pull/88573)). +- Fail early if shader mode is invalid in dummy renderer ([GH-88581](https://github.com/godotengine/godot/pull/88581)). - Add fix for TAA passes rendering black meshes on XR ([GH-88830](https://github.com/godotengine/godot/pull/88830)). - Make Overdraw, Lighting and Shadow Splits debug draw modes ignore decals ([GH-89253](https://github.com/godotengine/godot/pull/89253)). - Fix missed light clusters when inside clipped lights ([GH-89450](https://github.com/godotengine/godot/pull/89450)). @@ -465,6 +469,8 @@ branches, and linked at the [end of this file](#Past-releases). - Fix visual shader's `screen_uv` input preview uses position of node rather than a sample area like uv ([GH-84348](https://github.com/godotengine/godot/pull/84348)). - Check if the ref shader is valid in visual shader's `_update_option_menu` ([GH-87356](https://github.com/godotengine/godot/pull/87356)). +- Fully initialize all members of structs `IdentifierActions`, `GeneratedCode` and `DefaultIdentifierActions` ([GH-88021](https://github.com/godotengine/godot/pull/88021)). +- Change shader compiler default setting to avoid doctool error ([GH-88996](https://github.com/godotengine/godot/pull/88996)). #### XR