/// <summary> /// Copy results of queries in a query pool to a host memory region. /// </summary> public Result GetResults(uint firstQuery, uint queryCount, ArrayProxy <byte> data, DeviceSize stride, QueryResultFlags flags) { unsafe { try { Result result = default(Result); GCHandle dataHandle = default(GCHandle); byte * marshalledData = null; if (data.Contents != ProxyContents.Null) { if (data.Contents == ProxyContents.Single) { byte *dataPointer = stackalloc byte[1]; * dataPointer = data.GetSingleValue(); marshalledData = dataPointer; } else { var arrayValue = data.GetArrayValue(); dataHandle = GCHandle.Alloc(arrayValue.Array, GCHandleType.Pinned); marshalledData = (byte *)(dataHandle.AddrOfPinnedObject() + (int)(MemUtil.SizeOf <byte>() * arrayValue.Offset)).ToPointer(); } } else { marshalledData = null; } result = Interop.Commands.vkGetQueryPoolResults(this.parent.handle, this.handle, firstQuery, queryCount, (Size)(data.Length), marshalledData, stride, flags); if (SharpVkException.IsError(result)) { throw SharpVkException.Create(result); } if (dataHandle.IsAllocated) { dataHandle.Free(); } return(result); } finally { Interop.HeapUtil.FreeLog(); } } }
/// <summary> /// Submits a sequence of semaphores or command buffers to a queue. /// </summary> public void Submit(ArrayProxy <SubmitInfo> submits, Fence fence) { unsafe { try { Result commandResult; Interop.SubmitInfo *marshalledSubmits = null; if (submits.Contents != ProxyContents.Null) { Interop.SubmitInfo *arrayPointer = stackalloc Interop.SubmitInfo[submits.Length]; if (submits.Contents == ProxyContents.Single) { submits.GetSingleValue().MarshalTo(arrayPointer); } else { var arrayValue = submits.GetArrayValue(); for (int index = 0; index < submits.Length; index++) { arrayValue.Array[arrayValue.Offset + index].MarshalTo(&arrayPointer[index]); } } marshalledSubmits = arrayPointer; } else { marshalledSubmits = null; } Interop.Fence marshalledFence = default(Interop.Fence); fence?.MarshalTo(&marshalledFence); commandResult = Interop.Commands.vkQueueSubmit(this.handle, (uint)(submits.Length), marshalledSubmits, marshalledFence); if (SharpVkException.IsError(commandResult)) { throw SharpVkException.Create(commandResult); } } finally { Interop.HeapUtil.FreeLog(); } } }
/// <summary> /// Combine the data stores of pipeline caches. /// </summary> public void MergePipelineCaches(ArrayProxy <PipelineCache> sourceCaches) { unsafe { try { Result commandResult; Interop.PipelineCache *marshalledSourceCaches = null; if (sourceCaches.Contents != ProxyContents.Null) { Interop.PipelineCache *arrayPointer = stackalloc Interop.PipelineCache[sourceCaches.Length]; if (sourceCaches.Contents == ProxyContents.Single) { sourceCaches.GetSingleValue().MarshalTo(arrayPointer); } else { var arrayValue = sourceCaches.GetArrayValue(); for (int index = 0; index < sourceCaches.Length; index++) { arrayValue.Array[arrayValue.Offset + index].MarshalTo(&arrayPointer[index]); } } marshalledSourceCaches = arrayPointer; } else { marshalledSourceCaches = null; } commandResult = Interop.Commands.vkMergePipelineCaches(this.parent.handle, this.handle, (uint)(sourceCaches.Length), marshalledSourceCaches); if (SharpVkException.IsError(commandResult)) { throw SharpVkException.Create(commandResult); } } finally { Interop.HeapUtil.FreeLog(); } } }
/// <summary> /// Free one or more descriptor sets. /// </summary> public void FreeDescriptorSets(ArrayProxy <DescriptorSet> descriptorSets) { unsafe { try { Result commandResult; Interop.DescriptorSet *marshalledDescriptorSets = null; if (descriptorSets.Contents != ProxyContents.Null) { Interop.DescriptorSet *arrayPointer = stackalloc Interop.DescriptorSet[descriptorSets.Length]; if (descriptorSets.Contents == ProxyContents.Single) { descriptorSets.GetSingleValue().MarshalTo(arrayPointer); } else { var arrayValue = descriptorSets.GetArrayValue(); for (int index = 0; index < descriptorSets.Length; index++) { arrayValue.Array[arrayValue.Offset + index].MarshalTo(&arrayPointer[index]); } } marshalledDescriptorSets = arrayPointer; } else { marshalledDescriptorSets = null; } commandResult = Interop.Commands.vkFreeDescriptorSets(this.parent.handle, this.handle, (uint)(descriptorSets.Length), marshalledDescriptorSets); if (SharpVkException.IsError(commandResult)) { throw SharpVkException.Create(commandResult); } } finally { Interop.HeapUtil.FreeLog(); } } }
/// <summary> /// Free command buffers. /// </summary> public void FreeCommandBuffers(ArrayProxy <CommandBuffer> commandBuffers) { unsafe { try { Interop.CommandBuffer *marshalledCommandBuffers = null; if (commandBuffers.Contents != ProxyContents.Null) { Interop.CommandBuffer *arrayPointer = stackalloc Interop.CommandBuffer[commandBuffers.Length]; if (commandBuffers.Contents == ProxyContents.Single) { commandBuffers.GetSingleValue().MarshalTo(arrayPointer); } else { var arrayValue = commandBuffers.GetArrayValue(); for (int index = 0; index < commandBuffers.Length; index++) { arrayValue.Array[arrayValue.Offset + index].MarshalTo(&arrayPointer[index]); } } marshalledCommandBuffers = arrayPointer; } else { marshalledCommandBuffers = null; } Interop.Commands.vkFreeCommandBuffers(this.parent.handle, this.handle, (uint)(commandBuffers.Length), marshalledCommandBuffers); } finally { Interop.HeapUtil.FreeLog(); } } }
/// <summary> /// - /// </summary> public void RegisterObjects(ArrayProxy <ObjectTableEntry> objectTableEntries, ArrayProxy <uint> objectIndices) { unsafe { try { var commandDelegate = this.commandCache.GetCommandDelegate <Interop.vkRegisterObjectsNVX>("vkRegisterObjectsNVX", "device"); Result commandResult; GCHandle objectTableEntriesHandle = default(GCHandle); ObjectTableEntry * marshalledObjectTableEntries = null; ObjectTableEntry **doubleMarshalledObjectTableEntries = null; if (objectTableEntries.Contents != ProxyContents.Null) { if (objectTableEntries.Contents == ProxyContents.Single) { ObjectTableEntry *dataPointer = stackalloc ObjectTableEntry[1]; *dataPointer = objectTableEntries.GetSingleValue(); marshalledObjectTableEntries = dataPointer; doubleMarshalledObjectTableEntries = &marshalledObjectTableEntries; } else { var arrayValue = objectTableEntries.GetArrayValue(); objectTableEntriesHandle = GCHandle.Alloc(arrayValue.Array, GCHandleType.Pinned); marshalledObjectTableEntries = (ObjectTableEntry *)(objectTableEntriesHandle.AddrOfPinnedObject() + (int)(MemUtil.SizeOf <ObjectTableEntry>() * arrayValue.Offset)).ToPointer(); ObjectTableEntry **dataPointer = stackalloc ObjectTableEntry *[objectTableEntries.Length]; doubleMarshalledObjectTableEntries = dataPointer; for (int marshalIndex = 0; marshalIndex < objectTableEntries.Length; marshalIndex++) { doubleMarshalledObjectTableEntries[marshalIndex] = &marshalledObjectTableEntries[marshalIndex]; } } } else { marshalledObjectTableEntries = null; } GCHandle objectIndicesHandle = default(GCHandle); uint * marshalledObjectIndices = null; if (objectIndices.Contents != ProxyContents.Null) { if (objectIndices.Contents == ProxyContents.Single) { uint *dataPointer = stackalloc uint[1]; * dataPointer = objectIndices.GetSingleValue(); marshalledObjectIndices = dataPointer; } else { var arrayValue = objectIndices.GetArrayValue(); objectIndicesHandle = GCHandle.Alloc(arrayValue.Array, GCHandleType.Pinned); marshalledObjectIndices = (uint *)(objectIndicesHandle.AddrOfPinnedObject() + (int)(MemUtil.SizeOf <uint>() * arrayValue.Offset)).ToPointer(); } } else { marshalledObjectIndices = null; } commandResult = commandDelegate(this.parent.handle, this.handle, (uint)(objectIndices.Length), doubleMarshalledObjectTableEntries, marshalledObjectIndices); if (SharpVkException.IsError(commandResult)) { throw SharpVkException.Create(commandResult); } if (objectTableEntriesHandle.IsAllocated) { objectTableEntriesHandle.Free(); } if (objectIndicesHandle.IsAllocated) { objectIndicesHandle.Free(); } } finally { Interop.HeapUtil.FreeLog(); } } }