コード例 #1
0
ファイル: PvrttTexLib.cs プロジェクト: glepag1/stride
        /// <summary>
        /// Retrieves the native format from the PixelFormat.
        /// </summary>
        /// <param name="format">The format.</param>
        /// <returns></returns>
        /// <exception cref="TexLibraryException">UnHandled compression format by PowerVC Texture Tool.</exception>
        private UInt64 RetrieveNativeFormat(Xenko.Graphics.PixelFormat format)
        {
            switch (format)
            {
            case Xenko.Graphics.PixelFormat.ETC1:
                return(6);

            case Xenko.Graphics.PixelFormat.ETC2_RGB:
            case Xenko.Graphics.PixelFormat.ETC2_RGB_SRgb:
                return(22);

            case Xenko.Graphics.PixelFormat.ETC2_RGBA:
            case Xenko.Graphics.PixelFormat.ETC2_RGBA_SRgb:
                return(23);

            case Xenko.Graphics.PixelFormat.ETC2_RGB_A1:
                return(24);

            case Xenko.Graphics.PixelFormat.EAC_R11_Unsigned:
                return(25);

            case Xenko.Graphics.PixelFormat.EAC_R11_Signed:
                return(26);

            case Xenko.Graphics.PixelFormat.EAC_RG11_Unsigned:
                return(27);

            case Xenko.Graphics.PixelFormat.EAC_RG11_Signed:
                return(28);

            case Xenko.Graphics.PixelFormat.R32G32B32A32_Float:
            case Xenko.Graphics.PixelFormat.R32G32B32_Float:
            case Xenko.Graphics.PixelFormat.R32G32B32A32_UInt:
            case Xenko.Graphics.PixelFormat.R32G32B32_UInt:
            case Xenko.Graphics.PixelFormat.R32G32B32A32_SInt:
            case Xenko.Graphics.PixelFormat.R32G32B32_SInt:
                return(Utilities.ConvertPixelType(PixelType.Standard32PixelType));

            case Xenko.Graphics.PixelFormat.R16G16B16A16_UNorm:
            case Xenko.Graphics.PixelFormat.R16G16B16A16_UInt:
            case Xenko.Graphics.PixelFormat.R16G16B16A16_SNorm:
            case Xenko.Graphics.PixelFormat.R16G16B16A16_SInt:
                return(Utilities.ConvertPixelType(PixelType.Standard16PixelType));

            case Xenko.Graphics.PixelFormat.R8G8B8A8_UNorm_SRgb:
            case Xenko.Graphics.PixelFormat.R8G8B8A8_UNorm:
            case Xenko.Graphics.PixelFormat.R8G8B8A8_UInt:
            case Xenko.Graphics.PixelFormat.R8G8B8A8_SNorm:
            case Xenko.Graphics.PixelFormat.R8G8B8A8_SInt:
                return(Utilities.ConvertPixelType(PixelType.Standard8PixelType));

            default:
                Log.Error("UnHandled compression format by PowerVC Texture Tool.");
                throw new TextureToolsException("UnHandled compression format by PowerVC Texture Tool.");
            }
        }
コード例 #2
0
    private bool NeedToRecreateTexture(Xenko.Graphics.Texture tex, Vector3 dim, Xenko.Graphics.PixelFormat pixelFormat, MultisampleCount samples)
    {
        if (tex == null || !TextureDimensionsEqual(tex, dim) || tex.Format != pixelFormat || tex.MultisampleCount != samples)
        {
            if (tex != null)
            {
                tex.Dispose();
            }

            return(true);
        }
        return(false);
    }
コード例 #3
0
ファイル: AtitcTexLibrary.cs プロジェクト: Beefr/xenko-wd
        /// <summary>
        /// Determines whether this requested format is supported.
        /// </summary>
        /// <param name="format">The format.</param>
        /// <returns>
        ///     <c>true</c> if the formats is supported; otherwise, <c>false</c>.
        /// </returns>
        public bool SupportFormat(Xenko.Graphics.PixelFormat format)
        {
            switch (format)
            {
            case Xenko.Graphics.PixelFormat.R8G8B8A8_UNorm:
            case Xenko.Graphics.PixelFormat.B8G8R8A8_UNorm:
            case Xenko.Graphics.PixelFormat.ATC_RGB:
            case Xenko.Graphics.PixelFormat.ATC_RGBA_Explicit:
            case Xenko.Graphics.PixelFormat.ATC_RGBA_Interpolated:
                return(true);

            default:
                return(false);
            }
        }
