Ejemplo n.º 1
0
        public CommandQueueD3D12(D3D12GraphicsDevice device, CommandQueueType queueType)
            : base(device, queueType)
        {
            switch (queueType)
            {
            case CommandQueueType.Graphics:
                CommandListType = CommandListType.Direct;
                break;

            case CommandQueueType.Compute:
                CommandListType = CommandListType.Compute;
                break;

            case CommandQueueType.Copy:
                CommandListType = CommandListType.Copy;
                break;

            default:
                CommandListType = CommandListType.Bundle;
                break;
            }

            D3D12CommandQueue = device.D3D12Device.CreateCommandQueue(CommandListType);
            D3D12CommandQueue.SetName($"{CommandListType} Command Queue");
        }
Ejemplo n.º 2
0
        public SwapchainD3D12(
            D3D12GraphicsDevice device,
            SwapChainDescriptor descriptor,
            int backbufferCount)
            : base(device, descriptor, device.DXGIFactory, device.GraphicsQueue, backbufferCount, backbufferCount)
        {
            _backbufferTextures = new TextureD3D12[backbufferCount];
            for (int i = 0; i < backbufferCount; i++)
            {
                var backBufferTexture = _swapChain.GetBuffer <ID3D12Resource>(i);
                var d3dTextureDesc    = backBufferTexture.Description;
                var textureDescriptor = TextureDescriptor.Texture2D(
                    (int)d3dTextureDesc.Width,
                    d3dTextureDesc.Height,
                    d3dTextureDesc.MipLevels,
                    d3dTextureDesc.DepthOrArraySize,
                    d3dTextureDesc.Format.FromDirectXPixelFormat(),
                    D3D12Convert.Convert(d3dTextureDesc.Flags),
                    (SampleCount)d3dTextureDesc.SampleDescription.Count);

                _backbufferTextures[i] = new TextureD3D12(device, ref textureDescriptor, backBufferTexture);
            }

            // Configure base.
            Configure(descriptor);
        }
Ejemplo n.º 3
0
 public DescriptorAllocator(D3D12GraphicsDevice device, DescriptorHeapType type)
 {
     Device          = device;
     Type            = type;
     IsShaderVisible =
         type == DescriptorHeapType.ConstantBufferViewShaderResourceViewUnorderedAccessView ||
         type == DescriptorHeapType.Sampler;
 }
Ejemplo n.º 4
0
        public TextureD3D12(
            D3D12GraphicsDevice device,
            ref TextureDescriptor descriptor,
            ID3D12Resource nativeTexture)
            : base(device, ref descriptor)
        {
            DXGIFormat = descriptor.Format.ToDirectX();
            if (nativeTexture == null)
            {
                ResourceFlags resourceFlags = ResourceFlags.None;
                if ((descriptor.Usage & TextureUsage.ShaderWrite) != 0)
                {
                    resourceFlags |= ResourceFlags.AllowUnorderedAccess;
                }

                // A multisampled resource must have either D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET or
                // D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL set in D3D12_RESOURCE_DESC::Flags.
                if ((descriptor.Usage & TextureUsage.RenderTarget) != 0 ||
                    descriptor.Samples > 0 ||
                    !PixelFormatUtil.IsCompressed(descriptor.Format))
                {
                    if (PixelFormatUtil.IsDepthStencilFormat(descriptor.Format))
                    {
                        if ((descriptor.Usage & TextureUsage.ShaderRead) == 0)
                        {
                            resourceFlags |= ResourceFlags.DenyShaderResource;
                        }

                        resourceFlags |= ResourceFlags.AllowDepthStencil;
                    }
                    else
                    {
                        resourceFlags |= ResourceFlags.AllowRenderTarget;
                    }
                }
            }
            else
            {
                Resource = nativeTexture;
            }
        }
Ejemplo n.º 5
0
 public FenceD3D12(D3D12GraphicsDevice device, ulong initialValue)
 {
     Device      = device;
     _fence      = device.D3D12Device.CreateFence(initialValue, FenceFlags.None);
     _fenceEvent = new AutoResetEvent(false);
 }
Ejemplo n.º 6
0
 public BufferD3D12(D3D12GraphicsDevice device, in BufferDescriptor descriptor, IntPtr initialData)
Ejemplo n.º 7
0
 public PipelineStateD3D12(D3D12GraphicsDevice device, in RenderPipelineDescriptor descriptor)
Ejemplo n.º 8
0
 public ShaderD3D12(D3D12GraphicsDevice device, ShaderBytecode bytecode)
     : base(device, bytecode)
 {
     D3D12ShaderBytecode = new Vortice.DirectX.Direct3D12.ShaderBytecode(bytecode.Data);
 }