Exemplo n.º 1
0
        public FLSetup(string testName, string kernelPath, string performance = "performance", Type[] checkPipeline = null,
                       bool useMultiThreading = false, int workSizeMultiplier = 2) : base(testName, performance)
        {
            KernelDatabase = new KernelDatabase(CLAPI.MainThread, kernelPath, DataVectorTypes.Uchar1);
            InstructionSet = FLInstructionSet.CreateWithBuiltInTypes(KernelDatabase);
            BufferCreator  = BufferCreator.CreateWithBuiltInTypes();
            CheckBuilder   = null;
            if (checkPipeline == null)
            {
                CheckBuilder = FLProgramCheckBuilder.CreateDefaultCheckBuilder(InstructionSet, BufferCreator);
            }
            else
            {
                CheckBuilder = new FLProgramCheckBuilder(InstructionSet, BufferCreator);
                foreach (Type useCheck in checkPipeline)
                {
                    CheckBuilder.AddProgramCheck((FLProgramCheck)Activator.CreateInstance(useCheck));
                }
            }


            Parser = new FLParser(InstructionSet, BufferCreator,
                                  new WorkItemRunnerSettings(useMultiThreading, workSizeMultiplier));

            CheckBuilder.Attach(Parser, true);

            Directory.CreateDirectory(RunResultPath);
            Directory.CreateDirectory(DataOutputDirectory);
        }
Exemplo n.º 2
0
        public static string RunParserInitBenchmark(string testAdd, int iterations,
                                                    string performanceFolder = "performance", bool useChecks = true, bool useMultiThreading = false,
                                                    int workSizeMultiplier   = 2)
        {
            //FLSetup setup = new FLSetup("FL_ParserProcess_Performance"+ testAdd, "resources/kernel", performanceFolder,
            //    useChecks, useMultiThreading, workSizeMultiplier);
            StringBuilder logOut = new StringBuilder($"Performance Tests: {DateTime.Now:HH:mm:ss}\n");


            FLInstructionSet      iset         = null;
            BufferCreator         bc           = null;
            FLParser              parser       = null;
            FLProgramCheckBuilder checkBuilder = null;
            KernelDatabase        db           = new KernelDatabase(CLAPI.MainThread, "resources/kernel", DataVectorTypes.Uchar1);
            string key = "ParserInitPerformance";

            Logger.Log(LogType.Log, $"------------------------Run {key} Starting------------------------", 1);
            PerformanceTester.PerformanceResult result = PerformanceTester.Tester.RunTest(key, iterations, null,
                                                                                          (int its) =>
            {
                iset         = FLInstructionSet.CreateWithBuiltInTypes(db);
                bc           = BufferCreator.CreateWithBuiltInTypes();
                checkBuilder = FLProgramCheckBuilder.CreateDefaultCheckBuilder(iset, bc);
                parser       = new FLParser(iset, bc);
            }, null);

            logOut.AppendLine("\t" + result);
            Logger.Log(LogType.Log, $"------------------------Run {key} Finished------------------------", 1);
            return(logOut.ToString());
        }
Exemplo n.º 3
0
 public FLRunner(CLAPI instance, FLInstructionSet instructionSet, BufferCreator bufferCreator) : this(
         instance,
         instructionSet,
         bufferCreator,
         FLProgramCheckBuilder
         .CreateDefaultCheckBuilder(
             instructionSet,
             bufferCreator
             )
         )
 {
 }
Exemplo n.º 4
0
 public FLScriptRunner(CLAPI instance, DataVectorTypes dataVectorTypes = DataVectorTypes.Uchar1,
                       string kernelFolder = "resources/kernel")
 {
     Db             = new KernelDatabase(instance, kernelFolder, dataVectorTypes);
     InstructionSet = FLInstructionSet.CreateWithBuiltInTypes(Db);
     BufferCreator  = BufferCreator.CreateWithBuiltInTypes();
     ProgramChecks  = FLProgramCheckBuilder.CreateDefaultCheckBuilder(InstructionSet, BufferCreator);
     Parser         = new FLParser(InstructionSet, BufferCreator);
     ProgramChecks.Attach(Parser, true);
     Instance     = instance;
     ProcessQueue = new Queue <FlScriptExecutionContext>();
 }
Exemplo n.º 5
0
 public FLC2TexUnpacker(CLAPI instance, FLInstructionSet iset, BufferCreator bc)
 {
     runner = new FLRunner(
         instance,
         iset,
         bc,
         FLProgramCheckBuilder.CreateDefaultCheckBuilder(
             iset,
             bc,
             FLProgramCheckType
             .InputValidationOptimized
             )
         );
 }
