/// <summary> /// Function to convert this geometry shader to use a stream output. /// </summary> /// <param name="streamOutLayout">The stream output layout for the shader.</param> /// <param name="strides">[Optional] A list of strides that define the size of an element for each buffer.</param> /// <returns>A new <see cref="GorgonGeometryShader"/> that is capable of stream output.</returns> /// <exception cref="ArgumentNullException">Thrown when the <paramref name="streamOutLayout"/> parameter is <b>null</b>.</exception> /// <remarks> /// <para> /// A base geometry shader must be converted to use stream output if an application wants to send data from the shader into a buffer. /// </para> /// <para> /// If the <paramref name="strides"/> parameter is supplied, then it will be limited to 4 items at most, any more than that and the list will be truncated. /// </para> /// </remarks> public GorgonGeometryShader ToStreamOut(GorgonStreamOutLayout streamOutLayout, IEnumerable <int> strides = null) { if (streamOutLayout == null) { throw new ArgumentNullException(nameof(streamOutLayout)); } int[] strideList = strides?.Take(4).ToArray() ?? Array.Empty <int>(); // Clone the byte code just in case we decide to destroy the original. var byteCode = new ShaderBytecode(D3DByteCode.Data); Graphics.Log.Print($"Converting '{Name}' to Stream-Out.", LoggingLevel.Verbose); var shader = new D3D11.GeometryShader(Graphics.D3DDevice, byteCode, streamOutLayout.Native, strideList, 0) { DebugName = $"{Name}_ID3D11GeometryShader (SO)" }; var result = new GorgonGeometryShader(Graphics, Name + " (SO)", IsDebug, byteCode, shader) { StreamOutLayout = streamOutLayout }; result.RegisterDisposable(Graphics); return(result); }
/// <summary>Indicates whether the current object is equal to another object of the same type.</summary> /// <returns>true if the current object is equal to the <paramref name="layout" /> parameter; otherwise, false.</returns> /// <param name="layout">An object to compare with this object.</param> public bool Equals(GorgonStreamOutLayout layout) { if (layout?._elements.Length != _elements.Length) { return(false); } for (int i = 0; i < _elements.Length; ++i) { if (!GorgonStreamOutElement.Equals(in _elements[i], in layout._elements[i])) { return(false); } } return(true); }