コード例 #1
0
        public void TestTwoCommandsSameOutput()
        {
            Utils.CleanContext();
            Utils.GenerateSourceFile("input1", "{3F3C2132-911E-465C-B98F-020278ED4512}");

            var builder           = Utils.CreateBuilder();
            CommandBuildStep step = builder.Root.Add(new InputOutputCommand {
                Delay = 100, Source = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input1")), OutputUrl = "/db/url1"
            });
            CommandBuildStep childStep = builder.Root.Add(new InputOutputCommand {
                Delay = 100, Source = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input1")), OutputUrl = "/db/url1"
            });

            BuildStep.LinkBuildSteps(step, childStep);
            builder.Run(Builder.Mode.Build);
            builder.WriteIndexFile(false);

            Assert.IsTrue(step.Result.OutputObjects.Keys.Contains(new ObjectUrl(UrlType.Internal, "/db/url1")));
            Assert.IsTrue(childStep.Result.OutputObjects.Keys.Contains(new ObjectUrl(UrlType.Internal, "/db/url1")));

            var indexMap = AssetIndexMap.Load();

            indexMap.UseTransaction = true;
            indexMap.LoadNewValues();

            ObjectId outputId;
            bool     objectIdFound = indexMap.TryGetValue("/db/url1", out outputId);

            Assert.IsTrue(objectIdFound);
            Assert.That(childStep.Result.OutputObjects[new ObjectUrl(UrlType.Internal, "/db/url1")], Is.EqualTo(outputId));
        }
コード例 #2
0
        /// <summary>
        /// Write the generated objects into the index map file.
        /// </summary>
        /// <param name="mergeWithCurrentIndexFile">Indicate if old values must be deleted or merged</param>
        public void WriteIndexFile(bool mergeWithCurrentIndexFile)
        {
            if (!mergeWithCurrentIndexFile)
            {
                try
                {
                    VirtualFileSystem.FileDelete(IndexFileFullPath);
                }
                catch (IOException)
                {
                }
            }

            using (var indexFile = AssetIndexMap.NewTool(indexFilename))
            {
                // Filter database Location
                indexFile.AddValues(
                    Root.OutputObjects.Where(x => x.Key.Type == UrlType.Internal)
                    .Select(x => new KeyValuePair <string, ObjectId>(x.Key.Path, x.Value.ObjectId)));

                foreach (var x in Root.OutputObjects)
                {
                    if (x.Key.Type != UrlType.Internal)
                    {
                        continue;
                    }

                    if (x.Value.Tags.Contains(DoNotCompressTag))
                    {
                        DisableCompressionIds.Add(x.Value.ObjectId);
                    }
                }
            }
        }
コード例 #3
0
        public void TestInputDependencies()
        {
            Utils.CleanContext();
            Utils.GenerateSourceFile("input1", "{A7246DF6-3A68-40E2-BA58-6C9A0EFF552B}");
            Utils.GenerateSourceFile("inputDeps", "{8EE7A4BC-88E1-4CC8-B03F-1E6EA8B23955}");

            var builder  = Utils.CreateBuilder();
            var inputDep = new ObjectUrl(UrlType.File, Utils.GetSourcePath("inputDeps"));
            var command  = new InputOutputCommand {
                Delay = 100, Source = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input1")), OutputUrl = "/db/url1"
            };

            command.InputDependencies.Add(inputDep);
            CommandBuildStep step = builder.Root.Add(command);

            builder.Run(Builder.Mode.Build);

            var indexMap = AssetIndexMap.Load();

            indexMap.UseTransaction = true;
            indexMap.LoadNewValues();

            ObjectId inputDepId;
            bool     inputDepFound = step.Result.InputDependencyVersions.TryGetValue(inputDep, out inputDepId);

            Assert.IsTrue(inputDepFound);
        }