コード例 #4
0
        private EPVRTVariableType RetrieveNativePixelType(Xenko.Graphics.PixelFormat format)
        {
            switch (format)
            {
            case Xenko.Graphics.PixelFormat.R32G32B32A32_Float:
            case Xenko.Graphics.PixelFormat.R32G32B32_Float:
                return(EPVRTVariableType.ePVRTVarTypeFloat);

            //case Xenko.Framework.Graphics.PixelFormat.R16G16B16A16_Float:

            case Xenko.Graphics.PixelFormat.R32G32B32A32_UInt:
            case Xenko.Graphics.PixelFormat.R32G32B32_UInt:
                return(EPVRTVariableType.ePVRTVarTypeUnsignedInteger);

            case Xenko.Graphics.PixelFormat.R32G32B32A32_SInt:
            case Xenko.Graphics.PixelFormat.R32G32B32_SInt:
                return(EPVRTVariableType.ePVRTVarTypeSignedInteger);

            case Xenko.Graphics.PixelFormat.R16G16B16A16_UNorm:
                return(EPVRTVariableType.ePVRTVarTypeUnsignedShortNorm);

            case Xenko.Graphics.PixelFormat.R16G16B16A16_UInt:
                return(EPVRTVariableType.ePVRTVarTypeUnsignedShort);

            case Xenko.Graphics.PixelFormat.R16G16B16A16_SNorm:
                return(EPVRTVariableType.ePVRTVarTypeSignedShortNorm);

            case Xenko.Graphics.PixelFormat.R16G16B16A16_SInt:
                return(EPVRTVariableType.ePVRTVarTypeSignedShort);


            case Xenko.Graphics.PixelFormat.R8G8B8A8_UNorm_SRgb:
            case Xenko.Graphics.PixelFormat.R8G8B8A8_UNorm:
                return(EPVRTVariableType.ePVRTVarTypeUnsignedByteNorm);

            case Xenko.Graphics.PixelFormat.R8G8B8A8_UInt:
                return(EPVRTVariableType.ePVRTVarTypeUnsignedByte);

            case Xenko.Graphics.PixelFormat.R8G8B8A8_SNorm:
                return(EPVRTVariableType.ePVRTVarTypeSignedByteNorm);

            case Xenko.Graphics.PixelFormat.R8G8B8A8_SInt:
                return(EPVRTVariableType.ePVRTVarTypeSignedByte);

            default:
                return(EPVRTVariableType.ePVRTVarTypeUnsignedByteNorm);
            }
        }
コード例 #5
0
        /// <summary>
        /// Determines whether the specified compression format is supported by this library
        /// </summary>
        /// <param name="format">The format.</param>
        /// <returns>
        ///     <c>true</c> if the formats is supported by this library; otherwise, <c>false</c>.
        /// </returns>
        private bool SupportFormat(Xenko.Graphics.PixelFormat format)
        {
            switch (format)
            {
            case Xenko.Graphics.PixelFormat.R32G32B32A32_Float:
            case Xenko.Graphics.PixelFormat.R32G32B32_Float:
            case Xenko.Graphics.PixelFormat.R32G32B32A32_UInt:
            case Xenko.Graphics.PixelFormat.R32G32B32_UInt:
            case Xenko.Graphics.PixelFormat.R32G32B32A32_SInt:
            case Xenko.Graphics.PixelFormat.R32G32B32_SInt:
            case Xenko.Graphics.PixelFormat.R16G16B16A16_UNorm:
            case Xenko.Graphics.PixelFormat.R16G16B16A16_UInt:
            case Xenko.Graphics.PixelFormat.R16G16B16A16_SNorm:
            case Xenko.Graphics.PixelFormat.R16G16B16A16_SInt:
            case Xenko.Graphics.PixelFormat.R8G8B8A8_UNorm_SRgb:
            case Xenko.Graphics.PixelFormat.R8G8B8A8_UNorm:
            case Xenko.Graphics.PixelFormat.R8G8B8A8_UInt:
            case Xenko.Graphics.PixelFormat.R8G8B8A8_SNorm:
            case Xenko.Graphics.PixelFormat.R8G8B8A8_SInt:
            case Xenko.Graphics.PixelFormat.B8G8R8A8_UNorm_SRgb:
            case Xenko.Graphics.PixelFormat.B8G8R8A8_UNorm:

            case Xenko.Graphics.PixelFormat.PVRTC_2bpp_RGB:
            case Xenko.Graphics.PixelFormat.PVRTC_2bpp_RGBA:
            case Xenko.Graphics.PixelFormat.PVRTC_4bpp_RGB:
            case Xenko.Graphics.PixelFormat.PVRTC_4bpp_RGBA:
            case Xenko.Graphics.PixelFormat.PVRTC_II_2bpp:
            case Xenko.Graphics.PixelFormat.PVRTC_II_4bpp:
            case Xenko.Graphics.PixelFormat.PVRTC_2bpp_RGB_SRgb:
            case Xenko.Graphics.PixelFormat.PVRTC_2bpp_RGBA_SRgb:
            case Xenko.Graphics.PixelFormat.PVRTC_4bpp_RGB_SRgb:
            case Xenko.Graphics.PixelFormat.PVRTC_4bpp_RGBA_SRgb:
            case Xenko.Graphics.PixelFormat.ETC1:
            case Xenko.Graphics.PixelFormat.ETC2_RGB:
            case Xenko.Graphics.PixelFormat.ETC2_RGB_SRgb:
            case Xenko.Graphics.PixelFormat.ETC2_RGBA:
            case Xenko.Graphics.PixelFormat.ETC2_RGBA_SRgb:
            case Xenko.Graphics.PixelFormat.ETC2_RGB_A1:
            case Xenko.Graphics.PixelFormat.EAC_R11_Unsigned:
            case Xenko.Graphics.PixelFormat.EAC_R11_Signed:
            case Xenko.Graphics.PixelFormat.EAC_RG11_Unsigned:
            case Xenko.Graphics.PixelFormat.EAC_RG11_Signed:
                return(true);

            default:
                return(false);
            }
        }
