Example #1
0
        public static GalImageFormat ConvertTexture(
            GalTextureFormat Format,
            GalTextureType RType,
            GalTextureType GType,
            GalTextureType BType,
            GalTextureType AType,
            bool ConvSrgb)
        {
            if (RType != GType || RType != BType || RType != AType)
            {
                throw new NotImplementedException("Per component types are not implemented!");
            }

            if (!s_TextureTable.TryGetValue(Format, out GalImageFormat ImageFormat))
            {
                throw new NotImplementedException($"Format 0x{((int)Format):x} not implemented!");
            }

            GalImageFormat FormatType = ConvSrgb ? Srgb : GetFormatType(RType);

            GalImageFormat CombinedFormat = (ImageFormat & GalImageFormat.FormatMask) | FormatType;

            if (!ImageFormat.HasFlag(FormatType))
            {
                throw new NotImplementedException($"Format \"{CombinedFormat}\" not implemented!");
            }

            return(CombinedFormat);
        }
Example #2
0
        public static GalImageFormat ConvertTexture(
            GalTextureFormat format,
            GalTextureType rType,
            GalTextureType gType,
            GalTextureType bType,
            GalTextureType aType,
            bool convSrgb)
        {
            if (!TextureTable.TryGetValue(format, out GalImageFormat imageFormat))
            {
                throw new NotImplementedException($"Format 0x{((int)format):x} not implemented!");
            }

            if (!HasDepth(imageFormat) && (rType != gType || rType != bType || rType != aType))
            {
                throw new NotImplementedException("Per component types are not implemented!");
            }

            GalImageFormat formatType = convSrgb ? Srgb : GetFormatType(rType);

            GalImageFormat combinedFormat = (imageFormat & GalImageFormat.FormatMask) | formatType;

            if (!imageFormat.HasFlag(formatType))
            {
                throw new NotImplementedException($"Format \"{combinedFormat}\" not implemented!");
            }

            return(combinedFormat);
        }
Example #3
0
        public static GalImageFormat ConvertTexture(
            GalTextureFormat Format,
            GalTextureType RType,
            GalTextureType GType,
            GalTextureType BType,
            GalTextureType AType)
        {
            if (RType != GType || RType != BType || RType != AType)
            {
                throw new NotImplementedException("Per component types are not implemented");
            }

            if (!s_TextureTable.TryGetValue(Format, out GalImageFormat ImageFormat))
            {
                throw new NotImplementedException("Texture with format " + ((int)Format).ToString("x2") + " not implemented");
            }

            GalTextureType Type = RType;

            GalImageFormat FormatType = GetFormatType(RType);

            if (ImageFormat.HasFlag(FormatType))
            {
                return((ImageFormat & GalImageFormat.FormatMask) | FormatType);
            }
            else
            {
                throw new NotImplementedException("Texture with format " + Format +
                                                  " and component type " + Type + " is not implemented");
            }
        }
Example #4
0
        public static GalImage MakeTexture(NvGpuVmm Vmm, long TicPosition)
        {
            int[] Tic = ReadWords(Vmm, TicPosition, 8);

            GalTextureType RType = (GalTextureType)((Tic[0] >> 7) & 7);
            GalTextureType GType = (GalTextureType)((Tic[0] >> 10) & 7);
            GalTextureType BType = (GalTextureType)((Tic[0] >> 13) & 7);
            GalTextureType AType = (GalTextureType)((Tic[0] >> 16) & 7);

            GalImageFormat Format = ImageFormatConverter.ConvertTexture((GalTextureFormat)(Tic[0] & 0x7f), RType, GType, BType, AType);

            GalTextureSource XSource = (GalTextureSource)((Tic[0] >> 19) & 7);
            GalTextureSource YSource = (GalTextureSource)((Tic[0] >> 22) & 7);
            GalTextureSource ZSource = (GalTextureSource)((Tic[0] >> 25) & 7);
            GalTextureSource WSource = (GalTextureSource)((Tic[0] >> 28) & 7);

            int Width  = (Tic[4] & 0xffff) + 1;
            int Height = (Tic[5] & 0xffff) + 1;

            return(new GalImage(
                       Width,
                       Height,
                       Format,
                       XSource,
                       YSource,
                       ZSource,
                       WSource));
        }
Example #5
0
        private static GalImageFormat GetImageFormat(int[] Tic)
        {
            GalTextureType RType = (GalTextureType)((Tic[0] >> 7) & 7);
            GalTextureType GType = (GalTextureType)((Tic[0] >> 10) & 7);
            GalTextureType BType = (GalTextureType)((Tic[0] >> 13) & 7);
            GalTextureType AType = (GalTextureType)((Tic[0] >> 16) & 7);

            GalTextureFormat Format = (GalTextureFormat)(Tic[0] & 0x7f);

            return(ImageUtils.ConvertTexture(Format, RType, GType, BType, AType));
        }
