Пример #1
0
 /// <summary>
 /// Bind device memory to a sparse resource object.
 /// </summary>
 public void BindSparse(ArrayProxy <BindSparseInfo> bindInfo, Fence fence)
 {
     unsafe
     {
         try
         {
             Result commandResult;
             Interop.BindSparseInfo *marshalledBindInfo = null;
             if (bindInfo.Contents != ProxyContents.Null)
             {
                 Interop.BindSparseInfo *arrayPointer = stackalloc Interop.BindSparseInfo[bindInfo.Length];
                 if (bindInfo.Contents == ProxyContents.Single)
                 {
                     bindInfo.GetSingleValue().MarshalTo(arrayPointer);
                 }
                 else
                 {
                     var arrayValue = bindInfo.GetArrayValue();
                     for (int index = 0; index < bindInfo.Length; index++)
                     {
                         arrayValue.Array[arrayValue.Offset + index].MarshalTo(&arrayPointer[index]);
                     }
                 }
                 marshalledBindInfo = arrayPointer;
             }
             else
             {
                 marshalledBindInfo = null;
             }
             Interop.Fence marshalledFence = default(Interop.Fence);
             fence?.MarshalTo(&marshalledFence);
             commandResult = Interop.Commands.vkQueueBindSparse(this.handle, (uint)(bindInfo.Length), marshalledBindInfo, marshalledFence);
             if (SharpVkException.IsError(commandResult))
             {
                 throw SharpVkException.Create(commandResult);
             }
         }
         finally
         {
             Interop.HeapUtil.FreeLog();
         }
     }
 }
Пример #2
0
        internal unsafe void MarshalTo(Interop.BindSparseInfo *pointer)
        {
            pointer->SType = StructureType.BindSparseInfo;
            pointer->Next  = null;

            //WaitSemaphores
            if (this.WaitSemaphores != null)
            {
                var fieldPointer = (Interop.Semaphore *)Interop.HeapUtil.AllocateAndClear <Interop.Semaphore>(this.WaitSemaphores.Length);
                for (int index = 0; index < this.WaitSemaphores.Length; index++)
                {
                    this.WaitSemaphores[index].MarshalTo(&fieldPointer[index]);
                }
                pointer->WaitSemaphores = fieldPointer;
            }
            else
            {
                pointer->WaitSemaphores = null;
            }

            //BufferBinds
            if (this.BufferBinds != null)
            {
                var fieldPointer = (Interop.SparseBufferMemoryBindInfo *)Interop.HeapUtil.AllocateAndClear <Interop.SparseBufferMemoryBindInfo>(this.BufferBinds.Length);
                for (int index = 0; index < this.BufferBinds.Length; index++)
                {
                    this.BufferBinds[index].MarshalTo(&fieldPointer[index]);
                }
                pointer->BufferBinds = fieldPointer;
            }
            else
            {
                pointer->BufferBinds = null;
            }

            //ImageOpaqueBinds
            if (this.ImageOpaqueBinds != null)
            {
                var fieldPointer = (Interop.SparseImageOpaqueMemoryBindInfo *)Interop.HeapUtil.AllocateAndClear <Interop.SparseImageOpaqueMemoryBindInfo>(this.ImageOpaqueBinds.Length);
                for (int index = 0; index < this.ImageOpaqueBinds.Length; index++)
                {
                    this.ImageOpaqueBinds[index].MarshalTo(&fieldPointer[index]);
                }
                pointer->ImageOpaqueBinds = fieldPointer;
            }
            else
            {
                pointer->ImageOpaqueBinds = null;
            }

            //ImageBinds
            if (this.ImageBinds != null)
            {
                var fieldPointer = (Interop.SparseImageMemoryBindInfo *)Interop.HeapUtil.AllocateAndClear <Interop.SparseImageMemoryBindInfo>(this.ImageBinds.Length);
                for (int index = 0; index < this.ImageBinds.Length; index++)
                {
                    this.ImageBinds[index].MarshalTo(&fieldPointer[index]);
                }
                pointer->ImageBinds = fieldPointer;
            }
            else
            {
                pointer->ImageBinds = null;
            }

            //SignalSemaphores
            if (this.SignalSemaphores != null)
            {
                var fieldPointer = (Interop.Semaphore *)Interop.HeapUtil.AllocateAndClear <Interop.Semaphore>(this.SignalSemaphores.Length);
                for (int index = 0; index < this.SignalSemaphores.Length; index++)
                {
                    this.SignalSemaphores[index].MarshalTo(&fieldPointer[index]);
                }
                pointer->SignalSemaphores = fieldPointer;
            }
            else
            {
                pointer->SignalSemaphores = null;
            }
            pointer->WaitSemaphoreCount   = (uint)(this.WaitSemaphores?.Length ?? 0);
            pointer->BufferBindCount      = (uint)(this.BufferBinds?.Length ?? 0);
            pointer->ImageOpaqueBindCount = (uint)(this.ImageOpaqueBinds?.Length ?? 0);
            pointer->ImageBindCount       = (uint)(this.ImageBinds?.Length ?? 0);
            pointer->SignalSemaphoreCount = (uint)(this.SignalSemaphores?.Length ?? 0);
        }
Пример #3
0
 internal BindSparseInfo(Interop.BindSparseInfo* ptr)
 {
     m = ptr;
     Initialize ();
 }
Пример #4
0
 public BindSparseInfo()
 {
     m = (Interop.BindSparseInfo*) Interop.Structure.Allocate (typeof (Interop.BindSparseInfo));
     Initialize ();
 }