Example #1
0
        /// <summary>
        /// Get a list of strings extracted from the ISkillExecutionDevice describing it
        /// </summary>
        /// <param name="desc"></param>
        /// <returns></returns>
        public static List <KeyValuePair <string, string> > GetSkillExecutionDeviceStrings(ISkillExecutionDevice device)
        {
            if (device == null)
            {
                return(new List <KeyValuePair <string, string> >());
            }
            List <KeyValuePair <string, string> > result = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("Name", $"{device.Name}"),
                new KeyValuePair <string, string>("Kind", $"{device.ExecutionDeviceKind}"),
            };

            if (device is SkillExecutionDeviceCPU)
            {
                SkillExecutionDeviceCPU cpuDevice = device as SkillExecutionDeviceCPU;
                result.Add(new KeyValuePair <string, string>("CoreCount", $"{cpuDevice.CoreCount}"));
            }
            else if (device is SkillExecutionDeviceDirectX)
            {
                SkillExecutionDeviceDirectX directXDevice = device as SkillExecutionDeviceDirectX;
                result.Add(new KeyValuePair <string, string>("DedicatedVideoMemory", $"{directXDevice.DedicatedVideoMemory}"));
                result.Add(new KeyValuePair <string, string>("MaxSupportedFeatureLevel", $"{directXDevice.MaxSupportedFeatureLevel}"));
                result.Add(new KeyValuePair <string, string>("IsDefault", $"{directXDevice.IsDefault}"));
                result.Add(new KeyValuePair <string, string>("HighPerformanceIndex", $"{directXDevice.HighPerformanceIndex}"));
                result.Add(new KeyValuePair <string, string>("PowerSavingIndex", $"{directXDevice.PowerSavingIndex}"));
                result.Add(new KeyValuePair <string, string>("AdapterId", $"{directXDevice.AdapterId}"));
            }

            return(result);
        }
        public IAsyncOperation <IReadOnlyList <ISkillExecutionDevice> > GetSupportedExecutionDevicesAsync()
        {
            return(AsyncInfo.Run(async(token) =>
            {
                return await Task.Run(() =>
                {
                    var result = new List <ISkillExecutionDevice>();

                    // Add CPU as supported device
                    result.Add(SkillExecutionDeviceCPU.Create());

                    // Retrieve a list of DirectX devices available on the system and filter them by keeping only the ones that support DX12+ feature level
                    var devices = SkillExecutionDeviceDirectX.GetAvailableDirectXExecutionDevices();
                    var compatibleDevices = devices.Where((device) => (device as SkillExecutionDeviceDirectX).MaxSupportedFeatureLevel >= D3DFeatureLevelKind.D3D_FEATURE_LEVEL_12_0);
                    result.AddRange(compatibleDevices);

                    return result as IReadOnlyList <ISkillExecutionDevice>;
                });
            }));
        }