Address feedback
This commit is contained in:
parent
41f13105f5
commit
43886472b6
8 changed files with 46 additions and 48 deletions
|
@ -242,7 +242,8 @@ namespace Ryujinx.Graphics.Gal
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Depth formats are easier to maintain so not false case, just return false
|
//Depth formats are fewer than colors, so it's harder to miss one
|
||||||
|
//Instead of checking for individual formats, return false
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ using System;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Gal.OpenGL
|
namespace Ryujinx.Graphics.Gal.OpenGL
|
||||||
{
|
{
|
||||||
class TCE
|
class ImageHandler
|
||||||
{
|
{
|
||||||
//TODO: Use a variable value here
|
//TODO: Use a variable value here
|
||||||
public const int MaxBpp = 16;
|
public const int MaxBpp = 16;
|
||||||
|
@ -13,9 +13,10 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||||
|
|
||||||
public GalImage Image { get; private set; }
|
public GalImage Image { get; private set; }
|
||||||
|
|
||||||
public int Width { get => Image.Width; }
|
public int Width => Image.Width;
|
||||||
public int Height { get => Image.Height; }
|
public int Height => Image.Height;
|
||||||
public GalImageFormat Format { get => Image.Format; }
|
|
||||||
|
public GalImageFormat Format => Image.Format;
|
||||||
|
|
||||||
public PixelInternalFormat InternalFormat { get; private set; }
|
public PixelInternalFormat InternalFormat { get; private set; }
|
||||||
public PixelFormat PixelFormat { get; private set; }
|
public PixelFormat PixelFormat { get; private set; }
|
||||||
|
@ -25,12 +26,12 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||||
|
|
||||||
private bool Initialized;
|
private bool Initialized;
|
||||||
|
|
||||||
public TCE()
|
public ImageHandler()
|
||||||
{
|
{
|
||||||
Handle = GL.GenTexture();
|
Handle = GL.GenTexture();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TCE(int Handle, GalImage Image)
|
public ImageHandler(int Handle, GalImage Image)
|
||||||
{
|
{
|
||||||
this.Handle = Handle;
|
this.Handle = Handle;
|
||||||
|
|
|
@ -40,8 +40,8 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||||
|
|
||||||
private OGLTexture Texture;
|
private OGLTexture Texture;
|
||||||
|
|
||||||
private TCE RawTex;
|
private ImageHandler RawTex;
|
||||||
private TCE ReadTex;
|
private ImageHandler ReadTex;
|
||||||
|
|
||||||
private Rect Viewport;
|
private Rect Viewport;
|
||||||
private Rect Window;
|
private Rect Window;
|
||||||
|
@ -77,7 +77,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||||
|
|
||||||
public void BindColor(long Key, int Attachment)
|
public void BindColor(long Key, int Attachment)
|
||||||
{
|
{
|
||||||
if (Texture.TryGetTCE(Key, out TCE Tex))
|
if (Texture.TryGetImage(Key, out ImageHandler Tex))
|
||||||
{
|
{
|
||||||
EnsureFrameBuffer();
|
EnsureFrameBuffer();
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||||
|
|
||||||
public void BindZeta(long Key)
|
public void BindZeta(long Key)
|
||||||
{
|
{
|
||||||
if (Texture.TryGetTCE(Key, out TCE Tex))
|
if (Texture.TryGetImage(Key, out ImageHandler Tex))
|
||||||
{
|
{
|
||||||
EnsureFrameBuffer();
|
EnsureFrameBuffer();
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||||
|
|
||||||
public void BindTexture(long Key, int Index)
|
public void BindTexture(long Key, int Index)
|
||||||
{
|
{
|
||||||
if (Texture.TryGetTCE(Key, out TCE Tex))
|
if (Texture.TryGetImage(Key, out ImageHandler Tex))
|
||||||
{
|
{
|
||||||
GL.ActiveTexture(TextureUnit.Texture0 + Index);
|
GL.ActiveTexture(TextureUnit.Texture0 + Index);
|
||||||
|
|
||||||
|
@ -172,7 +172,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||||
|
|
||||||
public void Set(long Key)
|
public void Set(long Key)
|
||||||
{
|
{
|
||||||
if (Texture.TryGetTCE(Key, out TCE Tex))
|
if (Texture.TryGetImage(Key, out ImageHandler Tex))
|
||||||
{
|
{
|
||||||
ReadTex = Tex;
|
ReadTex = Tex;
|
||||||
}
|
}
|
||||||
|
@ -182,7 +182,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||||
{
|
{
|
||||||
if (RawTex == null)
|
if (RawTex == null)
|
||||||
{
|
{
|
||||||
RawTex = new TCE();
|
RawTex = new ImageHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
RawTex.EnsureSetup(new GalImage(Width, Height, RawFormat));
|
RawTex.EnsureSetup(new GalImage(Width, Height, RawFormat));
|
||||||
|
@ -307,8 +307,8 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||||
int DstX1,
|
int DstX1,
|
||||||
int DstY1)
|
int DstY1)
|
||||||
{
|
{
|
||||||
if (Texture.TryGetTCE(SrcKey, out TCE SrcTex) &&
|
if (Texture.TryGetImage(SrcKey, out ImageHandler SrcTex) &&
|
||||||
Texture.TryGetTCE(DstKey, out TCE DstTex))
|
Texture.TryGetImage(DstKey, out ImageHandler DstTex))
|
||||||
{
|
{
|
||||||
if (SrcTex.HasColor != DstTex.HasColor ||
|
if (SrcTex.HasColor != DstTex.HasColor ||
|
||||||
SrcTex.HasDepth != DstTex.HasDepth ||
|
SrcTex.HasDepth != DstTex.HasDepth ||
|
||||||
|
@ -370,9 +370,9 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||||
|
|
||||||
public void GetBufferData(long Key, Action<byte[]> Callback)
|
public void GetBufferData(long Key, Action<byte[]> Callback)
|
||||||
{
|
{
|
||||||
if (Texture.TryGetTCE(Key, out TCE Tex))
|
if (Texture.TryGetImage(Key, out ImageHandler Tex))
|
||||||
{
|
{
|
||||||
byte[] Data = new byte[Tex.Width * Tex.Height * TCE.MaxBpp];
|
byte[] Data = new byte[Tex.Width * Tex.Height * ImageHandler.MaxBpp];
|
||||||
|
|
||||||
GL.BindTexture(TextureTarget.Texture2D, Tex.Handle);
|
GL.BindTexture(TextureTarget.Texture2D, Tex.Handle);
|
||||||
|
|
||||||
|
@ -393,7 +393,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||||
int Height,
|
int Height,
|
||||||
byte[] Buffer)
|
byte[] Buffer)
|
||||||
{
|
{
|
||||||
if (Texture.TryGetTCE(Key, out TCE Tex))
|
if (Texture.TryGetImage(Key, out ImageHandler Tex))
|
||||||
{
|
{
|
||||||
GL.BindTexture(TextureTarget.Texture2D, Tex.Handle);
|
GL.BindTexture(TextureTarget.Texture2D, Tex.Handle);
|
||||||
|
|
||||||
|
|
|
@ -6,11 +6,11 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||||
{
|
{
|
||||||
class OGLTexture : IGalTexture
|
class OGLTexture : IGalTexture
|
||||||
{
|
{
|
||||||
private OGLCachedResource<TCE> TextureCache;
|
private OGLCachedResource<ImageHandler> TextureCache;
|
||||||
|
|
||||||
public OGLTexture()
|
public OGLTexture()
|
||||||
{
|
{
|
||||||
TextureCache = new OGLCachedResource<TCE>(DeleteTexture);
|
TextureCache = new OGLCachedResource<ImageHandler>(DeleteTexture);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LockCache()
|
public void LockCache()
|
||||||
|
@ -23,16 +23,16 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||||
TextureCache.Unlock();
|
TextureCache.Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void DeleteTexture(TCE CachedTexture)
|
private static void DeleteTexture(ImageHandler CachedImage)
|
||||||
{
|
{
|
||||||
GL.DeleteTexture(CachedTexture.Handle);
|
GL.DeleteTexture(CachedImage.Handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Create(long Key, byte[] Data, GalImage Image)
|
public void Create(long Key, byte[] Data, GalImage Image)
|
||||||
{
|
{
|
||||||
int Handle = GL.GenTexture();
|
int Handle = GL.GenTexture();
|
||||||
|
|
||||||
TextureCache.AddOrUpdate(Key, new TCE(Handle, Image), (uint)Data.Length);
|
TextureCache.AddOrUpdate(Key, new ImageHandler(Handle, Image), (uint)Data.Length);
|
||||||
|
|
||||||
GL.BindTexture(TextureTarget.Texture2D, Handle);
|
GL.BindTexture(TextureTarget.Texture2D, Handle);
|
||||||
|
|
||||||
|
@ -97,24 +97,24 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||||
|
|
||||||
public void CreateFb(long Key, long Size, GalImage Image)
|
public void CreateFb(long Key, long Size, GalImage Image)
|
||||||
{
|
{
|
||||||
if (!TryGetTCE(Key, out TCE Texture))
|
if (!TryGetImage(Key, out ImageHandler CachedImage))
|
||||||
{
|
{
|
||||||
Texture = new TCE();
|
CachedImage = new ImageHandler();
|
||||||
|
|
||||||
TextureCache.AddOrUpdate(Key, Texture, Size);
|
TextureCache.AddOrUpdate(Key, CachedImage, Size);
|
||||||
}
|
}
|
||||||
|
|
||||||
Texture.EnsureSetup(Image);
|
CachedImage.EnsureSetup(Image);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool TryGetTCE(long Key, out TCE CachedTexture)
|
public bool TryGetImage(long Key, out ImageHandler CachedImage)
|
||||||
{
|
{
|
||||||
if (TextureCache.TryGetValue(Key, out CachedTexture))
|
if (TextureCache.TryGetValue(Key, out CachedImage))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
CachedTexture = null;
|
CachedImage = null;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -169,9 +169,9 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||||
{
|
{
|
||||||
if (TextureCache.TryGetSize(Key, out long Size) && Size == DataSize)
|
if (TextureCache.TryGetSize(Key, out long Size) && Size == DataSize)
|
||||||
{
|
{
|
||||||
if (TextureCache.TryGetValue(Key, out TCE CachedTexture))
|
if (TextureCache.TryGetValue(Key, out ImageHandler CachedImage))
|
||||||
{
|
{
|
||||||
Image = CachedTexture.Image;
|
Image = CachedImage.Image;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -184,11 +184,11 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||||
|
|
||||||
public void Bind(long Key, int Index)
|
public void Bind(long Key, int Index)
|
||||||
{
|
{
|
||||||
if (TextureCache.TryGetValue(Key, out TCE CachedTexture))
|
if (TextureCache.TryGetValue(Key, out ImageHandler CachedImage))
|
||||||
{
|
{
|
||||||
GL.ActiveTexture(TextureUnit.Texture0 + Index);
|
GL.ActiveTexture(TextureUnit.Texture0 + Index);
|
||||||
|
|
||||||
GL.BindTexture(TextureTarget.Texture2D, CachedTexture.Handle);
|
GL.BindTexture(TextureTarget.Texture2D, CachedImage.Handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -354,7 +354,7 @@ namespace Ryujinx.Graphics.Gal.Shader
|
||||||
}
|
}
|
||||||
else if (DeclInfo.Name.Contains(GlslDecl.FragmentOutputName))
|
else if (DeclInfo.Name.Contains(GlslDecl.FragmentOutputName))
|
||||||
{
|
{
|
||||||
Name = "layout (location = " + DeclInfo.Index / 4 + ") out vec4 " + DeclInfo.Name + Suffix + ";" + Environment.NewLine;
|
Name = "layout (location = " + DeclInfo.Index / 4 + ") out vec4 " + DeclInfo.Name + Suffix + ";";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,10 +13,6 @@
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<None Include="Gal\OpenGL\TCE.cs" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="OpenTK.NetStandard" Version="1.0.4" />
|
<PackageReference Include="OpenTK.NetStandard" Version="1.0.4" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
@ -181,11 +181,11 @@ namespace Ryujinx.HLE.Gpu.Engines
|
||||||
int Width = ReadRegister(NvGpuEngine3dReg.FrameBufferNWidth + FbIndex * 0x10);
|
int Width = ReadRegister(NvGpuEngine3dReg.FrameBufferNWidth + FbIndex * 0x10);
|
||||||
int Height = ReadRegister(NvGpuEngine3dReg.FrameBufferNHeight + FbIndex * 0x10);
|
int Height = ReadRegister(NvGpuEngine3dReg.FrameBufferNHeight + FbIndex * 0x10);
|
||||||
|
|
||||||
float TX = ReadRegisterFloat(NvGpuEngine3dReg.ViewportNTranslateX + FbIndex * 4);
|
float TX = ReadRegisterFloat(NvGpuEngine3dReg.ViewportNTranslateX + FbIndex * 8);
|
||||||
float TY = ReadRegisterFloat(NvGpuEngine3dReg.ViewportNTranslateY + FbIndex * 4);
|
float TY = ReadRegisterFloat(NvGpuEngine3dReg.ViewportNTranslateY + FbIndex * 8);
|
||||||
|
|
||||||
float SX = ReadRegisterFloat(NvGpuEngine3dReg.ViewportNScaleX + FbIndex * 4);
|
float SX = ReadRegisterFloat(NvGpuEngine3dReg.ViewportNScaleX + FbIndex * 8);
|
||||||
float SY = ReadRegisterFloat(NvGpuEngine3dReg.ViewportNScaleY + FbIndex * 4);
|
float SY = ReadRegisterFloat(NvGpuEngine3dReg.ViewportNScaleY + FbIndex * 8);
|
||||||
|
|
||||||
int VpX = (int)MathF.Max(0, TX - MathF.Abs(SX));
|
int VpX = (int)MathF.Max(0, TX - MathF.Abs(SX));
|
||||||
int VpY = (int)MathF.Max(0, TY - MathF.Abs(SY));
|
int VpY = (int)MathF.Max(0, TY - MathF.Abs(SY));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue