示例#1
0
        /// <summary>
        /// Preprocesses the provided shader or effect source.
        /// </summary>
        /// <param name="shaderSource">An array of bytes containing the raw source of the shader or effect to preprocess.</param>
        /// <param name="sourceFileName">Name of the source file.</param>
        /// <param name="defines">A set of macros to define during preprocessing.</param>
        /// <param name="includeDirectories">The include directories used by the preprocessor.</param>
        /// <returns>
        /// The preprocessed shader source.
        /// </returns>
        public static string Run(string shaderSource, string sourceFileName, ShaderMacro[] defines = null, params string[] includeDirectories)
        {
            // Use a default include handler
            var defaultHandler = new DefaultIncludeHandler();

            if (includeDirectories != null)
            {
                defaultHandler.AddDirectories(includeDirectories);
            }

            defaultHandler.AddDirectory(Environment.CurrentDirectory);

            var directoryName = Path.GetDirectoryName(sourceFileName);

            if (!string.IsNullOrEmpty(directoryName))
            {
                defaultHandler.AddDirectory(directoryName);
            }

            // Run the processor
            return(Run(shaderSource, sourceFileName, defines, defaultHandler));
        }
示例#2
0
 public EffectCompiler(ShaderFlags shaderFlags, string includeHandlerPath)
 {
     _shaderFlags = shaderFlags;
     _include     = new PackOptimizeIncludeHandler(includeHandlerPath);
 }