TextureType => GalTextureTarget

This commit is contained in:
Thog 2018-12-05 15:30:33 +01:00
commit c9b0ee8178
No known key found for this signature in database
GPG key ID: 0CD291558FAFDBC6
13 changed files with 68 additions and 73 deletions

View file

@ -18,7 +18,7 @@ namespace Ryujinx.Graphics.Gal
public GalTextureSource YSource; public GalTextureSource YSource;
public GalTextureSource ZSource; public GalTextureSource ZSource;
public GalTextureSource WSource; public GalTextureSource WSource;
public TextureType TextureType; public GalTextureTarget TextureType;
public GalImage( public GalImage(
int Width, int Width,
@ -28,7 +28,7 @@ namespace Ryujinx.Graphics.Gal
int GobBlockHeight, int GobBlockHeight,
GalMemoryLayout Layout, GalMemoryLayout Layout,
GalImageFormat Format, GalImageFormat Format,
TextureType TextureType, GalTextureTarget TextureType,
int MaxMipmapLevel = 1, int MaxMipmapLevel = 1,
GalTextureSource XSource = GalTextureSource.Red, GalTextureSource XSource = GalTextureSource.Red,
GalTextureSource YSource = GalTextureSource.Green, GalTextureSource YSource = GalTextureSource.Green,

View file

@ -1,6 +1,6 @@
namespace Ryujinx.Graphics.Texture namespace Ryujinx.Graphics.Gal
{ {
public enum TextureType public enum GalTextureTarget
{ {
OneD = 0, OneD = 0,
TwoD = 1, TwoD = 1,

View file

@ -1,8 +1,6 @@
using OpenTK.Graphics.OpenGL; using OpenTK.Graphics.OpenGL;
using Ryujinx.Common.Logging;
using Ryujinx.Graphics.Texture; using Ryujinx.Graphics.Texture;
using System; using System;
using System.Diagnostics;
namespace Ryujinx.Graphics.Gal.OpenGL namespace Ryujinx.Graphics.Gal.OpenGL
{ {

View file

@ -235,14 +235,14 @@ namespace Ryujinx.Graphics.Gal.Shader
string Name = StagePrefix + TextureName + Index; string Name = StagePrefix + TextureName + Index;
TextureType TextureType; GalTextureTarget TextureType;
TextureInstructionSuffix TextureInstructionSuffix; TextureInstructionSuffix TextureInstructionSuffix;
// TODO: Non 2D texture type for TEXQ? // TODO: Non 2D texture type for TEXQ?
if (Op.Inst == ShaderIrInst.Texq) if (Op.Inst == ShaderIrInst.Texq)
{ {
TextureType = TextureType.TwoD; TextureType = GalTextureTarget.TwoD;
TextureInstructionSuffix = TextureInstructionSuffix.None; TextureInstructionSuffix = TextureInstructionSuffix.None;
} }
else else

View file

@ -30,69 +30,69 @@ namespace Ryujinx.Graphics.Gal.Shader
{ RGB_, RG_A, R_BA, _GBA, RGBA, ____, ____, ____ } { 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) switch (TexType)
{ {
case 0: case 0:
return IsArray ? TextureType.OneDArray : TextureType.OneD; return IsArray ? GalTextureTarget.OneDArray : GalTextureTarget.OneD;
case 2: case 2:
return IsArray ? TextureType.TwoDArray : TextureType.TwoD; return IsArray ? GalTextureTarget.TwoDArray : GalTextureTarget.TwoD;
case 4: case 4:
if (IsArray) if (IsArray)
throw new InvalidOperationException($"ARRAY bit set on a TEX with 3D texture!"); throw new InvalidOperationException($"ARRAY bit set on a TEX with 3D texture!");
return TextureType.ThreeD; return GalTextureTarget.ThreeD;
case 6: case 6:
return IsArray ? TextureType.CubeArray : TextureType.CubeMap; return IsArray ? GalTextureTarget.CubeArray : GalTextureTarget.CubeMap;
default: default:
throw new InvalidOperationException(); throw new InvalidOperationException();
} }
} }
private static TextureType TexsToTextureType(int TexType) private static GalTextureTarget TexsToTextureType(int TexType)
{ {
switch (TexType) switch (TexType)
{ {
case 0: case 0:
return TextureType.OneD; return GalTextureTarget.OneD;
case 2: case 2:
case 4: case 4:
case 6: case 6:
case 8: case 8:
case 0xa: case 0xa:
case 0xc: case 0xc:
return TextureType.TwoD; return GalTextureTarget.TwoD;
case 0xe: case 0xe:
case 0x10: case 0x10:
case 0x12: case 0x12:
return TextureType.TwoDArray; return GalTextureTarget.TwoDArray;
case 0x14: case 0x14:
case 0x16: case 0x16:
return TextureType.ThreeD; return GalTextureTarget.ThreeD;
case 0x18: case 0x18:
case 0x1a: case 0x1a:
return TextureType.CubeMap; return GalTextureTarget.CubeMap;
default: default:
throw new InvalidOperationException(); throw new InvalidOperationException();
} }
} }
public static TextureType TldsToTextureType(int TexType) public static GalTextureTarget TldsToTextureType(int TexType)
{ {
switch (TexType) switch (TexType)
{ {
case 0: case 0:
case 2: case 2:
return TextureType.OneD; return GalTextureTarget.OneD;
case 4: case 4:
case 8: case 8:
case 0xa: case 0xa:
case 0xc: case 0xc:
return TextureType.TwoD; return GalTextureTarget.TwoD;
case 0x10: case 0x10:
return TextureType.TwoDArray; return GalTextureTarget.TwoDArray;
case 0xe: case 0xe:
return TextureType.ThreeD; return GalTextureTarget.ThreeD;
default: default:
throw new InvalidOperationException(); throw new InvalidOperationException();
} }
@ -279,7 +279,7 @@ namespace Ryujinx.Graphics.Gal.Shader
{ {
bool IsArray = OpCode.HasArray(); 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); bool HasDepthCompare = OpCode.Read(0x32);
@ -430,7 +430,7 @@ namespace Ryujinx.Graphics.Gal.Shader
throw new InvalidOperationException($"Invalid Suffix for TEXS instruction {RawSuffix}"); 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); 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}"); 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); EmitTexs(Block, OpCode, ShaderIrInst.Txlf, TextureType, Suffix);
} }
@ -497,7 +497,7 @@ namespace Ryujinx.Graphics.Gal.Shader
bool IsArray = OpCode.HasArray(); bool IsArray = OpCode.HasArray();
int ChMask = OpCode.Read(31, 0xf); int ChMask = OpCode.Read(31, 0xf);
TextureType TextureType = TexToTextureType(OpCode.Read(28, 6), IsArray); GalTextureTarget TextureType = TexToTextureType(OpCode.Read(28, 6), IsArray);
if (IsShadow) if (IsShadow)
{ {
@ -525,16 +525,16 @@ namespace Ryujinx.Graphics.Gal.Shader
} }
// TLD4S seems to only support 2D textures with RGBA mask? // 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, private static void EmitTexs(ShaderIrBlock Block,
long OpCode, long OpCode,
ShaderIrInst Inst, ShaderIrInst Inst,
TextureType TextureType, GalTextureTarget TextureType,
TextureInstructionSuffix TextureInstructionSuffix) 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!"); 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 // Encoding of TEXS/TLDS is a bit special and change for 2d textures
// NOTE: OperA seems to hold at best two args. // 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. // 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] = OpCode.Gpr8();
Coords[Coords.Length - CoordStartIndex - 1].Index += Coords.Length - CoordStartIndex - 1; 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 OperA = OpCode.Gpr8();
ShaderIrOperGpr OperB = OpCode.Gpr20(); ShaderIrOperGpr OperB = OpCode.Gpr20();
@ -773,7 +773,7 @@ namespace Ryujinx.Graphics.Gal.Shader
OperBIndex++; 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] = OpCode.Gpr8();
Coords[Coords.Length - CoordStartIndex - 1].Index += Coords.Length - CoordStartIndex - 1; Coords[Coords.Length - CoordStartIndex - 1].Index += Coords.Length - CoordStartIndex - 1;

View file

@ -5,7 +5,7 @@ namespace Ryujinx.Graphics.Gal.Shader
class ShaderIrMetaTex : ShaderIrMeta class ShaderIrMetaTex : ShaderIrMeta
{ {
public int Elem { get; private set; } 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 ShaderIrNode[] Coordinates { get; private set; }
public TextureInstructionSuffix TextureInstructionSuffix { get; private set; } public TextureInstructionSuffix TextureInstructionSuffix { get; private set; }
public ShaderIrOperGpr LevelOfDetail; public ShaderIrOperGpr LevelOfDetail;
@ -13,7 +13,7 @@ namespace Ryujinx.Graphics.Gal.Shader
public ShaderIrOperGpr DepthCompare; public ShaderIrOperGpr DepthCompare;
public int Component; // for TLD4(S) 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.Elem = Elem;
this.TextureType = TextureType; this.TextureType = TextureType;

View file

@ -11,7 +11,7 @@ namespace Ryujinx.Graphics.Gal
public int Cbuf { get; private set; } public int Cbuf { get; private set; }
public int Size { 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; } public TextureInstructionSuffix TextureSuffix { get; private set; }
@ -21,7 +21,7 @@ namespace Ryujinx.Graphics.Gal
bool IsCb = false, bool IsCb = false,
int Cbuf = 0, int Cbuf = 0,
int Size = 1, int Size = 1,
TextureType TextureType = TextureType.TwoD, GalTextureTarget TextureType = GalTextureTarget.TwoD,
TextureInstructionSuffix TextureSuffix = TextureInstructionSuffix.None) TextureInstructionSuffix TextureSuffix = TextureInstructionSuffix.None)
{ {
this.Name = Name; this.Name = Name;

View file

@ -88,7 +88,7 @@ namespace Ryujinx.Graphics.Graphics3d
SrcBlockHeight, SrcBlockHeight,
SrcLayout, SrcLayout,
SrcImgFormat, SrcImgFormat,
TextureType.TwoD); GalTextureTarget.TwoD);
GalImage DstTexture = new GalImage( GalImage DstTexture = new GalImage(
DstWidth, DstWidth,
@ -96,7 +96,7 @@ namespace Ryujinx.Graphics.Graphics3d
DstBlockHeight, DstBlockHeight,
DstLayout, DstLayout,
DstImgFormat, DstImgFormat,
TextureType.TwoD); GalTextureTarget.TwoD);
SrcTexture.Pitch = SrcPitch; SrcTexture.Pitch = SrcPitch;
DstTexture.Pitch = DstPitch; DstTexture.Pitch = DstPitch;

View file

@ -208,7 +208,7 @@ namespace Ryujinx.Graphics.Graphics3d
GalImageFormat Format = ImageUtils.ConvertSurface((GalSurfaceFormat)SurfFormat); 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); Gpu.ResourceManager.SendColorBuffer(Vmm, Key, FbIndex, Image);
@ -263,7 +263,7 @@ namespace Ryujinx.Graphics.Graphics3d
GalImageFormat Format = ImageUtils.ConvertZeta((GalZetaFormat)ZetaFormat); GalImageFormat Format = ImageUtils.ConvertZeta((GalZetaFormat)ZetaFormat);
// TODO: Support non 2D? // 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); Gpu.ResourceManager.SendZetaBuffer(Vmm, Key, Image);
} }

