Example #1
0
        public static double[] Add(string objPath, double[] left, double[] right)
        {
            using (var fileStream = File.Create("AddArray.dxil"))
            {
                ShaderCompilation.CompileFromFile("AddArray.hlsl", "CSMain", "cs_5_0").Bytecode.Save(fileStream);
            }

            objPath = "AddArray.dxil";

            using (var fileStream = File.OpenRead(objPath))
            {
                AddArrayShaderCode = new byte[fileStream.Length];
                fileStream.Read(AddArrayShaderCode, 0, AddArrayShaderCode.Length);
            }

            device           = new Device(null, FeatureLevel.Level_11_0);
            fence            = device.CreateFence(0, FenceFlags.None);
            commandQueue     = device.CreateCommandQueue(CommandListType.Compute);
            commandAllocator = device.CreateCommandAllocator(CommandListType.Compute);
            commandList      = device.CreateCommandList(0, CommandListType.Compute, commandAllocator, null);

            currentFence = 0;
            fenceEvent   = new AutoResetEvent(false);

            var gpuResult = AddGpu(left, right);

            return(gpuResult);
        }