Пример #1
0
        public D3D11Texture(D3D11GraphicsDevice graphicsDevice, Resource nativeResource, int width, int height, int depth, bool isCube, int mipLevels, TextureViewType type)
        {
            _graphicsDevice = graphicsDevice;
            _nativeResource = nativeResource;

            View = new D3D11TextureView(graphicsDevice, _nativeResource, width, height, depth, isCube, mipLevels, type);
        }
Пример #2
0
        public static IVertexBuffer Create <T>(D3D11GraphicsDevice graphicsDevice, ref T[] vertices) where T : struct
        {
            var vertexBuffer = new D3D11VertexBuffer(graphicsDevice);

            vertexBuffer.Initialize(ref vertices);
            return(vertexBuffer);
        }
Пример #3
0
        public static IConstantBuffer Create <T>(D3D11GraphicsDevice graphicsDevice, T constants) where T : struct
        {
            var buffer = new D3D11ConstantBuffer(graphicsDevice);

            buffer.Initialize(constants);
            return(buffer);
        }
Пример #4
0
 public D3D11RasterizerState(D3D11GraphicsDevice graphicsDevice, CullMode cullMode, FillMode fillMode, bool isDepthEnabled, bool isScissorEnabled, bool isMultiSampleEnabled, bool isAntialiasedLineEnabled)
 {
     _graphicsDevice        = graphicsDevice;
     CullMode               = cullMode;
     FillMode               = fillMode;
     _nativeRasterizerState = CreateRasterizerState(isDepthEnabled, isScissorEnabled, isMultiSampleEnabled, isAntialiasedLineEnabled);
 }
Пример #5
0
 public D3D11BlendState(D3D11GraphicsDevice graphicsDevice, bool isBlendEnabled,
                        Blend sourceBlend, Blend destinationBlend, BlendOperation blendOperation,
                        Blend sourceAlphaBlend, Blend destinationAlphaBlend, BlendOperation blendOperationAlpha)
 {
     _graphicsDevice   = graphicsDevice;
     _nativeBlendState = CreateBlendState(isBlendEnabled, sourceBlend, destinationBlend, blendOperation, sourceAlphaBlend, destinationAlphaBlend, blendOperationAlpha);
 }
Пример #6
0
        public static IIndexBuffer Create <T>(D3D11GraphicsDevice graphicsDevice, ref T[] indices) where T : struct
        {
            var indexBuffer = new D3D11IndexBuffer(graphicsDevice);

            indexBuffer.Initialize(ref indices);
            indexBuffer.Is16Bit = typeof(T) == typeof(short) || typeof(T) == typeof(ushort);
            return(indexBuffer);
        }
Пример #7
0
        public D3D11InputLayout(D3D11GraphicsDevice graphicsDevice, byte[] shaderBytecode, IEnumerable <D3D11VertexAttribute> attributes)
        {
            var inputElements = attributes
                                .Select(attribute => new InputElement(attribute.Name, attribute.SemanticIndex, attribute.Format.ToSharpDX(), attribute.Offset, attribute.Binding))
                                .ToArray();

            _inputLayout = new InputLayout(graphicsDevice, shaderBytecode, inputElements);
        }
Пример #8
0
        public D3D11Sampler(D3D11GraphicsDevice graphicsDevice, TextureAddressMode addressModeU, TextureAddressMode addressModeV, Filter filter, ComparisonFunction comparisonFunction)
        {
            var samplerStateDescription = SamplerStateDescription.Default();

            samplerStateDescription.AddressU           = addressModeU.ToSharpDX();
            samplerStateDescription.AddressV           = addressModeV.ToSharpDX();
            samplerStateDescription.ComparisonFunction = comparisonFunction.ToSharpDX();
            samplerStateDescription.Filter             = filter.ToSharpDX();
            _nativeSamplerState = new SamplerState(graphicsDevice, samplerStateDescription);
        }
Пример #9
0
        private static TextureView CreateDepthStencilView(D3D11GraphicsDevice graphicsDevice, int width, int height)
        {
            var depthBufferDescription = new Texture2DDescription
            {
                Format            = SharpDX.DXGI.Format.D24_UNorm_S8_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
            };

            using var depthBuffer = new D3D11Texture2D(graphicsDevice, depthBufferDescription);

            return(new D3D11TextureView(graphicsDevice, depthBuffer, width, height, 0, false, 1, TextureViewType.DepthStencil));
        }
