Пример #1
0
        public void TestNoClean(out CompilerResults left, out CompilerResults right)
        {
            // Create and mount database file system
            var objDatabase = ObjectDatabase.CreateDefaultDatabase();

            using (var assetIndexMap = ContentIndexMap.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);
            }
        }
Пример #2
0
        public void TestTwoCommandsSameOutput()
        {
            Utils.CleanContext();
            Utils.GenerateSourceFile("input1", "{3F3C2132-911E-465C-B98F-020278ED4512}");

            var builder           = Utils.CreateBuilder(true);
            CommandBuildStep step = builder.Root.Add(new InputOutputTestCommand {
                Delay = 100, Source = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input1")), OutputUrl = "/db/url1"
            });
            CommandBuildStep childStep = builder.Root.Add(new InputOutputTestCommand {
                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.Contains(new ObjectUrl(UrlType.Content, "/db/url1"), step.Result.OutputObjects.Keys);
            Assert.Contains(new ObjectUrl(UrlType.Content, "/db/url1"), childStep.Result.OutputObjects.Keys);

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

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

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

            Assert.True(objectIdFound);
            Assert.Equal(childStep.Result.OutputObjects[new ObjectUrl(UrlType.Content, "/db/url1")], outputId);
        }
Пример #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(false);
            var inputDep = new ObjectUrl(UrlType.File, Utils.GetSourcePath("inputDeps"));
            var command  = new InputOutputTestCommand {
                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 = ContentIndexMap.Load(VirtualFileSystem.ApplicationDatabaseIndexPath);

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

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

            Assert.True(inputDepFound);
        }
Пример #4
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(true);
            var command = new InputOutputTestCommand {
                Delay = 100, Source = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input1")), OutputUrl = "/db/url1"
            };

            command.CommandsToSpawn.Add(new InputOutputTestCommand {
                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);

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

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

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

            Assert.True(objectIdFound);
        }
Пример #5
0
        public void TestUseBuildCacheOutput()
        {
            Utils.CleanContext();
            Utils.GenerateSourceFile("input1", "{32E4EDF4-E8AA-4D13-B111-9BD8AA2A8B07}");

            var builder1 = Utils.CreateBuilder(false);

            builder1.Root.Add(new InputOutputTestCommand {
                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 InputOutputTestCommand {
                Delay = 100, Source = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input1")), OutputUrl = "/db/url1"
            });

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

            Assert.Equal(ResultStatus.NotTriggeredWasSuccessful, step.Status);
            Assert.Contains(new ObjectUrl(UrlType.Content, "/db/url1"), step.Result.OutputObjects.Keys);

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

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

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

            Assert.True(objectIdFound);
            Assert.Equal(step.Result.OutputObjects[new ObjectUrl(UrlType.Content, "/db/url1")], outputId);
        }
Пример #6
0
        public void TestInputFromPreviousOutput()
        {
            Utils.CleanContext();
            Utils.GenerateSourceFile("input1", "{E7635471-8551-4C80-9E37-A1EBAFC3869E}");

            var builder           = Utils.CreateBuilder(true);
            CommandBuildStep step = builder.Root.Add(new InputOutputTestCommand {
                Delay = 100, Source = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input1")), OutputUrl = "/db/url1"
            });
            CommandBuildStep childStep = builder.Root.Add(new InputOutputTestCommand {
                Delay = 100, Source = new ObjectUrl(UrlType.Content, "/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.Content, "/db/url1")));
            Assert.IsTrue(childStep.Result.OutputObjects.Keys.Contains(new ObjectUrl(UrlType.Content, "/db/url2")));

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

            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.Content, "/db/url2")], Is.EqualTo(outputId));
        }
Пример #7
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(false);
            var command = new InputOutputTestCommand {
                Delay = 100, Source = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input1")), OutputUrl = "/db/url1", ExecuteRemotely = true
            };

            command.CommandsToSpawn.Add(new InputOutputTestCommand {
                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 = ContentIndexMap.Load(VirtualFileSystem.ApplicationDatabaseIndexPath);

            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.ContentLink, "/db/url2")], Is.EqualTo(outputId));
        }
Пример #8
0
        private static void Main5()
        {
            // Create and mount database file system
            var objDatabase          = ObjectDatabase.CreateDefaultDatabase();
            var assetIndexMap        = ContentIndexMap.Load(VirtualFileSystem.ApplicationDatabaseIndexPath);
            var databaseFileProvider = new DatabaseFileProvider(assetIndexMap, objDatabase);

            var test = new TestGenericClass();

            test.Run();
        }
Пример #9
0
        public void TestInputFromPreviousOutputWithCache()
        {
            Utils.CleanContext();
            Utils.GenerateSourceFile("input1", "{E60A3248-B4D8-43F6-9A73-975FD9A653FC}");

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

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

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

            var builder2 = Utils.CreateBuilder(true);

            step = builder2.Root.Add(new InputOutputTestCommand {
                Delay = 100, Source = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input1")), OutputUrl = "/db/url1"
            });
            builder2.Root.Add(new WaitBuildStep());
            childStep = builder2.Root.Add(new InputOutputTestCommand {
                Delay = 100, Source = new ObjectUrl(UrlType.ContentLink, "/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.ContentLink, "/db/url1")));
            Assert.IsTrue(childStep.Result.OutputObjects.Keys.Contains(new ObjectUrl(UrlType.ContentLink, "/db/url2")));

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

            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.ContentLink, "/db/url2")], Is.EqualTo(outputId));
        }
        public static void Main3()
        {
            // Create and mount database file system
            var objDatabase          = ObjectDatabase.CreateDefaultDatabase();
            var assetIndexMap        = ContentIndexMap.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();
            }
        }