コード例 #4
0
ファイル: FileOdbBackend.cs プロジェクト: cg123/xenko
        public FileOdbBackend(string vfsRootUrl, string indexName, bool isReadOnly)
        {
            var resolveProviderResult = VirtualFileSystem.ResolveProvider(vfsRootUrl, true);
            virtualFileProvider = resolveProviderResult.Provider;
            this.vfsRootUrl = resolveProviderResult.Path;
            vfsTempUrl = this.vfsRootUrl + TempDirectory;

            // Ensure directories exists
            if (!virtualFileProvider.DirectoryExists(this.vfsRootUrl))
                virtualFileProvider.CreateDirectory(this.vfsRootUrl);

            IsReadOnly = isReadOnly;

            assetIndexMap = !string.IsNullOrEmpty(indexName) ? Serialization.Assets.AssetIndexMap.Load(vfsRootUrl + VirtualFileSystem.DirectorySeparatorChar + indexName, isReadOnly)
                                                             : Serialization.Assets.AssetIndexMap.CreateInMemory();
            if (!isReadOnly && !virtualFileProvider.DirectoryExists(vfsTempUrl))
            {
                try
                {
                    virtualFileProvider.CreateDirectory(vfsTempUrl);
                }
                catch (Exception)
                {
                    IsReadOnly = true;
                }
            }
        }
コード例 #5
0
        public void TestInputFromPreviousOutput()
        {
            Utils.CleanContext();
            Utils.GenerateSourceFile("input1", "{E7635471-8551-4C80-9E37-A1EBAFC3869E}");

            var builder           = Utils.CreateBuilder();
            CommandBuildStep step = builder.Root.Add(new InputOutputCommand {
                Delay = 100, Source = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input1")), OutputUrl = "/db/url1"
            });

            builder.Root.Add(new WaitBuildStep());
            CommandBuildStep childStep = builder.Root.Add(new InputOutputCommand {
                Delay = 100, Source = new ObjectUrl(UrlType.Internal, "/db/url1"), OutputUrl = "/db/url2"
            });

            BuildStep.LinkBuildSteps(step, childStep);
            builder.Run(Builder.Mode.Build);
            builder.WriteIndexFile(false);

            Assert.IsTrue(step.Result.OutputObjects.Keys.Contains(new ObjectUrl(UrlType.Internal, "/db/url1")));
            Assert.IsTrue(childStep.Result.OutputObjects.Keys.Contains(new ObjectUrl(UrlType.Internal, "/db/url2")));

            var indexMap = AssetIndexMap.Load();

            indexMap.UseTransaction = true;
            indexMap.LoadNewValues();

            ObjectId outputId;
            bool     objectIdFound = indexMap.TryGetValue("/db/url2", out outputId);

            Assert.IsTrue(objectIdFound);
            Assert.That(childStep.Result.OutputObjects[new ObjectUrl(UrlType.Internal, "/db/url2")], Is.EqualTo(outputId));
        }
コード例 #6
0
ファイル: FileOdbBackend.cs プロジェクト: yongweisun/paradox
        public FileOdbBackend(string vfsRootUrl, bool isReadOnly, string indexName = "index")
        {
            var resolveProviderResult = VirtualFileSystem.ResolveProvider(vfsRootUrl, true);

            virtualFileProvider = resolveProviderResult.Provider;
            this.vfsRootUrl     = resolveProviderResult.Path;
            vfsTempUrl          = this.vfsRootUrl + "/tmp/";

            // Ensure directories exists
            if (!virtualFileProvider.DirectoryExists(this.vfsRootUrl))
            {
                virtualFileProvider.CreateDirectory(this.vfsRootUrl);
            }

            this.isReadOnly = isReadOnly;

            assetIndexMap = Serialization.Assets.AssetIndexMap.Load(vfsRootUrl + VirtualFileSystem.DirectorySeparatorChar + indexName, isReadOnly);
            if (!isReadOnly && !virtualFileProvider.DirectoryExists(vfsTempUrl))
            {
                try
                {
                    virtualFileProvider.CreateDirectory(vfsTempUrl);
                }
                catch (Exception)
                {
                    this.isReadOnly = true;
                }
            }
        }
