示例#1
0
        /// <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(Stride.Graphics.PixelFormat format)
        {
            switch (format)
            {
            case Stride.Graphics.PixelFormat.ETC1:
                return(6);

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

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

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

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

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

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

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

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

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

            case Stride.Graphics.PixelFormat.R8G8B8A8_UNorm_SRgb:
            case Stride.Graphics.PixelFormat.R8G8B8A8_UNorm:
            case Stride.Graphics.PixelFormat.R8G8B8A8_UInt:
            case Stride.Graphics.PixelFormat.R8G8B8A8_SNorm:
            case Stride.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 EPVRTVariableType RetrieveNativePixelType(Stride.Graphics.PixelFormat format)
        {
            switch (format)
            {
            case Stride.Graphics.PixelFormat.R32G32B32A32_Float:
            case Stride.Graphics.PixelFormat.R32G32B32_Float:
                return(EPVRTVariableType.ePVRTVarTypeFloat);

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

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

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

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

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

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

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


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

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

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

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

            default:
                return(EPVRTVariableType.ePVRTVarTypeUnsignedByteNorm);
            }
        }
示例#3
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(Stride.Graphics.PixelFormat format)
        {
            switch (format)
            {
            case Stride.Graphics.PixelFormat.R32G32B32A32_Float:
            case Stride.Graphics.PixelFormat.R32G32B32_Float:
            case Stride.Graphics.PixelFormat.R32G32B32A32_UInt:
            case Stride.Graphics.PixelFormat.R32G32B32_UInt:
            case Stride.Graphics.PixelFormat.R32G32B32A32_SInt:
            case Stride.Graphics.PixelFormat.R32G32B32_SInt:
            case Stride.Graphics.PixelFormat.R16G16B16A16_UNorm:
            case Stride.Graphics.PixelFormat.R16G16B16A16_UInt:
            case Stride.Graphics.PixelFormat.R16G16B16A16_SNorm:
            case Stride.Graphics.PixelFormat.R16G16B16A16_SInt:
            case Stride.Graphics.PixelFormat.R8G8B8A8_UNorm_SRgb:
            case Stride.Graphics.PixelFormat.R8G8B8A8_UNorm:
            case Stride.Graphics.PixelFormat.R8G8B8A8_UInt:
            case Stride.Graphics.PixelFormat.R8G8B8A8_SNorm:
            case Stride.Graphics.PixelFormat.R8G8B8A8_SInt:
            case Stride.Graphics.PixelFormat.B8G8R8A8_UNorm_SRgb:
            case Stride.Graphics.PixelFormat.B8G8R8A8_UNorm:

            case Stride.Graphics.PixelFormat.ETC1:
            case Stride.Graphics.PixelFormat.ETC2_RGB:
            case Stride.Graphics.PixelFormat.ETC2_RGB_SRgb:
            case Stride.Graphics.PixelFormat.ETC2_RGBA:
            case Stride.Graphics.PixelFormat.ETC2_RGBA_SRgb:
            case Stride.Graphics.PixelFormat.ETC2_RGB_A1:
            case Stride.Graphics.PixelFormat.EAC_R11_Unsigned:
            case Stride.Graphics.PixelFormat.EAC_R11_Signed:
            case Stride.Graphics.PixelFormat.EAC_RG11_Unsigned:
            case Stride.Graphics.PixelFormat.EAC_RG11_Signed:
                return(true);

            default:
                return(false);
            }
        }
示例#4
0
 /// <summary>
 /// Retrieves the native format from <see cref="Stride.Graphics.PixelFormat"/>.
 /// </summary>
 /// <param name="format">The format.</param>
 /// <returns>The corresponding <see cref="DXGI_FORMAT"/></returns>
 private DXGI_FORMAT RetrieveNativeFormat(Stride.Graphics.PixelFormat format)
 {
     return((DXGI_FORMAT)format);
 }
示例#5
0
        public static bool DisposeTextureBySpecs(Stride.Graphics.Texture tex, Vector3 dim, Stride.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);
        }
示例#6
0
 private EPVRTColourSpace RetrieveNativeColorSpace(Stride.Graphics.PixelFormat format)
 {
     return(format.IsSRgb() ? EPVRTColourSpace.ePVRTCSpaceSRgb : EPVRTColourSpace.ePVRTCSpacelRGB);
 }
示例#7
0
        private Stride.Graphics.PixelFormat RetrieveFormatFromNativeData(PVRTextureHeader header)
        {
            Stride.Graphics.PixelFormat format = header.GetFormat();
            if (format == Stride.Graphics.PixelFormat.R32G32B32A32_Float)
            {
                switch (header.GetChannelType())
                {
                case EPVRTVariableType.ePVRTVarTypeFloat:
                    return(Stride.Graphics.PixelFormat.R32G32B32A32_Float);

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

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

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

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

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

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

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

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

            return(format);
        }
示例#8
0
        public void UpdateTexture(VoxelStorageContext context, ref IVoxelStorageTexture texture, Stride.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 = Stride.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 = Stride.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 Stride.Graphics.Texture[MipMapCount];

                for (int i = 0; i < clipmap.TempMipMaps.Length; i++)
                {
                    clipmap.TempMipMaps[i] = Stride.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;
        }