Пример #1
1
        public RenderContainer(SwapChainDescription swapChainDescription, RenderControl control)
        {
            try
            {
                _swapChainDescription = swapChainDescription;

                using (Factory1 factory = new Factory1())
                using (Adapter adapter = factory.GetAdapter(0))
                {
                    Device11 = new Dx11ChainedDevice(adapter, _swapChainDescription);
                    Device10 = new Dx10Device(adapter);
                }

                GraphicsDevice = new GenericGraphicsDevice(Device11.Device);
                SpriteBatch = new SpriteBatch(GraphicsDevice);

                Reset(control.Width, control.Height);

                control.Resize += OnRenderControlResize;
            }
            catch
            {
                Dispose();
                throw;
            }
        }
Пример #2
0
        public DepthBuffer(Dx11ChainedDevice device, int width, int height)
        {
            try
            {
                _device      = device;
                _depthBuffer = new Texture2D(_device.Device, new Texture2DDescription
                {
                    Format            = Format.D32_Float_S8X24_UInt,
                    ArraySize         = 1,
                    MipLevels         = 1,
                    Width             = width,
                    Height            = height,
                    SampleDescription = new SampleDescription(1, 0),
                    Usage             = ResourceUsage.Default,
                    BindFlags         = BindFlags.DepthStencil,
                    CpuAccessFlags    = CpuAccessFlags.None,
                    OptionFlags       = ResourceOptionFlags.None
                });

                _depthView = new DepthStencilView(device.Device, _depthBuffer);
            }
            catch
            {
                Dispose();
                throw;
            }
        }
Пример #3
0
        public DepthBuffer(Dx11ChainedDevice device, int width, int height)
        {
            try
            {
                _device = device;
                _depthBuffer = new Texture2D(_device.Device, new Texture2DDescription
                {
                    Format = Format.D32_Float_S8X24_UInt,
                    ArraySize = 1,
                    MipLevels = 1,
                    Width = width,
                    Height = height,
                    SampleDescription = new SampleDescription(1, 0),
                    Usage = ResourceUsage.Default,
                    BindFlags = BindFlags.DepthStencil,
                    CpuAccessFlags = CpuAccessFlags.None,
                    OptionFlags = ResourceOptionFlags.None
                });

                _depthView = new DepthStencilView(device.Device, _depthBuffer);
            }
            catch
            {
                Dispose();
                throw;
            }
        }
Пример #4
0
        public RenderContainer(SwapChainDescription swapChainDescription, RenderControl control)
        {
            try
            {
                _swapChainDescription = swapChainDescription;

                using (Factory1 factory = new Factory1())
                    using (Adapter adapter = factory.GetAdapter(0))
                    {
                        Device11 = new Dx11ChainedDevice(adapter, _swapChainDescription);
                        Device10 = new Dx10Device(adapter);
                    }

                GraphicsDevice = new GenericGraphicsDevice(Device11.Device);
                SpriteBatch    = new SpriteBatch(GraphicsDevice);

                Reset(control.Width, control.Height);

                control.Resize += OnRenderControlResize;
            }
            catch
            {
                Dispose();
                throw;
            }
        }
Пример #5
0
        public BackBuffer(Dx10Device device10, Dx11ChainedDevice device11)
        {
            try
            {
                _device10 = device10;
                _device11 = device11;

                _backBuffer = Resource.FromSwapChain <Texture2D>(device11.SwapChain, 0);
                _renderView = new RenderTargetView(device11.Device, _backBuffer);

                Texture2DDescription descriptor = _backBuffer.Description;
                {
                    descriptor.MipLevels         = 1;
                    descriptor.ArraySize         = 1;
                    descriptor.Format            = Format.B8G8R8A8_UNorm;
                    descriptor.SampleDescription = new SampleDescription(1, 0);
                    descriptor.Usage             = SharpDX.Direct3D11.ResourceUsage.Default;
                    descriptor.BindFlags         = SharpDX.Direct3D11.BindFlags.RenderTarget | SharpDX.Direct3D11.BindFlags.ShaderResource;
                    descriptor.CpuAccessFlags    = SharpDX.Direct3D11.CpuAccessFlags.None;
                    descriptor.OptionFlags       = SharpDX.Direct3D11.ResourceOptionFlags.SharedKeyedmutex;
                };

                _textureD3D11 = new Texture2D(device11.Device, descriptor);

                _factory2D = new Factory(FactoryType.MultiThreaded);

                using (SharpDX.DXGI.Resource sharedResource = _textureD3D11.QueryInterface <SharpDX.DXGI.Resource>())
                    using (SharpDX.Direct3D10.Texture2D backBuffer10 = device10.Device.OpenSharedResource <SharpDX.Direct3D10.Texture2D>(sharedResource.SharedHandle))
                    {
                        _surface        = backBuffer10.QueryInterface <Surface>();
                        _renderTarget2D = new RenderTarget(_factory2D, _surface, GetRenderTargetProperties());
                    }
            }
            catch
            {
                Dispose();
                throw;
            }
        }