コード例 #7
0
        public void TestSpawnCommandOutput()
        {
            Utils.CleanContext();
            Utils.GenerateSourceFile("input1", "{05D6BCFA-B1FE-4AD1-920F-0352A6DEC02D}");
            Utils.GenerateSourceFile("input2", "{B9D01D6C-4048-4814-A2DF-9D317A492B10}");

            var builder = Utils.CreateBuilder();
            var command = new InputOutputCommand {
                Delay = 100, Source = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input1")), OutputUrl = "/db/url1"
            };

            command.CommandsToSpawn.Add(new InputOutputCommand {
                Delay = 100, Source = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input2")), OutputUrl = "/db/url2"
            });
            CommandBuildStep step = builder.Root.Add(command);

            builder.Run(Builder.Mode.Build);
            builder.WriteIndexFile(false);

            Assert.That(step.SpawnedSteps.Count(), Is.EqualTo(1));

            var indexMap = AssetIndexMap.Load();

            indexMap.UseTransaction = true;
            indexMap.LoadNewValues();

            ObjectId outputId;
            bool     objectIdFound = indexMap.TryGetValue("/db/url2", out outputId);

            Assert.IsTrue(objectIdFound);
            Assert.That(step.SpawnedSteps.First().Result.OutputObjects[new ObjectUrl(UrlType.Internal, "/db/url2")], Is.EqualTo(outputId));
        }
コード例 #8
0
        public void TestRemoteSpawnCommandOutput()
        {
            Utils.CleanContext();
            Utils.GenerateSourceFile("input1", "{BB42A922-ED1B-4837-98D2-189EFAF6BF42}");
            Utils.GenerateSourceFile("input2", "{8B212FA9-5F0D-4D29-A68B-01D87FF04AF4}");

            var builder = Utils.CreateBuilder();
            var command = new InputOutputCommand {
                Delay = 100, Source = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input1")), OutputUrl = "/db/url1", ExecuteRemotely = true
            };

            command.CommandsToSpawn.Add(new InputOutputCommand {
                Delay = 100, Source = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input2")), OutputUrl = "/db/url2"
            });
            CommandBuildStep step = builder.Root.Add(command);

            builder.Run(Builder.Mode.Build);
            builder.WriteIndexFile(false);

            Assert.That(step.SpawnedSteps.Count(), Is.EqualTo(1));

            var indexMap = AssetIndexMap.Load();

            indexMap.UseTransaction = true;
            indexMap.LoadNewValues();

            ObjectId outputId;
            bool     objectIdFound = indexMap.TryGetValue("/db/url2", out outputId);

            Assert.IsTrue(objectIdFound);
            Assert.That(step.SpawnedSteps.First().Result.OutputObjects[new ObjectUrl(UrlType.Internal, "/db/url2")], Is.EqualTo(outputId));
        }
コード例 #9
0
ファイル: FileOdbBackend.cs プロジェクト: robterrell/paradox
        public FileOdbBackend(string vfsRootUrl, bool isReadOnly, string indexName = "index")
        {
            var resolveProviderResult = VirtualFileSystem.ResolveProvider(vfsRootUrl, true);
            virtualFileProvider = resolveProviderResult.Provider;
            this.vfsRootUrl = resolveProviderResult.Path;
            vfsTempUrl = this.vfsRootUrl + "/tmp/";

            // Ensure directories exists
            if (!virtualFileProvider.DirectoryExists(this.vfsRootUrl))
                virtualFileProvider.CreateDirectory(this.vfsRootUrl);

            this.isReadOnly = isReadOnly;

            assetIndexMap = Serialization.Assets.AssetIndexMap.Load(vfsRootUrl + VirtualFileSystem.DirectorySeparatorChar + indexName, isReadOnly);
            if (!isReadOnly && !virtualFileProvider.DirectoryExists(vfsTempUrl))
            {
                try
                {
                    virtualFileProvider.CreateDirectory(vfsTempUrl);
                }
                catch (Exception)
                {
                    this.isReadOnly = true;
                }
            }
        }
