Example #1
0
        public static IFormatInfo DisplayPixelFormatInfo(Format d3dFormat)
        {
            var formatInfo = new FormatInfo
                                 {
                ID = (int)d3dFormat,
                NumColors = 3,
                ColorFormatType = FormatElementType.UNORM,
                Description = d3dFormat.ToString(),
                Flags = ColorAlphaFormatFlags.None
            };

            switch (d3dFormat)
            {
                case Format.A2R10G10B10:
                    {
                        formatInfo.ColorBits = 30;
                        formatInfo.AlphaBits = 2;
                        formatInfo.AlphaFormatType = FormatElementType.UNORM;
                        formatInfo.TotalBits = 32;
                    }
                    break;
                case Format.X8R8G8B8:
                    {
                        formatInfo.ColorBits = 24;
                        formatInfo.AlphaBits = 0;
                        formatInfo.AlphaFormatType = FormatElementType.UNKNOWN;
                        formatInfo.TotalBits = 32;
                    }
                    break;
                case Format.R5G6B5:
                    {
                        formatInfo.ColorBits = 16;
                        formatInfo.AlphaBits = 0;
                        formatInfo.AlphaFormatType = FormatElementType.UNKNOWN;
                        formatInfo.TotalBits = 16;
                        formatInfo.ExplicitFormat = ExplicitFormat.B5G6R5_UNORM;
                    }
                    break;
                case Format.X1R5G5B5:
                    {
                        formatInfo.ColorBits = 15;
                        formatInfo.AlphaBits = 0;
                        formatInfo.AlphaFormatType = FormatElementType.UNKNOWN;
                        formatInfo.TotalBits = 16;
                    }
                    break;
                default: throw new ArgumentOutOfRangeException("d3dFormat");
            }

            return formatInfo;
        }
