示例#1
0
        /// <summary>
        /// Analyzes the shader source code and go to definition.
        /// </summary>
        /// <param name="shaderSource">The shader source.</param>
        /// <param name="location">The location.</param>
        /// <param name="shaderDirectories">The shader directories.</param>
        /// <returns>ShaderNavigationResult.</returns>
        /// <exception cref="System.ArgumentNullException">shaderSource</exception>
        /// <exception cref="System.ArgumentException">Expecting a FileSource location;location</exception>
        public ShaderNavigationResult AnalyzeAndGoToDefinition(string shaderSource, SiliconStudio.Shaders.Ast.SourceLocation location, List<string> shaderDirectories)
        {
            if (shaderSource == null) throw new ArgumentNullException("shaderSource");
            var navigationResult = new ShaderNavigationResult();
            if (location.FileSource == null)
            {
                throw new ArgumentException("Expecting a FileSource location", "location");
            }

            try
            {
                if (location.FileSource.EndsWith(".xksl", StringComparison.CurrentCultureIgnoreCase))
                {
                    AnalyzeAndGoToDefinition(shaderSource, location, shaderDirectories, navigationResult);
                }

                // If any of the messages have empty filesource, add a default filesource
                foreach (var message in navigationResult.Messages.Messages)
                {
                    if (string.IsNullOrWhiteSpace(message.Span.Location.FileSource))
                    {
                        message.Span.Location.FileSource = location.FileSource;
                    }
                }
            }
            catch (Exception ex)
            {
                navigationResult.Messages.Error(MessageCode.ErrorUnexpectedException, GetSpan(location), ex);
            }

            return navigationResult;
        }
示例#2
0
        /// <summary>
        /// Preprocesses and parses the specified source.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="sourceFileName">Name of the source file.</param>
        /// <param name="macros">The macros defined for the preprocessor.</param>
        /// <param name="includeDirectories">The include directories used by the preprocessor..</param>
        /// <returns>Result of parsing</returns>
        public static ParsingResult TryPreProcessAndParse(string source, string sourceFileName, SiliconStudio.Shaders.Parser.ShaderMacro[] macros = null, params string[] includeDirectories)
        {

            var result = ShaderParser.GetParser<XenkoGrammar>().TryPreProcessAndParse(source, sourceFileName, macros, includeDirectories);
            PrepareShader(result.Shader);
            return result;
        }
 /// <summary>
 /// Explore the ShaderSource and add the necessary shaders
 /// </summary>
 /// <param name="shaderSource">the ShaderSource to explore</param>
 /// <param name="macros">the macros used</param>
 /// <returns></returns>
 public HashSet<ModuleMixinInfo> LoadShaderSource(ShaderSource shaderSource, SiliconStudio.Shaders.Parser.ShaderMacro[] macros)
 {
     var mixinsToAnalyze = new HashSet<ModuleMixinInfo>();
     ExtendLibrary(shaderSource, macros, mixinsToAnalyze);
     ReplaceMixins(mixinsToAnalyze); // no longer replace mixin, redo analysis everytime since there is no way to correctly detect something changed
     return mixinsToAnalyze;
 }
示例#4
0
 public static Color4 Convert(SiliconStudio.Core.Mathematics.Color4 color)
 {
     var temp = new Color4();
     unsafe
     {
         *((SiliconStudio.Core.Mathematics.Color4*)&temp) = color;
     }
     return temp;
 }
 /// <summary>
 /// Tests the equality of the macro sets.
 /// </summary>
 /// <param name="macros0">The first set of macros.</param>
 /// <param name="macros1">The second set of macros.</param>
 /// <returns>True if the sets match, false otherwise.</returns>
 private static bool AreMacrosEqual(SiliconStudio.Shaders.Parser.ShaderMacro[] macros0, SiliconStudio.Shaders.Parser.ShaderMacro[] macros1)
 {
     return macros0.All(macro => macros1.Any(x => x.Name == macro.Name && x.Definition == macro.Definition)) && macros1.All(macro => macros0.Any(x => x.Name == macro.Name && x.Definition == macro.Definition));
 }
 /// <summary>
 /// Adds a stream usage to the current method
 /// </summary>
 /// <param name="variable">the stream Variable</param>
 /// <param name="expression">the calling expression</param>
 /// <param name="usage">the encountered usage</param>
 private void AddStreamUsage(Variable variable, SiliconStudio.Shaders.Ast.Expression expression, StreamUsage usage)
 {
     currentStreamUsageList.Add(new StreamUsageInfo { CallType = StreamCallType.Member, Variable = variable, Expression = expression, Usage = usage });
 }
