ProwlEngine / Prowl

An Open Source C# 3D Game Engine under MIT license, inspired by Unity and featuring a complete editor
MIT License
451 stars 38 forks source link

Fix Swapchain Implementation #189

Open PaperPrototype opened 3 weeks ago

PaperPrototype commented 3 weeks ago

Describe the bug We don't know what is the best supported PixelFormat is until we create a graphics device, but for some reason we do:


public static partial class Graphics
{
   //...
    public static void Initialize(bool VSync = true, GraphicsBackend preferredBackend = GraphicsBackend.OpenGL)
    {
        GraphicsDeviceOptions deviceOptions = new()
        {
            SyncToVerticalBlank = VSync,
            ResourceBindingModel = ResourceBindingModel.Default,
            HasMainSwapchain = true,
            SwapchainDepthFormat = PixelFormat.D16_UNorm,
            SwapchainSrgbFormat = false,
        };

        //....
   }
   //...
}

To Reproduce Steps to reproduce the behavior:

  1. Open prowl on mac-os m1 and run
  2. You should see -[MTLTextureDescriptorInternal validateWithDevice:]:1405: failed assertionTexture Descriptor Validation MTLTextureDescriptor has invalid pixelFormat (255).'`

Expected behavior It should use the correct pixel format.

Because of the way things are setup you can't call TextureUtility.GetBestSupportedDepthFormat() when initializing the GraphicsDeviceOptions