Пример #10
0
        public D3D11TextureView(D3D11GraphicsDevice graphicsDevice, D3D11Resource resource, int width, int height, int depth, bool isCube, int mipLevels, TextureViewType type)
        {
            if (type.HasFlag(TextureViewType.RenderTarget))
            {
                _nativeRenderTargetView = new RenderTargetView(graphicsDevice, resource);
            }
            if (type.HasFlag(TextureViewType.ShaderResource))
            {
                var srvDescription = new ShaderResourceViewDescription();
                if (depth > 0 && height > 0 && width > 0)
                {
                    srvDescription.Format = ((Texture3D)resource).Description.Format;
                    srvDescription.Texture1D.MipLevels = mipLevels;
                    srvDescription.Dimension           = ShaderResourceViewDimension.Texture3D;
                }
                else if (depth == 0 && height > 0 && width > 0)
                {
                    srvDescription.Format = ((Texture2D)resource).Description.Format;
                    srvDescription.Texture2D.MipLevels = mipLevels;
                    srvDescription.Dimension           = ShaderResourceViewDimension.Texture2D;
                    if (isCube)
                    {
                        srvDescription.Dimension = ShaderResourceViewDimension.TextureCube;
                    }
                }
                else if (depth == 0 && height == 0 && width > 0)
                {
                    srvDescription.Format = ((Texture1D)resource).Description.Format;
                    srvDescription.Texture3D.MipLevels = mipLevels;
                    srvDescription.Dimension           = ShaderResourceViewDimension.Texture1D;
                }

                _nativeShaderResourceView = new ShaderResourceView(graphicsDevice, resource, srvDescription);
            }
            if (type.HasFlag(TextureViewType.DepthStencil))
            {
                _nativeDepthStencilView = new DepthStencilView(graphicsDevice, resource);
            }
        }
Пример #11
0
        public D3D11SwapChain(D3D11GraphicsDevice graphiceDevice, SwapChainInfo swapChainInfo)
        {
            _swapChainInfo = swapChainInfo;
            _factory       = new DXGIFactory();

            var swapChainDescription = new SwapChainDescription
            {
                SwapEffect        = swapChainInfo.SwapEffect.ToSharpDX(),
                BufferCount       = 2,
                Flags             = SwapChainFlags.None,
                IsWindowed        = swapChainInfo.IsWindowed,
                ModeDescription   = new ModeDescription(swapChainInfo.Width, swapChainInfo.Height, new Rational(60, 1), Format.R8G8B8A8UNorm.ToSharpDX()),
                OutputHandle      = swapChainInfo.WindowHandle,
                SampleDescription = new SampleDescription(1, 0),
                Usage             = Usage.RenderTargetOutput
            };

            _swapChain         = new SwapChain(_factory, graphiceDevice, swapChainDescription);
            using var resource = _swapChain.GetBackBuffer <D3D11Texture2D>(0);

            TextureView      = new D3D11TextureView(graphiceDevice, resource, swapChainInfo.Width, swapChainInfo.Height, 0, false, 1, TextureViewType.RenderTarget);
            DepthStencilView = CreateDepthStencilView(graphiceDevice, swapChainInfo.Width, swapChainInfo.Height);
        }
Пример #12
0
 private D3D11VertexBuffer(D3D11GraphicsDevice graphicsDevice)
 {
     _graphicsDevice = graphicsDevice;
 }
Пример #13
0
 public D3D11Shader(D3D11GraphicsDevice graphicsDevice, D3D11GraphicsFactory graphicsFactory)
 {
     _graphicsDevice  = graphicsDevice;
     _graphicsFactory = graphicsFactory;
 }
Пример #14
0
 private D3D11ConstantBuffer(D3D11GraphicsDevice graphicsDevice)
 {
     _graphicsDevice = graphicsDevice;
 }
Пример #15
0
 public D3D11TextureFactory(D3D11GraphicsDevice graphicsDevice)
 {
     _graphicsDevice = graphicsDevice;
 }
Пример #16
0
 public D3D11DepthStencilState(D3D11GraphicsDevice graphicsDevice)
 {
     _graphicsDevice          = graphicsDevice;
     _nativeDepthStencilState = CreateDepthStencilState();
 }
Пример #17
0
 public D3D11CommandList(D3D11GraphicsDevice graphicsDevice)
 {
     _graphicsDevice = graphicsDevice;
     _commandList    = new List <D3D11Command>(32);
 }