Proper cube map textures support + fix TEXS.LZ

This commit is contained in:
Thog 2018-11-22 16:16:17 +01:00
commit df99afeded
No known key found for this signature in database
GPG key ID: 0CD291558FAFDBC6
4 changed files with 38 additions and 9 deletions

View file

@ -47,7 +47,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL
const int Level = 0; //TODO: Support mipmap textures. const int Level = 0; //TODO: Support mipmap textures.
const int Border = 0; 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); 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 Level = 0; //TODO: Support mipmap textures.
const int Border = 0; 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); TextureCache.AddOrUpdate(Key, new ImageHandler(Handle, Image), (uint)Data.Length);
@ -153,6 +153,10 @@ namespace Ryujinx.Graphics.Gal.OpenGL
Data); Data);
break; break;
case TextureTarget.TextureCubeMap: case TextureTarget.TextureCubeMap:
Span<byte> Array = new Span<byte>(Data);
int FaceSize = ImageUtils.GetSize(Image) / Image.Depth;
for (int i = 0; i < 6; i++) for (int i = 0; i < 6; i++)
{ {
GL.CompressedTexImage2D( GL.CompressedTexImage2D(
@ -162,8 +166,8 @@ namespace Ryujinx.Graphics.Gal.OpenGL
Image.Width, Image.Width,
Image.Height, Image.Height,
Border, Border,
Data.Length, // FIXME: NOT SURE OF THIS FaceSize,
Data); Array.Slice(i * FaceSize, FaceSize).ToArray());
} }
break; break;
case TextureTarget.TextureCubeMapArray: case TextureTarget.TextureCubeMapArray:
@ -179,7 +183,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL
Data); Data);
break; break;
default: default:
Logger.PrintWarning(LogClass.Gpu, $"Unsupported texture target type: {Target} ({Image.Depth})"); Logger.PrintWarning(LogClass.Gpu, $"Unsupported texture target type: {Target}");
throw new InvalidOperationException(); throw new InvalidOperationException();
GL.CompressedTexImage2D( GL.CompressedTexImage2D(
TextureTarget.Texture2D, TextureTarget.Texture2D,
@ -247,6 +251,25 @@ namespace Ryujinx.Graphics.Gal.OpenGL
Type, Type,
Data); Data);
break; 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: default:
Logger.PrintWarning(LogClass.Gpu, $"Unsupported texture target type: {Target}"); Logger.PrintWarning(LogClass.Gpu, $"Unsupported texture target type: {Target}");
throw new InvalidOperationException(); throw new InvalidOperationException();

View file

@ -532,7 +532,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 && 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; Coords[Coords.Length - CoordStartIndex - 1].Index += Coords.Length - CoordStartIndex - 1;

View file

@ -243,7 +243,7 @@ namespace Ryujinx.Graphics.Texture
CpuMemory = (MemoryManager)Memory; 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); ISwizzle Swizzle = TextureHelper.GetSwizzle(Image);
@ -291,7 +291,7 @@ namespace Ryujinx.Graphics.Texture
int InOffs = 0; 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 Z = 0; Z < Depth; Z++)
for (int Y = 0; Y < Height; Y++) for (int Y = 0; Y < Height; Y++)

View file

@ -16,6 +16,8 @@ namespace Ryujinx.Graphics.Texture
TextureType TextureType = (TextureType)((Tic[4] >> 23) & 0xF); TextureType TextureType = (TextureType)((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);
GalTextureSource ZSource = (GalTextureSource)((Tic[0] >> 25) & 7); GalTextureSource ZSource = (GalTextureSource)((Tic[0] >> 25) & 7);
@ -56,6 +58,10 @@ namespace Ryujinx.Graphics.Texture
{ {
Depth = 1; Depth = 1;
} }
else if (TextureType == TextureType.CubeMap)
{
Depth = 6;
}
GalImage Image = new GalImage( GalImage Image = new GalImage(
Width, Width,