コード例 #10
0
ファイル: TestAssetManager.cs プロジェクト: rohitshe/Code
        public void SetupDatabase()
        {
            VirtualFileSystem.CreateDirectory(VirtualFileSystem.ApplicationDatabasePath);
            var databaseFileProvider = new DatabaseFileProvider(AssetIndexMap.NewTool(VirtualFileSystem.ApplicationDatabaseIndexName), new ObjectDatabase(VirtualFileSystem.ApplicationDatabasePath, VirtualFileSystem.ApplicationDatabaseIndexName));

            ContentManager.GetFileProvider = () => databaseFileProvider;
        }
コード例 #11
0
        public void TestUseBuildCacheOutput()
        {
            Utils.CleanContext();
            Utils.GenerateSourceFile("input1", "{32E4EDF4-E8AA-4D13-B111-9BD8AA2A8B07}");

            var builder1 = Utils.CreateBuilder(false);

            builder1.Root.Add(new InputOutputCommand {
                Delay = 100, Source = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input1")), OutputUrl = "/db/url1"
            });
            builder1.Run(Builder.Mode.Build);

            var builder2          = Utils.CreateBuilder(true);
            CommandBuildStep step = builder2.Root.Add(new InputOutputCommand {
                Delay = 100, Source = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input1")), OutputUrl = "/db/url1"
            });

            builder2.Run(Builder.Mode.Build);
            builder2.WriteIndexFile(false);

            Assert.That(step.Status, Is.EqualTo(ResultStatus.NotTriggeredWasSuccessful));
            Assert.IsTrue(step.Result.OutputObjects.Keys.Contains(new ObjectUrl(UrlType.ContentLink, "/db/url1")));

            var indexMap = AssetIndexMap.Load(VirtualFileSystem.ApplicationDatabaseIndexPath);

            indexMap.UseTransaction = true;
            indexMap.LoadNewValues();

            ObjectId outputId;
            bool     objectIdFound = indexMap.TryGetValue("/db/url1", out outputId);

            Assert.IsTrue(objectIdFound);
            Assert.That(step.Result.OutputObjects[new ObjectUrl(UrlType.ContentLink, "/db/url1")], Is.EqualTo(outputId));
        }
コード例 #12
0
ファイル: TestMixinCompiler.cs プロジェクト: jiangzi/paradox
        public void TestNoClean(out CompilerResults left, out CompilerResults right)
        {
            // Create and mount database file system
            var objDatabase = new ObjectDatabase("/data/db", "index", "/local/db");

            using (var assetIndexMap = AssetIndexMap.Load())
            {
                var database = new DatabaseFileProvider(assetIndexMap, objDatabase);
                AssetManager.GetFileProvider = () => database;

                foreach (var shaderName in Directory.EnumerateFiles(@"..\..\sources\shaders", "*.pdxsl"))
                {
                    CopyStream(database, shaderName);
                }

                foreach (var shaderName in Directory.EnumerateFiles(@"..\..\sources\engine\SiliconStudio.Paradox.Shaders.Tests\GameAssets\Compiler", "*.pdxsl"))
                {
                    CopyStream(database, shaderName);
                }

                var compiler = new EffectCompiler();
                compiler.SourceDirectories.Add("assets/shaders");
                var compilerCache = new EffectCompilerCache(compiler);

                var compilerParameters = new CompilerParameters {
                    Platform = GraphicsPlatform.Direct3D11
                };

                left  = compilerCache.Compile(new ShaderMixinGeneratorSource("SimpleEffect"), compilerParameters);
                right = compilerCache.Compile(new ShaderMixinGeneratorSource("SimpleEffect"), compilerParameters);
            }
        }
