Example #1
0
 public CGeometryShader(ICDevice device, CShaderReflection reflection)
     : base(device, reflection)
 {
     maxVertexCount = Reflection.GetMaxVertexCount();
     inputPrimitiveType = Reflection.GetGeometryInputPrimitiveType();
     outputPrimitiveType = Reflection.GetGeometryOutputPrimitiveType();
 }
Example #2
0
 public CDomainShader(ICDevice device, CShaderReflection reflection)
     : base(device, reflection)
 {
     glShadersToGeometry = new TightConcurrentDictionary<TesselationLayout, TesselationEvaluationShader>(TesselationLayout.Equal);
     glShadersToPixel = new TightConcurrentDictionary<TesselationLayout, TesselationEvaluationShader>(TesselationLayout.Equal);
     domain = Reflection.GetTesselationDomain();
 }
Example #3
0
 public CHullShader(ICDevice device, CShaderReflection reflection)
     : base(device, reflection)
 {
     domain = reflection.GetTesselationDomain();
     partitioning = reflection.GetTesselationPartitioning();
     outputTopology = reflection.GetTesselationOutputTopology();
     outputControlPoints = reflection.GetOutputControlPoints();
     maxTesselationFactor = reflection.GetMaxTesselationFactor();
 }
Example #4
0
 public CPixelShader(ICDevice device, CShaderReflection reflection)
     : base(device, reflection)
 {
     Profile = ParseProfile(Reflection.Profile);
     var text = GenerateText<CPixelShader>(WriteIOAndCode);
     CompilationResult bytecode;
     try
     {
         bytecode = ShaderBytecode.Compile(text, "main", ProfileToString(Profile),
             ShaderFlags.PackMatrixColumnMajor | ShaderFlags.OptimizationLevel3, EffectFlags.None, Name);
     }
     catch (Exception e)
     {
         throw new ArgumentException(string.Format("Failed to compile a pixel shader '{0}'\r\n--- Code ---\r\n{1}\r\n--- Errors ---\r\n{2}", Name, text, e.Message), e);
     }
     D3DPixelShader = new PixelShader(device.D3DDevice, bytecode);
 }
Example #5
0
        public CPixelShader(ICDevice device, CShaderReflection reflection)
            : base(device, reflection)
        {
            profile = ParseProfile(reflection.Profile);

            var text = GenerateText();
            try
            {
                var bytecode = ShaderBytecode.Compile(text, "main", ProfileToString(profile), ShaderFlags.PackMatrixColumnMajor | ShaderFlags.OptimizationLevel3);
                d3dShader = new PixelShader(device.D3DDevice, bytecode);
                bytecode.Dispose();
            }
            catch (Exception e)
            {
                throw new ArgumentException(string.Format("Failed to compile a pixel shader '{0}'\r\n--- Code ---\r\n{1}\r\n--- Errors ---\r\n{2}", Name, text, e.Message), e);
            }
        }
Example #6
0
 public CVertexShader(ICDevice device, CShaderReflection reflection)
     : base(device, reflection)
 {
     Profile = ParseProfile(Reflection.Profile);
     var text = GenerateText<CVertexShader>(WriteIOAndCode);
     try
     {
         Bytecode = ShaderBytecode.Compile(text, "main", ProfileToString(Profile),
             ShaderFlags.PackMatrixColumnMajor | ShaderFlags.OptimizationLevel3, EffectFlags.None, Name);
     }
     catch (Exception e)
     {
         throw new ArgumentException(string.Format("Failed to compile a vertex shader '{0}'\r\n--- Code ---\r\n{1}\r\n--- Errors ---\r\n{2}", Name, text, e.Message), e);
     }
     D3DVertexShader = new VertexShader(device.D3DDevice, Bytecode);
     D3DInputElementsDraft = CreateVertexElementsDraft(reflection);
 }
