public RenderToTargetViewDeviceProxy(Adapter adapter, GraphicSurfaceSize size)
        {
            D3DDevice        = new SharpDX.Direct3D11.Device(adapter, DeviceCreationFlags.BgraSupport, levels);
            ImmediateContext = D3DDevice.ImmediateContext;

            Resize(size.Width, size.Height);
        }
示例#2
0
        internal GraphicsDevice(DirectX11Proxy proxy, GraphicSurfaceSize size, AdapterDescription adapterDescription)
        {
            resourseHash = new ResourseRegistrHash();
            Compilator   = new D3DShaderCompilator();
            Adapter      = adapterDescription;

            int width  = size.Width;
            int height = size.Height;

            directX = proxy;
            directX.Resize(width, height);
            CreateBuffers(width, height);

            TexturedLoader = new TextureLoader(directX.D3DDevice);
        }
示例#3
0
 public SharpDX.Direct3D11.Texture2D CreateTexture2D(GraphicSurfaceSize size)
 {
     return(new Texture2D(D3DDevice, new Texture2DDescription()
     {
         Format = Format.R32G32B32A32_Float,
         Width = size.Width,
         Height = size.Height,
         ArraySize = 1,
         BindFlags = BindFlags.ShaderResource,
         CpuAccessFlags = CpuAccessFlags.None,
         MipLevels = 1,
         OptionFlags = ResourceOptionFlags.GenerateMipMaps,
         SampleDescription = new SampleDescription(1, 0),
         Usage = ResourceUsage.Default,
     }));
 }
        public RenderToTextureDeviceProxy(Adapter adapter, GraphicSurfaceSize size)
        {
            D3DDevice = new SharpDX.Direct3D11.Device(adapter, DeviceCreationFlags.None, levels);

            TargetTexture = new Texture2D(D3DDevice, new Texture2DDescription()
            {
                Format            = Format.R8G8B8A8_UNorm,
                Width             = size.Width,
                Height            = size.Height,
                ArraySize         = 1,
                BindFlags         = BindFlags.RenderTarget | BindFlags.ShaderResource,
                CpuAccessFlags    = CpuAccessFlags.None,
                MipLevels         = 1,
                OptionFlags       = ResourceOptionFlags.None,
                SampleDescription = new SampleDescription(1, 0),
                Usage             = ResourceUsage.Default,
            });

            RenderTarget = new RenderTargetView(D3DDevice, TargetTexture);

            ImmediateContext = D3DDevice.ImmediateContext;
        }
示例#5
0
        public RenderToHandleDeviceProxy(Adapter adapter, IntPtr handle, GraphicSurfaceSize size)
        {
            var backBufferDesc = new ModeDescription(size.Width, size.Height, new Rational(60, 1), GraphicsDevice.BackBufferTextureFormat);

            // Descriptor for the swap chain
            var swapChainDesc = new SwapChainDescription()
            {
                ModeDescription   = backBufferDesc,
                SampleDescription = new SampleDescription(1, 0),
                BufferCount       = 2,
                IsWindowed        = true,
                OutputHandle      = handle,
                Usage             = Usage.RenderTargetOutput,
                Flags             = SwapChainFlags.None,
                // SwapEffect = SwapEffect.FlipSequential
            };
            // Create device and swap chain
            var flags = DeviceCreationFlags.None;

#if DEBUG
            //flags |= DeviceCreationFlags.Debug;
#endif
            if (SharpDX.Direct3D11.Device.IsSupportedFeatureLevel(adapter, FeatureLevel.Level_11_1))   //update win->dxdiag
                                                                                                       //flags |= DeviceCreationFlags.Debuggable;
            {
            }
            if (SharpDX.Direct3D11.Device.IsSupportedFeatureLevel(adapter, FeatureLevel.Level_12_0))
            {
            }

            //using (var factory = adapter.GetParent<Factory2>()) {
            //    var device11 = new SharpDX.Direct3D11.Device(adapter, DeviceCreationFlags.None,
            //       new[] {
            //               FeatureLevel.Level_12_1,
            //               FeatureLevel.Level_12_0,
            //               FeatureLevel.Level_11_1,
            //               FeatureLevel.Level_11_0,
            //       });
            //    var desc1 = new SwapChainDescription1() {
            //        Width = width,
            //        Height = height,
            //        Format = BackBufferTextureFormat,
            //        Stereo = false,
            //        SampleDescription = new SampleDescription(1, 0),
            //        Usage = Usage.BackBuffer | Usage.RenderTargetOutput,
            //        BufferCount = 1,
            //        Scaling = Scaling.Stretch,
            //        SwapEffect = SwapEffect.Discard,

            //    };
            //    swapChain = new SwapChain1(factory, device11, handle, ref desc1,
            //        new SwapChainFullScreenDescription() {
            //            RefreshRate = new Rational(60, 1),
            //            Scaling = DisplayModeScaling.Centered,
            //            Windowed = true
            //        },
            //        // Restrict output to specific Output (monitor)
            //        null);
            //}

            SharpDX.Direct3D11.Device.CreateWithSwapChain(adapter, flags, swapChainDesc, out var d3dDevice, out var sch);

            var wc = sch.QueryInterfaceOrNull <SwapChain1>();
            if (wc != null)
            {
                swapChain1 = wc;
            }
            var sc3 = sch.QueryInterfaceOrNull <SwapChain3>();
            if (sc3 != null)
            {
                swapChain3 = sc3;
            }

            swapChain = sch;                                                        //.QueryInterface<SwapChain4>();//

            var d3 = d3dDevice.QueryInterfaceOrNull <SharpDX.Direct3D11.Device3>(); //Device5
            if (d3 != null)
            {
                device3 = d3;
            }
            D3DDevice = d3dDevice;

            ImmediateContext = d3dDevice.ImmediateContext;

            // Enable object tracking
            //SharpDX.Configuration.EnableObjectTracking = true;
        }