/// <summary>
 /// Initializes a new instance of the <see cref="ResourceTransitionBarrier" /> struct.
 /// </summary>
 /// <param name="resource">The resource.</param>
 /// <param name="subresource">The subresource.</param>
 /// <param name="stateBefore">The state before.</param>
 /// <param name="stateAfter">The state after.</param>
 /// <exception cref="System.ArgumentNullException">resource</exception>
 public ResourceTransitionBarrier(Resource resource, int subresource, ResourceStates stateBefore, ResourceStates stateAfter)
 {
     if (resource == null) throw new ArgumentNullException("resource");
     ResourcePointer = resource.NativePointer;
     Subresource = subresource;
     StateBefore = stateBefore;
     StateAfter = stateAfter;
 }
Exemple #2
0
 private void DetermineState()
 {
     if (TotalUnits <= 0)
         resourceState = ResourceStates.Consumed;
     else
         resourceState = ResourceStates.Idle;
 }
Exemple #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ResourceTransitionBarrier"/> struct.
 /// </summary>
 /// <param name="resource">The <see cref="ID3D12Resource"/>.</param>
 /// <param name="stateBefore">The state before.</param>
 /// <param name="stateAfter">The state after.</param>
 /// <param name="subresource">The subresource.</param>
 /// <exception cref="System.ArgumentNullException">resource</exception>
 public ResourceTransitionBarrier(ID3D12Resource resource, ResourceStates stateBefore, ResourceStates stateAfter, int subresource = D3D12.ResourceBarrierAllSubResources)
 {
     ResourcePointer = resource.NativePointer;
     Subresource     = subresource;
     StateBefore     = stateBefore;
     StateAfter      = stateAfter;
 }
        public void ResourceBarrier(ID3D12GraphicsCommandList4 pCmdLit, ID3D12Resource pResource, ResourceStates stateBefore, ResourceStates stateAfter)
        {
            ResourceBarrier barrier = new ResourceBarrier(new ResourceTransitionBarrier(pResource, stateBefore, stateAfter));

            pCmdLit.ResourceBarrier(barrier);
        }
Exemple #5
0
 public T CreateReservedResource1 <T>(ResourceDescription description, ResourceStates initialState, ID3D12ProtectedResourceSession protectedResourceSession) where T : ID3D12Resource
 {
     CreateReservedResource1(ref description, initialState, null, protectedResourceSession, typeof(T).GUID, out IntPtr nativePtr).CheckError();
     return(MarshallingHelpers.FromPointer <T>(nativePtr));
 }
Exemple #6
0
 public StructuredBuffer(Resource resource, ResourceStates currentState) : base(resource, currentState)
 {
 }
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);
        }
