Exemplo n.º 1
0
        internal static IntPtr CopyStringArrays(List <IntPtr> allocatedItems, string[] array, out uint count)
        {
            if (array == null)
            {
                count = 0U;
                return(IntPtr.Zero);
            }

            int noOfElements = array.Length;

            var dest = IntPtr.Zero;

            //  EnabledLayerNames
            if (noOfElements > 0)
            {
                var POINTER_SIZE = Marshal.SizeOf(typeof(IntPtr));

                dest = Marshal.AllocHGlobal(POINTER_SIZE * noOfElements);
                allocatedItems.Add(dest);

                var names = new IntPtr[noOfElements];
                for (int i = 0; i < noOfElements; ++i)
                {
                    names[i] = VkInteropsUtility.NativeUtf8FromString(array[i]);
                    allocatedItems.Add(names[i]);
                }

                Marshal.Copy(names, 0, dest, noOfElements);
            }

            count = (uint)noOfElements;
            return(dest);
        }
Exemplo n.º 2
0
 static IntPtr CopySingleString(List <IntPtr> allocatedItems, string name)
 {
     if (!string.IsNullOrWhiteSpace(name))
     {
         var dest = VkInteropsUtility.NativeUtf8FromString(name);
         allocatedItems.Add(dest);
         return(dest);
     }
     else
     {
         return(IntPtr.Zero);
     }
 }
Exemplo n.º 3
0
        public Result EnumerateInstanceExtensionProperties(string layerName, out MgExtensionProperties[] pProperties)
        {
            var pLayerName = IntPtr.Zero;

            try
            {
                if (!string.IsNullOrWhiteSpace(layerName))
                {
                    pLayerName = VkInteropsUtility.NativeUtf8FromString(layerName);
                }

                UInt32 pPropertyCount = 0;
                var    first          = Interops.vkEnumerateInstanceExtensionProperties(pLayerName, ref pPropertyCount, null);

                if (first != Result.SUCCESS)
                {
                    pProperties = null;
                    return(first);
                }

                var extensionProperties = new VkExtensionProperties[pPropertyCount];
                var last = Interops.vkEnumerateInstanceExtensionProperties(pLayerName, ref pPropertyCount, extensionProperties);

                pProperties = new MgExtensionProperties[pPropertyCount];
                for (uint i = 0; i < pPropertyCount; ++i)
                {
                    pProperties[i] = new MgExtensionProperties
                    {
                        ExtensionName = VkInteropsUtility.ByteArrayToTrimmedString(extensionProperties[i].extensionName),
                        SpecVersion   = extensionProperties[i].specVersion,
                    };
                }
                return(last);
            }
            finally
            {
                if (pLayerName != IntPtr.Zero)
                {
                }
            }
        }