public void CreateDeviceWithDeviceGroupInfo() { ExtensionProperties[] availableExtensions = Instance.EnumerateExtensionProperties(); if (!availableExtensions.Contains(Constant.InstanceExtension.KhxDeviceGroupCreation)) { return; } var instance = new Instance(new InstanceCreateInfo( enabledExtensionNames: new[] { Constant.InstanceExtension.KhxDeviceGroupCreation })); PhysicalDeviceGroupPropertiesKhx physicalDeviceGroup = instance.EnumeratePhysicalDeviceGroupsKhx()[0]; // We need a pointer to the array of native handles. IntPtr devicePtrs = Interop.Struct.AllocToPointer(physicalDeviceGroup.PhysicalDevices.ToHandleArray()); // Fill in the device group create info struct. var deviceGroupCreateInfo = new DeviceGroupDeviceCreateInfoKhx(physicalDeviceGroup.PhysicalDevices.Length, devicePtrs); // We also need a pointer to the create info struct itself. IntPtr createInfoPtr = Interop.Struct.AllocToPointer(ref deviceGroupCreateInfo); // Finally, pass the device group create info pointer to the `Next` chain of device create info. Device device = physicalDeviceGroup.PhysicalDevices[0].CreateDevice(new DeviceCreateInfo( new[] { new DeviceQueueCreateInfo(0, 1, 1.0f) }, next: createInfoPtr)); // Make sure to free unmanaged allocations. Interop.Free(createInfoPtr); Interop.Free(devicePtrs); }
internal static void FromNative(ref Native native, PhysicalDevice[] physicalDevices, out PhysicalDeviceGroupPropertiesKhx managed) { managed.Next = native.Next; managed.PhysicalDevices = physicalDevices; managed.SubsetAllocation = native.SubsetAllocation; }