diff options
author | Teravus Ovares | 2009-01-25 04:34:00 +0000 |
---|---|---|
committer | Teravus Ovares | 2009-01-25 04:34:00 +0000 |
commit | 76206543e83661bbf04ee046b10b27736c589c81 (patch) | |
tree | 0379cb3411bfea0e8348092de8d4d50f30fb9934 /OpenSim | |
parent | Update svn properties. (diff) | |
download | opensim-SC-76206543e83661bbf04ee046b10b27736c589c81.zip opensim-SC-76206543e83661bbf04ee046b10b27736c589c81.tar.gz opensim-SC-76206543e83661bbf04ee046b10b27736c589c81.tar.bz2 opensim-SC-76206543e83661bbf04ee046b10b27736c589c81.tar.xz |
* Adds console command, 'predecode-j2k <number of threads>' 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.
Diffstat (limited to 'OpenSim')
4 files changed, 153 insertions, 2 deletions
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 | |||
496 | case "reset": | 496 | case "reset": |
497 | Reset(cmdparams); | 497 | Reset(cmdparams); |
498 | break; | 498 | break; |
499 | case "predecode-j2k": | ||
500 | if (cmdparams.Length > 0) | ||
501 | { | ||
502 | m_sceneManager.CacheJ2kDecode(Convert.ToInt32(cmdparams[0])); | ||
503 | } | ||
504 | else | ||
505 | { | ||
506 | m_sceneManager.CacheJ2kDecode(1); | ||
507 | } | ||
508 | break; | ||
499 | 509 | ||
500 | default: | 510 | default: |
501 | string[] tmpPluginArgs = new string[cmdparams.Length + 1]; | 511 | string[] tmpPluginArgs = new string[cmdparams.Length + 1]; |
@@ -688,6 +698,7 @@ namespace OpenSim | |||
688 | m_console.Notice("login-enable - Allows login at sim level"); | 698 | m_console.Notice("login-enable - Allows login at sim level"); |
689 | m_console.Notice("login-disable - Disable login at sim level"); | 699 | m_console.Notice("login-disable - Disable login at sim level"); |
690 | m_console.Notice("login-status - Show the actual login status"); | 700 | m_console.Notice("login-status - Show the actual login status"); |
701 | m_console.Notice("predecode-j2k - Precache assets,decode j2k layerdata, First parameter is threads to use"); | ||
691 | 702 | ||
692 | ShowPluginCommandsHelp(CombineParams(helpArgs, 0), m_console); | 703 | ShowPluginCommandsHelp(CombineParams(helpArgs, 0), m_console); |
693 | 704 | ||
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 | |||
230 | else if (!process.data.J2KDecodeWaiting) | 230 | else if (!process.data.J2KDecodeWaiting) |
231 | { | 231 | { |
232 | // Send more data at a time for higher discard levels | 232 | // Send more data at a time for higher discard levels |
233 | for (int i = 0; i < (2*(5 - process.data.DiscardLevel) + 1)*2; i++) | 233 | bool done = false; |
234 | for (int i = 0; i < (2*(process.data.DiscardLevel) + 1)*2; i++) | ||
234 | if (!process.data.SendPacket(m_client)) | 235 | if (!process.data.SendPacket(m_client)) |
235 | { | 236 | { |
237 | done = true; | ||
236 | pq[h] -= (500000*i); | 238 | pq[h] -= (500000*i); |
237 | break; | 239 | break; |
238 | } | 240 | } |
241 | if (!done) | ||
242 | { | ||
243 | for (int i = 0; i < (2 * (5- process.data.DiscardLevel) + 1) * 2; i++) | ||
244 | if (!process.data.SendPacket(m_client)) | ||
245 | { | ||
246 | done = true; | ||
247 | pq[h] -= (500000 * i); | ||
248 | break; | ||
249 | } | ||
250 | } | ||
239 | } | 251 | } |
240 | // If the priority is less then -4 billion, the client has forgotten about it, pop it off | 252 | // If the priority is less then -4 billion, the client has forgotten about it, pop it off |
241 | if (pq[h] < -400000000) | 253 | 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 | |||
236 | // Cache Decoded layers | 236 | // Cache Decoded layers |
237 | lock (m_cacheddecode) | 237 | lock (m_cacheddecode) |
238 | { | 238 | { |
239 | m_cacheddecode.Add(AssetId, layers); | 239 | if (!m_cacheddecode.ContainsKey(AssetId)) |
240 | m_cacheddecode.Add(AssetId, layers); | ||
240 | 241 | ||
241 | } | 242 | } |
242 | 243 | ||
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 | |||
547 | { | 547 | { |
548 | m_localScenes.ForEach(action); | 548 | m_localScenes.ForEach(action); |
549 | } | 549 | } |
550 | |||
551 | public void CacheJ2kDecode(int threads) | ||
552 | { | ||
553 | if (threads < 1) threads = 1; | ||
554 | |||
555 | IJ2KDecoder m_decoder = m_localScenes[0].RequestModuleInterface<IJ2KDecoder>(); | ||
556 | |||
557 | List<UUID> assetRequestList = new List<UUID>(); | ||
558 | |||
559 | #region AssetGathering! | ||
560 | foreach (Scene scene in m_localScenes) | ||
561 | { | ||
562 | List<EntityBase> entitles = scene.GetEntities(); | ||
563 | foreach (EntityBase entity in entitles) | ||
564 | { | ||
565 | if (entity is SceneObjectGroup) | ||
566 | { | ||
567 | SceneObjectGroup sog = (SceneObjectGroup) entity; | ||
568 | foreach (SceneObjectPart part in sog.Children.Values) | ||
569 | { | ||
570 | if (part.Shape != null) | ||
571 | { | ||
572 | if (part.Shape.TextureEntry.Length > 0) | ||
573 | { | ||
574 | OpenMetaverse.Primitive.TextureEntry te = | ||
575 | new Primitive.TextureEntry(part.Shape.TextureEntry, 0, | ||
576 | part.Shape.TextureEntry.Length); | ||
577 | if (te.DefaultTexture != null) // this has been null for some reason... | ||
578 | { | ||
579 | if (te.DefaultTexture.TextureID != UUID.Zero) | ||
580 | assetRequestList.Add(te.DefaultTexture.TextureID); | ||
581 | } | ||
582 | for (int i=0; i<te.FaceTextures.Length; i++) | ||
583 | { | ||
584 | if (te.FaceTextures[i] != null) | ||
585 | { | ||
586 | if (te.FaceTextures[i].TextureID != UUID.Zero) | ||
587 | { | ||
588 | assetRequestList.Add(te.FaceTextures[i].TextureID); | ||
589 | } | ||
590 | } | ||
591 | } | ||
592 | } | ||
593 | if (part.Shape.SculptTexture != UUID.Zero) | ||
594 | { | ||
595 | assetRequestList.Add(part.Shape.SculptTexture); | ||
596 | } | ||
597 | |||
598 | } | ||
599 | } | ||
600 | } | ||
601 | } | ||
602 | } | ||
603 | #endregion | ||
604 | |||
605 | int entries_per_thread = (assetRequestList.Count/threads) + 1; | ||
606 | |||
607 | UUID[] arrAssetRequestList = assetRequestList.ToArray(); | ||
608 | |||
609 | int currpos = 0; | ||
610 | |||
611 | List<UUID[]> arrvalus = new List<UUID[]>(); | ||
612 | |||
613 | //split into separate arrays | ||
614 | for (int j=0;j<threads;j++) | ||
615 | { | ||
616 | List<UUID> val = new List<UUID>(); | ||
617 | |||
618 | for (int k=j*entries_per_thread; k < ((j+1)* entries_per_thread);k++) | ||
619 | { | ||
620 | if (k < arrAssetRequestList.Length) | ||
621 | { | ||
622 | val.Add(arrAssetRequestList[k]); | ||
623 | } | ||
624 | |||
625 | } | ||
626 | arrvalus.Add(val.ToArray()); | ||
627 | } | ||
628 | |||
629 | for (int l=0;l<arrvalus.Count;l++) | ||
630 | { | ||
631 | DecodeThreadContents threadworkItem = new DecodeThreadContents(); | ||
632 | threadworkItem.sn = m_localScenes[0]; | ||
633 | threadworkItem.j2kdecode = m_decoder; | ||
634 | threadworkItem.arrassets = arrvalus[l]; | ||
635 | |||
636 | System.Threading.Thread decodethread = | ||
637 | new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(threadworkItem.run)); | ||
638 | |||
639 | threadworkItem.SetThread(decodethread); | ||
640 | |||
641 | decodethread.Priority = System.Threading.ThreadPriority.Lowest; | ||
642 | decodethread.Name = "J2kCacheDecodeThread_" + l+1; | ||
643 | ThreadTracker.Add(decodethread); | ||
644 | decodethread.Start(); | ||
645 | |||
646 | } | ||
647 | |||
648 | |||
649 | |||
650 | } | ||
651 | } | ||
652 | public class DecodeThreadContents | ||
653 | { | ||
654 | public Scene sn; | ||
655 | public UUID[] arrassets; | ||
656 | public IJ2KDecoder j2kdecode; | ||
657 | private System.Threading.Thread thisthread; | ||
658 | |||
659 | public void run( object o) | ||
660 | { | ||
661 | for (int i=0;i<arrassets.Length;i++) | ||
662 | { | ||
663 | AssetBase ab = sn.AssetCache.GetAsset(arrassets[i], true); | ||
664 | if (ab != null && ab.Data != null) | ||
665 | { | ||
666 | j2kdecode.syncdecode(arrassets[i], ab.Data); | ||
667 | } | ||
668 | } | ||
669 | ThreadTracker.Remove(thisthread); | ||
670 | } | ||
671 | |||
672 | public void SetThread(System.Threading.Thread thr) | ||
673 | { | ||
674 | thisthread = thr; | ||
675 | } | ||
676 | |||
550 | } | 677 | } |
551 | } | 678 | } |