public GalImage( int Width, int Height, int TileWidth, int GobBlockHeight, GalMemoryLayout Layout, GalImageFormat Format, GalTextureSource XSource = GalTextureSource.Red, GalTextureSource YSource = GalTextureSource.Green, GalTextureSource ZSource = GalTextureSource.Blue, GalTextureSource WSource = GalTextureSource.Alpha) { this.Width = Width; this.Height = Height; this.TileWidth = TileWidth; this.GobBlockHeight = GobBlockHeight; this.Layout = Layout; this.Format = Format; this.XSource = XSource; this.YSource = YSource; this.ZSource = ZSource; this.WSource = WSource; Pitch = ImageUtils.GetPitch(Format, Width); }
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)); }
public GalImage( int width, int height, int depth, int layerCount, int tileWidth, int gobBlockHeight, int gobBlockDepth, GalMemoryLayout layout, GalImageFormat format, GalTextureTarget textureTarget, int maxMipmapLevel = 1, GalTextureSource xSource = GalTextureSource.Red, GalTextureSource ySource = GalTextureSource.Green, GalTextureSource zSource = GalTextureSource.Blue, GalTextureSource wSource = GalTextureSource.Alpha) { Width = width; Height = height; LayerCount = layerCount; Depth = depth; TileWidth = tileWidth; GobBlockHeight = gobBlockHeight; GobBlockDepth = gobBlockDepth; Layout = layout; Format = format; MaxMipmapLevel = maxMipmapLevel; XSource = xSource; YSource = ySource; ZSource = zSource; WSource = wSource; TextureTarget = textureTarget; Pitch = ImageUtils.GetPitch(format, width); }
public static GalImage MakeTexture(NvGpuVmm Vmm, long TicPosition) { int[] Tic = ReadWords(Vmm, TicPosition, 8); GalImageFormat Format = GetImageFormat(Tic); 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); TextureSwizzle Swizzle = (TextureSwizzle)((Tic[2] >> 21) & 7); GalMemoryLayout Layout; if (Swizzle == TextureSwizzle.BlockLinear || Swizzle == TextureSwizzle.BlockLinearColorKey) { Layout = GalMemoryLayout.BlockLinear; } else { Layout = GalMemoryLayout.Pitch; } int BlockHeightLog2 = (Tic[3] >> 3) & 7; int TileWidthLog2 = (Tic[3] >> 10) & 7; int BlockHeight = 1 << BlockHeightLog2; int TileWidth = 1 << TileWidthLog2; int Width = (Tic[4] & 0xffff) + 1; int Height = (Tic[5] & 0xffff) + 1; GalImage Image = new GalImage( Width, Height, TileWidth, BlockHeight, Layout, Format, XSource, YSource, ZSource, WSource); if (Layout == GalMemoryLayout.Pitch) { Image.Pitch = (Tic[3] & 0xffff) << 5; } return(Image); }
public static GalTexture MakeTexture(NvGpu Gpu, NvGpuVmm Vmm, long TicPosition) { int[] Tic = ReadWords(Vmm, TicPosition, 8); GalTextureFormat Format = (GalTextureFormat)(Tic[0] & 0x7f); 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); long TextureAddress = (uint)Tic[1]; TextureAddress |= (long)((ushort)Tic[2]) << 32; TextureSwizzle Swizzle = (TextureSwizzle)((Tic[2] >> 21) & 7); int Pitch = (Tic[3] & 0xffff) << 5; int BlockHeightLog2 = (Tic[3] >> 3) & 7; int BlockHeight = 1 << BlockHeightLog2; int Width = (Tic[4] & 0xffff) + 1; int Height = (Tic[5] & 0xffff) + 1; Texture Texture = new Texture( TextureAddress, Width, Height, Pitch, BlockHeight, Swizzle, Format); byte[] Data = TextureReader.Read(Vmm, Texture); return(new GalTexture( Data, Width, Height, Format, XSource, YSource, ZSource, WSource)); }
public GalImage( int Width, int Height, GalImageFormat Format, GalTextureSource XSource = GalTextureSource.Red, GalTextureSource YSource = GalTextureSource.Green, GalTextureSource ZSource = GalTextureSource.Blue, GalTextureSource WSource = GalTextureSource.Alpha) { this.Width = Width; this.Height = Height; this.Format = Format; this.XSource = XSource; this.YSource = YSource; this.ZSource = ZSource; this.WSource = WSource; }
public GalTexture( int Width, int Height, GalTextureFormat Format, GalTextureSource XSource, GalTextureSource YSource, GalTextureSource ZSource, GalTextureSource WSource) { this.Width = Width; this.Height = Height; this.Format = Format; this.XSource = XSource; this.YSource = YSource; this.ZSource = ZSource; this.WSource = WSource; }
public static All GetTextureSwizzle(GalTextureSource source) { switch (source) { case GalTextureSource.Zero: return(All.Zero); case GalTextureSource.Red: return(All.Red); case GalTextureSource.Green: return(All.Green); case GalTextureSource.Blue: return(All.Blue); case GalTextureSource.Alpha: return(All.Alpha); case GalTextureSource.OneInt: return(All.One); case GalTextureSource.OneFloat: return(All.One); } throw new ArgumentException(nameof(source) + " \"" + source + "\" is not valid!"); }
public static All GetTextureSwizzle(GalTextureSource Source) { switch (Source) { case GalTextureSource.Zero: return(All.Zero); case GalTextureSource.Red: return(All.Red); case GalTextureSource.Green: return(All.Green); case GalTextureSource.Blue: return(All.Blue); case GalTextureSource.Alpha: return(All.Alpha); case GalTextureSource.OneInt: return(All.One); case GalTextureSource.OneFloat: return(All.One); } return(All.Zero); }
public static GalTexture MakeTexture(NvGpuVmm Vmm, long TicPosition) { int[] Tic = ReadWords(Vmm, TicPosition, 8); GalTextureFormat Format = (GalTextureFormat)(Tic[0] & 0x7f); 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 GalTexture( Width, Height, Format, XSource, YSource, ZSource, WSource)); }
public static GalImage MakeTexture(NvGpuVmm vmm, long ticPosition) { int[] tic = ReadWords(vmm, ticPosition, 8); GalImageFormat format = GetImageFormat(tic); GalTextureTarget textureTarget = (GalTextureTarget)((tic[4] >> 23) & 0xF); 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); TextureSwizzle swizzle = (TextureSwizzle)((tic[2] >> 21) & 7); int maxMipmapLevel = (tic[3] >> 28) & 0xF + 1; GalMemoryLayout layout; if (swizzle == TextureSwizzle.BlockLinear || swizzle == TextureSwizzle.BlockLinearColorKey) { layout = GalMemoryLayout.BlockLinear; } else { layout = GalMemoryLayout.Pitch; } int gobBlockHeightLog2 = (tic[3] >> 3) & 7; int gobBlockDepthLog2 = (tic[3] >> 6) & 7; int tileWidthLog2 = (tic[3] >> 10) & 7; int gobBlockHeight = 1 << gobBlockHeightLog2; int gobBlockDepth = 1 << gobBlockDepthLog2; int tileWidth = 1 << tileWidthLog2; int width = ((tic[4] >> 0) & 0xffff) + 1; int height = ((tic[5] >> 0) & 0xffff) + 1; int depth = ((tic[5] >> 16) & 0x3fff) + 1; int layoutCount = 1; // TODO: check this if (ImageUtils.IsArray(textureTarget)) { layoutCount = depth; depth = 1; } if (textureTarget == GalTextureTarget.OneD) { height = 1; } if (textureTarget == GalTextureTarget.TwoD || textureTarget == GalTextureTarget.OneD) { depth = 1; } else if (textureTarget == GalTextureTarget.CubeMap) { // FIXME: This is a bit hacky but I guess it's fine for now layoutCount = 6; depth = 1; } else if (textureTarget == GalTextureTarget.CubeArray) { // FIXME: This is a really really hacky but I guess it's fine for now layoutCount *= 6; depth = 1; } GalImage image = new GalImage( width, height, depth, layoutCount, tileWidth, gobBlockHeight, gobBlockDepth, layout, format, textureTarget, maxMipmapLevel, xSource, ySource, zSource, wSource); if (layout == GalMemoryLayout.Pitch) { image.Pitch = (tic[3] & 0xffff) << 5; } return(image); }