コード例 #6
0
ファイル: AtitcTexLibrary.cs プロジェクト: Beefr/xenko-wd
        /// <summary>
        /// Retrieves the native format from <see cref="Xenko.Graphics.PixelFormat"/>.
        /// </summary>
        /// <param name="format">The format.</param>
        /// <returns>the corresponding <see cref="Format"/> format</returns>
        private Format RetrieveNativeFormat(Xenko.Graphics.PixelFormat format)
        {
            switch (format)
            {
            case Xenko.Graphics.PixelFormat.R8G8B8A8_UNorm:
            case Xenko.Graphics.PixelFormat.B8G8R8A8_UNorm:
                return(Format.ATI_TC_FORMAT_ARGB_8888);

            case Xenko.Graphics.PixelFormat.ATC_RGB:
                return(Format.ATI_TC_FORMAT_ATC_RGB);

            case Xenko.Graphics.PixelFormat.ATC_RGBA_Explicit:
                return(Format.ATI_TC_FORMAT_ATC_RGBA_Explicit);

            case Xenko.Graphics.PixelFormat.ATC_RGBA_Interpolated:
                return(Format.ATI_TC_FORMAT_ATC_RGBA_Interpolated);

            default:
                throw new TextureToolsException("UnHandled compression format by ATI texture.");
            }
        }
コード例 #7
0
        public void UpdateTexture(VoxelStorageContext context, ref IVoxelStorageTexture texture, Xenko.Graphics.PixelFormat pixelFormat, int LayoutSize)
        {
            VoxelStorageTextureClipmap clipmap = texture as VoxelStorageTextureClipmap;

            if (clipmap == null)
            {
                clipmap = new VoxelStorageTextureClipmap();
            }

            Vector3 ClipMapTextureResolution = new Vector3(ClipMapResolution.X, ClipMapResolution.Y * ClipMapCount * LayoutSize, ClipMapResolution.Z);
            Vector3 MipMapResolution         = new Vector3(ClipMapResolution.X / 2, ClipMapResolution.Y / 2 * LayoutSize, ClipMapResolution.Z / 2);

            if (VoxelUtils.DisposeTextureBySpecs(clipmap.ClipMaps, ClipMapTextureResolution, pixelFormat))
            {
                clipmap.ClipMaps = Xenko.Graphics.Texture.New3D(context.device, (int)ClipMapTextureResolution.X, (int)ClipMapTextureResolution.Y, (int)ClipMapTextureResolution.Z, new MipMapCount(false), pixelFormat, TextureFlags.ShaderResource | TextureFlags.UnorderedAccess);
            }
            if (VoxelUtils.DisposeTextureBySpecs(clipmap.MipMaps, MipMapResolution, pixelFormat))
            {
                if (clipmap.TempMipMaps != null)
                {
                    for (int i = 0; i < clipmap.TempMipMaps.Length; i++)
                    {
                        clipmap.TempMipMaps[i].Dispose();
                    }
                }

                Vector3 MipMapResolutionMax = MipMapResolution;

                clipmap.MipMaps = Xenko.Graphics.Texture.New3D(context.device, (int)MipMapResolution.X, (int)MipMapResolution.Y, (int)MipMapResolution.Z, new MipMapCount(true), pixelFormat, TextureFlags.ShaderResource | TextureFlags.UnorderedAccess);

                clipmap.TempMipMaps = new Xenko.Graphics.Texture[MipMapCount];

                for (int i = 0; i < clipmap.TempMipMaps.Length; i++)
                {
                    clipmap.TempMipMaps[i] = Xenko.Graphics.Texture.New3D(context.device, (int)MipMapResolutionMax.X, (int)MipMapResolutionMax.Y, (int)MipMapResolutionMax.Z, false, pixelFormat, TextureFlags.ShaderResource | TextureFlags.UnorderedAccess);

                    MipMapResolutionMax /= 2;
                }
            }
            clipmap.DownsampleFinerClipMaps = DownsampleFinerClipMaps;
            clipmap.ClipMapResolution       = ClipMapResolution;
            clipmap.ClipMapCount            = ClipMapCount;
            clipmap.LayoutSize        = LayoutSize;
            clipmap.VoxelSize         = context.RealVoxelSize();
            clipmap.VolumeTranslation = new Int3((int)context.VoxelSpaceTranslation.X, (int)context.VoxelSpaceTranslation.Y, (int)context.VoxelSpaceTranslation.Z);

            Array.Copy(MippingOffset, clipmap.MippingOffset, MippingOffset.Length);
            Array.Copy(PerMapOffsetScale, clipmap.PerMapOffsetScale, PerMapOffsetScale.Length);



            texture = clipmap;
        }
