public DepthStencilBufferImpl(GraphicsDevice graphicsDevice, int width, int height, float clearValue)
        {
            _graphicsDevice = graphicsDevice;

            var format = SharpDX.DXGI.Format.D32_Float;

            var resourceDescription = ResourceDescription.Texture2D(
                format,
                width,
                height,
                mipLevels: 1,
                flags: ResourceFlags.AllowDepthStencil | ResourceFlags.DenyShaderResource);

            var texture = AddDisposable(graphicsDevice.Device.CreateCommittedResource(
                                            new HeapProperties(HeapType.Default),
                                            HeapFlags.None,
                                            resourceDescription,
                                            ResourceStates.DepthWrite,
                                            new ClearValue
            {
                Format       = format,
                DepthStencil = new DepthStencilValue {
                    Depth = clearValue
                }
            }));

            _descriptorTablePoolEntry = graphicsDevice.DescriptorHeapDsv.Reserve(1);

            graphicsDevice.Device.CreateDepthStencilView(
                texture,
                new DepthStencilViewDescription
            {
                Dimension = DepthStencilViewDimension.Texture2D,
                Format    = format,
                Flags     = DepthStencilViewFlags.None,
                Texture2D =
                {
                    MipSlice = 0
                }
            },
                _descriptorTablePoolEntry.CpuDescriptorHandle);
        }
Example #2
0
 private void PlatformConstruct(GraphicsDevice graphicsDevice, int numResources)
 {
     _cbvUavSrvPoolEntry = graphicsDevice.DescriptorHeapCbvUavSrv.Reserve(numResources);
 }