示例#7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TexImage"/> class.
        /// </summary>
        /// <param name="data">The data.</param>
        /// <param name="dataSize">Size of the data.</param>
        /// <param name="width">The width.</param>
        /// <param name="height">The height.</param>
        /// <param name="depth">The depth.</param>
        /// <param name="format">The format.</param>
        /// <param name="mipmapCount">The mipmap count.</param>
        /// <param name="arraySize">Size of the array.</param>
        /// <param name="dimension">The dimension.</param>
        /// <param name="faceCount">The face count (multiple of 6 if Texture Cube, 1 otherwise).</param>
        public TexImage(IntPtr data, int dataSize, int width, int height, int depth, SiliconStudio.Paradox.Graphics.PixelFormat format, int mipmapCount, int arraySize, TextureDimension dimension, int faceCount = 1)
        {
            Data = data;
            DataSize = dataSize;
            Width = width;
            Height = height;
            Depth = depth;
            Format = format;
            MipmapCount = mipmapCount;
            ArraySize = arraySize;
            Dimension = dimension;
            FaceCount = faceCount;
            Name = "";

            int imageCount;
            if (Dimension == TexImage.TextureDimension.Texture3D)
            {
                int subImagePerArrayElementCount = 0;
                int curDepth = Depth;
                for (int i = 0; i < MipmapCount; ++i)
                {
                    subImagePerArrayElementCount += curDepth;
                    curDepth = curDepth > 1 ? curDepth >>= 1 : curDepth;
                }

                imageCount = (int)(ArraySize * FaceCount * subImagePerArrayElementCount);
            }
            else
            {
                imageCount = (int)(ArraySize * FaceCount * MipmapCount);
            }

            SubImageArray = new SubImage[imageCount];
            int ct = 0;
            int rowPitch, slicePitch, curHeight, curWidth;

            Tools.ComputePitch(Format, Width, Height, out rowPitch, out slicePitch);
            RowPitch = rowPitch;
            SlicePitch = slicePitch;

            for (uint i = 0; i < FaceCount; ++i)
            {
                for (uint j = 0; j < ArraySize; ++j)
                {
                    depth = Depth;
                    for (uint k = 0; k < MipmapCount; ++k)
                    {
                        curWidth = Width;
                        curHeight = Height;
                        Tools.ComputePitch(Format, curWidth, curHeight, out rowPitch, out slicePitch);

                        for (int l = 0; l < depth; ++l)
                        {
                            SubImageArray[ct] = new TexImage.SubImage();
                            SubImageArray[ct].Width = curWidth;
                            SubImageArray[ct].Height = curHeight;
                            SubImageArray[ct].RowPitch = rowPitch;
                            SubImageArray[ct].SlicePitch = slicePitch;
                            SubImageArray[ct].DataSize = slicePitch;
                            SubImageArray[ct].Data = new IntPtr(Data.ToInt64() + l * slicePitch);
                            ++ct;
                        }
                        depth = depth > 1 ? depth >>= 1 : depth;
                    }
                }
            }

            LibraryData = new Dictionary<ITexLibrary, ITextureLibraryData>();

            Disposed = false;
        }
示例#8
0
 private bool IsExpressionMatching(Node astNode, SiliconStudio.Shaders.Ast.SourceLocation location)
 {
     var span = astNode.Span;
     var startColumn = span.Location.Column;
     var endColumn = startColumn + span.Length;
     if (astNode.Span.Location.Line == location.Line && location.Column >= startColumn)
     {
         if (location.Column >= startColumn && location.Column <= endColumn)
         {
             return true;
         }
     }
     return false;
 }
示例#9
0
 private EPVRTColourSpace RetrieveNativeColorSpace(SiliconStudio.Paradox.Graphics.PixelFormat format)
 {
     return format.IsSRgb() ? EPVRTColourSpace.ePVRTCSpaceSRgb : EPVRTColourSpace.ePVRTCSpacelRGB;
 }
示例#10
0
        /// <summary>
        /// Build the ModuleMixinInfo class
        /// </summary>
        /// <param name="shaderSource">the ShaderSource to load</param>
        /// <param name="macros">the macros applied on the source</param>
        /// <returns>the ModuleMixinInfo</returns>
        private ModuleMixinInfo BuildMixinInfo(ShaderSource shaderSource, SiliconStudio.Shaders.Parser.ShaderMacro[] macros)
        {
            ModuleMixinInfo mixinInfo = null;
            
            if (shaderSource is ShaderClassSource)
            {
                var shaderClassSource = shaderSource as ShaderClassSource;
                mixinInfo = new ModuleMixinInfo { ShaderSource = shaderClassSource, Macros = macros };
                LoadMixinFromClassSource(mixinInfo);
            }
            else if (shaderSource is ShaderMixinSource)
            {
                var shaderMixinSource = shaderSource as ShaderMixinSource;

                var shaderName = "Mix" + lastMixIndex;
                ++lastMixIndex;
                var fakeAst = new ShaderClassType(shaderName);
                foreach (var classSource in shaderMixinSource.Mixins)
                {
                    Identifier name;
                    if (classSource.GenericArguments != null && classSource.GenericArguments.Length > 0)
                        name = new IdentifierGeneric(classSource.ClassName, classSource.GenericArguments.Select(x => new Identifier(x.ToString())).ToArray());
                    else
                        name = new Identifier(classSource.ClassName);

                    fakeAst.BaseClasses.Add(new TypeName(name));
                }

                mixinInfo = new ModuleMixinInfo
                    {
                        MixinGenericName = shaderName,
                        Macros = macros, 
                        MixinAst = fakeAst, 
                        ShaderSource =  shaderSource,
                        SourceHash = ObjectId.FromBytes(Encoding.UTF8.GetBytes(shaderName)), 
                        Instanciated = true
                    };
            }

            return mixinInfo;
        }
