public Gpu(SystemConfiguration systemConfiguration, string GpuRequierement) { CardPcName = DeleteInfo(systemConfiguration.GpuName); CardRequierementName = DeleteInfo(GpuRequierement); // VRAM only double Vram = 0; string TempVram = string.Empty; if (GpuRequierement.ToLower().IndexOf("vram") > -1 && !CallIsNvidia(GpuRequierement) && !CallIsAmd(GpuRequierement)) { TempVram = GpuRequierement.Replace(".", CultureInfo.CurrentCulture.NumberFormat.CurrencyDecimalSeparator); TempVram = Regex.Replace(TempVram, "vram", string.Empty, RegexOptions.IgnoreCase); if (TempVram.ToLower().IndexOf("mb") > -1 && !CallIsNvidia(GpuRequierement) && !CallIsAmd(GpuRequierement)) { double.TryParse(Regex.Replace(TempVram, "mb", string.Empty, RegexOptions.IgnoreCase).Trim(), out Vram); if (Vram > 0) { Vram = Vram * 1024; } } if (TempVram.ToLower().IndexOf("gb") > -1 && !CallIsNvidia(GpuRequierement) && !CallIsAmd(GpuRequierement)) { double.TryParse(Regex.Replace(TempVram, "gb", string.Empty, RegexOptions.IgnoreCase).Trim(), out Vram); if (Vram > 0) { Vram = Vram * 1024 * 1024; } } } // Rezolution only int ResolutionHorizontal = 0; if (GpuRequierement.ToLower().IndexOf("1280×720") > -1 || GpuRequierement.ToLower().IndexOf("1280 × 720") > -1) { ResolutionHorizontal = 1280; } if (GpuRequierement.ToLower().IndexOf("1368×") > -1 || GpuRequierement.ToLower().IndexOf("1368 ×") > -1) { ResolutionHorizontal = 1368; } if (GpuRequierement.ToLower().IndexOf("1600×") > -1 || GpuRequierement.ToLower().IndexOf("1600 ×") > -1) { ResolutionHorizontal = 1600; } if (GpuRequierement.ToLower().IndexOf("1920×") > -1 || GpuRequierement.ToLower().IndexOf("1920 ×") > -1) { ResolutionHorizontal = 1920; } CardPc = SetCard(DeleteInfo(systemConfiguration.GpuName)); CardRequierement = SetCard(DeleteInfo(GpuRequierement)); CardPc.Vram = systemConfiguration.GpuRam; CardRequierement.Vram = (long)Vram; CardPc.ResolutionHorizontal = (int)systemConfiguration.CurrentHorizontalResolution; CardRequierement.ResolutionHorizontal = ResolutionHorizontal; }
public bool IsBetter() { #if DEBUG logger.Debug($"SystemChecker - Gpu.IsBetter - CardPc({CardPcName}): {JsonConvert.SerializeObject(CardPc)}"); logger.Debug($"SystemChecker - Gpu.IsBetter - CardRequierement({CardRequierementName}): {JsonConvert.SerializeObject(CardRequierement)}"); #endif // Old card requiered if (CardRequierement.IsOld || CardPc.IsOld) { return(true); } // DirectX if (CardRequierement.IsDx) { if (CardPc.IsIntegrate) { if (CardRequierement.DxVersion < 10) { IsWithNoCard = true; return(true); } } else { IsWithNoCard = true; return(true); } } // OpenGL if (CardRequierement.IsOGL && CardRequierement.OglVersion < 4) { IsWithNoCard = true; return(true); } // No card defined if (!CardRequierement.IsIntegrate && !CardRequierement.IsNvidia && !CardRequierement.IsAmd) { if (CardRequierement.Vram != 0 && CardRequierement.Vram <= CardPc.Vram) { IsWithNoCard = true; return(true); } if (CardRequierement.ResolutionHorizontal != 0 && CardRequierement.ResolutionHorizontal <= CardPc.ResolutionHorizontal) { IsWithNoCard = true; return(true); } } // Integrate if (CardRequierement.IsIntegrate && (CardPc.IsNvidia || CardPc.IsAmd) && !CardPc.IsOld) { return(true); } if (CardRequierement.IsIntegrate && CardPc.IsIntegrate) { if (CardRequierement.Type == CardPc.Type) { return(CardRequierement.Number <= CardPc.Number); } if (CardRequierement.Type == "HD" && CardPc.Type == "UHD") { return(true); } if (CardRequierement.Number > 999 && CardPc.Number < 1000) { return(true); } if (CardRequierement.Number > 999 && CardPc.Number > 999) { return(CardRequierement.Number < CardPc.Number); } if (CardRequierement.Number < 1000 && CardPc.Number < 1000) { return(CardRequierement.Number < CardPc.Number); } } // Nvidia vs Nvidia if (CardRequierement.IsNvidia && CardPc.IsNvidia) { return(CardRequierement.Number <= CardPc.Number); } // Amd vs Amd if (CardRequierement.IsAmd && CardPc.IsAmd) { if (CardRequierement.Type == CardPc.Type) { return(CardRequierement.Number <= CardPc.Number); } if (CardRequierement.Type == "Radeon HD" && CardRequierement.Type != CardPc.Type) { return(true); } switch (CardRequierement.Type + CardPc.Type) { case "R5R7": return(true); case "R5R9": return(true); case "R5RX": return(true); case "R7R9": return(true); case "R7RX": return(true); case "R9RX": return(true); } } // Nvidia vs Amd if (CardRequierement.IsNvidia && CardPc.IsAmd) { string gpuEquivalenceName = string.Empty; try { List <GpuEquivalence> EquivalenceAmd = Equivalence.FindAll(x => x.Amd.ToLower().Contains(CardRequierement.Number.ToString()) && x.Amd.ToLower().Contains(CardRequierement.Type)).ToList(); bool tempValue = false; foreach (GpuEquivalence gpuEquivalence in EquivalenceAmd) { gpuEquivalenceName = gpuEquivalence.Amd; CardRequierement = SetCard(gpuEquivalenceName); tempValue = IsBetter(); if (tempValue != false) { return(tempValue); } } logger.Warn($"SystemChecker - No equivalence for {JsonConvert.SerializeObject(CardPc)} & {JsonConvert.SerializeObject(CardRequierement)}"); return(false); } catch (Exception ex) { Common.LogError(ex, "SystemChecker", $"Error on IsBetter() for Nvidia vs Amd"); } } // Amd vs Nvidia if (CardRequierement.IsAmd && CardPc.IsNvidia) { string gpuEquivalenceName = string.Empty; try { List <GpuEquivalence> EquivalenceNvidia = Equivalence.FindAll(x => x.Nvidia.ToLower().Contains(CardRequierement.Number.ToString()) && x.Nvidia.ToLower().Contains(CardRequierement.Type)).ToList(); bool tempValue = false; foreach (GpuEquivalence gpuEquivalence in EquivalenceNvidia) { gpuEquivalenceName = gpuEquivalence.Nvidia; CardRequierement = SetCard(gpuEquivalenceName); tempValue = IsBetter(); if (tempValue != false) { return(tempValue); } } } catch (Exception ex) { Common.LogError(ex, "SystemChecker", $"Error on IsBetter() for Amd vs Nvidia"); } logger.Warn($"SystemChecker - No equivalence for {JsonConvert.SerializeObject(CardPc)} & {JsonConvert.SerializeObject(CardRequierement)}"); return(false); } logger.Warn($"SystemChecker - No GPU treatment for {JsonConvert.SerializeObject(CardPc)} & {JsonConvert.SerializeObject(CardRequierement)}"); return(false); }