Exemple #8
0
        /// <summary>
        /// <p> Notifies the driver that it needs to synchronize multiple accesses to resources. </p>
        /// </summary>
        /// <param name="numBarriers"><dd>  <p> The number of submitted barrier descriptions. </p> </dd></param>
        /// <param name="barriersRef"><dd>  <p> Pointer to an array of barrier descriptions. </p> </dd></param>
        /// <remarks>
        /// <p>There are three types of barrier descriptions:</p><ul> <li> <strong><see cref="SharpDX.Direct3D12.ResourceTransitionBarrier"/></strong> -  Transition barriers  indicate that a set of subresources transition between different usages.  The caller must specify the <em>before</em> and <em>after</em> usages of the subresources.  The D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES flag is used to transition all subresources in a resource at the same time. </li> <li> <strong><see cref="SharpDX.Direct3D12.ResourceAliasingBarrier"/></strong> - Aliasing barriers indicate a transition between usages of two different resources which have mappings into the same heap.  The application can specify both the before and the after resource.  Note that one or both resources can be <c>null</c> (indicating that any tiled resource could cause aliasing). </li> <li> <strong><see cref="SharpDX.Direct3D12.ResourceUnorderedAccessViewBarrier"/></strong> - Unordered access view barriers indicate all UAV accesses (read or writes) to a particular resource must complete before any future UAV accesses (read or write) can begin.  The specified resource cannot be <c>null</c>.  It is not necessary to insert a UAV barrier between two draw or dispatch calls which only read a UAV.  Additionally, it is not necessary to insert a UAV barrier between two draw or dispatch calls which write to the same UAV if the application knows that it is safe to execute the UAV accesses in any order.  The resource can be <c>null</c> (indicating that any UAV access could require the barrier). </li> </ul><p> When <strong><see cref="SharpDX.Direct3D12.GraphicsCommandList.ResourceBarrier"/></strong> is passed an array of resource barrier descriptions, the API behaves as if it was called N times (1 for each array element), in the specified order. </p><p> For descriptions of the usage states a subresource can be in, see the <strong><see cref="SharpDX.Direct3D12.ResourceStates"/></strong> enumeration and the Using Resource Barriers to Synchronize Resource States in Direct3D 12 section. </p><p> A subresource can be in any state when <strong><see cref="SharpDX.Direct3D12.GraphicsCommandList.DiscardResource"/></strong> is called. </p><p> When a back buffer is presented, it must be in the <see cref="SharpDX.Direct3D12.ResourceStates.Present"/> state.  If <strong>Present</strong> is called on a resource which is not in the PRESENT state, a debug layer warning will be emitted. </p><p>The resource usage bits are group into two categories, read-only and read/write.</p><p> The following usage bits are read-only: </p><ul> <li><see cref="SharpDX.Direct3D12.ResourceStates.VertexAndConstantBuffer"/></li> <li><see cref="SharpDX.Direct3D12.ResourceStates.IndexBuffer"/></li> <li><see cref="SharpDX.Direct3D12.ResourceStates.NonPixelShaderResource"/></li> <li><see cref="SharpDX.Direct3D12.ResourceStates.PixelShaderResource"/></li> <li><see cref="SharpDX.Direct3D12.ResourceStates.IndirectArgument"/></li> <li><see cref="SharpDX.Direct3D12.ResourceStates.CopySource"/></li> <li><see cref="SharpDX.Direct3D12.ResourceStates.DepthRead"/></li> </ul><p>The following usage bits are read/write:</p><ul> <li><see cref="SharpDX.Direct3D12.ResourceStates.CopyDestination"/></li> <li><see cref="SharpDX.Direct3D12.ResourceStates.RenderTarget"/></li> <li><see cref="SharpDX.Direct3D12.ResourceStates.UnorderedAccess"/></li> <li><see cref="SharpDX.Direct3D12.ResourceStates.DepthWrite"/></li> <li>D3D12_RESOURCE_STATE_GENERATE_MIPS</li> <li><see cref="SharpDX.Direct3D12.ResourceStates.StreamOut"/></li> </ul><p> At most one write bit can be set. If any write bit is set, then no read bit may be set. If no write bit is set, then any number of read bits may be set.  </p><p> At any given time, a subresource is in exactly one  state (determined by a set of flags).  The application must ensure that the states are matched when making a sequence of <strong>ResourceBarrier</strong> calls. In other words, the before and after states in consecutive calls to <strong>ResourceBarrier</strong> must agree. </p><p>To transition all subresources within a resource, the application can set the subresource index to D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES, which implies that all subresources are changed.</p><p> For improved performance, applications should use split barriers (refer to Synchronization and Multi-Engine). Applications should also batch multiple transitions into a single call whenever possible. </p>
        /// </remarks>
        /// <include file='.\..\Documentation\CodeComments.xml' path="/comments/comment[@id='ID3D12GraphicsCommandList::ResourceBarrier']/*"/>
        /// <msdn-id>dn903898</msdn-id>
        /// <unmanaged>void ID3D12GraphicsCommandList::ResourceBarrier([In] unsigned int NumBarriers,[In, Buffer] const void* pBarriers)</unmanaged>
        /// <unmanaged-short>ID3D12GraphicsCommandList::ResourceBarrier</unmanaged-short>
        public unsafe void ResourceBarrierTransition(Resource resource, int subresource, ResourceStates stateBefore, ResourceStates stateAfter)
        {
            var barrier = new ResourceBarrier(new ResourceTransitionBarrier(resource, subresource, stateBefore, stateAfter));

            ResourceBarrier(1, new IntPtr(&barrier));
        }
