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/Region/Environment/Scenes | |
parent | Update svn properties. (diff) | |
download | opensim-SC_OLD-76206543e83661bbf04ee046b10b27736c589c81.zip opensim-SC_OLD-76206543e83661bbf04ee046b10b27736c589c81.tar.gz opensim-SC_OLD-76206543e83661bbf04ee046b10b27736c589c81.tar.bz2 opensim-SC_OLD-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/Region/Environment/Scenes')
-rw-r--r-- | OpenSim/Region/Environment/Scenes/SceneManager.cs | 127 |
1 files changed, 127 insertions, 0 deletions
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 | } |