コード例 #8
0
        private Xenko.Graphics.PixelFormat RetrieveFormatFromNativeData(PVRTextureHeader header)
        {
            Xenko.Graphics.PixelFormat format = header.GetFormat();
            if (format == Xenko.Graphics.PixelFormat.R32G32B32A32_Float)
            {
                switch (header.GetChannelType())
                {
                case EPVRTVariableType.ePVRTVarTypeFloat:
                    return(Xenko.Graphics.PixelFormat.R32G32B32A32_Float);

                case EPVRTVariableType.ePVRTVarTypeUnsignedInteger:
                    return(Xenko.Graphics.PixelFormat.R32G32B32A32_UInt);

                case EPVRTVariableType.ePVRTVarTypeSignedInteger:
                    return(Xenko.Graphics.PixelFormat.R32G32B32A32_SInt);
                }
            }
            else if (format == Xenko.Graphics.PixelFormat.R16G16B16A16_UNorm)
            {
                switch (header.GetChannelType())
                {
                case EPVRTVariableType.ePVRTVarTypeUnsignedShortNorm:
                    return(Xenko.Graphics.PixelFormat.R16G16B16A16_UNorm);

                case EPVRTVariableType.ePVRTVarTypeUnsignedShort:
                    return(Xenko.Graphics.PixelFormat.R16G16B16A16_UInt);

                case EPVRTVariableType.ePVRTVarTypeSignedShortNorm:
                    return(Xenko.Graphics.PixelFormat.R16G16B16A16_SNorm);

                case EPVRTVariableType.ePVRTVarTypeSignedShort:
                    return(Xenko.Graphics.PixelFormat.R16G16B16A16_SInt);
                }
            }
            else if (format == Xenko.Graphics.PixelFormat.R8G8B8A8_UNorm)
            {
                switch (header.GetChannelType())
                {
                case EPVRTVariableType.ePVRTVarTypeUnsignedByteNorm:
                {
                    if (header.GetColourSpace() == EPVRTColourSpace.ePVRTCSpacelRGB)
                    {
                        return(Xenko.Graphics.PixelFormat.R8G8B8A8_UNorm);
                    }
                    else
                    {
                        return(Xenko.Graphics.PixelFormat.R8G8B8A8_UNorm_SRgb);
                    }
                }

                case EPVRTVariableType.ePVRTVarTypeUnsignedByte:
                    return(Xenko.Graphics.PixelFormat.R8G8B8A8_UInt);

                case EPVRTVariableType.ePVRTVarTypeSignedByteNorm:
                    return(Xenko.Graphics.PixelFormat.R8G8B8A8_SNorm);

                case EPVRTVariableType.ePVRTVarTypeSignedByte:
                    return(Xenko.Graphics.PixelFormat.R8G8B8A8_SInt);
                }
            }

            return(format);
        }
