Exemple #1
0
 internal unsafe void MarshalTo(SharpVk.Interop.DeviceCreateInfo *pointer)
 {
     pointer->SType = StructureType.DeviceCreateInfo;
     pointer->Next  = null;
     if (this.Flags != null)
     {
         pointer->Flags = this.Flags.Value;
     }
     else
     {
         pointer->Flags = default(SharpVk.DeviceCreateFlags);
     }
     pointer->QueueCreateInfoCount = (uint)(this.QueueCreateInfos?.Length ?? 0);
     if (this.QueueCreateInfos != null)
     {
         var fieldPointer = (SharpVk.Interop.DeviceQueueCreateInfo *)(Interop.HeapUtil.AllocateAndClear <SharpVk.Interop.DeviceQueueCreateInfo>(this.QueueCreateInfos.Length).ToPointer());
         for (int index = 0; index < (uint)(this.QueueCreateInfos.Length); index++)
         {
             this.QueueCreateInfos[index].MarshalTo(&fieldPointer[index]);
         }
         pointer->QueueCreateInfos = fieldPointer;
     }
     else
     {
         pointer->QueueCreateInfos = null;
     }
     pointer->EnabledLayerCount = (uint)(this.EnabledLayerNames?.Length ?? 0);
     if (this.EnabledLayerNames != null)
     {
         pointer->EnabledLayerNames = Interop.HeapUtil.MarshalTo(this.EnabledLayerNames);
     }
     else
     {
     }
     pointer->EnabledExtensionCount = (uint)(this.EnabledExtensionNames?.Length ?? 0);
     if (this.EnabledExtensionNames != null)
     {
         pointer->EnabledExtensionNames = Interop.HeapUtil.MarshalTo(this.EnabledExtensionNames);
     }
     else
     {
     }
     if (this.EnabledFeatures != null)
     {
         pointer->EnabledFeatures = (SharpVk.Interop.PhysicalDeviceFeatures *)(Interop.HeapUtil.Allocate <SharpVk.Interop.PhysicalDeviceFeatures>());
         this.EnabledFeatures.Value.MarshalTo(pointer->EnabledFeatures);
     }
     else
     {
         pointer->EnabledFeatures = default(SharpVk.Interop.PhysicalDeviceFeatures *);
     }
 }
