protected override bool GetPixelFormatSupportCore( PixelFormat format, TextureType type, TextureUsage usage, out PixelFormatProperties properties) { if (D3D11Formats.IsUnsupportedFormat(format)) { properties = default(PixelFormatProperties); return(false); } Format dxgiFormat = D3D11Formats.ToDxgiFormat(format, (usage & TextureUsage.DepthStencil) != 0); FormatSupport fs = _device.CheckFormatSupport(dxgiFormat); if ((usage & TextureUsage.RenderTarget) != 0 && (fs & FormatSupport.RenderTarget) == 0 || (usage & TextureUsage.DepthStencil) != 0 && (fs & FormatSupport.DepthStencil) == 0 || (usage & TextureUsage.Sampled) != 0 && (fs & FormatSupport.ShaderSample) == 0 || (usage & TextureUsage.Cubemap) != 0 && (fs & FormatSupport.TextureCube) == 0 || (usage & TextureUsage.Storage) != 0 && (fs & FormatSupport.TypedUnorderedAccessView) == 0) { properties = default(PixelFormatProperties); return(false); } const uint MaxTextureDimension = 16384; const uint MaxVolumeExtent = 2048; uint sampleCounts = 0; if (CheckFormatMultisample(dxgiFormat, 1)) { sampleCounts |= (1 << 0); } if (CheckFormatMultisample(dxgiFormat, 2)) { sampleCounts |= (1 << 1); } if (CheckFormatMultisample(dxgiFormat, 4)) { sampleCounts |= (1 << 2); } if (CheckFormatMultisample(dxgiFormat, 8)) { sampleCounts |= (1 << 3); } if (CheckFormatMultisample(dxgiFormat, 16)) { sampleCounts |= (1 << 4); } if (CheckFormatMultisample(dxgiFormat, 32)) { sampleCounts |= (1 << 5); } properties = new PixelFormatProperties( MaxTextureDimension, type == TextureType.Texture1D ? 1 : MaxTextureDimension, type != TextureType.Texture3D ? 1 : MaxVolumeExtent, uint.MaxValue, type == TextureType.Texture3D ? 1 : MaxVolumeExtent, sampleCounts); return(true); }
private protected override bool GetPixelFormatSupportCore( PixelFormat format, TextureType type, TextureUsage usage, out PixelFormatProperties properties) { if (!MTLFormats.IsFormatSupported(format, usage, MetalFeatures)) { properties = default(PixelFormatProperties); return(false); } uint sampleCounts = 0; for (int i = 0; i < _supportedSampleCounts.Length; i++) { if (_supportedSampleCounts[i]) { sampleCounts |= (uint)(1 << i); } } MTLFeatureSet maxFeatureSet = MetalFeatures.MaxFeatureSet; uint maxArrayLayer = MTLFormats.GetMaxTextureVolume(maxFeatureSet); uint maxWidth; uint maxHeight; uint maxDepth; if (type == TextureType.Texture1D) { maxWidth = MTLFormats.GetMaxTexture1DWidth(maxFeatureSet); maxHeight = 1; maxDepth = 1; } else if (type == TextureType.Texture2D) { uint maxDimensions; if ((usage & TextureUsage.Cubemap) != 0) { maxDimensions = MTLFormats.GetMaxTextureCubeDimensions(maxFeatureSet); } else { maxDimensions = MTLFormats.GetMaxTexture2DDimensions(maxFeatureSet); } maxWidth = maxDimensions; maxHeight = maxDimensions; maxDepth = 1; } else if (type == TextureType.Texture3D) { maxWidth = maxArrayLayer; maxHeight = maxArrayLayer; maxDepth = maxArrayLayer; maxArrayLayer = 1; } else { throw Illegal.Value <TextureType>(); } properties = new PixelFormatProperties( maxWidth, maxHeight, maxDepth, uint.MaxValue, maxArrayLayer, sampleCounts); return(true); }