mirror of
				https://github.com/hedge-dev/UnleashedRecomp.git
				synced 2025-10-30 07:11:05 +00:00 
			
		
		
		
	Added MSAA level availability checks (#1446)
This commit is contained in:
		
							parent
							
								
									d15bb7a501
								
							
						
					
					
						commit
						8e0d1f2873
					
				
					 4 changed files with 69 additions and 8 deletions
				
			
		|  | @ -1741,6 +1741,21 @@ bool Video::CreateHostDevice(const char *sdlVideoDriver) | |||
|         ApplyLowEndDefaults(); | ||||
|     } | ||||
| 
 | ||||
|     const RenderSampleCounts colourSampleCount = g_device->getSampleCountsSupported(RenderFormat::R16G16B16A16_FLOAT); | ||||
|     const RenderSampleCounts depthSampleCount  = g_device->getSampleCountsSupported(RenderFormat::D32_FLOAT); | ||||
|     const RenderSampleCounts commonSampleCount = colourSampleCount & depthSampleCount; | ||||
| 
 | ||||
|     // Disable specific MSAA levels if they are not supported.
 | ||||
|     if ((commonSampleCount & RenderSampleCount::COUNT_2) == 0) | ||||
|         Config::AntiAliasing.InaccessibleValues.emplace(EAntiAliasing::MSAA2x); | ||||
|     if ((commonSampleCount & RenderSampleCount::COUNT_4) == 0) | ||||
|         Config::AntiAliasing.InaccessibleValues.emplace(EAntiAliasing::MSAA4x); | ||||
|     if ((commonSampleCount & RenderSampleCount::COUNT_8) == 0) | ||||
|         Config::AntiAliasing.InaccessibleValues.emplace(EAntiAliasing::MSAA8x); | ||||
| 
 | ||||
|     // Set Anti-Aliasing to nearest supported level.
 | ||||
|     Config::AntiAliasing.SnapToNearestAccessibleValue(false); | ||||
| 
 | ||||
|     g_queue = g_device->createCommandQueue(RenderCommandListType::DIRECT); | ||||
| 
 | ||||
|     for (auto& commandList : g_commandLists) | ||||
|  |  | |||
|  | @ -1043,6 +1043,7 @@ static void DrawConfigOption(int32_t rowIndex, float yOffset, ConfigDef<T>* conf | |||
|             } | ||||
| 
 | ||||
|             config->Value = it->first; | ||||
|             config->SnapToNearestAccessibleValue(rightTapped); | ||||
| 
 | ||||
|             if (increment || decrement) | ||||
|                 Game_PlaySound("sys_actstg_pausecursor"); | ||||
|  | @ -1271,7 +1272,7 @@ static void DrawConfigOptions() | |||
|             DrawConfigOption(rowCount++, yOffset, &Config::VSync, true); | ||||
|             DrawConfigOption(rowCount++, yOffset, &Config::FPS, true, nullptr, FPS_MIN, 120, FPS_MAX); | ||||
|             DrawConfigOption(rowCount++, yOffset, &Config::Brightness, true); | ||||
|             DrawConfigOption(rowCount++, yOffset, &Config::AntiAliasing, true); | ||||
|             DrawConfigOption(rowCount++, yOffset, &Config::AntiAliasing, Config::AntiAliasing.InaccessibleValues.size() != 3, &Localise("Options_Desc_NotAvailableHardware")); | ||||
|             DrawConfigOption(rowCount++, yOffset, &Config::TransparencyAntiAliasing, Config::AntiAliasing != EAntiAliasing::None, &Localise("Options_Desc_NotAvailableMSAA")); | ||||
|             DrawConfigOption(rowCount++, yOffset, &Config::ShadowResolution, true); | ||||
|             DrawConfigOption(rowCount++, yOffset, &Config::GITextureFiltering, true); | ||||
|  |  | |||
|  | @ -494,6 +494,9 @@ template<typename T, bool isHidden> | |||
| void ConfigDef<T, isHidden>::MakeDefault() | ||||
| { | ||||
|     Value = DefaultValue; | ||||
| 
 | ||||
|     if constexpr (std::is_enum_v<T>) | ||||
|         SnapToNearestAccessibleValue(false); | ||||
| } | ||||
| 
 | ||||
| template<typename T, bool isHidden> | ||||
|  | @ -696,6 +699,51 @@ void ConfigDef<T, isHidden>::GetLocaleStrings(std::vector<std::string_view>& loc | |||
|     } | ||||
| } | ||||
| 
 | ||||
