Skip to content

Commit

Permalink
[Graphics] Removed PreferredGraphicsPlatform from RenderingSettings
Browse files Browse the repository at this point in the history
  • Loading branch information
xen2 committed Dec 7, 2018
1 parent a006a76 commit fa1acae
Show file tree
Hide file tree
Showing 35 changed files with 2 additions and 155 deletions.
Expand Up @@ -12,7 +12,6 @@ Defaults:
DefaultGraphicsProfile: Level_9_3
ColorSpace: Linear
DisplayOrientation: LandscapeRight
PreferredGraphicsPlatform: Default
- !Xenko.Assets.EditorSettings,Xenko.Assets
RenderingMode: HDR
- !Xenko.Assets.Textures.TextureSettings,Xenko.Assets
Expand Down
Expand Up @@ -12,7 +12,6 @@ Defaults:
DefaultGraphicsProfile: Level_9_3
ColorSpace: Linear
DisplayOrientation: Portrait
PreferredGraphicsPlatform: Default
- !Xenko.Assets.EditorSettings,Xenko.Assets
RenderingMode: HDR
- !Xenko.Assets.Textures.TextureSettings,Xenko.Assets
Expand Down
Expand Up @@ -12,7 +12,6 @@ Defaults:
DefaultGraphicsProfile: Level_9_3
ColorSpace: Linear
DisplayOrientation: Portrait
PreferredGraphicsPlatform: Default
- !Xenko.Assets.EditorSettings,Xenko.Assets
RenderingMode: HDR
- !Xenko.Assets.Textures.TextureSettings,Xenko.Assets
Expand Down
Expand Up @@ -12,7 +12,6 @@ Defaults:
DefaultGraphicsProfile: Level_9_3
ColorSpace: Linear
DisplayOrientation: Portrait
PreferredGraphicsPlatform: Default
- !Xenko.Assets.EditorSettings,Xenko.Assets
RenderingMode: HDR
- !Xenko.Assets.Textures.TextureSettings,Xenko.Assets
Expand Down
Expand Up @@ -12,7 +12,6 @@ Defaults:
DefaultGraphicsProfile: Level_9_3
ColorSpace: Linear
DisplayOrientation: LandscapeRight
PreferredGraphicsPlatform: Default
- !Xenko.Assets.EditorSettings,Xenko.Assets
RenderingMode: HDR
- !Xenko.Assets.Textures.TextureSettings,Xenko.Assets
Expand Down
Expand Up @@ -12,7 +12,6 @@ Defaults:
DefaultGraphicsProfile: Level_10_0
ColorSpace: Linear
DisplayOrientation: LandscapeRight
PreferredGraphicsPlatform: Default
- !Xenko.Assets.EditorSettings,Xenko.Assets
RenderingMode: HDR
- !Xenko.Assets.Textures.TextureSettings,Xenko.Assets
Expand Down
Expand Up @@ -12,7 +12,6 @@ Defaults:
DefaultGraphicsProfile: Level_9_3
ColorSpace: Linear
DisplayOrientation: LandscapeRight
PreferredGraphicsPlatform: Default
- !Xenko.Assets.EditorSettings,Xenko.Assets
RenderingMode: HDR
- !Xenko.Assets.Textures.TextureSettings,Xenko.Assets
Expand Down
Expand Up @@ -12,7 +12,6 @@ Defaults:
DefaultGraphicsProfile: Level_9_3
ColorSpace: Linear
DisplayOrientation: LandscapeRight
PreferredGraphicsPlatform: Default
- !Xenko.Assets.EditorSettings,Xenko.Assets
RenderingMode: HDR
- !Xenko.Assets.Textures.TextureSettings,Xenko.Assets
Expand Down
Expand Up @@ -12,7 +12,6 @@ Defaults:
DefaultGraphicsProfile: Level_9_3
ColorSpace: Linear
DisplayOrientation: Default
PreferredGraphicsPlatform: Default
- !Xenko.Assets.EditorSettings,Xenko.Assets
RenderingMode: HDR
- !Xenko.Assets.Textures.TextureSettings,Xenko.Assets
Expand Down
Expand Up @@ -12,7 +12,6 @@ Defaults:
DefaultGraphicsProfile: Level_9_3
ColorSpace: Linear
DisplayOrientation: LandscapeRight
PreferredGraphicsPlatform: Default
- !Xenko.Assets.EditorSettings,Xenko.Assets
RenderingMode: HDR
- !Xenko.Assets.Textures.TextureSettings,Xenko.Assets
Expand Down
Expand Up @@ -12,7 +12,6 @@ Defaults:
DefaultGraphicsProfile: Level_9_3
ColorSpace: Linear
DisplayOrientation: LandscapeRight
PreferredGraphicsPlatform: Default
- !Xenko.Assets.EditorSettings,Xenko.Assets
RenderingMode: HDR
- !Xenko.Assets.Textures.TextureSettings,Xenko.Assets
Expand Down
Expand Up @@ -12,7 +12,6 @@ Defaults:
DefaultGraphicsProfile: Level_9_3
ColorSpace: Linear
DisplayOrientation: LandscapeRight
PreferredGraphicsPlatform: Default
- !Xenko.Assets.EditorSettings,Xenko.Assets
RenderingMode: HDR
- !Xenko.Assets.Textures.TextureSettings,Xenko.Assets
Expand Down
Expand Up @@ -12,7 +12,6 @@ Defaults:
DefaultGraphicsProfile: Level_10_0
ColorSpace: Linear
DisplayOrientation: LandscapeRight
PreferredGraphicsPlatform: Default
- !Xenko.Assets.EditorSettings,Xenko.Assets
RenderingMode: HDR
- !Xenko.Assets.Textures.TextureSettings,Xenko.Assets
Expand Down
Expand Up @@ -12,7 +12,6 @@ Defaults:
DefaultGraphicsProfile: Level_10_0
ColorSpace: Linear
DisplayOrientation: LandscapeRight
PreferredGraphicsPlatform: Default
- !Xenko.Assets.EditorSettings,Xenko.Assets
RenderingMode: HDR
- !Xenko.Assets.Textures.TextureSettings,Xenko.Assets
Expand Down
Expand Up @@ -12,7 +12,6 @@ Defaults:
DefaultGraphicsProfile: Level_10_0
ColorSpace: Linear
DisplayOrientation: LandscapeRight
PreferredGraphicsPlatform: Default
- !Xenko.Assets.EditorSettings,Xenko.Assets
RenderingMode: HDR
- !Xenko.Assets.Textures.TextureSettings,Xenko.Assets
Expand Down
Expand Up @@ -12,7 +12,6 @@ Defaults:
DefaultGraphicsProfile: Level_11_0
ColorSpace: Linear
DisplayOrientation: LandscapeRight
PreferredGraphicsPlatform: Default
- !Xenko.Assets.EditorSettings,Xenko.Assets
RenderingMode: HDR
- !Xenko.Assets.Textures.TextureSettings,Xenko.Assets
Expand Down
Expand Up @@ -12,7 +12,6 @@ Defaults:
DefaultGraphicsProfile: Level_9_3
ColorSpace: Linear
DisplayOrientation: Portrait
PreferredGraphicsPlatform: Default
- !Xenko.Assets.EditorSettings,Xenko.Assets
RenderingMode: HDR
- !Xenko.Assets.Textures.TextureSettings,Xenko.Assets
Expand Down
Expand Up @@ -12,7 +12,6 @@ Defaults:
DefaultGraphicsProfile: Level_10_0
ColorSpace: Linear
DisplayOrientation: Portrait
PreferredGraphicsPlatform: Default
- !Xenko.Assets.EditorSettings,Xenko.Assets
RenderingMode: HDR
- !Xenko.Assets.Textures.TextureSettings,Xenko.Assets
Expand Down
Expand Up @@ -12,7 +12,6 @@ Defaults:
DefaultGraphicsProfile: Level_9_3
ColorSpace: Linear
DisplayOrientation: Portrait
PreferredGraphicsPlatform: Default
- !Xenko.Assets.EditorSettings,Xenko.Assets
RenderingMode: HDR
- !Xenko.Assets.Textures.TextureSettings,Xenko.Assets
Expand Down
27 changes: 0 additions & 27 deletions sources/assets/Xenko.Core.Assets.CompilerApp/PackageBuilder.cs
Expand Up @@ -167,33 +167,6 @@ private BuildResultCode BuildMaster()
}
}

