Esempio n. 1
0
        public void ReleaseModelSlot(int slotIndex)
        {
            ModelRendererSlot selectedSlot = null;

            foreach (var slot in modelSlotMapping)
            {
                if (slot.Value.Slot == slotIndex)
                {
                    selectedSlot = slot.Value;
                    break;
                }
            }

            if (selectedSlot == null)
            {
                throw new ArgumentOutOfRangeException("slotIndex", "Invalid slot");
            }

            if (--selectedSlot.ReferenceCount == 0)
            {
                // Release the slot if no other reference points to it (add it in free list)
                if (!modelSlotMapping.Remove(selectedSlot.EffectName))
                {
                    throw new InvalidOperationException("Model slot not found while trying to remove it.");
                }
                availableModelSlots.Enqueue(selectedSlot);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Gets or creates a mesh pass slot for this pass inside its <see cref="RenderPipeline" />.
        /// </summary>
        /// <param name="effectName">Name of the effect.</param>
        /// <returns>ModelRendererSlot.</returns>
        public int AllocateModelSlot(string effectName)
        {
            ModelRendererSlot modelRendererSlot;
            if (!modelSlotMapping.TryGetValue(effectName, out modelRendererSlot))
            {
                // First, check free list, otherwise create a new slot
                if (availableModelSlots.Count > 0)
                {
                    modelRendererSlot = availableModelSlots.Dequeue();
                    modelRendererSlot.EffectName = effectName;
                    modelSlotMapping[effectName] = modelRendererSlot;
                }
                else
                    modelSlotMapping[effectName] = modelRendererSlot = new ModelRendererSlot(effectName, modelSlotMapping.Count);
            }

            modelRendererSlot.ReferenceCount++;
            return modelRendererSlot.Slot;
        }
Esempio n. 3
0
        /// <summary>
        /// Gets or creates a mesh pass slot for this pass inside its <see cref="RenderPipeline" />.
        /// </summary>
        /// <param name="effectName">Name of the effect.</param>
        /// <returns>ModelRendererSlot.</returns>
        public int AllocateModelSlot(string effectName)
        {
            ModelRendererSlot modelRendererSlot;

            if (!modelSlotMapping.TryGetValue(effectName, out modelRendererSlot))
            {
                // First, check free list, otherwise create a new slot
                if (availableModelSlots.Count > 0)
                {
                    modelRendererSlot            = availableModelSlots.Dequeue();
                    modelRendererSlot.EffectName = effectName;
                    modelSlotMapping[effectName] = modelRendererSlot;
                }
                else
                {
                    modelSlotMapping[effectName] = modelRendererSlot = new ModelRendererSlot(effectName, modelSlotMapping.Count);
                }
            }

            modelRendererSlot.ReferenceCount++;
            return(modelRendererSlot.Slot);
        }