Exemple #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ResourceTransitionBarrier"/> struct.
        /// </summary>
        /// <param name="resource">The <see cref="ID3D12Resource"/>.</param>
        /// <param name="stateBefore">The state before.</param>
        /// <param name="stateAfter">The state after.</param>
        /// <param name="subresource">The subresource.</param>
        /// <exception cref="System.ArgumentNullException">resource</exception>
        public ResourceTransitionBarrier(ID3D12Resource resource, ResourceStates stateBefore, ResourceStates stateAfter, int subresource = -1)
        {
            Guard.NotNull(resource, nameof(resource));

            ResourcePointer = resource.NativePointer;
            Subresource     = subresource;
            StateBefore     = stateBefore;
            StateAfter      = stateAfter;
            Subresource     = subresource;
        }
Exemple #10
0
 public WPC(string name) : base(name, ResourceType.Storage)
 {
     ResourceStates.SetState("ItemIsProcessed", false);
 }
Exemple #11
0
 /// <summary>
 /// <p> Notifies the driver that it needs to synchronize multiple accesses to resources. </p>
 /// </summary>
 /// <param name="numBarriers"><dd>  <p> The number of submitted barrier descriptions. </p> </dd></param>
 /// <param name="barriersRef"><dd>  <p> Pointer to an array of barrier descriptions. </p> </dd></param>
 /// <remarks>
 /// <p>There are three types of barrier descriptions:</p><ul> <li> <strong><see cref="SharpDX.Direct3D12.ResourceTransitionBarrier"/></strong> -  Transition barriers  indicate that a set of subresources transition between different usages.  The caller must specify the <em>before</em> and <em>after</em> usages of the subresources.  The D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES flag is used to transition all subresources in a resource at the same time. </li> <li> <strong><see cref="SharpDX.Direct3D12.ResourceAliasingBarrier"/></strong> - Aliasing barriers indicate a transition between usages of two different resources which have mappings into the same heap.  The application can specify both the before and the after resource.  Note that one or both resources can be <c>null</c> (indicating that any tiled resource could cause aliasing). </li> <li> <strong><see cref="SharpDX.Direct3D12.ResourceUnorderedAccessViewBarrier"/></strong> - Unordered access view barriers indicate all UAV accesses (read or writes) to a particular resource must complete before any future UAV accesses (read or write) can begin.  The specified resource cannot be <c>null</c>.  It is not necessary to insert a UAV barrier between two draw or dispatch calls which only read a UAV.  Additionally, it is not necessary to insert a UAV barrier between two draw or dispatch calls which write to the same UAV if the application knows that it is safe to execute the UAV accesses in any order.  The resource can be <c>null</c> (indicating that any UAV access could require the barrier). </li> </ul><p> When <strong><see cref="SharpDX.Direct3D12.GraphicsCommandList.ResourceBarrier"/></strong> is passed an array of resource barrier descriptions, the API behaves as if it was called N times (1 for each array element), in the specified order. </p><p> For descriptions of the usage states a subresource can be in, see the <strong><see cref="SharpDX.Direct3D12.ResourceStates"/></strong> enumeration and the Using Resource Barriers to Synchronize Resource States in Direct3D 12 section. </p><p> A subresource can be in any state when <strong><see cref="SharpDX.Direct3D12.GraphicsCommandList.DiscardResource"/></strong> is called. </p><p> When a back buffer is presented, it must be in the <see cref="SharpDX.Direct3D12.ResourceStates.Present"/> state.  If <strong>Present</strong> is called on a resource which is not in the PRESENT state, a debug layer warning will be emitted. </p><p>The resource usage bits are group into two categories, read-only and read/write.</p><p> The following usage bits are read-only: </p><ul> <li><see cref="SharpDX.Direct3D12.ResourceStates.VertexAndConstantBuffer"/></li> <li><see cref="SharpDX.Direct3D12.ResourceStates.IndexBuffer"/></li> <li><see cref="SharpDX.Direct3D12.ResourceStates.NonPixelShaderResource"/></li> <li><see cref="SharpDX.Direct3D12.ResourceStates.PixelShaderResource"/></li> <li><see cref="SharpDX.Direct3D12.ResourceStates.IndirectArgument"/></li> <li><see cref="SharpDX.Direct3D12.ResourceStates.CopySource"/></li> <li><see cref="SharpDX.Direct3D12.ResourceStates.DepthRead"/></li> </ul><p>The following usage bits are read/write:</p><ul> <li><see cref="SharpDX.Direct3D12.ResourceStates.CopyDestination"/></li> <li><see cref="SharpDX.Direct3D12.ResourceStates.RenderTarget"/></li> <li><see cref="SharpDX.Direct3D12.ResourceStates.UnorderedAccess"/></li> <li><see cref="SharpDX.Direct3D12.ResourceStates.DepthWrite"/></li> <li>D3D12_RESOURCE_STATE_GENERATE_MIPS</li> <li><see cref="SharpDX.Direct3D12.ResourceStates.StreamOut"/></li> </ul><p> At most one write bit can be set. If any write bit is set, then no read bit may be set. If no write bit is set, then any number of read bits may be set.  </p><p> At any given time, a subresource is in exactly one  state (determined by a set of flags).  The application must ensure that the states are matched when making a sequence of <strong>ResourceBarrier</strong> calls. In other words, the before and after states in consecutive calls to <strong>ResourceBarrier</strong> must agree. </p><p>To transition all subresources within a resource, the application can set the subresource index to D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES, which implies that all subresources are changed.</p><p> For improved performance, applications should use split barriers (refer to Synchronization and Multi-Engine). Applications should also batch multiple transitions into a single call whenever possible. </p>
 /// </remarks>
 /// <include file='.\..\Documentation\CodeComments.xml' path="/comments/comment[@id='ID3D12GraphicsCommandList::ResourceBarrier']/*"/>
 /// <msdn-id>dn903898</msdn-id>
 /// <unmanaged>void ID3D12GraphicsCommandList::ResourceBarrier([In] unsigned int NumBarriers,[In, Buffer] const void* pBarriers)</unmanaged>
 /// <unmanaged-short>ID3D12GraphicsCommandList::ResourceBarrier</unmanaged-short>
 public void ResourceBarrierTransition(Resource resource, ResourceStates stateBefore, ResourceStates stateAfter)
 {
     ResourceBarrierTransition(resource, -1, stateBefore, stateAfter);
 }
