Ejemplo n.º 1
0
 public EffectCompiler(IVirtualFileProvider fileProvider)
 {
     FileProvider = fileProvider;
     NativeLibraryHelper.PreloadLibrary("d3dcompiler_47.dll", typeof(EffectCompiler));
     SourceDirectories = new List <string>();
     UrlToFilePath     = new Dictionary <string, string>();
 }
Ejemplo n.º 2
0
        public static void Initialize()
        {
            AssemblyRegistry.Register(typeof(Module).GetTypeInfo().Assembly, AssemblyCommonCategories.Assets);

            // Preload proper libbulletc native library (depending on CPU type)
            NativeLibraryHelper.PreloadLibrary("libbulletc.dll", typeof(PhysicsComponent));
        }
Ejemplo n.º 3
0
        /// <summary>
        ///   Preloads all FFmpeg libraries.
        /// </summary>
        /// <remarks>
        ///   Must be called before any attempt to use FFmpeg API or this will have no effect.
        /// </remarks>
        public static void PreloadLibraries()
        {
            if (!CheckPlatformSupport() || initialized)
            {
                return;
            }

            // Note: order matters (dependencies)
            // avdevice
            //   |---- avfilter
            //   |       |---- avformat
            //   |       |       |---- avcodec
            //   |       |       |       |---- swresample
            //   |       |       |       |       |---- avutil
            //   |       |       |       |---- avutil
            //   |       |       |---- avutil
            //   |       |---- swscale
            //   |       |       |---- avutil
            //   |       |---- swresample
            //   |       |---- avutil
            //   |---- avformat
            //   |---- avcodec
            //   |---- avutil
            var type = typeof(FFmpegUtils);

            NativeLibraryHelper.Load("avutil-55", type);
            NativeLibraryHelper.Load("swresample-2", type);
            NativeLibraryHelper.Load("avcodec-57", type);
            NativeLibraryHelper.Load("avformat-57", type);
            NativeLibraryHelper.Load("swscale-4", type);
            NativeLibraryHelper.Load("avfilter-6", type);
            NativeLibraryHelper.Load("avdevice-57", type);
        }
Ejemplo n.º 4
0
 public EffectCompiler(IVirtualFileProvider fileProvider)
 {
     FileProvider = fileProvider;
     if (Platform.IsWindowsDesktop && !d3dCompilerLoaded)
     {
         NativeLibraryHelper.PreloadLibrary("d3dcompiler_47", typeof(EffectCompiler));
         d3dCompilerLoaded = true;
     }
     SourceDirectories = new List <string>();
     UrlToFilePath     = new Dictionary <string, string>();
 }