private BuildResultCode BuildGetGraphicsPlatform()
{
var loadParameters = new PackageLoadParameters
{
AutoLoadTemporaryAssets = true,
LoadAssemblyReferences = false,
AutoCompileProjects = false,
TemporaryAssetFilter = (asset) => asset.AssetLocation == GameSettingsAsset.GameSettingsLocation,
TemporaryAssetsInMsbuild = false,
};
var sessionResult = PackageSession.Load(builderOptions.PackageFile, loadParameters);
var simplePackage = sessionResult.Session.Packages.First();
sessionResult.Session.LoadMissingReferences(sessionResult, loadParameters);

if (simplePackage == null || sessionResult.HasErrors)
{
sessionResult.CopyTo(builderOptions.Logger);
return BuildResultCode.BuildError;
}

var settings = simplePackage.GetGameSettingsAsset();
var renderingSettings = settings.GetOrCreate<RenderingSettings>();

Console.WriteLine(RenderingSettings.GetGraphicsPlatform(builderOptions.Platform, renderingSettings.PreferredGraphicsPlatform));
return BuildResultCode.Successful;
}

private void RegisterBuildStepProcessedHandler(object sender, AssetCompiledArgs e)
{
if (e.Result.BuildSteps == null)
Expand Down
Expand Up @@ -12,7 +12,6 @@ Defaults:
DefaultGraphicsProfile: Level_11_0
ColorSpace: Linear
DisplayOrientation: Default
PreferredGraphicsPlatform: Default
- !Xenko.Assets.EditorSettings,Xenko.Assets
RenderingMode: HDR
- !Xenko.Assets.Textures.TextureSettings,Xenko.Assets
Expand Down
Expand Up @@ -14,7 +14,6 @@ Defaults:
DefaultGraphicsProfile: Level_9_1
ColorSpace: Gamma
DisplayOrientation: Default
PreferredGraphicsPlatform: Default
- !Xenko.Assets.EditorSettings,Xenko.Assets
RenderingMode: HDR
- !Xenko.Assets.Textures.TextureSettings,Xenko.Assets
Expand Down
5 changes: 2 additions & 3 deletions sources/engine/Xenko.Assets/AssetCompilerContextExtensions.cs
Expand Up @@ -36,9 +36,8 @@ public static GraphicsPlatform GetGraphicsPlatform(this AssetCompilerContext con
if (context.OptionProperties.TryGetValue("XenkoGraphicsApi", out graphicsApi))
return (GraphicsPlatform)Enum.Parse(typeof(GraphicsPlatform), graphicsApi);

// Ohterwise, use game settings, or default as fallback
var settings = package.GetGameSettingsAsset();
return settings == null ? context.Platform.GetDefaultGraphicsPlatform() : RenderingSettings.GetGraphicsPlatform(context.Platform, settings.GetOrCreate<RenderingSettings>().PreferredGraphicsPlatform);
// Ohterwise, use default as fallback
return context.Platform.GetDefaultGraphicsPlatform();
}

public static GraphicsPlatform GetDefaultGraphicsPlatform(this PlatformType platformType)
Expand Down
Expand Up @@ -14,7 +14,6 @@ Defaults:
DefaultGraphicsProfile: Level_9_1
ColorSpace: Linear
DisplayOrientation: Default
PreferredGraphicsPlatform: Default
- !Xenko.Assets.EditorSettings,Xenko.Assets
RenderingMode: HDR
- !Xenko.Assets.Textures.TextureSettings,Xenko.Assets
Expand Down
Expand Up @@ -14,7 +14,6 @@ Defaults:
DefaultGraphicsProfile: Level_9_3
ColorSpace: Linear
DisplayOrientation: Default
PreferredGraphicsPlatform: Default
- !Xenko.Assets.EditorSettings,Xenko.Assets
RenderingMode: HDR
- !Xenko.Assets.Textures.TextureSettings,Xenko.Assets
Expand Down
Expand Up @@ -14,7 +14,6 @@ Defaults:
DefaultGraphicsProfile: Level_10_0
ColorSpace: Linear
DisplayOrientation: Default
PreferredGraphicsPlatform: Default
- !Xenko.Assets.EditorSettings,Xenko.Assets
RenderingMode: HDR
- !Xenko.Assets.Textures.TextureSettings,Xenko.Assets
Expand Down
Expand Up @@ -14,7 +14,6 @@ Defaults:
DefaultGraphicsProfile: Level_11_0
ColorSpace: Linear
DisplayOrientation: Default
PreferredGraphicsPlatform: Default
- !Xenko.Assets.EditorSettings,Xenko.Assets
RenderingMode: HDR
- !Xenko.Assets.Textures.TextureSettings,Xenko.Assets
Expand Down
Expand Up @@ -14,7 +14,6 @@ Defaults:
DefaultGraphicsProfile: Level_9_1
ColorSpace: Linear
DisplayOrientation: Default
PreferredGraphicsPlatform: Default
- !Xenko.Assets.EditorSettings,Xenko.Assets
RenderingMode: HDR
- !Xenko.Assets.Textures.TextureSettings,Xenko.Assets
Expand Down
93 changes: 0 additions & 93 deletions sources/engine/Xenko.Graphics/RenderingSettings.cs
Expand Up @@ -120,98 +120,5 @@ public class RenderingSettings : Configuration
/// <userdoc>The display orientations this game support.</userdoc>
[DataMember(40)]
public RequiredDisplayOrientation DisplayOrientation = RequiredDisplayOrientation.Default;

/// <summary>
/// Gets or sets the target graphics platform.
/// </summary>
/// <userdoc>
/// The project will be built for the specified graphics platform.
/// Leave as Default to let the engine choose the most appropriate platform depending on the hardware.
/// </userdoc>
[DataMember(50)]
[Display("Target graphics platform")]
public PreferredGraphicsPlatform PreferredGraphicsPlatform = PreferredGraphicsPlatform.Default;

private static GraphicsPlatform GetDefaultGraphicsPlatform(PlatformType platformType)
{
switch (platformType)
{
case PlatformType.Windows:
case PlatformType.UWP:
return GraphicsPlatform.Direct3D11;
case PlatformType.Android:
case PlatformType.iOS:
return GraphicsPlatform.OpenGLES;
case PlatformType.Linux:
case PlatformType.macOS:
return GraphicsPlatform.OpenGL;
default:
throw new ArgumentOutOfRangeException();
}
}

private static bool CheckGraphicsPlatform(PlatformType platform, PreferredGraphicsPlatform preferredGraphicsPlatform)
{
switch (platform)
{
case PlatformType.Shared:
return false;
case PlatformType.UWP:
return preferredGraphicsPlatform == PreferredGraphicsPlatform.Direct3D11;
case PlatformType.Windows:
return preferredGraphicsPlatform == PreferredGraphicsPlatform.Direct3D11
|| preferredGraphicsPlatform == PreferredGraphicsPlatform.Direct3D12
|| preferredGraphicsPlatform == PreferredGraphicsPlatform.OpenGL
|| preferredGraphicsPlatform == PreferredGraphicsPlatform.OpenGLES
|| preferredGraphicsPlatform == PreferredGraphicsPlatform.Vulkan;
case PlatformType.Android:
return preferredGraphicsPlatform == PreferredGraphicsPlatform.OpenGLES
|| preferredGraphicsPlatform == PreferredGraphicsPlatform.Vulkan;
case PlatformType.iOS:
return preferredGraphicsPlatform == PreferredGraphicsPlatform.OpenGLES;
case PlatformType.macOS:
return preferredGraphicsPlatform == PreferredGraphicsPlatform.OpenGL;
case PlatformType.Linux:
return preferredGraphicsPlatform == PreferredGraphicsPlatform.OpenGL
|| preferredGraphicsPlatform == PreferredGraphicsPlatform.Vulkan;
default:
throw new ArgumentOutOfRangeException(nameof(platform), platform, null);
}
}

public static GraphicsPlatform GetGraphicsPlatform(PlatformType platform, PreferredGraphicsPlatform preferredGraphicsPlatform)
{
//revert to default if platforms are not compatible
if (!CheckGraphicsPlatform(platform, preferredGraphicsPlatform))
{
return GetDefaultGraphicsPlatform(platform);
}

GraphicsPlatform graphicsPlatform;
switch (preferredGraphicsPlatform)
{
case PreferredGraphicsPlatform.Default:
graphicsPlatform = GetDefaultGraphicsPlatform(platform);
break;
case PreferredGraphicsPlatform.Direct3D11:
graphicsPlatform = GraphicsPlatform.Direct3D11;
break;
case PreferredGraphicsPlatform.Direct3D12:
graphicsPlatform = GraphicsPlatform.Direct3D12;
break;
case PreferredGraphicsPlatform.OpenGL:
graphicsPlatform = GraphicsPlatform.OpenGL;
break;
case PreferredGraphicsPlatform.OpenGLES:
graphicsPlatform = GraphicsPlatform.OpenGLES;
break;
case PreferredGraphicsPlatform.Vulkan:
graphicsPlatform = GraphicsPlatform.Vulkan;
break;
default:
throw new ArgumentOutOfRangeException();
}
return graphicsPlatform;
}
}
}
Expand Up @@ -14,7 +14,6 @@ Defaults:
DefaultGraphicsProfile: Level_9_1
ColorSpace: Linear
DisplayOrientation: Default
PreferredGraphicsPlatform: Default
- !Xenko.Assets.EditorSettings,Xenko.Assets
RenderingMode: HDR
- !Xenko.Assets.Textures.TextureSettings,Xenko.Assets
Expand Down
Expand Up @@ -14,7 +14,6 @@ Defaults:
DefaultGraphicsProfile: Level_10_0
ColorSpace: Linear
DisplayOrientation: Default
PreferredGraphicsPlatform: Default
- !Xenko.Assets.EditorSettings,Xenko.Assets
RenderingMode: HDR
- !Xenko.Assets.Textures.TextureSettings,Xenko.Assets
Expand Down
Expand Up @@ -14,7 +14,6 @@ Defaults:
DefaultGraphicsProfile: Level_9_1
ColorSpace: Linear
DisplayOrientation: Default
PreferredGraphicsPlatform: Default
- !Xenko.Assets.EditorSettings,Xenko.Assets
RenderingMode: HDR
- !Xenko.Assets.Textures.TextureSettings,Xenko.Assets
Expand Down
Expand Up @@ -14,7 +14,6 @@ Defaults:
DefaultGraphicsProfile: Level_9_3
ColorSpace: Linear
DisplayOrientation: Default
PreferredGraphicsPlatform: Default
- !Xenko.Assets.EditorSettings,Xenko.Assets
RenderingMode: HDR
- !Xenko.Assets.Textures.TextureSettings,Xenko.Assets
Expand Down
Expand Up @@ -14,7 +14,6 @@ Defaults:
DefaultGraphicsProfile: Level_9_1
ColorSpace: Linear
DisplayOrientation: Default
PreferredGraphicsPlatform: Default
- !Xenko.Assets.EditorSettings,Xenko.Assets
RenderingMode: HDR
- !Xenko.Assets.Textures.TextureSettings,Xenko.Assets
Expand Down

0 comments on commit fa1acae

Please sign in to comment.