public unsafe void ResourceBarrierUnorderedAccessView(ID3D12Resource resource)
        {
            var barrier = new ResourceBarrier
            {
                Type = ResourceBarrierType.UnorderedAccessView,
                UnorderedAccessView = new ResourceUnorderedAccessViewBarrier(resource)
            };

            ResourceBarrier(1, new IntPtr(&barrier));
        }
 /// <summary>
 /// Discards a resource.
 /// </summary>
 /// <param name="resource">The resource to discard.</param>
 /// <param name="rects">An array of  rectangles in the resource to discard. If null, DiscardResource discards the entire resource.</param>
 /// <param name="firstSubresource">Index of the first subresource in the resource to discard.</param>
 /// <param name="numSubresources">The number of subresources in the resource to discard.</param>
 public unsafe void DiscardResource(ID3D12Resource resource, RawRectangle[] rects, int firstSubresource, int numSubresources)
 {
     DiscardResource(resource, new DiscardRegion
     {
         NumRects         = rects.Length,
         PRects           = (IntPtr)Unsafe.AsPointer(ref rects[0]),
         FirstSubresource = firstSubresource,
         NumSubresources  = numSubresources
     });
 }
        public unsafe void ResourceBarrierAliasing(ID3D12Resource resourceBefore, ID3D12Resource resourceAfter)
        {
            var barrier = new ResourceBarrier
            {
                Type     = ResourceBarrierType.Aliasing,
                Aliasing = new ResourceAliasingBarrier(resourceBefore, resourceAfter)
            };

            ResourceBarrier(1, new IntPtr(&barrier));
        }
 /// <summary>
 /// Discards a resource.
 /// </summary>
 /// <param name="resource">The resource to discard.</param>
 /// <param name="firstSubresource">Index of the first subresource in the resource to discard.</param>
 /// <param name="numSubresources">The number of subresources in the resource to discard.</param>
 public void DiscardResource(ID3D12Resource resource, int firstSubresource, int numSubresources)
 {
     DiscardResource(resource, new DiscardRegion
     {
         NumRects         = 0,
         PRects           = IntPtr.Zero,
         FirstSubresource = firstSubresource,
         NumSubresources  = numSubresources
     });
 }
        public unsafe void ResourceBarrierTransition(
            ID3D12Resource resource,
            ResourceStates stateBefore,
            ResourceStates stateAfter,
            int subresource            = Direct3D12.ResourceBarrier.AllSubResources,
            ResourceBarrierFlags flags = ResourceBarrierFlags.None)
        {
            var barrier = new ResourceBarrier(
                new ResourceTransitionBarrier(resource, stateBefore, stateAfter, subresource),
                flags);

            ResourceBarrier(1, new IntPtr(&barrier));
        }
 /// <summary>
 /// Copy a region of a multisampled or compressed resource into a non-multisampled or non-compressed resource.
 /// </summary>
 /// <param name="dstResource">Destination resource.</param>
 /// <param name="dstSubresource">A zero-based index that identifies the destination subresource. Use <see cref="ID3D12Resource.CalculateSubresource(int, int, int, int, int)"/> to calculate the subresource index if the parent resource is complex.</param>
 /// <param name="dstX">The X coordinate of the left-most edge of the destination region. The width of the destination region is the same as the width of the source rect.</param>
 /// <param name="dstY">The Y coordinate of the top-most edge of the destination region. The height of the destination region is the same as the height of the source rect.</param>
 /// <param name="srcResource">Source resource. Must be multisampled or compressed.</param>
 /// <param name="srcSubresource">A zero-based index that identifies the source subresource.</param>
 /// <param name="format">A <see cref="Format"/> that specifies how the source and destination resource formats are consolidated.</param>
 /// <param name="resolveMode">Specifies the operation used to resolve the source samples.</param>
 public void ResolveSubresourceRegion(
     ID3D12Resource dstResource,
     int dstSubresource,
     int dstX, int dstY,
     ID3D12Resource srcResource,
     int srcSubresource,
     Format format,
     ResolveMode resolveMode = ResolveMode.Decompress)
 {
     ResolveSubresourceRegion_(
         dstResource, dstSubresource, dstX, dstY,
         srcResource, srcSubresource, null,
         format, resolveMode);
 }
 public unsafe void ClearUnorderedAccessView(
     GpuDescriptorHandle viewGpuHandleInCurrentHeap,
     CpuDescriptorHandle viewCpuHandle,
     ID3D12Resource resource,
     Int4 clearValue,
     params InteropRect[] rectangles)
 {
     if (rectangles.Length == 0)
     {
         ClearUnorderedAccessViewUint(viewGpuHandleInCurrentHeap, viewCpuHandle, resource, clearValue, 0, null);
     }
     else
     {
         ClearUnorderedAccessViewUint(viewGpuHandleInCurrentHeap, viewCpuHandle, resource, clearValue, rectangles.Length, rectangles);
     }
 }
        public unsafe void ResourceBarrierTransition(
            ID3D12Resource resource,
            ResourceStates stateBefore,
            ResourceStates stateAfter,
            int subresource            = -1,
            ResourceBarrierFlags flags = ResourceBarrierFlags.None)
        {
            var barrier = new ResourceBarrier
            {
                Type       = ResourceBarrierType.Transition,
                Flags      = flags,
                Transition = new ResourceTransitionBarrier(resource, stateBefore, stateAfter, subresource)
            };

            ResourceBarrier(1, new IntPtr(&barrier));
        }
        public void UpdateTileMappings(
            ID3D12Resource resource,
            TiledResourceCoordinate[] resourceRegionStartCoordinates,
            TileRegionSize[] resourceRegionSizes,
            ID3D12Heap heap,
            TileRangeFlags[] rangeFlags,
            int[] heapRangeStartOffsets,
            int[] rangeTileCounts,
            TileMappingFlags flags = TileMappingFlags.None)
        {
            Guard.NotNull(resource, nameof(resource));

            UpdateTileMappings(resource,
                               resourceRegionStartCoordinates.Length,
                               resourceRegionStartCoordinates,
                               resourceRegionSizes,
                               heap,
                               rangeFlags.Length,
                               rangeFlags,
                               heapRangeStartOffsets,
                               rangeTileCounts,
                               flags);
        }
        public unsafe void ResourceBarrierUnorderedAccessView(ID3D12Resource resource)
        {
            var barrier = new ResourceBarrier(new ResourceUnorderedAccessViewBarrier(resource));

            ResourceBarrier(1, new IntPtr(&barrier));
        }
 /// <summary>
 /// Discards an entire resource.
 /// </summary>
 /// <param name="resource">The resource to discard.</param>
 public void DiscardResource(ID3D12Resource resource)
 {
     DiscardResource(resource, null);
 }