godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.16k stars 97 forks source link

Implement Modular Export Templates in Godot for Optimized Performance and Reduced File Sizes #10689

Closed therabug closed 1 month ago

therabug commented 1 month ago

Describe the project you are working on

I am developing a 2D RPG game using the Godot Engine. This project aims to deliver high performance and optimization across various platforms, including desktop (Windows, macOS, Linux) and mobile devices (iOS, Android). Efficient resource management and minimizing file sizes are crucial for successful game deployment.

Describe the problem or limitation you are having in your project

Currently, Godot’s export templates bundle a wide range of features and graphics APIs into a single build, which leads to:

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Feature: Modular Export Templates

The proposed enhancement is to implement a modular export system in Godot, where developers can inject or exclude specific modules based on their requirements. This feature would involve:

Benefits:

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

a. Modular Export System Design:

  1. Base Export Templates:

    • Core Components Directory:

      • Maintain a basic set of export templates that include only essential components.

      Example Directory Structure:

      godot/
      ├── base_templates/
      │   ├── windows_core/
      │   ├── android_core/
      │   └── ios_core/
      └── modules/
       ├── opengl/
       ├── vulkan/
       ├── directx/
       └── bullet/
  2. Module Injection:

    • Configuration Files:

      • Developers create a configuration file specifying the modules to include.

      Example Configuration File:

      {
       "platform": "Windows",
       "graphics_api": "OpenGL",
       "physics_engine": "Bullet",
       "custom_features": ["2D Lighting"]
      }
    • Build Script:

      • A script reads the configuration file and builds the executable by injecting the specified modules into the base template.

      Example Build Script:

      def build_executable(config_file):
       with open(config_file, 'r') as f:
           config = json.load(f)
      
       base_template = load_base_template(config['platform'])
       modules = load_modules(config)
       build_executable_from_template(base_template, modules)
    • Editor Integration:

      • Adding Configuration Options:
      • Update the Godot Editor to allow developers to select and configure modules.

      Example Editor Plugin Code:

      extends EditorPlugin
      
      func _enter_tree():
         var panel = VBoxContainer.new()
         var graphics_api_option = OptionButton.new()
         graphics_api_option.add_item("OpenGL")
         graphics_api_option.add_item("Vulkan")
         panel.add_child(graphics_api_option)
      
         # Add more options for other configurations...
         add_control_to_container(CONTAINER_SPATIAL_EDITOR_BOTTOM, panel)

If this enhancement will not be used often, can it be worked around with a few lines of script?

While some aspects of modular export configurations can be partially managed with scripts, such as enabling or disabling features at runtime, they cannot fully address file size or performance optimization issues. Native support for modular export templates would be more efficient and streamlined.

Is there a reason why this should be core and not an add-on in the asset library?

This feature should be part of the core Godot Engine rather than an asset library add-on because it impacts the fundamental export process, which is essential for game development. Modular export templates affect file size, performance, and platform compatibility, making it crucial to integrate this feature into the core of Godot for consistency, ease of use, and better support for all users.

Zireael07 commented 1 month ago

WASM is one platform where file size is a big concern, and would benefit a lot from this

tetrapod00 commented 1 month ago

See also https://github.com/godotengine/godot-proposals/issues/1001 (and the other proposals linked by it). I thought there were some other modular export proposals floating around but I can't find them

zynga-jpetersen commented 1 month ago

More notes on this since I was going to open an issue about it (and the size increase).

Sizes: 4.3-stable is 1.01 GB (1,002,307,334 bytes) 4.2-stable is 873.1 MB (861,639,648 bytes)

templates_files_list_with_size_4.3.txt templates_files_list_with_size_4.2.txt

This impacts all platforms since there is only one export_templates for all versions of the editor.

A lot of this size increase is caused by adding in arm64 for windows (but its only going to get bigger as more platforms are added).

Calinou commented 1 month ago

Thanks for the proposal! Consolidating in https://github.com/godotengine/godot-proposals/issues/1001.

PS: In the future, please don't copy-paste text that is clearly AI-generated into proposals. The code samples provided here don't make sense, as the feature has to be implemented in C++ in the editor, not in GDScript. Moreover, Godot already has build profile editor functionality: https://github.com/godotengine/godot/pull/62996

A lot of this size increase is caused by adding in arm64 for windows (but its only going to get bigger as more platforms are added).

This is covered by its own proposal: https://github.com/godotengine/godot-proposals/issues/647

therabug commented 1 month ago

Thanks for the proposal! Consolidating in https://github.com/godotengine/godot-proposals/issues/1001.

PS: In the future, please don't copy-paste text that is clearly AI-generated into proposals. The code samples provided here don't make sense, as the feature has to be implemented in C++ in the editor, not in GDScript. Moreover, Godot already has build profile editor functionality: https://github.com/godotengine/godot/pull/62996

A lot of this size increase is caused by adding in arm64 for windows (but its only going to get bigger as more platforms are added).

This is covered by its own proposal: https://github.com/godotengine/godot-proposals/issues/647

sorry I don't have techincal information about this I just said the idea and as being my english not super on techincal sitatiouns. I use AI to rewrite all prospal