Exemplo n.º 6
0
        protected override void InitializeScene()
        {
            creator       = BufferCreator.CreateWithBuiltInTypes();
            iset          = FLInstructionSet.CreateWithBuiltInTypes(CLAPI.MainThread, "assets/kernel/");
            checkPipeline = FLProgramCheckBuilder.CreateDefaultCheckBuilder(iset, creator);
            parser        = new FLParser(iset, creator);
            checkPipeline.Attach(parser, true);

            Add(DebugConsoleComponent.CreateConsole());
            Matrix4 proj = Matrix4.CreatePerspectiveFieldOfView(
                MathHelper.DegreesToRadians(75f), //Field of View Vertical
                16f / 9f,                         //Aspect Ratio
                0.1f,                             //Near Plane
                1000f);                           //Far Plane

            BasicCamera bc = new BasicCamera(proj, Vector3.Zero);

            Add(bc);       //Adding the BasicCamera(That is a gameobject under the hood) to the scene to receive events
            SetCamera(bc); //Sets the Camera as the "active" camera that the scene will be rendered from.


            GameObject box = new GameObject(-Vector3.UnitZ * 4, "Box");  //Creating a new Empty GameObject
            LitMeshRendererComponent lmr = new LitMeshRendererComponent( //Creating a Renderer Component
                DefaultFilepaths.DefaultLitShader,                       //The OpenGL Shader used(Unlit and Lit shaders are provided)
                Prefabs.Cube,                                            //The Mesh that is going to be used by the MeshRenderer
                tex,                                                     //Diffuse Texture to put on the mesh
                1);                                                      //Render Mask (UI = 1 << 30)

            box.AddComponent(lmr);                                       //Attaching the Renderer to the GameObject
            box.AddComponent(new RotateSelfComponent());                 //Adding a component that rotates the Object on the Y-Axis
            Add(box);                                                    //Adding the Object to the Scene.


            FLBuffer buffer =
                new FLBuffer(TextureLoader.TextureToMemoryBuffer(CLAPI.MainThread, tex, "BufferForFLProgram"), 128,
                             128);


            FLProgram program = parser.Process(new FLParserInput("assets/filter/red.fl")).Initialize(iset);


            program.Run(CLAPI.MainThread, buffer, true);

            FLBuffer result = program.GetActiveBuffer(false);

            byte[] dat = CLAPI.ReadBuffer <byte>(CLAPI.MainThread, result.Buffer, (int)result.Buffer.Size);
            //Create a texture from the output.
            TextureLoader.Update(tex, dat, 128, 128);
            result.Dispose();
        }
Exemplo n.º 7
0
        public static void InitializeFL(bool noDialogs, FLProgramCheckType checkType)
        {
            NoDialogs = noDialogs;
            int maxTasks = 6;

            Logger.Log(LogType.Log, "Initializing FS", 1);
            PrepareFileSystem();

            SetProgress("Initializing Logging System", 0, 1, maxTasks);
            Debug.DefaultInitialization();

            SetProgress("Initializing Resource System", 0, 2, maxTasks);
            InitializeResourceSystem();

            SetProgress("Initializing Plugin System", 0, 3, maxTasks);
            InitializePluginSystem();

            PluginManager.LoadPlugins(Host);

            SetProgress("Running Custom Actions", 0, 4, maxTasks);
            CustomStartupActions?.Invoke();

            SetProgress("Initializing FL", 0, 5, maxTasks);
            Container = InitializeCLKernels("resources/kernel");

            FLProgramCheckBuilder builder =
                FLProgramCheckBuilder.CreateDefaultCheckBuilder(
                    Container.InstructionSet,
                    Container.BufferCreator,
                    checkType
                    );

            Container.SetCheckBuilder(builder);

            SetProgress("Finished", 0, 6, maxTasks);
        }
