Beispiel #1
0
        public static VkDeviceCreateInfo.Raw MarshalDirect(this VkDeviceCreateInfo s, ref byte *unmanaged)
        {
            if (s == null)
            {
                throw new InvalidOperationException("Trying to directly marshal a null.");
            }

            var pNext                   = s.Next.MarshalIndirect(ref unmanaged);
            var pQueueCreateInfos       = s.QueueCreateInfos.MarshalDirect(ref unmanaged);
            var ppEnabledLayerNames     = s.EnabledLayerNames.MarshalIndirect(ref unmanaged);
            var ppEnabledExtensionNames = s.EnabledExtensionNames.MarshalIndirect(ref unmanaged);
            var pEnabledFeatures        = s.EnabledFeatures.MarshalIndirect(ref unmanaged);

            VkDeviceCreateInfo.Raw result;
            result.sType = VkStructureType.DeviceCreateInfo;
            result.pNext = pNext;
            result.flags = s.Flags;
            result.queueCreateInfoCount    = s.QueueCreateInfos?.Count ?? 0;
            result.pQueueCreateInfos       = pQueueCreateInfos;
            result.enabledLayerCount       = s.EnabledLayerNames?.Count ?? 0;
            result.ppEnabledLayerNames     = ppEnabledLayerNames;
            result.enabledExtensionCount   = s.EnabledExtensionNames?.Count ?? 0;
            result.ppEnabledExtensionNames = ppEnabledExtensionNames;
            result.pEnabledFeatures        = pEnabledFeatures;
            return(result);
        }
Beispiel #2
0
        public VkObjectResult <IVkDevice> CreateDevice(VkDeviceCreateInfo createInfo, IVkAllocationCallbacks allocator)
        {
            var size =
                createInfo.SizeOfMarshalDirect() +
                allocator.SizeOfMarshalIndirect();

            return(VkHelpers.RunWithUnamangedData(size, u => CreateDevice(u, createInfo, allocator)));
        }
Beispiel #3
0
        public static VkDeviceCreateInfo.Raw *MarshalIndirect(this VkDeviceCreateInfo s, ref byte *unmanaged)
        {
            if (s == null)
            {
                return((VkDeviceCreateInfo.Raw *) 0);
            }
            var result = (VkDeviceCreateInfo.Raw *)unmanaged;

            unmanaged += VkDeviceCreateInfo.Raw.SizeInBytes;
            *result = s.MarshalDirect(ref unmanaged);
            return(result);
        }
Beispiel #4
0
        private VkObjectResult <IVkDevice> CreateDevice(IntPtr data, VkDeviceCreateInfo createInfo, IVkAllocationCallbacks allocator)
        {
            var unmanaged     = (byte *)data;
            var createInfoRaw = createInfo.MarshalDirect(ref unmanaged);
            var pAllocator    = allocator.MarshalIndirect(ref unmanaged);

            VkDevice.HandleType handle;
            var result = Direct.CreateDevice(Handle, &createInfoRaw, pAllocator, &handle);
            var device = result == VkResult.Success ? new VkDevice(this, handle, allocator) : null;

            return(new VkObjectResult <IVkDevice>(result, device));
        }
Beispiel #5
0
        public static int SizeOfMarshalDirect(this VkDeviceCreateInfo s)
        {
            if (s == null)
            {
                throw new InvalidOperationException("Trying to directly marshal a null.");
            }

            return
                (s.Next.SizeOfMarshalIndirect() +
                 s.QueueCreateInfos.SizeOfMarshalDirect() +
                 s.EnabledLayerNames.SizeOfMarshalIndirect() +
                 s.EnabledExtensionNames.SizeOfMarshalIndirect() +
                 s.EnabledFeatures.SizeOfMarshalIndirect());
        }
Beispiel #6
0
 public static int SizeOfMarshalIndirect(this VkDeviceCreateInfo s) =>
 s == null ? 0 : s.SizeOfMarshalDirect() + VkDeviceCreateInfo.Raw.SizeInBytes;
Beispiel #7
0
 private VkObjectResult<IVkDevice> CreateDevice(IntPtr data, VkDeviceCreateInfo createInfo, IVkAllocationCallbacks allocator)
 {
     var unmanaged = (byte*)data;
     var createInfoRaw = createInfo.MarshalDirect(ref unmanaged);
     var pAllocator = allocator.MarshalIndirect(ref unmanaged);
     VkDevice.HandleType handle;
     var result = Direct.CreateDevice(Handle, &createInfoRaw, pAllocator, &handle);
     var device = result == VkResult.Success ? new VkDevice(this, handle, allocator) : null;
     return new VkObjectResult<IVkDevice>(result, device);
 }
Beispiel #8
0
 public VkObjectResult<IVkDevice> CreateDevice(VkDeviceCreateInfo createInfo, IVkAllocationCallbacks allocator)
 {
     var size =
         createInfo.SizeOfMarshalDirect() +
         allocator.SizeOfMarshalIndirect();
     return VkHelpers.RunWithUnamangedData(size, u => CreateDevice(u, createInfo, allocator));
 }