/// <summary> /// /// </summary> /// <param name="extendedHandle"> /// The CommandBuffer handle to extend. /// </param> /// <param name="info"> /// </param> /// <param name="instanceData"> /// </param> /// <param name="instanceOffset"> /// </param> /// <param name="update"> /// </param> /// <param name="destination"> /// </param> /// <param name="source"> /// </param> /// <param name="scratch"> /// </param> /// <param name="scratchOffset"> /// </param> public static unsafe void BuildAccelerationStructure(this SharpVk.CommandBuffer extendedHandle, SharpVk.NVidia.AccelerationStructureInfo info, SharpVk.Buffer instanceData, ulong instanceOffset, bool update, SharpVk.NVidia.AccelerationStructure destination, SharpVk.NVidia.AccelerationStructure source, SharpVk.Buffer scratch, ulong scratchOffset) { try { CommandCache commandCache = default(CommandCache); SharpVk.Interop.NVidia.AccelerationStructureInfo *marshalledInfo = default(SharpVk.Interop.NVidia.AccelerationStructureInfo *); commandCache = extendedHandle.commandCache; marshalledInfo = (SharpVk.Interop.NVidia.AccelerationStructureInfo *)(Interop.HeapUtil.Allocate <SharpVk.Interop.NVidia.AccelerationStructureInfo>()); info.MarshalTo(marshalledInfo); SharpVk.Interop.NVidia.VkCommandBufferBuildAccelerationStructureDelegate commandDelegate = commandCache.Cache.vkCmdBuildAccelerationStructureNV; commandDelegate(extendedHandle.handle, marshalledInfo, instanceData?.handle ?? default(SharpVk.Interop.Buffer), instanceOffset, update, destination?.handle ?? default(SharpVk.Interop.NVidia.AccelerationStructure), source?.handle ?? default(SharpVk.Interop.NVidia.AccelerationStructure), scratch?.handle ?? default(SharpVk.Interop.Buffer), scratchOffset); } finally { Interop.HeapUtil.FreeAll(); } }
/// <summary> /// /// </summary> /// <param name="pointer"> /// </param> internal unsafe void MarshalTo(SharpVk.Interop.NVidia.AccelerationStructureInfo *pointer) { pointer->SType = StructureType.AccelerationStructureInfo; pointer->Next = null; pointer->Type = this.Type; if (this.Flags != null) { pointer->Flags = this.Flags.Value; } else { pointer->Flags = default(SharpVk.NVidia.BuildAccelerationStructureFlags); } if (this.InstanceCount != null) { pointer->InstanceCount = this.InstanceCount.Value; } else { pointer->InstanceCount = default(uint); } pointer->GeometryCount = (uint)(Interop.HeapUtil.GetLength(this.Geometries)); if (this.Geometries != null) { var fieldPointer = (SharpVk.Interop.NVidia.Geometry *)(Interop.HeapUtil.AllocateAndClear <SharpVk.Interop.NVidia.Geometry>(this.Geometries.Length).ToPointer()); for (int index = 0; index < (uint)(this.Geometries.Length); index++) { this.Geometries[index].MarshalTo(&fieldPointer[index]); } pointer->Geometries = fieldPointer; } else { pointer->Geometries = null; } }