Пример #1
0
        protected Dictionary <string, byte[]> Process(FlScriptExecutionContext context)
        {
            MemoryBuffer  buf = CLAPI.CreateBuffer(Instance, context.Input, MemoryFlag.ReadWrite);
            FLInterpreter ret = new FLInterpreter(Instance, context.Filename, buf, context.Width,
                                                  context.Height, 1, 4, Db, true);

            do
            {
                ret.Step();
            } while (!ret.Terminated);


            byte[] buffer = ret.GetResult <byte>();
            Dictionary <string, byte[]> result = new Dictionary <string, byte[]> {
                { "result", buffer }
            };

            foreach (KeyValuePair <string, Bitmap> keyValuePair in context.TextureMap)
            {
                CLBufferInfo mbuf = ret.GetBuffer(keyValuePair.Key);
                if (mbuf == null)
                {
                    continue;
                }

                byte[] spec = CLAPI.ReadBuffer <byte>(Instance, mbuf.Buffer, (int)mbuf.Buffer.Size);
                result.Add(keyValuePair.Key, spec);
                mbuf.Buffer.Dispose();
            }

            return(result);
        }
Пример #2
0
        public void OpenFL_DefineScriptFile_Wrong_Test()
        {
            string file = "resources/filter/defines/test_wrong_script_invalid_file.fl";

            for (int i = 0; i < 2; i++)
            {
                try
                {
                    FLInterpreter p = new FLInterpreter(CLAPI.MainThread, file,
                                                        CLAPI.CreateEmpty <byte>(CLAPI.MainThread, 128 * 128 * 4,
                                                                                 MemoryFlag.CopyHostPointer | MemoryFlag.ReadWrite), 128,
                                                        128,
                                                        1,
                                                        4, TestSetup.KernelDb);
                }
                catch (Exception e)
                {
                    if (!(e is FLInvalidFunctionUseException))
                    {
                        Assert.True(false);
                    }

                    //We passed
                }
            }
        }
Пример #3
0
        public void OpenFL_WFCDefines_Wrong_Test()
        {
            string[] files = Directory.GetFiles("resources/filter/defines/", "test_wrong_define_wfc_*.fl");


            foreach (string file in files)
            {
                try
                {
                    FLInterpreter p = new FLInterpreter(CLAPI.MainThread, file,
                                                        CLAPI.CreateEmpty <byte>(CLAPI.MainThread, 128 * 128 * 4,
                                                                                 MemoryFlag.CopyHostPointer | MemoryFlag.ReadWrite),
                                                        128,
                                                        128,
                                                        1,
                                                        4, TestSetup.KernelDb);
                }
                catch (Exception e)
                {
                    if (!(e is FLInvalidFunctionUseException))
                    {
                        Assert.True(false);
                    }

                    //We passed
                }
            }
        }
Пример #4
0
        public void OpenFL_Comments_Test()
        {
            string        file = Path.GetFullPath("resources/filter/comments/test.fl");
            FLInterpreter p    = new FLInterpreter(CLAPI.MainThread, file,
                                                   CLAPI.CreateEmpty <byte>(CLAPI.MainThread, 128 * 128 * 4,
                                                                            MemoryFlag.CopyHostPointer | MemoryFlag.ReadWrite), 128, 128,
                                                   1,
                                                   4, new KernelDatabase(CLAPI.MainThread, "resources/kernel", DataTypes.Uchar1)); //We need to Create a "fresh" database since xunit is making the cl context invalid when changing the test

            while (!p.Terminated)
            {
                p.Step();
            }
        }
Пример #5
0
        public void OpenFL_Defines_Test()
        {
            string        file = Path.GetFullPath("resources/filter/defines/test.fl");
            FLInterpreter p    = new FLInterpreter(CLAPI.MainThread, file,
                                                   CLAPI.CreateEmpty <byte>(CLAPI.MainThread, 128 * 128 * 4,
                                                                            MemoryFlag.CopyHostPointer | MemoryFlag.ReadWrite), 128, 128,
                                                   1,
                                                   4, TestSetup.KernelDb);

            FLInterpreterStepResult ret = p.Step();


            Assert.True(ret.DefinedBuffers.Count == 5);
            Assert.True(ret.DefinedBuffers[0] == "in_unmanaged");
            Assert.True(ret.DefinedBuffers[1] == "textureD_internal");
            Assert.True(ret.DefinedBuffers[2] == "textureC_internal");
            Assert.True(ret.DefinedBuffers[3] == "textureB_internal");
            Assert.True(ret.DefinedBuffers[4] == "textureA_internal");
        }
Пример #6
0
        public void OpenFL_Kernels_Test()
        {
            string path = "resources/filter/tests";

            string[]       files = Directory.GetFiles(path, "*.fl");
            KernelDatabase db    =
                new KernelDatabase(CLAPI.MainThread, "resources/kernel", DataTypes.Uchar1);

            foreach (string file in files)
            {
                FLInterpreter p = new FLInterpreter(CLAPI.MainThread, file,
                                                    CLAPI.CreateEmpty <byte>(CLAPI.MainThread, 64 * 64 * 4,
                                                                             MemoryFlag.CopyHostPointer | MemoryFlag.ReadWrite), 64, 64,
                                                    1,
                                                    4, db); //We need to Create a "fresh" database since xunit is making the cl context invalid when changing the test
                while (!p.Terminated)
                {
                    p.Step();
                }
            }
        }