示例#11
0
        /// <summary>
        /// Merge the set of macros in the mixin. The top level macros are always overidden by the child's ones (the one defined in the current ShaderMixinSource).
        /// Also update the macros of the mixin.
        /// </summary>
        /// <param name="mixin">The mixin that will be looked at with the macros.</param>
        /// <param name="macros">The external macros.</param>
        /// <returns>An array with all the macros</returns>
        private SiliconStudio.Shaders.Parser.ShaderMacro[] MergeMacroSets(ShaderMixinSource mixin, SiliconStudio.Shaders.Parser.ShaderMacro[] macros)
        {
            var newMacros = new List<SiliconStudio.Shaders.Parser.ShaderMacro>();

            // get the parent macros
            foreach (var macro in macros)
            {
                newMacros.RemoveAll(x => x.Name == macro.Name);
                newMacros.Add(macro);
            }

            // override with child macros, the mixin's ones
            foreach (var macro in mixin.Macros)
            {
                newMacros.RemoveAll(x => x.Name == macro.Name);
                var tempMacro = new SiliconStudio.Shaders.Parser.ShaderMacro(macro.Name, macro.Definition);
                newMacros.Add(tempMacro);
            }

            mixin.Macros = newMacros.Select(x => new ShaderMacro(x.Name, x.Definition)).ToList();
            return newMacros.ToArray();
        }
示例#12
0
 /// <summary>
 /// Determines whether this requested format is supported.
 /// </summary>
 /// <param name="format">The format.</param>
 /// <returns>
 ///     <c>true</c> if the formats is supported; otherwise, <c>false</c>.
 /// </returns>
 private bool SupportFormat(SiliconStudio.Paradox.Graphics.PixelFormat format)
 {
     return ((int) (format) >= 1 && (int) (format) <= 115);
 }
示例#13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ConvertingRequest"/> class.
 /// </summary>
 /// <param name="format">The destination format.</param>
 public ConvertingRequest(SiliconStudio.Xenko.Graphics.PixelFormat format)
 {
     this.Format = format;
 }
示例#14
0
 /// <summary>
 /// Determines whether this requested format is supported.
 /// </summary>
 /// <param name="format">The format.</param>
 /// <returns>
 ///     <c>true</c> if the formats is supported; otherwise, <c>false</c>.
 /// </returns>
 public bool SupportFormat(SiliconStudio.Paradox.Graphics.PixelFormat format)
 {
     switch (format)
     {
         case SiliconStudio.Paradox.Graphics.PixelFormat.R8G8B8A8_UNorm:
         case SiliconStudio.Paradox.Graphics.PixelFormat.B8G8R8A8_UNorm:
         case SiliconStudio.Paradox.Graphics.PixelFormat.ATC_RGB:
         case SiliconStudio.Paradox.Graphics.PixelFormat.ATC_RGBA_Explicit:
         case SiliconStudio.Paradox.Graphics.PixelFormat.ATC_RGBA_Interpolated:
             return true;
         default:
             return false;
     }
 }
示例#15
0
 /// <summary>
 /// Retrieves the native format from <see cref="SiliconStudio.Paradox.Graphics.PixelFormat"/>.
 /// </summary>
 /// <param name="format">The format.</param>
 /// <returns>the corresponding <see cref="Format"/> format</returns>
 private Format RetrieveNativeFormat(SiliconStudio.Paradox.Graphics.PixelFormat format)
 {
     switch (format)
     {
         case SiliconStudio.Paradox.Graphics.PixelFormat.R8G8B8A8_UNorm:
         case SiliconStudio.Paradox.Graphics.PixelFormat.B8G8R8A8_UNorm:
             return Format.ATI_TC_FORMAT_ARGB_8888;
         case SiliconStudio.Paradox.Graphics.PixelFormat.ATC_RGB:
             return Format.ATI_TC_FORMAT_ATC_RGB;
         case SiliconStudio.Paradox.Graphics.PixelFormat.ATC_RGBA_Explicit:
             return Format.ATI_TC_FORMAT_ATC_RGBA_Explicit;
         case SiliconStudio.Paradox.Graphics.PixelFormat.ATC_RGBA_Interpolated:
             return Format.ATI_TC_FORMAT_ATC_RGBA_Interpolated;
         default:
             throw new TextureToolsException("UnHandled compression format by ATI texture.");
     }
 }
