Ejemplo n.º 1
0
        private ShaderDataTypeFull _parseShaderType()
        {
            var precision = ShaderPrecisionQualifier.None;

            while (true)
            {
                var typeToken = _takeToken();
                if (!(typeToken is TokenWord wordType))
                {
                    throw new ShaderParseException("Expected type or precision", typeToken?.Position);
                }

                if (_shaderTypePrecisionMap.TryGetValue(wordType.Word, out var tmprc))
                {
                    precision = tmprc;
                    continue;
                }

                if (_shaderTypeMap.TryGetValue(wordType.Word, out var ret))
                {
                    var result = new ShaderDataTypeFull(ret, precision);
                    if (!result.TypePrecisionConsistent())
                    {
                        throw new ShaderParseException($"Type {ret} cannot accept precision {precision}", wordType.Position);
                    }
                    return(result);
                }

                throw new ShaderParseException("Expected type or precision", wordType.Position);
            }
        }
Ejemplo n.º 2
0
 public ShaderFunctionDefinition(string name, ShaderDataTypeFull returnType,
                                 IReadOnlyList <ShaderFunctionParameter> parameters, string body)
 {
     Name       = name;
     ReturnType = returnType;
     Parameters = parameters;
     Body       = body;
 }
Ejemplo n.º 3
0
 public ShaderVaryingDefinition(string name, ShaderDataTypeFull type)
 {
     Name = name;
     Type = type;
 }
Ejemplo n.º 4
0
 public ShaderFunctionParameter(string name, ShaderDataTypeFull type, ShaderParameterQualifiers qualifiers)
 {
     Name       = name;
     Type       = type;
     Qualifiers = qualifiers;
 }
Ejemplo n.º 5
0
 public ShaderConstantDefinition(string name, ShaderDataTypeFull type, string value)
 {
     Name  = name;
     Type  = type;
     Value = value;
 }
Ejemplo n.º 6
0
 public ShaderUniformDefinition(string name, ShaderDataTypeFull type, string?defaultValue)
 {
     Name         = name;
     Type         = type;
     DefaultValue = defaultValue;
 }