コード例 #13
0
ファイル: FileOdbBackend.cs プロジェクト: rohitshe/Code
        public FileOdbBackend(string vfsRootUrl, string indexName, bool isReadOnly)
        {
            var resolveProviderResult = VirtualFileSystem.ResolveProvider(vfsRootUrl, true);

            virtualFileProvider = resolveProviderResult.Provider;
            this.vfsRootUrl     = resolveProviderResult.Path;
            vfsTempUrl          = this.vfsRootUrl + TempDirectory;

            // Ensure directories exists
            if (!virtualFileProvider.DirectoryExists(this.vfsRootUrl))
            {
                virtualFileProvider.CreateDirectory(this.vfsRootUrl);
            }

            IsReadOnly = isReadOnly;

            assetIndexMap = !string.IsNullOrEmpty(indexName) ? Serialization.Assets.AssetIndexMap.Load(vfsRootUrl + VirtualFileSystem.DirectorySeparatorChar + indexName, isReadOnly)
                                                             : Serialization.Assets.AssetIndexMap.CreateInMemory();
            if (!isReadOnly && !virtualFileProvider.DirectoryExists(vfsTempUrl))
            {
                try
                {
                    virtualFileProvider.CreateDirectory(vfsTempUrl);
                }
                catch (Exception)
                {
                    IsReadOnly = true;
                }
            }
        }
コード例 #14
0
        public void TestNoClean(out CompilerResults left, out CompilerResults right)
        {
            // Create and mount database file system
            var objDatabase = ObjectDatabase.CreateDefaultDatabase();

            using (var assetIndexMap = AssetIndexMap.Load(VirtualFileSystem.ApplicationDatabaseIndexPath))
            {
                var database = new DatabaseFileProvider(assetIndexMap, objDatabase);
                ContentManager.GetFileProvider = () => database;

                foreach (var shaderName in Directory.EnumerateFiles(@"..\..\sources\shaders", "*.xksl"))
                {
                    CopyStream(database, shaderName);
                }

                foreach (var shaderName in Directory.EnumerateFiles(@"..\..\sources\engine\SiliconStudio.Xenko.Shaders.Tests\GameAssets\Compiler", "*.xksl"))
                {
                    CopyStream(database, shaderName);
                }

                var compiler = new EffectCompiler();
                compiler.SourceDirectories.Add("assets/shaders");
                var compilerCache = new EffectCompilerCache(compiler);

                var compilerParameters = new CompilerParameters {
                    EffectParameters = { Platform = GraphicsPlatform.Direct3D11 }
                };

                left  = compilerCache.Compile(new ShaderMixinGeneratorSource("SimpleEffect"), compilerParameters);
                right = compilerCache.Compile(new ShaderMixinGeneratorSource("SimpleEffect"), compilerParameters);
            }
        }
コード例 #15
0
        public void SetupDatabase()
        {
            VirtualFileSystem.CreateDirectory("/data");
            VirtualFileSystem.CreateDirectory("/data/db");
            var databaseFileProvider = new DatabaseFileProvider(AssetIndexMap.NewTool(), new ObjectDatabase("/data/db"));

            AssetManager.GetFileProvider = () => databaseFileProvider;
        }
コード例 #16
0
ファイル: TestGenericClass.cs プロジェクト: slagusev/paradox
        public static void Main5()
        {
            // Create and mount database file system
            var objDatabase          = new ObjectDatabase("/data/db");
            var assetIndexMap        = AssetIndexMap.Load();
            var databaseFileProvider = new DatabaseFileProvider(assetIndexMap, objDatabase);

            AssetManager.GetFileProvider = () => databaseFileProvider;

            var test = new TestGenericClass();

            test.Run();
        }
コード例 #17
0
ファイル: TestGenericClass.cs プロジェクト: rohitshe/Code
        public static void Main5()
        {
            // Create and mount database file system
            var objDatabase          = ObjectDatabase.CreateDefaultDatabase();
            var assetIndexMap        = AssetIndexMap.Load(VirtualFileSystem.ApplicationDatabaseIndexPath);
            var databaseFileProvider = new DatabaseFileProvider(assetIndexMap, objDatabase);

            ContentManager.GetFileProvider = () => databaseFileProvider;

            var test = new TestGenericClass();

            test.Run();
        }
