public OpenGLESCubemapTexture(
            IntPtr pixelsFront,
            IntPtr pixelsBack,
            IntPtr pixelsLeft,
            IntPtr pixelsRight,
            IntPtr pixelsTop,
            IntPtr pixelsBottom,
            int width,
            int height,
            PixelFormat format)
            : base(TextureTarget.TextureCubeMap, width, height)
        {
            _texComponentCount = OpenGLESFormats.MapTextureComponentCount(format, false);
            _format            = OpenGLESFormats.MapPixelFormat(format);
            _type = OpenGLESFormats.MapPixelType(format);

            Bind();
            GL.TexParameter(TextureTarget.TextureCubeMap, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
            Utilities.CheckLastGLES3Error();
            GL.TexParameter(TextureTarget.TextureCubeMap, TextureParameterName.TextureMinFilter, (int)TextureMagFilter.Linear);
            Utilities.CheckLastGLES3Error();
            GL.TexParameter(TextureTarget.TextureCubeMap, TextureParameterName.TextureWrapS, (int)TextureWrapMode.ClampToEdge);
            Utilities.CheckLastGLES3Error();
            GL.TexParameter(TextureTarget.TextureCubeMap, TextureParameterName.TextureWrapT, (int)TextureWrapMode.ClampToEdge);
            Utilities.CheckLastGLES3Error();
            GL.TexParameter(TextureTarget.TextureCubeMap, TextureParameterName.TextureWrapR, (int)TextureWrapMode.ClampToEdge);
            Utilities.CheckLastGLES3Error();

            SetFacePixels(0, pixelsRight);
            SetFacePixels(1, pixelsLeft);
            SetFacePixels(2, pixelsTop);
            SetFacePixels(3, pixelsBottom);
            SetFacePixels(4, pixelsBack);
            SetFacePixels(5, pixelsFront);
        }
示例#2
0
        public static void ConvertPixelFormat(GraphicsDevice graphicsDevice, ref PixelFormat inputFormat, out PixelInternalFormat internalFormat, out PixelFormatGl format, out PixelType type,
                                              out int pixelSize, out bool compressed)
        {
            compressed = false;

            // If the Device doesn't support SRGB, we remap automatically the format to non-srgb
            if (!graphicsDevice.Features.HasSRgb)
            {
                switch (inputFormat)
                {
                case PixelFormat.ETC2_RGB_SRgb:
                    inputFormat = PixelFormat.ETC2_RGB;
                    break;

                case PixelFormat.ETC2_RGBA_SRgb:
                    inputFormat = PixelFormat.ETC2_RGBA;
                    break;

                case PixelFormat.R8G8B8A8_UNorm_SRgb:
                    inputFormat = PixelFormat.R8G8B8A8_UNorm;
                    break;

                case PixelFormat.B8G8R8A8_UNorm_SRgb:
                    inputFormat = PixelFormat.B8G8R8A8_UNorm;
                    break;
                }
            }

            switch (inputFormat)
            {
            case PixelFormat.A8_UNorm:
                internalFormat = PixelInternalFormat.Alpha;
                format         = PixelFormatGl.Alpha;
                type           = PixelType.UnsignedByte;
                pixelSize      = 1;
                break;

            case PixelFormat.R8_UNorm:
                internalFormat = PixelInternalFormat.R8;
                format         = PixelFormatGl.Red;
                type           = PixelType.UnsignedByte;
                pixelSize      = 1;
                break;

            case PixelFormat.R8G8B8A8_UNorm:
                internalFormat = PixelInternalFormat.Rgba;
                format         = PixelFormatGl.Rgba;
                type           = PixelType.UnsignedByte;
                pixelSize      = 4;
                break;

            case PixelFormat.B8G8R8A8_UNorm:
#if STRIDE_GRAPHICS_API_OPENGLES
                if (!graphicsDevice.HasExtTextureFormatBGRA8888)
                {
                    throw new NotSupportedException();
                }

                // It seems iOS and Android expects different things
#if STRIDE_PLATFORM_IOS
                internalFormat = PixelInternalFormat.Rgba;
#else
                internalFormat = (PixelInternalFormat)ExtTextureFormatBgra8888.BgraExt;
#endif
                format = (PixelFormatGl)ExtTextureFormatBgra8888.BgraExt;
#else
                internalFormat = PixelInternalFormat.Rgba;
                format         = PixelFormatGl.Bgra;
#endif
                type      = PixelType.UnsignedByte;
                pixelSize = 4;
                break;

            case PixelFormat.R8G8B8A8_UNorm_SRgb:
                internalFormat = PixelInternalFormat.Srgb8Alpha8;
                format         = PixelFormatGl.Rgba;
                type           = PixelType.UnsignedByte;
                pixelSize      = 4;
                break;

#if STRIDE_GRAPHICS_API_OPENGLCORE
            case PixelFormat.B8G8R8A8_UNorm_SRgb:
                // TODO: Check on iOS/Android and OpenGL 3
                internalFormat = PixelInternalFormat.Srgb8Alpha8;
                format         = PixelFormatGl.Bgra;
                type           = PixelType.UnsignedByte;
                pixelSize      = 4;
                break;

            case PixelFormat.BC1_UNorm:
                if (!graphicsDevice.HasDXT)
                {
                    throw new NotSupportedException();
                }
                internalFormat = PixelInternalFormat.CompressedRgbaS3tcDxt1Ext;
                format         = (PixelFormatGl)PixelInternalFormat.CompressedRgbaS3tcDxt1Ext;
                pixelSize      = 4;
                type           = PixelType.UnsignedByte;
                compressed     = true;
                break;

            case PixelFormat.BC1_UNorm_SRgb:
                if (!graphicsDevice.HasDXT)
                {
                    throw new NotSupportedException();
                }
                internalFormat = PixelInternalFormat.CompressedSrgbAlphaS3tcDxt1Ext;
                format         = (PixelFormatGl)PixelInternalFormat.CompressedSrgbAlphaS3tcDxt1Ext;
                pixelSize      = 4;
                type           = PixelType.UnsignedByte;
                compressed     = true;
                break;

            case PixelFormat.BC2_UNorm:
                if (!graphicsDevice.HasDXT)
                {
                    throw new NotSupportedException();
                }
                internalFormat = PixelInternalFormat.CompressedRgbaS3tcDxt3Ext;
                format         = (PixelFormatGl)PixelInternalFormat.CompressedRgbaS3tcDxt3Ext;
                pixelSize      = 4;
                type           = PixelType.UnsignedByte;
                compressed     = true;
                break;

            case PixelFormat.BC2_UNorm_SRgb:
                if (!graphicsDevice.HasDXT)
                {
                    throw new NotSupportedException();
                }
                internalFormat = PixelInternalFormat.CompressedSrgbAlphaS3tcDxt3Ext;
                format         = (PixelFormatGl)PixelInternalFormat.CompressedSrgbAlphaS3tcDxt3Ext;
                pixelSize      = 4;
                type           = PixelType.UnsignedByte;
                compressed     = true;
                break;

            case PixelFormat.BC3_UNorm:
                if (!graphicsDevice.HasDXT)
                {
                    throw new NotSupportedException();
                }
                internalFormat = PixelInternalFormat.CompressedRgbaS3tcDxt5Ext;
                format         = (PixelFormatGl)PixelInternalFormat.CompressedRgbaS3tcDxt5Ext;
                pixelSize      = 4;
                type           = PixelType.UnsignedByte;
                compressed     = true;
                break;

            case PixelFormat.BC3_UNorm_SRgb:
                if (!graphicsDevice.HasDXT)
                {
                    throw new NotSupportedException();
                }
                internalFormat = PixelInternalFormat.CompressedSrgbAlphaS3tcDxt5Ext;
                format         = (PixelFormatGl)PixelInternalFormat.CompressedSrgbAlphaS3tcDxt5Ext;
                pixelSize      = 4;
                type           = PixelType.UnsignedByte;
                compressed     = true;
                break;
#endif
            case PixelFormat.R16_SInt:
                internalFormat = PixelInternalFormat.R16i;
                format         = PixelFormatGl.RedInteger;
                type           = PixelType.Short;
                pixelSize      = 2;
                break;

            case PixelFormat.R16_UInt:
                internalFormat = PixelInternalFormat.R16ui;
                format         = PixelFormatGl.RedInteger;
                type           = PixelType.UnsignedShort;
                pixelSize      = 2;
                break;

            case PixelFormat.R16_Float:
                internalFormat = PixelInternalFormat.R16f;
                format         = PixelFormatGl.Red;
                type           = PixelType.HalfFloat;
                pixelSize      = 2;
                break;

            case PixelFormat.R16G16_SInt:
                internalFormat = PixelInternalFormat.Rg16i;
                format         = PixelFormatGl.RgInteger;
                type           = PixelType.Short;
                pixelSize      = 4;
                break;

            case PixelFormat.R16G16_UInt:
                internalFormat = PixelInternalFormat.Rg16ui;
                format         = PixelFormatGl.RgInteger;
                type           = PixelType.UnsignedShort;
                pixelSize      = 4;
                break;

            case PixelFormat.R16G16_Float:
                internalFormat = PixelInternalFormat.Rg16f;
                format         = PixelFormatGl.Rg;
                type           = PixelType.HalfFloat;
                pixelSize      = 4;
                break;

            case PixelFormat.R16G16B16A16_SInt:
                internalFormat = PixelInternalFormat.Rgba16i;
                format         = PixelFormatGl.RgbaInteger;
                type           = PixelType.Short;
                pixelSize      = 8;
                break;

            case PixelFormat.R16G16B16A16_UInt:
                internalFormat = PixelInternalFormat.Rgba16ui;
                format         = PixelFormatGl.RgbaInteger;
                type           = PixelType.UnsignedShort;
                pixelSize      = 8;
                break;

            case PixelFormat.R16G16B16A16_Float:
                internalFormat = PixelInternalFormat.Rgba16f;
                format         = PixelFormatGl.Rgba;
                type           = PixelType.HalfFloat;
                pixelSize      = 8;
                break;

            case PixelFormat.R10G10B10A2_UNorm:
                internalFormat = PixelInternalFormat.Rgb10A2;
                format         = PixelFormatGl.Rgba;
                type           = PixelType.UnsignedInt1010102;
                pixelSize      = 4;
                break;

            case PixelFormat.R11G11B10_Float:
                internalFormat = PixelInternalFormat.R11fG11fB10f;
                format         = PixelFormatGl.Rgb;
                type           = PixelType.HalfFloat;
                pixelSize      = 4;
                break;

            case PixelFormat.R32_SInt:
                internalFormat = PixelInternalFormat.R32i;
                format         = PixelFormatGl.RedInteger;
                type           = PixelType.Int;
                pixelSize      = 4;
                break;

            case PixelFormat.R32_UInt:
                internalFormat = PixelInternalFormat.R32ui;
                format         = PixelFormatGl.RedInteger;
                type           = PixelType.UnsignedInt;
                pixelSize      = 4;
                break;

            case PixelFormat.R32_Float:
                internalFormat = PixelInternalFormat.R32f;
                format         = PixelFormatGl.Red;
                type           = PixelType.Float;
                pixelSize      = 4;
                break;

            case PixelFormat.R32G32_SInt:
                internalFormat = PixelInternalFormat.Rg32i;
                format         = PixelFormatGl.RgInteger;
                type           = PixelType.Int;
                pixelSize      = 8;
                break;

            case PixelFormat.R32G32_UInt:
                internalFormat = PixelInternalFormat.Rg32ui;
                format         = PixelFormatGl.RgInteger;
                type           = PixelType.UnsignedInt;
                pixelSize      = 8;
                break;

            case PixelFormat.R32G32_Float:
                internalFormat = PixelInternalFormat.Rg32f;
                format         = PixelFormatGl.Rg;
                type           = PixelType.Float;
                pixelSize      = 8;
                break;

            case PixelFormat.R32G32B32_SInt:
                internalFormat = PixelInternalFormat.Rgb32i;
                format         = PixelFormatGl.RgbInteger;
                type           = PixelType.Int;
                pixelSize      = 12;
                break;

            case PixelFormat.R32G32B32_UInt:
                internalFormat = PixelInternalFormat.Rgb32ui;
                format         = PixelFormatGl.RgbInteger;
                type           = PixelType.UnsignedInt;
                pixelSize      = 12;
                break;

            case PixelFormat.R32G32B32_Float:
                internalFormat = PixelInternalFormat.Rgb32f;
                format         = PixelFormatGl.Rgb;
                type           = PixelType.Float;
                pixelSize      = 12;
                break;

            case PixelFormat.R32G32B32A32_SInt:
                internalFormat = PixelInternalFormat.Rgba32i;
                format         = PixelFormatGl.RgbaInteger;
                type           = PixelType.Int;
                pixelSize      = 16;
                break;

            case PixelFormat.R32G32B32A32_UInt:
                internalFormat = PixelInternalFormat.Rgba32ui;
                format         = PixelFormatGl.RgbaInteger;
                type           = PixelType.UnsignedInt;
                pixelSize      = 16;
                break;

            case PixelFormat.R32G32B32A32_Float:
                internalFormat = PixelInternalFormat.Rgba32f;
                format         = PixelFormatGl.Rgba;
                type           = PixelType.Float;
                pixelSize      = 16;
                break;

            case PixelFormat.D16_UNorm:
                internalFormat = PixelInternalFormat.DepthComponent16;
                format         = PixelFormatGl.DepthComponent;
                type           = PixelType.UnsignedShort;
                pixelSize      = 2;
                break;

            case PixelFormat.D24_UNorm_S8_UInt:
                internalFormat = PixelInternalFormat.Depth24Stencil8;
                format         = PixelFormatGl.DepthStencil;
                type           = PixelType.UnsignedInt248;
                pixelSize      = 4;
                break;

            // TODO: Temporary depth format (need to decide relation between RenderTarget1D and Texture)
            case PixelFormat.D32_Float:
                internalFormat = PixelInternalFormat.DepthComponent32f;
                format         = PixelFormatGl.DepthComponent;
                type           = PixelType.Float;
                pixelSize      = 4;
                break;

#if STRIDE_GRAPHICS_API_OPENGLES
            // Desktop OpenGLES
            case PixelFormat.ETC1:
                // TODO: Runtime check for extension?
                internalFormat = (PixelInternalFormat)OesCompressedEtc1Rgb8Texture.Etc1Rgb8Oes;
                format         = (PixelFormatGl)OesCompressedEtc1Rgb8Texture.Etc1Rgb8Oes;
                compressed     = true;
                pixelSize      = 2;
                type           = PixelType.UnsignedByte;
                break;

            case PixelFormat.ETC2_RGBA:
                internalFormat = (PixelInternalFormat)CompressedInternalFormat.CompressedRgba8Etc2Eac;
                format         = (PixelFormatGl)CompressedInternalFormat.CompressedRgba8Etc2Eac;
                compressed     = true;
                pixelSize      = 2;
                type           = PixelType.UnsignedByte;
                break;

            case PixelFormat.ETC2_RGBA_SRgb:
                internalFormat = (PixelInternalFormat)CompressedInternalFormat.CompressedSrgb8Alpha8Etc2Eac;
                format         = (PixelFormatGl)CompressedInternalFormat.CompressedSrgb8Alpha8Etc2Eac;
                compressed     = true;
                pixelSize      = 2;
                type           = PixelType.UnsignedByte;
                break;
#endif
            case PixelFormat.None:     // TODO: remove this - this is only for buffers used in compute shaders
                internalFormat = PixelInternalFormat.Rgba;
                format         = PixelFormatGl.Red;
                type           = PixelType.UnsignedByte;
                pixelSize      = 1;
                break;

            default:
                throw new InvalidOperationException("Unsupported texture format: " + inputFormat);
            }
        }
示例#3
0
        public static void ConvertPixelFormat(GraphicsDevice graphicsDevice, ref PixelFormat inputFormat, out PixelInternalFormat internalFormat, out PixelFormatGl format, out PixelType type,
                                              out int pixelSize, out bool compressed)
        {
            compressed = false;

#if SILICONSTUDIO_XENKO_GRAPHICS_API_OPENGLES
            // check formats more carefully if the device is initialized with OpenGL ES 2
            if (graphicsDevice.currentVersion < 300)
            {
                switch (inputFormat)
                {
                case PixelFormat.R16_Float:
                case PixelFormat.R16G16_Float:
                    if (!graphicsDevice.HasTextureRG || !graphicsDevice.HasTextureHalf)
                    {
                        goto unsupported;
                    }
                    break;

                case PixelFormat.R16G16B16A16_Float:
                    if (!graphicsDevice.HasTextureHalf)
                    {
                        goto unsupported;
                    }
                    break;

                case PixelFormat.R16_UInt:
                case PixelFormat.R16_SInt:
                case PixelFormat.R16G16_UInt:
                case PixelFormat.R16G16_SInt:
                case PixelFormat.R16G16B16A16_UInt:
                case PixelFormat.R16G16B16A16_SInt:
                    goto unsupported;

                case PixelFormat.R32_Float:
                case PixelFormat.R32G32_Float:
                case PixelFormat.R32G32B32_Float:
                    if (!graphicsDevice.HasTextureRG || !graphicsDevice.HasTextureFloat)
                    {
                        goto unsupported;
                    }
                    break;

                case PixelFormat.R32G32B32A32_Float:
                    if (!graphicsDevice.HasTextureFloat)
                    {
                        goto unsupported;
                    }
                    break;

                case PixelFormat.R32_UInt:
                case PixelFormat.R32_SInt:
                case PixelFormat.R32G32_UInt:
                case PixelFormat.R32G32_SInt:
                case PixelFormat.R32G32B32_UInt:
                case PixelFormat.R32G32B32_SInt:
                case PixelFormat.R32G32B32A32_UInt:
                case PixelFormat.R32G32B32A32_SInt:
                    goto unsupported;

                case PixelFormat.D32_Float:
                    goto unsupported;
unsupported:
                    throw new NotSupportedException($"Texture format {inputFormat} not supported with OpenGL ES 2.0");

                    // NOTE: We always allow PixelFormat.D24_UNorm_S8_UInt.
                    // If it is not supported we will fall back to separate D24/D16 and S8 resources when creating a texture.
                }
            }
#endif

            // If the Device doesn't support SRGB, we remap automatically the format to non-srgb
            if (!graphicsDevice.Features.HasSRgb)
            {
                switch (inputFormat)
                {
                case PixelFormat.PVRTC_2bpp_RGB_SRgb:
                    inputFormat = PixelFormat.PVRTC_2bpp_RGB;
                    break;

                case PixelFormat.PVRTC_2bpp_RGBA_SRgb:
                    inputFormat = PixelFormat.PVRTC_2bpp_RGBA;
                    break;

                case PixelFormat.PVRTC_4bpp_RGB_SRgb:
                    inputFormat = PixelFormat.PVRTC_4bpp_RGB;
                    break;

                case PixelFormat.PVRTC_4bpp_RGBA_SRgb:
                    inputFormat = PixelFormat.PVRTC_4bpp_RGBA;
                    break;

                case PixelFormat.ETC2_RGB_SRgb:
                    inputFormat = PixelFormat.ETC2_RGB;
                    break;

                case PixelFormat.ETC2_RGBA_SRgb:
                    inputFormat = PixelFormat.ETC2_RGBA;
                    break;

                case PixelFormat.R8G8B8A8_UNorm_SRgb:
                    inputFormat = PixelFormat.R8G8B8A8_UNorm;
                    break;

                case PixelFormat.B8G8R8A8_UNorm_SRgb:
                    inputFormat = PixelFormat.B8G8R8A8_UNorm;
                    break;
                }
            }

            switch (inputFormat)
            {
            case PixelFormat.A8_UNorm:
                internalFormat = PixelInternalFormat.Alpha;
                format         = PixelFormatGl.Alpha;
                type           = PixelType.UnsignedByte;
                pixelSize      = 1;
                break;

            case PixelFormat.R8_UNorm:
#if SILICONSTUDIO_XENKO_GRAPHICS_API_OPENGLES
                if (!graphicsDevice.HasTextureRG && graphicsDevice.currentVersion < 300)
                {
                    internalFormat = PixelInternalFormat.Luminance;
                    format         = PixelFormatGl.Luminance;
                }
                else
#endif
                {
                    internalFormat = PixelInternalFormat.R8;
                    format         = PixelFormatGl.Red;
                }
                type      = PixelType.UnsignedByte;
                pixelSize = 1;
                break;

            case PixelFormat.R8G8B8A8_UNorm:
                internalFormat = PixelInternalFormat.Rgba;
                format         = PixelFormatGl.Rgba;
                type           = PixelType.UnsignedByte;
                pixelSize      = 4;
                break;

            case PixelFormat.B8G8R8A8_UNorm:
#if SILICONSTUDIO_XENKO_GRAPHICS_API_OPENGLES
                if (!graphicsDevice.HasExtTextureFormatBGRA8888)
                {
                    throw new NotSupportedException();
                }

                // It seems iOS and Android expects different things
#if SILICONSTUDIO_PLATFORM_IOS
                internalFormat = PixelInternalFormat.Rgba;
#else
                internalFormat = (PixelInternalFormat)ExtTextureFormatBgra8888.BgraExt;
#endif
                format = (PixelFormatGl)ExtTextureFormatBgra8888.BgraExt;
#else
                internalFormat = PixelInternalFormat.Rgba;
                format         = PixelFormatGl.Bgra;
#endif
                type      = PixelType.UnsignedByte;
                pixelSize = 4;
                break;

            case PixelFormat.R8G8B8A8_UNorm_SRgb:
                internalFormat = PixelInternalFormat.Srgb8Alpha8;
                format         = PixelFormatGl.Rgba;
                type           = PixelType.UnsignedByte;
                pixelSize      = 4;
                break;

#if SILICONSTUDIO_XENKO_GRAPHICS_API_OPENGLCORE
            case PixelFormat.B8G8R8A8_UNorm_SRgb:
                // TODO: Check on iOS/Android and OpenGL 3
                internalFormat = PixelInternalFormat.Srgb8Alpha8;
                format         = PixelFormatGl.Bgra;
                type           = PixelType.UnsignedByte;
                pixelSize      = 4;
                break;

            case PixelFormat.BC1_UNorm:
                if (!graphicsDevice.HasDXT)
                {
                    throw new NotSupportedException();
                }
                internalFormat = PixelInternalFormat.CompressedRgbaS3tcDxt1Ext;
                format         = (PixelFormatGl)PixelInternalFormat.CompressedRgbaS3tcDxt1Ext;
                pixelSize      = 4;
                type           = PixelType.UnsignedByte;
                compressed     = true;
                break;

            case PixelFormat.BC1_UNorm_SRgb:
                if (!graphicsDevice.HasDXT)
                {
                    throw new NotSupportedException();
                }
                internalFormat = PixelInternalFormat.CompressedSrgbAlphaS3tcDxt1Ext;
                format         = (PixelFormatGl)PixelInternalFormat.CompressedSrgbAlphaS3tcDxt1Ext;
                pixelSize      = 4;
                type           = PixelType.UnsignedByte;
                compressed     = true;
                break;

            case PixelFormat.BC2_UNorm:
                if (!graphicsDevice.HasDXT)
                {
                    throw new NotSupportedException();
                }
                internalFormat = PixelInternalFormat.CompressedRgbaS3tcDxt3Ext;
                format         = (PixelFormatGl)PixelInternalFormat.CompressedRgbaS3tcDxt3Ext;
                pixelSize      = 4;
                type           = PixelType.UnsignedByte;
                compressed     = true;
                break;

            case PixelFormat.BC2_UNorm_SRgb:
                if (!graphicsDevice.HasDXT)
                {
                    throw new NotSupportedException();
                }
                internalFormat = PixelInternalFormat.CompressedSrgbAlphaS3tcDxt3Ext;
                format         = (PixelFormatGl)PixelInternalFormat.CompressedSrgbAlphaS3tcDxt3Ext;
                pixelSize      = 4;
                type           = PixelType.UnsignedByte;
                compressed     = true;
                break;

            case PixelFormat.BC3_UNorm:
                if (!graphicsDevice.HasDXT)
                {
                    throw new NotSupportedException();
                }
                internalFormat = PixelInternalFormat.CompressedRgbaS3tcDxt5Ext;
                format         = (PixelFormatGl)PixelInternalFormat.CompressedRgbaS3tcDxt5Ext;
                pixelSize      = 4;
                type           = PixelType.UnsignedByte;
                compressed     = true;
                break;

            case PixelFormat.BC3_UNorm_SRgb:
                if (!graphicsDevice.HasDXT)
                {
                    throw new NotSupportedException();
                }
                internalFormat = PixelInternalFormat.CompressedSrgbAlphaS3tcDxt5Ext;
                format         = (PixelFormatGl)PixelInternalFormat.CompressedSrgbAlphaS3tcDxt5Ext;
                pixelSize      = 4;
                type           = PixelType.UnsignedByte;
                compressed     = true;
                break;
#endif
            case PixelFormat.R16_Float:
                internalFormat = PixelInternalFormat.R16f;
                format         = PixelFormatGl.Red;
                type           = PixelType.HalfFloat;
                pixelSize      = 2;
                break;

            case PixelFormat.R16G16_Float:
                internalFormat = PixelInternalFormat.Rg16f;
                format         = PixelFormatGl.Rg;
                type           = PixelType.HalfFloat;
                pixelSize      = 4;
                break;

            case PixelFormat.R16G16B16A16_Float:
                internalFormat = PixelInternalFormat.Rgba16f;
                format         = PixelFormatGl.Rgba;
                type           = PixelType.HalfFloat;
                pixelSize      = 8;
                break;

            case PixelFormat.R32_SInt:
                internalFormat = PixelInternalFormat.R32i;
                format         = PixelFormatGl.RedInteger;
                type           = PixelType.Int;
                pixelSize      = 4;
                break;

            case PixelFormat.R32_UInt:
                internalFormat = PixelInternalFormat.R32ui;
                format         = PixelFormatGl.RedInteger;
                type           = PixelType.UnsignedInt;
                pixelSize      = 4;
                break;

            case PixelFormat.R32_Float:
                internalFormat = PixelInternalFormat.R32f;
                format         = PixelFormatGl.Red;
                type           = PixelType.Float;
                pixelSize      = 4;
                break;

            case PixelFormat.R32G32_SInt:
                internalFormat = PixelInternalFormat.Rg32i;
                format         = PixelFormatGl.RgInteger;
                type           = PixelType.Int;
                pixelSize      = 8;
                break;

            case PixelFormat.R32G32_UInt:
                internalFormat = PixelInternalFormat.Rg32ui;
                format         = PixelFormatGl.RgInteger;
                type           = PixelType.UnsignedInt;
                pixelSize      = 8;
                break;

            case PixelFormat.R32G32_Float:
                internalFormat = PixelInternalFormat.Rg32f;
                format         = PixelFormatGl.Rg;
                type           = PixelType.Float;
                pixelSize      = 8;
                break;

            case PixelFormat.R32G32B32_SInt:
                internalFormat = PixelInternalFormat.Rgb32i;
                format         = PixelFormatGl.RgbInteger;
                type           = PixelType.Int;
                pixelSize      = 12;
                break;

            case PixelFormat.R32G32B32_UInt:
                internalFormat = PixelInternalFormat.Rgb32ui;
                format         = PixelFormatGl.RgbInteger;
                type           = PixelType.UnsignedInt;
                pixelSize      = 12;
                break;

            case PixelFormat.R32G32B32_Float:
                internalFormat = PixelInternalFormat.Rgb32f;
                format         = PixelFormatGl.Rgb;
                type           = PixelType.Float;
                pixelSize      = 12;
                break;

            case PixelFormat.R32G32B32A32_SInt:
                internalFormat = PixelInternalFormat.Rgba32i;
                format         = PixelFormatGl.RgbaInteger;
                type           = PixelType.Int;
                pixelSize      = 16;
                break;

            case PixelFormat.R32G32B32A32_UInt:
                internalFormat = PixelInternalFormat.Rgba32ui;
                format         = PixelFormatGl.RgbaInteger;
                type           = PixelType.UnsignedInt;
                pixelSize      = 16;
                break;

            case PixelFormat.R32G32B32A32_Float:
                internalFormat = PixelInternalFormat.Rgba32f;
                format         = PixelFormatGl.Rgba;
                type           = PixelType.Float;
                pixelSize      = 16;
                break;

            case PixelFormat.D16_UNorm:
                internalFormat = PixelInternalFormat.DepthComponent16;
                format         = PixelFormatGl.DepthComponent;
                type           = PixelType.UnsignedShort;
                pixelSize      = 2;
                break;

            case PixelFormat.D24_UNorm_S8_UInt:
                internalFormat = PixelInternalFormat.Depth24Stencil8;
                format         = PixelFormatGl.DepthStencil;
                type           = PixelType.UnsignedInt248;
                pixelSize      = 4;
                break;

            // TODO: Temporary depth format (need to decide relation between RenderTarget1D and Texture)
            case PixelFormat.D32_Float:
                internalFormat = PixelInternalFormat.DepthComponent32f;
                format         = PixelFormatGl.DepthComponent;
                type           = PixelType.Float;
                pixelSize      = 4;
                break;

#if SILICONSTUDIO_PLATFORM_IOS
            case PixelFormat.PVRTC_4bpp_RGB:
                internalFormat = (PixelInternalFormat)ImgTextureCompressionPvrtc.CompressedRgbPvrtc4Bppv1Img;
                format         = (PixelFormatGl)ImgTextureCompressionPvrtc.CompressedRgbPvrtc4Bppv1Img;
                compressed     = true;
                pixelSize      = 4;
                type           = PixelType.UnsignedByte;
                break;

            case PixelFormat.PVRTC_2bpp_RGB:
                internalFormat = (PixelInternalFormat)ImgTextureCompressionPvrtc.CompressedRgbPvrtc2Bppv1Img;
                format         = (PixelFormatGl)ImgTextureCompressionPvrtc.CompressedRgbPvrtc2Bppv1Img;
                compressed     = true;
                pixelSize      = 2;
                type           = PixelType.UnsignedByte;
                break;

            case PixelFormat.PVRTC_4bpp_RGBA:
                internalFormat = (PixelInternalFormat)ImgTextureCompressionPvrtc.CompressedRgbaPvrtc4Bppv1Img;
                format         = (PixelFormatGl)ImgTextureCompressionPvrtc.CompressedRgbaPvrtc4Bppv1Img;
                compressed     = true;
                pixelSize      = 4;
                type           = PixelType.UnsignedByte;
                break;

            case PixelFormat.PVRTC_2bpp_RGBA:
                internalFormat = (PixelInternalFormat)ImgTextureCompressionPvrtc.CompressedRgbaPvrtc2Bppv1Img;
                format         = (PixelFormatGl)ImgTextureCompressionPvrtc.CompressedRgbaPvrtc2Bppv1Img;
                compressed     = true;
                pixelSize      = 2;
                type           = PixelType.UnsignedByte;
                break;

            case PixelFormat.PVRTC_4bpp_RGB_SRgb:
                internalFormat = (PixelInternalFormat)ExtPvrtcSrgb.CompressedSrgbPvrtc4Bppv1Ext;
                format         = (PixelFormatGl)ExtPvrtcSrgb.CompressedSrgbPvrtc4Bppv1Ext;
                compressed     = true;
                pixelSize      = 4;
                type           = PixelType.UnsignedByte;
                break;

            case PixelFormat.PVRTC_2bpp_RGB_SRgb:
                internalFormat = (PixelInternalFormat)ExtPvrtcSrgb.CompressedSrgbPvrtc2Bppv1Ext;
                format         = (PixelFormatGl)ExtPvrtcSrgb.CompressedSrgbPvrtc2Bppv1Ext;
                compressed     = true;
                pixelSize      = 2;
                type           = PixelType.UnsignedByte;
                break;

            case PixelFormat.PVRTC_4bpp_RGBA_SRgb:
                internalFormat = (PixelInternalFormat)ExtPvrtcSrgb.CompressedSrgbAlphaPvrtc4Bppv1Ext;
                format         = (PixelFormatGl)ExtPvrtcSrgb.CompressedSrgbAlphaPvrtc4Bppv1Ext;
                compressed     = true;
                pixelSize      = 4;
                type           = PixelType.UnsignedByte;
                break;

            case PixelFormat.PVRTC_2bpp_RGBA_SRgb:
                internalFormat = (PixelInternalFormat)ExtPvrtcSrgb.CompressedSrgbAlphaPvrtc2Bppv1Ext;
                format         = (PixelFormatGl)ExtPvrtcSrgb.CompressedSrgbAlphaPvrtc2Bppv1Ext;
                compressed     = true;
                pixelSize      = 2;
                type           = PixelType.UnsignedByte;
                break;
#elif SILICONSTUDIO_XENKO_GRAPHICS_API_OPENGLES
            // Desktop OpenGLES
            case PixelFormat.ETC1:
                // TODO: Runtime check for extension?
                internalFormat = (PixelInternalFormat)OesCompressedEtc1Rgb8Texture.Etc1Rgb8Oes;
                format         = (PixelFormatGl)OesCompressedEtc1Rgb8Texture.Etc1Rgb8Oes;
                compressed     = true;
                pixelSize      = 2;
                type           = PixelType.UnsignedByte;
                break;

            case PixelFormat.ETC2_RGBA:
                internalFormat = (PixelInternalFormat)CompressedInternalFormat.CompressedRgba8Etc2Eac;
                format         = (PixelFormatGl)CompressedInternalFormat.CompressedRgba8Etc2Eac;
                compressed     = true;
                pixelSize      = 2;
                type           = PixelType.UnsignedByte;
                break;

            case PixelFormat.ETC2_RGBA_SRgb:
                internalFormat = (PixelInternalFormat)CompressedInternalFormat.CompressedSrgb8Alpha8Etc2Eac;
                format         = (PixelFormatGl)CompressedInternalFormat.CompressedSrgb8Alpha8Etc2Eac;
                compressed     = true;
                pixelSize      = 2;
                type           = PixelType.UnsignedByte;
                break;
#endif
            case PixelFormat.None:     // TODO: remove this - this is only for buffers used in compute shaders
                internalFormat = PixelInternalFormat.Rgba;
                format         = PixelFormatGl.Red;
                type           = PixelType.UnsignedByte;
                pixelSize      = 1;
                break;

            default:
                throw new InvalidOperationException("Unsupported texture format");
            }

#if SILICONSTUDIO_XENKO_GRAPHICS_API_OPENGLES
            // override some formats for ES2.0
            if (graphicsDevice.currentVersion < 300)
            {
                switch (inputFormat)
                {
                case PixelFormat.R8G8B8A8_UNorm_SRgb:
                    // HasSRgb was true because we have GL_EXT_sRGB
                    // Note: Qualcomm Adreno 4xx fails to use GL_EXT_sRGB with FBO,
                    // but they will report a currentVersion >= 300 (ES 3.0) anyway
                    internalFormat = (PixelInternalFormat)ExtSrgb.SrgbAlphaExt;
                    format         = (PixelFormatGl)ExtSrgb.SrgbAlphaExt;
                    break;

                case PixelFormat.R8_UNorm:
                case PixelFormat.R8_SNorm:
                case PixelFormat.R8_UInt:
                case PixelFormat.R8_SInt:
                case PixelFormat.R16_Float:
                case PixelFormat.R16_UNorm:
                case PixelFormat.R16_SNorm:
                case PixelFormat.R16_UInt:
                case PixelFormat.R16_SInt:
                case PixelFormat.R32_Float:
                case PixelFormat.R32_UInt:
                case PixelFormat.R32_SInt:
                    if (inputFormat == PixelFormat.R16_Float)
                    {
                        type = (PixelType)OesTextureHalfFloat.HalfFloatOes;
                    }
                    if (graphicsDevice.HasTextureRG)
                    {
                        internalFormat = (PixelInternalFormat)ExtTextureRg.RedExt;
                    }
                    break;

                case PixelFormat.R16G16_Float:
                case PixelFormat.R16G16_UNorm:
                case PixelFormat.R16G16_SNorm:
                case PixelFormat.R16G16_UInt:
                case PixelFormat.R16G16_SInt:
                case PixelFormat.R32G32_Float:
                case PixelFormat.R32G32_UInt:
                case PixelFormat.R32G32_SInt:
                    if (inputFormat == PixelFormat.R16G16_Float)
                    {
                        type = (PixelType)OesTextureHalfFloat.HalfFloatOes;
                    }
                    if (graphicsDevice.HasTextureRG)
                    {
                        internalFormat = (PixelInternalFormat)ExtTextureRg.RgExt;
                    }
                    break;

                case PixelFormat.R32G32B32_Float:
                case PixelFormat.R32G32B32_UInt:
                case PixelFormat.R32G32B32_SInt:
                    internalFormat = PixelInternalFormat.Rgb;
                    break;

                case PixelFormat.R16G16B16A16_Float:
                case PixelFormat.R32G32B32A32_Float:
                case PixelFormat.R16G16B16A16_UInt:
                case PixelFormat.R32G32B32A32_UInt:
                case PixelFormat.R16G16B16A16_SInt:
                case PixelFormat.R32G32B32A32_SInt:
                    if (inputFormat == PixelFormat.R16G16B16A16_Float)
                    {
                        type = (PixelType)OesTextureHalfFloat.HalfFloatOes;
                    }
                    internalFormat = PixelInternalFormat.Rgba;
                    break;
                }
            }
#endif
        }
示例#4
0
        public static void ConvertPixelFormat(GraphicsDevice graphicsDevice, ref PixelFormat inputFormat, out PixelInternalFormat internalFormat, out PixelFormatGl format, out PixelType type, out int pixelSize, out bool compressed)
        {
            compressed = false;

#if SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
            // check formats is the device is initialized with OpenGL ES 2
            if (graphicsDevice.IsOpenGLES2)
            {
                switch (inputFormat)
                {
                case PixelFormat.R32_UInt:
                case PixelFormat.R32_Float:
                case PixelFormat.R32G32_Float:
                case PixelFormat.R32G32B32_Float:
                case PixelFormat.R16G16B16A16_Float:
                case PixelFormat.R32G32B32A32_Float:
                case PixelFormat.D32_Float:
                    throw new NotSupportedException(String.Format("Texture format {0} not supported", inputFormat));

                case PixelFormat.D24_UNorm_S8_UInt:
                    if (!(graphicsDevice.HasDepth24 && graphicsDevice.HasPackedDepthStencilExtension))
                    {
                        throw new NotSupportedException(String.Format("Texture format {0} not supported", inputFormat));
                    }
                    break;
                }
            }
#endif

            // If the Device doesn't support SRGB, we remap automatically the format to non-srgb
            if (!graphicsDevice.Features.HasSRgb)
            {
                switch (inputFormat)
                {
                case PixelFormat.PVRTC_2bpp_RGB_SRgb:
                    inputFormat = PixelFormat.PVRTC_2bpp_RGB;
                    break;

                case PixelFormat.PVRTC_2bpp_RGBA_SRgb:
                    inputFormat = PixelFormat.PVRTC_2bpp_RGBA;
                    break;

                case PixelFormat.PVRTC_4bpp_RGB_SRgb:
                    inputFormat = PixelFormat.PVRTC_4bpp_RGB;
                    break;

                case PixelFormat.PVRTC_4bpp_RGBA_SRgb:
                    inputFormat = PixelFormat.PVRTC_4bpp_RGBA;
                    break;

                case PixelFormat.ETC2_RGB_SRgb:
                    inputFormat = PixelFormat.ETC2_RGB;
                    break;

                case PixelFormat.ETC2_RGBA_SRgb:
                    inputFormat = PixelFormat.ETC2_RGBA;
                    break;

                case PixelFormat.R8G8B8A8_UNorm_SRgb:
                    inputFormat = PixelFormat.R8G8B8A8_UNorm;
                    break;

                case PixelFormat.B8G8R8A8_UNorm_SRgb:
                    inputFormat = PixelFormat.B8G8R8A8_UNorm;
                    break;
                }
            }

            switch (inputFormat)
            {
            case PixelFormat.A8_UNorm:
                internalFormat = PixelInternalFormat.Alpha;
                format         = PixelFormatGl.Alpha;
                type           = PixelType.UnsignedByte;
                pixelSize      = 1;
                break;

            case PixelFormat.R8_UNorm:
#if SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
                if (graphicsDevice.IsOpenGLES2)
                {
                    internalFormat = PixelInternalFormat.Luminance;
                    format         = PixelFormatGl.Luminance;
                }
                else
#endif
                {
                    internalFormat = R8;
                    format         = PixelFormatGl.Red;
                }
                type      = PixelType.UnsignedByte;
                pixelSize = 1;
                break;

            case PixelFormat.R8G8B8A8_UNorm:
                internalFormat = PixelInternalFormat.Rgba;
                format         = PixelFormatGl.Rgba;
                type           = PixelType.UnsignedByte;
                pixelSize      = 4;
                break;

            case PixelFormat.B8G8R8A8_UNorm:
#if SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
                if (!graphicsDevice.HasExtTextureFormatBGRA8888)
                {
                    throw new NotSupportedException();
                }

                // It seems iOS and Android expects different things
#if SILICONSTUDIO_PLATFORM_IOS
                internalFormat = PixelInternalFormat.Rgba;
#else
                internalFormat = (PixelInternalFormat)ExtTextureFormatBgra8888.BgraExt;
#endif
                format = (PixelFormatGl)ExtTextureFormatBgra8888.BgraExt;
#else
                internalFormat = PixelInternalFormat.Rgba;
                format         = PixelFormatGl.Bgra;
#endif
                type      = PixelType.UnsignedByte;
                pixelSize = 4;
                break;

            case PixelFormat.R8G8B8A8_UNorm_SRgb:
                internalFormat = graphicsDevice.currentVersionMajor < 3 ? SrgbAlpha : Srgb8Alpha8;
                format         = graphicsDevice.currentVersionMajor < 3 ? (PixelFormatGl)SrgbAlpha : PixelFormatGl.Rgba;
                type           = PixelType.UnsignedByte;
                pixelSize      = 4;
                break;

            case PixelFormat.R16_Float:
                internalFormat = R16f;
                format         = PixelFormatGl.Red;
                type           = PixelType.HalfFloat;
                pixelSize      = 2;
                break;

            case PixelFormat.R16G16_Float:
                internalFormat = Rg16f;
                format         = PixelFormatGl.Rg;
                type           = PixelType.HalfFloat;
                pixelSize      = 4;
                break;

            case PixelFormat.R16G16B16A16_Float:
                internalFormat = Rgba16f;
                format         = PixelFormatGl.Rgba;
                type           = PixelType.HalfFloat;
                pixelSize      = 8;
                break;

            case PixelFormat.R32_UInt:
                internalFormat = R32ui;
                format         = PixelFormatGl.RedInteger;
                type           = PixelType.UnsignedInt;
                pixelSize      = 4;
                break;

            case PixelFormat.R32_Float:
                internalFormat = R32f;
                format         = PixelFormatGl.Red;
                type           = PixelType.Float;
                pixelSize      = 4;
                break;

            case PixelFormat.R32G32_Float:
                internalFormat = Rg32f;
                format         = PixelFormatGl.Rg;
                type           = PixelType.Float;
                pixelSize      = 8;
                break;

            case PixelFormat.R32G32B32_Float:
                internalFormat = Rgb32f;
                format         = PixelFormatGl.Rgb;
                type           = PixelType.Float;
                pixelSize      = 12;
                break;

            case PixelFormat.R32G32B32A32_Float:
                internalFormat = Rgba32f;
                format         = PixelFormatGl.Rgba;
                type           = PixelType.Float;
                pixelSize      = 16;
                break;

            case PixelFormat.D16_UNorm:
                internalFormat = DepthComponent16;
                format         = PixelFormatGl.DepthComponent;
                type           = PixelType.UnsignedShort;
                pixelSize      = 2;
                break;

            case PixelFormat.D24_UNorm_S8_UInt:
                internalFormat = Depth24Stencil8;
                format         = PixelFormatGl.DepthStencil;
                type           = PixelType.UnsignedInt248;
                pixelSize      = 4;
                break;

            // TODO: Temporary depth format (need to decide relation between RenderTarget1D and Texture)
            case PixelFormat.D32_Float:
                internalFormat = DepthComponent32f;
                format         = PixelFormatGl.DepthComponent;
                type           = PixelType.Float;
                pixelSize      = 4;
                break;

#if SILICONSTUDIO_PLATFORM_IOS
            case PixelFormat.PVRTC_4bpp_RGB:
                internalFormat = (PixelInternalFormat)ImgTextureCompressionPvrtc.CompressedRgbPvrtc4Bppv1Img;
                format         = (PixelFormatGl)ImgTextureCompressionPvrtc.CompressedRgbPvrtc4Bppv1Img;
                compressed     = true;
                pixelSize      = 4;
                type           = PixelType.UnsignedByte;
                break;

            case PixelFormat.PVRTC_2bpp_RGB:
                internalFormat = (PixelInternalFormat)ImgTextureCompressionPvrtc.CompressedRgbPvrtc2Bppv1Img;
                format         = (PixelFormatGl)ImgTextureCompressionPvrtc.CompressedRgbPvrtc2Bppv1Img;
                compressed     = true;
                pixelSize      = 2;
                type           = PixelType.UnsignedByte;
                break;

            case PixelFormat.PVRTC_4bpp_RGBA:
                internalFormat = (PixelInternalFormat)ImgTextureCompressionPvrtc.CompressedRgbaPvrtc4Bppv1Img;
                format         = (PixelFormatGl)ImgTextureCompressionPvrtc.CompressedRgbaPvrtc4Bppv1Img;
                compressed     = true;
                pixelSize      = 4;
                type           = PixelType.UnsignedByte;
                break;

            case PixelFormat.PVRTC_2bpp_RGBA:
                internalFormat = (PixelInternalFormat)ImgTextureCompressionPvrtc.CompressedRgbaPvrtc2Bppv1Img;
                format         = (PixelFormatGl)ImgTextureCompressionPvrtc.CompressedRgbaPvrtc2Bppv1Img;
                compressed     = true;
                pixelSize      = 2;
                type           = PixelType.UnsignedByte;
                break;

            case PixelFormat.PVRTC_4bpp_RGB_SRgb:
                internalFormat = (PixelInternalFormat)ImgTextureCompressionPvrtc.CompressedSrgbPvrtc4Bppv1Ext;
                format         = (PixelFormatGl)ImgTextureCompressionPvrtc.CompressedSrgbPvrtc4Bppv1Ext;
                compressed     = true;
                pixelSize      = 4;
                type           = PixelType.UnsignedByte;
                break;

            case PixelFormat.PVRTC_2bpp_RGB_SRgb:
                internalFormat = (PixelInternalFormat)ImgTextureCompressionPvrtc.CompressedSrgbPvrtc2Bppv1Ext;
                format         = (PixelFormatGl)ImgTextureCompressionPvrtc.CompressedSrgbPvrtc2Bppv1Ext;
                compressed     = true;
                pixelSize      = 2;
                type           = PixelType.UnsignedByte;
                break;

            case PixelFormat.PVRTC_4bpp_RGBA_SRgb:
                internalFormat = (PixelInternalFormat)ImgTextureCompressionPvrtc.CompressedSrgbAlphaPvrtc4Bppv1Ext;
                format         = (PixelFormatGl)ImgTextureCompressionPvrtc.CompressedSrgbAlphaPvrtc4Bppv1Ext;
                compressed     = true;
                pixelSize      = 4;
                type           = PixelType.UnsignedByte;
                break;

            case PixelFormat.PVRTC_2bpp_RGBA_SRgb:
                internalFormat = (PixelInternalFormat)ImgTextureCompressionPvrtc.CompressedSrgbAlphaPvrtc2Bppv1Ext;
                format         = (PixelFormatGl)ImgTextureCompressionPvrtc.CompressedSrgbAlphaPvrtc2Bppv1Ext;
                compressed     = true;
                pixelSize      = 2;
                type           = PixelType.UnsignedByte;
                break;
#elif SILICONSTUDIO_PLATFORM_ANDROID || !SILICONSTUDIO_PLATFORM_MONO_MOBILE && SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
            // Desktop OpenGLES
            case PixelFormat.ETC1:
                // TODO: Runtime check for extension?
                internalFormat = (PixelInternalFormat)OesCompressedEtc1Rgb8Texture.Etc1Rgb8Oes;
                format         = (PixelFormatGl)OesCompressedEtc1Rgb8Texture.Etc1Rgb8Oes;
                compressed     = true;
                pixelSize      = 2;
                type           = PixelType.UnsignedByte;
                break;

            case PixelFormat.ETC2_RGBA:
                internalFormat = (PixelInternalFormat)CompressedInternalFormat.CompressedRgba8Etc2Eac;
                format         = (PixelFormatGl)CompressedInternalFormat.CompressedRgba8Etc2Eac;
                compressed     = true;
                pixelSize      = 2;
                type           = PixelType.UnsignedByte;
                break;

            case PixelFormat.ETC2_RGBA_SRgb:
                internalFormat = (PixelInternalFormat)CompressedInternalFormat.CompressedSrgb8Alpha8Etc2Eac;
                format         = (PixelFormatGl)CompressedInternalFormat.CompressedSrgb8Alpha8Etc2Eac;
                compressed     = true;
                pixelSize      = 2;
                type           = PixelType.UnsignedByte;
                break;
#endif
            case PixelFormat.None:     // TODO: remove this - this is only for buffers used in compute shaders
                internalFormat = PixelInternalFormat.Rgba;
                format         = PixelFormatGl.Red;
                type           = PixelType.UnsignedByte;
                pixelSize      = 1;
                break;

            default:
                throw new InvalidOperationException("Unsupported texture format");
            }
        }
        public static void ConvertPixelFormat(GraphicsDevice graphicsDevice, ref PixelFormat inputFormat, out PixelInternalFormat internalFormat, out PixelFormatGl format, out PixelType type, out int pixelSize, out bool compressed)
        {
            compressed = false;

#if SILICONSTUDIO_XENKO_GRAPHICS_API_OPENGLES
            // check formats is the device is initialized with OpenGL ES 2
            if (graphicsDevice.IsOpenGLES2)
            {
                switch (inputFormat)
                {
                    case PixelFormat.R32_UInt:
                    case PixelFormat.R32_Float:
                    case PixelFormat.R32G32_Float:
                    case PixelFormat.R32G32B32_Float:
                    case PixelFormat.R16G16B16A16_Float:
                    case PixelFormat.R32G32B32A32_Float:
                    case PixelFormat.D32_Float:
                        throw new NotSupportedException(String.Format("Texture format {0} not supported", inputFormat));

                    // NOTE: We always allow PixelFormat.D24_UNorm_S8_UInt.
                    // If it is not supported we will fall back to separate D24/D16 and S8 resources when creating a texture.
                }
            }
#endif

            // If the Device doesn't support SRGB, we remap automatically the format to non-srgb
            if (!graphicsDevice.Features.HasSRgb)
            {
                switch (inputFormat)
                {
                    case PixelFormat.PVRTC_2bpp_RGB_SRgb:
                        inputFormat = PixelFormat.PVRTC_2bpp_RGB;
                        break;
                    case PixelFormat.PVRTC_2bpp_RGBA_SRgb:
                        inputFormat = PixelFormat.PVRTC_2bpp_RGBA;
                        break;
                    case PixelFormat.PVRTC_4bpp_RGB_SRgb:
                        inputFormat = PixelFormat.PVRTC_4bpp_RGB;
                        break;
                    case PixelFormat.PVRTC_4bpp_RGBA_SRgb:
                        inputFormat = PixelFormat.PVRTC_4bpp_RGBA;
                        break;
                    case PixelFormat.ETC2_RGB_SRgb:
                        inputFormat = PixelFormat.ETC2_RGB;
                        break;
                    case PixelFormat.ETC2_RGBA_SRgb:
                        inputFormat = PixelFormat.ETC2_RGBA;
                        break;
                    case PixelFormat.R8G8B8A8_UNorm_SRgb:
                        inputFormat = PixelFormat.R8G8B8A8_UNorm;
                        break;
                    case PixelFormat.B8G8R8A8_UNorm_SRgb:
                        inputFormat = PixelFormat.B8G8R8A8_UNorm;
                        break;
                }
            }

            switch (inputFormat)
            {
                case PixelFormat.A8_UNorm:
                    internalFormat = PixelInternalFormat.Alpha;
                    format = PixelFormatGl.Alpha;
                    type = PixelType.UnsignedByte;
                    pixelSize = 1;
                    break;
                case PixelFormat.R8_UNorm:
#if SILICONSTUDIO_XENKO_GRAPHICS_API_OPENGLES
                    if (!graphicsDevice.HasTextureRG && graphicsDevice.IsOpenGLES2)
                    {
                        internalFormat = PixelInternalFormat.Luminance;
                        format = PixelFormatGl.Luminance;
                    }
                    else
#endif
                    {
#if SILICONSTUDIO_PLATFORM_IOS
                        internalFormat = PixelInternalFormat.Luminance;
                        format = PixelFormatGl.Luminance;
#else
                        internalFormat = R8;
                        format = PixelFormatGl.Red;
#endif
                    }
                    type = PixelType.UnsignedByte;
                    pixelSize = 1;
                    break;
                case PixelFormat.R8G8B8A8_UNorm:
                    internalFormat = PixelInternalFormat.Rgba;
                    format = PixelFormatGl.Rgba;
                    type = PixelType.UnsignedByte;
                    pixelSize = 4;
                    break;
                case PixelFormat.B8G8R8A8_UNorm:
#if SILICONSTUDIO_XENKO_GRAPHICS_API_OPENGLES
                    if (!graphicsDevice.HasExtTextureFormatBGRA8888)
                        throw new NotSupportedException();

                    // It seems iOS and Android expects different things
#if SILICONSTUDIO_PLATFORM_IOS
                    internalFormat = PixelInternalFormat.Rgba;
#else
                    internalFormat = (PixelInternalFormat)ExtTextureFormatBgra8888.BgraExt;
#endif
                    format = (PixelFormatGl)ExtTextureFormatBgra8888.BgraExt;
#else
                    internalFormat = PixelInternalFormat.Rgba;
                    format = PixelFormatGl.Bgra;
#endif
                    type = PixelType.UnsignedByte;
                    pixelSize = 4;
                    break;
                case PixelFormat.R8G8B8A8_UNorm_SRgb:
                    internalFormat = graphicsDevice.currentVersionMajor < 3 ? SrgbAlpha : Srgb8Alpha8;
                    format = graphicsDevice.currentVersionMajor < 3 ? (PixelFormatGl)SrgbAlpha : PixelFormatGl.Rgba;
                    type = PixelType.UnsignedByte;
                    pixelSize = 4;
                    break;
#if SILICONSTUDIO_XENKO_GRAPHICS_API_OPENGLCORE
                case PixelFormat.B8G8R8A8_UNorm_SRgb:
                    // TODO: Check on iOS/Android and OpenGL 3
                    internalFormat = graphicsDevice.currentVersionMajor < 3 ? SrgbAlpha : Srgb8Alpha8;
                    format = graphicsDevice.currentVersionMajor < 3 ? (PixelFormatGl)SrgbAlpha : PixelFormatGl.Bgra;
                    type = PixelType.UnsignedByte;
                    pixelSize = 4;
                    break;
#endif
                case PixelFormat.R16_Float:
                    internalFormat = R16f;
                    format = PixelFormatGl.Red;
                    type = PixelType.HalfFloat;
                    pixelSize = 2;
                    break;
                case PixelFormat.R16G16_Float:
                    internalFormat = Rg16f;
                    format = PixelFormatGl.Rg;
                    type = PixelType.HalfFloat;
                    pixelSize = 4;
                    break;
                case PixelFormat.R16G16B16A16_Float:
                    internalFormat = Rgba16f;
                    format = PixelFormatGl.Rgba;
                    type = PixelType.HalfFloat;
                    pixelSize = 8;
                    break;
                case PixelFormat.R32_UInt:
                    internalFormat = R32ui;
                    format = PixelFormatGl.RedInteger;
                    type = PixelType.UnsignedInt;
                    pixelSize = 4;
                    break;
                case PixelFormat.R32_Float:
                    internalFormat = R32f;
                    format = PixelFormatGl.Red;
                    type = PixelType.Float;
                    pixelSize = 4;
                    break;
                case PixelFormat.R32G32_Float:
                    internalFormat = Rg32f;
                    format = PixelFormatGl.Rg;
                    type = PixelType.Float;
                    pixelSize = 8;
                    break;
                case PixelFormat.R32G32B32_Float:
                    internalFormat = Rgb32f;
                    format = PixelFormatGl.Rgb;
                    type = PixelType.Float;
                    pixelSize = 12;
                    break;
                case PixelFormat.R32G32B32A32_Float:
                    internalFormat = Rgba32f;
                    format = PixelFormatGl.Rgba;
                    type = PixelType.Float;
                    pixelSize = 16;
                    break;
                case PixelFormat.D16_UNorm:
                    internalFormat = DepthComponent16;
                    format = PixelFormatGl.DepthComponent;
                    type = PixelType.UnsignedShort;
                    pixelSize = 2;
                    break;
                case PixelFormat.D24_UNorm_S8_UInt:
                    internalFormat = Depth24Stencil8;
                    format = PixelFormatGl.DepthStencil;
                    type = PixelType.UnsignedInt248;
                    pixelSize = 4;
                    break;
                // TODO: Temporary depth format (need to decide relation between RenderTarget1D and Texture)
                case PixelFormat.D32_Float:
                    internalFormat = DepthComponent32f;
                    format = PixelFormatGl.DepthComponent;
                    type = PixelType.Float;
                    pixelSize = 4;
                    break;
#if SILICONSTUDIO_PLATFORM_IOS
                case PixelFormat.PVRTC_4bpp_RGB:
                    internalFormat = (PixelInternalFormat)ImgTextureCompressionPvrtc.CompressedRgbPvrtc4Bppv1Img;
                    format = (PixelFormatGl)ImgTextureCompressionPvrtc.CompressedRgbPvrtc4Bppv1Img;
                    compressed = true;
                    pixelSize = 4;
                    type = PixelType.UnsignedByte;
                    break;
                case PixelFormat.PVRTC_2bpp_RGB:
                    internalFormat = (PixelInternalFormat)ImgTextureCompressionPvrtc.CompressedRgbPvrtc2Bppv1Img;
                    format = (PixelFormatGl)ImgTextureCompressionPvrtc.CompressedRgbPvrtc2Bppv1Img;
                    compressed = true;
                    pixelSize = 2;
                    type = PixelType.UnsignedByte;
                    break;
                case PixelFormat.PVRTC_4bpp_RGBA:
                    internalFormat = (PixelInternalFormat)ImgTextureCompressionPvrtc.CompressedRgbaPvrtc4Bppv1Img;
                    format = (PixelFormatGl)ImgTextureCompressionPvrtc.CompressedRgbaPvrtc4Bppv1Img;
                    compressed = true;
                    pixelSize = 4;
                    type = PixelType.UnsignedByte;
                    break;
                case PixelFormat.PVRTC_2bpp_RGBA:
                    internalFormat = (PixelInternalFormat)ImgTextureCompressionPvrtc.CompressedRgbaPvrtc2Bppv1Img;
                    format = (PixelFormatGl)ImgTextureCompressionPvrtc.CompressedRgbaPvrtc2Bppv1Img;
                    compressed = true;
                    pixelSize = 2;
                    type = PixelType.UnsignedByte;
                    break;  
                case PixelFormat.PVRTC_4bpp_RGB_SRgb:
                    internalFormat = (PixelInternalFormat)ImgTextureCompressionPvrtc.CompressedSrgbPvrtc4Bppv1Ext;
                    format = (PixelFormatGl)ImgTextureCompressionPvrtc.CompressedSrgbPvrtc4Bppv1Ext;
                    compressed = true;
                    pixelSize = 4;
                    type = PixelType.UnsignedByte;
                    break;		
                case PixelFormat.PVRTC_2bpp_RGB_SRgb:
                    internalFormat = (PixelInternalFormat)ImgTextureCompressionPvrtc.CompressedSrgbPvrtc2Bppv1Ext;
                    format = (PixelFormatGl)ImgTextureCompressionPvrtc.CompressedSrgbPvrtc2Bppv1Ext;
                    compressed = true;
                    pixelSize = 2;
                    type = PixelType.UnsignedByte;
                    break;
                case PixelFormat.PVRTC_4bpp_RGBA_SRgb:
                    internalFormat = (PixelInternalFormat)ImgTextureCompressionPvrtc.CompressedSrgbAlphaPvrtc4Bppv1Ext;
                    format = (PixelFormatGl)ImgTextureCompressionPvrtc.CompressedSrgbAlphaPvrtc4Bppv1Ext;
                    compressed = true;
                    pixelSize = 4;
                    type = PixelType.UnsignedByte;
                    break;
                case PixelFormat.PVRTC_2bpp_RGBA_SRgb:
                    internalFormat = (PixelInternalFormat)ImgTextureCompressionPvrtc.CompressedSrgbAlphaPvrtc2Bppv1Ext;
                    format = (PixelFormatGl)ImgTextureCompressionPvrtc.CompressedSrgbAlphaPvrtc2Bppv1Ext;
                    compressed = true;
                    pixelSize = 2;
                    type = PixelType.UnsignedByte;
                    break;  
#elif SILICONSTUDIO_PLATFORM_ANDROID || !SILICONSTUDIO_PLATFORM_MONO_MOBILE && SILICONSTUDIO_XENKO_GRAPHICS_API_OPENGLES
                // Desktop OpenGLES
                case PixelFormat.ETC1:
                    // TODO: Runtime check for extension?
                    internalFormat = (PixelInternalFormat)OesCompressedEtc1Rgb8Texture.Etc1Rgb8Oes;
                    format = (PixelFormatGl)OesCompressedEtc1Rgb8Texture.Etc1Rgb8Oes;
                    compressed = true;
                    pixelSize = 2;
                    type = PixelType.UnsignedByte;
                    break;
                case PixelFormat.ETC2_RGBA:
                    internalFormat = (PixelInternalFormat)CompressedInternalFormat.CompressedRgba8Etc2Eac;
                    format = (PixelFormatGl)CompressedInternalFormat.CompressedRgba8Etc2Eac;
                    compressed = true;
                    pixelSize = 2;
                    type = PixelType.UnsignedByte;
                    break;
                case PixelFormat.ETC2_RGBA_SRgb:
                    internalFormat = (PixelInternalFormat)CompressedInternalFormat.CompressedSrgb8Alpha8Etc2Eac;
                    format = (PixelFormatGl)CompressedInternalFormat.CompressedSrgb8Alpha8Etc2Eac;
                    compressed = true;
                    pixelSize = 2;
                    type = PixelType.UnsignedByte;
                    break;
#endif
                case PixelFormat.None: // TODO: remove this - this is only for buffers used in compute shaders
                    internalFormat = PixelInternalFormat.Rgba;
                    format = PixelFormatGl.Red;
                    type = PixelType.UnsignedByte;
                    pixelSize = 1;
                    break;
                default:
                    throw new InvalidOperationException("Unsupported texture format");
            }
        }
        public static void ConvertPixelFormat(GraphicsDevice graphicsDevice, PixelFormat inputFormat, out PixelInternalFormat internalFormat, out PixelFormatGl format, out PixelType type, out int pixelSize, out bool compressed)
        {
            compressed = false;

#if SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
            // check formats is the device is initialized with OpenGL ES 2
            if (graphicsDevice.IsOpenGLES2)
            {
                switch (inputFormat)
                {
                    case PixelFormat.R32_UInt:
                    case PixelFormat.R32_Float:
                    case PixelFormat.R32G32_Float:
                    case PixelFormat.R32G32B32_Float:
                    case PixelFormat.R16G16B16A16_Float:
                    case PixelFormat.R32G32B32A32_Float:
                    case PixelFormat.D32_Float:
                        throw new NotSupportedException(String.Format("Texture format {0} not supported", inputFormat));
                    case PixelFormat.D24_UNorm_S8_UInt:
                        if (!(graphicsDevice.HasDepth24 && graphicsDevice.HasPackedDepthStencilExtension))
                            throw new NotSupportedException(String.Format("Texture format {0} not supported", inputFormat));
                        break;
                }
            }
#endif

            switch (inputFormat)
            {
                case PixelFormat.A8_UNorm:
                    internalFormat = PixelInternalFormat.Alpha;
                    format = PixelFormatGl.Alpha;
                    type = PixelType.UnsignedByte;
                    pixelSize = 1;
                    break;
                case PixelFormat.R8_UNorm:
#if SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
                    if (graphicsDevice.IsOpenGLES2)
                    {
                        internalFormat = PixelInternalFormat.Luminance;
                        format = PixelFormatGl.Luminance;
                    }
                    else
#endif
                    {
                        internalFormat = R8;
                        format = PixelFormatGl.Red;
                    }
                    type = PixelType.UnsignedByte;
                    pixelSize = 1;
                    break;
                case PixelFormat.R8G8B8A8_UNorm:
                    internalFormat = PixelInternalFormat.Rgba;
                    format = PixelFormatGl.Rgba;
                    type = PixelType.UnsignedByte;
                    pixelSize = 4;
                    break;
                case PixelFormat.B8G8R8A8_UNorm:
#if SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
                    if (!graphicsDevice.HasExtTextureFormatBGRA8888)
                        throw new NotSupportedException();

                    // It seems iOS and Android expects different things
#if SILICONSTUDIO_PLATFORM_IOS
                    internalFormat = PixelInternalFormat.Rgba;
#else
                    internalFormat = (PixelInternalFormat)ExtTextureFormatBgra8888.BgraExt;
#endif
                    format = (PixelFormatGl)ExtTextureFormatBgra8888.BgraExt;
#else
                    internalFormat = PixelInternalFormat.Rgba;
                    format = PixelFormatGl.Bgra;
#endif
                    type = PixelType.UnsignedByte;
                    pixelSize = 4;
                    break;
                case PixelFormat.R8G8B8A8_UNorm_SRgb:
                    internalFormat = Srgb8Alpha8;
                    format = PixelFormatGl.Rgba;
                    type = PixelType.UnsignedByte;
                    pixelSize = 4;
                    break;
                case PixelFormat.B8G8R8A8_UNorm_SRgb:
                    internalFormat = Srgb8Alpha8;
#if SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
                    format = (PixelFormatGl)ExtTextureFormatBgra8888.BgraExt;
#else
                    format = PixelFormatGl.Bgra;
#endif
                    type = PixelType.UnsignedByte;
                    pixelSize = 4;
                    break;
                case PixelFormat.R16_Float:
                    internalFormat = R16f;
                    format = PixelFormatGl.Red;
                    type = PixelType.HalfFloat;
                    pixelSize = 2;
                    break;
                case PixelFormat.R16G16_Float:
                    internalFormat = Rg16f;
                    format = PixelFormatGl.Rg;
                    type = PixelType.HalfFloat;
                    pixelSize = 4;
                    break;
                case PixelFormat.R16G16B16A16_Float:
                    internalFormat = Rgba16f;
                    format = PixelFormatGl.Rgba;
                    type = PixelType.HalfFloat;
                    pixelSize = 8;
                    break;
                case PixelFormat.R32_UInt:
                    internalFormat = R32ui;
                    format = PixelFormatGl.RedInteger;
                    type = PixelType.UnsignedInt;
                    pixelSize = 4;
                    break;
                case PixelFormat.R32_Float:
                    internalFormat = R32f;
                    format = PixelFormatGl.Red;
                    type = PixelType.Float;
                    pixelSize = 4;
                    break;
                case PixelFormat.R32G32_Float:
                    internalFormat = Rg32f;
                    format = PixelFormatGl.Rg;
                    type = PixelType.Float;
                    pixelSize = 8;
                    break;
                case PixelFormat.R32G32B32_Float:
                    internalFormat = Rgb32f;
                    format = PixelFormatGl.Rgb;
                    type = PixelType.Float;
                    pixelSize = 12;
                    break;
                case PixelFormat.R32G32B32A32_Float:
                    internalFormat = Rgba32f;
                    format = PixelFormatGl.Rgba;
                    type = PixelType.Float;
                    pixelSize = 16;
                    break;
                case PixelFormat.D16_UNorm:
                    internalFormat = DepthComponent16;
                    format = PixelFormatGl.DepthComponent;
                    type = PixelType.UnsignedShort;
                    pixelSize = 2;
                    break;
                case PixelFormat.D24_UNorm_S8_UInt:
                    internalFormat = Depth24Stencil8;
                    format = PixelFormatGl.DepthStencil;
                    type = PixelType.UnsignedInt248;
                    pixelSize = 4;
                    break;
                // TODO: Temporary depth format (need to decide relation between RenderTarget1D and Texture)
                case PixelFormat.D32_Float:
                    internalFormat = DepthComponent32f;
                    format = PixelFormatGl.DepthComponent;
                    type = PixelType.Float;
                    pixelSize = 4;
                    break;
#if SILICONSTUDIO_PLATFORM_IOS
                case PixelFormat.PVRTC_4bpp_RGB:
                    internalFormat = (PixelInternalFormat)ImgTextureCompressionPvrtc.CompressedRgbPvrtc4Bppv1Img;
                    format = (PixelFormatGl)ImgTextureCompressionPvrtc.CompressedRgbPvrtc4Bppv1Img;
                    compressed = true;
                    pixelSize = 4;
                    type = PixelType.UnsignedByte;
                    break;
                case PixelFormat.PVRTC_2bpp_RGB:
                    internalFormat = (PixelInternalFormat)ImgTextureCompressionPvrtc.CompressedRgbPvrtc2Bppv1Img;
                    format = (PixelFormatGl)ImgTextureCompressionPvrtc.CompressedRgbPvrtc2Bppv1Img;
                    compressed = true;
                    pixelSize = 2;
                    type = PixelType.UnsignedByte;
                    break;
                case PixelFormat.PVRTC_4bpp_RGBA:
                    internalFormat = (PixelInternalFormat)ImgTextureCompressionPvrtc.CompressedRgbaPvrtc4Bppv1Img;
                    format = (PixelFormatGl)ImgTextureCompressionPvrtc.CompressedRgbaPvrtc4Bppv1Img;
                    compressed = true;
                    pixelSize = 4;
                    type = PixelType.UnsignedByte;
                    break;
                case PixelFormat.PVRTC_2bpp_RGBA:
                    internalFormat = (PixelInternalFormat)ImgTextureCompressionPvrtc.CompressedRgbaPvrtc2Bppv1Img;
                    format = (PixelFormatGl)ImgTextureCompressionPvrtc.CompressedRgbaPvrtc2Bppv1Img;
                    compressed = true;
                    pixelSize = 2;
                    type = PixelType.UnsignedByte;
                    break;  
#elif SILICONSTUDIO_PLATFORM_ANDROID || !SILICONSTUDIO_PLATFORM_MONO_MOBILE && SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
// Desktop OpenGLES
                case PixelFormat.ETC1:
                    // TODO: Runtime check for extension?
                    internalFormat = (PixelInternalFormat)OesCompressedEtc1Rgb8Texture.Etc1Rgb8Oes;
                    format = (PixelFormatGl)OesCompressedEtc1Rgb8Texture.Etc1Rgb8Oes;
                    compressed = true;
                    pixelSize = 2;
                    type = PixelType.UnsignedByte;
                    break;
                case PixelFormat.ETC2_RGBA:
                    internalFormat = (PixelInternalFormat)CompressedInternalFormat.CompressedRgba8Etc2Eac;
                    format = (PixelFormatGl)CompressedInternalFormat.CompressedRgba8Etc2Eac;
                    compressed = true;
                    pixelSize = 2;
                    type = PixelType.UnsignedByte;
                    break;     
#endif
                case PixelFormat.None: // TODO: remove this - this is only for buffers used in compute shaders
                    internalFormat = PixelInternalFormat.Rgba;
                    format = PixelFormatGl.Red;
                    type = PixelType.UnsignedByte;
                    pixelSize = 1;
                    break;
                default:
                    throw new InvalidOperationException("Unsupported texture format");
            }
        }
示例#7
0
        protected static void ConvertPixelFormat(GraphicsDevice graphicsDevice, PixelFormat inputFormat, out PixelInternalFormat internalFormat, out PixelFormatGl format, out PixelType type, out int pixelSize, out bool compressed)
        {
            compressed = false;

            switch (inputFormat)
            {
            case PixelFormat.R8G8B8A8_UNorm:
                internalFormat = PixelInternalFormat.Rgba;
                format         = PixelFormatGl.Rgba;
                type           = PixelType.UnsignedByte;
                pixelSize      = 4;
                break;

            case PixelFormat.D16_UNorm:
                internalFormat = PixelInternalFormat.Rgba;
                format         = PixelFormatGl.Rgba;
                type           = PixelType.UnsignedByte;
                pixelSize      = 2;
                break;

            case PixelFormat.A8_UNorm:
#if SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
                internalFormat = PixelInternalFormat.Alpha;
                format         = PixelFormatGl.Alpha;
#else
                internalFormat = PixelInternalFormat.R8;
                format         = PixelFormatGl.Red;
#endif
                type      = PixelType.UnsignedByte;
                pixelSize = 1;
                break;

            case PixelFormat.R8_UNorm:
#if SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
                internalFormat = PixelInternalFormat.Luminance;
                format         = PixelFormatGl.Luminance;
#else
                internalFormat = PixelInternalFormat.R8;
                format         = PixelFormatGl.Red;
#endif
                type      = PixelType.UnsignedByte;
                pixelSize = 1;
                break;

            case PixelFormat.B8G8R8A8_UNorm:
#if SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
                if (!graphicsDevice.HasExtTextureFormatBGRA8888)
                {
                    throw new NotSupportedException();
                }

                // It seems iOS and Android expects different things
#if SILICONSTUDIO_PLATFORM_IOS
                internalFormat = PixelInternalFormat.Rgba;
#else
                internalFormat = (PixelInternalFormat)ExtTextureFormatBgra8888.BgraExt;
#endif
                format = (PixelFormatGl)ExtTextureFormatBgra8888.BgraExt;
#else
                internalFormat = PixelInternalFormat.Rgba;
                format         = PixelFormatGl.Bgra;
#endif
                type      = PixelType.UnsignedByte;
                pixelSize = 4;
                break;

#if !SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
            case PixelFormat.R32_UInt:
                internalFormat = PixelInternalFormat.R32ui;
                format         = PixelFormatGl.RedInteger;
                type           = PixelType.UnsignedInt;
                pixelSize      = 4;
                break;

            case PixelFormat.R16G16B16A16_Float:
                internalFormat = PixelInternalFormat.Rgba16f;
                format         = PixelFormatGl.Rgba;
                type           = PixelType.HalfFloat;
                pixelSize      = 8;
                break;

            case PixelFormat.R32_Float:
                internalFormat = PixelInternalFormat.R32f;
                format         = PixelFormatGl.Red;
                type           = PixelType.Float;
                pixelSize      = 4;
                break;

            case PixelFormat.R32G32_Float:
                internalFormat = PixelInternalFormat.Rg32f;
                format         = PixelFormatGl.Rg;
                type           = PixelType.Float;
                pixelSize      = 8;
                break;

            case PixelFormat.R32G32B32_Float:
                internalFormat = PixelInternalFormat.Rgb32f;
                format         = PixelFormatGl.Rgb;
                type           = PixelType.Float;
                pixelSize      = 12;
                break;

            case PixelFormat.R32G32B32A32_Float:
                internalFormat = PixelInternalFormat.Rgba32f;
                format         = PixelFormatGl.Rgba;
                type           = PixelType.Float;
                pixelSize      = 16;
                break;

            // TODO: Temporary depth format (need to decide relation between RenderTarget1D and Texture1D)
            case (PixelFormat)40:
                internalFormat = PixelInternalFormat.DepthComponent32f;
                format         = PixelFormatGl.DepthComponent;
                type           = PixelType.Float;
                pixelSize      = 4;
                break;
#endif
#if SILICONSTUDIO_PLATFORM_ANDROID
            case PixelFormat.ETC1:
                // TODO: Runtime check for extension?
                internalFormat = (PixelInternalFormat)OesCompressedEtc1Rgb8Texture.Etc1Rgb8Oes;
                format         = (PixelFormatGl)OesCompressedEtc1Rgb8Texture.Etc1Rgb8Oes;
                compressed     = true;
                pixelSize      = 2;
                type           = PixelType.UnsignedByte;
                break;
#elif SILICONSTUDIO_PLATFORM_IOS
            case PixelFormat.PVRTC_4bpp_RGB:
                internalFormat = (PixelInternalFormat)ImgTextureCompressionPvrtc.CompressedRgbPvrtc4Bppv1Img;
                format         = (PixelFormatGl)ImgTextureCompressionPvrtc.CompressedRgbPvrtc4Bppv1Img;
                compressed     = true;
                pixelSize      = 4;
                type           = PixelType.UnsignedByte;
                break;

            case PixelFormat.PVRTC_2bpp_RGB:
                internalFormat = (PixelInternalFormat)ImgTextureCompressionPvrtc.CompressedRgbPvrtc2Bppv1Img;
                format         = (PixelFormatGl)ImgTextureCompressionPvrtc.CompressedRgbPvrtc2Bppv1Img;
                compressed     = true;
                pixelSize      = 2;
                type           = PixelType.UnsignedByte;
                break;

            case PixelFormat.PVRTC_4bpp_RGBA:
                internalFormat = (PixelInternalFormat)ImgTextureCompressionPvrtc.CompressedRgbaPvrtc4Bppv1Img;
                format         = (PixelFormatGl)ImgTextureCompressionPvrtc.CompressedRgbaPvrtc4Bppv1Img;
                compressed     = true;
                pixelSize      = 4;
                type           = PixelType.UnsignedByte;
                break;

            case PixelFormat.PVRTC_2bpp_RGBA:
                internalFormat = (PixelInternalFormat)ImgTextureCompressionPvrtc.CompressedRgbaPvrtc2Bppv1Img;
                format         = (PixelFormatGl)ImgTextureCompressionPvrtc.CompressedRgbaPvrtc2Bppv1Img;
                compressed     = true;
                pixelSize      = 2;
                type           = PixelType.UnsignedByte;
                break;
#endif
            default:
                throw new InvalidOperationException("Unsupported texture format");
            }
        }
        public static void ConvertPixelFormat(GraphicsDevice graphicsDevice, ref PixelFormat inputFormat, out PixelInternalFormat internalFormat, out PixelFormatGl format, out PixelType type,
            out int pixelSize, out bool compressed)
        {
            compressed = false;

#if SILICONSTUDIO_XENKO_GRAPHICS_API_OPENGLES
            // check formats more carefully if the device is initialized with OpenGL ES 2
            if (graphicsDevice.currentVersion < 300)
            {
                switch (inputFormat)
                {
                    case PixelFormat.R16_Float:
                    case PixelFormat.R16G16_Float:
                        if (!graphicsDevice.HasTextureRG || !graphicsDevice.HasTextureHalf)
                            goto unsupported;
                        break;
                    case PixelFormat.R16G16B16A16_Float:
                        if (!graphicsDevice.HasTextureHalf)
                            goto unsupported;
                        break;
                    case PixelFormat.R16_UInt:
                    case PixelFormat.R16_SInt:
                    case PixelFormat.R16G16_UInt:
                    case PixelFormat.R16G16_SInt:
                    case PixelFormat.R16G16B16A16_UInt:
                    case PixelFormat.R16G16B16A16_SInt:
                        goto unsupported;
                    case PixelFormat.R32_Float:
                    case PixelFormat.R32G32_Float:
                    case PixelFormat.R32G32B32_Float:
                        if (!graphicsDevice.HasTextureRG || !graphicsDevice.HasTextureFloat)
                            goto unsupported;
                        break;
                    case PixelFormat.R32G32B32A32_Float:
                        if (!graphicsDevice.HasTextureFloat)
                            goto unsupported;
                        break;
                    case PixelFormat.R32_UInt:
                    case PixelFormat.R32_SInt:
                    case PixelFormat.R32G32_UInt:
                    case PixelFormat.R32G32_SInt:
                    case PixelFormat.R32G32B32_UInt:
                    case PixelFormat.R32G32B32_SInt:
                    case PixelFormat.R32G32B32A32_UInt:
                    case PixelFormat.R32G32B32A32_SInt:
                        goto unsupported;
                    case PixelFormat.D32_Float:
                        goto unsupported;
                    unsupported:
                        throw new NotSupportedException($"Texture format {inputFormat} not supported with OpenGL ES 2.0");

                    // NOTE: We always allow PixelFormat.D24_UNorm_S8_UInt.
                    // If it is not supported we will fall back to separate D24/D16 and S8 resources when creating a texture.
                }
            }
#endif

            // If the Device doesn't support SRGB, we remap automatically the format to non-srgb
            if (!graphicsDevice.Features.HasSRgb)
            {
                switch (inputFormat)
                {
                    case PixelFormat.PVRTC_2bpp_RGB_SRgb:
                        inputFormat = PixelFormat.PVRTC_2bpp_RGB;
                        break;
                    case PixelFormat.PVRTC_2bpp_RGBA_SRgb:
                        inputFormat = PixelFormat.PVRTC_2bpp_RGBA;
                        break;
                    case PixelFormat.PVRTC_4bpp_RGB_SRgb:
                        inputFormat = PixelFormat.PVRTC_4bpp_RGB;
                        break;
                    case PixelFormat.PVRTC_4bpp_RGBA_SRgb:
                        inputFormat = PixelFormat.PVRTC_4bpp_RGBA;
                        break;
                    case PixelFormat.ETC2_RGB_SRgb:
                        inputFormat = PixelFormat.ETC2_RGB;
                        break;
                    case PixelFormat.ETC2_RGBA_SRgb:
                        inputFormat = PixelFormat.ETC2_RGBA;
                        break;
                    case PixelFormat.R8G8B8A8_UNorm_SRgb:
                        inputFormat = PixelFormat.R8G8B8A8_UNorm;
                        break;
                    case PixelFormat.B8G8R8A8_UNorm_SRgb:
                        inputFormat = PixelFormat.B8G8R8A8_UNorm;
                        break;
                }
            }

            switch (inputFormat)
            {
                case PixelFormat.A8_UNorm:
                    internalFormat = PixelInternalFormat.Alpha;
                    format = PixelFormatGl.Alpha;
                    type = PixelType.UnsignedByte;
                    pixelSize = 1;
                    break;
                case PixelFormat.R8_UNorm:
#if SILICONSTUDIO_XENKO_GRAPHICS_API_OPENGLES
                    if (!graphicsDevice.HasTextureRG && graphicsDevice.currentVersion < 300)
                    {
                        internalFormat = PixelInternalFormat.Luminance;
                        format = PixelFormatGl.Luminance;
                    }
                    else
#endif
                    {
                        internalFormat = PixelInternalFormat.R8;
                        format = PixelFormatGl.Red;
                    }
                    type = PixelType.UnsignedByte;
                    pixelSize = 1;
                    break;
                case PixelFormat.R8G8B8A8_UNorm:
                    internalFormat = PixelInternalFormat.Rgba;
                    format = PixelFormatGl.Rgba;
                    type = PixelType.UnsignedByte;
                    pixelSize = 4;
                    break;
                case PixelFormat.B8G8R8A8_UNorm:
#if SILICONSTUDIO_XENKO_GRAPHICS_API_OPENGLES
                    if (!graphicsDevice.HasExtTextureFormatBGRA8888)
                        throw new NotSupportedException();

                    // It seems iOS and Android expects different things
#if SILICONSTUDIO_PLATFORM_IOS
                    internalFormat = PixelInternalFormat.Rgba;
#else
                    internalFormat = (PixelInternalFormat)ExtTextureFormatBgra8888.BgraExt;
#endif
                    format = (PixelFormatGl)ExtTextureFormatBgra8888.BgraExt;
#else
                    internalFormat = PixelInternalFormat.Rgba;
                    format = PixelFormatGl.Bgra;
#endif
                    type = PixelType.UnsignedByte;
                    pixelSize = 4;
                    break;
                case PixelFormat.R8G8B8A8_UNorm_SRgb:
                    internalFormat = PixelInternalFormat.Srgb8Alpha8;
                    format = PixelFormatGl.Rgba;
                    type = PixelType.UnsignedByte;
                    pixelSize = 4;
                    break;
#if SILICONSTUDIO_XENKO_GRAPHICS_API_OPENGLCORE
                case PixelFormat.B8G8R8A8_UNorm_SRgb:
                    // TODO: Check on iOS/Android and OpenGL 3
                    internalFormat = PixelInternalFormat.Srgb8Alpha8;
                    format = PixelFormatGl.Bgra;
                    type = PixelType.UnsignedByte;
                    pixelSize = 4;
                    break;
                case PixelFormat.BC1_UNorm:
                    if (!graphicsDevice.HasDXT)
                        throw new NotSupportedException();
                    internalFormat = PixelInternalFormat.CompressedRgbaS3tcDxt1Ext;
                    format = (PixelFormatGl)PixelInternalFormat.CompressedRgbaS3tcDxt1Ext;
                    pixelSize = 4;
                    type = PixelType.UnsignedByte;
                    compressed = true;
                    break;
                case PixelFormat.BC1_UNorm_SRgb:
                    if (!graphicsDevice.HasDXT)
                        throw new NotSupportedException();
                    internalFormat = PixelInternalFormat.CompressedSrgbAlphaS3tcDxt1Ext;
                    format = (PixelFormatGl)PixelInternalFormat.CompressedSrgbAlphaS3tcDxt1Ext;
                    pixelSize = 4;
                    type = PixelType.UnsignedByte;
                    compressed = true;
                    break;
                case PixelFormat.BC2_UNorm:
                    if (!graphicsDevice.HasDXT)
                        throw new NotSupportedException();
                    internalFormat = PixelInternalFormat.CompressedRgbaS3tcDxt3Ext;
                    format = (PixelFormatGl)PixelInternalFormat.CompressedRgbaS3tcDxt3Ext;
                    pixelSize = 4;
                    type = PixelType.UnsignedByte;
                    compressed = true;
                    break;
                case PixelFormat.BC2_UNorm_SRgb:
                    if (!graphicsDevice.HasDXT)
                        throw new NotSupportedException();
                    internalFormat = PixelInternalFormat.CompressedSrgbAlphaS3tcDxt3Ext;
                    format = (PixelFormatGl)PixelInternalFormat.CompressedSrgbAlphaS3tcDxt3Ext;
                    pixelSize = 4;
                    type = PixelType.UnsignedByte;
                    compressed = true;
                    break;
                case PixelFormat.BC3_UNorm:
                    if (!graphicsDevice.HasDXT)
                        throw new NotSupportedException();
                    internalFormat = PixelInternalFormat.CompressedRgbaS3tcDxt5Ext;
                    format = (PixelFormatGl)PixelInternalFormat.CompressedRgbaS3tcDxt5Ext;
                    pixelSize = 4;
                    type = PixelType.UnsignedByte;
                    compressed = true;
                    break;
                case PixelFormat.BC3_UNorm_SRgb:
                    if (!graphicsDevice.HasDXT)
                        throw new NotSupportedException();
                    internalFormat = PixelInternalFormat.CompressedSrgbAlphaS3tcDxt5Ext;
                    format = (PixelFormatGl)PixelInternalFormat.CompressedSrgbAlphaS3tcDxt5Ext;
                    pixelSize = 4;
                    type = PixelType.UnsignedByte;
                    compressed = true;
                    break;
#endif
                case PixelFormat.R16_Float:
                    internalFormat = PixelInternalFormat.R16f;
                    format = PixelFormatGl.Red;
                    type = PixelType.HalfFloat;
                    pixelSize = 2;
                    break;
                case PixelFormat.R16G16_Float:
                    internalFormat = PixelInternalFormat.Rg16f;
                    format = PixelFormatGl.Rg;
                    type = PixelType.HalfFloat;
                    pixelSize = 4;
                    break;
                case PixelFormat.R16G16B16A16_Float:
                    internalFormat = PixelInternalFormat.Rgba16f;
                    format = PixelFormatGl.Rgba;
                    type = PixelType.HalfFloat;
                    pixelSize = 8;
                    break;
                case PixelFormat.R32_SInt:
                    internalFormat = PixelInternalFormat.R32i;
                    format = PixelFormatGl.RedInteger;
                    type = PixelType.Int;
                    pixelSize = 4;
                    break;
                case PixelFormat.R32_UInt:
                    internalFormat = PixelInternalFormat.R32ui;
                    format = PixelFormatGl.RedInteger;
                    type = PixelType.UnsignedInt;
                    pixelSize = 4;
                    break;
                case PixelFormat.R32_Float:
                    internalFormat = PixelInternalFormat.R32f;
                    format = PixelFormatGl.Red;
                    type = PixelType.Float;
                    pixelSize = 4;
                    break;
                case PixelFormat.R32G32_SInt:
                    internalFormat = PixelInternalFormat.Rg32i;
                    format = PixelFormatGl.RgInteger;
                    type = PixelType.Int;
                    pixelSize = 8;
                    break;
                case PixelFormat.R32G32_UInt:
                    internalFormat = PixelInternalFormat.Rg32ui;
                    format = PixelFormatGl.RgInteger;
                    type = PixelType.UnsignedInt;
                    pixelSize = 8;
                    break;
                case PixelFormat.R32G32_Float:
                    internalFormat = PixelInternalFormat.Rg32f;
                    format = PixelFormatGl.Rg;
                    type = PixelType.Float;
                    pixelSize = 8;
                    break;
                case PixelFormat.R32G32B32_SInt:
                    internalFormat = PixelInternalFormat.Rgb32i;
                    format = PixelFormatGl.RgbInteger;
                    type = PixelType.Int;
                    pixelSize = 12;
                    break;
                case PixelFormat.R32G32B32_UInt:
                    internalFormat = PixelInternalFormat.Rgb32ui;
                    format = PixelFormatGl.RgbInteger;
                    type = PixelType.UnsignedInt;
                    pixelSize = 12;
                    break;
                case PixelFormat.R32G32B32_Float:
                    internalFormat = PixelInternalFormat.Rgb32f;
                    format = PixelFormatGl.Rgb;
                    type = PixelType.Float;
                    pixelSize = 12;
                    break;
                case PixelFormat.R32G32B32A32_SInt:
                    internalFormat = PixelInternalFormat.Rgba32i;
                    format = PixelFormatGl.RgbaInteger;
                    type = PixelType.Int;
                    pixelSize = 16;
                    break;
                case PixelFormat.R32G32B32A32_UInt:
                    internalFormat = PixelInternalFormat.Rgba32ui;
                    format = PixelFormatGl.RgbaInteger;
                    type = PixelType.UnsignedInt;
                    pixelSize = 16;
                    break;
                case PixelFormat.R32G32B32A32_Float:
                    internalFormat = PixelInternalFormat.Rgba32f;
                    format = PixelFormatGl.Rgba;
                    type = PixelType.Float;
                    pixelSize = 16;
                    break;
                case PixelFormat.D16_UNorm:
                    internalFormat = PixelInternalFormat.DepthComponent16;
                    format = PixelFormatGl.DepthComponent;
                    type = PixelType.UnsignedShort;
                    pixelSize = 2;
                    break;
                case PixelFormat.D24_UNorm_S8_UInt:
                    internalFormat = PixelInternalFormat.Depth24Stencil8;
                    format = PixelFormatGl.DepthStencil;
                    type = PixelType.UnsignedInt248;
                    pixelSize = 4;
                    break;
                // TODO: Temporary depth format (need to decide relation between RenderTarget1D and Texture)
                case PixelFormat.D32_Float:
                    internalFormat = PixelInternalFormat.DepthComponent32f;
                    format = PixelFormatGl.DepthComponent;
                    type = PixelType.Float;
                    pixelSize = 4;
                    break;
#if SILICONSTUDIO_PLATFORM_IOS
                case PixelFormat.PVRTC_4bpp_RGB:
                    internalFormat = (PixelInternalFormat)ImgTextureCompressionPvrtc.CompressedRgbPvrtc4Bppv1Img;
                    format = (PixelFormatGl)ImgTextureCompressionPvrtc.CompressedRgbPvrtc4Bppv1Img;
                    compressed = true;
                    pixelSize = 4;
                    type = PixelType.UnsignedByte;
                    break;
                case PixelFormat.PVRTC_2bpp_RGB:
                    internalFormat = (PixelInternalFormat)ImgTextureCompressionPvrtc.CompressedRgbPvrtc2Bppv1Img;
                    format = (PixelFormatGl)ImgTextureCompressionPvrtc.CompressedRgbPvrtc2Bppv1Img;
                    compressed = true;
                    pixelSize = 2;
                    type = PixelType.UnsignedByte;
                    break;
                case PixelFormat.PVRTC_4bpp_RGBA:
                    internalFormat = (PixelInternalFormat)ImgTextureCompressionPvrtc.CompressedRgbaPvrtc4Bppv1Img;
                    format = (PixelFormatGl)ImgTextureCompressionPvrtc.CompressedRgbaPvrtc4Bppv1Img;
                    compressed = true;
                    pixelSize = 4;
                    type = PixelType.UnsignedByte;
                    break;
                case PixelFormat.PVRTC_2bpp_RGBA:
                    internalFormat = (PixelInternalFormat)ImgTextureCompressionPvrtc.CompressedRgbaPvrtc2Bppv1Img;
                    format = (PixelFormatGl)ImgTextureCompressionPvrtc.CompressedRgbaPvrtc2Bppv1Img;
                    compressed = true;
                    pixelSize = 2;
                    type = PixelType.UnsignedByte;
                    break;
                case PixelFormat.PVRTC_4bpp_RGB_SRgb:
                    internalFormat = (PixelInternalFormat)ExtPvrtcSrgb.CompressedSrgbPvrtc4Bppv1Ext;
                    format = (PixelFormatGl)ExtPvrtcSrgb.CompressedSrgbPvrtc4Bppv1Ext;
                    compressed = true;
                    pixelSize = 4;
                    type = PixelType.UnsignedByte;
                    break;
                case PixelFormat.PVRTC_2bpp_RGB_SRgb:
                    internalFormat = (PixelInternalFormat)ExtPvrtcSrgb.CompressedSrgbPvrtc2Bppv1Ext;
                    format = (PixelFormatGl)ExtPvrtcSrgb.CompressedSrgbPvrtc2Bppv1Ext;
                    compressed = true;
                    pixelSize = 2;
                    type = PixelType.UnsignedByte;
                    break;
                case PixelFormat.PVRTC_4bpp_RGBA_SRgb:
                    internalFormat = (PixelInternalFormat)ExtPvrtcSrgb.CompressedSrgbAlphaPvrtc4Bppv1Ext;
                    format = (PixelFormatGl)ExtPvrtcSrgb.CompressedSrgbAlphaPvrtc4Bppv1Ext;
                    compressed = true;
                    pixelSize = 4;
                    type = PixelType.UnsignedByte;
                    break;
                case PixelFormat.PVRTC_2bpp_RGBA_SRgb:
                    internalFormat = (PixelInternalFormat)ExtPvrtcSrgb.CompressedSrgbAlphaPvrtc2Bppv1Ext;
                    format = (PixelFormatGl)ExtPvrtcSrgb.CompressedSrgbAlphaPvrtc2Bppv1Ext;
                    compressed = true;
                    pixelSize = 2;
                    type = PixelType.UnsignedByte;
                    break;
#elif SILICONSTUDIO_XENKO_GRAPHICS_API_OPENGLES
                // Desktop OpenGLES
                case PixelFormat.ETC1:
                    // TODO: Runtime check for extension?
                    internalFormat = (PixelInternalFormat)OesCompressedEtc1Rgb8Texture.Etc1Rgb8Oes;
                    format = (PixelFormatGl)OesCompressedEtc1Rgb8Texture.Etc1Rgb8Oes;
                    compressed = true;
                    pixelSize = 2;
                    type = PixelType.UnsignedByte;
                    break;
                case PixelFormat.ETC2_RGBA:
                    internalFormat = (PixelInternalFormat)CompressedInternalFormat.CompressedRgba8Etc2Eac;
                    format = (PixelFormatGl)CompressedInternalFormat.CompressedRgba8Etc2Eac;
                    compressed = true;
                    pixelSize = 2;
                    type = PixelType.UnsignedByte;
                    break;
                case PixelFormat.ETC2_RGBA_SRgb:
                    internalFormat = (PixelInternalFormat)CompressedInternalFormat.CompressedSrgb8Alpha8Etc2Eac;
                    format = (PixelFormatGl)CompressedInternalFormat.CompressedSrgb8Alpha8Etc2Eac;
                    compressed = true;
                    pixelSize = 2;
                    type = PixelType.UnsignedByte;
                    break;
#endif
                case PixelFormat.None: // TODO: remove this - this is only for buffers used in compute shaders
                    internalFormat = PixelInternalFormat.Rgba;
                    format = PixelFormatGl.Red;
                    type = PixelType.UnsignedByte;
                    pixelSize = 1;
                    break;
                default:
                    throw new InvalidOperationException("Unsupported texture format: " + inputFormat);
            }

#if SILICONSTUDIO_XENKO_GRAPHICS_API_OPENGLES
            // override some formats for ES2.0
            if (graphicsDevice.currentVersion < 300)
            {
                switch (inputFormat)
                {
                    case PixelFormat.R8G8B8A8_UNorm_SRgb:
                        // HasSRgb was true because we have GL_EXT_sRGB
                        // Note: Qualcomm Adreno 4xx fails to use GL_EXT_sRGB with FBO,
                        // but they will report a currentVersion >= 300 (ES 3.0) anyway
                        internalFormat = (PixelInternalFormat)ExtSrgb.SrgbAlphaExt;
                        format = (PixelFormatGl)ExtSrgb.SrgbAlphaExt;
                        break;
                    case PixelFormat.R8_UNorm:
                    case PixelFormat.R8_SNorm:
                    case PixelFormat.R8_UInt:
                    case PixelFormat.R8_SInt:
                    case PixelFormat.R16_Float:
                    case PixelFormat.R16_UNorm:
                    case PixelFormat.R16_SNorm:
                    case PixelFormat.R16_UInt:
                    case PixelFormat.R16_SInt:
                    case PixelFormat.R32_Float:
                    case PixelFormat.R32_UInt:
                    case PixelFormat.R32_SInt:
                        if (inputFormat == PixelFormat.R16_Float)
                            type = (PixelType)OesTextureHalfFloat.HalfFloatOes;
                        if (graphicsDevice.HasTextureRG)
                            internalFormat = (PixelInternalFormat)ExtTextureRg.RedExt;
                        break;
                    case PixelFormat.R16G16_Float:
                    case PixelFormat.R16G16_UNorm:
                    case PixelFormat.R16G16_SNorm:
                    case PixelFormat.R16G16_UInt:
                    case PixelFormat.R16G16_SInt:
                    case PixelFormat.R32G32_Float:
                    case PixelFormat.R32G32_UInt:
                    case PixelFormat.R32G32_SInt:
                        if (inputFormat == PixelFormat.R16G16_Float)
                            type = (PixelType)OesTextureHalfFloat.HalfFloatOes;
                        if (graphicsDevice.HasTextureRG)
                            internalFormat = (PixelInternalFormat)ExtTextureRg.RgExt;
                        break;
                    case PixelFormat.R32G32B32_Float:
                    case PixelFormat.R32G32B32_UInt:
                    case PixelFormat.R32G32B32_SInt:
                        internalFormat = PixelInternalFormat.Rgb;
                        break;
                    case PixelFormat.R16G16B16A16_Float:
                    case PixelFormat.R32G32B32A32_Float:
                    case PixelFormat.R16G16B16A16_UInt:
                    case PixelFormat.R32G32B32A32_UInt:
                    case PixelFormat.R16G16B16A16_SInt:
                    case PixelFormat.R32G32B32A32_SInt:
                        if (inputFormat == PixelFormat.R16G16B16A16_Float)
                            type = (PixelType)OesTextureHalfFloat.HalfFloatOes;
                        internalFormat = PixelInternalFormat.Rgba;
                        break;
                }
            }
#endif
        }