Пример #1
0
        /// <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>
 /// Function to set the current geometry shader on the pipeline.
 /// </summary>
 /// <param name="geometryShader">The geometry shader to assign.</param>
 /// <returns>The fluent interface for this builder.</returns>
 public GorgonPipelineStateBuilder GeometryShader(GorgonGeometryShader geometryShader)
 {
     _workState.GeometryShader = geometryShader;
     return(this);
 }