From 44c11cef76fd02355270188ec4f00910ec3289bb Mon Sep 17 00:00:00 2001 From: minjaesong Date: Fri, 20 Nov 2020 14:08:18 +0900 Subject: [PATCH] multithread light: forget about it --- .gitattributes | 3 +- .../terrarum/concurrent/ThreadExecutor.kt | 2 +- .../worlddrawer/LightmapRendererNew.kt | 34 ++++++++----------- 3 files changed, 18 insertions(+), 21 deletions(-) diff --git a/.gitattributes b/.gitattributes index 69f4dd9e3..bcfd590f3 100644 --- a/.gitattributes +++ b/.gitattributes @@ -5,4 +5,5 @@ *.opus filter=lfs diff=lfs merge=lfs -text *.pdf filter=lfs diff=lfs merge=lfs -text *.zip filter=lfs diff=lfs merge=lfs -text -*.kra filter=lfs diff=lfs merge=lfs -text \ No newline at end of file +*.kra filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text diff --git a/src/net/torvald/terrarum/concurrent/ThreadExecutor.kt b/src/net/torvald/terrarum/concurrent/ThreadExecutor.kt index 981bc30a4..3dfbb5fe5 100644 --- a/src/net/torvald/terrarum/concurrent/ThreadExecutor.kt +++ b/src/net/torvald/terrarum/concurrent/ThreadExecutor.kt @@ -56,7 +56,7 @@ object ThreadExecutor { // https://stackoverflow.com/questions/28818494/threads-stopping-prematurely-for-certain-values fun join() { - println("ThreadExecutor.join") + //println("ThreadExecutor.join") isOpen = false futures.forEach { try { diff --git a/src/net/torvald/terrarum/worlddrawer/LightmapRendererNew.kt b/src/net/torvald/terrarum/worlddrawer/LightmapRendererNew.kt index ac72217f7..ff4897a7d 100644 --- a/src/net/torvald/terrarum/worlddrawer/LightmapRendererNew.kt +++ b/src/net/torvald/terrarum/worlddrawer/LightmapRendererNew.kt @@ -10,6 +10,7 @@ import net.torvald.terrarum.AppLoader.printdbg import net.torvald.terrarum.blockproperties.Block import net.torvald.terrarum.blockproperties.BlockCodex import net.torvald.terrarum.blockproperties.Fluid +import net.torvald.terrarum.concurrent.ThreadExecutor import net.torvald.terrarum.gameactors.ActorWithBody import net.torvald.terrarum.gameactors.Luminous import net.torvald.terrarum.gameworld.BlockAddress @@ -357,28 +358,23 @@ object LightmapRenderer { // each usually takes 8..12 ms total when not threaded // - with direct memory access of world array and pre-calculating things in the start of the frame, // I was able to pull out 3.5..5.5 ms! With abhorrently many occurrences of segfaults I had to track down... + // - with 'NEWLIGHT2', I was able to pull ~2 ms! + // + // multithreading - forget about it; overhead is way too big and for some reason i was not able to + // resolve the 'noisy shit' artefact + AppLoader.measureDebugTime("Renderer.LightRuns") { - if (!AppLoader.getConfigBoolean("multithreadedlight")) { - AppLoader.measureDebugTime("Renderer.LightRuns") { + // To save you from pains: + // - Per-channel light updating is actually slower + // BELOW NOTES DOES NOT APPLY TO 'NEWLIGHT2' LIGHT SWIPER + // - It seems 5-pass lighting is needed to resonably eliminate the dark spot (of which I have zero idea + // why dark spots appear in the first place) + // - Multithreading? I have absolutely no idea. + // - If you naively slice the screen (job area) to multithread, the seam will appear. - // To save you from pains: - // - Per-channel light updating is actually slower - // BELOW NOTES DOES NOT APPLY TO 'NEWLIGHT2' LIGHT SWIPER - // - It seems 5-pass lighting is needed to resonably eliminate the dark spot (of which I have zero idea - // why dark spots appear in the first place) - // - Multithreading? I have absolutely no idea. - // - If you naively slice the screen (job area) to multithread, the seam will appear. - //r3();r4();r1();r2();r3(); - - r1();r2();r3();r4() - //r1();r2();r3();r4() - - } - } - else if (world.worldIndex != -1) { // to avoid updating on the null world - AppLoader.measureDebugTime("Renderer.LightRuns") { - } + r1();r2();r3();r4() } + } private fun buildLanternmap(actorContainers: Array?>) {