示例#16
0
 private EPVRTColourSpace RetrieveNativeColorSpace(SiliconStudio.Paradox.Graphics.PixelFormat format)
 {
     switch (format)
     {
         case SiliconStudio.Paradox.Graphics.PixelFormat.R8G8B8A8_UNorm_SRgb:
             return EPVRTColourSpace.ePVRTCSpaceSRgb;
         default:
             return EPVRTColourSpace.ePVRTCSpacelRGB;
     }
 }
示例#17
0
        private void AnalyzeAndGoToDefinition(string shaderSource, SiliconStudio.Shaders.Ast.SourceLocation location, List<string> shaderDirectories, ShaderNavigationResult result)
        {
            // We are not using the storage when loading shaders from VS but directly the filesystem
            var mixer = new ShaderMixinParser(null);
            mixer.SourceManager.UseFileSystem = true;
            mixer.AllowNonInstantiatedGenerics = true;
            mixer.SourceManager.LookupDirectoryList.AddRange(shaderDirectories);

            var shaderSourceName = Path.GetFileNameWithoutExtension(location.FileSource);
            mixer.SourceManager.AddShaderSource(shaderSourceName, shaderSource, location.FileSource);

            var mixinSource = new ShaderMixinSource();
            mixinSource.Mixins.Add(new ShaderClassSource(shaderSourceName));

            ShaderMixinParsingResult parsingResult;
            HashSet<ModuleMixinInfo> moduleMixins;
            var mixerResult = mixer.ParseAndAnalyze(mixinSource, null, out parsingResult, out moduleMixins);

            // Copy shader analysis to result
            parsingResult.CopyTo(result.Messages);

            if (mixerResult == null)
            {
                return;
            }

            var mixin = mixerResult.MixinInfos.FirstOrDefault(item => item.MixinName == shaderSourceName);

            if (mixin == null)
            {
                result.Messages.Error(ErrorMixinNotFound, GetSpan(location), shaderSourceName);
                return;
            }

            // If first line, first column, this is not a go to definition but only parsing request, so return directly
            if (location.Line == 1 && location.Column == 1)
            {
                return;
            }

            // var ast = mixin.MixinAst;

            var parsingInfo = mixin.Mixin.ParsingInfo;

            var pools = new List<ReferencesPool>
                {
                    parsingInfo.ClassReferences,
                    parsingInfo.StaticReferences,
                    parsingInfo.ExternReferences,
                    parsingInfo.StageInitReferences,
                };

            foreach (var pool in pools)
            {
                var span = Find(pool, location);
                if (span.HasValue)
                {
                    result.DefinitionLocation = span.Value;
                    return;
                }
            }

            // Else Try to find from remaining navigable nodes
            foreach (var node in parsingInfo.NavigableNodes)
            {
                if (IsExpressionMatching(node, location))
                {
                    var typeReferencer = node as ITypeInferencer;
                    if (typeReferencer != null && typeReferencer.TypeInference != null && typeReferencer.TypeInference.Declaration != null)
                    {
                        var declarationNode = (Node)typeReferencer.TypeInference.Declaration;
                        result.DefinitionLocation = declarationNode.Span;
                        break;
                    }
                }
            }
        }
示例#18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CompressingRequest"/> class.
 /// </summary>
 /// <param name="format">The compression format.</param>
 public CompressingRequest(SiliconStudio.Xenko.Graphics.PixelFormat format, TextureQuality quality = TextureQuality.Fast)
 {
     this.Format = format;
     this.Quality = quality;
 }
示例#19
0
 /// <summary>
 /// Explore the ShaderSource and add the necessary shaders
 /// </summary>
 /// <param name="shaderSource">the ShaderSource to explore</param>
 /// <param name="macros">the macros used</param>
 private void ExtendLibrary(ShaderSource shaderSource, SiliconStudio.Shaders.Parser.ShaderMacro[] macros, HashSet<ModuleMixinInfo> mixinToAnalyze)
 {
     if (shaderSource is ShaderMixinSource)
     {
         var newMacros = MergeMacroSets((ShaderMixinSource)shaderSource, macros);
         mixinToAnalyze.Add(GetModuleMixinInfo(shaderSource, newMacros));
         foreach (var composition in ((ShaderMixinSource)shaderSource).Compositions)
             ExtendLibrary(composition.Value, newMacros, mixinToAnalyze);
     }
     else if (shaderSource is ShaderClassSource)
         mixinToAnalyze.Add(GetModuleMixinInfo(shaderSource, macros));
     else if (shaderSource is ShaderArraySource)
     {
         foreach (var shader in ((ShaderArraySource)shaderSource).Values)
             ExtendLibrary(shader, macros, mixinToAnalyze);
     }
 }
