Proper cube map textures support + fix TEXS.LZ
This commit is contained in:
parent
5f0da0245e
commit
df99afeded
4 changed files with 38 additions and 9 deletions
|
@ -47,7 +47,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
|||
const int Level = 0; //TODO: Support mipmap textures.
|
||||
const int Border = 0;
|
||||
|
||||
Debug.Assert(Image.MaxMipmapLevel != 1, "No Mipmap support");
|
||||
//Debug.Assert(Image.MaxMipmapLevel != 1, "No Mipmap support");
|
||||
|
||||
TextureCache.AddOrUpdate(Key, new ImageHandler(Handle, Image), (uint)Size);
|
||||
|
||||
|
@ -118,7 +118,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
|||
const int Level = 0; //TODO: Support mipmap textures.
|
||||
const int Border = 0;
|
||||
|
||||
Debug.Assert(Image.MaxMipmapLevel != 1, "No Mipmap support");
|
||||
//Debug.Assert(Image.MaxMipmapLevel != 1, "No Mipmap support");
|
||||
|
||||
TextureCache.AddOrUpdate(Key, new ImageHandler(Handle, Image), (uint)Data.Length);
|
||||
|
||||
|
@ -153,6 +153,10 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
|||
Data);
|
||||
break;
|
||||
case TextureTarget.TextureCubeMap:
|
||||
Span<byte> Array = new Span<byte>(Data);
|
||||
|
||||
int FaceSize = ImageUtils.GetSize(Image) / Image.Depth;
|
||||
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
GL.CompressedTexImage2D(
|
||||
|
@ -162,8 +166,8 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
|||
Image.Width,
|
||||
Image.Height,
|
||||
Border,
|
||||
Data.Length, // FIXME: NOT SURE OF THIS
|
||||
Data);
|
||||
FaceSize,
|
||||
Array.Slice(i * FaceSize, FaceSize).ToArray());
|
||||
}
|
||||
break;
|
||||
case TextureTarget.TextureCubeMapArray:
|
||||
|
@ -179,7 +183,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
|||
Data);
|
||||
break;
|
||||
default:
|
||||
Logger.PrintWarning(LogClass.Gpu, $"Unsupported texture target type: {Target} ({Image.Depth})");
|
||||
Logger.PrintWarning(LogClass.Gpu, $"Unsupported texture target type: {Target}");
|
||||
throw new InvalidOperationException();
|
||||
GL.CompressedTexImage2D(
|
||||
TextureTarget.Texture2D,
|
||||
|
@ -247,6 +251,25 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
|||
Type,
|
||||
Data);
|
||||
break;
|
||||
case TextureTarget.TextureCubeMap:
|
||||
Span<byte> Array = new Span<byte>(Data);
|
||||
|
||||
int FaceSize = ImageUtils.GetSize(Image) / Image.Depth;
|
||||
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
GL.TexImage2D(
|
||||
TextureTarget.TextureCubeMapPositiveX + i,
|
||||
Level,
|
||||
InternalFmt,
|
||||
Image.Width,
|
||||
Image.Height,
|
||||
Border,
|
||||
Format,
|
||||
Type,
|
||||
Array.Slice(i * FaceSize, FaceSize).ToArray());
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Logger.PrintWarning(LogClass.Gpu, $"Unsupported texture target type: {Target}");
|
||||
throw new InvalidOperationException();
|
||||
|
|
|
@ -532,9 +532,9 @@ 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 && TextureType == TextureType.TwoD)
|
||||
if (TextureInstructionSuffix != TextureInstructionSuffix.None && TextureInstructionSuffix != TextureInstructionSuffix.LZ && TextureType == TextureType.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;
|
||||
OperBIndex--;
|
||||
}
|
||||
|
|
|
@ -243,7 +243,7 @@ namespace Ryujinx.Graphics.Texture
|
|||
CpuMemory = (MemoryManager)Memory;
|
||||
}
|
||||
|
||||
Debug.Assert(Image.TextureType == TextureType.TwoD, "non 2d texture read");
|
||||
//Debug.Assert(Image.TextureType == TextureType.TwoD, "non 2d texture read");
|
||||
|
||||
ISwizzle Swizzle = TextureHelper.GetSwizzle(Image);
|
||||
|
||||
|
@ -291,7 +291,7 @@ namespace Ryujinx.Graphics.Texture
|
|||
|
||||
int InOffs = 0;
|
||||
|
||||
Debug.Assert(Image.TextureType == TextureType.TwoD, "non 2d texture write");
|
||||
//Debug.Assert(Image.TextureType == TextureType.TwoD, "non 2d texture write");
|
||||
|
||||
for (int Z = 0; Z < Depth; Z++)
|
||||
for (int Y = 0; Y < Height; Y++)
|
||||
|
|
|
@ -16,6 +16,8 @@ namespace Ryujinx.Graphics.Texture
|
|||
|
||||
TextureType TextureType = (TextureType)((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);
|
||||
|
@ -56,6 +58,10 @@ namespace Ryujinx.Graphics.Texture
|
|||
{
|
||||
Depth = 1;
|
||||
}
|
||||
else if (TextureType == TextureType.CubeMap)
|
||||
{
|
||||
Depth = 6;
|
||||
}
|
||||
|
||||
GalImage Image = new GalImage(
|
||||
Width,
|
||||
|
|
Loading…
Add table
Reference in a new issue