From bde31fbe0722058e140dd9ec28b127ea7b80975c Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Thu, 7 Mar 2024 10:34:30 -0800 Subject: [PATCH] change graphics backend selection behavior --- MoonWorks.csproj | 1 - lib/RefreshCS | 2 +- src/Game.cs | 7 +++---- src/Graphics/GraphicsDevice.cs | 12 +++++++++--- src/Graphics/RefreshEnums.cs | 1 - .../StockShaders/Binary/blit.frag.refresh | Bin 1262 -> 1262 bytes .../Binary/fullscreen.vert.refresh | Bin 2038 -> 2038 bytes .../Binary/text_msdf.frag.refresh | Bin 4335 -> 4335 bytes .../Binary/text_transform.vert.refresh | Bin 2642 -> 2642 bytes .../Binary/video_yuv2rgba.frag.refresh | Bin 3034 -> 3034 bytes 10 files changed, 13 insertions(+), 10 deletions(-) diff --git a/MoonWorks.csproj b/MoonWorks.csproj index a1e1f4e..20fb35d 100644 --- a/MoonWorks.csproj +++ b/MoonWorks.csproj @@ -3,7 +3,6 @@ net8.0 true - 11 diff --git a/lib/RefreshCS b/lib/RefreshCS index 859675d..55acf6e 160000 --- a/lib/RefreshCS +++ b/lib/RefreshCS @@ -1 +1 @@ -Subproject commit 859675dbab86e6eeda662ef9bdb0c688cce4cec3 +Subproject commit 55acf6ee1818b0801cffe7217ee07eb1f56016f6 diff --git a/src/Game.cs b/src/Game.cs index cf1e133..1876814 100644 --- a/src/Game.cs +++ b/src/Game.cs @@ -53,11 +53,10 @@ namespace MoonWorks public Game( WindowCreateInfo windowCreateInfo, FrameLimiterSettings frameLimiterSettings, - Backend backend = Backend.Vulkan, + Span preferredBackends, int targetTimestep = 60, bool debugMode = false - ) - { + ) { Logger.LogInfo("Initializing frame limiter..."); Timestep = TimeSpan.FromTicks(TimeSpan.TicksPerSecond / targetTimestep); gameTimer = Stopwatch.StartNew(); @@ -83,7 +82,7 @@ namespace MoonWorks Logger.LogInfo("Initializing graphics device..."); GraphicsDevice = new GraphicsDevice( - backend, + preferredBackends, debugMode ); diff --git a/src/Graphics/GraphicsDevice.cs b/src/Graphics/GraphicsDevice.cs index cbe8d79..86eb6c5 100644 --- a/src/Graphics/GraphicsDevice.cs +++ b/src/Graphics/GraphicsDevice.cs @@ -40,11 +40,17 @@ namespace MoonWorks.Graphics private FencePool FencePool; private CommandBufferPool CommandBufferPool; - internal GraphicsDevice( - Backend preferredBackend, + internal unsafe GraphicsDevice( + Span preferredBackends, bool debugMode ) { - Backend = (Backend) Refresh.Refresh_SelectBackend((Refresh.Backend) preferredBackend, out windowFlags); + var backends = stackalloc Refresh.Backend[preferredBackends.Length]; + for (var i = 0; i < preferredBackends.Length; i += 1) + { + backends[i] = (Refresh.Backend) preferredBackends[i]; + } + + Backend = (Backend) Refresh.Refresh_SelectBackend(backends, (uint) preferredBackends.Length, out windowFlags); if (Backend == Backend.Invalid) { diff --git a/src/Graphics/RefreshEnums.cs b/src/Graphics/RefreshEnums.cs index 2e1b9f8..56de211 100644 --- a/src/Graphics/RefreshEnums.cs +++ b/src/Graphics/RefreshEnums.cs @@ -311,7 +311,6 @@ namespace MoonWorks.Graphics public enum Backend { - DontCare, Vulkan, D3D11, PS5, diff --git a/src/Graphics/StockShaders/Binary/blit.frag.refresh b/src/Graphics/StockShaders/Binary/blit.frag.refresh index a64dddb90d2da6cbed35983dc87e61b66d6e31c5..5ca4059570182e35b4b66268de37c45f598e4197 100644 GIT binary patch delta 25 fcmaFI`Hqt_$Sv4|kpT!cayBqAGH&i-N?`&3SY-we delta 25 gcmaFI`Hqt_$Sv4|k%57MaU*8~6C=~+E~XSF09bbh5dZ)H diff --git a/src/Graphics/StockShaders/Binary/fullscreen.vert.refresh b/src/Graphics/StockShaders/Binary/fullscreen.vert.refresh index 762caae8e41d3634bd49e08021b7e702e7684580..750264a8d25eb37fe6789d84cb2f83e19841d45c 100644 GIT binary patch delta 25 ecmeyy|BatB$Sv4|0R%R3-e6&5-28||gc$%{*anXP delta 25 fcmeyy|BatB$Sv4|0SFj3a^7HJWZL|QMT8juUg`#s diff --git a/src/Graphics/StockShaders/Binary/text_msdf.frag.refresh b/src/Graphics/StockShaders/Binary/text_msdf.frag.refresh index ad0a698599d78c80abc8ddf52395272bf5faa6ff..c28ff6c71e954c0cc6a5674593c837b01d573195 100644 GIT binary patch delta 25 fcmaE__+F7S$Sv4|kpT!ca<*_WGH&kUN@N27U2g_j delta 25 gcmaE__+F7S$Sv4|k%57MaU*977bDZ=KCVPI09}CwTmS$7 diff --git a/src/Graphics/StockShaders/Binary/text_transform.vert.refresh b/src/Graphics/StockShaders/Binary/text_transform.vert.refresh index fd34e1b2fe5df7c189d24fd08d5d21cf8c85fec4..12c3a3e4a118f2705b9c3cea1551e3120e0a87e6 100644 GIT binary patch delta 25 ecmca4a!G_U$Sv4|0R%R3eqm)~-29IaBGynhq