示例#20
0
 private static void CopyLogs(SiliconStudio.Shaders.Utility.LoggerResult inputLog, LoggerResult outputLog)
 {
     foreach (var inputMessage in inputLog.Messages)
     {
         var logType = LogMessageType.Info;
         switch (inputMessage.Level)
         {
             case ReportMessageLevel.Error:
                 logType = LogMessageType.Error;
                 break;
             case ReportMessageLevel.Info:
                 logType = LogMessageType.Info;
                 break;
             case ReportMessageLevel.Warning:
                 logType = LogMessageType.Warning;
                 break;
         }
         var outputMessage = new LogMessage(inputMessage.Span.ToString(), logType, string.Format(" {0}: {1}", inputMessage.Code, inputMessage.Text));
         outputLog.Log(outputMessage);
     }
     outputLog.HasErrors = inputLog.HasErrors;
 }
示例#21
0
        /// <summary>
        /// Get the ModuleMixinInfo based on the ShaderSource and the macros. Creates the needed shader if necessary
        /// </summary>
        /// <param name="shaderSource">the ShaderSource</param>
        /// <param name="macros">the macros</param>
        /// <param name="macrosString">the name of the macros</param>
        /// <returns>ModuleMixinInfo.</returns>
        private ModuleMixinInfo GetModuleMixinInfo(ShaderSource shaderSource, SiliconStudio.Shaders.Parser.ShaderMacro[] macros, string macrosString = null)
        {
            if (macros == null)
                macros = new SiliconStudio.Shaders.Parser.ShaderMacro[0];

            if (macrosString == null)
            {
                macrosString =  string.Join(",", macros.OrderBy(x => x.Name));
            }

            List<ModuleMixinInfo> context;
            if (!mapMacrosToMixins.TryGetValue(macrosString, out context))
            {
                context = new List<ModuleMixinInfo>();
                mapMacrosToMixins.Add(macrosString, context);
            }

            var mixinInfo = context.FirstOrDefault(x => x.AreEqual(shaderSource, macros));
            if (mixinInfo == null)
            {
                mixinInfo = BuildMixinInfo(shaderSource, macros);

                if (mixinInfo.Instanciated)
                {
                    MixinInfos.Add(mixinInfo);
                    mapMacrosToMixins[macrosString].Add(mixinInfo);

                    mixinInfo.MinimalContext.Add(mixinInfo);

                    if (!mixinInfo.Log.HasErrors)
                    {
                        LoadNecessaryShaders(mixinInfo, macros, macrosString);
                    }
                    mixinInfo.MinimalContext = new HashSet<ModuleMixinInfo>(mixinInfo.MinimalContext.Distinct());
                }
            }

            return mixinInfo;
        }
示例#22
0
        public ModuleMixinInfo Copy(SiliconStudio.Shaders.Parser.ShaderMacro[] macros)
        {
            var mixinInfo = new ModuleMixinInfo();
            mixinInfo.ShaderSource = ShaderSource;
            mixinInfo.MixinAst = MixinAst;
            mixinInfo.MixinGenericName = MixinGenericName;
            mixinInfo.Mixin = Mixin;
            mixinInfo.Instanciated = Instanciated;
            mixinInfo.HashPreprocessSource = HashPreprocessSource;
            mixinInfo.Macros = macros;

            return mixinInfo;
        }
示例#23
0
        /// <summary>
        /// Loads generic classes that may appear in the mixin
        /// </summary>
        /// <param name="mixinInfo">The mixin to investigate</param>
        /// <param name="macros">The macros.</param>
        /// <param name="macrosString">The macros string.</param>
        private void LoadNecessaryShaders(ModuleMixinInfo mixinInfo, SiliconStudio.Shaders.Parser.ShaderMacro[] macros, string macrosString)
        {
            if (!mixinInfo.Instanciated)
                return;

            // Look for all the generic calls
            var shaderDependencyVisitor = new ShaderDependencyVisitor(mixinInfo.Log, ShaderLoader.SourceManager);
            shaderDependencyVisitor.Run(mixinInfo.MixinAst);

            foreach (var foundClass in shaderDependencyVisitor.FoundClasses)
            {
                var classSource = new ShaderClassSource(foundClass, null);
                var foundMixinInfo = GetModuleMixinInfo(classSource, macros, macrosString);
                mixinInfo.MinimalContext.UnionWith(foundMixinInfo.MinimalContext);
            }

            foreach (var id in shaderDependencyVisitor.FoundIdentifiers)
            {
                var genericClass = id.Item1;
                ModuleMixinInfo.CleanIdentifiers(genericClass.Identifiers);
                var genericParams = BuildShaderGenericParameters(genericClass);
                var classSource = new ShaderClassSource(genericClass.Text, genericParams);

                var instanciatedClassInfo = GetModuleMixinInfo(classSource, macros, macrosString);
                mixinInfo.MinimalContext.UnionWith(instanciatedClassInfo.MinimalContext);

                var newId = new Identifier(instanciatedClassInfo.MixinName);
                if (id.Item2 is TypeName) // in the baseclass list or in a variable declaration
                    (id.Item2 as TypeName).Name = newId;
                else if (id.Item2 is VariableReferenceExpression)
                    (id.Item2 as VariableReferenceExpression).Name = newId;
                else if (id.Item2 is MemberReferenceExpression)
                    (id.Item2 as MemberReferenceExpression).Member = newId;
            }
        }
