Exemplo n.º 1
0
        public void Initialize(MgApplicationInfo appInfo, MgEnableExtensionsOption options)
        {
            string[] extensions = null;
            if (options == MgEnableExtensionsOption.ALL)
            {
                MgExtensionProperties[] extensionProperties;
                var err = mEntrypoint.EnumerateInstanceExtensionProperties(null, out extensionProperties);

                Debug.Assert(err == Result.SUCCESS, err + " != Result.SUCCESS");

                var enabledExtensions = new List <string>();
                if (extensionProperties != null)
                {
                    foreach (var ext in extensionProperties)
                    {
                        enabledExtensions.Add(ext.ExtensionName);
                    }
                }
                extensions = enabledExtensions.ToArray();
            }

            Initialize(appInfo, null, extensions);
        }
Exemplo n.º 2
0
        public IMgLogicalDevice CreateLogicalDevice(IMgSurfaceKHR presentationSurface, MgEnableExtensionsOption option)
        {
            string[] extensions = null;

            IMgPhysicalDevice[] physicalDevices;
            var errorCode = mInstance.EnumeratePhysicalDevices(out physicalDevices);

            Debug.Assert(errorCode == Result.SUCCESS, errorCode + " != Result.SUCCESS");
            IMgPhysicalDevice firstPhysicalDevice = physicalDevices[0];

            if (option == MgEnableExtensionsOption.ALL)
            {
                MgExtensionProperties[] extensionProperties;
                var err = firstPhysicalDevice.EnumerateDeviceExtensionProperties(null, out extensionProperties);

                Debug.Assert(err == Result.SUCCESS, err + " != Result.SUCCESS");

                var enabledExtensions = new List <string>();
                if (extensionProperties != null)
                {
                    foreach (var ext in extensionProperties)
                    {
                        enabledExtensions.Add(ext.ExtensionName);
                    }
                }
                extensions = enabledExtensions.ToArray();
            }

            return(CreateDevice(firstPhysicalDevice, presentationSurface, MgQueueAllocation.One, MgQueueFlagBits.GRAPHICS_BIT, extensions));
        }