View file

@ -474,58 +474,58 @@ namespace Ryujinx.Graphics.Texture
} }
} }
public static TextureTarget GetTextureTarget(TextureType TextureType) public static TextureTarget GetTextureTarget(GalTextureTarget TextureType)
{ {
switch (TextureType) switch (TextureType)
{ {
case TextureType.OneD: case GalTextureTarget.OneD:
return TextureTarget.Texture1D; return TextureTarget.Texture1D;
case TextureType.TwoD: case GalTextureTarget.TwoD:
case TextureType.TwoDNoMipMap: case GalTextureTarget.TwoDNoMipMap:
return TextureTarget.Texture2D; return TextureTarget.Texture2D;
case TextureType.ThreeD: case GalTextureTarget.ThreeD:
return TextureTarget.Texture3D; return TextureTarget.Texture3D;
case TextureType.OneDArray: case GalTextureTarget.OneDArray:
return TextureTarget.Texture1DArray; return TextureTarget.Texture1DArray;
case TextureType.TwoDArray: case GalTextureTarget.TwoDArray:
return TextureTarget.Texture2DArray; return TextureTarget.Texture2DArray;
case TextureType.CubeMap: case GalTextureTarget.CubeMap:
return TextureTarget.TextureCubeMap; return TextureTarget.TextureCubeMap;
case TextureType.CubeArray: case GalTextureTarget.CubeArray:
return TextureTarget.TextureCubeMapArray; return TextureTarget.TextureCubeMapArray;
default: default:
throw new NotSupportedException($"Texture type {TextureType} currently not supported!"); throw new NotSupportedException($"Texture type {TextureType} currently not supported!");
} }
} }
public static bool IsArray(TextureType TextureType) public static bool IsArray(GalTextureTarget TextureType)
{ {
switch (TextureType) switch (TextureType)
{ {
case TextureType.OneDArray: case GalTextureTarget.OneDArray:
case TextureType.TwoDArray: case GalTextureTarget.TwoDArray:
case TextureType.CubeArray: case GalTextureTarget.CubeArray:
return true; return true;
default: default:
return false; return false;
} }
} }
public static int GetCoordsCountTextureType(TextureType TextureType) public static int GetCoordsCountTextureType(GalTextureTarget TextureType)
{ {
switch (TextureType) switch (TextureType)
{ {
case TextureType.OneD: case GalTextureTarget.OneD:
return 1; return 1;
case TextureType.OneDArray: case GalTextureTarget.OneDArray:
case TextureType.TwoD: case GalTextureTarget.TwoD:
case TextureType.TwoDNoMipMap: case GalTextureTarget.TwoDNoMipMap:
return 2; return 2;
case TextureType.ThreeD: case GalTextureTarget.ThreeD:
case TextureType.TwoDArray: case GalTextureTarget.TwoDArray:
case TextureType.CubeMap: case GalTextureTarget.CubeMap:
return 3; return 3;
case TextureType.CubeArray: case GalTextureTarget.CubeArray:
return 4; return 4;
default: default:
throw new NotImplementedException($"TextureTpe.{TextureType} not implemented yet."); throw new NotImplementedException($"TextureTpe.{TextureType} not implemented yet.");

View file

@ -1,8 +1,6 @@
using Ryujinx.Common.Logging;
using Ryujinx.Graphics.Gal; using Ryujinx.Graphics.Gal;
using Ryujinx.Graphics.Memory; using Ryujinx.Graphics.Memory;
using System; using System;
using System.Diagnostics;
namespace Ryujinx.Graphics.Texture namespace Ryujinx.Graphics.Texture
{ {
@ -14,7 +12,7 @@ namespace Ryujinx.Graphics.Texture
GalImageFormat Format = GetImageFormat(Tic); 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 XSource = (GalTextureSource)((Tic[0] >> 19) & 7);
GalTextureSource YSource = (GalTextureSource)((Tic[0] >> 22) & 7); GalTextureSource YSource = (GalTextureSource)((Tic[0] >> 22) & 7);
@ -47,16 +45,16 @@ namespace Ryujinx.Graphics.Texture
int Height = (Tic[5] & 0xffff) + 1; int Height = (Tic[5] & 0xffff) + 1;
int Depth = ((Tic[5] >> 16) & 0x3fff) + 1; int Depth = ((Tic[5] >> 16) & 0x3fff) + 1;
if (TextureType == TextureType.OneD) if (TextureType == GalTextureTarget.OneD)
{ {
Height = 1; Height = 1;
} }
if (TextureType == TextureType.TwoD || TextureType == TextureType.OneD) if (TextureType == GalTextureTarget.TwoD || TextureType == GalTextureTarget.OneD)
{ {
Depth = 1; Depth = 1;
} }
else if (TextureType == TextureType.CubeMap) else if (TextureType == GalTextureTarget.CubeMap)
{ {
Depth = 6; Depth = 6;
} }

View file

@ -220,7 +220,7 @@ namespace Ryujinx.Graphics.VDec
OutputConfig.GobBlockHeight, OutputConfig.GobBlockHeight,
GalMemoryLayout.BlockLinear, GalMemoryLayout.BlockLinear,
GalImageFormat.RGBA8 | GalImageFormat.Unorm, GalImageFormat.RGBA8 | GalImageFormat.Unorm,
TextureType.TwoD); GalTextureTarget.TwoD);
ImageUtils.WriteTexture(Vmm, Image, Vmm.GetPhysicalAddress(OutputConfig.SurfaceLumaAddress), Frame.Data); ImageUtils.WriteTexture(Vmm, Image, Vmm.GetPhysicalAddress(OutputConfig.SurfaceLumaAddress), Frame.Data);
} }

View file

@ -1,7 +1,6 @@
using Ryujinx.Common.Logging; using Ryujinx.Common.Logging;
using Ryujinx.Graphics.Gal; using Ryujinx.Graphics.Gal;
using Ryujinx.Graphics.Memory; using Ryujinx.Graphics.Memory;
using Ryujinx.Graphics.Texture;
using Ryujinx.HLE.HOS.Kernel; using Ryujinx.HLE.HOS.Kernel;
using Ryujinx.HLE.HOS.Kernel.Threading; using Ryujinx.HLE.HOS.Kernel.Threading;
using Ryujinx.HLE.HOS.Services.Nv.NvGpuAS; using Ryujinx.HLE.HOS.Services.Nv.NvGpuAS;
@ -420,7 +419,7 @@ namespace Ryujinx.HLE.HOS.Services.Android
fbHeight, 1, 1, BlockHeight, fbHeight, 1, 1, BlockHeight,
GalMemoryLayout.BlockLinear, GalMemoryLayout.BlockLinear,
imageFormat, imageFormat,
TextureType.TwoD); GalTextureTarget.TwoD);
} }
context.Device.Gpu.ResourceManager.ClearPbCache(); context.Device.Gpu.ResourceManager.ClearPbCache();