示例#24
0
 /// <summary>
 /// Preprocesses and parses the specified source.
 /// </summary>
 /// <param name="sourceFileName">Name of the source file.</param>
 /// <param name="macros">The macros defined for the preprocessor.</param>
 /// <param name="includeDirectories">The include directories used by the preprocessor..</param>
 /// <returns>Result of parsing</returns>
 public static Shader PreProcessAndParse(string sourceFileName, SiliconStudio.Shaders.Parser.ShaderMacro[] macros = null, params string[] includeDirectories)
 {
     return PreProcessAndParse(File.ReadAllText(sourceFileName), sourceFileName, macros, includeDirectories);
 }
示例#25
0
        /// <summary>
        /// Determines whether the specified compression format is supported by this library
        /// </summary>
        /// <param name="format">The format.</param>
        /// <returns>
        ///     <c>true</c> if the formats is supported by this library; otherwise, <c>false</c>.
        /// </returns>
        private bool SupportFormat(SiliconStudio.Paradox.Graphics.PixelFormat format)
        {
            switch (format)
            {
                case SiliconStudio.Paradox.Graphics.PixelFormat.R32G32B32A32_Float:
                case SiliconStudio.Paradox.Graphics.PixelFormat.R32G32B32_Float:
                case SiliconStudio.Paradox.Graphics.PixelFormat.R32G32B32A32_UInt:
                case SiliconStudio.Paradox.Graphics.PixelFormat.R32G32B32_UInt:
                case SiliconStudio.Paradox.Graphics.PixelFormat.R32G32B32A32_SInt:
                case SiliconStudio.Paradox.Graphics.PixelFormat.R32G32B32_SInt:
                case SiliconStudio.Paradox.Graphics.PixelFormat.R16G16B16A16_UNorm:
                case SiliconStudio.Paradox.Graphics.PixelFormat.R16G16B16A16_UInt:
                case SiliconStudio.Paradox.Graphics.PixelFormat.R16G16B16A16_SNorm:
                case SiliconStudio.Paradox.Graphics.PixelFormat.R16G16B16A16_SInt:
                case SiliconStudio.Paradox.Graphics.PixelFormat.R8G8B8A8_UNorm_SRgb:
                case SiliconStudio.Paradox.Graphics.PixelFormat.R8G8B8A8_UNorm:
                case SiliconStudio.Paradox.Graphics.PixelFormat.R8G8B8A8_UInt:
                case SiliconStudio.Paradox.Graphics.PixelFormat.R8G8B8A8_SNorm:
                case SiliconStudio.Paradox.Graphics.PixelFormat.R8G8B8A8_SInt:
                case SiliconStudio.Paradox.Graphics.PixelFormat.B8G8R8A8_UNorm_SRgb:
                case SiliconStudio.Paradox.Graphics.PixelFormat.B8G8R8A8_UNorm:

                case SiliconStudio.Paradox.Graphics.PixelFormat.PVRTC_2bpp_RGB:
                case SiliconStudio.Paradox.Graphics.PixelFormat.PVRTC_2bpp_RGBA:
                case SiliconStudio.Paradox.Graphics.PixelFormat.PVRTC_4bpp_RGB:
                case SiliconStudio.Paradox.Graphics.PixelFormat.PVRTC_4bpp_RGBA:
                case SiliconStudio.Paradox.Graphics.PixelFormat.PVRTC_II_2bpp:
                case SiliconStudio.Paradox.Graphics.PixelFormat.PVRTC_II_4bpp:
                case SiliconStudio.Paradox.Graphics.PixelFormat.ETC1:
                case SiliconStudio.Paradox.Graphics.PixelFormat.ETC2_RGB:
                case SiliconStudio.Paradox.Graphics.PixelFormat.ETC2_RGBA:
                case SiliconStudio.Paradox.Graphics.PixelFormat.ETC2_RGB_A1:
                case SiliconStudio.Paradox.Graphics.PixelFormat.EAC_R11_Unsigned:
                case SiliconStudio.Paradox.Graphics.PixelFormat.EAC_R11_Signed:
                case SiliconStudio.Paradox.Graphics.PixelFormat.EAC_RG11_Unsigned:
                case SiliconStudio.Paradox.Graphics.PixelFormat.EAC_RG11_Signed:
                    return true;
                default:
                    return false;
            }
        }
