Skip to content

Commit

Permalink
Add GDK-related platforms to enums and csproj (MonoGame#8474)
Browse files Browse the repository at this point in the history
See MonoGame#8195.

This PR add the GDK platforms to various enums, this is necessary to
build the [GDK
backend](MonoGame/MonoGame.XB1#51).

Unfortunately this add two GDK-specific #ifdef to the code, one in
Game.cs already present for DX11 and another one to
WinFormsGamePlatform.cs in order to add a Prepare() call used by the
DX12 backend and to avoid calling SharpDX related stuff. This could
probably be removed when merging when MonoGame#8242 is ready.
  • Loading branch information
Togimaro authored Sep 30, 2024
1 parent c42673d commit 8847878
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,5 +174,6 @@
<Import Project="..\PlayStation4\MonoGame.Framework.Content.Pipeline.targets" Condition="exists('..\PlayStation4\MonoGame.Framework.Content.Pipeline.targets')" />
<Import Project="..\PlayStation5\MonoGame.Framework.Content.Pipeline.targets" Condition="exists('..\PlayStation5\MonoGame.Framework.Content.Pipeline.targets')" />
<Import Project="..\PSVita\MonoGame.Framework.Content.Pipeline.targets" Condition="exists('..\PSVita\MonoGame.Framework.Content.Pipeline.targets')" />
<Import Project="..\GDKX\MonoGame.Framework.Content.Pipeline.targets" Condition="exists('..\GDKX\MonoGame.Framework.Content.Pipeline.targets')" />

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ private string GetProfileForPlatform(TargetPlatform platform)
return "OpenGL";
case TargetPlatform.DesktopVK:
return "Vulkan";
case TargetPlatform.WindowsGDK:
case TargetPlatform.XboxOne:
case TargetPlatform.XboxSeries:
return "GDK";
}

return platform.ToString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public sealed class ContentWriter : BinaryWriter
'S', // Nintendo Switch
'b', // WebAssembly and Bridge.NET
'V', // DesktopVK (Vulkan)
'G', // Windows GDK
's', // Xbox Series
};

/// <summary>
Expand Down
9 changes: 9 additions & 0 deletions MonoGame.Framework.Content.Pipeline/TargetPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,15 @@ public enum TargetPlatform
/// All desktop versions using Vulkan.
/// </summary>
DesktopVK,

/// Windows GDK
/// </summary>
WindowsGDK,

/// <summary>
/// Xbox Series
/// </summary>
XboxSeries
}


Expand Down
2 changes: 2 additions & 0 deletions MonoGame.Framework/Content/ContentManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public partial class ContentManager : IDisposable
'S', // Nintendo Switch
'b', // WebAssembly and Bridge.NET
'V', // DesktopVK
'G', // Windows GDK
's', // Xbox Series

// NOTE: There are additional identifiers for consoles that
// are not defined in this repository. Be sure to ask the
Expand Down
7 changes: 7 additions & 0 deletions MonoGame.Framework/Platform/Windows/WinFormsGamePlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ public override bool BeforeUpdate(GameTime gameTime)

public override bool BeforeDraw(GameTime gameTime)
{
#if GDKX
var device = Game.GraphicsDevice;
if (device != null)
device.PlatformPrepare(); // maybe add a Prepare() to GraphicsDevice, could be useful for other backend?
#endif
return true;
}

Expand Down Expand Up @@ -126,7 +131,9 @@ protected override void Dispose(bool disposing)
_window = null;
Window = null;
}
#if !GDKX
Microsoft.Xna.Framework.Media.MediaManagerState.CheckShutdown();
#endif
}

base.Dispose(disposing);
Expand Down
9 changes: 7 additions & 2 deletions MonoGame.Framework/Utilities/GraphicsBackend.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace MonoGame.Framework.Utilities
public enum GraphicsBackend
{
/// <summary>
/// Represents the Microsoft DirectX graphics backend.
/// Represents the Microsoft DirectX 11 graphics backend.
/// </summary>
DirectX,

Expand All @@ -27,6 +27,11 @@ public enum GraphicsBackend
/// <summary>
/// Represents the Apple Metal graphics backend.
/// </summary>
Metal
Metal,

/// <summary>
/// Represents the Microsoft DirectX 12 graphics backend. (GDKX only for now)
/// </summary>
DirectX12
}
}
10 changes: 10 additions & 0 deletions MonoGame.Framework/Utilities/MonoGamePlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ public enum MonoGamePlatform
/// MonoGame Xbox One platform.
/// </summary>
XboxOne,

/// <summary>
/// MonoGame Windows GDK platform.
/// </summary>
WindowsGDK,

/// <summary>
/// MonoGame Xbox Series platform.
/// </summary>
XboxSeries,

/// <summary>
/// MonoGame PlayStation 4 platform.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
<Import Project="..\..\XBoxOne\MonoGame.Effect.Compiler.targets" Condition="exists('..\..\XBoxOne\MonoGame.Effect.Compiler.targets')" />
<Import Project="..\..\PlayStation4\MonoGame.Effect.Compiler.targets" Condition="exists('..\..\PlayStation4\MonoGame.Effect.Compiler.targets')" />
<Import Project="..\..\PlayStation5\MonoGame.Effect.Compiler.targets" Condition="exists('..\..\PlayStation5\MonoGame.Effect.Compiler.targets')" />
<Import Project="..\..\GDKX\MonoGame.Effect.Compiler.targets" Condition="exists('..\..\GDKX\MonoGame.Effect.Compiler.targets')" />

<Target Name="CopyNuGetToolFiles" AfterTargets="Build">
<ItemGroup>
Expand Down

0 comments on commit 8847878

Please sign in to comment.