コード例 #18
0
        public void TestInputFromPreviousOutputWithCache()
        {
            Utils.CleanContext();
            Utils.GenerateSourceFile("input1", "{E60A3248-B4D8-43F6-9A73-975FD9A653FC}");

            var builder1          = Utils.CreateBuilder();
            CommandBuildStep step = builder1.Root.Add(new InputOutputCommand {
                Delay = 100, Source = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input1")), OutputUrl = "/db/url1"
            });

            builder1.Root.Add(new WaitBuildStep());
            CommandBuildStep childStep = builder1.Root.Add(new InputOutputCommand {
                Delay = 100, Source = new ObjectUrl(UrlType.Internal, "/db/url1"), OutputUrl = "/db/url2"
            });

            BuildStep.LinkBuildSteps(step, childStep);
            builder1.Run(Builder.Mode.Build);

            VirtualFileSystem.FileDelete("/data/db/index");

            var builder2 = Utils.CreateBuilder();

            step = builder2.Root.Add(new InputOutputCommand {
                Delay = 100, Source = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input1")), OutputUrl = "/db/url1"
            });
            builder2.Root.Add(new WaitBuildStep());
            childStep = builder2.Root.Add(new InputOutputCommand {
                Delay = 100, Source = new ObjectUrl(UrlType.Internal, "/db/url1"), OutputUrl = "/db/url2"
            });
            BuildStep.LinkBuildSteps(step, childStep);
            builder2.Run(Builder.Mode.Build);
            builder2.WriteIndexFile(false);

            Assert.That(step.Status, Is.EqualTo(ResultStatus.NotTriggeredWasSuccessful));
            Assert.That(childStep.Status, Is.EqualTo(ResultStatus.NotTriggeredWasSuccessful));

            Assert.IsTrue(step.Result.OutputObjects.Keys.Contains(new ObjectUrl(UrlType.Internal, "/db/url1")));
            Assert.IsTrue(childStep.Result.OutputObjects.Keys.Contains(new ObjectUrl(UrlType.Internal, "/db/url2")));

            var indexMap = AssetIndexMap.Load();

            indexMap.UseTransaction = true;
            indexMap.LoadNewValues();

            ObjectId outputId;
            bool     objectIdFound = indexMap.TryGetValue("/db/url2", out outputId);

            Assert.IsTrue(objectIdFound);
            Assert.That(childStep.Result.OutputObjects[new ObjectUrl(UrlType.Internal, "/db/url2")], Is.EqualTo(outputId));
        }
コード例 #19
0
        public static void Main()
        {
            using (var profile = Profiler.Begin(GameProfilingKeys.ObjectDatabaseInitialize))
            {
                // Create and mount database file system
                var objDatabase          = new ObjectDatabase("/data/db");
                var assetIndexMap        = AssetIndexMap.Load();
                var databaseFileProvider = new DatabaseFileProvider(assetIndexMap, objDatabase);
                AssetManager.GetFileProvider = () => databaseFileProvider;
            }

            var test = new TestGenericClass();

            test.Run();
        }
