From 76206543e83661bbf04ee046b10b27736c589c81 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Sun, 25 Jan 2009 04:34:00 +0000 Subject: * Adds console command, 'predecode-j2k ' to load all of the texture assets from the scene and decode the j2k layer data to cache. The work is split between the number of threads you specify. A good number of threads value is the number of cores on your machine minus 1. * Increases the number of ImageDataPackets we send per PriorityQueue pop and tweak it so that the number of packets is ( (2 * decode level) + 1 ) * 2, and (((2 * (5-decode level)) + 1) * 2). The first one sends more data for low quality textures, the second one sends more data for high quality textures. --- OpenSim/Region/Application/OpenSim.cs | 11 ++ .../Region/ClientStack/LindenUDP/LLImageManager.cs | 14 ++- .../Agent/TextureSender/J2KDecoderModule.cs | 3 +- OpenSim/Region/Environment/Scenes/SceneManager.cs | 127 +++++++++++++++++++++ 4 files changed, 153 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index 3db7176..802adcd 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs @@ -496,6 +496,16 @@ namespace OpenSim case "reset": Reset(cmdparams); break; + case "predecode-j2k": + if (cmdparams.Length > 0) + { + m_sceneManager.CacheJ2kDecode(Convert.ToInt32(cmdparams[0])); + } + else + { + m_sceneManager.CacheJ2kDecode(1); + } + break; default: string[] tmpPluginArgs = new string[cmdparams.Length + 1]; @@ -688,6 +698,7 @@ namespace OpenSim m_console.Notice("login-enable - Allows login at sim level"); m_console.Notice("login-disable - Disable login at sim level"); m_console.Notice("login-status - Show the actual login status"); + m_console.Notice("predecode-j2k - Precache assets,decode j2k layerdata, First parameter is threads to use"); ShowPluginCommandsHelp(CombineParams(helpArgs, 0), m_console); diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs b/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs index 58c4e04..3b21c85 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs @@ -230,12 +230,24 @@ namespace OpenSim.Region.ClientStack.LindenUDP else if (!process.data.J2KDecodeWaiting) { // Send more data at a time for higher discard levels - for (int i = 0; i < (2*(5 - process.data.DiscardLevel) + 1)*2; i++) + bool done = false; + for (int i = 0; i < (2*(process.data.DiscardLevel) + 1)*2; i++) if (!process.data.SendPacket(m_client)) { + done = true; pq[h] -= (500000*i); break; } + if (!done) + { + for (int i = 0; i < (2 * (5- process.data.DiscardLevel) + 1) * 2; i++) + if (!process.data.SendPacket(m_client)) + { + done = true; + pq[h] -= (500000 * i); + break; + } + } } // If the priority is less then -4 billion, the client has forgotten about it, pop it off if (pq[h] < -400000000) diff --git a/OpenSim/Region/Environment/Modules/Agent/TextureSender/J2KDecoderModule.cs b/OpenSim/Region/Environment/Modules/Agent/TextureSender/J2KDecoderModule.cs index 53e66fc..cf76ebc 100644 --- a/OpenSim/Region/Environment/Modules/Agent/TextureSender/J2KDecoderModule.cs +++ b/OpenSim/Region/Environment/Modules/Agent/TextureSender/J2KDecoderModule.cs @@ -236,7 +236,8 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureSender // Cache Decoded layers lock (m_cacheddecode) { - m_cacheddecode.Add(AssetId, layers); + if (!m_cacheddecode.ContainsKey(AssetId)) + m_cacheddecode.Add(AssetId, layers); } diff --git a/OpenSim/Region/Environment/Scenes/SceneManager.cs b/OpenSim/Region/Environment/Scenes/SceneManager.cs index 040a0d4..b2b79b4 100644 --- a/OpenSim/Region/Environment/Scenes/SceneManager.cs +++ b/OpenSim/Region/Environment/Scenes/SceneManager.cs @@ -547,5 +547,132 @@ namespace OpenSim.Region.Environment.Scenes { m_localScenes.ForEach(action); } + + public void CacheJ2kDecode(int threads) + { + if (threads < 1) threads = 1; + + IJ2KDecoder m_decoder = m_localScenes[0].RequestModuleInterface(); + + List assetRequestList = new List(); + + #region AssetGathering! + foreach (Scene scene in m_localScenes) + { + List entitles = scene.GetEntities(); + foreach (EntityBase entity in entitles) + { + if (entity is SceneObjectGroup) + { + SceneObjectGroup sog = (SceneObjectGroup) entity; + foreach (SceneObjectPart part in sog.Children.Values) + { + if (part.Shape != null) + { + if (part.Shape.TextureEntry.Length > 0) + { + OpenMetaverse.Primitive.TextureEntry te = + new Primitive.TextureEntry(part.Shape.TextureEntry, 0, + part.Shape.TextureEntry.Length); + if (te.DefaultTexture != null) // this has been null for some reason... + { + if (te.DefaultTexture.TextureID != UUID.Zero) + assetRequestList.Add(te.DefaultTexture.TextureID); + } + for (int i=0; i arrvalus = new List(); + + //split into separate arrays + for (int j=0;j val = new List(); + + for (int k=j*entries_per_thread; k < ((j+1)* entries_per_thread);k++) + { + if (k < arrAssetRequestList.Length) + { + val.Add(arrAssetRequestList[k]); + } + + } + arrvalus.Add(val.ToArray()); + } + + for (int l=0;l