aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack
diff options
context:
space:
mode:
authorUbitUmarov2014-08-07 05:20:45 +0100
committerUbitUmarov2014-08-07 05:20:45 +0100
commitc3f9c99fb32d15e57b24502b71c79fe028ed3007 (patch)
tree0b7cef6c028edfff0e09ca6d5442141221bc85a2 /OpenSim/Region/ClientStack
parentbakemodule didnt like last changes (diff)
downloadopensim-SC-c3f9c99fb32d15e57b24502b71c79fe028ed3007.zip
opensim-SC-c3f9c99fb32d15e57b24502b71c79fe028ed3007.tar.gz
opensim-SC-c3f9c99fb32d15e57b24502b71c79fe028ed3007.tar.bz2
opensim-SC-c3f9c99fb32d15e57b24502b71c79fe028ed3007.tar.xz
DANGER... changed bakedtextures caching. Assuming grid baking is cache
only, reduced number of accesses to it. TESTING
Diffstat (limited to 'OpenSim/Region/ClientStack')
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs124
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs110
2 files changed, 99 insertions, 135 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs
index 2da653d..50e9275 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs
@@ -96,9 +96,7 @@ namespace OpenSim.Region.ClientStack.Linden
96 s.EventManager.OnRemovePresence -= DeRegisterPresence; 96 s.EventManager.OnRemovePresence -= DeRegisterPresence;
97 m_BakedTextureModule = null; 97 m_BakedTextureModule = null;
98 m_scene = null; 98 m_scene = null;
99 } 99 }
100
101
102 100
103 public void RegionLoaded(Scene s) 101 public void RegionLoaded(Scene s)
104 { 102 {
@@ -110,44 +108,58 @@ namespace OpenSim.Region.ClientStack.Linden
110 108
111 private void DeRegisterPresence(UUID agentId) 109 private void DeRegisterPresence(UUID agentId)
112 { 110 {
113 ScenePresence presence = null; 111// ScenePresence presence = null;
114 if (m_scene.TryGetScenePresence(agentId, out presence)) 112// if (m_scene.TryGetScenePresence(agentId, out presence))
115 { 113 {
116 presence.ControllingClient.OnSetAppearance -= CaptureAppearanceSettings; 114// presence.ControllingClient.OnSetAppearance -= CaptureAppearanceSettings;
117 } 115 }
118 116
119 } 117 }
120 118
121 private void RegisterNewPresence(ScenePresence presence) 119 private void RegisterNewPresence(ScenePresence presence)
122 { 120 {
123 presence.ControllingClient.OnSetAppearance += CaptureAppearanceSettings; 121// presence.ControllingClient.OnSetAppearance += CaptureAppearanceSettings;
124
125 } 122 }
126 123
127 private void CaptureAppearanceSettings(IClientAPI remoteClient, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 avSize, WearableCacheItem[] cacheItems) 124/* not in use. work done in AvatarFactoryModule ValidateBakedTextureCache() and UpdateBakedTextureCache()
128 { 125 private void CaptureAppearanceSettings(IClientAPI remoteClient, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 avSize, WearableCacheItem[] cacheItems)
129 int maxCacheitemsLoop = cacheItems.Length;
130 if (maxCacheitemsLoop > AvatarWearable.MAX_WEARABLES)
131 {
132 maxCacheitemsLoop = AvatarWearable.MAX_WEARABLES;
133 m_log.WarnFormat("[CACHEDBAKES]: Too Many Cache items Provided {0}, the max is {1}. Truncating!", cacheItems.Length, AvatarWearable.MAX_WEARABLES);
134 }
135
136 m_BakedTextureModule = m_scene.RequestModuleInterface<IBakedTextureModule>();
137 if (cacheItems.Length > 0)
138 {
139 m_log.Debug("[Cacheitems]: " + cacheItems.Length);
140 for (int iter = 0; iter < maxCacheitemsLoop; iter++)
141 {
142 m_log.Debug("[Cacheitems] {" + iter + "/" + cacheItems[iter].TextureIndex + "}: c-" + cacheItems[iter].CacheId + ", t-" +
143 cacheItems[iter].TextureID);
144 }
145
146 ScenePresence p = null;
147 if (m_scene.TryGetScenePresence(remoteClient.AgentId, out p))
148 { 126 {
127 // if cacheItems.Length > 0 viewer is giving us current textures information.
128 // baked ones should had been uploaded and in assets cache as local itens
129
130
131 if (cacheItems.Length == 0)
132 return; // no textures information, nothing to do
133
134 ScenePresence p = null;
135 if (!m_scene.TryGetScenePresence(remoteClient.AgentId, out p))
136 return; // what are we doing if there is no presence to cache for?
137
138 if (p.IsDeleted)
139 return; // does this really work?
140
141 int maxCacheitemsLoop = cacheItems.Length;
142 if (maxCacheitemsLoop > 20)
143 {
144 maxCacheitemsLoop = AvatarWearable.MAX_WEARABLES;
145 m_log.WarnFormat("[CACHEDBAKES]: Too Many Cache items Provided {0}, the max is {1}. Truncating!", cacheItems.Length, AvatarWearable.MAX_WEARABLES);
146 }
147
148 m_BakedTextureModule = m_scene.RequestModuleInterface<IBakedTextureModule>();
149
150
151 // some nice debug
152 m_log.Debug("[Cacheitems]: " + cacheItems.Length);
153 for (int iter = 0; iter < maxCacheitemsLoop; iter++)
154 {
155 m_log.Debug("[Cacheitems] {" + iter + "/" + cacheItems[iter].TextureIndex + "}: c-" + cacheItems[iter].CacheId + ", t-" +
156 cacheItems[iter].TextureID);
157 }
158
159 // p.Appearance.WearableCacheItems is in memory primary cashID to textures mapper
149 160
150 WearableCacheItem[] existingitems = p.Appearance.WearableCacheItems; 161 WearableCacheItem[] existingitems = p.Appearance.WearableCacheItems;
162
151 if (existingitems == null) 163 if (existingitems == null)
152 { 164 {
153 if (m_BakedTextureModule != null) 165 if (m_BakedTextureModule != null)
@@ -161,38 +173,22 @@ namespace OpenSim.Region.ClientStack.Linden
161 p.Appearance.WearableCacheItems = savedcache; 173 p.Appearance.WearableCacheItems = savedcache;
162 p.Appearance.WearableCacheItemsDirty = false; 174 p.Appearance.WearableCacheItemsDirty = false;
163 } 175 }
164
165 } 176 }
166 /* 177
167 * The following Catch types DO NOT WORK with m_BakedTextureModule.Get
168 * it jumps to the General Packet Exception Handler if you don't catch Exception!
169 *
170 catch (System.Net.Sockets.SocketException)
171 {
172 cacheItems = null;
173 }
174 catch (WebException)
175 {
176 cacheItems = null;
177 }
178 catch (InvalidOperationException)
179 {
180 cacheItems = null;
181 } */
182 catch (Exception) 178 catch (Exception)
183 { 179 {
184 // The service logs a sufficient error message. 180 // The service logs a sufficient error message.
185 } 181 }
186 182
187 183
188 if (savedcache != null) 184 if (savedcache != null)
189 existingitems = savedcache; 185 existingitems = savedcache;
190 } 186 }
191 } 187 }
188
192 // Existing items null means it's a fully new appearance 189 // Existing items null means it's a fully new appearance
193 if (existingitems == null) 190 if (existingitems == null)
194 { 191 {
195
196 for (int i = 0; i < maxCacheitemsLoop; i++) 192 for (int i = 0; i < maxCacheitemsLoop; i++)
197 { 193 {
198 if (textureEntry.FaceTextures.Length > cacheItems[i].TextureIndex) 194 if (textureEntry.FaceTextures.Length > cacheItems[i].TextureIndex)
@@ -205,7 +201,7 @@ namespace OpenSim.Region.ClientStack.Linden
205 AppearanceManager.DEFAULT_AVATAR_TEXTURE; 201 AppearanceManager.DEFAULT_AVATAR_TEXTURE;
206 continue; 202 continue;
207 } 203 }
208 cacheItems[i].TextureID =face.TextureID; 204 cacheItems[i].TextureID = face.TextureID;
209 if (m_scene.AssetService != null) 205 if (m_scene.AssetService != null)
210 cacheItems[i].TextureAsset = 206 cacheItems[i].TextureAsset =
211 m_scene.AssetService.GetCached(cacheItems[i].TextureID.ToString()); 207 m_scene.AssetService.GetCached(cacheItems[i].TextureID.ToString());
@@ -214,15 +210,10 @@ namespace OpenSim.Region.ClientStack.Linden
214 { 210 {
215 m_log.WarnFormat("[CACHEDBAKES]: Invalid Texture Index Provided, Texture doesn't exist or hasn't been uploaded yet {0}, the max is {1}. Skipping!", cacheItems[i].TextureIndex, textureEntry.FaceTextures.Length); 211 m_log.WarnFormat("[CACHEDBAKES]: Invalid Texture Index Provided, Texture doesn't exist or hasn't been uploaded yet {0}, the max is {1}. Skipping!", cacheItems[i].TextureIndex, textureEntry.FaceTextures.Length);
216 } 212 }
217
218
219 } 213 }
220 } 214 }
221 else 215 else
222 216 {
223
224 {
225 // for each uploaded baked texture
226 for (int i = 0; i < maxCacheitemsLoop; i++) 217 for (int i = 0; i < maxCacheitemsLoop; i++)
227 { 218 {
228 if (textureEntry.FaceTextures.Length > cacheItems[i].TextureIndex) 219 if (textureEntry.FaceTextures.Length > cacheItems[i].TextureIndex)
@@ -253,27 +244,24 @@ namespace OpenSim.Region.ClientStack.Linden
253 } 244 }
254 } 245 }
255 } 246 }
256
257 p.Appearance.WearableCacheItems = cacheItems; 247 p.Appearance.WearableCacheItems = cacheItems;
258 248
259 if (m_BakedTextureModule != null) 249 if (m_BakedTextureModule != null)
260 { 250 {
261 m_BakedTextureModule.Store(remoteClient.AgentId, cacheItems); 251 m_BakedTextureModule.Store(remoteClient.AgentId, cacheItems);
262 p.Appearance.WearableCacheItemsDirty = true; 252 p.Appearance.WearableCacheItemsDirty = true;
263 253
264 } 254 }
265 else 255 else
266 p.Appearance.WearableCacheItemsDirty = false; 256 p.Appearance.WearableCacheItemsDirty = false;
267 }
268 }
269
270 for (int iter = 0; iter < maxCacheitemsLoop; iter++)
271 {
272 m_log.Debug("[CacheitemsLeaving] {" + iter + "/" + cacheItems[iter].TextureIndex + "}: c-" + cacheItems[iter].CacheId + ", t-" +
273 cacheItems[iter].TextureID);
274 }
275 }
276 257
258 for (int iter = 0; iter < maxCacheitemsLoop; iter++)
259 {
260 m_log.Debug("[CacheitemsLeaving] {" + iter + "/" + cacheItems[iter].TextureIndex + "}: c-" + cacheItems[iter].CacheId + ", t-" +
261 cacheItems[iter].TextureID);
262 }
263 }
264 */
277 public void PostInitialise() 265 public void PostInitialise()
278 { 266 {
279 } 267 }
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
index 08b6cb4..38a9af3 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
@@ -3684,6 +3684,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3684 avp.Sender.IsTrial = false; 3684 avp.Sender.IsTrial = false;
3685 avp.Sender.ID = agentID; 3685 avp.Sender.ID = agentID;
3686 avp.AppearanceData = new AvatarAppearancePacket.AppearanceDataBlock[0]; 3686 avp.AppearanceData = new AvatarAppearancePacket.AppearanceDataBlock[0];
3687
3688 // this need be use in future
3689 // avp.AppearanceData[0].AppearanceVersion = 0;
3690 // avp.AppearanceData[0].CofVersion = 0;
3691
3687 //m_log.DebugFormat("[CLIENT]: Sending appearance for {0} to {1}", agentID.ToString(), AgentId.ToString()); 3692 //m_log.DebugFormat("[CLIENT]: Sending appearance for {0} to {1}", agentID.ToString(), AgentId.ToString());
3688 OutPacket(avp, ThrottleOutPacketType.Task); 3693 OutPacket(avp, ThrottleOutPacketType.Task);
3689 } 3694 }
@@ -12006,8 +12011,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
12006 AgentCachedTextureResponsePacket cachedresp = (AgentCachedTextureResponsePacket)PacketPool.Instance.GetPacket(PacketType.AgentCachedTextureResponse); 12011 AgentCachedTextureResponsePacket cachedresp = (AgentCachedTextureResponsePacket)PacketPool.Instance.GetPacket(PacketType.AgentCachedTextureResponse);
12007 12012
12008 if (cachedtex.AgentData.SessionID != SessionId) 12013 if (cachedtex.AgentData.SessionID != SessionId)
12009 return false; 12014 return false;
12010
12011 12015
12012 // TODO: don't create new blocks if recycling an old packet 12016 // TODO: don't create new blocks if recycling an old packet
12013 cachedresp.AgentData.AgentID = AgentId; 12017 cachedresp.AgentData.AgentID = AgentId;
@@ -12022,23 +12026,27 @@ namespace OpenSim.Region.ClientStack.LindenUDP
12022 //WearableCacheItem[] items = fac.GetCachedItems(AgentId); 12026 //WearableCacheItem[] items = fac.GetCachedItems(AgentId);
12023 12027
12024 IAssetService cache = m_scene.AssetService; 12028 IAssetService cache = m_scene.AssetService;
12025 IBakedTextureModule bakedTextureModule = m_scene.RequestModuleInterface<IBakedTextureModule>();
12026 //bakedTextureModule = null; 12029 //bakedTextureModule = null;
12027 int maxWearablesLoop = cachedtex.WearableData.Length; 12030 int maxWearablesLoop = cachedtex.WearableData.Length;
12028 if (maxWearablesLoop > AvatarWearable.MAX_WEARABLES) 12031 if (maxWearablesLoop > AvatarWearable.MAX_WEARABLES)
12029 maxWearablesLoop = AvatarWearable.MAX_WEARABLES; 12032 maxWearablesLoop = AvatarWearable.MAX_WEARABLES;
12030 12033
12031// if (bakedTextureModule != null && cache != null) 12034 int cacheHits = 0;
12035
12032 if (cache != null) 12036 if (cache != null)
12033 { 12037 {
12034 // We need to make sure the asset stored in the bake is available on this server also by it's assetid before we map it to a Cacheid 12038 // We need to make sure the asset stored in the bake is available on this server also by it's assetid before we map it to a Cacheid
12035 12039
12036 WearableCacheItem[] cacheItems = null; 12040 WearableCacheItem[] cacheItems = null;
12041
12037 ScenePresence p = m_scene.GetScenePresence(AgentId); 12042 ScenePresence p = m_scene.GetScenePresence(AgentId);
12038 if (p.Appearance != null) 12043
12044 if (p!= null && p.Appearance != null)
12039 { 12045 {
12040 if (p.Appearance.WearableCacheItems == null || p.Appearance.WearableCacheItemsDirty) 12046 /* we should only check bakedTextureModule at login or when appearance changes
12047 if (p.Appearance.WearableCacheItems == null) // currently with a caching only bakemodule Appearance.Wearables.dirty as no use
12041 { 12048 {
12049 IBakedTextureModule bakedTextureModule = m_scene.RequestModuleInterface<IBakedTextureModule>();
12042 if (bakedTextureModule != null) 12050 if (bakedTextureModule != null)
12043 { 12051 {
12044 m_log.Debug("[ HandleAgentTextureCached] bakedTextureModule"); 12052 m_log.Debug("[ HandleAgentTextureCached] bakedTextureModule");
@@ -12047,23 +12055,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP
12047 cacheItems = bakedTextureModule.Get(AgentId); 12055 cacheItems = bakedTextureModule.Get(AgentId);
12048 p.Appearance.WearableCacheItems = cacheItems; 12056 p.Appearance.WearableCacheItems = cacheItems;
12049 p.Appearance.WearableCacheItemsDirty = false; 12057 p.Appearance.WearableCacheItemsDirty = false;
12050 }
12051 12058
12052 /* 12059 if (cacheItems != null)
12053 * The following Catch types DO NOT WORK, it jumps to the General Packet Exception Handler if you don't catch Exception! 12060 {
12054 * 12061 foreach (WearableCacheItem item in cacheItems)
12055 catch (System.Net.Sockets.SocketException) 12062 {
12056 { 12063 if (item.TextureAsset != null)
12057 cacheItems = null; 12064 {
12058 } 12065 item.TextureAsset.Temporary = true;
12059 catch (WebException) 12066 item.TextureAsset.Local = true;
12060 { 12067 cache.Store(item.TextureAsset);
12061 cacheItems = null; 12068 }
12069 }
12070 }
12062 } 12071 }
12063 catch (InvalidOperationException) 12072
12064 {
12065 cacheItems = null;
12066 } */
12067 catch (Exception) 12073 catch (Exception)
12068 { 12074 {
12069 cacheItems = null; 12075 cacheItems = null;
@@ -12075,36 +12081,23 @@ namespace OpenSim.Region.ClientStack.LindenUDP
12075 { 12081 {
12076 cacheItems = p.Appearance.WearableCacheItems; 12082 cacheItems = p.Appearance.WearableCacheItems;
12077 } 12083 }
12084*/
12085 cacheItems = p.Appearance.WearableCacheItems;
12078 } 12086 }
12079 12087
12080 if (cache != null && cacheItems != null)
12081 {
12082 foreach (WearableCacheItem item in cacheItems)
12083 {
12084
12085 if (cache.GetCached(item.TextureID.ToString()) == null)
12086 {
12087 item.TextureAsset.Temporary = true;
12088 cache.Store(item.TextureAsset);
12089 }
12090 }
12091 }
12092
12093 if (cacheItems != null) 12088 if (cacheItems != null)
12094 { 12089 {
12095
12096 for (int i = 0; i < maxWearablesLoop; i++) 12090 for (int i = 0; i < maxWearablesLoop; i++)
12097 { 12091 {
12098 WearableCacheItem item = 12092 int idx = cachedtex.WearableData[i].TextureIndex;
12099 WearableCacheItem.SearchTextureIndex(cachedtex.WearableData[i].TextureIndex,cacheItems);
12100 12093
12101 cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock(); 12094 cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
12102 cachedresp.WearableData[i].TextureIndex= cachedtex.WearableData[i].TextureIndex; 12095 cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex;
12103 cachedresp.WearableData[i].HostName = new byte[0]; 12096 cachedresp.WearableData[i].HostName = new byte[0];
12104 if (item != null && cachedtex.WearableData[i].ID == item.CacheId) 12097 if (cachedtex.WearableData[i].ID == cacheItems[idx].CacheId)
12105 { 12098 {
12106 12099 cachedresp.WearableData[i].TextureID = cacheItems[idx].TextureID;
12107 cachedresp.WearableData[i].TextureID = item.TextureID; 12100 cacheHits++;
12108 } 12101 }
12109 else 12102 else
12110 { 12103 {
@@ -12124,36 +12117,19 @@ namespace OpenSim.Region.ClientStack.LindenUDP
12124 } 12117 }
12125 } 12118 }
12126 } 12119 }
12127 else 12120 else // no cache
12128 { 12121 {
12129 if (cache == null) 12122 for (int i = 0; i < maxWearablesLoop; i++)
12130 { 12123 {
12131 for (int i = 0; i < maxWearablesLoop; i++) 12124 cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
12132 { 12125 cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex;
12133 cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock(); 12126 cachedresp.WearableData[i].TextureID = UUID.Zero;
12134 cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex; 12127 cachedresp.WearableData[i].HostName = new byte[0];
12135 cachedresp.WearableData[i].TextureID = UUID.Zero;
12136 //UUID.Parse("8334fb6e-c2f5-46ee-807d-a435f61a8d46");
12137 cachedresp.WearableData[i].HostName = new byte[0];
12138 }
12139 }
12140 else
12141 {
12142 for (int i = 0; i < maxWearablesLoop; i++)
12143 {
12144 cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
12145 cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex;
12146
12147 if (cache.GetCached(cachedresp.WearableData[i].TextureID.ToString()) == null)
12148 cachedresp.WearableData[i].TextureID = UUID.Zero;
12149 //UUID.Parse("8334fb6e-c2f5-46ee-807d-a435f61a8d46");
12150// else
12151// cachedresp.WearableData[i].TextureID = UUID.Zero;
12152 // UUID.Parse("8334fb6e-c2f5-46ee-807d-a435f61a8d46");
12153 cachedresp.WearableData[i].HostName = new byte[0];
12154 }
12155 } 12128 }
12156 } 12129 }
12130
12131 m_log.DebugFormat("texture cached: hits {0}", cacheHits);
12132
12157 cachedresp.Header.Zerocoded = true; 12133 cachedresp.Header.Zerocoded = true;
12158 OutPacket(cachedresp, ThrottleOutPacketType.Task); 12134 OutPacket(cachedresp, ThrottleOutPacketType.Task);
12159 12135