コード例 #20
0
        public static void Main()
        {
            using (var profile = Profiler.Begin(GameProfilingKeys.ObjectDatabaseInitialize))
            {
                // Create and mount database file system
                var objDatabase          = new ObjectDatabase("/data/db");
                var assetIndexMap        = AssetIndexMap.Load();
                var databaseFileProvider = new DatabaseFileProvider(assetIndexMap, objDatabase);
                AssetManager.GetFileProvider = () => databaseFileProvider;
            }

            compiler = new EffectCompiler();
            compiler.SourceDirectories.Add("shaders");
            var shaderMixinSource = new ShaderMixinSource();

            shaderMixinSource.Mixins.Add(new ShaderClassSource("ShaderBase"));
            shaderMixinSource.Mixins.Add(new ShaderClassSource("TransformationWVP"));
            shaderMixinSource.Mixins.Add(new ShaderClassSource("ShadingBase"));

            var shaderMixinSource2 = new ShaderMixinSource();

            shaderMixinSource2.Mixins.Add(new ShaderClassSource("ShaderBase"));
            shaderMixinSource2.Mixins.Add(new ShaderClassSource("TransformationWVP"));
            shaderMixinSource2.Mixins.Add(new ShaderClassSource("ShadingBase"));
            shaderMixinSource2.Mixins.Add(new ShaderClassSource("ShadingOverlay"));

            var allThreads = new List <Thread>();

            for (int i = 0; i < NumThreads; ++i)
            {
                CompilerThread compilerThread;
                if (i % 2 == 0)
                {
                    compilerThread = new CompilerThread(compiler, shaderMixinSource);
                }
                else
                {
                    compilerThread = new CompilerThread(compiler, shaderMixinSource2);
                }
                allThreads.Add(new Thread(compilerThread.Compile));
            }

            foreach (var thread in allThreads)
            {
                thread.Start();
            }
        }
コード例 #21
0
        public static void Main3()
        {
            // Create and mount database file system
            var objDatabase          = ObjectDatabase.CreateDefaultDatabase();
            var assetIndexMap        = AssetIndexMap.Load(VirtualFileSystem.ApplicationDatabaseIndexPath);
            var databaseFileProvider = new DatabaseFileProvider(assetIndexMap, objDatabase);

            ContentManager.GetFileProvider = () => databaseFileProvider;

            compiler = new EffectCompiler();
            compiler.SourceDirectories.Add("shaders");
            var shaderMixinSource = new ShaderMixinSource();

            shaderMixinSource.Mixins.Add(new ShaderClassSource("ShaderBase"));
            shaderMixinSource.Mixins.Add(new ShaderClassSource("TransformationWVP"));
            shaderMixinSource.Mixins.Add(new ShaderClassSource("ShadingBase"));

            var shaderMixinSource2 = new ShaderMixinSource();

            shaderMixinSource2.Mixins.Add(new ShaderClassSource("ShaderBase"));
            shaderMixinSource2.Mixins.Add(new ShaderClassSource("TransformationWVP"));
            shaderMixinSource2.Mixins.Add(new ShaderClassSource("ShadingBase"));
            shaderMixinSource2.Mixins.Add(new ShaderClassSource("ShadingOverlay"));

            var allThreads = new List <Thread>();

            for (int i = 0; i < NumThreads; ++i)
            {
                CompilerThread compilerThread;
                if (i % 2 == 0)
                {
                    compilerThread = new CompilerThread(compiler, shaderMixinSource);
                }
                else
                {
                    compilerThread = new CompilerThread(compiler, shaderMixinSource2);
                }
                allThreads.Add(new Thread(compilerThread.Compile));
            }

            foreach (var thread in allThreads)
            {
                thread.Start();
            }
        }
