Skip to content

Commit

Permalink
Fix multithreaded scene loading & Steam Deck dpad_right import settin…
Browse files Browse the repository at this point in the history
…gs (#82)

* Defer load_texture_path to the main thread

* Fix import settings for steamdeck dpad_right

* Fix deferred call

* Call directly if on main thread already
  • Loading branch information
plink-plonk-will authored Mar 25, 2024
1 parent c3ad12e commit 9564f73
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
13 changes: 6 additions & 7 deletions addons/controller_icons/assets/steamdeck/dpad_right.png.import
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,25 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://ccjjrpx72dn2r"
path.s3tc="res://.godot/imported/dpad_right.png-828c1fa323dfa47ac18628cf2c8ec764.s3tc.ctex"
path="res://.godot/imported/dpad_right.png-828c1fa323dfa47ac18628cf2c8ec764.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
"vram_texture": false
}

[deps]

source_file="res://addons/controller_icons/assets/steamdeck/dpad_right.png"
dest_files=["res://.godot/imported/dpad_right.png-828c1fa323dfa47ac18628cf2c8ec764.s3tc.ctex"]
dest_files=["res://.godot/imported/dpad_right.png-828c1fa323dfa47ac18628cf2c8ec764.ctex"]

[params]

compress/mode=2
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
Expand All @@ -32,4 +31,4 @@ process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0
detect_3d/compress_to=1
9 changes: 8 additions & 1 deletion addons/controller_icons/objects/ControllerIconTexture.gd
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func _reload_resource():
_dirty = true
emit_changed()

func _load_texture_path():
func _load_texture_path_main_thread():
var textures : Array[Texture2D] = []
if ControllerIcons.is_node_ready() and _can_be_shown():
var input_type = ControllerIcons._last_input_type if force_type == ForceType.NONE else force_type - 1
Expand All @@ -171,6 +171,13 @@ func _load_texture_path():
_textures = textures
_reload_resource()

func _load_texture_path():
# Ensure loading only occurs on the main thread
if OS.get_thread_caller_id() != OS.get_main_thread_id():
_load_texture_path_main_thread.call_deferred()
else:
_load_texture_path_main_thread()

func _init():
ControllerIcons.input_type_changed.connect(_on_input_type_changed)

Expand Down

0 comments on commit 9564f73

Please sign in to comment.