TextureType => GalTextureTarget
This commit is contained in:
parent
8a3a128ecb
commit
c9b0ee8178
13 changed files with 68 additions and 73 deletions
|
@ -18,7 +18,7 @@ namespace Ryujinx.Graphics.Gal
|
|||
public GalTextureSource YSource;
|
||||
public GalTextureSource ZSource;
|
||||
public GalTextureSource WSource;
|
||||
public TextureType TextureType;
|
||||
public GalTextureTarget TextureType;
|
||||
|
||||
public GalImage(
|
||||
int Width,
|
||||
|
@ -28,7 +28,7 @@ namespace Ryujinx.Graphics.Gal
|
|||
int GobBlockHeight,
|
||||
GalMemoryLayout Layout,
|
||||
GalImageFormat Format,
|
||||
TextureType TextureType,
|
||||
GalTextureTarget TextureType,
|
||||
int MaxMipmapLevel = 1,
|
||||
GalTextureSource XSource = GalTextureSource.Red,
|
||||
GalTextureSource YSource = GalTextureSource.Green,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
namespace Ryujinx.Graphics.Texture
|
||||
namespace Ryujinx.Graphics.Gal
|
||||
{
|
||||
public enum TextureType
|
||||
public enum GalTextureTarget
|
||||
{
|
||||
OneD = 0,
|
||||
TwoD = 1,
|
|
@ -1,8 +1,6 @@
|
|||
using OpenTK.Graphics.OpenGL;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Graphics.Texture;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Ryujinx.Graphics.Gal.OpenGL
|
||||
{
|
||||
|
|
|
@ -235,14 +235,14 @@ namespace Ryujinx.Graphics.Gal.Shader
|
|||
|
||||
string Name = StagePrefix + TextureName + Index;
|
||||
|
||||
TextureType TextureType;
|
||||
GalTextureTarget TextureType;
|
||||
|
||||
TextureInstructionSuffix TextureInstructionSuffix;
|
||||
|
||||
// TODO: Non 2D texture type for TEXQ?
|
||||
if (Op.Inst == ShaderIrInst.Texq)
|
||||
{
|
||||
TextureType = TextureType.TwoD;
|
||||
TextureType = GalTextureTarget.TwoD;
|
||||
TextureInstructionSuffix = TextureInstructionSuffix.None;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -30,69 +30,69 @@ namespace Ryujinx.Graphics.Gal.Shader
|
|||
{ RGB_, RG_A, R_BA, _GBA, RGBA, ____, ____, ____ }
|
||||
};
|
||||
|
||||
private static TextureType TexToTextureType(int TexType, bool IsArray)
|
||||
private static GalTextureTarget TexToTextureType(int TexType, bool IsArray)
|
||||
{
|
||||
switch (TexType)
|
||||
{
|
||||
case 0:
|
||||
return IsArray ? TextureType.OneDArray : TextureType.OneD;
|
||||
return IsArray ? GalTextureTarget.OneDArray : GalTextureTarget.OneD;
|
||||
case 2:
|
||||
return IsArray ? TextureType.TwoDArray : TextureType.TwoD;
|
||||
return IsArray ? GalTextureTarget.TwoDArray : GalTextureTarget.TwoD;
|
||||
case 4:
|
||||
if (IsArray)
|
||||
throw new InvalidOperationException($"ARRAY bit set on a TEX with 3D texture!");
|
||||
return TextureType.ThreeD;
|
||||
return GalTextureTarget.ThreeD;
|
||||
case 6:
|
||||
return IsArray ? TextureType.CubeArray : TextureType.CubeMap;
|
||||
return IsArray ? GalTextureTarget.CubeArray : GalTextureTarget.CubeMap;
|
||||
default:
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
private static TextureType TexsToTextureType(int TexType)
|
||||
private static GalTextureTarget TexsToTextureType(int TexType)
|
||||
{
|
||||
switch (TexType)
|
||||
{
|
||||
case 0:
|
||||
return TextureType.OneD;
|
||||
return GalTextureTarget.OneD;
|
||||
case 2:
|
||||
case 4:
|
||||
case 6:
|
||||
case 8:
|
||||
case 0xa:
|
||||
case 0xc:
|
||||
return TextureType.TwoD;
|
||||
return GalTextureTarget.TwoD;
|
||||
case 0xe:
|
||||
case 0x10:
|
||||
case 0x12:
|
||||
return TextureType.TwoDArray;
|
||||
return GalTextureTarget.TwoDArray;
|
||||
case 0x14:
|
||||
case 0x16:
|
||||
return TextureType.ThreeD;
|
||||
return GalTextureTarget.ThreeD;
|
||||
case 0x18:
|
||||
case 0x1a:
|
||||
return TextureType.CubeMap;
|
||||
return GalTextureTarget.CubeMap;
|
||||
default:
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
public static TextureType TldsToTextureType(int TexType)
|
||||
public static GalTextureTarget TldsToTextureType(int TexType)
|
||||
{
|
||||
switch (TexType)
|
||||
{
|
||||
case 0:
|
||||
case 2:
|
||||
return TextureType.OneD;
|
||||
return GalTextureTarget.OneD;
|
||||
case 4:
|
||||
case 8:
|
||||
case 0xa:
|
||||
case 0xc:
|
||||
return TextureType.TwoD;
|
||||
return GalTextureTarget.TwoD;
|
||||
case 0x10:
|
||||
return TextureType.TwoDArray;
|
||||
return GalTextureTarget.TwoDArray;
|
||||
case 0xe:
|
||||
return TextureType.ThreeD;
|
||||
return GalTextureTarget.ThreeD;
|
||||
default:
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
@ -279,7 +279,7 @@ namespace Ryujinx.Graphics.Gal.Shader
|
|||
{
|
||||
bool IsArray = OpCode.HasArray();
|
||||
|
||||
TextureType TextureType = TexToTextureType(OpCode.Read(28, 6), IsArray);
|
||||
GalTextureTarget TextureType = TexToTextureType(OpCode.Read(28, 6), IsArray);
|
||||
|
||||
bool HasDepthCompare = OpCode.Read(0x32);
|
||||
|
||||
|
@ -430,7 +430,7 @@ namespace Ryujinx.Graphics.Gal.Shader
|
|||
throw new InvalidOperationException($"Invalid Suffix for TEXS instruction {RawSuffix}");
|
||||
}
|
||||
|
||||
TextureType TextureType = TexsToTextureType(OpCode.Read(52, 0x1e));
|
||||
GalTextureTarget TextureType = TexsToTextureType(OpCode.Read(52, 0x1e));
|
||||
|
||||
EmitTexs(Block, OpCode, ShaderIrInst.Texs, TextureType, Suffix);
|
||||
}
|
||||
|
@ -466,7 +466,7 @@ namespace Ryujinx.Graphics.Gal.Shader
|
|||
throw new InvalidOperationException($"Invalid Suffix for TLDS instruction {RawSuffix}");
|
||||
}
|
||||
|
||||
TextureType TextureType = TldsToTextureType(OpCode.Read(52, 0x1e));
|
||||
GalTextureTarget TextureType = TldsToTextureType(OpCode.Read(52, 0x1e));
|
||||
|
||||
EmitTexs(Block, OpCode, ShaderIrInst.Txlf, TextureType, Suffix);
|
||||
}
|
||||
|
@ -497,7 +497,7 @@ namespace Ryujinx.Graphics.Gal.Shader
|
|||
bool IsArray = OpCode.HasArray();
|
||||
int ChMask = OpCode.Read(31, 0xf);
|
||||
|
||||
TextureType TextureType = TexToTextureType(OpCode.Read(28, 6), IsArray);
|
||||
GalTextureTarget TextureType = TexToTextureType(OpCode.Read(28, 6), IsArray);
|
||||
|
||||
if (IsShadow)
|
||||
{
|
||||
|
@ -525,16 +525,16 @@ namespace Ryujinx.Graphics.Gal.Shader
|
|||
}
|
||||
|
||||
// TLD4S seems to only support 2D textures with RGBA mask?
|
||||
EmitTld4(Block, OpCode, TextureType.TwoD, Suffix, RGBA, OpCode.Read(0x34, 0x3), true);
|
||||
EmitTld4(Block, OpCode, GalTextureTarget.TwoD, Suffix, RGBA, OpCode.Read(0x34, 0x3), true);
|
||||
}
|
||||
|
||||
private static void EmitTexs(ShaderIrBlock Block,
|
||||
long OpCode,
|
||||
ShaderIrInst Inst,
|
||||
TextureType TextureType,
|
||||
GalTextureTarget TextureType,
|
||||
TextureInstructionSuffix TextureInstructionSuffix)
|
||||
{
|
||||
if (Inst == ShaderIrInst.Txlf && TextureType == TextureType.CubeArray)
|
||||
if (Inst == ShaderIrInst.Txlf && TextureType == GalTextureTarget.CubeArray)
|
||||
{
|
||||
throw new InvalidOperationException("TLDS instructions cannot use CUBE modifier!");
|
||||
}
|
||||
|
@ -597,7 +597,7 @@ namespace Ryujinx.Graphics.Gal.Shader
|
|||
// Encoding of TEXS/TLDS is a bit special and change for 2d textures
|
||||
// NOTE: OperA seems to hold at best two args.
|
||||
// On 2D textures, if no suffix need an additional values, Y is stored in OperB, otherwise coords are in OperA and the additional values is in OperB.
|
||||
if (TextureInstructionSuffix != TextureInstructionSuffix.None && TextureInstructionSuffix != TextureInstructionSuffix.LZ && TextureType == TextureType.TwoD)
|
||||
if (TextureInstructionSuffix != TextureInstructionSuffix.None && TextureInstructionSuffix != TextureInstructionSuffix.LZ && TextureType == GalTextureTarget.TwoD)
|
||||
{
|
||||
Coords[Coords.Length - CoordStartIndex - 1] = OpCode.Gpr8();
|
||||
Coords[Coords.Length - CoordStartIndex - 1].Index += Coords.Length - CoordStartIndex - 1;
|
||||
|
@ -719,7 +719,7 @@ namespace Ryujinx.Graphics.Gal.Shader
|
|||
}
|
||||
}
|
||||
|
||||
private static void EmitTld4(ShaderIrBlock Block, long OpCode, TextureType TextureType, TextureInstructionSuffix TextureInstructionSuffix, int ChMask, int Component, bool Scalar)
|
||||
private static void EmitTld4(ShaderIrBlock Block, long OpCode, GalTextureTarget TextureType, TextureInstructionSuffix TextureInstructionSuffix, int ChMask, int Component, bool Scalar)
|
||||
{
|
||||
ShaderIrOperGpr OperA = OpCode.Gpr8();
|
||||
ShaderIrOperGpr OperB = OpCode.Gpr20();
|
||||
|
@ -773,7 +773,7 @@ namespace Ryujinx.Graphics.Gal.Shader
|
|||
OperBIndex++;
|
||||
}
|
||||
|
||||
if (TextureInstructionSuffix != TextureInstructionSuffix.None && TextureType == TextureType.TwoD)
|
||||
if (TextureInstructionSuffix != TextureInstructionSuffix.None && TextureType == GalTextureTarget.TwoD)
|
||||
{
|
||||
Coords[Coords.Length - CoordStartIndex - 1] = OpCode.Gpr8();
|
||||
Coords[Coords.Length - CoordStartIndex - 1].Index += Coords.Length - CoordStartIndex - 1;
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace Ryujinx.Graphics.Gal.Shader
|
|||
class ShaderIrMetaTex : ShaderIrMeta
|
||||
{
|
||||
public int Elem { get; private set; }
|
||||
public TextureType TextureType { get; private set; }
|
||||
public GalTextureTarget TextureType { get; private set; }
|
||||
public ShaderIrNode[] Coordinates { get; private set; }
|
||||
public TextureInstructionSuffix TextureInstructionSuffix { get; private set; }
|
||||
public ShaderIrOperGpr LevelOfDetail;
|
||||
|
@ -13,7 +13,7 @@ namespace Ryujinx.Graphics.Gal.Shader
|
|||
public ShaderIrOperGpr DepthCompare;
|
||||
public int Component; // for TLD4(S)
|
||||
|
||||
public ShaderIrMetaTex(int Elem, TextureType TextureType, TextureInstructionSuffix TextureInstructionSuffix, params ShaderIrNode[] Coordinates)
|
||||
public ShaderIrMetaTex(int Elem, GalTextureTarget TextureType, TextureInstructionSuffix TextureInstructionSuffix, params ShaderIrNode[] Coordinates)
|
||||
{
|
||||
this.Elem = Elem;
|
||||
this.TextureType = TextureType;
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace Ryujinx.Graphics.Gal
|
|||
public int Cbuf { get; private set; }
|
||||
public int Size { get; private set; }
|
||||
|
||||
public TextureType TextureType { get; private set; }
|
||||
public GalTextureTarget TextureType { get; private set; }
|
||||
|
||||
public TextureInstructionSuffix TextureSuffix { get; private set; }
|
||||
|
||||
|
@ -21,7 +21,7 @@ namespace Ryujinx.Graphics.Gal
|
|||
bool IsCb = false,
|
||||
int Cbuf = 0,
|
||||
int Size = 1,
|
||||
TextureType TextureType = TextureType.TwoD,
|
||||
GalTextureTarget TextureType = GalTextureTarget.TwoD,
|
||||
TextureInstructionSuffix TextureSuffix = TextureInstructionSuffix.None)
|
||||
{
|
||||
this.Name = Name;
|
||||
|
|
|
@ -88,7 +88,7 @@ namespace Ryujinx.Graphics.Graphics3d
|
|||
SrcBlockHeight,
|
||||
SrcLayout,
|
||||
SrcImgFormat,
|
||||
TextureType.TwoD);
|
||||
GalTextureTarget.TwoD);
|
||||
|
||||
GalImage DstTexture = new GalImage(
|
||||
DstWidth,
|
||||
|
@ -96,7 +96,7 @@ namespace Ryujinx.Graphics.Graphics3d
|
|||
DstBlockHeight,
|
||||
DstLayout,
|
||||
DstImgFormat,
|
||||
TextureType.TwoD);
|
||||
GalTextureTarget.TwoD);
|
||||
|
||||
SrcTexture.Pitch = SrcPitch;
|
||||
DstTexture.Pitch = DstPitch;
|
||||
|
|
|
@ -208,7 +208,7 @@ namespace Ryujinx.Graphics.Graphics3d
|
|||
|
||||
GalImageFormat Format = ImageUtils.ConvertSurface((GalSurfaceFormat)SurfFormat);
|
||||
|
||||
GalImage Image = new GalImage(Width, Height, 1, 1, GobBlockHeight, Layout, Format, TextureType.TwoD);
|
||||
GalImage Image = new GalImage(Width, Height, 1, 1, GobBlockHeight, Layout, Format, GalTextureTarget.TwoD);
|
||||
|
||||
Gpu.ResourceManager.SendColorBuffer(Vmm, Key, FbIndex, Image);
|
||||
|
||||
|
@ -263,7 +263,7 @@ namespace Ryujinx.Graphics.Graphics3d
|
|||
GalImageFormat Format = ImageUtils.ConvertZeta((GalZetaFormat)ZetaFormat);
|
||||
|
||||
// TODO: Support non 2D?
|
||||
GalImage Image = new GalImage(Width, Height, 1, 1, GobBlockHeight, Layout, Format, TextureType.TwoD);
|
||||
GalImage Image = new GalImage(Width, Height, 1, 1, GobBlockHeight, Layout, Format, GalTextureTarget.TwoD);
|
||||
|
||||
Gpu.ResourceManager.SendZetaBuffer(Vmm, Key, Image);
|
||||
}
|
||||
|
|
|
@ -474,58 +474,58 @@ namespace Ryujinx.Graphics.Texture
|
|||
}
|
||||
}
|
||||
|
||||
public static TextureTarget GetTextureTarget(TextureType TextureType)
|
||||
public static TextureTarget GetTextureTarget(GalTextureTarget TextureType)
|
||||
{
|
||||
switch (TextureType)
|
||||
{
|
||||
case TextureType.OneD:
|
||||
case GalTextureTarget.OneD:
|
||||
return TextureTarget.Texture1D;
|
||||
case TextureType.TwoD:
|
||||
case TextureType.TwoDNoMipMap:
|
||||
case GalTextureTarget.TwoD:
|
||||
case GalTextureTarget.TwoDNoMipMap:
|
||||
return TextureTarget.Texture2D;
|
||||
case TextureType.ThreeD:
|
||||
case GalTextureTarget.ThreeD:
|
||||
return TextureTarget.Texture3D;
|
||||
case TextureType.OneDArray:
|
||||
case GalTextureTarget.OneDArray:
|
||||
return TextureTarget.Texture1DArray;
|
||||
case TextureType.TwoDArray:
|
||||
case GalTextureTarget.TwoDArray:
|
||||
return TextureTarget.Texture2DArray;
|
||||
case TextureType.CubeMap:
|
||||
case GalTextureTarget.CubeMap:
|
||||
return TextureTarget.TextureCubeMap;
|
||||
case TextureType.CubeArray:
|
||||
case GalTextureTarget.CubeArray:
|
||||
return TextureTarget.TextureCubeMapArray;
|
||||
default:
|
||||
throw new NotSupportedException($"Texture type {TextureType} currently not supported!");
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsArray(TextureType TextureType)
|
||||
public static bool IsArray(GalTextureTarget TextureType)
|
||||
{
|
||||
switch (TextureType)
|
||||
{
|
||||
case TextureType.OneDArray:
|
||||
case TextureType.TwoDArray:
|
||||
case TextureType.CubeArray:
|
||||
case GalTextureTarget.OneDArray:
|
||||
case GalTextureTarget.TwoDArray:
|
||||
case GalTextureTarget.CubeArray:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static int GetCoordsCountTextureType(TextureType TextureType)
|
||||
public static int GetCoordsCountTextureType(GalTextureTarget TextureType)
|
||||
{
|
||||
switch (TextureType)
|
||||
{
|
||||
case TextureType.OneD:
|
||||
case GalTextureTarget.OneD:
|
||||
return 1;
|
||||
case TextureType.OneDArray:
|
||||
case TextureType.TwoD:
|
||||
case TextureType.TwoDNoMipMap:
|
||||
case GalTextureTarget.OneDArray:
|
||||
case GalTextureTarget.TwoD:
|
||||
case GalTextureTarget.TwoDNoMipMap:
|
||||
return 2;
|
||||
case TextureType.ThreeD:
|
||||
case TextureType.TwoDArray:
|
||||
case TextureType.CubeMap:
|
||||
case GalTextureTarget.ThreeD:
|
||||
case GalTextureTarget.TwoDArray:
|
||||
case GalTextureTarget.CubeMap:
|
||||
return 3;
|
||||
case TextureType.CubeArray:
|
||||
case GalTextureTarget.CubeArray:
|
||||
return 4;
|
||||
default:
|
||||
throw new NotImplementedException($"TextureTpe.{TextureType} not implemented yet.");
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Graphics.Gal;
|
||||
using Ryujinx.Graphics.Memory;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Ryujinx.Graphics.Texture
|
||||
{
|
||||
|
@ -14,7 +12,7 @@ namespace Ryujinx.Graphics.Texture
|
|||
|
||||
GalImageFormat Format = GetImageFormat(Tic);
|
||||
|
||||
TextureType TextureType = (TextureType)((Tic[4] >> 23) & 0xF);
|
||||
GalTextureTarget TextureType = (GalTextureTarget)((Tic[4] >> 23) & 0xF);
|
||||
|
||||
GalTextureSource XSource = (GalTextureSource)((Tic[0] >> 19) & 7);
|
||||
GalTextureSource YSource = (GalTextureSource)((Tic[0] >> 22) & 7);
|
||||
|
@ -47,16 +45,16 @@ namespace Ryujinx.Graphics.Texture
|
|||
int Height = (Tic[5] & 0xffff) + 1;
|
||||
int Depth = ((Tic[5] >> 16) & 0x3fff) + 1;
|
||||
|
||||
if (TextureType == TextureType.OneD)
|
||||
if (TextureType == GalTextureTarget.OneD)
|
||||
{
|
||||
Height = 1;
|
||||
}
|
||||
|
||||
if (TextureType == TextureType.TwoD || TextureType == TextureType.OneD)
|
||||
if (TextureType == GalTextureTarget.TwoD || TextureType == GalTextureTarget.OneD)
|
||||
{
|
||||
Depth = 1;
|
||||
}
|
||||
else if (TextureType == TextureType.CubeMap)
|
||||
else if (TextureType == GalTextureTarget.CubeMap)
|
||||
{
|
||||
Depth = 6;
|
||||
}
|
||||
|
|
|
@ -220,7 +220,7 @@ namespace Ryujinx.Graphics.VDec
|
|||
OutputConfig.GobBlockHeight,
|
||||
GalMemoryLayout.BlockLinear,
|
||||
GalImageFormat.RGBA8 | GalImageFormat.Unorm,
|
||||
TextureType.TwoD);
|
||||
GalTextureTarget.TwoD);
|
||||
|
||||
ImageUtils.WriteTexture(Vmm, Image, Vmm.GetPhysicalAddress(OutputConfig.SurfaceLumaAddress), Frame.Data);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Graphics.Gal;
|
||||
using Ryujinx.Graphics.Memory;
|
||||
using Ryujinx.Graphics.Texture;
|
||||
using Ryujinx.HLE.HOS.Kernel;
|
||||
using Ryujinx.HLE.HOS.Kernel.Threading;
|
||||
using Ryujinx.HLE.HOS.Services.Nv.NvGpuAS;
|
||||
|
@ -420,7 +419,7 @@ namespace Ryujinx.HLE.HOS.Services.Android
|
|||
fbHeight, 1, 1, BlockHeight,
|
||||
GalMemoryLayout.BlockLinear,
|
||||
imageFormat,
|
||||
TextureType.TwoD);
|
||||
GalTextureTarget.TwoD);
|
||||
}
|
||||
|
||||
context.Device.Gpu.ResourceManager.ClearPbCache();
|
||||
|
|
Loading…
Add table
Reference in a new issue