示例#26
0
        private SourceSpan? Find(ReferencesPool pool, SiliconStudio.Shaders.Ast.SourceLocation location)
        {
            foreach (var methodRef in pool.MethodsReferences)
            {
                foreach (var expression in methodRef.Value)
                {
                    if (IsExpressionMatching(expression, location))
                    {
                        return methodRef.Key.Span;
                    }
                }
            }

            foreach (var variableRef in pool.VariablesReferences)
            {
                foreach (var expression in variableRef.Value)
                {
                    if (IsExpressionMatching(expression.Expression, location))
                    {
                        return variableRef.Key.Span;
                    }
                }
            }
            return null;
        }
示例#27
0
 /// <summary>
 /// Retrieves the native format from <see cref="SiliconStudio.Paradox.Graphics.PixelFormat"/>.
 /// </summary>
 /// <param name="format">The format.</param>
 /// <returns>The corresponding <see cref="DXGI_FORMAT"/></returns>
 private DXGI_FORMAT RetrieveNativeFormat(SiliconStudio.Paradox.Graphics.PixelFormat format)
 {
     return (DXGI_FORMAT)format;
 }
示例#28
0
 /// <summary>
 /// Retrieves the native format from the PixelFormat.
 /// </summary>
 /// <param name="format">The format.</param>
 /// <returns></returns>
 /// <exception cref="TexLibraryException">UnHandled compression format by PowerVC Texture Tool.</exception>
 private UInt64 RetrieveNativeFormat(SiliconStudio.Paradox.Graphics.PixelFormat format)
 {
     switch (format)
     {
         case SiliconStudio.Paradox.Graphics.PixelFormat.PVRTC_2bpp_RGB:
         case SiliconStudio.Paradox.Graphics.PixelFormat.PVRTC_2bpp_RGB_SRgb:
             return 0;
         case SiliconStudio.Paradox.Graphics.PixelFormat.PVRTC_2bpp_RGBA:
         case SiliconStudio.Paradox.Graphics.PixelFormat.PVRTC_2bpp_RGBA_SRgb:
             return 1;
         case SiliconStudio.Paradox.Graphics.PixelFormat.PVRTC_4bpp_RGB:
         case SiliconStudio.Paradox.Graphics.PixelFormat.PVRTC_4bpp_RGB_SRgb:
             return 2;
         case SiliconStudio.Paradox.Graphics.PixelFormat.PVRTC_4bpp_RGBA:
         case SiliconStudio.Paradox.Graphics.PixelFormat.PVRTC_4bpp_RGBA_SRgb:
             return 3;
         case SiliconStudio.Paradox.Graphics.PixelFormat.PVRTC_II_2bpp:
             return 4;
         case SiliconStudio.Paradox.Graphics.PixelFormat.PVRTC_II_4bpp:
             return 5;
         case SiliconStudio.Paradox.Graphics.PixelFormat.ETC1:
             return 6;
         case SiliconStudio.Paradox.Graphics.PixelFormat.ETC2_RGB:
             return 22;
         case SiliconStudio.Paradox.Graphics.PixelFormat.ETC2_RGBA:
         case SiliconStudio.Paradox.Graphics.PixelFormat.ETC2_RGBA_SRgb:
             return 23;
         case SiliconStudio.Paradox.Graphics.PixelFormat.ETC2_RGB_A1:
             return 24;
         case SiliconStudio.Paradox.Graphics.PixelFormat.EAC_R11_Unsigned:
             return 25;
         case SiliconStudio.Paradox.Graphics.PixelFormat.EAC_R11_Signed:
             return 26;
         case SiliconStudio.Paradox.Graphics.PixelFormat.EAC_RG11_Unsigned:
             return 27;
         case SiliconStudio.Paradox.Graphics.PixelFormat.EAC_RG11_Signed:
             return 28;
         case SiliconStudio.Paradox.Graphics.PixelFormat.R32G32B32A32_Float:
         case SiliconStudio.Paradox.Graphics.PixelFormat.R32G32B32_Float:
         case SiliconStudio.Paradox.Graphics.PixelFormat.R32G32B32A32_UInt:
         case SiliconStudio.Paradox.Graphics.PixelFormat.R32G32B32_UInt:
         case SiliconStudio.Paradox.Graphics.PixelFormat.R32G32B32A32_SInt:
         case SiliconStudio.Paradox.Graphics.PixelFormat.R32G32B32_SInt:
             return Utilities.ConvertPixelType(PixelType.Standard32PixelType);
         case SiliconStudio.Paradox.Graphics.PixelFormat.R16G16B16A16_UNorm:
         case SiliconStudio.Paradox.Graphics.PixelFormat.R16G16B16A16_UInt:
         case SiliconStudio.Paradox.Graphics.PixelFormat.R16G16B16A16_SNorm:
         case SiliconStudio.Paradox.Graphics.PixelFormat.R16G16B16A16_SInt:
             return Utilities.ConvertPixelType(PixelType.Standard16PixelType);
         case SiliconStudio.Paradox.Graphics.PixelFormat.R8G8B8A8_UNorm_SRgb:
         case SiliconStudio.Paradox.Graphics.PixelFormat.R8G8B8A8_UNorm:
         case SiliconStudio.Paradox.Graphics.PixelFormat.R8G8B8A8_UInt:
         case SiliconStudio.Paradox.Graphics.PixelFormat.R8G8B8A8_SNorm:
         case SiliconStudio.Paradox.Graphics.PixelFormat.R8G8B8A8_SInt:
             return Utilities.ConvertPixelType(PixelType.Standard8PixelType);
         default:
             Log.Error("UnHandled compression format by PowerVC Texture Tool.");
             throw new TextureToolsException("UnHandled compression format by PowerVC Texture Tool.");
     }
 }