Ejemplo n.º 5
0
 protected sealed override IntPtr ResolveExportedSymbol(IntPtr libraryHandle, string name)
 {
     if (NativeLibraryHelper.IsSupported)
     {
         return(NativeLibraryHelper.GetExport(libraryHandle, name));
     }
     else
     {
         return(UnixGetExportedSymbol(libraryHandle, name));
     }
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Preload all FFmpeg libraries.
        /// </summary>
        /// <remarks>
        /// Must be called before any attempt to use FFmpeg API or this will have no effect.
        /// </remarks>
        public static void PreloadLibraries()
        {
            if (!CheckPlatformSupport() || initialized)
            {
                return;
            }

            // Note: order matters (dependencies)
            // avdevice
            //   |---- avfilter
            //   |       |---- avformat
            //   |       |       |---- avcodec
            //   |       |       |       |---- swresample
            //   |       |       |       |       |---- avutil
            //   |       |       |       |---- avutil
            //   |       |       |---- avutil
            //   |       |---- swscale
            //   |       |       |---- avutil
            //   |       |---- swresample
            //   |       |---- avutil
            //   |---- avformat
            //   |---- avcodec
            //   |---- avutil
            if (Platform.Type == PlatformType.Windows)
            {
                var type = typeof(FFmpegUtils);
                NativeLibraryHelper.PreloadLibrary("avutil-55", type);
                NativeLibraryHelper.PreloadLibrary("swresample-2", type);
                NativeLibraryHelper.PreloadLibrary("avcodec-57", type);
                NativeLibraryHelper.PreloadLibrary("avformat-57", type);
                NativeLibraryHelper.PreloadLibrary("swscale-4", type);
                NativeLibraryHelper.PreloadLibrary("avfilter-6", type);
                NativeLibraryHelper.PreloadLibrary("avdevice-57", type);
            }
            else
            {
                // This is likely there for forcing dll loading (on Android?), it will need some review.
                uint version;
                version = ffmpeg.avutil_version();
                version = ffmpeg.swresample_version();
                version = ffmpeg.avcodec_version();
                version = ffmpeg.avformat_version();
                version = ffmpeg.swscale_version();
                version = ffmpeg.avfilter_version();
                version = ffmpeg.avdevice_version();
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Create an empty register.
        /// </summary>
        public FontManager(IDatabaseFileProviderService fileProviderService)
        {
            contentManager = new ContentManager(fileProviderService);

            // Preload proper freetype native library (depending on CPU type)
            NativeLibraryHelper.Load("freetype.dll", typeof(FontManager));

            // create a freetype library used to generate the bitmaps
            freetypeLibrary = new Library();

            // launch the thumbnail builder thread
            bitmapBuilderThread = new Thread(SafeAction.Wrap(BuildBitmapThread))
            {
                IsBackground = true, Name = "Bitmap Builder thread"
            };
            bitmapBuilderThread.Start();
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Try to create the graphics context.
        /// </summary>
        /// <param name="requestedWidth">The requested width.</param>
        /// <param name="requestedHeight">The requested height.</param>
        /// <param name="graphicMode">The graphics mode.</param>
        /// <param name="versionMajor">The major version of OpenGL.</param>
        /// <param name="versionMinor">The minor version of OpenGL.</param>
        /// <param name="creationFlags">The creation flags.</param>
        /// <returns>The created GameWindow.</returns>
        private static OpenTK.GameWindow TryGameWindow(int requestedWidth, int requestedHeight, GraphicsMode graphicMode, int versionMajor, int versionMinor, GraphicsContextFlags creationFlags)
        {
            try
            {
#if STRIDE_GRAPHICS_API_OPENGL || STRIDE_GRAPHICS_API_OPENGLES
                // Preload proper SDL native library (depending on CPU type)
                // This is for OpenGL ES on desktop
                NativeLibraryHelper.PreloadLibrary("SDL2.dll", typeof(GameContextOpenTK));
#endif

                var gameWindow = new OpenTK.GameWindow(requestedWidth, requestedHeight, graphicMode, GameContext.ProductName, GameWindowFlags.Default, DisplayDevice.Default, versionMajor, versionMinor,
                                                       creationFlags);
                return(gameWindow);
            }
            catch (Exception)
            {
                return(null);
            }
        }
        public static void Init()
        {
            if (!loadedLibraries)
            {
                /*
                 * Since the above DLLs are native, they need to be loaded manually from the _Lib directory since DLLImport and LoadLibrary in
                 * Tolk.dll won't be able to find nvdaControllerClient64.dll inside the _Lib folder.
                 */
                foreach (var lib in libraries)
                {
                    NativeLibraryHelper.LoadLibrary("_Lib/" + lib);
                }
                loadedLibraries = true;
            }

            if (!isLoaded)
            {
                Tolk.Load();
            }
            isLoaded = Tolk.IsLoaded();
        }
Ejemplo n.º 10
0
        protected sealed override LoadLibraryResult LoadLibrary(string path)
        {
            if (NativeLibraryHelper.IsSupported)
            {
                return(NativeLibraryHelper.Load(path));
            }
            else
            {
                IntPtr handle = UnixLoadLibrary(path, NativeConstants.RTLD_NOW);

                if (handle != IntPtr.Zero)
                {
                    return(new LoadLibraryResult(handle));
                }
                else
                {
                    string message = Marshal.PtrToStringAnsi(UnixGetErrorMessage()) ?? string.Empty;

                    return(new LoadLibraryResult(new ExternalException(message)));
                }
            }
        }
Ejemplo n.º 11
0
 static NativeLz4Base()
 {
     NativeLibraryHelper.Load(NativeInvoke.Library, typeof(NativeLz4Base));
 }
Ejemplo n.º 12
0
 static AssimpAssetImporter()
 {
     NativeLibraryHelper.PreloadLibrary("assimp-vc140-mt.dll", typeof(AssimpAssetImporter));
 }
 static BowyerWatsonTetrahedralization()
 {
     // TODO: Add native to Stride.Engine?
     NativeLibraryHelper.PreloadLibrary(NativeInvoke.Library, typeof(NativeInvoke));
     exactinit();
 }
Ejemplo n.º 14
0
 static OpenVR()
 {
     NativeLibraryHelper.PreloadLibrary("openvr_api.dll", typeof(OpenVR));
 }
Ejemplo n.º 15
0
 static NativeInvoke()
 {
     NativeLibraryHelper.PreloadLibrary("libcore", typeof(NativeInvoke));
 }
Ejemplo n.º 16
0
 static OculusOvr()
 {
     NativeLibraryHelper.PreloadLibrary(NativeInvoke.Library, typeof(OculusOvr));
 }
Ejemplo n.º 17
0
 static Bullet2PhysicsSystem()
 {
     // Preload proper libbulletc native library (depending on CPU type)
     NativeLibraryHelper.PreloadLibrary("libbulletc.dll", typeof(Bullet2PhysicsSystem));
 }
Ejemplo n.º 18
0
 internal static void PreLoad()
 {
     NativeLibraryHelper.Load("libstride", typeof(NativeInvoke));
 }
Ejemplo n.º 19
0
        private static void Initialize()
        {
            string dir      = AppDomain.CurrentDomain.BaseDirectory;
            string filename = string.Empty;

#if NET45
            if (System.Environment.OSVersion.Platform == PlatformID.Win32NT)
            {
                if (IntPtr.Size == 4)
                {
                    filename = Path.Combine(dir, "win-x86", "native", "libuv.dll");
                }
                else
                {
                    filename = Path.Combine(dir, "win-x64", "native", "libuv.dll");
                }
            }
            else if (System.Environment.OSVersion.Platform == PlatformID.Unix)
            {
                filename = Path.Combine(dir, "linux-x64", "native", "libuv.so");
            }
            else
            {
                filename = Path.Combine(dir, "osx", "native", "libuv.dylib");
            }

            NativeLibraryHelper.LoadLibrary(filename);
#endif
            //#else
            //            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            //            {
            //                if (RuntimeInformation.OSArchitecture == Architecture.X86)
            //                {
            //                    filename = Path.Combine(dir, "win-x86", "native", "libuv.dll");
            //                }
            //                else if (RuntimeInformation.OSArchitecture == Architecture.X64)
            //                {
            //                    filename = Path.Combine(dir, "win-x64",  "native","libuv.dll");
            //                }
            //                else if (RuntimeInformation.OSArchitecture == Architecture.Arm || RuntimeInformation.OSArchitecture == Architecture.Arm64)
            //                {
            //                    filename = Path.Combine(dir, "win-arm", "native", "libuv.dll");
            //                }
            //            }
            //            else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
            //            {
            //                if (RuntimeInformation.OSArchitecture == Architecture.Arm)
            //                {
            //                    filename = Path.Combine(dir, "linux-arm", "native", "libuv.so");
            //                }
            //                else if (RuntimeInformation.OSArchitecture == Architecture.Arm64)
            //                {
            //                    filename = Path.Combine(dir, "linux-arm64",  "native","libuv.so");
            //                }
            //                else if (RuntimeInformation.OSArchitecture == Architecture.X64)
            //                {
            //                    filename = Path.Combine(dir, "linux-x64",  "native","libuv.so");
            //                }
            //            }
            //            else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
            //            {
            //                filename = Path.Combine(dir, "osx",  "native","libuv.dylib");
            //            }
            //            else
            //            {
            //                throw new Exception("unknow operation");
            //            }
            //            if (string.IsNullOrEmpty(filename))
            //            {
            //                throw new Exception("unknow process arch");
            //            }
            //            NativeLibraryHelper.LoadLibrary(filename);
            //#endif
        }
Ejemplo n.º 20
0
 static GameContextSDL()
 {
     // Preload proper SDL native library (depending on CPU type)
     NativeLibraryHelper.PreloadLibrary("SDL2.dll", typeof(Window));
 }
Ejemplo n.º 21
0
 static Bullet2PhysicsSystem()
 {
     // Preload proper libbulletc native library
     NativeLibraryHelper.Load("libbulletc", typeof(Bullet2PhysicsSystem));
 }
Ejemplo n.º 22
0
 static FbxAssetImporter()
 {
     NativeLibraryHelper.Load("libfbxsdk", typeof(FbxAssetImporter));
 }
Ejemplo n.º 23
0
        public override TaskOrResult <EffectBytecodeCompilerResult> Compile(ShaderMixinSource mixinTree, EffectCompilerParameters effectParameters, CompilerParameters compilerParameters)
        {
            var log = new LoggerResult();

            // Load D3D compiler dll
            // Note: No lock, it's probably fine if it gets called from multiple threads at the same time.
            if (Platform.IsWindowsDesktop && !d3dCompilerLoaded)
            {
                NativeLibraryHelper.PreloadLibrary("d3dcompiler_47.dll", typeof(EffectCompiler));
                d3dCompilerLoaded = true;
            }

            var shaderMixinSource = mixinTree;
            var fullEffectName    = mixinTree.Name;

            // Make a copy of shaderMixinSource. Use deep clone since shaderMixinSource can be altered during compilation (e.g. macros)
            var shaderMixinSourceCopy = new ShaderMixinSource();

            shaderMixinSourceCopy.DeepCloneFrom(shaderMixinSource);
            shaderMixinSource = shaderMixinSourceCopy;

            // Generate platform-specific macros
            switch (effectParameters.Platform)
            {
            case GraphicsPlatform.Direct3D11:
                shaderMixinSource.AddMacro("STRIDE_GRAPHICS_API_DIRECT3D", 1);
                shaderMixinSource.AddMacro("STRIDE_GRAPHICS_API_DIRECT3D11", 1);
                break;

            case GraphicsPlatform.Direct3D12:
                shaderMixinSource.AddMacro("STRIDE_GRAPHICS_API_DIRECT3D", 1);
                shaderMixinSource.AddMacro("STRIDE_GRAPHICS_API_DIRECT3D12", 1);
                break;

            case GraphicsPlatform.OpenGL:
                shaderMixinSource.AddMacro("STRIDE_GRAPHICS_API_OPENGL", 1);
                shaderMixinSource.AddMacro("STRIDE_GRAPHICS_API_OPENGLCORE", 1);
                break;

            case GraphicsPlatform.OpenGLES:
                shaderMixinSource.AddMacro("STRIDE_GRAPHICS_API_OPENGL", 1);
                shaderMixinSource.AddMacro("STRIDE_GRAPHICS_API_OPENGLES", 1);
                break;

            case GraphicsPlatform.Vulkan:
                shaderMixinSource.AddMacro("STRIDE_GRAPHICS_API_VULKAN", 1);
                break;

            default:
                throw new NotSupportedException();
            }

            // Generate profile-specific macros
            shaderMixinSource.AddMacro("STRIDE_GRAPHICS_PROFILE", (int)effectParameters.Profile);
            shaderMixinSource.AddMacro("GRAPHICS_PROFILE_LEVEL_9_1", (int)GraphicsProfile.Level_9_1);
            shaderMixinSource.AddMacro("GRAPHICS_PROFILE_LEVEL_9_2", (int)GraphicsProfile.Level_9_2);
            shaderMixinSource.AddMacro("GRAPHICS_PROFILE_LEVEL_9_3", (int)GraphicsProfile.Level_9_3);
            shaderMixinSource.AddMacro("GRAPHICS_PROFILE_LEVEL_10_0", (int)GraphicsProfile.Level_10_0);
            shaderMixinSource.AddMacro("GRAPHICS_PROFILE_LEVEL_10_1", (int)GraphicsProfile.Level_10_1);
            shaderMixinSource.AddMacro("GRAPHICS_PROFILE_LEVEL_11_0", (int)GraphicsProfile.Level_11_0);
            shaderMixinSource.AddMacro("GRAPHICS_PROFILE_LEVEL_11_1", (int)GraphicsProfile.Level_11_1);
            shaderMixinSource.AddMacro("GRAPHICS_PROFILE_LEVEL_11_2", (int)GraphicsProfile.Level_11_2);

            // In .sdsl, class has been renamed to shader to avoid ambiguities with HLSL
            shaderMixinSource.AddMacro("class", "shader");

            var parsingResult = GetMixinParser().Parse(shaderMixinSource, shaderMixinSource.Macros.ToArray());

            // Copy log from parser results to output
            CopyLogs(parsingResult, log);

            // Return directly if there are any errors
            if (parsingResult.HasErrors)
            {
                return(new EffectBytecodeCompilerResult(null, log));
            }

            // Convert the AST to HLSL
            var writer = new Stride.Core.Shaders.Writer.Hlsl.HlslWriter
            {
                EnablePreprocessorLine = false, // Allow to output links to original pdxsl via #line pragmas
            };

            writer.Visit(parsingResult.Shader);
            var shaderSourceText = writer.Text;

            if (string.IsNullOrEmpty(shaderSourceText))
            {
                log.Error($"No code generated for effect [{fullEffectName}]");
                return(new EffectBytecodeCompilerResult(null, log));
            }

            // -------------------------------------------------------
            // Save shader log
            // TODO: TEMP code to allow debugging generated shaders on Windows Desktop
#if STRIDE_PLATFORM_DESKTOP
            var shaderId = ObjectId.FromBytes(Encoding.UTF8.GetBytes(shaderSourceText));

            var logDir = Path.Combine(PlatformFolders.ApplicationBinaryDirectory, "log");
            if (!Directory.Exists(logDir))
            {
                Directory.CreateDirectory(logDir);
            }
            var shaderSourceFilename = Path.Combine(logDir, "shader_" + fullEffectName.Replace('.', '_') + "_" + shaderId + ".hlsl");
            lock (WriterLock) // protect write in case the same shader is created twice
            {
                // Write shader before generating to make sure that we are having a trace before compiling it (compiler may crash...etc.)
                if (!File.Exists(shaderSourceFilename))
                {
                    File.WriteAllText(shaderSourceFilename, shaderSourceText);
                }
            }
#else
            string shaderSourceFilename = null;
#endif
            // -------------------------------------------------------

            var bytecode = new EffectBytecode {
                Reflection = parsingResult.Reflection, HashSources = parsingResult.HashSources
            };

            // Select the correct backend compiler
            IShaderCompiler compiler;
            switch (effectParameters.Platform)
            {
#if STRIDE_PLATFORM_DESKTOP
            case GraphicsPlatform.Direct3D11:
            case GraphicsPlatform.Direct3D12:
                if (Platform.Type != PlatformType.Windows && Platform.Type != PlatformType.UWP)
                {
                    throw new NotSupportedException();
                }
                compiler = new Direct3D.ShaderCompiler();
                break;
#endif
            case GraphicsPlatform.OpenGL:
            case GraphicsPlatform.OpenGLES:
            case GraphicsPlatform.Vulkan:
                // get the number of render target outputs
                var rtOutputs = 0;
                var psOutput  = parsingResult.Shader.Declarations.OfType <StructType>().FirstOrDefault(x => x.Name.Text == "PS_OUTPUT");
                if (psOutput != null)
                {
                    foreach (var rto in psOutput.Fields)
                    {
                        var sem = rto.Qualifiers.OfType <Semantic>().FirstOrDefault();
                        if (sem != null)
                        {
                            // special case SV_Target
                            if (rtOutputs == 0 && sem.Name.Text == "SV_Target")
                            {
                                rtOutputs = 1;
                                break;
                            }
                            for (var i = rtOutputs; i < 8; ++i)
                            {
                                if (sem.Name.Text == ("SV_Target" + i))
                                {
                                    rtOutputs = i + 1;
                                    break;
                                }
                            }
                        }
                    }
                }
                compiler = new OpenGL.ShaderCompiler(rtOutputs);
                break;

            default:
                throw new NotSupportedException();
            }

            var shaderStageBytecodes = new List <ShaderBytecode>();

#if STRIDE_PLATFORM_DESKTOP
            var stageStringBuilder = new StringBuilder();
#endif
            // if the shader (non-compute) does not have a pixel shader, we should add it for OpenGL and OpenGL ES.
            if ((effectParameters.Platform == GraphicsPlatform.OpenGL || effectParameters.Platform == GraphicsPlatform.OpenGLES) && !parsingResult.EntryPoints.ContainsKey(ShaderStage.Pixel) && !parsingResult.EntryPoints.ContainsKey(ShaderStage.Compute))
            {
                parsingResult.EntryPoints.Add(ShaderStage.Pixel, null);
            }

            foreach (var stageBinding in parsingResult.EntryPoints)
            {
                // Compile
                // TODO: We could compile stages in different threads to improve compiler throughput?
                var result = compiler.Compile(shaderSourceText, stageBinding.Value, stageBinding.Key, effectParameters, bytecode.Reflection, shaderSourceFilename);
                result.CopyTo(log);

                if (result.HasErrors)
                {
                    continue;
                }

                // -------------------------------------------------------
                // Append bytecode id to shader log
#if STRIDE_PLATFORM_DESKTOP
                stageStringBuilder.AppendLine("@G    {0} => {1}".ToFormat(stageBinding.Key, result.Bytecode.Id));
                if (result.DisassembleText != null)
                {
                    stageStringBuilder.Append(result.DisassembleText);
                }
#endif
                // -------------------------------------------------------

                shaderStageBytecodes.Add(result.Bytecode);

                // When this is a compute shader, there is no need to scan other stages
                if (stageBinding.Key == ShaderStage.Compute)
                {
                    break;
                }
            }

            // Remove unused reflection data, as it is entirely resolved at compile time.
            CleanupReflection(bytecode.Reflection);

            bytecode.Stages = shaderStageBytecodes.ToArray();

#if STRIDE_PLATFORM_DESKTOP
            int    shaderSourceLineOffset      = 0;
            int    shaderSourceCharacterOffset = 0;
            string outputShaderLog;
            lock (WriterLock) // protect write in case the same shader is created twice
            {
                var builder = new StringBuilder();
                builder.AppendLine("/**************************");
                builder.AppendLine("***** Compiler Parameters *****");
                builder.AppendLine("***************************");
                builder.Append("@P EffectName: ");
                builder.AppendLine(fullEffectName ?? "");
                builder.Append(compilerParameters?.ToStringPermutationsDetailed());
                builder.AppendLine("***************************");

                if (bytecode.Reflection.ConstantBuffers.Count > 0)
                {
                    builder.AppendLine("****  ConstantBuffers  ****");
                    builder.AppendLine("***************************");
                    foreach (var cBuffer in bytecode.Reflection.ConstantBuffers)
                    {
                        builder.AppendFormat("cbuffer {0} [Size: {1}]", cBuffer.Name, cBuffer.Size).AppendLine();
                        foreach (var parameter in cBuffer.Members)
                        {
                            builder.AppendFormat("@C    {0} => {1}", parameter.RawName, parameter.KeyInfo.KeyName).AppendLine();
                        }
                    }
                    builder.AppendLine("***************************");
                }

                if (bytecode.Reflection.ResourceBindings.Count > 0)
                {
                    builder.AppendLine("******  Resources    ******");
                    builder.AppendLine("***************************");
                    foreach (var resource in bytecode.Reflection.ResourceBindings)
                    {
                        builder.AppendFormat("@R    {0} => {1} [Stage: {2}, Slot: ({3}-{4})]", resource.RawName, resource.KeyInfo.KeyName, resource.Stage, resource.SlotStart, resource.SlotStart + resource.SlotCount - 1).AppendLine();
                    }
                    builder.AppendLine("***************************");
                }

                if (bytecode.HashSources.Count > 0)
                {
                    builder.AppendLine("*****     Sources     *****");
                    builder.AppendLine("***************************");
                    foreach (var hashSource in bytecode.HashSources)
                    {
                        builder.AppendFormat("@S    {0} => {1}", hashSource.Key, hashSource.Value).AppendLine();
                    }
                    builder.AppendLine("***************************");
                }

                if (bytecode.Stages.Length > 0)
                {
                    builder.AppendLine("*****     Stages      *****");
                    builder.AppendLine("***************************");
                    builder.Append(stageStringBuilder);
                    builder.AppendLine("***************************");
                }
                builder.AppendLine("*************************/");

                shaderSourceCharacterOffset = builder.Length;

                // Re-append the shader with all informations
                builder.Append(shaderSourceText);

                outputShaderLog = builder.ToString();
                File.WriteAllText(shaderSourceFilename, outputShaderLog);
            }

            // Count lines till source start
            for (int i = 0; i < shaderSourceCharacterOffset - 1;)
            {
                if (outputShaderLog[i] == '\r' && outputShaderLog[i + 1] == '\n')
                {
                    shaderSourceLineOffset++;
                    i += 2;
                }
                else
                {
                    i++;
                }
            }

            // Rewrite shader log
            Regex shaderLogReplace = new Regex(@"\.hlsl\((\d+),[0-9\-]+\):");
            foreach (var msg in log.Messages)
            {
                var match = shaderLogReplace.Match(msg.Text);
                if (match.Success)
                {
                    int line = int.Parse(match.Groups[1].Value);
                    line += shaderSourceLineOffset;

                    msg.Text = msg.Text.Remove(match.Groups[1].Index, match.Groups[1].Length)
                               .Insert(match.Groups[1].Index, line.ToString());
                }
            }
#endif

            return(new EffectBytecodeCompilerResult(bytecode, log));
        }
Ejemplo n.º 24
0
 static NativeNow()
 {
     NativeLibraryHelper.LoadEmbeddedLibrary(typeof(NativeNow).Assembly, LibName);
 }
Ejemplo n.º 25
0
 static Fove()
 {
     NativeLibraryHelper.PreloadLibrary(NativeInvoke.Library, typeof(Fove));
 }
Ejemplo n.º 26
0
 static NativeLz4Base()
 {
     NativeLibraryHelper.PreloadLibrary(NativeInvoke.Library, typeof(NativeLz4Base));
 }
Ejemplo n.º 27
0
 internal static void PreLoad()
 {
     NativeLibraryHelper.PreloadLibrary("libstridenavigation", typeof(NativeInvoke));
 }
Ejemplo n.º 28
0
 static ColliderShapeAssetCompiler()
 {
     NativeLibraryHelper.PreloadLibrary("VHACD", typeof(ColliderShapeAssetCompiler));
 }
Ejemplo n.º 29
0
 static FbxAssetImporter()
 {
     NativeLibraryHelper.PreloadLibrary("libfbxsdk.dll", typeof(FbxAssetImporter));
 }
Ejemplo n.º 30
0
 static AssimpAssetImporter()
 {
     NativeLibraryHelper.Load("assimp-vc140-mt", typeof(AssimpAssetImporter));
 }