Exemplo n.º 1
0
 public D3D11ResourceFactory(D3D11GraphicsDevice gd)
     : base(gd.Features)
 {
     _gd     = gd;
     _device = gd.Device;
     _cache  = new D3D11ResourceCache(_device);
 }
Exemplo n.º 2
0
        private protected override TextureView CreateFullTextureView(GraphicsDevice gd)
        {
            TextureViewDescription desc    = new TextureViewDescription(this);
            D3D11GraphicsDevice    d3d11GD = Util.AssertSubtype <GraphicsDevice, D3D11GraphicsDevice>(gd);

            return(new D3D11TextureView(d3d11GD, ref desc));
        }
Exemplo n.º 3
0
 public D3D11CommandList(D3D11GraphicsDevice gd, ref CommandListDescription description)
     : base(ref description)
 {
     _gd       = gd;
     _context  = new DeviceContext(gd.Device);
     _context1 = _context.QueryInterfaceOrNull <DeviceContext1>();
     if (_context1 == null)
     {
         throw new VeldridException("Direct3D 11.1 is required.");
     }
 }
Exemplo n.º 4
0
        public D3D11TextureView(D3D11GraphicsDevice gd, ref TextureViewDescription description)
            : base(ref description)
        {
            Device       device = gd.Device;
            D3D11Texture d3dTex = Util.AssertSubtype <Texture, D3D11Texture>(description.Target);
            ShaderResourceViewDescription srvDesc = D3D11Util.GetSrvDesc(
                d3dTex,
                description.BaseMipLevel,
                description.MipLevels,
                description.BaseArrayLayer,
                description.ArrayLayers,
                Format);

            ShaderResourceView = new ShaderResourceView(device, d3dTex.DeviceTexture, srvDesc);

            if ((d3dTex.Usage & TextureUsage.Storage) == TextureUsage.Storage)
            {
                UnorderedAccessViewDescription uavDesc = new UnorderedAccessViewDescription();
                uavDesc.Format = D3D11Formats.GetViewFormat(d3dTex.DxgiFormat);

                if ((d3dTex.Usage & TextureUsage.Cubemap) == TextureUsage.Cubemap)
                {
                    throw new NotSupportedException();
                }
                else if (d3dTex.Depth == 1)
                {
                    if (d3dTex.ArrayLayers == 1)
                    {
                        uavDesc.Dimension          = UnorderedAccessViewDimension.Texture2D;
                        uavDesc.Texture2D.MipSlice = (int)description.BaseMipLevel;
                    }
                    else
                    {
                        uavDesc.Dimension = UnorderedAccessViewDimension.Texture2DArray;
                        uavDesc.Texture2DArray.MipSlice        = (int)description.BaseMipLevel;
                        uavDesc.Texture2DArray.FirstArraySlice = (int)description.BaseArrayLayer;
                        uavDesc.Texture2DArray.ArraySize       = (int)description.ArrayLayers;
                    }
                }
                else
                {
                    uavDesc.Dimension             = UnorderedAccessViewDimension.Texture3D;
                    uavDesc.Texture3D.MipSlice    = (int)description.BaseMipLevel;
                    uavDesc.Texture3D.FirstWSlice = (int)description.BaseArrayLayer;
                    uavDesc.Texture3D.WSize       = (int)description.ArrayLayers;
                }

                UnorderedAccessView = new UnorderedAccessView(device, d3dTex.DeviceTexture, uavDesc);
            }
        }