Ejemplo n.º 1
0
 public bool IsIntrinsic(ShaderAttributes attributes)
 {
     return(attributes.Contains(typeof(Shader.IntrinsicFunction)) || attributes.Contains(typeof(Shader.SimpleIntrinsicFunction)) || attributes.Contains(typeof(Shader.SimpleExtensionIntrinsic)) ||
            attributes.Contains(typeof(Math.CompositeConstruct)) || attributes.Contains(typeof(Math.Swizzle)) ||
            attributes.Contains(typeof(Shader.ImageIntrinsicFunction)) || attributes.Contains(typeof(Shader.SampledImageIntrinsicFunction)) ||
            attributes.Contains(typeof(Shader.ArrayGetIntrinsic)) || attributes.Contains(typeof(Shader.ArraySetIntrinsic)));
 }
Ejemplo n.º 2
0
        public ShaderAttributes Clone()
        {
            var result = new ShaderAttributes();

            foreach (var attribute in Attributes)
            {
                result.Add(attribute.Clone());
            }
            return(result);
        }
        public ShaderType CreatePrimitiveShaderType(INamedTypeSymbol typeSymbol, ShaderAttributes attributes)
        {
            ShaderType shaderType = null;

            // If there's a special resolver for this type then use that to get the shader type
            foreach (var attribute in typeSymbol.GetAttributes())
            {
                var attributeName = TypeAliases.GetFullTypeName(attribute.AttributeClass);
                var processor     = SpecialResolvers.SpecialTypeCreationAttributeProcessors.GetValueOrDefault(attributeName);
                shaderType = processor?.Invoke(mFrontEnd, typeSymbol, attribute);
                if (shaderType != null)
                {
                    return(shaderType);
                }
            }
            throw new Exception("Failed to create primitive");
        }
Ejemplo n.º 4
0
        public ShaderAttributes ParseAttributes(ISymbol symbol)
        {
            var shaderAttributes = new ShaderAttributes();

            foreach (var attribute in symbol.GetAttributes())
            {
                var shaderAttribute = new ShaderAttribute();
                shaderAttributes.Add(shaderAttribute);
                shaderAttribute.Name      = TypeAliases.GetTypeName(attribute.AttributeClass);
                shaderAttribute.Attribute = attribute;

                foreach (var argument in attribute.ConstructorArguments)
                {
                    var shaderAttributeParam = new ShaderAttributeParameter();
                    shaderAttribute.Parameters.Add(shaderAttributeParam);
                    if (argument.Kind != TypedConstantKind.Array)
                    {
                        shaderAttributeParam.Value = argument.Value;
                    }
                }
                foreach (var argument in attribute.NamedArguments)
                {
                    var shaderAttributeParam = new ShaderAttributeParameter();
                    shaderAttribute.Parameters.Add(shaderAttributeParam);
                    shaderAttributeParam.Name  = argument.Key;
                    shaderAttributeParam.Value = argument.Value.Value;
                }

                if (TypeAliases.GetFullTypeName(attribute.AttributeClass) == TypeAliases.GetFullTypeName <Shader.Input>())
                {
                    var inputAttributes = new List <TypeName>
                    {
                        TypeAliases.GetTypeName <Shader.FragmentInput>(),
                        TypeAliases.GetTypeName <Shader.StageInput>(),
                        TypeAliases.GetTypeName <Shader.AppBuiltInInput>(),
                        TypeAliases.GetTypeName <Shader.HardwareBuiltInInput>(),
                        TypeAliases.GetTypeName <Shader.PropertyInput>(),
                    };
                    foreach (var inputAttribute in inputAttributes)
                    {
                        var clone = shaderAttribute.Clone();
                        clone.Name = inputAttribute;
                        shaderAttributes.Add(clone);
                    }
                }
                if (TypeAliases.GetFullTypeName(attribute.AttributeClass) == TypeAliases.GetFullTypeName <Shader.Output>())
                {
                    var outputAttributes = new List <TypeName>
                    {
                        TypeAliases.GetTypeName <Shader.FragmentOutput>(),
                        TypeAliases.GetTypeName <Shader.StageOutput>(),
                        TypeAliases.GetTypeName <Shader.HardwareBuiltInOutput>(),
                    };
                    foreach (var outputAttribute in outputAttributes)
                    {
                        var clone = shaderAttribute.Clone();
                        clone.Name = outputAttribute;
                        shaderAttributes.Add(clone);
                    }
                }
            }
            return(shaderAttributes);
        }