Start looking into cube map again

Also add some way to log write in register in engines
This commit is contained in:
Thog 2019-02-21 18:29:39 +01:00
parent e5bd32968e
commit 3a3062605c
No known key found for this signature in database
GPG key ID: 0CD291558FAFDBC6
9 changed files with 57 additions and 7 deletions

View file

@ -60,7 +60,7 @@ namespace Ryujinx.Graphics.Gal
Pitch = ImageUtils.GetPitch(Format, Width);
}
public bool SizeMatches(GalImage Image)
public bool SizeMatches(GalImage Image, bool IgnoreLayer = false)
{
if (ImageUtils.GetBytesPerPixel(Format) !=
ImageUtils.GetBytesPerPixel(Image.Format))
@ -74,7 +74,14 @@ namespace Ryujinx.Graphics.Gal
return false;
}
return Height == Image.Height && Depth == Image.Depth && LayerCount == Image.LayerCount;
bool Result = Height == Image.Height && Depth == Image.Depth;
if (!IgnoreLayer)
{
Result = Result && LayerCount == Image.LayerCount;
}
return Result;
}
}
}

View file

@ -258,6 +258,25 @@ namespace Ryujinx.Graphics.Gal.OpenGL
Type,
Data);
break;
case TextureTarget.TextureCubeMap:
Span<byte> Array = new Span<byte>(Data);
int FaceSize = ImageUtils.GetSize(Image) / 6;
for (int Face = 0; Face < 6; Face++)
{
GL.TexImage2D(
TextureTarget.TextureCubeMapPositiveX + Face,
Level,
InternalFmt,
Image.Width,
Image.Height,
Border,
Format,
Type,
Array.Slice(Face * FaceSize, FaceSize).ToArray());
}
break;
default:
throw new NotImplementedException($"Unsupported texture target type: {Target}");
}

View file

@ -241,6 +241,7 @@ namespace Ryujinx.Graphics.Graphics3d
private void WriteRegister(GpuMethodCall MethCall)
{
Registers[MethCall.Method] = MethCall.Argument;
Logger.PrintDebug(LogClass.Gpu, $"[2D] Writing to register {(NvGpuEngine2dReg)MethCall.Method} value {MethCall.Argument:x}");
}
private long ReadRegisterFixed1_31_32(NvGpuEngine2dReg Reg)

View file

@ -1,4 +1,5 @@
using Ryujinx.Common;
using Ryujinx.Common.Logging;
using Ryujinx.Graphics.Gal;
using Ryujinx.Graphics.Memory;
using Ryujinx.Graphics.Texture;
@ -188,6 +189,10 @@ namespace Ryujinx.Graphics.Graphics3d
int Width = ReadRegister(NvGpuEngine3dReg.FrameBufferNWidth + FbIndex * 0x10);
int Height = ReadRegister(NvGpuEngine3dReg.FrameBufferNHeight + FbIndex * 0x10);
int ArrayMode = ReadRegister(NvGpuEngine3dReg.FrameBufferNArrayMode + FbIndex * 0x10);
int LayerCount = ArrayMode & 0xFFFF;
int LayerStride = ReadRegister(NvGpuEngine3dReg.FrameBufferNLayerStride + FbIndex * 0x10);
int BaseLayer = ReadRegister(NvGpuEngine3dReg.FrameBufferNBaseLayer + FbIndex * 0x10);
int BlockDim = ReadRegister(NvGpuEngine3dReg.FrameBufferNBlockDim + FbIndex * 0x10);
int GobBlockHeight = 1 << ((BlockDim >> 4) & 7);
@ -1091,6 +1096,7 @@ namespace Ryujinx.Graphics.Graphics3d
private void WriteRegister(GpuMethodCall MethCall)
{
Registers[MethCall.Method] = MethCall.Argument;
Logger.PrintDebug(LogClass.Gpu, $"[3D] Writing to register {(NvGpuEngine3dReg)MethCall.Method} value {MethCall.Argument:x}");
}
private int ReadRegister(NvGpuEngine3dReg Reg)

View file

@ -7,6 +7,9 @@ namespace Ryujinx.Graphics.Graphics3d
FrameBufferNHeight = 0x203,
FrameBufferNFormat = 0x204,
FrameBufferNBlockDim = 0x205,
FrameBufferNArrayMode = 0x206,
FrameBufferNLayerStride = 0x207,
FrameBufferNBaseLayer = 0x208,
ViewportNScaleX = 0x280,
ViewportNScaleY = 0x281,
ViewportNScaleZ = 0x282,

View file

@ -1,3 +1,4 @@
using Ryujinx.Common.Logging;
using Ryujinx.Graphics.Memory;
using Ryujinx.Graphics.Texture;
using System.Collections.Generic;
@ -180,6 +181,7 @@ namespace Ryujinx.Graphics.Graphics3d
private void WriteRegister(GpuMethodCall MethCall)
{
Registers[MethCall.Method] = MethCall.Argument;
Logger.PrintWarning(LogClass.Gpu, $"[2D] Writing to register {(NvGpuEngine2dReg)MethCall.Method} value {MethCall.Argument:x}");
}
private int ReadRegister(NvGpuEngineM2mfReg Reg)

View file

@ -1,3 +1,4 @@
using Ryujinx.Common.Logging;
using Ryujinx.Graphics.Memory;
using Ryujinx.Graphics.Texture;
using System.Collections.Generic;
@ -149,6 +150,7 @@ namespace Ryujinx.Graphics.Graphics3d
private void WriteRegister(GpuMethodCall MethCall)
{
Registers[MethCall.Method] = MethCall.Argument;
Logger.PrintDebug(LogClass.Gpu, $"[M2MF] Writing to register {(NvGpuEngineM2mfReg)MethCall.Method} value {MethCall.Argument:x}");
}
private int ReadRegister(NvGpuEngineP2mfReg Reg)

View file

@ -362,11 +362,11 @@ namespace Ryujinx.Graphics.Texture
switch (ComponentCount)
{
case 1:
return Desc.BytesPerPixel * Width;
return Desc.BytesPerPixel * Width * Image.LayerCount;
case 2:
return Desc.BytesPerPixel * Width * Height;
return Desc.BytesPerPixel * Width * Height * Image.LayerCount;
case 3:
return Desc.BytesPerPixel * Width * Height * Depth;
return Desc.BytesPerPixel * Width * Height * Depth * Image.LayerCount;
default:
throw new InvalidOperationException($"Invalid component count: {ComponentCount}");
}
@ -511,6 +511,8 @@ namespace Ryujinx.Graphics.Texture
return TextureTarget.Texture3D;
case GalTextureTarget.OneDArray:
return TextureTarget.Texture1DArray;
case GalTextureTarget.OneDBuffer:
return TextureTarget.TextureBuffer;
case GalTextureTarget.TwoDArray:
return TextureTarget.Texture2DArray;
case GalTextureTarget.CubeMap:
@ -542,6 +544,7 @@ namespace Ryujinx.Graphics.Texture
case GalTextureTarget.OneD:
return 1;
case GalTextureTarget.OneDArray:
case GalTextureTarget.OneDBuffer:
case GalTextureTarget.TwoD:
case GalTextureTarget.TwoDNoMipMap:
return 2;

View file

@ -67,8 +67,15 @@ namespace Ryujinx.Graphics.Texture
}
else if (TextureTarget == GalTextureTarget.CubeMap)
{
// TODO: WRONG
Depth = 6;
// 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(