Beispiel #1
0
        /// <summary>
        /// Returns global extension properties.
        /// </summary>
        /// <param name="layerName">
        /// Is either <c>null</c> or a unicode string naming the layer to retrieve extensions from.
        /// When parameter is <c>null</c>, only extensions provided by the Vulkan implementation or
        /// by implicitly enabled layers are returned.
        /// </param>
        /// <returns>Properties of available extensions for layer.</returns>
        /// <exception cref="VulkanException">Vulkan returns an error code.</exception>
        public static ExtensionProperties[] EnumerateExtensionProperties(string layerName = null)
        {
            int dstLayerNameByteCount = Interop.String.GetMaxByteCount(layerName);
            var dstLayerNamePtr       = stackalloc byte[dstLayerNameByteCount];

            Interop.String.ToPointer(layerName, dstLayerNamePtr, dstLayerNameByteCount);

            int    count;
            Result result = vkEnumerateInstanceExtensionProperties(dstLayerNamePtr, &count, null);

            VulkanException.ThrowForInvalidResult(result);

            var propertiesPtr = stackalloc ExtensionProperties.Native[count];

            result = vkEnumerateInstanceExtensionProperties(dstLayerNamePtr, &count, propertiesPtr);
            VulkanException.ThrowForInvalidResult(result);

            var properties = new ExtensionProperties[count];

            for (int i = 0; i < count; i++)
            {
                ExtensionProperties.FromNative(ref propertiesPtr[i], out properties[i]);
            }
            return(properties);
        }
Beispiel #2
0
 internal static void FromNative(ref Native native, out ExtensionProperties managed)
 {
     fixed(byte *extensionNamePtr = native.ExtensionName)
     {
         managed = new ExtensionProperties
         {
             ExtensionName = Interop.String.FromPointer(extensionNamePtr),
             SpecVersion   = native.SpecVersion
         };
     }
 }