示例#1
0
 private void EmitVertexInputsGetter(ShaderSetProcessorInput input, CsCodeWriter ccw)
 {
     using (ccw.PushBlock($"public static VertexInputDescription[] GetVertexInputs()"))
     {
         ccw.WriteLine($"return new VertexInputDescription[]");
         using (ccw.PushBlock(null, ";"))
         {
             ccw.WriteLine("new VertexInputDescription(");
             ccw.IncreaseIndentation();
             ParameterDefinition[] vsParams = input.VertexFunction.Parameters;
             foreach (ParameterDefinition param in vsParams)
             {
                 StructureDefinition sd = input.Model.GetStructureDefinition(param.Type);
                 foreach (FieldDefinition fd in sd.Fields)
                 {
                     string              name     = fd.Name;
                     VertexSemanticType  semantic = GetSemantic(fd.SemanticType);
                     VertexElementFormat format   = GetFormat(fd.Type);
                     ccw.Write($"new VertexInputElement(\"{name}\", VertexSemanticType.{semantic}, VertexElementFormat.{format})");
                     if (fd == sd.Fields.Last())
                     {
                         ccw.WriteLine(")");
                     }
                     else
                     {
                         ccw.WriteLine(",");
                     }
                 }
             }
             ccw.DecreaseIndentation();
         }
     }
 }
 /// <summary>
 /// Constructs a new MaterialVertexInputElement.
 /// </summary>
 public VertexInputElement(string name, VertexSemanticType semanticType, VertexElementFormat format)
 {
     Name              = name;
     SemanticType      = semanticType;
     ElementFormat     = format;
     SizeInBytes       = GetSizeInBytes(format);
     StorageClassifier = VertexElementInputClass.PerVertex;
     InstanceStepRate  = 0;
 }
示例#3
0
 /// <summary>Constructs a new MaterialVertexInputElement</summary>
 public MaterialVertexInputElement(
     string name,
     VertexSemanticType semanticType,
     VertexElementFormat format,
     VertexElementInputClass inputClass,
     int stepRate)
 {
     Name              = name;
     SemanticType      = semanticType;
     ElementFormat     = format;
     SizeInBytes       = GetSizeInBytes(format);
     StorageClassifier = inputClass;
     InstanceStepRate  = stepRate;
 }
示例#4
0
        private static string GetSemanticName(VertexSemanticType semanticType)
        {
            switch (semanticType)
            {
            case VertexSemanticType.Position:
                return("POSITION");

            case VertexSemanticType.TextureCoordinate:
                return("TEXCOORD");

            case VertexSemanticType.Normal:
                return("NORMAL");

            case VertexSemanticType.Color:
                return("COLOR");

            default:
                throw Illegal.Value <VertexSemanticType>();
            }
        }
示例#5
0
            public int GetAndIncrement(VertexSemanticType type)
            {
                switch (type)
                {
                case VertexSemanticType.Position:
                    return(_position++);

                case VertexSemanticType.TextureCoordinate:
                    return(_texCoord++);

                case VertexSemanticType.Normal:
                    return(_normal++);

                case VertexSemanticType.Color:
                    return(_color++);

                default:
                    throw Illegal.Value <VertexSemanticType>();
                }
            }