Exemple #1
0
        protected override void SetRenderTargetsImpl(DescriptorHeap descriptorHeapColor, uint[] slotsColor, DescriptorHeap descriptorHeapDepthStencil, uint slotDepthStencil)
        {
            bool continuous = true;

            for (int i = 1; i < slotsColor.Length; ++i)
            {
                if (slotsColor[i] != slotsColor[i - 1] + 1)
                {
                    continuous = false;
                    break;
                }
            }

            CpuDescriptorHandle?depthStencilCpuDescriptorHandle = ((DescriptorHeapDX)descriptorHeapDepthStencil)?.GetCPUHandle(slotDepthStencil);

            if (continuous)
            {
                CommandListD3D12.SetRenderTargets(slotsColor.Length, ((DescriptorHeapDX)descriptorHeapColor).GetCPUHandle(slotsColor[0]), true, depthStencilCpuDescriptorHandle);
            }
            else
            {
                throw new NotImplementedException("Setting color render targets with non-continuous descriptor slots are not yet supported.");
                //CommandListD3D12.SetRenderTargets(slotsColor.Length, ((Binding.DescriptorHeap)descriptorHeapColor).GetCPUHandle(slotsColor[0]), false, depthStencilCpuDescriptorHandle);
            }
        }
Exemple #2
0
        public RenderPassDepthStencilDesc
        (
            CpuDescriptorHandle?cpuDescriptor = null,
            RenderPassBeginningAccess?depthBeginningAccess   = null,
            RenderPassBeginningAccess?stencilBeginningAccess = null,
            RenderPassEndingAccess?depthEndingAccess         = null,
            RenderPassEndingAccess?stencilEndingAccess       = null
        ) : this()
        {
            if (cpuDescriptor is not null)
            {
                CpuDescriptor = cpuDescriptor.Value;
            }

            if (depthBeginningAccess is not null)
            {
                DepthBeginningAccess = depthBeginningAccess.Value;
            }

            if (stencilBeginningAccess is not null)
            {
                StencilBeginningAccess = stencilBeginningAccess.Value;
            }

            if (depthEndingAccess is not null)
            {
                DepthEndingAccess = depthEndingAccess.Value;
            }

            if (stencilEndingAccess is not null)
            {
                StencilEndingAccess = stencilEndingAccess.Value;
            }
        }
Exemple #3
0
        /// <summary>
        /// <p> Sets CPU descriptor handles for the render targets and depth stencil. </p>
        /// </summary>
        /// <param name="numRenderTargetDescriptors"><dd>  <p> The number of entries in the <em>pRenderTargetDescriptors</em> array. </p> </dd></param>
        /// <param name="renderTargetDescriptorsRef"><dd>  <p> Specifies an array of <strong><see cref="SharpDX.Direct3D12.CpuDescriptorHandle"/></strong> structures that describe the CPU descriptor handles that represents the start of the heap of render target descriptors. </p> </dd></param>
        /// <param name="rTsSingleHandleToDescriptorRange"><dd>  <p><strong>True</strong> means the handle passed in is the reference to a contiguous range of <em>NumRenderTargetDescriptors</em> descriptors.  This case is useful if the set of descriptors to bind already happens to be contiguous in memory (so all that?s needed is a handle to the first one).  For example, if  <em>NumRenderTargetDescriptors</em> is 3 then the memory layout is taken as follows:</p><p>In this case the driver dereferences the handle and then increments the memory being pointed to.</p> <p><strong>False</strong> means that the handle is the first of an array of <em>NumRenderTargetDescriptors</em> handles.  The false case allows an application to bind a set of descriptors from different locations at once. Again assuming that <em>NumRenderTargetDescriptors</em> is 3, the memory layout is taken as follows:</p><p>In this case the driver dereferences three handles that are expected to be adjacent to each other in memory.</p> </dd></param>
        /// <param name="depthStencilDescriptorRef"><dd>  <p> A reference to a <strong><see cref="SharpDX.Direct3D12.CpuDescriptorHandle"/></strong> structure that describes the CPU descriptor handle that represents the start of the heap that holds the depth stencil descriptor. </p> </dd></param>
        /// <include file='.\..\Documentation\CodeComments.xml' path="/comments/comment[@id='ID3D12GraphicsCommandList::OMSetRenderTargets']/*"/>
        /// <msdn-id>dn986884</msdn-id>
        /// <unmanaged>void ID3D12GraphicsCommandList::OMSetRenderTargets([In] unsigned int NumRenderTargetDescriptors,[In, Optional] const void* pRenderTargetDescriptors,[In] BOOL RTsSingleHandleToDescriptorRange,[In, Optional] const D3D12_CPU_DESCRIPTOR_HANDLE* pDepthStencilDescriptor)</unmanaged>
        /// <unmanaged-short>ID3D12GraphicsCommandList::OMSetRenderTargets</unmanaged-short>
        public unsafe void SetRenderTargets(CpuDescriptorHandle?renderTargetDescriptor, SharpDX.Direct3D12.CpuDescriptorHandle?depthStencilDescriptorRef)
        {
            var renderTargetDesc = new CpuDescriptorHandle();

            if (renderTargetDescriptor.HasValue)
            {
                renderTargetDesc = renderTargetDescriptor.Value;
            }
            SetRenderTargets(renderTargetDesc.Ptr != PointerSize.Zero ? 1 : 0, renderTargetDescriptor.HasValue ? new IntPtr(&renderTargetDesc) : IntPtr.Zero, false, depthStencilDescriptorRef);
        }