Exemplo n.º 8
0
        protected override void InitializeScene()
        {
            creator       = BufferCreator.CreateWithBuiltInTypes();
            iset          = FLInstructionSet.CreateWithBuiltInTypes(CLAPI.MainThread, "assets/kernel/");
            checkPipeline = FLProgramCheckBuilder.CreateDefaultCheckBuilder(iset, creator);
            parser        = new FLParser(iset, creator);
            checkPipeline.Attach(parser, true);
            Mesh plane = MeshLoader.FileToMesh("assets/models/plane.obj");

            Texture texQuad   = TextureLoader.ParameterToTexture(1024, 1024, "FLDisplayTextureQuad");
            Texture texSphere = TextureLoader.ParameterToTexture(1024, 1024, "FLDisplayTextureSphere");

            GameObject objSphere = new GameObject(new Vector3(1, 1, 0), "SphereDisplay");

            LitMeshRendererComponent sphereLmr = new LitMeshRendererComponent(DefaultFilepaths.DefaultLitShader,
                                                                              Prefabs.Sphere,
                                                                              texSphere, 1);

            objSphere.AddComponent(sphereLmr);
            sphereLmr.Textures = new[]
            { sphereLmr.Textures[0], DefaultFilepaths.DefaultTexture };

            objSphere.AddComponent(new RotatingComponent());

            GameObject objQuad = new GameObject(new Vector3(-1, 1, 0), "QuadDisplay");
            LitMeshRendererComponent quadLmr = new LitMeshRendererComponent(DefaultFilepaths.DefaultLitShader, plane,
                                                                            texQuad, 1);

            objQuad.AddComponent(quadLmr);
            quadLmr.Textures = new[]
            { quadLmr.Textures[0], DefaultFilepaths.DefaultTexture };

            objQuad.Rotate(new Vector3(1, 0, 0), MathHelper.DegreesToRadians(45));

            GameObject sourceCube = new GameObject(new Vector3(0, 10, 10), "Light Source");

            sourceCube.AddComponent(new LightComponent());
            sourceCube.AddComponent(new RotateAroundComponent {
                Slow = 0.15f
            });
            sourceCube.AddComponent(new LitMeshRendererComponent(DefaultFilepaths.DefaultLitShader, Prefabs.Cube,
                                                                 TextureLoader.ColorToTexture(Color.White), 1));

            GameObject uiText = new GameObject(new Vector3(0), "UIText");

            uiText.AddComponent(new FlGeneratorComponent(new List <LitMeshRendererComponent>
            {
                sphereLmr, quadLmr
            },
                                                         512,
                                                         512, true));

            Add(sourceCube);
            Add(uiText);
            Add(DebugConsoleComponent.CreateConsole());
            Add(objSphere);
            Add(objQuad);

            GameObject bgObj = new GameObject(Vector3.UnitY * -3, "BG")
            {
                Scale = new Vector3(25, 1, 25)
            };


            bgObj.AddComponent(new LitMeshRendererComponent(DefaultFilepaths.DefaultLitShader, Prefabs.Cube,
                                                            GenerateGroundTexture(), 1));
            Add(bgObj);


            BasicCamera mainCamera =
                new BasicCamera(
                    Matrix4.CreatePerspectiveFieldOfView(MathHelper.DegreesToRadians(75f),
                                                         GameEngine.Instance.Width / (float)GameEngine.Instance.Height, 0.01f, 1000f), Vector3.Zero);

            object mc = mainCamera;

            EngineConfig.LoadConfig("assets/configs/camera_fldemo.xml", ref mc);


            Add(mainCamera);
            SetCamera(mainCamera);

            GameObject camContainer = new GameObject("CamContainer");

            BasicCamera inPicCam =
                new BasicCamera(
                    Matrix4.CreatePerspectiveFieldOfView(MathHelper.DegreesToRadians(75f),
                                                         GameEngine.Instance.Width / (float)GameEngine.Instance.Height, 0.01f, 1000f), Vector3.Zero);

            inPicCam.Rotate(new Vector3(1, 0, 0), MathHelper.DegreesToRadians(0));
            inPicCam.Translate(new Vector3(0, 2, 4));
            inPicCam.AddComponent(new RotateAroundComponent());
            GameObject zeroPoint = new GameObject("Zero");

            Add(zeroPoint);
            LookAtComponent comp = new LookAtComponent();

            comp.SetTarget(zeroPoint);
            inPicCam.AddComponent(comp);
            Add(inPicCam);


            splitCam = new RenderTarget(inPicCam, 1, Color.FromArgb(0, 0, 0, 0))
            {
                MergeType = RenderTargetMergeType.Additive,
                ViewPort  = new Rectangle(0, 0, (int)(GameEngine.Instance.Width * 0.3f),
                                          (int)(GameEngine.Instance.Height * 0.3f))
            };

            Add(camContainer);
            GameEngine.Instance.AddRenderTarget(splitCam);
        }