示例#1
0
        /// <summary>Initializes a new instance of the <see cref="GraphicsPipeline" /> class.</summary>
        /// <param name="device">The device for which the pipeline is being created.</param>
        /// <param name="signature">The signature which details the inputs given and resources available to the pipeline.</param>
        /// <param name="vertexShader">The vertex shader for the pipeline or <c>null</c> if none exists.</param>
        /// <param name="pixelShader">The pixel shader for the pipeline or <c>null</c> if none exists.</param>
        /// <exception cref="ArgumentNullException"><paramref name="device" /> is <c>null</c>.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="signature" /> is <c>null</c>.</exception>
        /// <exception cref="ArgumentOutOfRangeException">The kind of <paramref name="vertexShader" /> is not <see cref="GraphicsShaderKind.Vertex" />.</exception>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="vertexShader" /> was not created for <paramref name="device" />.</exception>
        /// <exception cref="ArgumentOutOfRangeException">The kind of <paramref name="pixelShader" /> is not <see cref="GraphicsShaderKind.Pixel" />.</exception>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="pixelShader" /> was not created for <paramref name="device" />.</exception>
        protected GraphicsPipeline(GraphicsDevice device, GraphicsPipelineSignature signature, GraphicsShader?vertexShader, GraphicsShader?pixelShader)
            : base(device)
        {
            ThrowIfNull(signature, nameof(signature));

            if (vertexShader is not null)
            {
                if (vertexShader.Kind != GraphicsShaderKind.Vertex)
                {
                    ThrowForInvalidKind(vertexShader.Kind, nameof(vertexShader), GraphicsShaderKind.Vertex);
                }

                if (vertexShader.Device != device)
                {
                    ThrowForInvalidParent(vertexShader.Device, nameof(vertexShader));
                }
            }

            if (pixelShader is not null)
            {
                if (pixelShader.Kind != GraphicsShaderKind.Pixel)
                {
                    ThrowForInvalidKind(pixelShader.Kind, nameof(pixelShader), GraphicsShaderKind.Pixel);
                }

                if (pixelShader.Device != device)
                {
                    ThrowForInvalidParent(pixelShader.Device, nameof(pixelShader));
                }
            }

            _signature    = signature;
            _vertexShader = vertexShader;
            _pixelShader  = pixelShader;
        }
示例#2
0
        /// <summary>Initializes a new instance of the <see cref="GraphicsPipeline" /> class.</summary>
        /// <param name="device">The device for which the pipeline was created.</param>
        /// <param name="signature">The signature which details the inputs given and resources available to the pipeline.</param>
        /// <param name="vertexShader">The vertex shader for the pipeline or <c>null</c> if none exists.</param>
        /// <param name="pixelShader">The pixel shader for the pipeline or <c>null</c> if none exists.</param>
        /// <exception cref="ArgumentNullException"><paramref name="device" /> is <c>null</c>.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="signature" /> is <c>null</c>.</exception>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="vertexShader" /> is not <see cref="GraphicsShaderKind.Vertex"/>.</exception>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="vertexShader" /> was not created for <paramref name="device" />.</exception>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="pixelShader" /> is not <see cref="GraphicsShaderKind.Pixel"/>.</exception>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="pixelShader" />was not created for <paramref name="device" />.</exception>
        protected GraphicsPipeline(GraphicsDevice device, GraphicsPipelineSignature signature, GraphicsShader?vertexShader, GraphicsShader?pixelShader)
        {
            ThrowIfNull(device, nameof(device));
            ThrowIfNull(signature, nameof(signature));

            if ((vertexShader != null) && ((vertexShader.Kind != GraphicsShaderKind.Vertex) || (vertexShader.Device != device)))
            {
                ThrowArgumentOutOfRangeException(nameof(vertexShader), vertexShader);
            }

            if ((pixelShader != null) && ((pixelShader.Kind != GraphicsShaderKind.Pixel) || (pixelShader.Device != device)))
            {
                ThrowArgumentOutOfRangeException(nameof(pixelShader), pixelShader);;
            }

            _device       = device;
            _signature    = signature;
            _vertexShader = vertexShader;
            _pixelShader  = pixelShader;
        }
示例#3
0
 /// <summary>Creates a new graphics pipeline for the device.</summary>
 /// <param name="signature">The signature which details the inputs given and resources available to the graphics pipeline.</param>
 /// <param name="vertexShader">The vertex shader for the graphics pipeline or <c>null</c> if none exists.</param>
 /// <param name="pixelShader">The pixel shader for the graphics pipeline or <c>null</c> if none exists.</param>
 /// <returns>A new graphics pipeline created for the device.</returns>
 /// <exception cref="ArgumentNullException"><paramref name="signature" /> is <c>null</c>.</exception>
 /// <exception cref="ArgumentOutOfRangeException"><paramref name="vertexShader" /> is not <see cref="GraphicsShaderKind.Vertex"/>.</exception>
 /// <exception cref="ArgumentOutOfRangeException"><paramref name="vertexShader" /> was not created for this device.</exception>
 /// <exception cref="ArgumentOutOfRangeException"><paramref name="pixelShader" /> is not <see cref="GraphicsShaderKind.Pixel"/>.</exception>
 /// <exception cref="ArgumentOutOfRangeException"><paramref name="pixelShader" /> was not created for this device.</exception>
 /// <exception cref="ObjectDisposedException">The device has been disposed.</exception>
 public abstract GraphicsPipeline CreatePipeline(GraphicsPipelineSignature signature, GraphicsShader?vertexShader = null, GraphicsShader?pixelShader = null);