Address feedback
This commit is contained in:
parent
41f13105f5
commit
43886472b6
8 changed files with 46 additions and 48 deletions
|
@ -9,7 +9,7 @@
|
|||
RGBA32Uint = 0xc2,
|
||||
RGBX32Float = 0xc3,
|
||||
RGBX32Sint = 0xc4,
|
||||
RGBX32Uint = 0xc5,
|
||||
RGBX32Uint = 0xc5,
|
||||
RGBA16Unorm = 0xc6,
|
||||
RGBA16Snorm = 0xc7,
|
||||
RGBA16Sint = 0xc8,
|
||||
|
|
|
@ -242,7 +242,8 @@ namespace Ryujinx.Graphics.Gal
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ using System;
|
|||
|
||||
namespace Ryujinx.Graphics.Gal.OpenGL
|
||||
{
|
||||
class TCE
|
||||
class ImageHandler
|
||||
{
|
||||
//TODO: Use a variable value here
|
||||
public const int MaxBpp = 16;
|
||||
|
@ -13,24 +13,25 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
|||
|
||||
public GalImage Image { get; private set; }
|
||||
|
||||
public int Width { get => Image.Width; }
|
||||
public int Height { get => Image.Height; }
|
||||
public GalImageFormat Format { get => Image.Format; }
|
||||
public int Width => Image.Width;
|
||||
public int Height => Image.Height;
|
||||
|
||||
public GalImageFormat Format => Image.Format;
|
||||
|
||||
public PixelInternalFormat InternalFormat { get; private set; }
|
||||
public PixelFormat PixelFormat { get; private set; }
|
||||
public PixelType PixelType { get; private set; }
|
||||
public PixelFormat PixelFormat { get; private set; }
|
||||
public PixelType PixelType { get; private set; }
|
||||
|
||||
public int Handle { get; private set; }
|
||||
|
||||
private bool Initialized;
|
||||
|
||||
public TCE()
|
||||
public ImageHandler()
|
||||
{
|
||||
Handle = GL.GenTexture();
|
||||
}
|
||||
|
||||
public TCE(int Handle, GalImage Image)
|
||||
public ImageHandler(int Handle, GalImage Image)
|
||||
{
|
||||
this.Handle = Handle;
|
||||
|
|
@ -40,8 +40,8 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
|||
|
||||
private OGLTexture Texture;
|
||||
|
||||
private TCE RawTex;
|
||||
private TCE ReadTex;
|
||||
private ImageHandler RawTex;
|
||||
private ImageHandler ReadTex;
|
||||
|
||||
private Rect Viewport;
|
||||
private Rect Window;
|
||||
|
@ -77,7 +77,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
|||
|
||||
public void BindColor(long Key, int Attachment)
|
||||
{
|
||||
if (Texture.TryGetTCE(Key, out TCE Tex))
|
||||
if (Texture.TryGetImage(Key, out ImageHandler Tex))
|
||||
{
|
||||
EnsureFrameBuffer();
|
||||
|
||||
|
@ -98,7 +98,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
|||
|
||||
public void BindZeta(long Key)
|
||||
{
|
||||
if (Texture.TryGetTCE(Key, out TCE Tex))
|
||||
if (Texture.TryGetImage(Key, out ImageHandler Tex))
|
||||
{
|
||||
EnsureFrameBuffer();
|
||||
|
||||
|
@ -162,7 +162,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
|||
|
||||
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);
|
||||
|
||||
|
@ -172,7 +172,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
|||
|
||||
public void Set(long Key)
|
||||
{
|
||||
if (Texture.TryGetTCE(Key, out TCE Tex))
|
||||
if (Texture.TryGetImage(Key, out ImageHandler Tex))
|
||||
{
|
||||
ReadTex = Tex;
|
||||
}
|
||||
|
@ -182,7 +182,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
|||
{
|
||||
if (RawTex == null)
|
||||
{
|
||||
RawTex = new TCE();
|
||||
RawTex = new ImageHandler();
|
||||
}
|
||||
|
||||
RawTex.EnsureSetup(new GalImage(Width, Height, RawFormat));
|
||||
|
@ -307,8 +307,8 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
|||
int DstX1,
|
||||
int DstY1)
|
||||
{
|
||||
if (Texture.TryGetTCE(SrcKey, out TCE SrcTex) &&
|
||||
Texture.TryGetTCE(DstKey, out TCE DstTex))
|
||||
if (Texture.TryGetImage(SrcKey, out ImageHandler SrcTex) &&
|
||||
Texture.TryGetImage(DstKey, out ImageHandler DstTex))
|
||||
{
|
||||
if (SrcTex.HasColor != DstTex.HasColor ||
|
||||
SrcTex.HasDepth != DstTex.HasDepth ||
|
||||
|
@ -370,9 +370,9 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
|||
|
||||
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);
|
||||
|
||||
|
@ -393,7 +393,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
|||
int Height,
|
||||
byte[] Buffer)
|
||||
{
|
||||
if (Texture.TryGetTCE(Key, out TCE Tex))
|
||||
if (Texture.TryGetImage(Key, out ImageHandler Tex))
|
||||
{
|
||||
GL.BindTexture(TextureTarget.Texture2D, Tex.Handle);
|
||||
|
||||
|
|
|
@ -6,11 +6,11 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
|||
{
|
||||
class OGLTexture : IGalTexture
|
||||
{
|
||||
private OGLCachedResource<TCE> TextureCache;
|
||||
private OGLCachedResource<ImageHandler> TextureCache;
|
||||
|
||||
public OGLTexture()
|
||||
{
|
||||
TextureCache = new OGLCachedResource<TCE>(DeleteTexture);
|
||||
TextureCache = new OGLCachedResource<ImageHandler>(DeleteTexture);
|
||||
}
|
||||
|
||||
public void LockCache()
|
||||
|
@ -23,16 +23,16 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
|||
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)
|
||||
{
|
||||
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);
|
||||
|
||||
|
@ -97,24 +97,24 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
|||
|
||||
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;
|
||||
}
|
||||
|
||||
CachedTexture = null;
|
||||
CachedImage = null;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -169,9 +169,9 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
|||
{
|
||||
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;
|
||||
}
|
||||
|
@ -184,11 +184,11 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
|||
|
||||
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.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))
|
||||
{
|
||||
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
|
||||
{
|
||||
|
|
|
@ -13,10 +13,6 @@
|
|||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="Gal\OpenGL\TCE.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="OpenTK.NetStandard" Version="1.0.4" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -180,12 +180,12 @@ namespace Ryujinx.HLE.Gpu.Engines
|
|||
|
||||
int Width = ReadRegister(NvGpuEngine3dReg.FrameBufferNWidth + FbIndex * 0x10);
|
||||
int Height = ReadRegister(NvGpuEngine3dReg.FrameBufferNHeight + FbIndex * 0x10);
|
||||
|
||||
float TX = ReadRegisterFloat(NvGpuEngine3dReg.ViewportNTranslateX + FbIndex * 4);
|
||||
float TY = ReadRegisterFloat(NvGpuEngine3dReg.ViewportNTranslateY + FbIndex * 4);
|
||||
|
||||
float SX = ReadRegisterFloat(NvGpuEngine3dReg.ViewportNScaleX + FbIndex * 4);
|
||||
float SY = ReadRegisterFloat(NvGpuEngine3dReg.ViewportNScaleY + FbIndex * 4);
|
||||
float TX = ReadRegisterFloat(NvGpuEngine3dReg.ViewportNTranslateX + FbIndex * 8);
|
||||
float TY = ReadRegisterFloat(NvGpuEngine3dReg.ViewportNTranslateY + FbIndex * 8);
|
||||
|
||||
float SX = ReadRegisterFloat(NvGpuEngine3dReg.ViewportNScaleX + FbIndex * 8);
|
||||
float SY = ReadRegisterFloat(NvGpuEngine3dReg.ViewportNScaleY + FbIndex * 8);
|
||||
|
||||
int VpX = (int)MathF.Max(0, TX - MathF.Abs(SX));
|
||||
int VpY = (int)MathF.Max(0, TY - MathF.Abs(SY));
|
||||
|
|
Loading…
Add table
Reference in a new issue