Exemple #1
0
        internal ShaderPipeline GetShaderPipeline(Shader vertex, Shader tescontrol, Shader teseval, Shader geometry,
                                                  Shader fragment, Shader compute)
        {
            ShaderPipelineDescription desc = new ShaderPipelineDescription()
            {
                Vertex                = vertex,
                TesselationControl    = tescontrol,
                TesselationEvaluation = teseval,
                Geometry              = geometry,
                Fragment              = fragment,
                Compute               = compute
            };

            if (_pipelines.ContainsKey(desc))
            {
                return(_pipelines[desc]);
            }

            ShaderPipeline pipeline = new ShaderPipeline(desc);

            _pipelines.Add(desc, pipeline);

            desc.Vertex?.Pipelines.Add(pipeline);
            desc.TesselationControl?.Pipelines.Add(pipeline);
            desc.TesselationEvaluation?.Pipelines.Add(pipeline);
            desc.Geometry?.Pipelines.Add(pipeline);
            desc.Fragment?.Pipelines.Add(pipeline);
            desc.Compute?.Pipelines.Add(pipeline);

            return(pipeline);
        }
Exemple #2
0
 /// <summary>
 /// Creates a new graphics pipeline
 /// </summary>
 /// <param name="device">Glob device</param>
 /// <param name="vertex">Vertex shader</param>
 /// <param name="tesselationControl">Tesselation control shader - can be null</param>
 /// <param name="tesselationEvaluation">Tesselation evaluation shader - can be null</param>
 /// <param name="geometry">Geometry shader - can be null</param>
 /// <param name="fragment">Fragment shader</param>
 /// <param name="vertexFormat">Vertex buffer format - can be null</param>
 /// <param name="rasterizerState">Rasterization state - cull face and polygon mode</param>
 /// <param name="depthState">Depth state - depth test func and depth mask</param>
 /// <param name="blendState">Blend state - color/alpha blending mode - can be null</param>
 public GraphicsPipeline(Device device, Shader vertex, Shader fragment, Shader tesselationControl, Shader tesselationEvaluation, Shader geometry, VertexBufferFormat vertexFormat, RasterizerState rasterizerState, DepthState depthState, BlendState blendState = null)
 {
     _device          = device;
     _shaderPipeline  = _device.ShaderRepository.GetShaderPipeline(vertex, tesselationControl, tesselationEvaluation, geometry, fragment, null);
     _vertexFormat    = vertexFormat;
     _rasterizerState = rasterizerState;
     _depthState      = depthState;
     _blendState      = blendState;
     if (_blendState == null)
     {
         _blendState = new BlendState();
     }
 }
Exemple #3
0
 /// <summary>
 /// Changes all current states to null, so any future bind or state change will effectively skip redundant state change checks and should execute its OpenGL calls.
 /// </summary>
 public void Invalidate()
 {
     ShaderPipeline = null;
     _textureUnit.Invalidate();
     _currentRasterizerState = null;
     _currentDepthState      = null;
     _currentBlendState      = null;
     _boundReadFramebuffer   = -1;
     _boundDrawFramebuffer   = -1;
     _boundBothFramebuffer   = -1;
     _boundVertexFormat      = null;
     _boundVertexSource      = null;
     _bufferBindingManager.Invalidate();
 }
Exemple #4
0
 public ComputePipeline(Device device, Shader compute)
 {
     _shaderPipeline = device.ShaderRepository.GetShaderPipeline(null, null, null, null, null, compute);
 }