Example #6
0
        private static GalImageFormat GetImageFormat(int[] tic)
        {
            GalTextureType rType = (GalTextureType)((tic[0] >> 7) & 7);
            GalTextureType gType = (GalTextureType)((tic[0] >> 10) & 7);
            GalTextureType bType = (GalTextureType)((tic[0] >> 13) & 7);
            GalTextureType aType = (GalTextureType)((tic[0] >> 16) & 7);

            GalTextureFormat format = (GalTextureFormat)(tic[0] & 0x7f);

            bool convSrgb = ((tic[4] >> 22) & 1) != 0;

            return(ImageUtils.ConvertTexture(format, rType, gType, bType, aType, convSrgb));
        }
Example #7
0
        private static GalImageFormat GetFormatType(GalTextureType Type)
        {
            switch (Type)
            {
            case GalTextureType.Snorm: return(Snorm);

            case GalTextureType.Unorm: return(Unorm);

            case GalTextureType.Sint:  return(Sint);

            case GalTextureType.Uint:  return(Uint);

            case GalTextureType.Float: return(Float);

            default: throw new NotImplementedException(((int)Type).ToString());
            }
        }
Example #8
0
        public static GalImageFormat ConvertTexture(
            GalTextureFormat Format,
            GalTextureType RType,
            GalTextureType GType,
            GalTextureType BType,
            GalTextureType AType)
        {
            if (RType != GType || RType != BType || RType != AType)
            {
                throw new NotImplementedException("Per component types are not implemented");
            }

            GalTextureType Type = RType;

            switch (Type)
            {
            case GalTextureType.Snorm:
                switch (Format)
                {
                case GalTextureFormat.R16G16B16A16: return(GalImageFormat.R16G16B16A16_SNORM);

                case GalTextureFormat.A8B8G8R8:     return(GalImageFormat.A8B8G8R8_SNORM_PACK32);

                case GalTextureFormat.A2B10G10R10:  return(GalImageFormat.A2B10G10R10_SNORM_PACK32);

                case GalTextureFormat.G8R8:         return(GalImageFormat.R8G8_SNORM);

                case GalTextureFormat.R16:          return(GalImageFormat.R16_SNORM);

                case GalTextureFormat.R8:           return(GalImageFormat.R8_SNORM);

                case GalTextureFormat.BC4:          return(GalImageFormat.BC4_SNORM_BLOCK);

                case GalTextureFormat.BC5:          return(GalImageFormat.BC5_SNORM_BLOCK);
                }
                break;

            case GalTextureType.Unorm:
                switch (Format)
                {
                case GalTextureFormat.R16G16B16A16: return(GalImageFormat.R16G16B16A16_UNORM);

                case GalTextureFormat.A8B8G8R8:     return(GalImageFormat.A8B8G8R8_UNORM_PACK32);

                case GalTextureFormat.A2B10G10R10:  return(GalImageFormat.A2B10G10R10_UNORM_PACK32);

                case GalTextureFormat.A4B4G4R4:     return(GalImageFormat.R4G4B4A4_UNORM_PACK16_REVERSED);

                case GalTextureFormat.A1B5G5R5:     return(GalImageFormat.A1R5G5B5_UNORM_PACK16);

                case GalTextureFormat.B5G6R5:       return(GalImageFormat.B5G6R5_UNORM_PACK16);

                case GalTextureFormat.BC7U:         return(GalImageFormat.BC7_UNORM_BLOCK);

                case GalTextureFormat.G8R8:         return(GalImageFormat.R8G8_UNORM);

                case GalTextureFormat.R16:          return(GalImageFormat.R16_UNORM);

                case GalTextureFormat.R8:           return(GalImageFormat.R8_UNORM);

                case GalTextureFormat.BC1:          return(GalImageFormat.BC1_RGBA_UNORM_BLOCK);

                case GalTextureFormat.BC2:          return(GalImageFormat.BC2_UNORM_BLOCK);

                case GalTextureFormat.BC3:          return(GalImageFormat.BC3_UNORM_BLOCK);

                case GalTextureFormat.BC4:          return(GalImageFormat.BC4_UNORM_BLOCK);

                case GalTextureFormat.BC5:          return(GalImageFormat.BC5_UNORM_BLOCK);

                case GalTextureFormat.Z24S8:        return(GalImageFormat.D24_UNORM_S8_UINT);

                case GalTextureFormat.Astc2D4x4:    return(GalImageFormat.ASTC_4x4_UNORM_BLOCK);

                case GalTextureFormat.Astc2D5x5:    return(GalImageFormat.ASTC_5x5_UNORM_BLOCK);

                case GalTextureFormat.Astc2D6x6:    return(GalImageFormat.ASTC_6x6_UNORM_BLOCK);

                case GalTextureFormat.Astc2D8x8:    return(GalImageFormat.ASTC_8x8_UNORM_BLOCK);

                case GalTextureFormat.Astc2D10x10:  return(GalImageFormat.ASTC_10x10_UNORM_BLOCK);

                case GalTextureFormat.Astc2D12x12:  return(GalImageFormat.ASTC_12x12_UNORM_BLOCK);

                case GalTextureFormat.Astc2D5x4:    return(GalImageFormat.ASTC_5x4_UNORM_BLOCK);

                case GalTextureFormat.Astc2D6x5:    return(GalImageFormat.ASTC_6x5_UNORM_BLOCK);

                case GalTextureFormat.Astc2D8x6:    return(GalImageFormat.ASTC_8x6_UNORM_BLOCK);

                case GalTextureFormat.Astc2D10x8:   return(GalImageFormat.ASTC_10x8_UNORM_BLOCK);

                case GalTextureFormat.Astc2D12x10:  return(GalImageFormat.ASTC_12x10_UNORM_BLOCK);

                case GalTextureFormat.Astc2D8x5:    return(GalImageFormat.ASTC_8x5_UNORM_BLOCK);

                case GalTextureFormat.Astc2D10x5:   return(GalImageFormat.ASTC_10x5_UNORM_BLOCK);

                case GalTextureFormat.Astc2D10x6:   return(GalImageFormat.ASTC_10x6_UNORM_BLOCK);
                }
                break;

            case GalTextureType.Sint:
                switch (Format)
                {
                case GalTextureFormat.R32G32B32A32: return(GalImageFormat.R32G32B32A32_SINT);

                case GalTextureFormat.R16G16B16A16: return(GalImageFormat.R16G16B16A16_SINT);

                case GalTextureFormat.A8B8G8R8:     return(GalImageFormat.A8B8G8R8_SINT_PACK32);

                case GalTextureFormat.A2B10G10R10:  return(GalImageFormat.A2B10G10R10_SINT_PACK32);

                case GalTextureFormat.R32:          return(GalImageFormat.R32_SINT);

                case GalTextureFormat.G8R8:         return(GalImageFormat.R8G8_SINT);

                case GalTextureFormat.R16:          return(GalImageFormat.R16_SINT);

                case GalTextureFormat.R8:           return(GalImageFormat.R8_SINT);
                }
                break;

            case GalTextureType.Uint:
                switch (Format)
                {
                case GalTextureFormat.R32G32B32A32: return(GalImageFormat.R32G32B32A32_UINT);

                case GalTextureFormat.R16G16B16A16: return(GalImageFormat.R16G16B16A16_UINT);

                case GalTextureFormat.A8B8G8R8:     return(GalImageFormat.A8B8G8R8_UINT_PACK32);

                case GalTextureFormat.A2B10G10R10:  return(GalImageFormat.A2B10G10R10_UINT_PACK32);

                case GalTextureFormat.R32:          return(GalImageFormat.R32_UINT);

                case GalTextureFormat.G8R8:         return(GalImageFormat.R8G8_UINT);

                case GalTextureFormat.R16:          return(GalImageFormat.R16_UINT);

                case GalTextureFormat.R8:           return(GalImageFormat.R8_UINT);
                }
                break;

            case GalTextureType.Snorm_Force_Fp16:
                //TODO
                break;

            case GalTextureType.Unorm_Force_Fp16:
                //TODO
                break;

            case GalTextureType.Float:
                switch (Format)
                {
                case GalTextureFormat.R32G32B32A32: return(GalImageFormat.R32G32B32A32_SFLOAT);

                case GalTextureFormat.R16G16B16A16: return(GalImageFormat.R16G16B16A16_SFLOAT);

                case GalTextureFormat.R32:          return(GalImageFormat.R32_SFLOAT);

                case GalTextureFormat.BC6H_SF16:    return(GalImageFormat.BC6H_SFLOAT_BLOCK);

                case GalTextureFormat.BC6H_UF16:    return(GalImageFormat.BC6H_UFLOAT_BLOCK);

                case GalTextureFormat.R16:          return(GalImageFormat.R16_SFLOAT);

                case GalTextureFormat.BF10GF11RF11: return(GalImageFormat.B10G11R11_UFLOAT_PACK32);

                case GalTextureFormat.ZF32:         return(GalImageFormat.D32_SFLOAT);
                }
                break;
            }

            throw new NotImplementedException("0x" + Format.ToString("x2") + " " + Type.ToString());
        }