public bool ProcessImageQueue(int packetsToSend) { int StartTime = Util.EnvironmentTickCount(); int packetsSent = 0; while (packetsSent < packetsToSend) { J2KImage image = GetHighestPriorityImage(); // If null was returned, the texture priority queue is currently empty if (image == null) { return(false); } if (image.IsDecoded) { int sent; bool imageDone = image.SendPackets(m_client, packetsToSend - packetsSent, out sent); packetsSent += sent; // If the send is complete, destroy any knowledge of this transfer if (imageDone) { RemoveImageFromQueue(image); } } else { // TODO: This is a limitation of how LLImageManager is currently // written. Undecoded textures should not be going into the priority // queue, because a high priority undecoded texture will clog up the // pipeline for a client return(true); } } int EndTime = Util.EnvironmentTickCountSubtract(StartTime); IMonitorModule module = m_client.Scene.RequestModuleInterface <IMonitorModule>(); if (module != null) { IImageFrameTimeMonitor monitor = (IImageFrameTimeMonitor)module.GetMonitor(m_client.Scene.RegionInfo.RegionID.ToString(), "Images Frame Time"); monitor.AddImageTime(EndTime); } return(m_priorityQueue.Count > 0); }
public bool ProcessImageQueue(int packetsToSend) { int packetsSent = 0; while (packetsSent < packetsToSend) { J2KImage image = GetHighestPriorityImage(); // If null was returned, the texture priority queue is currently empty if (image == null) { break; } if (image.IsDecoded) { int sent; bool imageDone = image.SendPackets(Client, packetsToSend - packetsSent, out sent); packetsSent += sent; // If the send is complete, destroy any knowledge of this transfer if (imageDone) { RemoveImageFromQueue(image); } } else { // TODO: This is a limitation of how LLImageManager is currently // written. Undecoded textures should not be going into the priority // queue, because a high priority undecoded texture will clog up the // pipeline for a client // m_log.DebugFormat( // "[LL IMAGE MANAGER]: Exiting image queue processing early on encountering undecoded image {0}", // image.TextureID); break; } } // if (packetsSent != 0) // m_log.DebugFormat("[LL IMAGE MANAGER]: Processed {0} packets from image queue", packetsSent); return(m_priorityQueue.Count > 0); }
public bool ProcessImageQueue(int packetsToSend) { int packetsSent = 0; while (packetsSent < packetsToSend) { J2KImage image = GetHighestPriorityImage(); // If null was returned, the texture priority queue is currently empty if (image == null) { return(false); } image.CheckDoFirstUpdate(); if (image.IsDecoded) { int sent; bool imageDone = image.SendPackets(m_client, packetsToSend - packetsSent, out sent); packetsSent += sent; // If the send is complete, destroy any knowledge of this transfer if (imageDone) { RemoveImageFromQueue(image); } } else { // TODO: This is a limitation of how LLImageManager is currently // written. Undecoded textures should not be going into the priority // queue, because a high priority undecoded texture will clog up the // pipeline for a client return(true); } } return(m_priorityQueue.Count > 0); }
public bool ProcessImageQueue(int packetsToSend) { int StartTime = Util.EnvironmentTickCount(); int packetsSent = 0; List <J2KImage> imagesToReAdd = new List <J2KImage>(); while (packetsSent < packetsToSend) { J2KImage image = GetHighestPriorityImage(); // If null was returned, the texture priority queue is currently empty if (image == null) { break; //Break so that we add any images back that we might remove because they arn't finished decoding } if (image.IsDecoded) { if (image.Layers == null) { //We don't have it, tell the client that it doesn't exist m_client.SendAssetUploadCompleteMessage((sbyte)AssetType.Texture, false, image.TextureID); RemoveImageFromQueue(image); packetsSent++; } else { int sent; bool imageDone = image.SendPackets(m_client, packetsToSend - packetsSent, out sent); packetsSent += sent; // If the send is complete, destroy any knowledge of this transfer if (imageDone) { RemoveImageFromQueue(image); } } } else { //Add it to the other queue and delete it from the top imagesToReAdd.Add(image); m_priorityQueue.DeleteMax(); packetsSent++; //We tried to send one // UNTODO: This was a limitation of how LLImageManager is currently // written. Undecoded textures should not be going into the priority // queue, because a high priority undecoded texture will clog up the // pipeline for a client //return true; } } //Add all the ones we removed so that we wouldn't block the queue if (imagesToReAdd.Count != 0) { foreach (J2KImage image in imagesToReAdd) { this.AddImageToQueue(image); } } int EndTime = Util.EnvironmentTickCountSubtract(StartTime); IMonitorModule module = m_client.Scene.RequestModuleInterface <IMonitorModule>(); if (module != null) { IImageFrameTimeMonitor monitor = (IImageFrameTimeMonitor)module.GetMonitor(m_client.Scene.RegionInfo.RegionID.ToString(), "Images Frame Time"); monitor.AddImageTime(EndTime); } return(m_priorityQueue.Count > 0); }
public void ProcessImageQueue(int count) { // this can happen during Close() if (m_client == null) { return; } //Count is the number of textures we want to process in one go. //As part of this class re-write, that number will probably rise //since we're processing in a more efficient manner. int numCollected = 0; //Calculate our threshold int threshold; if (m_lastloopprocessed == 0) { if (m_client.PacketHandler == null || m_client.PacketHandler.PacketQueue == null || m_client.PacketHandler.PacketQueue.TextureThrottle == null) { return; } //This is decent for a semi fast machine, but we'll calculate it more accurately based on time below threshold = m_client.PacketHandler.PacketQueue.TextureThrottle.Current / 6300; m_lastloopprocessed = DateTime.Now.Ticks; } else { double throttleseconds = ((double)DateTime.Now.Ticks - (double)m_lastloopprocessed) / (double)TimeSpan.TicksPerSecond; throttleseconds = throttleseconds * m_client.PacketHandler.PacketQueue.TextureThrottle.Current; //Average of 1000 bytes per packet throttleseconds = throttleseconds / 1000; //Safe-zone multiplier of 2.0 threshold = (int)(throttleseconds * 2.0); m_lastloopprocessed = DateTime.Now.Ticks; } if (threshold < 10) { threshold = 10; } if (m_client.PacketHandler == null) { return; } if (m_client.PacketHandler.PacketQueue == null) { return; } //First of all make sure our packet queue isn't above our threshold //Uncomment this to see what the texture stack is doing //m_log.Debug("Queue: " + m_client.PacketHandler.PacketQueue.TextureOutgoingPacketQueueCount.ToString() + " Threshold: " + threshold.ToString() + " outstanding: " + m_outstandingtextures.ToString()); if (m_client.PacketHandler.PacketQueue.TextureOutgoingPacketQueueCount < threshold && m_outstandingtextures > 0) { bool justreset = false; for (int x = m_priorities.Count - 1; x > -1; x--) { J2KImage imagereq = m_imagestore[m_priorities.Values[x]]; if (imagereq.m_decoded == true && !imagereq.m_completedSendAtCurrentDiscardLevel) { numCollected++; //SendPackets will send up to ten packets per cycle if (imagereq.SendPackets(m_client)) { //Send complete if (!imagereq.m_completedSendAtCurrentDiscardLevel) { imagereq.m_completedSendAtCurrentDiscardLevel = true; m_outstandingtextures--; //Re-assign priority to bottom //Remove the old priority m_priorities.Remove(imagereq.m_designatedPriorityKey); int lowest; if (m_priorities.Count > 0) { lowest = (int)m_priorities.Keys[0]; lowest--; } else { lowest = -10000; } m_priorities.Add((double)lowest, imagereq.m_requestedUUID); imagereq.m_designatedPriorityKey = (double)lowest; if (m_priorityresolver.ContainsKey((int)lowest)) { m_priorityresolver[(int)lowest]++; } else { m_priorityresolver.Add((int)lowest, 0); } } } if (numCollected == count) { break; } } if (numCollected == count || m_outstandingtextures == 0) { break; } if (numCollected % m_outstandingtextures == 0 && !justreset) { //We've gotten as much as we can from the stack, //reset to the top so that we can send MOAR DATA (nomnomnom)! x = m_priorities.Count - 1; justreset = true; //prevents us from getting stuck in a loop } } } }