Exemple #2
0
 /// <summary>
 /// Create a new device instance.
 /// </summary>
 /// <param name="flags">
 /// Reserved for future use.
 /// </param>
 /// <param name="enabledLayerNames">
 /// ppEnabledLayerNames is deprecated and ignored. See Device Layer
 /// Deprecation.
 /// </param>
 /// <param name="enabledExtensionNames">
 /// An array of enabledExtensionCount strings containing the names of
 /// extensions to enable for the created device. See the Extensions
 /// section for further details.
 /// </param>
 /// <param name="enabledFeatures">
 /// Null or a PhysicalDeviceFeatures structure that contains boolean
 /// indicators of all the features to be enabled. Refer to the Features
 /// section for further details.
 /// </param>
 /// <param name="allocator">
 /// An optional AllocationCallbacks instance that controls host memory
 /// allocation.
 /// </param>
 public unsafe SharpVk.Device CreateDevice(ArrayProxy <SharpVk.DeviceQueueCreateInfo>?queueCreateInfos, ArrayProxy <string>?enabledLayerNames, ArrayProxy <string>?enabledExtensionNames, SharpVk.DeviceCreateFlags?flags = default(SharpVk.DeviceCreateFlags?), SharpVk.PhysicalDeviceFeatures?enabledFeatures = default(SharpVk.PhysicalDeviceFeatures?), SharpVk.Khronos.PhysicalDeviceFeatures2?physicalDeviceFeatures2Khr = null, SharpVk.Khronos.Experimental.DeviceGroupDeviceCreateInfo?deviceGroupDeviceCreateInfoKhx = null, SharpVk.AllocationCallbacks?allocator = default(SharpVk.AllocationCallbacks?))
 {
     try
     {
         SharpVk.Device result = default(SharpVk.Device);
         SharpVk.Interop.DeviceCreateInfo *marshalledCreateInfo = default(SharpVk.Interop.DeviceCreateInfo *);
         void *nextPointer = default(void *);
         SharpVk.Interop.AllocationCallbacks *marshalledAllocator = default(SharpVk.Interop.AllocationCallbacks *);
         SharpVk.Interop.Device marshalledDevice = default(SharpVk.Interop.Device);
         if (physicalDeviceFeatures2Khr != null)
         {
             SharpVk.Interop.Khronos.PhysicalDeviceFeatures2 *extensionPointer = default(SharpVk.Interop.Khronos.PhysicalDeviceFeatures2 *);
             extensionPointer = (SharpVk.Interop.Khronos.PhysicalDeviceFeatures2 *)(Interop.HeapUtil.Allocate <SharpVk.Interop.Khronos.PhysicalDeviceFeatures2>());
             physicalDeviceFeatures2Khr.Value.MarshalTo(extensionPointer);
             extensionPointer->Next = nextPointer;
             nextPointer            = extensionPointer;
         }
         if (deviceGroupDeviceCreateInfoKhx != null)
         {
             SharpVk.Interop.Khronos.Experimental.DeviceGroupDeviceCreateInfo *extensionPointer = default(SharpVk.Interop.Khronos.Experimental.DeviceGroupDeviceCreateInfo *);
             extensionPointer = (SharpVk.Interop.Khronos.Experimental.DeviceGroupDeviceCreateInfo *)(Interop.HeapUtil.Allocate <SharpVk.Interop.Khronos.Experimental.DeviceGroupDeviceCreateInfo>());
             deviceGroupDeviceCreateInfoKhx.Value.MarshalTo(extensionPointer);
             extensionPointer->Next = nextPointer;
             nextPointer            = extensionPointer;
         }
         marshalledCreateInfo        = (SharpVk.Interop.DeviceCreateInfo *)(Interop.HeapUtil.Allocate <SharpVk.Interop.DeviceCreateInfo>());
         marshalledCreateInfo->SType = StructureType.DeviceCreateInfo;
         marshalledCreateInfo->Next  = nextPointer;
         if (flags != null)
         {
             marshalledCreateInfo->Flags = flags.Value;
         }
         else
         {
             marshalledCreateInfo->Flags = default(SharpVk.DeviceCreateFlags);
         }
         marshalledCreateInfo->QueueCreateInfoCount = (uint)(Interop.HeapUtil.GetLength(queueCreateInfos));
         if (queueCreateInfos.IsNull())
         {
             marshalledCreateInfo->QueueCreateInfos = null;
         }
         else
         {
             if (queueCreateInfos.Value.Contents == ProxyContents.Single)
             {
                 marshalledCreateInfo->QueueCreateInfos = (SharpVk.Interop.DeviceQueueCreateInfo *)(Interop.HeapUtil.Allocate <SharpVk.Interop.DeviceQueueCreateInfo>());
                 queueCreateInfos.Value.GetSingleValue().MarshalTo(&*(SharpVk.Interop.DeviceQueueCreateInfo *)(marshalledCreateInfo->QueueCreateInfos));
             }
             else
             {
                 var fieldPointer = (SharpVk.Interop.DeviceQueueCreateInfo *)(Interop.HeapUtil.AllocateAndClear <SharpVk.Interop.DeviceQueueCreateInfo>(Interop.HeapUtil.GetLength(queueCreateInfos.Value)).ToPointer());
                 for (int index = 0; index < (uint)(Interop.HeapUtil.GetLength(queueCreateInfos.Value)); index++)
                 {
                     queueCreateInfos.Value[index].MarshalTo(&fieldPointer[index]);
                 }
                 marshalledCreateInfo->QueueCreateInfos = fieldPointer;
             }
         }
         marshalledCreateInfo->EnabledLayerCount     = (uint)(Interop.HeapUtil.GetLength(enabledLayerNames));
         marshalledCreateInfo->EnabledLayerNames     = Interop.HeapUtil.MarshalTo(enabledLayerNames);
         marshalledCreateInfo->EnabledExtensionCount = (uint)(Interop.HeapUtil.GetLength(enabledExtensionNames));
         marshalledCreateInfo->EnabledExtensionNames = Interop.HeapUtil.MarshalTo(enabledExtensionNames);
         if (enabledFeatures != null)
         {
             marshalledCreateInfo->EnabledFeatures = (SharpVk.Interop.PhysicalDeviceFeatures *)(Interop.HeapUtil.Allocate <SharpVk.Interop.PhysicalDeviceFeatures>());
             enabledFeatures.Value.MarshalTo(marshalledCreateInfo->EnabledFeatures);
         }
         else
         {
             marshalledCreateInfo->EnabledFeatures = default(SharpVk.Interop.PhysicalDeviceFeatures *);
         }
         if (allocator != null)
         {
             marshalledAllocator = (SharpVk.Interop.AllocationCallbacks *)(Interop.HeapUtil.Allocate <SharpVk.Interop.AllocationCallbacks>());
             allocator.Value.MarshalTo(marshalledAllocator);
         }
         else
         {
             marshalledAllocator = default(SharpVk.Interop.AllocationCallbacks *);
         }
         SharpVk.Interop.VkPhysicalDeviceCreateDeviceDelegate commandDelegate = commandCache.GetCommandDelegate <SharpVk.Interop.VkPhysicalDeviceCreateDeviceDelegate>("vkCreateDevice", "");
         Result methodResult = commandDelegate(this.handle, marshalledCreateInfo, marshalledAllocator, &marshalledDevice);
         if (SharpVkException.IsError(methodResult))
         {
             throw SharpVkException.Create(methodResult);
         }
         result = new SharpVk.Device(this, marshalledDevice);
         return(result);
     }
     finally
     {
         Interop.HeapUtil.FreeAll();
     }
 }