示例#29
0
 public bool AreEqual(ShaderSource shaderSource, SiliconStudio.Shaders.Parser.ShaderMacro[] macros)
 {
     return ShaderSource.Equals(shaderSource) && macros.All(macro => Macros.Any(x => x.Name == macro.Name && x.Definition == macro.Definition)) && Macros.All(macro => macros.Any(x => x.Name == macro.Name && x.Definition == macro.Definition));
 }
示例#30
0
        private EPVRTVariableType RetrieveNativePixelType(SiliconStudio.Paradox.Graphics.PixelFormat format)
        {
            switch (format)
            {
                case SiliconStudio.Paradox.Graphics.PixelFormat.R32G32B32A32_Float:
                case SiliconStudio.Paradox.Graphics.PixelFormat.R32G32B32_Float:
                    return EPVRTVariableType.ePVRTVarTypeFloat;
                //case Paradox.Framework.Graphics.PixelFormat.R16G16B16A16_Float:

                case SiliconStudio.Paradox.Graphics.PixelFormat.R32G32B32A32_UInt:
                case SiliconStudio.Paradox.Graphics.PixelFormat.R32G32B32_UInt:
                    return EPVRTVariableType.ePVRTVarTypeUnsignedInteger;
                case SiliconStudio.Paradox.Graphics.PixelFormat.R32G32B32A32_SInt:
                case SiliconStudio.Paradox.Graphics.PixelFormat.R32G32B32_SInt:
                    return EPVRTVariableType.ePVRTVarTypeSignedInteger;

                case SiliconStudio.Paradox.Graphics.PixelFormat.R16G16B16A16_UNorm:
                    return EPVRTVariableType.ePVRTVarTypeUnsignedShortNorm;
                case SiliconStudio.Paradox.Graphics.PixelFormat.R16G16B16A16_UInt:
                    return EPVRTVariableType.ePVRTVarTypeUnsignedShort;
                case SiliconStudio.Paradox.Graphics.PixelFormat.R16G16B16A16_SNorm:
                    return EPVRTVariableType.ePVRTVarTypeSignedShortNorm;
                case SiliconStudio.Paradox.Graphics.PixelFormat.R16G16B16A16_SInt:
                    return EPVRTVariableType.ePVRTVarTypeSignedShort;


                case SiliconStudio.Paradox.Graphics.PixelFormat.R8G8B8A8_UNorm_SRgb:
                case SiliconStudio.Paradox.Graphics.PixelFormat.R8G8B8A8_UNorm:
                    return EPVRTVariableType.ePVRTVarTypeUnsignedByteNorm;
                case SiliconStudio.Paradox.Graphics.PixelFormat.R8G8B8A8_UInt:
                    return EPVRTVariableType.ePVRTVarTypeUnsignedByte;
                case SiliconStudio.Paradox.Graphics.PixelFormat.R8G8B8A8_SNorm:
                    return EPVRTVariableType.ePVRTVarTypeSignedByteNorm;
                case SiliconStudio.Paradox.Graphics.PixelFormat.R8G8B8A8_SInt:
                    return EPVRTVariableType.ePVRTVarTypeSignedByte;

                default:
                    return EPVRTVariableType.ePVRTVarTypeUnsignedByteNorm;
            }
        }