godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.14k stars 96 forks source link

Add Memory-Mapped Files (VFS) to Godot Editor as `memory://` #10978

Open CycloneRing opened 2 days ago

CycloneRing commented 2 days ago

Describe the project you are working on

RTX for Godot Extension

Describe the problem or limitation you are having in your project

Godot Editor is required to load all files and resources from disk.

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

Since Godot already has a memory file access system and uses VFS (Virtual File System) on PCK and ZIP at build runtime, This feature should brought to Editor as well.

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

Instead of using "res://we can use create memory files with path of "memory:// for example we create a and serialize a scene to `memory://scenes//my_scene.tscn" and retrive data as PackedByteArray, At another time we create virtual file again from data and use the ResourceLoader to load it. I am aware that some resources like images, videos and fonts are loadable from buffers but we need a global system for this.

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

It's not simple to implement but it's not hard as well, Since Godot already uses VFS for PCK at runtime and loads everything from archive to memory and resource loaders also read files to memory buffer and parse them.

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

Because it must be implemented in core.

atirut-w commented 1 day ago

So, a temporary file system? I think a tmp:// path would make more sense. Most OSes already provide space for temporary files AFAIK.

CycloneRing commented 1 day ago

So, a temporary file system? I think a tmp:// path would make more sense. Most OSes already provide space for temporary files AFAIK.

The whole point of having VFS is to avoid temporary files :) All operations will be redirected to a memory area instead of disk. It's faster and it's secure and has many features. Godot already has it just need some manipulation to make it enable in editor.