Exemple #3
0
 public static extern SharpVk.Result vkCreateDevice(SharpVk.Interop.PhysicalDevice physicalDevice, SharpVk.Interop.DeviceCreateInfo *createInfo, SharpVk.Interop.AllocationCallbacks *allocator, SharpVk.Interop.Device *device);
 /// <summary>
 ///
 /// </summary>
 public unsafe SharpVk.Device CreateDevice(SharpVk.DeviceQueueCreateInfo[] queueCreateInfos, string[] enabledLayerNames, string[] enabledExtensionNames, SharpVk.DeviceCreateFlags?flags = default(SharpVk.DeviceCreateFlags?), SharpVk.PhysicalDeviceFeatures?enabledFeatures = default(SharpVk.PhysicalDeviceFeatures?), SharpVk.AllocationCallbacks?allocator = default(SharpVk.AllocationCallbacks?))
 {
     try
     {
         SharpVk.Device result = default(SharpVk.Device);
         SharpVk.Interop.DeviceCreateInfo *   marshalledCreateInfo = default(SharpVk.Interop.DeviceCreateInfo *);
         SharpVk.Interop.AllocationCallbacks *marshalledAllocator  = default(SharpVk.Interop.AllocationCallbacks *);
         SharpVk.Interop.Device marshalledDevice = default(SharpVk.Interop.Device);
         marshalledCreateInfo        = (SharpVk.Interop.DeviceCreateInfo *)(Interop.HeapUtil.Allocate <SharpVk.Interop.DeviceCreateInfo>());
         marshalledCreateInfo->SType = StructureType.DeviceCreateInfo;
         marshalledCreateInfo->Next  = null;
         if (flags != null)
         {
             marshalledCreateInfo->Flags = flags.Value;
         }
         else
         {
             marshalledCreateInfo->Flags = default(SharpVk.DeviceCreateFlags);
         }
         marshalledCreateInfo->QueueCreateInfoCount = (uint)(queueCreateInfos?.Length ?? 0);
         if (queueCreateInfos != null)
         {
             var fieldPointer = (SharpVk.Interop.DeviceQueueCreateInfo *)(Interop.HeapUtil.AllocateAndClear <SharpVk.Interop.DeviceQueueCreateInfo>(queueCreateInfos.Length).ToPointer());
             for (int index = 0; index < (uint)(queueCreateInfos.Length); index++)
             {
                 queueCreateInfos[index].MarshalTo(&fieldPointer[index]);
             }
             marshalledCreateInfo->QueueCreateInfos = fieldPointer;
         }
         else
         {
             marshalledCreateInfo->QueueCreateInfos = null;
         }
         marshalledCreateInfo->EnabledLayerCount = (uint)(enabledLayerNames?.Length ?? 0);
         if (enabledLayerNames != null)
         {
             marshalledCreateInfo->EnabledLayerNames = Interop.HeapUtil.MarshalTo(enabledLayerNames);
         }
         else
         {
         }
         marshalledCreateInfo->EnabledExtensionCount = (uint)(enabledExtensionNames?.Length ?? 0);
         if (enabledExtensionNames != null)
         {
             marshalledCreateInfo->EnabledExtensionNames = Interop.HeapUtil.MarshalTo(enabledExtensionNames);
         }
         else
         {
         }
         if (enabledFeatures != null)
         {
             marshalledCreateInfo->EnabledFeatures = (SharpVk.Interop.PhysicalDeviceFeatures *)(Interop.HeapUtil.Allocate <SharpVk.Interop.PhysicalDeviceFeatures>());
             enabledFeatures.Value.MarshalTo(marshalledCreateInfo->EnabledFeatures);
         }
         else
         {
             marshalledCreateInfo->EnabledFeatures = default(SharpVk.Interop.PhysicalDeviceFeatures *);
         }
         if (allocator != null)
         {
             marshalledAllocator = (SharpVk.Interop.AllocationCallbacks *)(Interop.HeapUtil.Allocate <SharpVk.Interop.AllocationCallbacks>());
             allocator.Value.MarshalTo(marshalledAllocator);
         }
         else
         {
             marshalledAllocator = default(SharpVk.Interop.AllocationCallbacks *);
         }
         Result methodResult = Interop.Commands.vkCreateDevice(this.handle, marshalledCreateInfo, marshalledAllocator, &marshalledDevice);
         if (SharpVkException.IsError(methodResult))
         {
             throw SharpVkException.Create(methodResult);
         }
         result = new SharpVk.Device(this, marshalledDevice);
         return(result);
     }
     finally
     {
         Interop.HeapUtil.FreeAll();
     }
 }