From e04e3ba6248d2d44197582ede541beb1ee5039ad Mon Sep 17 00:00:00 2001 From: DockFrankenstein Date: Sat, 16 May 2026 15:39:16 +0200 Subject: [PATCH 1/4] Fixed game settings configuration override specific filter not working --- sources/engine/Stride.Engine/Engine/Game.cs | 3 +++ .../Stride/Data/PlatformConfigurations.cs | 25 ++++++++----------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/sources/engine/Stride.Engine/Engine/Game.cs b/sources/engine/Stride.Engine/Engine/Game.cs index 456221c538..fc03185aa6 100644 --- a/sources/engine/Stride.Engine/Engine/Game.cs +++ b/sources/engine/Stride.Engine/Engine/Game.cs @@ -11,6 +11,7 @@ using Stride.Core.IO; using Stride.Core.Mathematics; using Stride.Core.Storage; +using Stride.Data; using Stride.Engine.Design; using Stride.Engine.Processors; using Stride.Games; @@ -260,6 +261,8 @@ protected override void PrepareContext() // Init assets if (Context.InitializeDatabase) { + PlatformConfigurations.RendererName = GraphicsAdapterFactory.DefaultAdapter?.Name ?? string.Empty; + databaseFileProvider = InitializeAssetDatabase(); ((DatabaseFileProviderService)Services.GetService()).FileProvider = databaseFileProvider; diff --git a/sources/engine/Stride/Data/PlatformConfigurations.cs b/sources/engine/Stride/Data/PlatformConfigurations.cs index 0bfa551ce8..96d689f061 100644 --- a/sources/engine/Stride/Data/PlatformConfigurations.cs +++ b/sources/engine/Stride/Data/PlatformConfigurations.cs @@ -12,9 +12,7 @@ namespace Stride.Data [DataContract] public class PlatformConfigurations { - public static string RendererName = string.Empty; - - public static string DeviceModel = string.Empty; + public static string RendererName { get; set; } = string.Empty; [DataMember] public List Configurations = []; @@ -25,7 +23,7 @@ public class PlatformConfigurations public T Get() where T : Configuration, new() { //find default - var config = Configurations.Where(x => x.Platforms == ConfigPlatforms.None).FirstOrDefault(x => x.Configuration is T); + var config = Configurations.Where(x => x.Platforms == ConfigPlatforms.None).LastOrDefault(x => x.Configuration is T); //perform logic by platform and if required even gpu/cpu/specs @@ -57,21 +55,14 @@ public class PlatformConfigurations } //find per platform if available - var platformConfig = Configurations.Where(x => x.Platforms.HasFlag(platform) && x.SpecificFilter == -1).FirstOrDefault(x => x.Configuration is T); + var platformConfig = Configurations.Where(x => x.Platforms.HasFlag(platform) && x.SpecificFilter == -1).LastOrDefault(x => x.Configuration is T); if (platformConfig != null) { config = platformConfig; } //find per specific renderer settings - platformConfig = Configurations.Where(x => x.Platforms.HasFlag(platform) && x.SpecificFilter != -1 && new Regex(PlatformFilters[x.SpecificFilter], RegexOptions.IgnoreCase).IsMatch(RendererName)).FirstOrDefault(x => x.Configuration is T); - if (platformConfig != null) - { - config = platformConfig; - } - - //find per specific device settings - platformConfig = Configurations.Where(x => x.Platforms.HasFlag(platform) && x.SpecificFilter != -1 && new Regex(PlatformFilters[x.SpecificFilter], RegexOptions.IgnoreCase).IsMatch(DeviceModel)).FirstOrDefault(x => x.Configuration is T); + platformConfig = Configurations.Where(x => x.Platforms.HasFlag(platform) && x.SpecificFilter != -1 && new Regex(PlatformFilters[x.SpecificFilter], RegexOptions.IgnoreCase).IsMatch(RendererName)).LastOrDefault(x => x.Configuration is T); if (platformConfig != null) { config = platformConfig; @@ -79,7 +70,13 @@ public class PlatformConfigurations if (config == null) { - return new T(); + var newInstance = new T(); + Configurations.Add(new() + { + Configuration = newInstance, + }); + + return newInstance; } return (T)config.Configuration; From fc1166c9f3e870f6d019e57e24c6e3745128f2d0 Mon Sep 17 00:00:00 2001 From: DockFrankenstein Date: Sat, 16 May 2026 16:27:48 +0200 Subject: [PATCH 2/4] Fixed using name instead of description --- sources/engine/Stride.Engine/Engine/Game.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/engine/Stride.Engine/Engine/Game.cs b/sources/engine/Stride.Engine/Engine/Game.cs index fc03185aa6..551650df74 100644 --- a/sources/engine/Stride.Engine/Engine/Game.cs +++ b/sources/engine/Stride.Engine/Engine/Game.cs @@ -261,7 +261,7 @@ protected override void PrepareContext() // Init assets if (Context.InitializeDatabase) { - PlatformConfigurations.RendererName = GraphicsAdapterFactory.DefaultAdapter?.Name ?? string.Empty; + PlatformConfigurations.RendererName = GraphicsAdapterFactory.DefaultAdapter?.Description ?? string.Empty; databaseFileProvider = InitializeAssetDatabase(); ((DatabaseFileProviderService)Services.GetService()).FileProvider = databaseFileProvider; From 2703b8f7358bdd09a0cf448e2e1cac07c730d034 Mon Sep 17 00:00:00 2001 From: DockFrankenstein Date: Sat, 16 May 2026 16:57:25 +0200 Subject: [PATCH 3/4] Cleanup --- .../Stride/Data/PlatformConfigurations.cs | 55 +++++++------------ 1 file changed, 21 insertions(+), 34 deletions(-) diff --git a/sources/engine/Stride/Data/PlatformConfigurations.cs b/sources/engine/Stride/Data/PlatformConfigurations.cs index 96d689f061..c6a9a3dbd1 100644 --- a/sources/engine/Stride/Data/PlatformConfigurations.cs +++ b/sources/engine/Stride/Data/PlatformConfigurations.cs @@ -12,6 +12,7 @@ namespace Stride.Data [DataContract] public class PlatformConfigurations { + /// String identifying the rendering device, used for configuration overrides. public static string RendererName { get; set; } = string.Empty; [DataMember] @@ -22,54 +23,40 @@ public class PlatformConfigurations public T Get() where T : Configuration, new() { - //find default + // Find the default for all platforms and devices var config = Configurations.Where(x => x.Platforms == ConfigPlatforms.None).LastOrDefault(x => x.Configuration is T); - //perform logic by platform and if required even gpu/cpu/specs + // Try finding one for the specific platform or hardware configuration - var platform = ConfigPlatforms.None; - switch (Platform.Type) + var platform = Platform.Type switch { - case PlatformType.Shared: - break; - case PlatformType.Windows: - platform = ConfigPlatforms.Windows; - break; - case PlatformType.Android: - platform = ConfigPlatforms.Android; - break; - case PlatformType.iOS: - platform = ConfigPlatforms.iOS; - break; - case PlatformType.UWP: - platform = ConfigPlatforms.UWP; - break; - case PlatformType.Linux: - platform = ConfigPlatforms.Linux; - break; - case PlatformType.macOS: - platform = ConfigPlatforms.macOS; - break; - default: - throw new ArgumentOutOfRangeException(); - } + PlatformType.Shared => ConfigPlatforms.None, + PlatformType.Windows => ConfigPlatforms.Windows, + PlatformType.Android => ConfigPlatforms.Android, + PlatformType.iOS => ConfigPlatforms.iOS, + PlatformType.UWP => ConfigPlatforms.UWP, + PlatformType.Linux => ConfigPlatforms.Linux, + PlatformType.macOS => ConfigPlatforms.macOS, + _ => throw new ArgumentOutOfRangeException(), + }; - //find per platform if available - var platformConfig = Configurations.Where(x => x.Platforms.HasFlag(platform) && x.SpecificFilter == -1).LastOrDefault(x => x.Configuration is T); - if (platformConfig != null) + // Find per platform if available + if (Configurations.Where(x => x.Platforms.HasFlag(platform) && x.SpecificFilter == -1) + .LastOrDefault(x => x.Configuration is T) is { } platformConfig) { config = platformConfig; } - //find per specific renderer settings - platformConfig = Configurations.Where(x => x.Platforms.HasFlag(platform) && x.SpecificFilter != -1 && new Regex(PlatformFilters[x.SpecificFilter], RegexOptions.IgnoreCase).IsMatch(RendererName)).LastOrDefault(x => x.Configuration is T); - if (platformConfig != null) + // Find per specific renderer + if (Configurations.Where(x => x.Platforms.HasFlag(platform) && x.SpecificFilter != -1 && new Regex(PlatformFilters[x.SpecificFilter], RegexOptions.IgnoreCase).IsMatch(RendererName)) + .LastOrDefault(x => x.Configuration is T) is { } rendererConfig) { - config = platformConfig; + config = rendererConfig; } if (config == null) { + // If the requested configuration doesn't exist, create and add a new one var newInstance = new T(); Configurations.Add(new() { From b21104413149214f3e1b83a5e8a8875a3b9029e1 Mon Sep 17 00:00:00 2001 From: Fera <49789311+ferafiks@users.noreply.github.com> Date: Sun, 17 May 2026 09:56:03 +0200 Subject: [PATCH 4/4] Ensured that config overrides with no platform set and a specific filter aren't used as the default on all devices --- sources/engine/Stride/Data/PlatformConfigurations.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/engine/Stride/Data/PlatformConfigurations.cs b/sources/engine/Stride/Data/PlatformConfigurations.cs index c6a9a3dbd1..440b9c31c3 100644 --- a/sources/engine/Stride/Data/PlatformConfigurations.cs +++ b/sources/engine/Stride/Data/PlatformConfigurations.cs @@ -24,7 +24,7 @@ public class PlatformConfigurations public T Get() where T : Configuration, new() { // Find the default for all platforms and devices - var config = Configurations.Where(x => x.Platforms == ConfigPlatforms.None).LastOrDefault(x => x.Configuration is T); + var config = Configurations.Where(x => x.Platforms == ConfigPlatforms.None && x.SpecificFilter == -1).LastOrDefault(x => x.Configuration is T); // Try finding one for the specific platform or hardware configuration