Exemple #4
0
        public RenderPassRenderTargetDesc
        (
            CpuDescriptorHandle?cpuDescriptor         = null,
            RenderPassBeginningAccess?beginningAccess = null,
            RenderPassEndingAccess?endingAccess       = null
        ) : this()
        {
            if (cpuDescriptor is not null)
            {
                CpuDescriptor = cpuDescriptor.Value;
            }

            if (beginningAccess is not null)
            {
                BeginningAccess = beginningAccess.Value;
            }

            if (endingAccess is not null)
            {
                EndingAccess = endingAccess.Value;
            }
        }
 public unsafe void OMSetRenderTargets(int renderTargetDescriptorsCount, CpuDescriptorHandle[] renderTargetDescriptors, CpuDescriptorHandle?depthStencilDescriptor = null)
 {
     fixed(void *pRT = renderTargetDescriptors)
     {
         OMSetRenderTargets(renderTargetDescriptorsCount, new IntPtr(pRT), false, depthStencilDescriptor);
     }
 }
 public unsafe void OMSetRenderTargets(CpuDescriptorHandle renderTargetDescriptor, CpuDescriptorHandle?depthStencilDescriptor = null)
 {
     OMSetRenderTargets(1, new IntPtr(&renderTargetDescriptor), false, depthStencilDescriptor);
 }
Exemple #7
0
        public void InitializeFrom(BufferDescription description)
        {
            Description = description;

            ResourceStates resourceStates = ResourceStates.Common;



            if (description.HeapType == HeapType.Upload)
            {
                resourceStates |= ResourceStates.GenericRead;
            }


            else if (description.HeapType == HeapType.Readback)
            {
                resourceStates |= ResourceStates.CopyDestination;
            }


            if ((description.Flags & BufferFlags.ConstantBuffer) != 0)
            {
                constantBufferView = CreateConstantBufferView();
            }



            ResourceDescription ResourceDesc = new ResourceDescription()
            {
                Width             = (ulong)SizeInBytes,
                Height            = 1,
                DepthOrArraySize  = 1,
                Dimension         = ResourceDimension.Buffer,
                Alignment         = 65536,
                Layout            = TextureLayout.RowMajor,
                Flags             = ResourceFlags.None,
                MipLevels         = 1,
                Format            = Format.Unknown,
                SampleDescription = new SampleDescription()
                {
                    Count   = 1,
                    Quality = 0
                }
            };



            HeapProperties heapProp = new HeapProperties()
            {
                Type                 = (Vortice.Direct3D12.HeapType)description.HeapType,
                CreationNodeMask     = 1,
                VisibleNodeMask      = 1,
                CPUPageProperty      = CpuPageProperty.Unknown,
                MemoryPoolPreference = MemoryPool.Unknown,
            };

            NativeResource = GraphicsDevice.NativeDevice.CreateCommittedResource <ID3D12Resource>(heapProp, HeapFlags.None, ResourceDesc, resourceStates);



            GPUVirtualAddress = (long)NativeResource.GPUVirtualAddress;


            //return InitializeFrom(resource, description);
        }