public void InitializeFormat(MTLRenderPipelineDescriptor dest) { nint colorAttachmentIndex = 0; foreach (var attachment in ColorAttachments) { dest.ColorAttachments[colorAttachmentIndex].PixelFormat = AmtFormatExtensions.GetPixelFormat(attachment.Format); ++colorAttachmentIndex; } if (DepthStencil != null) { dest.DepthAttachmentPixelFormat = AmtFormatExtensions.GetPixelFormat(DepthStencil.Format); dest.StencilAttachmentPixelFormat = AmtFormatExtensions.GetPixelFormat(DepthStencil.Format); } }
public AmtImageView(MgImageViewCreateInfo pCreateInfo) { if (pCreateInfo == null) { throw new ArgumentNullException(nameof(pCreateInfo)); } if (pCreateInfo.Image == null) { throw new ArgumentNullException(nameof(pCreateInfo.Image)); } var bImage = (AmtImage)pCreateInfo.Image; mImageView = bImage.OriginalTexture.CreateTextureView( AmtFormatExtensions.GetPixelFormat(pCreateInfo.Format), TranslateTextureType(pCreateInfo.ViewType), GenerateLevelRange(pCreateInfo.SubresourceRange), GenerateSliceRange(pCreateInfo.SubresourceRange)); }
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; }