Пример #11
0
        public void TestSingleCommandTwiceWithInputChange()
        {
            Utils.CleanContext();
            Utils.GenerateSourceFile("input1", "{71938BC2-6876-406E-84E9-4F4E862651D5}");

            var builder1           = Utils.CreateBuilder(false);
            CommandBuildStep step1 = builder1.Root.Add(new InputOutputTestCommand {
                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(true);
            CommandBuildStep step2 = builder2.Root.Add(new InputOutputTestCommand {
                Delay = 100, Source = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input1")), OutputUrl = "/db/url1"
            });

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

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

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

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

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

            Assert.True(objectIdFound);

            Assert.Equal(ResultStatus.Successful, step1.Status);
            Assert.Equal(ResultStatus.Successful, step2.Status);
            Assert.NotEqual(step1.Result.OutputObjects[new ObjectUrl(UrlType.Content, "/db/url1")], outputId);
            Assert.Equal(step2.Result.OutputObjects[new ObjectUrl(UrlType.Content, "/db/url1")], outputId);
        }
Пример #12
0
        private static void CommonSingleOutput(bool executeRemotely)
        {
            var builder           = Utils.CreateBuilder(true);
            CommandBuildStep step = builder.Root.Add(new InputOutputTestCommand {
                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.Content, "/db/url1"), step.Result.OutputObjects.Keys);

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

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

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

            Assert.True(objectIdFound);
            Assert.Equal(step.Result.OutputObjects[new ObjectUrl(UrlType.Content, "/db/url1")], outputId);
        }
Пример #13
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(false);
            CommandBuildStep step1 = builder1.Root.Add(new InputOutputTestCommand {
                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(false);
            CommandBuildStep step2 = builder2.Root.Add(new InputOutputTestCommand {
                Delay = 100, Source = new ObjectUrl(UrlType.File, Utils.GetSourcePath("input1")), OutputUrl = "/db/url1", InputDependencies = { inputDep }
            });

            builder2.Run(Builder.Mode.Build);

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

            indexMap.LoadNewValues();

            Assert.Equal(ResultStatus.Successful, step1.Status);
            Assert.Equal(ResultStatus.Successful, step2.Status);
            ObjectId inputDepId1;
            ObjectId inputDepId2;

            Assert.True(step1.Result.InputDependencyVersions.TryGetValue(inputDep, out inputDepId1));
            Assert.True(step2.Result.InputDependencyVersions.TryGetValue(inputDep, out inputDepId2));
            Assert.NotEqual(inputDepId1, inputDepId2);
        }