Пример #1
0
        /// <summary>
        /// Function to set a single stream output buffer.
        /// </summary>
        /// <param name="buffer">Buffer to set.</param>
        /// <remarks>Stream output buffers are only used by the <see cref="GorgonLibrary.Graphics.GorgonOutputGeometryShader">GorgonOutputGeometryShader</see> object.  If the currently bound shader 
        /// is not an output geometry shader, then any values set here will be ignored.</remarks>
        public void SetStreamOutputBuffer(GorgonOutputBufferBinding buffer)
        {
            if ((_bindings != null) && (GorgonOutputBufferBinding.Equals(ref buffer, ref _bindings[0])))
            {
                return;
            }

            if ((_bindings == null) || (_bindings.Length != 1))
            {
                _bindings = null;
                _D3Dbindings = null;

                if (!buffer.Equals(GorgonOutputBufferBinding.Empty))
                {
                    _bindings = new GorgonOutputBufferBinding[1];
                    _D3Dbindings = new D3D.StreamOutputBufferBinding[1];
                }
            }

            if ((_bindings != null) && (_D3Dbindings != null))
            {
                _bindings[0] = buffer;
                _D3Dbindings[0] = buffer.Convert();

                Graphics.Context.StreamOutput.SetTargets(_D3Dbindings);
            }
            else
            {
                Graphics.Context.StreamOutput.SetTargets(null);
            }
        }
Пример #2
0
        /// <summary>
        /// Function to retrieve the list of output buffers bound to the pipeline.
        /// </summary>
        /// <returns>An array of output buffers.</returns>
        public GorgonOutputBufferBinding[] GetOutputBuffers()
        {
            var result = new GorgonOutputBufferBinding[_bindings == null ? 0 : _bindings.Length];

            if ((_bindings != null) && (_bindings.Length != 0))
            {
                _bindings.CopyTo(result, 0);
            }

            return result;
        }
Пример #3
0
        /// <summary>
        /// Function to set a list of stream output buffers at the same time.
        /// </summary>
        /// <param name="buffers">Buffers to bind.</param>
        /// <remarks>Stream output buffers are only used by the <see cref="GorgonLibrary.Graphics.GorgonOutputGeometryShader">GorgonOutputGeometryShader</see> object.  If the currently bound shader 
        /// is not an output geometry shader, then any values set here will be ignored.</remarks>
        public void SetStreamOutputBuffers(GorgonOutputBufferBinding[] buffers)
        {
            bool hasChanged = false;

            // If we didn't pass any buffers, then unbind everything.
            if ((buffers == null) || (buffers.Length == 0))
            {
                if (_bindings == null)
                {
                    return;
                }

                Graphics.Context.StreamOutput.SetTargets(null);
                _bindings = null;
                _D3Dbindings = null;

                return;
            }

            if ((_bindings == null) || (_bindings.Length != buffers.Length))
            {
                _bindings = new GorgonOutputBufferBinding[buffers.Length];
                _D3Dbindings = new D3D.StreamOutputBufferBinding[buffers.Length];
                hasChanged = true;
            }

            // Copy.
            for (int i = 0; i < _bindings.Length; i++)
            {
                var buffer = buffers[i];

                if (GorgonOutputBufferBinding.Equals(ref _bindings[i], ref buffer))
                {
                    continue;
                }

                hasChanged = true;
                _bindings[i] = buffer;
                _D3Dbindings[i] = buffer.Convert();
            }

            if (hasChanged)
            {
                Graphics.Context.StreamOutput.SetTargets(_D3Dbindings);
            }
        }