Example #7
0
        public CGeometryShader(ICDevice device, CShaderReflection reflection)
            : base(device, reflection)
        {
            Profile = ParseProfile(reflection.Profile);
            MaxVertexCount = reflection.GetMaxVertexCount();
            InputPrimitiveType = reflection.GetGeometryInputPrimitiveType();
            OutputPrimitiveType = reflection.GetGeometryOutputPrimitiveType();

            var text = GenerateText<CGeometryShader>(WriteIOAndCode);
            CompilationResult bytecode;
            try
            {
                bytecode = ShaderBytecode.Compile(text, "main", ProfileToString(Profile),
                    ShaderFlags.PackMatrixColumnMajor | ShaderFlags.OptimizationLevel3, EffectFlags.None, Name);
            }
            catch (Exception e)
            {
                throw new ArgumentException(string.Format("Failed to compile a geometry shader '{0}'\r\n--- Code ---\r\n{1}\r\n--- Errors ---\r\n{2}", Name, text, e.Message), e);
            }
            D3DGeometryShader = new GeometryShader(device.D3DDevice, bytecode);
        }
Example #8
0
        public CHullShader(ICDevice device, CShaderReflection reflection)
            : base(device, reflection)
        {
            Profile = ParseProfile(reflection.Profile);
            Domain = reflection.GetTesselationDomain();
            Partitioning = reflection.GetTesselationPartitioning();
            OutputTopology = reflection.GetTesselationOutputTopology();
            InputControlPoints = reflection.GetInputControlPoints();
            OutputControlPoints = reflection.GetOutputControlPoints();
            MaxTesselationFactor = reflection.GetMaxTesselationFactor();

            var text = GenerateText<CHullShader>(WriteIOAndCode);
            CompilationResult bytecode;
            try
            {
                bytecode = ShaderBytecode.Compile(text, "main", ProfileToString(Profile),
                    ShaderFlags.PackMatrixColumnMajor | ShaderFlags.OptimizationLevel3, EffectFlags.None, Name);
            }
            catch (Exception e)
            {
                throw new ArgumentException(string.Format("Failed to compile a hull shader '{0}'\r\n--- Code ---\r\n{1}\r\n--- Errors ---\r\n{2}", Name, text, e.Message), e);
            }
            D3DHullShader = new HullShader(device.D3DDevice, bytecode);
        }
Example #9
0
 public CVertexShader(ICDevice device, CShaderReflection reflection)
     : base(device, reflection)
 {
     attributeNames = Reflection.Input.Where(v => v.IsUsed && !v.IsSystem).Select(v => OutputPrefixForStage(ShaderStage.Vertex) + v.Semantic).ToArray();
 }
Example #10
0
 public CComputeShader(ICDevice device, CShaderReflection reflection)
     : base(device, reflection)
 {
 }
Example #11
0
 static List<Pair<InputElement, int>> CreateVertexElementsDraft(CShaderReflection reflection)
 {
     var vertexElementsDraft = new List<Pair<InputElement, int>>();
     int bElementIndex = 0;
     foreach (var variable in reflection.Input)
     {
         if (variable.IsUsed)
         {
             for (int i = 0; i < variable.LayoutElementsRequired; i++)
             {
                 vertexElementsDraft.Add(new Pair<InputElement, int>(new InputElement
                 {
                     SemanticName = variable.Semantic,
                     SemanticIndex = i
                 }, bElementIndex));
             }
         }
         bElementIndex++;
     }
     return vertexElementsDraft;
 }
Example #12
0
 public CPixelShader(ICDevice device, CShaderReflection reflection)
     : base(device, reflection)
 {
 }
Example #13
0
 static List<Pair<VertexElement, int>> CreateVertexElementsDraft(CShaderReflection reflection)
 {
     var vertexElementsDraft = new List<Pair<VertexElement, int>>();
     int bElementIndex = 0;
     foreach (var variable in reflection.Input)
     {
         if (variable.IsUsed)
         {
             for (int i = 0; i < variable.LayoutElementsRequired; i++)
             {
                 vertexElementsDraft.Add(new Pair<VertexElement, int>(new VertexElement
                 {
                     Method = 0,
                     Usage = variable.Usage,
                     UsageIndex = variable.UsageIndex
                 }, bElementIndex));
             }
         }
         bElementIndex++;
     }
     return vertexElementsDraft;
 }