Example #2
0
        public static IFormatInfo TexelFormatInfo(Format d3dFormat)
        {
            switch (d3dFormat)
            {
                case Format.A32B32G32R32F: return ExplicitFormatInfo(d3dFormat, ExplicitFormat.R32G32B32A32_FLOAT);
                case Format.A16B16G16R16F: return ExplicitFormatInfo(d3dFormat, ExplicitFormat.R16G16B16A16_FLOAT);
                case Format.A16B16G16R16: return ExplicitFormatInfo(d3dFormat, ExplicitFormat.R16G16B16A16_UNORM);
                case Format.G32R32F: return ExplicitFormatInfo(d3dFormat, ExplicitFormat.R32G32_FLOAT);
                case Format.A2B10G10R10: return ExplicitFormatInfo(d3dFormat, ExplicitFormat.R10G10B10A2_UNORM);
                case Format.A8B8G8R8: return ExplicitFormatInfo(d3dFormat, ExplicitFormat.R8G8B8A8_UNORM);
                case Format.G16R16F: return ExplicitFormatInfo(d3dFormat, ExplicitFormat.R16G16_FLOAT);
                case Format.G16R16: return ExplicitFormatInfo(d3dFormat, ExplicitFormat.R16G16_UNORM);
                case Format.D32SingleLockable: return ExplicitFormatInfo(d3dFormat, ExplicitFormat.D32_FLOAT);
                case Format.R32F: return ExplicitFormatInfo(d3dFormat, ExplicitFormat.R32_FLOAT);
                case Format.D24S8: return ExplicitFormatInfo(d3dFormat, ExplicitFormat.D24_UNORM_S8_UINT);
                case Format.D16: return ExplicitFormatInfo(d3dFormat, ExplicitFormat.D16_UNORM);
                case Format.R16F: return ExplicitFormatInfo(d3dFormat, ExplicitFormat.R16_FLOAT);
                case Format.A8: return ExplicitFormatInfo(d3dFormat, ExplicitFormat.A8_UNORM);
                case Format.G8R8_G8B8: return ExplicitFormatInfo(d3dFormat, ExplicitFormat.R8G8_B8G8_UNORM);
                case Format.R8G8_B8G8: return ExplicitFormatInfo(d3dFormat, ExplicitFormat.G8R8_G8B8_UNORM);
                case Format.Dxt1: return ExplicitFormatInfo(d3dFormat, ExplicitFormat.BC1_UNORM);
                case Format.Dxt3: return ExplicitFormatInfo(d3dFormat, ExplicitFormat.BC2_UNORM);
                case Format.Dxt5: return ExplicitFormatInfo(d3dFormat, ExplicitFormat.BC3_UNORM);
                case Format.R5G6B5: return ExplicitFormatInfo(d3dFormat, ExplicitFormat.B5G6R5_UNORM);
                case Format.A1R5G5B5: return ExplicitFormatInfo(d3dFormat, ExplicitFormat.B5G5R5A1_UNORM);
                case Format.A8R8G8B8: return ExplicitFormatInfo(d3dFormat, ExplicitFormat.B8G8R8A8_UNORM);
                case Format.X8R8G8B8: return ExplicitFormatInfo(d3dFormat, ExplicitFormat.B8G8R8X8_UNORM);
            }

            var formatInfo = new FormatInfo
            {
                ID = (int)d3dFormat,
                Description = d3dFormat.ToString()
            };

            switch (d3dFormat)
            {
                case Format.R8G8B8:
                    {
                        formatInfo.NumColors = 3;
                        formatInfo.ColorBits = 24;
                        formatInfo.ColorFormatType = FormatElementType.UNORM;
                        formatInfo.AlphaBits = 0;
                        formatInfo.AlphaFormatType = FormatElementType.UNKNOWN;
                        formatInfo.TotalBits = 24;
                        formatInfo.Flags = ColorAlphaFormatFlags.Bgra;
                    }
                    break;
                case Format.X1R5G5B5:
                    {
                        formatInfo.NumColors = 3;
                        formatInfo.ColorBits = 15;
                        formatInfo.ColorFormatType = FormatElementType.UNORM;
                        formatInfo.AlphaBits = 0;
                        formatInfo.AlphaFormatType = FormatElementType.UNKNOWN;
                        formatInfo.TotalBits = 16;
                        formatInfo.Flags = ColorAlphaFormatFlags.Bgra;
                    }
                    break;
                case Format.A4R4G4B4:
                    {
                        formatInfo.NumColors = 3;
                        formatInfo.ColorBits = 12;
                        formatInfo.ColorFormatType = FormatElementType.UNORM;
                        formatInfo.AlphaBits = 4;
                        formatInfo.AlphaFormatType = FormatElementType.UNORM;
                        formatInfo.TotalBits = 16;
                        formatInfo.Flags = ColorAlphaFormatFlags.Bgra;
                    }
                    break;
                case Format.R3G3B2:
                    {
                        formatInfo.NumColors = 3;
                        formatInfo.ColorBits = 8;
                        formatInfo.ColorFormatType = FormatElementType.UNORM;
                        formatInfo.AlphaBits = 0;
                        formatInfo.AlphaFormatType = FormatElementType.UNKNOWN;
                        formatInfo.TotalBits = 8;
                        formatInfo.Flags = ColorAlphaFormatFlags.Bgra;
                    }
                    break;
                case Format.A8R3G3B2:
                    {
                        formatInfo.NumColors = 3;
                        formatInfo.ColorBits = 8;
                        formatInfo.ColorFormatType = FormatElementType.UNORM;
                        formatInfo.AlphaBits = 8;
                        formatInfo.AlphaFormatType = FormatElementType.UNORM;
                        formatInfo.TotalBits = 8;
                        formatInfo.Flags = ColorAlphaFormatFlags.Bgra;
                    }
                    break;
                case Format.X4R4G4B4:
                    {
                        formatInfo.NumColors = 3;
                        formatInfo.ColorBits = 12;
                        formatInfo.ColorFormatType = FormatElementType.UNORM;
                        formatInfo.AlphaBits = 0;
                        formatInfo.AlphaFormatType = FormatElementType.UNKNOWN;
                        formatInfo.TotalBits = 16;
                        formatInfo.Flags = ColorAlphaFormatFlags.Bgra;
                    }
                    break;
                case Format.X8B8G8R8:
                    {
                        formatInfo.NumColors = 3;
                        formatInfo.ColorBits = 24;
                        formatInfo.ColorFormatType = FormatElementType.UNORM;
                        formatInfo.AlphaBits = 0;
                        formatInfo.AlphaFormatType = FormatElementType.UNKNOWN;
                        formatInfo.TotalBits = 32;
                    }
                    break;
                case Format.A2R10G10B10:
                    {
                        formatInfo.NumColors = 3;
                        formatInfo.ColorBits = 30;
                        formatInfo.ColorFormatType = FormatElementType.UNORM;
                        formatInfo.AlphaBits = 2;
                        formatInfo.AlphaFormatType = FormatElementType.UNORM;
                        formatInfo.TotalBits = 32;
                        formatInfo.Flags = ColorAlphaFormatFlags.Bgra;
                    }
                    break;
                case Format.D16Lockable:
                    {
                        formatInfo.NumColors = 1;
                        formatInfo.ColorBits = 16;
                        formatInfo.ColorFormatType = FormatElementType.UNORM;
                        formatInfo.AlphaBits = 0;
                        formatInfo.AlphaFormatType = FormatElementType.UNKNOWN;
                        formatInfo.TotalBits = 16;
                        formatInfo.Flags = ColorAlphaFormatFlags.DepthStencil;
                    }
                    break;
                case Format.D32:
                    {
                        formatInfo.NumColors = 1;
                        formatInfo.ColorBits = 32;
                        formatInfo.ColorFormatType = FormatElementType.UNORM;
                        formatInfo.AlphaBits = 0;
                        formatInfo.AlphaFormatType = FormatElementType.UNKNOWN;
                        formatInfo.TotalBits = 32;
                    }
                    break;
                case Format.D15S1:
                    {
                        formatInfo.NumColors = 1;
                        formatInfo.ColorBits = 15;
                        formatInfo.ColorFormatType = FormatElementType.UNORM;
                        formatInfo.AlphaBits = 1;
                        formatInfo.AlphaFormatType = FormatElementType.UINT;
                        formatInfo.TotalBits = 16;
                    }
                    break;
                case Format.D24X8:
                    {
                        formatInfo.NumColors = 1;
                        formatInfo.ColorBits = 24;
                        formatInfo.ColorFormatType = FormatElementType.UNORM;
                        formatInfo.AlphaBits = 0;
                        formatInfo.AlphaFormatType = FormatElementType.UNKNOWN;
                        formatInfo.TotalBits = 32;
                    }
                    break;
                case Format.D24X4S4:
                    {
                        formatInfo.NumColors = 1;
                        formatInfo.ColorBits = 24;
                        formatInfo.ColorFormatType = FormatElementType.UNORM;
                        formatInfo.AlphaBits = 4;
                        formatInfo.AlphaFormatType = FormatElementType.UINT;
                        formatInfo.TotalBits = 32;
                    }
                    break;
                case Format.D24SingleS8:
                    {
                        formatInfo.NumColors = 1;
                        formatInfo.ColorBits = 24;
                        formatInfo.ColorFormatType = FormatElementType.FLOAT;
                        formatInfo.AlphaBits = 8;
                        formatInfo.AlphaFormatType = FormatElementType.UINT;
                        formatInfo.TotalBits = 32;
                    }
                    break;
                case Format.D32Lockable:
                    {
                        formatInfo.NumColors = 1;
                        formatInfo.ColorBits = 32;
                        formatInfo.ColorFormatType = FormatElementType.UNORM;
                        formatInfo.AlphaBits = 0;
                        formatInfo.AlphaFormatType = FormatElementType.UNKNOWN;
                        formatInfo.TotalBits = 32;
                    }
                    break;
                case Format.S8Lockable:
                    {
                        formatInfo.NumColors = 0;
                        formatInfo.ColorBits = 0;
                        formatInfo.ColorFormatType = FormatElementType.UNKNOWN;
                        formatInfo.AlphaBits = 8;
                        formatInfo.AlphaFormatType = FormatElementType.UINT;
                        formatInfo.TotalBits = 8;
                    }
                    break;
                default: throw new ArgumentOutOfRangeException("d3dFormat");
            }

            return formatInfo;
        }