From b8d728342c07bcc961b376d8ee814b7cd13f7f14 Mon Sep 17 00:00:00 2001 From: drewcassidy Date: Sat, 26 Sep 2020 11:32:41 -0700 Subject: [PATCH] Fix text rendering user counter for new renders --- GameData/ConformalDecals/Plugins/ConformalDecals.dll | 4 ++-- Source/ConformalDecals/Text/TextRenderer.cs | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/GameData/ConformalDecals/Plugins/ConformalDecals.dll b/GameData/ConformalDecals/Plugins/ConformalDecals.dll index 1e9f233..d2589e7 100644 --- a/GameData/ConformalDecals/Plugins/ConformalDecals.dll +++ b/GameData/ConformalDecals/Plugins/ConformalDecals.dll @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:24dc0d4b3ee3e591a1fc612f1b8e4bdf7978ed3d4baa4d1c3f9d15452d9e353a -size 87040 +oid sha256:30a4feb4c4ae642efff196aa35771db01257ffad1956a737f868a2dc11628b95 +size 87552 diff --git a/Source/ConformalDecals/Text/TextRenderer.cs b/Source/ConformalDecals/Text/TextRenderer.cs index 2e421bc..82fab44 100644 --- a/Source/ConformalDecals/Text/TextRenderer.cs +++ b/Source/ConformalDecals/Text/TextRenderer.cs @@ -6,7 +6,7 @@ using UnityEngine; using UnityEngine.Events; namespace ConformalDecals.Text { - [KSPAddon(KSPAddon.Startup.EveryScene, false)] + [KSPAddon(KSPAddon.Startup.Instantly, true)] public class TextRenderer : MonoBehaviour { public const TextureFormat TextTextureFormat = TextureFormat.RG16; public const RenderTextureFormat TextRenderTextureFormat = RenderTextureFormat.R8; @@ -52,7 +52,9 @@ namespace ConformalDecals.Text { return Instance.RunJob(new TextRenderJob(oldText, newText, null), out _); } + // Unregister a user of a piece of text public static void UnregisterText(DecalText text) { + Debug.Log($"[ConformalDecals] Unregistering text '{text.Text}'"); if (RenderCache.TryGetValue(text, out var renderedText)) { renderedText.UserCount--; if (renderedText.UserCount <= 0) { @@ -102,7 +104,10 @@ namespace ConformalDecals.Text { return null; } - Debug.Log($"Starting Text Rendering Job. queue depth = {RenderJobs.Count}, cache size = {RenderCache.Count}"); + Debug.Log($"[ConformalDecals] Starting Text Rendering Job. queue depth = {RenderJobs.Count}, cache size = {RenderCache.Count}"); + foreach (var cacheitem in RenderCache) { + Debug.Log($"[ConformalDecals] Cache item: '{cacheitem.Key.Text}' with {cacheitem.Value.UserCount} users"); + } job.Start(); Texture2D texture = null; @@ -137,6 +142,7 @@ namespace ConformalDecals.Text { } var output = RenderText(job.NewText, texture); + output.UserCount++; RenderCache.Add(job.NewText, output); job.Finish(output);