void InitializeMultisampleInfo(MgPipelineMultisampleStateCreateInfo multisampleState) { if (multisampleState != null) { AlphaToCoverageEnabled = multisampleState.AlphaToCoverageEnable; AlphaToOneEnabled = multisampleState.AlphaToOneEnable; SampleCount = AmtSampleCountFlagBitExtensions.TranslateSampleCount( multisampleState.RasterizationSamples); } else { // NO MULTISAMPLING AlphaToCoverageEnabled = false; AlphaToOneEnabled = false; SampleCount = 1; } }
public Result CreateImage(MgImageCreateInfo pCreateInfo, IMgAllocationCallbacks allocator, out IMgImage pImage) { Debug.Assert(pCreateInfo != null); var depth = (nuint)pCreateInfo.Extent.Depth; var height = (nuint)pCreateInfo.Extent.Height; var width = (nuint)pCreateInfo.Extent.Width; var arrayLayers = (nuint)pCreateInfo.ArrayLayers; var mipLevels = (nuint)pCreateInfo.MipLevels; //TODO : Figure this out var storageMode = MTLStorageMode.Shared; var resourceOptions = MTLResourceOptions.CpuCacheModeDefault; var cpuCacheMode = MTLCpuCacheMode.DefaultCache; var descriptor = new MTLTextureDescriptor { ArrayLength = arrayLayers, PixelFormat = AmtFormatExtensions.GetPixelFormat(pCreateInfo.Format), SampleCount = AmtSampleCountFlagBitExtensions.TranslateSampleCount(pCreateInfo.Samples), TextureType = TranslateTextureType(pCreateInfo.ImageType), StorageMode = storageMode, Width = width, Height = height, Depth = depth, MipmapLevelCount = mipLevels, Usage = TranslateUsage(pCreateInfo.Usage), ResourceOptions = resourceOptions, CpuCacheMode = cpuCacheMode, }; var texture = mDevice.CreateTexture(descriptor); pImage = new AmtImage(texture); return(Result.SUCCESS); }
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; }