/// <summary>
        /// Function to determine if an element already exists with the same context, index and slot.
        /// </summary>
        /// <param name="elements">The list of elements to compare against.</param>
        /// <param name="element">The element to search for.</param>
        /// <param name="index">The index of the current element.</param>
        /// <param name="parameterName">The name of the parameter being validated.</param>
        private static void FindDuplicateElements(IList <GorgonStreamOutElement> elements, GorgonStreamOutElement element, int index, string parameterName)
        {
            for (int i = 0; i < elements.Count; ++i)
            {
                // Skip the element that we're testing against.
                if (index == i)
                {
                    continue;
                }

                GorgonStreamOutElement currentElement = elements[i];

                if (GorgonStreamOutElement.Equals(in currentElement, in element))
                {
                    throw new ArgumentException(string.Format(Resources.GORGFX_ERR_LAYOUT_ELEMENT_IN_USE, i, element.Context), parameterName);
                }
            }
        }
        /// <summary>
        /// Function to convert this input layout into a <see cref="GorgonStreamOutLayout"/>
        /// </summary>
        /// <param name="stream">[Optional] The output stream to use.</param>
        /// <param name="slot">[Optional] The associated stream output buffer that is bound to the pipeline.</param>
        /// <returns>A new <see cref="GorgonStreamOutLayout"/> derived from this input layout.</returns>
        /// <remarks>
        /// <para>
        /// When streaming data out from the GPU, the layout of that data must be defined as a <see cref="GorgonStreamOutLayout"/>, which is quite similar to an input layout. For convenience, this method
        /// will create a new <see cref="GorgonStreamOutLayout"/> that uses the same semantics as the input layout.
        /// </para>
        /// </remarks>
        /// <seealso cref="GorgonStreamOutLayout"/>
        public GorgonStreamOutLayout ToStreamOutLayout(int stream = 0, byte slot = 0)
        {
            var elements = new GorgonStreamOutElement[_elements.Length];

            for (int i = 0; i < _elements.Length; ++i)
            {
                // Only allow 64 elements.
                if (i > 64)
                {
                    break;
                }

                GorgonInputElement inputElement = _elements[i];

                var info = new GorgonFormatInfo(inputElement.Format);

                elements[i] = new GorgonStreamOutElement(inputElement.Context, 0, (byte)info.ComponentCount, slot, inputElement.Index, stream);
            }

            return(new GorgonStreamOutLayout(Name + " (SO)", elements));
        }