コード例 #9
0
 private EPVRTColourSpace RetrieveNativeColorSpace(Xenko.Graphics.PixelFormat format)
 {
     return(format.IsSRgb() ? EPVRTColourSpace.ePVRTCSpaceSRgb : EPVRTColourSpace.ePVRTCSpacelRGB);
 }
コード例 #10
0
ファイル: DxtTexLib.cs プロジェクト: santoshna/xenko-1
 /// <summary>
 /// Retrieves the native format from <see cref="Xenko.Graphics.PixelFormat"/>.
 /// </summary>
 /// <param name="format">The format.</param>
 /// <returns>The corresponding <see cref="DXGI_FORMAT"/></returns>
 private DXGI_FORMAT RetrieveNativeFormat(Xenko.Graphics.PixelFormat format)
 {
     return((DXGI_FORMAT)format);
 }
コード例 #11
0
        public static bool DisposeTextureBySpecs(Xenko.Graphics.Texture tex, Vector3 dim, Xenko.Graphics.PixelFormat pixelFormat, MultisampleCount samples)
        {
            if (tex == null || !TextureDimensionsEqual(tex, dim) || tex.Format != pixelFormat || tex.MultisampleCount != samples)
            {
                if (tex != null)
                {
                    tex.Dispose();
                }

                return(true);
            }
            return(false);
        }
コード例 #12
0
        public void UpdateTexture(VoxelStorageContext context, ref IVoxelStorageTexture texture, Xenko.Graphics.PixelFormat pixelFormat, int layoutCount)
        {
            VoxelStorageTextureClipmap clipmap = texture as VoxelStorageTextureClipmap;

            if (clipmap == null)
            {
                clipmap = new VoxelStorageTextureClipmap();
            }

            Vector3 ClipMapTextureResolution = new Vector3(ClipMapResolution.X, ClipMapResolution.Y * ClipMapCount * layoutCount, ClipMapResolution.Z);
            Vector3 MipMapResolution         = new Vector3(ClipMapResolution.X / 2, ClipMapResolution.Y / 2 * layoutCount, ClipMapResolution.Z / 2);
            Vector3 MipMapNoLayoutResolution = new Vector3(ClipMapResolution.X / 2, ClipMapResolution.Y / 2, ClipMapResolution.Z / 2);

            if (NeedToRecreateTexture(clipmap.ClipMaps, ClipMapTextureResolution, pixelFormat))
            {
                clipmap.ClipMaps = Xenko.Graphics.Texture.New3D(context.device, (int)ClipMapTextureResolution.X, (int)ClipMapTextureResolution.Y, (int)ClipMapTextureResolution.Z, new MipMapCount(false), pixelFormat, TextureFlags.ShaderResource | TextureFlags.UnorderedAccess);
            }
            if (NeedToRecreateTexture(clipmap.MipMaps, MipMapResolution, pixelFormat))
            {
                if (clipmap.TempMipMaps != null)
                {
                    for (int i = 0; i < clipmap.TempMipMaps.Length; i++)
                    {
                        clipmap.TempMipMaps[i].Dispose();
                    }
                }


                Vector3 MipMapResolutionMax = MipMapResolution;
                int     mipCount            = 1 + (int)Math.Floor(Math.Log(Math.Min(MipMapNoLayoutResolution.X, Math.Min(MipMapNoLayoutResolution.Y, MipMapNoLayoutResolution.Z)), 2));

                clipmap.MipMaps = Xenko.Graphics.Texture.New3D(context.device, (int)MipMapResolution.X, (int)MipMapResolution.Y, (int)MipMapResolution.Z, new MipMapCount(true), pixelFormat, TextureFlags.ShaderResource | TextureFlags.UnorderedAccess);

                clipmap.TempMipMaps = new Xenko.Graphics.Texture[mipCount];

                for (int i = 0; i < clipmap.TempMipMaps.Length; i++)
                {
                    clipmap.TempMipMaps[i] = Xenko.Graphics.Texture.New3D(context.device, (int)MipMapResolutionMax.X, (int)MipMapResolutionMax.Y, (int)MipMapResolutionMax.Z, false, pixelFormat, TextureFlags.ShaderResource | TextureFlags.UnorderedAccess);

                    MipMapResolutionMax /= 2;
                }
            }
            clipmap.MipmapInner       = MipmapInner;
            clipmap.ClipMapResolution = ClipMapResolution;
            clipmap.ClipMapCount      = ClipMapCount;
            clipmap.LayoutSize        = layoutCount;
            clipmap.VoxelMatrix       = InnerTextureMatrix;
            clipmap.VoxelSize         = context.RealVoxelSize();

            texture = clipmap;
        }