コード例 #1
0
 public int Evict([NativeTypeName("UINT")] uint NumObjects, [NativeTypeName("ID3D12Pageable *const *")] ID3D12Pageable **ppObjects)
 {
     return(((delegate * unmanaged <ID3D12Device *, uint, ID3D12Pageable **, int>)(lpVtbl[35]))((ID3D12Device *)Unsafe.AsPointer(ref this), NumObjects, ppObjects));
 }
コード例 #2
0
 public int EnqueueMakeResident(D3D12_RESIDENCY_FLAGS Flags, [NativeTypeName("UINT")] uint NumObjects, [NativeTypeName("ID3D12Pageable *const *")] ID3D12Pageable **ppObjects, ID3D12Fence *pFenceToSignal, [NativeTypeName("UINT64")] ulong FenceValueToSignal)
 {
     return(((delegate * unmanaged <ID3D12Device8 *, D3D12_RESIDENCY_FLAGS, uint, ID3D12Pageable **, ID3D12Fence *, ulong, int>)(lpVtbl[50]))((ID3D12Device8 *)Unsafe.AsPointer(ref this), Flags, NumObjects, ppObjects, pFenceToSignal, FenceValueToSignal));
 }
コード例 #3
0
 public int SetResidencyPriority([NativeTypeName("UINT")] uint NumObjects, [NativeTypeName("ID3D12Pageable *const *")] ID3D12Pageable **ppObjects, [NativeTypeName("const D3D12_RESIDENCY_PRIORITY *")] D3D12_RESIDENCY_PRIORITY *pPriorities)
 {
     return(((delegate * unmanaged <ID3D12Device8 *, uint, ID3D12Pageable **, D3D12_RESIDENCY_PRIORITY *, int>)(lpVtbl[46]))((ID3D12Device8 *)Unsafe.AsPointer(ref this), NumObjects, ppObjects, pPriorities));
 }
コード例 #4
0
 public int MakeResident([NativeTypeName("UINT")] uint NumObjects, [NativeTypeName("ID3D12Pageable *const *")] ID3D12Pageable **ppObjects)
 {
     return(((delegate * stdcall <ID3D12Device8 *, uint, ID3D12Pageable **, int>)(lpVtbl[34]))((ID3D12Device8 *)Unsafe.AsPointer(ref this), NumObjects, ppObjects));
 }
コード例 #5
0
 public HRESULT MakeResident(uint NumObjects, [NativeTypeName("ID3D12Pageable *const *")] ID3D12Pageable **ppObjects)
 {
     return(((delegate * unmanaged <ID3D12Device1 *, uint, ID3D12Pageable **, int>)(lpVtbl[34]))((ID3D12Device1 *)Unsafe.AsPointer(ref this), NumObjects, ppObjects));
 }
コード例 #6
0
        /// <summary>
        /// Asynchronously makes <paramref name="evicted"/> resident on the device
        /// </summary>
        /// <typeparam name="T">The type of the evicted resourcse</typeparam>
        /// <param name="evicted">The <typeparamref name="T"/>s to make resident</param>
        /// <returns>A <see cref="GpuTask"/> that can be used to work out when the resource is resident</returns>
        public GpuTask MakeResidentAsync <T>(ReadOnlySpan <T> evicted) where T : IEvictable
        {
            if (DeviceLevel < SupportedDevice.Device3)
            {
                ThrowHelper.ThrowNotSupportedException(Error_CantMakeResidentAsync);
            }

            var newValue = Interlocked.Increment(ref _lastFenceSignal);

            // classes will never be blittable to pointer, so this handles that
            if (default(T)?.IsBlittableToPointer ?? false)
            {
                fixed(void *pEvictables = &Unsafe.As <T, byte>(ref MemoryMarshal.GetReference(evicted)))
                {
                    ThrowIfFailed(As <ID3D12Device3>()->EnqueueMakeResident(
                                      D3D12_RESIDENCY_FLAGS.D3D12_RESIDENCY_FLAG_DENY_OVERBUDGET,
                                      (uint)evicted.Length,
                                      (ID3D12Pageable **)pEvictables,
                                      _residencyFence.Ptr,
                                      newValue
                                      ));
                }
            }
            else
            {
                if (StackSentinel.SafeToStackallocPointers(evicted.Length))
                {
                    ID3D12Pageable **pEvictables = stackalloc ID3D12Pageable *[evicted.Length];
                    for (int i = 0; i < evicted.Length; i++)
                    {
                        pEvictables[i] = evicted[i].GetPageable();
                    }

                    ThrowIfFailed(As <ID3D12Device3>()->EnqueueMakeResident(
                                      D3D12_RESIDENCY_FLAGS.D3D12_RESIDENCY_FLAG_DENY_OVERBUDGET,
                                      (uint)evicted.Length,
                                      pEvictables,
                                      _residencyFence.Ptr,
                                      newValue
                                      ));
                }
                else
                {
                    using var pool = RentedArray <nuint> .Create(evicted.Length, PinnedArrayPool <nuint> .Default);

                    for (int i = 0; i < evicted.Length; i++)
                    {
                        pool.Value[i] = (nuint)evicted[i].GetPageable();
                    }

                    ThrowIfFailed(As <ID3D12Device3>()->EnqueueMakeResident(
                                      D3D12_RESIDENCY_FLAGS.D3D12_RESIDENCY_FLAG_DENY_OVERBUDGET,
                                      (uint)evicted.Length,
                                      (ID3D12Pageable **)Unsafe.AsPointer(ref MemoryMarshal.GetArrayDataReference(pool.Value)),
                                      _residencyFence.Ptr,
                                      newValue
                                      ));
                }
            }

            return(new GpuTask(this, _residencyFence, newValue));
        }