Exemple #12
0
 public ByteAddressBuffer(Resource resource, ResourceStates currentState) : base(resource, currentState)
 {
 }
Exemple #13
0
 public PixelBuffer(Resource resource, ResourceStates usage) : base(resource, usage)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="LinearAllocationPage"/> class.
 /// </summary>
 /// <param name="resource">The <see cref="Resource"/></param>
 /// <param name="usage">The <see cref="ResourceStates"/></param>
 public LinearAllocationPage(Resource resource, ResourceStates usage) : base(resource, usage)
 {
     _GPUVirtualAddress = _Resource.GPUVirtualAddress;
     CPUVirtualAddress  = _Resource.Map(0, null);
 }
 /// <summary>	
 /// <p> Notifies the driver that it needs to synchronize multiple accesses to resources. </p>	
 /// </summary>	
 /// <param name="numBarriers"><dd>  <p> The number of submitted barrier descriptions. </p> </dd></param>	
 /// <param name="barriersRef"><dd>  <p> Pointer to an array of barrier descriptions. </p> </dd></param>	
 /// <remarks>	
 /// <p>There are three types of barrier descriptions:</p><ul> <li> <strong><see cref="SharpDX.Direct3D12.ResourceTransitionBarrier"/></strong> -  Transition barriers  indicate that a set of subresources transition between different usages.  The caller must specify the <em>before</em> and <em>after</em> usages of the subresources.  The D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES flag is used to transition all subresources in a resource at the same time. </li> <li> <strong><see cref="SharpDX.Direct3D12.ResourceAliasingBarrier"/></strong> - Aliasing barriers indicate a transition between usages of two different resources which have mappings into the same heap.  The application can specify both the before and the after resource.  Note that one or both resources can be <c>null</c> (indicating that any tiled resource could cause aliasing). </li> <li> <strong><see cref="SharpDX.Direct3D12.ResourceUnorderedAccessViewBarrier"/></strong> - Unordered access view barriers indicate all UAV accesses (read or writes) to a particular resource must complete before any future UAV accesses (read or write) can begin.  The specified resource cannot be <c>null</c>.  It is not necessary to insert a UAV barrier between two draw or dispatch calls which only read a UAV.  Additionally, it is not necessary to insert a UAV barrier between two draw or dispatch calls which write to the same UAV if the application knows that it is safe to execute the UAV accesses in any order.  The resource can be <c>null</c> (indicating that any UAV access could require the barrier). </li> </ul><p> When <strong><see cref="SharpDX.Direct3D12.GraphicsCommandList.ResourceBarrier"/></strong> is passed an array of resource barrier descriptions, the API behaves as if it was called N times (1 for each array element), in the specified order. </p><p> For descriptions of the usage states a subresource can be in, see the <strong><see cref="SharpDX.Direct3D12.ResourceStates"/></strong> enumeration and the Using Resource Barriers to Synchronize Resource States in Direct3D 12 section. </p><p> A subresource can be in any state when <strong><see cref="SharpDX.Direct3D12.GraphicsCommandList.DiscardResource"/></strong> is called. </p><p> When a back buffer is presented, it must be in the <see cref="SharpDX.Direct3D12.ResourceStates.Present"/> state.  If <strong>Present</strong> is called on a resource which is not in the PRESENT state, a debug layer warning will be emitted. </p><p>The resource usage bits are group into two categories, read-only and read/write.</p><p> The following usage bits are read-only: </p><ul> <li><see cref="SharpDX.Direct3D12.ResourceStates.VertexAndConstantBuffer"/></li> <li><see cref="SharpDX.Direct3D12.ResourceStates.IndexBuffer"/></li> <li><see cref="SharpDX.Direct3D12.ResourceStates.NonPixelShaderResource"/></li> <li><see cref="SharpDX.Direct3D12.ResourceStates.PixelShaderResource"/></li> <li><see cref="SharpDX.Direct3D12.ResourceStates.IndirectArgument"/></li> <li><see cref="SharpDX.Direct3D12.ResourceStates.CopySource"/></li> <li><see cref="SharpDX.Direct3D12.ResourceStates.DepthRead"/></li> </ul><p>The following usage bits are read/write:</p><ul> <li><see cref="SharpDX.Direct3D12.ResourceStates.CopyDestination"/></li> <li><see cref="SharpDX.Direct3D12.ResourceStates.RenderTarget"/></li> <li><see cref="SharpDX.Direct3D12.ResourceStates.UnorderedAccess"/></li> <li><see cref="SharpDX.Direct3D12.ResourceStates.DepthWrite"/></li> <li>D3D12_RESOURCE_STATE_GENERATE_MIPS</li> <li><see cref="SharpDX.Direct3D12.ResourceStates.StreamOut"/></li> </ul><p> At most one write bit can be set. If any write bit is set, then no read bit may be set. If no write bit is set, then any number of read bits may be set.  </p><p> At any given time, a subresource is in exactly one  state (determined by a set of flags).  The application must ensure that the states are matched when making a sequence of <strong>ResourceBarrier</strong> calls. In other words, the before and after states in consecutive calls to <strong>ResourceBarrier</strong> must agree. </p><p>To transition all subresources within a resource, the application can set the subresource index to D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES, which implies that all subresources are changed.</p><p> For improved performance, applications should use split barriers (refer to Synchronization and Multi-Engine). Applications should also batch multiple transitions into a single call whenever possible. </p>	
 /// </remarks>	
 /// <include file='.\..\Documentation\CodeComments.xml' path="/comments/comment[@id='ID3D12GraphicsCommandList::ResourceBarrier']/*"/>	
 /// <msdn-id>dn903898</msdn-id>	
 /// <unmanaged>void ID3D12GraphicsCommandList::ResourceBarrier([In] unsigned int NumBarriers,[In, Buffer] const void* pBarriers)</unmanaged>	
 /// <unmanaged-short>ID3D12GraphicsCommandList::ResourceBarrier</unmanaged-short>	
 public void ResourceBarrierTransition(Resource resource, ResourceStates stateBefore, ResourceStates stateAfter)
 {
     ResourceBarrierTransition(resource, -1, stateBefore, stateAfter);
 }
        public ID3D12Resource CreateBuffer(ID3D12Device5 pDevice, uint size, ResourceFlags flags, ResourceStates initState, HeapProperties heapProps)
        {
            ResourceDescription bufDesc = new ResourceDescription();

            bufDesc.Alignment         = 0;
            bufDesc.DepthOrArraySize  = 1;
            bufDesc.Dimension         = ResourceDimension.Buffer;
            bufDesc.Flags             = flags;
            bufDesc.Format            = Format.Unknown;
            bufDesc.Height            = 1;
            bufDesc.Layout            = TextureLayout.RowMajor;
            bufDesc.MipLevels         = 1;
            bufDesc.SampleDescription = new SampleDescription(1, 0);
            bufDesc.Width             = size;

            ID3D12Resource pBuffer = pDevice.CreateCommittedResource(heapProps, HeapFlags.None, bufDesc, initState, null);

            return(pBuffer);
        }
 /// <summary>	
 /// <p> Notifies the driver that it needs to synchronize multiple accesses to resources. </p>	
 /// </summary>	
 /// <param name="numBarriers"><dd>  <p> The number of submitted barrier descriptions. </p> </dd></param>	
 /// <param name="barriersRef"><dd>  <p> Pointer to an array of barrier descriptions. </p> </dd></param>	
 /// <remarks>	
 /// <p>There are three types of barrier descriptions:</p><ul> <li> <strong><see cref="SharpDX.Direct3D12.ResourceTransitionBarrier"/></strong> -  Transition barriers  indicate that a set of subresources transition between different usages.  The caller must specify the <em>before</em> and <em>after</em> usages of the subresources.  The D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES flag is used to transition all subresources in a resource at the same time. </li> <li> <strong><see cref="SharpDX.Direct3D12.ResourceAliasingBarrier"/></strong> - Aliasing barriers indicate a transition between usages of two different resources which have mappings into the same heap.  The application can specify both the before and the after resource.  Note that one or both resources can be <c>null</c> (indicating that any tiled resource could cause aliasing). </li> <li> <strong><see cref="SharpDX.Direct3D12.ResourceUnorderedAccessViewBarrier"/></strong> - Unordered access view barriers indicate all UAV accesses (read or writes) to a particular resource must complete before any future UAV accesses (read or write) can begin.  The specified resource cannot be <c>null</c>.  It is not necessary to insert a UAV barrier between two draw or dispatch calls which only read a UAV.  Additionally, it is not necessary to insert a UAV barrier between two draw or dispatch calls which write to the same UAV if the application knows that it is safe to execute the UAV accesses in any order.  The resource can be <c>null</c> (indicating that any UAV access could require the barrier). </li> </ul><p> When <strong><see cref="SharpDX.Direct3D12.GraphicsCommandList.ResourceBarrier"/></strong> is passed an array of resource barrier descriptions, the API behaves as if it was called N times (1 for each array element), in the specified order. </p><p> For descriptions of the usage states a subresource can be in, see the <strong><see cref="SharpDX.Direct3D12.ResourceStates"/></strong> enumeration and the Using Resource Barriers to Synchronize Resource States in Direct3D 12 section. </p><p> A subresource can be in any state when <strong><see cref="SharpDX.Direct3D12.GraphicsCommandList.DiscardResource"/></strong> is called. </p><p> When a back buffer is presented, it must be in the <see cref="SharpDX.Direct3D12.ResourceStates.Present"/> state.  If <strong>Present</strong> is called on a resource which is not in the PRESENT state, a debug layer warning will be emitted. </p><p>The resource usage bits are group into two categories, read-only and read/write.</p><p> The following usage bits are read-only: </p><ul> <li><see cref="SharpDX.Direct3D12.ResourceStates.VertexAndConstantBuffer"/></li> <li><see cref="SharpDX.Direct3D12.ResourceStates.IndexBuffer"/></li> <li><see cref="SharpDX.Direct3D12.ResourceStates.NonPixelShaderResource"/></li> <li><see cref="SharpDX.Direct3D12.ResourceStates.PixelShaderResource"/></li> <li><see cref="SharpDX.Direct3D12.ResourceStates.IndirectArgument"/></li> <li><see cref="SharpDX.Direct3D12.ResourceStates.CopySource"/></li> <li><see cref="SharpDX.Direct3D12.ResourceStates.DepthRead"/></li> </ul><p>The following usage bits are read/write:</p><ul> <li><see cref="SharpDX.Direct3D12.ResourceStates.CopyDestination"/></li> <li><see cref="SharpDX.Direct3D12.ResourceStates.RenderTarget"/></li> <li><see cref="SharpDX.Direct3D12.ResourceStates.UnorderedAccess"/></li> <li><see cref="SharpDX.Direct3D12.ResourceStates.DepthWrite"/></li> <li>D3D12_RESOURCE_STATE_GENERATE_MIPS</li> <li><see cref="SharpDX.Direct3D12.ResourceStates.StreamOut"/></li> </ul><p> At most one write bit can be set. If any write bit is set, then no read bit may be set. If no write bit is set, then any number of read bits may be set.  </p><p> At any given time, a subresource is in exactly one  state (determined by a set of flags).  The application must ensure that the states are matched when making a sequence of <strong>ResourceBarrier</strong> calls. In other words, the before and after states in consecutive calls to <strong>ResourceBarrier</strong> must agree. </p><p>To transition all subresources within a resource, the application can set the subresource index to D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES, which implies that all subresources are changed.</p><p> For improved performance, applications should use split barriers (refer to Synchronization and Multi-Engine). Applications should also batch multiple transitions into a single call whenever possible. </p>	
 /// </remarks>	
 /// <include file='.\..\Documentation\CodeComments.xml' path="/comments/comment[@id='ID3D12GraphicsCommandList::ResourceBarrier']/*"/>	
 /// <msdn-id>dn903898</msdn-id>	
 /// <unmanaged>void ID3D12GraphicsCommandList::ResourceBarrier([In] unsigned int NumBarriers,[In, Buffer] const void* pBarriers)</unmanaged>	
 /// <unmanaged-short>ID3D12GraphicsCommandList::ResourceBarrier</unmanaged-short>	
 public unsafe void ResourceBarrierTransition(Resource resource, int subresource, ResourceStates stateBefore, ResourceStates stateAfter)
 {
     var barrier = new ResourceBarrier(new ResourceTransitionBarrier(resource, subresource, stateBefore, stateAfter));
     ResourceBarrier(1, new IntPtr(&barrier));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ResourceTransitionBarrier"/> struct.
 /// </summary>
 /// <param name="resource">The resource.</param>
 /// <param name="stateBefore">The state before.</param>
 /// <param name="stateAfter">The state after.</param>
 /// <exception cref="System.ArgumentNullException">resource</exception>
 public ResourceTransitionBarrier(Resource resource, ResourceStates stateBefore, ResourceStates stateAfter)
     : this(resource, -1, stateBefore, stateAfter)
 {
 }