mirror of
https://github.com/Relintai/pandemonium_demo_projects.git
synced 2024-12-21 13:56:50 +01:00
Added a process group demo.
This commit is contained in:
parent
9dc8dd2036
commit
cf6e7ce207
30
process_groups/multi_threaded/Main.gd
Normal file
30
process_groups/multi_threaded/Main.gd
Normal file
@ -0,0 +1,30 @@
|
||||
extends Node
|
||||
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
# var a: int = 2
|
||||
# var b: String = "text"
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
print("")
|
||||
print("")
|
||||
print("When running this demo what you need to see is that ")
|
||||
print("between every frame steps you see 3 _process() calls, and 3 _process_group_process() start,")
|
||||
print("and 3 _process_group_process() end calls printed to the console.")
|
||||
print("This means that the ProcessGroups works properly.")
|
||||
print("_process() methods will run in the main thread, and ProcessGroup calls it's ")
|
||||
print("children's _process_group_process() in it's own thread, and ProcessGroup2 also calls it's ")
|
||||
print("children's _process_group_process() in it's own thread,")
|
||||
print("and SceneTree waits for them to finish before going to the next step.")
|
||||
print("This allows multi threaded processing similar to Godot 4s,")
|
||||
print("howewer this implementation tries t make it as explicit as possible when you are working in a thread or not.")
|
||||
print("")
|
||||
print("")
|
||||
|
||||
get_tree().connect("idle_frame", self, "idle_frame")
|
||||
|
||||
|
||||
func idle_frame():
|
||||
print("============== NEW FRAME START ==============")
|
20
process_groups/multi_threaded/Main.tscn
Normal file
20
process_groups/multi_threaded/Main.tscn
Normal file
@ -0,0 +1,20 @@
|
||||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://Main.gd" type="Script" id=1]
|
||||
[ext_resource path="res://ProcessorNode.gd" type="Script" id=2]
|
||||
|
||||
[node name="Main" type="Node"]
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="ProcessGroup" type="ProcessGroup" parent="."]
|
||||
|
||||
[node name="ProcessorNode" type="Node" parent="ProcessGroup"]
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="ProcessorNode2" type="Node" parent="ProcessGroup"]
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="ProcessGroup2" type="ProcessGroup" parent="."]
|
||||
|
||||
[node name="ProcessorNode4" type="Node" parent="ProcessGroup2"]
|
||||
script = ExtResource( 2 )
|
26
process_groups/multi_threaded/ProcessorNode.gd
Normal file
26
process_groups/multi_threaded/ProcessorNode.gd
Normal file
@ -0,0 +1,26 @@
|
||||
extends Node
|
||||
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
# var a: int = 2
|
||||
# var b: String = "text"
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
#func _ready() -> void:
|
||||
# set_process_group_process(false)
|
||||
# set_process_group_process(true)
|
||||
|
||||
func _process_group_process(delta: float) -> void:
|
||||
print(str(get_path()) + " _process_group_process() start")
|
||||
OS.delay_msec(1000)
|
||||
print(str(get_path()) + " _process_group_process() fin")
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
print(str(get_path()) + " _process()")
|
||||
|
||||
#func _notification(what: int) -> void:
|
||||
# #print(what)
|
||||
# if what >= 60 && what <= 70:
|
||||
# print(what)
|
7
process_groups/multi_threaded/default_env.tres
Normal file
7
process_groups/multi_threaded/default_env.tres
Normal file
@ -0,0 +1,7 @@
|
||||
[gd_resource type="Environment3D" load_steps=2 format=2]
|
||||
|
||||
[sub_resource type="ProceduralSky" id=1]
|
||||
|
||||
[resource]
|
||||
background_mode = 2
|
||||
background_sky = SubResource( 1 )
|
BIN
process_groups/multi_threaded/icon.png
Normal file
BIN
process_groups/multi_threaded/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.1 KiB |
35
process_groups/multi_threaded/icon.png.import
Normal file
35
process_groups/multi_threaded/icon.png.import
Normal file
@ -0,0 +1,35 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://icon.png"
|
||||
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=true
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
25
process_groups/multi_threaded/project.pandemonium
Normal file
25
process_groups/multi_threaded/project.pandemonium
Normal file
@ -0,0 +1,25 @@
|
||||
; Engine configuration file.
|
||||
; It's best edited using the editor UI and not directly,
|
||||
; since the parameters that go here are not all obvious.
|
||||
;
|
||||
; Format:
|
||||
; [section] ; section goes between []
|
||||
; param=value ; assign values to parameters
|
||||
|
||||
config_version=4
|
||||
|
||||
[application]
|
||||
|
||||
config/name="Multi Threaded"
|
||||
run/main_scene="res://Main.tscn"
|
||||
config/icon="res://icon.png"
|
||||
|
||||
[physics]
|
||||
|
||||
common/enable_pause_aware_picking=true
|
||||
|
||||
[rendering]
|
||||
|
||||
vram_compression/import_etc=true
|
||||
vram_compression/import_etc2=false
|
||||
environment/default_environment="res://default_env.tres"
|
Loading…
Reference in New Issue
Block a user