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 } } }
public void FLDefineFile_Wrong() { DebugHelper.ThrowOnAllExceptions = true; string file = "resources/filter/defines/test_wrong_define_invalid_file.fl"; for (int i = 0; i < 2; i++) { DebugHelper.ThrowOnAllExceptions = i == 0; try { Interpreter P = new Interpreter(file, CLAPI.CreateEmpty <byte>(128 * 128 * 4, MemoryFlag.CopyHostPointer | MemoryFlag.ReadWrite), 128, 128, 1, 4, TestSetup.KernelDB); Assert.True(!DebugHelper.ThrowOnAllExceptions); } catch (Exception e) { Assert.True(DebugHelper.ThrowOnAllExceptions); if (!(e is FLInvalidFunctionUseException)) { Assert.True(false); } //We passed } } }
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 } } }
public override FLBuffer GetBuffer() { return(new LazyLoadingFLBuffer(root => new FLBuffer( CLAPI.CreateEmpty <byte>(root.Instance, root.InputSize, MemoryFlag.ReadWrite, "EmptySerializableBuffer." + Name), root.Dimensions.x, root.Dimensions.y))); }
public FLProgram Run(FLProgram file, int width, int height) { FLBuffer buffer = new FLBuffer( CLAPI.CreateEmpty <byte>(Instance, height * width * 4, MemoryFlag.ReadWrite, "FLRunnerExecutionCreatedBuffer"), width, height); return(Run(file, buffer, true)); }
public void FLComments() { DebugHelper.ThrowOnAllExceptions = true; string file = Path.GetFullPath("resources/filter/comments/test.fl"); Interpreter P = new Interpreter(file, CLAPI.CreateEmpty <byte>(128 * 128 * 4, MemoryFlag.CopyHostPointer | MemoryFlag.ReadWrite), 128, 128, 1, 4, new KernelDatabase("resources/kernel", OpenCL.TypeEnums.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(); } }
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(); } }
public FLBuffer( CLAPI instance, int width, int height, int depth, object handleIdentifier, MemoryFlag flag = MemoryFlag.ReadWrite, bool optimize = false) : this( CLAPI.CreateEmpty <byte>( instance, width *height *depth * 4, flag, handleIdentifier, optimize ), width, height, depth ) { }
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"); }
public void OpenCL_WriteBuffer_Test() { float[] b = new float[255]; for (int i = 0; i < b.Length; i++) { b[i] = i; } MemoryBuffer buffer = CLAPI.CreateEmpty <float>(CLAPI.MainThread, b.Length, MemoryFlag.ReadWrite, "TestBuffer"); CLAPI.WriteToBuffer(CLAPI.MainThread, buffer, b); float[] c = CLAPI.ReadBuffer <float>(CLAPI.MainThread, buffer, b.Length); Assert.True(CheckValues(c, b)); }
public void FLDefines() { DebugHelper.ThrowOnAllExceptions = true; string file = Path.GetFullPath("resources/filter/defines/test.fl"); Interpreter P = new Interpreter(file, CLAPI.CreateEmpty <byte>(128 * 128 * 4, MemoryFlag.CopyHostPointer | MemoryFlag.ReadWrite), 128, 128, 1, 4, TestSetup.KernelDB); InterpreterStepResult 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"); }
public void WriteBuffer() { CLAPI.Reinitialize(); DebugHelper.ThrowOnAllExceptions = true; float[] b = new float[255]; for (int i = 0; i < b.Length; i++) { b[i] = i; } MemoryBuffer buffer = CLAPI.CreateEmpty <float>(b.Length, MemoryFlag.CopyHostPointer | MemoryFlag.ReadWrite); CLAPI.WriteToBuffer(buffer, b); float[] c = CLAPI.ReadBuffer <float>(buffer, b.Length); Assert.True(CheckValues(c, b)); }
public void FLKernels() { DebugHelper.ThrowOnAllExceptions = true; DebugHelper.SeverityFilter = 10; string path = "resources/filter/tests"; string[] files = Directory.GetFiles(path, "*.fl"); KernelDatabase db = new KernelDatabase("resources/kernel", OpenCL.TypeEnums.DataTypes.UCHAR1); foreach (string file in files) { Interpreter P = new Interpreter(file, CLAPI.CreateEmpty <byte>(128 * 128 * 4, MemoryFlag.CopyHostPointer | MemoryFlag.ReadWrite), 128, 128, 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(); } } }
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(); } } }
public override FLBuffer GetBuffer() { MemoryFlag flag = Modifiers.IsReadOnly ? MemoryFlag.ReadOnly : MemoryFlag.ReadWrite; if (!IsArray) { return(new LazyLoadingFLBuffer( root => new FLBuffer( CLAPI.CreateEmpty <byte>( root.Instance, root.InputSize, flag, "EmptySerializableBuffer." + Name ), root.Dimensions.x, root.Dimensions.y, root.Dimensions.z ), Modifiers.InitializeOnStart )); } return(new LazyLoadingFLBuffer( root => new FLBuffer( CLAPI.CreateEmpty <byte>( root.Instance, Size, flag, "EmptySerializableBuffer." + Name ), Size, 1, 1 ), Modifiers.InitializeOnStart )); }
/// <summary> /// Jumps the interpreter to the specified index /// </summary> /// <param name="index">the index of the line to jump to</param> /// <param name="leaveBuffer">a flag to optionally keep the current buffer</param> private void JumpTo(int index, bool leaveBuffer = false) { Logger.Log(DebugChannel.Log | DebugChannel.OpenFL, Verbosity.Level6, "Jumping To Function: " + data.Source[index]); jumpStack.Push(new FLInterpreterState(currentIndex, currentBuffer, currentArgStack)); stepResult.HasJumped = true; int size = (int)currentBuffer.Buffer.Size; if (!leaveBuffer) { currentBuffer = new CLBufferInfo( CLAPI.CreateEmpty <byte>(instance, size, MemoryFlag.ReadWrite | MemoryFlag.CopyHostPointer), true); currentBuffer.SetKey("Internal_JumpBuffer_Stack_Index" + (jumpStack.Count - 1)); } currentIndex = index + 1; //+1 because the index is the function header currentWord = 0; }
public void FLWFCDefines_Wrong() { DebugHelper.ThrowOnAllExceptions = true; string[] files = Directory.GetFiles("resources/filter/defines/", "test_wrong_define_wfc_*.fl"); for (int i = 0; i < 2; i++) { DebugHelper.ThrowOnAllExceptions = i == 0; foreach (string file in files) { try { Interpreter P = new Interpreter(file, CLAPI.CreateEmpty <byte>(128 * 128 * 4, MemoryFlag.CopyHostPointer | MemoryFlag.ReadWrite), 128, 128, 1, 4, TestSetup.KernelDB); Assert.True(!DebugHelper.ThrowOnAllExceptions); } catch (Exception e) { Assert.True(DebugHelper.ThrowOnAllExceptions); if (!(e is FLInvalidFunctionUseException)) { Assert.True(false); continue; } //We passed } } } }
/// <summary> /// Jumps the interpreter to the specified index /// </summary> /// <param name="index">the index of the line to jump to</param> /// <param name="leaveBuffer">a flag to optionally keep the current buffer</param> private void JumpTo(int index, bool leaveBuffer = false) { Logger.Log("Jumping To Function: " + Data.Source[index], DebugChannel.OpenFL | DebugChannel.Log, 6); _jumpStack.Push(new InterpreterState(_currentIndex, _currentBuffer, _currentArgStack)); _stepResult.HasJumped = true; #if NO_CL int size = 1; #else int size = (int)_currentBuffer.Buffer.Size; #endif if (!leaveBuffer) { _currentBuffer = new CLBufferInfo(CLAPI.CreateEmpty <byte>(size, MemoryFlag.ReadWrite | MemoryFlag.CopyHostPointer), true); _currentBuffer.SetKey("Internal_JumpBuffer_Stack_Index" + (_jumpStack.Count - 1)); } _currentIndex = index + 1; //+1 because the index is the function header _currentWord = 0; }
/// <summary> /// Define handler that loads defined Textures /// </summary> /// <param name="instance">CLAPI Instance of the Current Thread</param> /// <param name="arg">Args from the FL Script</param> /// <param name="defines">Defines</param> /// <param name="width">width of the input buffer</param> /// <param name="height">height of the input buffer</param> /// <param name="depth">depth of the input buffer</param> /// <param name="channelCount">channel count of the input buffer</param> /// <param name="kernelDb">the kernel database to use</param> private void DefineTexture(CLAPI instance, string[] arg, Dictionary <string, CLBufferInfo> defines, int width, int height, int depth, int channelCount, KernelDatabase kernelDb) { if (arg.Length < 2) { throw new FLInvalidFunctionUseException(SCRIPT_DEFINE_KEY, "Invalid Define statement"); } string varname = arg[0].Trim(); if (defines.ContainsKey(varname)) { Logger.Log(DebugChannel.Error, Verbosity.Level1, "Overwriting " + varname, DebugChannel.Warning | DebugChannel.OpenFL, 10); defines.Remove(varname); } MemoryFlag flags = MemoryFlag.ReadWrite; string[] flagTest = varname.Split(' '); if (flagTest.Length > 1) { varname = flagTest[1]; if (flagTest[0] == "r") { flags = MemoryFlag.ReadOnly; } else if (flagTest[0] == "w") { flags = MemoryFlag.WriteOnly; } } string[] args = arg[1].Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); string filename = args[0].Trim(); byte[] activeChannels = new byte[channelCount]; for (int i = 0; i < activeChannels.Length; i++) { activeChannels[i] = 1; } int inputBufferSize = width * height * depth * channelCount; if (IsSurroundedBy(filename, FILEPATH_INDICATOR)) { string fn = filename.Replace(FILEPATH_INDICATOR, ""); if (File.Exists(fn)) { Bitmap bmp = new Bitmap((Bitmap)System.Drawing.Image.FromFile(fn), width, height); CLBufferInfo info = new CLBufferInfo(CLAPI.CreateFromImage(instance, bmp, MemoryFlag.CopyHostPointer | flags), true); info.SetKey(varname); defines.Add(varname, info); } else { throw new FLInvalidFunctionUseException(DEFINE_KEY, "Invalid Filepath", new InvalidFilePathException(fn)); } } else if (filename == "rnd") { MemoryBuffer buf = CLAPI.CreateEmpty <byte>(instance, inputBufferSize, flags | MemoryFlag.CopyHostPointer); CLAPI.WriteRandom(instance, buf, Randombytesource, activeChannels, false); CLBufferInfo info = new CLBufferInfo(buf, true); info.SetKey(varname); defines.Add(varname, info); } else if (filename == "urnd") { MemoryBuffer buf = CLAPI.CreateEmpty <byte>(instance, inputBufferSize, flags | MemoryFlag.CopyHostPointer); CLAPI.WriteRandom(instance, buf, Randombytesource, activeChannels, true); CLBufferInfo info = new CLBufferInfo(buf, true); info.SetKey(varname); defines.Add(varname, info); } else if (filename == "empty") { CLBufferInfo info = new CLBufferInfo(CLAPI.CreateEmpty <byte>(instance, inputBufferSize, flags), true); info.SetKey(varname); defines.Add(varname, info); } else if (filename == "wfc" || filename == "wfcf") { bool force = filename == "wfcf"; if (args.Length < 10) { throw new FLInvalidFunctionUseException("wfc", "Invalid WFC Define statement"); } else if (!int.TryParse(args[2], out int n)) { throw new FLInvalidFunctionUseException("wfc", "Invalid WFC Define statement"); } else if (!int.TryParse(args[3], out int widh)) { throw new FLInvalidFunctionUseException("wfc", "Invalid WFC Define statement"); } else if (!int.TryParse(args[4], out int heigt)) { throw new FLInvalidFunctionUseException("wfc", "Invalid WFC Define statement"); } else if (!bool.TryParse(args[5], out bool periodicInput)) { throw new FLInvalidFunctionUseException("wfc", "Invalid WFC Define statement"); } else if (!bool.TryParse(args[6], out bool periodicOutput)) { throw new FLInvalidFunctionUseException("wfc", "Invalid WFC Define statement"); } else if (!int.TryParse(args[7], out int symmetry)) { throw new FLInvalidFunctionUseException("wfc", "Invalid WFC Define statement"); } else if (!int.TryParse(args[8], out int ground)) { throw new FLInvalidFunctionUseException("wfc", "Invalid WFC Define statement"); } else if (!int.TryParse(args[9], out int limit)) { throw new FLInvalidFunctionUseException("wfc", "Invalid WFC Define statement"); } else { string fn = args[1].Trim().Replace(FILEPATH_INDICATOR, ""); if (CLAPI.FileExists(fn)) { Bitmap bmp; WFCOverlayMode wfc = new WFCOverlayMode(fn, n, widh, heigt, periodicInput, periodicOutput, symmetry, ground); if (force) { do { wfc.Run(limit); bmp = new Bitmap(wfc.Graphics(), new Size(width, height)); //Apply scaling } while (!wfc.Success); } else { wfc.Run(limit); bmp = new Bitmap(wfc.Graphics(), new Size(width, height)); //Apply scaling } CLBufferInfo info = new CLBufferInfo(CLAPI.CreateFromImage(instance, bmp, MemoryFlag.CopyHostPointer | flags), true); info.SetKey(varname); defines.Add(varname, info); } else { throw new FLInvalidFunctionUseException("wfc", "Invalid WFC Image statement", new InvalidFilePathException(fn)); } } } else { StringBuilder s = new StringBuilder(); foreach (string s1 in args) { s.Append(s1 + " "); } throw new FLInvalidFunctionUseException(DEFINE_KEY, "Define statement wrong: " + s); } }
public FLBuffer(CLAPI instance, int width, int height, object handleIdentifier) : this( CLAPI.CreateEmpty <byte>(instance, width *height * 4, MemoryFlag.ReadWrite, handleIdentifier), width, height) { }
protected override void InitializeScene() { 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. //Image size in bytes(Width * Height * ChannelCount) int imageSize = 512 * 512 * 4; //Creating a Kernel Database that will load all the Kernels contained in the asset directory KernelDatabase db = new KernelDatabase(CLAPI.MainThread, "assets/test_kernel/", DataVectorTypes.Uchar1); //We try to get the kernel_red from the file assets/test_kernel/red.cl db.TryGetClKernel("kernel_red", out CLKernel redKernel); //Creating a MemoryBuffer with size of the image. //We are using the CLAPI instance of the main thread and specify that we`d like to read/write from the buffer MemoryBuffer imageBuffer = CLAPI.CreateEmpty <byte>(CLAPI.MainThread, imageSize, MemoryFlag.ReadWrite, "CLMemoryBufferForBox"); //With plain OpenCL you would need to Set the Arguments/Buffers by their argument index/types/size/yada yads, //thanks to the CL abstraction for the engine, we can just specify the argument name how we do in OpenGL Shaders(But Faster). redKernel.SetBuffer("imageData", imageBuffer); //Set Arg has the capabilities to automatically cast the value that is passed to the right type, //however this is not really fast and can be avoided by specifying the correct type directly. redKernel.SetArg("strength", 0.5f); //We directly pass a float, no casting required //When We pass something as byte(uchar in cl), we need to cast it. //If we dont the Engine OpenCL Wrapper will automatically convert the integer into a byte, but it will apply rescaling // This takes over automatic type conversion from float(opengl) to byte(System.Bitmap/opencl) // Calculation when not passed: (4 / Int32.MaxSize) * byte.MaxValue. redKernel.SetArg("channelCount", (byte)4); //This Line runs the kernel. CLAPI.Run(CLAPI.MainThread, redKernel, imageSize); //After the kernel ran, we can read the buffer we have passed to the kernel and Convert it into a OpenGL Texture. Texture tex = TextureLoader.BytesToTexture(CLAPI.ReadBuffer <byte>(CLAPI.MainThread, imageBuffer, imageSize), 512, 512, "BoxTexture"); 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. }
/// <summary> /// Define handler that loads defined scripts /// </summary> /// <param name="arg">The Line of the definition</param> private static void DefineScript(string[] arg, Dictionary <string, CLBufferInfo> defines, int width, int height, int depth, int channelCount, KernelDatabase kernelDb) { if (arg.Length < 2) { Logger.Crash(new FLInvalidFunctionUseException(ScriptDefineKey, "Invalid Define statement"), true); return; } string varname = arg[0].Trim(); if (defines.ContainsKey(varname)) { Logger.Log("Overwriting " + varname, DebugChannel.Warning | DebugChannel.OpenFL, 10); defines.Remove(varname); } string[] args = arg[1].Split(' ', StringSplitOptions.RemoveEmptyEntries); string filename = args[0].Trim(); int InputBufferSize = width * height * depth * channelCount; if (IsSurroundedBy(filename, FilepathIndicator)) { Logger.Log("Loading SubScript...", DebugChannel.Log | DebugChannel.OpenFL, 10); MemoryBuffer buf = CLAPI.CreateEmpty <byte>(InputBufferSize, MemoryFlag.ReadWrite); string fn = filename.Replace(FilepathIndicator, ""); if (File.Exists(fn)) { Interpreter interpreter = new Interpreter(fn, buf, width, height, depth, channelCount, kernelDb, true); do { interpreter.Step(); } while (!interpreter.Terminated); CLBufferInfo info = interpreter.GetActiveBufferInternal(); info.SetKey(varname); defines.Add(varname, info); interpreter.ReleaseResources(); } else { Logger.Crash( new FLInvalidFunctionUseException(ScriptDefineKey, "Not a valid filepath as argument.", new InvalidFilePathException(fn)), true); CLBufferInfo info = new CLBufferInfo(CLAPI.CreateEmpty <byte>(InputBufferSize, MemoryFlag.ReadWrite), true); info.SetKey(varname); defines.Add(varname, info); } } else { Logger.Crash(new FLInvalidFunctionUseException(ScriptDefineKey, "Not a valid filepath as argument."), true); CLBufferInfo info = new CLBufferInfo(CLAPI.CreateEmpty <byte>(InputBufferSize, MemoryFlag.ReadWrite), true); info.SetKey(varname); defines.Add(varname, info); } }
/// <summary> /// Define handler that loads defined scripts /// </summary> /// <param name="instance">CLAPI Instance of the Current Thread</param> /// <param name="arg">Args from the FL Script</param> /// <param name="defines">Defines</param> /// <param name="width">width of the input buffer</param> /// <param name="height">height of the input buffer</param> /// <param name="depth">depth of the input buffer</param> /// <param name="channelCount">channel count of the input buffer</param> /// <param name="kernelDb">the kernel database to use</param> private void DefineScript(CLAPI instance, string[] arg, Dictionary <string, CLBufferInfo> defines, int width, int height, int depth, int channelCount, KernelDatabase kernelDb) { if (arg.Length < 2) { throw new FLInvalidFunctionUseException(SCRIPT_DEFINE_KEY, "Invalid Define statement"); } string varname = arg[0].Trim(); if (defines.ContainsKey(varname)) { Logger.Log(DebugChannel.Error, Verbosity.Level1, "Overwriting " + varname, DebugChannel.Warning | DebugChannel.OpenFL, 10); defines.Remove(varname); } string[] args = arg[1].Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); string filename = args[0].Trim(); int inputBufferSize = width * height * depth * channelCount; if (IsSurroundedBy(filename, FILEPATH_INDICATOR)) { Logger.Log(DebugChannel.Error, Verbosity.Level1, "Loading SubScript...", DebugChannel.Log | DebugChannel.OpenFL, 10); MemoryBuffer buf = CLAPI.CreateEmpty <byte>(instance, inputBufferSize, MemoryFlag.ReadWrite); string fn = filename.Replace(FILEPATH_INDICATOR, ""); if (CLAPI.FileExists(fn)) { FLInterpreter flInterpreter = new FLInterpreter(instance, fn, buf, width, height, depth, channelCount, kernelDb, true); do { flInterpreter.Step(); } while (!flInterpreter.Terminated); CLBufferInfo info = flInterpreter.GetActiveBufferInternal(); info.SetKey(varname); defines.Add(varname, info); flInterpreter.ReleaseResources(); } else { throw new FLInvalidFunctionUseException(SCRIPT_DEFINE_KEY, "Not a valid filepath as argument.", new InvalidFilePathException(fn)); } } else { throw new FLInvalidFunctionUseException(SCRIPT_DEFINE_KEY, "Not a valid filepath as argument."); } }
public void CreateEmptyAlloc() { MemoryBuffer buf = CLAPI.CreateEmpty <byte>(instance, BufferSize, MemoryFlag.ReadWrite, "TestEmptyAlloc"); buf.Dispose(); }