change graphics backend selection behavior

what_if_no_video_threads
cosmonaut 2024-03-07 10:34:30 -08:00
parent a762a80c4f
commit bde31fbe07
10 changed files with 13 additions and 10 deletions

View File

@ -3,7 +3,6 @@
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>11</LangVersion>
</PropertyGroup>
<PropertyGroup>

@ -1 +1 @@
Subproject commit 859675dbab86e6eeda662ef9bdb0c688cce4cec3
Subproject commit 55acf6ee1818b0801cffe7217ee07eb1f56016f6

View File

@ -53,11 +53,10 @@ namespace MoonWorks
public Game(
WindowCreateInfo windowCreateInfo,
FrameLimiterSettings frameLimiterSettings,
Backend backend = Backend.Vulkan,
Span<Backend> 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
);

View File

@ -40,11 +40,17 @@ namespace MoonWorks.Graphics
private FencePool FencePool;
private CommandBufferPool CommandBufferPool;
internal GraphicsDevice(
Backend preferredBackend,
internal unsafe GraphicsDevice(
Span<Backend> 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)
{

View File

@ -311,7 +311,6 @@ namespace MoonWorks.Graphics
public enum Backend
{
DontCare,
Vulkan,
D3D11,
PS5,