diff options
author | Justin Clark-Casey (justincc) | 2012-09-06 22:12:05 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-09-06 22:12:05 +0100 |
commit | 8f02fd926e14dfad7f5eb77a67a6701f449511e0 (patch) | |
tree | 08e15f6bb44ff84027c278c51bb55a22951d5ecd /OpenSim/Region/CoreModules/Scripting/DynamicTexture | |
parent | Added missing configs, and deleted the [Profile] part on the Hypergrind config. (diff) | |
download | opensim-SC_OLD-8f02fd926e14dfad7f5eb77a67a6701f449511e0.zip opensim-SC_OLD-8f02fd926e14dfad7f5eb77a67a6701f449511e0.tar.gz opensim-SC_OLD-8f02fd926e14dfad7f5eb77a67a6701f449511e0.tar.bz2 opensim-SC_OLD-8f02fd926e14dfad7f5eb77a67a6701f449511e0.tar.xz |
If reusing dynamic textures, do not reuse small data length textures that fall below current viewer discard level 2 thresholds.
Viewer LL 3.3.4 and before sometimes fail to properly redisplay dynamic textures that have a small data length compared to pixel size when pulled from cache.
This appears to happen when the data length is smaller than the estimate discard level 2 size the viewer uses when making this GetTexture request.
This commit works around this by always regenerating dynamic textures that fall below this threshold rather than reusing them if ReuseDynamicTextures = true
This can be controlled by the [Textures] ReuseDynamicLowDataTextures config setting which defaults to false.
Diffstat (limited to 'OpenSim/Region/CoreModules/Scripting/DynamicTexture')
-rw-r--r-- | OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs | 59 |
1 files changed, 49 insertions, 10 deletions
diff --git a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs index e09f1a9..1f340df 100644 --- a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs | |||
@@ -42,7 +42,7 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture | |||
42 | { | 42 | { |
43 | public class DynamicTextureModule : IRegionModule, IDynamicTextureManager | 43 | public class DynamicTextureModule : IRegionModule, IDynamicTextureManager |
44 | { | 44 | { |
45 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
46 | 46 | ||
47 | private const int ALL_SIDES = -1; | 47 | private const int ALL_SIDES = -1; |
48 | 48 | ||
@@ -54,6 +54,17 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture | |||
54 | /// </summary> | 54 | /// </summary> |
55 | public bool ReuseTextures { get; set; } | 55 | public bool ReuseTextures { get; set; } |
56 | 56 | ||
57 | /// <summary> | ||
58 | /// If false, then textures which have a low data size are not reused when ReuseTextures = true. | ||
59 | /// </summary> | ||
60 | /// <remarks> | ||
61 | /// LL viewers 3.3.4 and before appear to not fully render textures pulled from the viewer cache if those | ||
62 | /// textures have a relatively high pixel surface but a small data size. Typically, this appears to happen | ||
63 | /// if the data size is smaller than the viewer's discard level 2 size estimate. So if this is setting is | ||
64 | /// false, textures smaller than the calculation in IsSizeReuseable are always regenerated rather than reused | ||
65 | /// to work around this problem.</remarks> | ||
66 | public bool ReuseLowDataTextures { get; set; } | ||
67 | |||
57 | private Dictionary<UUID, Scene> RegisteredScenes = new Dictionary<UUID, Scene>(); | 68 | private Dictionary<UUID, Scene> RegisteredScenes = new Dictionary<UUID, Scene>(); |
58 | 69 | ||
59 | private Dictionary<string, IDynamicTextureRender> RenderPlugins = | 70 | private Dictionary<string, IDynamicTextureRender> RenderPlugins = |
@@ -83,18 +94,17 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture | |||
83 | /// <summary> | 94 | /// <summary> |
84 | /// Called by code which actually renders the dynamic texture to supply texture data. | 95 | /// Called by code which actually renders the dynamic texture to supply texture data. |
85 | /// </summary> | 96 | /// </summary> |
86 | /// <param name="id"></param> | 97 | /// <param name="updaterId"></param> |
87 | /// <param name="data"></param> | 98 | /// <param name="texture"></param> |
88 | /// <param name="isReuseable">True if the data generated can be reused for subsequent identical requests</param> | 99 | public void ReturnData(UUID updaterId, IDynamicTexture texture) |
89 | public void ReturnData(UUID id, byte[] data, bool isReuseable) | ||
90 | { | 100 | { |
91 | DynamicTextureUpdater updater = null; | 101 | DynamicTextureUpdater updater = null; |
92 | 102 | ||
93 | lock (Updaters) | 103 | lock (Updaters) |
94 | { | 104 | { |
95 | if (Updaters.ContainsKey(id)) | 105 | if (Updaters.ContainsKey(updaterId)) |
96 | { | 106 | { |
97 | updater = Updaters[id]; | 107 | updater = Updaters[updaterId]; |
98 | } | 108 | } |
99 | } | 109 | } |
100 | 110 | ||
@@ -103,11 +113,16 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture | |||
103 | if (RegisteredScenes.ContainsKey(updater.SimUUID)) | 113 | if (RegisteredScenes.ContainsKey(updater.SimUUID)) |
104 | { | 114 | { |
105 | Scene scene = RegisteredScenes[updater.SimUUID]; | 115 | Scene scene = RegisteredScenes[updater.SimUUID]; |
106 | UUID newTextureID = updater.DataReceived(data, scene); | 116 | UUID newTextureID = updater.DataReceived(texture.Data, scene); |
107 | 117 | ||
108 | if (ReuseTextures && isReuseable && !updater.BlendWithOldTexture) | 118 | if (ReuseTextures |
119 | && !updater.BlendWithOldTexture | ||
120 | && texture.IsReuseable | ||
121 | && (ReuseLowDataTextures || IsDataSizeReuseable(texture))) | ||
122 | { | ||
109 | m_reuseableDynamicTextures.Store( | 123 | m_reuseableDynamicTextures.Store( |
110 | GenerateReusableTextureKey(updater.BodyData, updater.Params), newTextureID); | 124 | GenerateReusableTextureKey(texture.InputCommands, texture.InputParams), newTextureID); |
125 | } | ||
111 | } | 126 | } |
112 | } | 127 | } |
113 | 128 | ||
@@ -123,6 +138,27 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture | |||
123 | } | 138 | } |
124 | } | 139 | } |
125 | 140 | ||
141 | /// <summary> | ||
142 | /// Determines whether the texture is reuseable based on its data size. | ||
143 | /// </summary> | ||
144 | /// <remarks> | ||
145 | /// This is a workaround for a viewer bug where very small data size textures relative to their pixel size | ||
146 | /// are not redisplayed properly when pulled from cache. The calculation here is based on the typical discard | ||
147 | /// level of 2, a 'rate' of 0.125 and 4 components (which makes for a factor of 0.5). | ||
148 | /// </remarks> | ||
149 | /// <returns></returns> | ||
150 | private bool IsDataSizeReuseable(IDynamicTexture texture) | ||
151 | { | ||
152 | // Console.WriteLine("{0} {1}", texture.Size.Width, texture.Size.Height); | ||
153 | int discardLevel2DataThreshold = (int)Math.Ceiling((texture.Size.Width >> 2) * (texture.Size.Height >> 2) * 0.5); | ||
154 | |||
155 | // m_log.DebugFormat( | ||
156 | // "[DYNAMIC TEXTURE MODULE]: Discard level 2 threshold {0}, texture data length {1}", | ||
157 | // discardLevel2DataThreshold, texture.Data.Length); | ||
158 | |||
159 | return discardLevel2DataThreshold < texture.Data.Length; | ||
160 | } | ||
161 | |||
126 | public UUID AddDynamicTextureURL(UUID simID, UUID primID, string contentType, string url, | 162 | public UUID AddDynamicTextureURL(UUID simID, UUID primID, string contentType, string url, |
127 | string extraParams, int updateTimer) | 163 | string extraParams, int updateTimer) |
128 | { | 164 | { |
@@ -293,7 +329,10 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture | |||
293 | { | 329 | { |
294 | IConfig texturesConfig = config.Configs["Textures"]; | 330 | IConfig texturesConfig = config.Configs["Textures"]; |
295 | if (texturesConfig != null) | 331 | if (texturesConfig != null) |
332 | { | ||
296 | ReuseTextures = texturesConfig.GetBoolean("ReuseDynamicTextures", false); | 333 | ReuseTextures = texturesConfig.GetBoolean("ReuseDynamicTextures", false); |
334 | ReuseLowDataTextures = texturesConfig.GetBoolean("ReuseDynamicLowDataTextures", false); | ||
335 | } | ||
297 | 336 | ||
298 | if (!RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID)) | 337 | if (!RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID)) |
299 | { | 338 | { |