Esempio n. 1
0
        private void InitGPUSupport()
        {
            // Make device
            device = new Device(DriverType.Hardware, DeviceCreationFlags.Debug, FeatureLevel.Level_11_0);

            // Compile compute shader
            computeShader = GPGPUHelper.LoadComputeShader(device, "GPGPU/FilterObjects.compute", "Filter", out shaderByteCode);
        }
Esempio n. 2
0
        public void testgpu()
        {
            // Make device
            Device device = new Device(DriverType.Hardware, DeviceCreationFlags.None, FeatureLevel.Level_11_0);

            ShaderBytecode byteCode;
            ComputeShader  compute = GPGPUHelper.LoadComputeShader(device, "GPGPU/Simple.compute", "main", out byteCode);

            Texture2D           uavTexture;
            UnorderedAccessView computeResult = GPGPUHelper.CreateUnorderedAccessView(device, 1024, 1024, SlimDX.DXGI.Format.R8G8B8A8_UNorm, out uavTexture);

            device.ImmediateContext.ComputeShader.Set(compute);
            device.ImmediateContext.ComputeShader.SetUnorderedAccessView(computeResult, 0);
            device.ImmediateContext.Dispatch(32, 32, 1);

            Texture2D.ToFile(device.ImmediateContext, uavTexture, ImageFileFormat.Png, "uav.png");
        }