コード例 #22
0
        public void TestSingleCommandTwiceWithInputChange()
        {
            Utils.CleanContext();
            Utils.GenerateSourceFile("input1", "{71938BC2-6876-406E-84E9-4F4E862651D5}");

            var builder1           = Utils.CreateBuilder();
            CommandBuildStep step1 = builder1.Root.Add(new InputOutputCommand {
                Delay = 100, Source = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input1")), OutputUrl = "/db/url1"
            });

            builder1.Run(Builder.Mode.Build);

            // Modifying input file
            Utils.GenerateSourceFile("input1", "{5794B336-55F9-400A-B99D-DA61C9F09CCE}", true);

            var builder2           = Utils.CreateBuilder();
            CommandBuildStep step2 = builder2.Root.Add(new InputOutputCommand {
                Delay = 100, Source = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input1")), OutputUrl = "/db/url1"
            });

            builder2.Run(Builder.Mode.Build);
            builder2.WriteIndexFile(false);

            Assert.IsTrue(step1.Result.OutputObjects.Keys.Contains(new ObjectUrl(UrlType.Internal, "/db/url1")));
            Assert.IsTrue(step2.Result.OutputObjects.Keys.Contains(new ObjectUrl(UrlType.Internal, "/db/url1")));

            var indexMap = AssetIndexMap.Load();

            indexMap.UseTransaction = true;
            indexMap.LoadNewValues();

            ObjectId outputId;
            bool     objectIdFound = indexMap.TryGetValue("/db/url1", out outputId);

            Assert.IsTrue(objectIdFound);

            Assert.That(step1.Status, Is.EqualTo(ResultStatus.Successful));
            Assert.That(step2.Status, Is.EqualTo(ResultStatus.Successful));
            Assert.That(step1.Result.OutputObjects[new ObjectUrl(UrlType.Internal, "/db/url1")], !Is.EqualTo(outputId));
            Assert.That(step2.Result.OutputObjects[new ObjectUrl(UrlType.Internal, "/db/url1")], Is.EqualTo(outputId));
        }
コード例 #23
0
        void CommonSingleOutput(bool executeRemotely)
        {
            var builder           = Utils.CreateBuilder();
            CommandBuildStep step = builder.Root.Add(new InputOutputCommand {
                Delay = 100, Source = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input1")), OutputUrl = "/db/url1", ExecuteRemotely = executeRemotely
            });

            builder.Run(Builder.Mode.Build);
            builder.WriteIndexFile(false);

            Assert.Contains(new ObjectUrl(UrlType.Internal, "/db/url1"), step.Result.OutputObjects.Keys);

            var indexMap = AssetIndexMap.Load();

            indexMap.UseTransaction = true;
            indexMap.LoadNewValues();

            ObjectId outputId;
            bool     objectIdFound = indexMap.TryGetValue("/db/url1", out outputId);

            Assert.IsTrue(objectIdFound);
            Assert.That(step.Result.OutputObjects[new ObjectUrl(UrlType.Internal, "/db/url1")], Is.EqualTo(outputId));
        }
コード例 #24
0
        public void TestInputDependenciesChange()
        {
            Utils.CleanContext();
            Utils.GenerateSourceFile("input1", "{A7246DF6-3A68-40E2-BA58-6C9A0EFF552B}");
            Utils.GenerateSourceFile("inputDeps", "{8EE7A4BC-88E1-4CC8-B03F-1E6EA8B23955}");
            var inputDep = new ObjectUrl(UrlType.File, Utils.GetSourcePath("inputDeps"));

            var builder1           = Utils.CreateBuilder();
            CommandBuildStep step1 = builder1.Root.Add(new InputOutputCommand {
                Delay = 100, Source = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input1")), OutputUrl = "/db/url1", InputDependencies = { inputDep }
            });

            builder1.Run(Builder.Mode.Build);

            Utils.GenerateSourceFile("inputDeps", "{E505A61B-5F2A-4BB8-8F6C-3788C76BAE5F}", true);

            var builder2           = Utils.CreateBuilder();
            CommandBuildStep step2 = builder2.Root.Add(new InputOutputCommand {
                Delay = 100, Source = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input1")), OutputUrl = "/db/url1", InputDependencies = { inputDep }
            });

            builder2.Run(Builder.Mode.Build);

            var indexMap = AssetIndexMap.Load();

            indexMap.LoadNewValues();

            Assert.That(step1.Status, Is.EqualTo(ResultStatus.Successful));
            Assert.That(step2.Status, Is.EqualTo(ResultStatus.Successful));
            ObjectId inputDepId1;
            ObjectId inputDepId2;

            Assert.IsTrue(step1.Result.InputDependencyVersions.TryGetValue(inputDep, out inputDepId1));
            Assert.IsTrue(step2.Result.InputDependencyVersions.TryGetValue(inputDep, out inputDepId2));
            Assert.That(inputDepId1, !Is.EqualTo(inputDepId2));
        }