public void Create(IMgCommandBuffer setupCmdBuffer, IMgSwapchainCollection swapchainCollection, MgGraphicsDeviceCreateInfo createInfo) { if (createInfo == null) { throw new ArgumentNullException(nameof(createInfo)); } if (setupCmdBuffer == null) { throw new ArgumentNullException(nameof(setupCmdBuffer)); } if (swapchainCollection == null) { throw new ArgumentNullException(nameof(swapchainCollection)); } ReleaseUnmanagedResources(); mDeviceCreated = false; SetupContext(createInfo); SetupRenderpass(createInfo); // MANDATORY swapchainCollection.Create(setupCmdBuffer, createInfo.Width, createInfo.Height); SetupSwapchain(swapchainCollection, createInfo); mFramebuffers.Create(swapchainCollection, mRenderpass, mView, createInfo.Width, createInfo.Height); Scissor = new MgRect2D { Extent = new MgExtent2D { Width = createInfo.Width, Height = createInfo.Height }, Offset = new MgOffset2D { X = 0, Y = 0 }, }; // initialize viewport CurrentViewport = new MgViewport { Width = createInfo.Width, Height = createInfo.Height, X = 0, Y = 0, MinDepth = 0f, MaxDepth = 1f, }; mDeviceCreated = true; }
public void Create(IMgCommandBuffer setupCmdBuffer, IMgSwapchainCollection swapchainCollection, MgGraphicsDeviceCreateInfo dsCreateInfo) { if (dsCreateInfo == null) { throw new ArgumentNullException(nameof(dsCreateInfo)); } if (swapchainCollection == null) { throw new ArgumentNullException(nameof(swapchainCollection)); } mDeviceCreated = false; var colorFormat = AmtFormatExtensions.GetPixelFormat(dsCreateInfo.Color); var depthFormat = AmtFormatExtensions.GetPixelFormat(dsCreateInfo.DepthStencil); var sampleCount = AmtSampleCountFlagBitExtensions.TranslateSampleCount(dsCreateInfo.Samples); ReleaseUnmanagedResources(); mApplicationView.SampleCount = sampleCount; // FIXME : RUNTIME ISSUE WITH SETTING COLOR FORMAT; SHOULD "FIGURE" OUT APPROPRIATE COLOR FORMAT SOMEHOW mApplicationView.ColorPixelFormat = colorFormat; mApplicationView.DepthStencilPixelFormat = depthFormat; CreateDepthStencilImageView(); CreateRenderpass(dsCreateInfo); var bSwapchainCollection = (AmtSwapchainCollection)swapchainCollection; bSwapchainCollection.Format = dsCreateInfo.Color; bSwapchainCollection.Create(setupCmdBuffer, dsCreateInfo.Width, dsCreateInfo.Height); mFramebuffers.Create( swapchainCollection, mRenderpass, mDepthStencilView, dsCreateInfo.Width, dsCreateInfo.Height); Scissor = new MgRect2D { Extent = new MgExtent2D { Width = dsCreateInfo.Width, Height = dsCreateInfo.Height }, Offset = new MgOffset2D { X = 0, Y = 0 }, }; // initialise viewport CurrentViewport = new MgViewport { Width = dsCreateInfo.Width, Height = dsCreateInfo.Height, X = 0, Y = 0, MinDepth = 0f, MaxDepth = 1f, }; mDeviceCreated = true; }