| template<typename T, bool isHidden> | ||||
| void ConfigDef<T, isHidden>::SnapToNearestAccessibleValue(bool searchUp) | ||||
| { | ||||
|     if constexpr (std::is_enum_v<T>) | ||||
|     { | ||||
|         if (EnumTemplateReverse.empty() || InaccessibleValues.empty()) | ||||
|             return; | ||||
| 
 | ||||
|         if (EnumTemplateReverse.size() == InaccessibleValues.size()) | ||||
|         { | ||||
|             assert(false && "All enum values are marked inaccessible and the nearest accessible value cannot be determined."); | ||||
|             return; | ||||
|         } | ||||
| 
 | ||||
|         auto it = EnumTemplateReverse.find(Value); | ||||
| 
 | ||||
|         if (it == EnumTemplateReverse.end()) | ||||
|         { | ||||
|             assert(false && "Enum value does not exist in the template."); | ||||
|             return; | ||||
|         } | ||||
| 
 | ||||
|         // Skip the enum value if it's marked as inaccessible.
 | ||||
|         while (InaccessibleValues.find(it->first) != InaccessibleValues.end()) | ||||
|         { | ||||
|             if (searchUp) | ||||
|             { | ||||
|                 ++it; | ||||
| 
 | ||||
|                 if (it == EnumTemplateReverse.end()) | ||||
|                     it = EnumTemplateReverse.begin(); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 if (it == EnumTemplateReverse.begin()) | ||||
|                     it = EnumTemplateReverse.end(); | ||||
| 
 | ||||
|                 --it; | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         Value = it->first; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| std::filesystem::path Config::GetConfigPath() | ||||
| { | ||||
|     return GetUserPath() / "config.toml"; | ||||
|  |  | |||
|  | @ -20,6 +20,7 @@ public: | |||
|     virtual std::string GetDefinition(bool withSection = false) const = 0; | ||||
|     virtual std::string ToString(bool strWithQuotes = true) const = 0; | ||||
|     virtual void GetLocaleStrings(std::vector<std::string_view>& localeStrings) const = 0; | ||||
|     virtual void SnapToNearestAccessibleValue(bool searchUp) = 0; | ||||
| }; | ||||
| 
 | ||||
| #define CONFIG_LOCALE            std::unordered_map<ELanguage, std::tuple<std::string, std::string>> | ||||
|  | @ -158,7 +159,8 @@ public: | |||
|     CONFIG_LOCALE* Locale{}; | ||||
|     T DefaultValue{}; | ||||
|     T Value{ DefaultValue }; | ||||
|     std::unordered_map<std::string, T>* EnumTemplate; | ||||
|     std::set<T> InaccessibleValues{}; | ||||
|     std::unordered_map<std::string, T>* EnumTemplate{}; | ||||
|     std::map<T, std::string> EnumTemplateReverse{}; | ||||
|     CONFIG_ENUM_LOCALE(T)* EnumLocale{}; | ||||
|     std::function<void(ConfigDef<T, isHidden>*)> Callback; | ||||
|  | @ -183,25 +185,20 @@ public: | |||
|     ~ConfigDef(); | ||||
| 
 | ||||
|     bool IsHidden() override; | ||||
| 
 | ||||
|     void ReadValue(toml::v3::ex::parse_result& toml) override; | ||||
|     void MakeDefault() override; | ||||
| 
 | ||||
|     std::string_view GetSection() const override; | ||||
|     std::string_view GetName() const override; | ||||
|     std::string GetNameLocalised(ELanguage language) const override; | ||||
|     std::string GetDescription(ELanguage language) const override; | ||||
| 
 | ||||
|     bool IsDefaultValue() const override; | ||||
|     const void* GetValue() const override; | ||||
| 
 | ||||
|     std::string GetValueLocalised(ELanguage language) const override; | ||||
|     std::string GetValueDescription(ELanguage language) const override; | ||||
| 
 | ||||
|     std::string GetDefinition(bool withSection = false) const override; | ||||
|     std::string ToString(bool strWithQuotes = true) const override; | ||||
| 
 | ||||
|     void GetLocaleStrings(std::vector<std::string_view>& localeStrings) const override; | ||||
|     void SnapToNearestAccessibleValue(bool searchUp) override; | ||||
| 
 | ||||
|     operator T() const | ||||
|     { | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Hyper
						Hyper