Ejemplo n.º 1
0
        public void CreateRenderTargetView(DescriptorHeap target, uint descriptorHeapSlot, Resource resource, ref RenderTargetViewDescription description)
        {
            Assert.Debug(target.Desc.Type == DescriptorHeap.Descriptor.ResourceDescriptorType.RenderTarget, "Can create render target views only on render target descriptor heaps.");
            Assert.Debug(target.Desc.NumResourceDescriptors >= descriptorHeapSlot, "Descriptor heap does not have enought slots.");

            target.SetAssociatedResource(descriptorHeapSlot, resource);
            CreateRenderTargetViewImpl(target, descriptorHeapSlot, resource, ref description);
        }
Ejemplo n.º 2
0
        public void AfterEngineInit()
        {
            // Basics.
            {
                var deviceDesc = new Device.Descriptor {DebugDevice = true};
                renderDevice = new ClearSight.RendererDX12.Device(ref deviceDesc,
                    ClearSight.RendererDX12.Device.FeatureLevel.Level_11_0);

                var descCQ = new CommandQueue.Descriptor() {Type = CommandListType.Graphics};
                commandQueue = renderDevice.Create(ref descCQ);

                var wih = new WindowInteropHelper(window);
                var swapChainDesc = new SwapChain.Descriptor()
                {
                    AssociatedGraphicsQueue = commandQueue,

                    MaxFramesInFlight = 3,
                    BufferCount = 3,

                    Width = (uint) window.Width,
                    Height = (uint) window.Height,
                    Format = Format.R8G8B8A8_UNorm,

                    SampleCount = 1,
                    SampleQuality = 0,

                    WindowHandle = wih.Handle,
                    Fullscreen = false
                };
                swapChain = renderDevice.Create(ref swapChainDesc);

                var commandListDesc = new CommandList.Descriptor()
                {
                    Type = CommandListType.Graphics,
                    AllocationPolicy = new CommandListInFlightFrameAllocationPolicy(CommandListType.Graphics, swapChain)
                };
                commandList = renderDevice.Create(ref commandListDesc);
            }

            // Render targets.
            {
                var descHeapDesc = new DescriptorHeap.Descriptor()
                {
                    Type = DescriptorHeap.Descriptor.ResourceDescriptorType.RenderTarget,
                    NumResourceDescriptors = swapChain.Desc.BufferCount
                };
                descHeapRenderTargets = renderDevice.Create(ref descHeapDesc);

                var rtvViewDesc = new RenderTargetViewDescription()
                {
                    Format = swapChain.Desc.Format,
                    Dimension = Dimension.Texture2D,
                    Texture = new TextureSubresourceDesc(mipSlice: 0)
                };
                for (uint i = 0; i < swapChain.Desc.BufferCount; ++i)
                {
                    renderDevice.CreateRenderTargetView(descHeapRenderTargets, i, swapChain.BackbufferResources[i], ref rtvViewDesc);
                }
            }
        }
Ejemplo n.º 3
0
 protected abstract void CreateRenderTargetViewImpl(DescriptorHeap target, uint descriptorHeapSlot, Resource resource, ref RenderTargetViewDescription description);