General cleanup

This commit is contained in:
Isaac Marovitz 2024-05-10 11:54:52 -04:00
parent 4ec9793602
commit ccb3b08333
No known key found for this signature in database
GPG key ID: 97250B2B09A132E1
10 changed files with 34 additions and 49 deletions

View file

@ -78,20 +78,18 @@ namespace Ryujinx.Graphics.OpenGL
{ {
return new PinnedSpan<byte>(IntPtr.Add(ptr, offset).ToPointer(), size); return new PinnedSpan<byte>(IntPtr.Add(ptr, offset).ToPointer(), size);
} }
else if (gd.Capabilities.UsePersistentBufferForFlush)
if (gd.Capabilities.UsePersistentBufferForFlush)
{ {
return PinnedSpan<byte>.UnsafeFromSpan(gd.PersistentBuffers.Default.GetBufferData(buffer, offset, size)); return PinnedSpan<byte>.UnsafeFromSpan(gd.PersistentBuffers.Default.GetBufferData(buffer, offset, size));
} }
else
{
IntPtr target = gd.PersistentBuffers.Default.GetHostArray(size);
gd.Api.BindBuffer(BufferTargetARB.CopyReadBuffer, buffer.ToUInt32()); IntPtr target = gd.PersistentBuffers.Default.GetHostArray(size);
gd.Api.GetBufferSubData(BufferTargetARB.CopyReadBuffer, offset, (uint)size, (void*)target); gd.Api.BindBuffer(BufferTargetARB.CopyReadBuffer, buffer.ToUInt32());
gd.Api.GetBufferSubData(BufferTargetARB.CopyReadBuffer, offset, (uint)size, (void*)target);
return new PinnedSpan<byte>(target.ToPointer(), size); return new PinnedSpan<byte>(target.ToPointer(), size);
}
} }
public static void Resize(GL api, BufferHandle handle, int size) public static void Resize(GL api, BufferHandle handle, int size)

View file

@ -28,18 +28,18 @@ namespace Ryujinx.Graphics.OpenGL
gl.Enable(EnableCap.DebugOutputSynchronous); gl.Enable(EnableCap.DebugOutputSynchronous);
if (logLevel == GraphicsDebugLevel.Error) switch (logLevel)
{ {
gl.DebugMessageControl(DebugSource.DontCare, DebugType.DebugTypeError, DebugSeverity.DontCare, 0, (uint[])null, true); case GraphicsDebugLevel.Error:
} gl.DebugMessageControl(DebugSource.DontCare, DebugType.DebugTypeError, DebugSeverity.DontCare, 0, (uint[])null, true);
else if (logLevel == GraphicsDebugLevel.Slowdowns) break;
{ case GraphicsDebugLevel.Slowdowns:
gl.DebugMessageControl(DebugSource.DontCare, DebugType.DebugTypeError, DebugSeverity.DontCare, 0, (uint[])null, true); gl.DebugMessageControl(DebugSource.DontCare, DebugType.DebugTypeError, DebugSeverity.DontCare, 0, (uint[])null, true);
gl.DebugMessageControl(DebugSource.DontCare, DebugType.DebugTypePerformance, DebugSeverity.DontCare, 0, (uint[])null, true); gl.DebugMessageControl(DebugSource.DontCare, DebugType.DebugTypePerformance, DebugSeverity.DontCare, 0, (uint[])null, true);
} break;
else default:
{ gl.DebugMessageControl(DebugSource.DontCare, DebugType.DontCare, DebugSeverity.DontCare, 0, (uint[])null, true);
gl.DebugMessageControl(DebugSource.DontCare, DebugType.DontCare, DebugSeverity.DontCare, 0, (uint[])null, true); break;
} }
_counter = 0; _counter = 0;

View file

@ -127,14 +127,13 @@ namespace Ryujinx.Graphics.OpenGL
{ {
return FramebufferAttachment.DepthStencilAttachment; return FramebufferAttachment.DepthStencilAttachment;
} }
else if (FormatTable.IsDepthOnly(format))
if (FormatTable.IsDepthOnly(format))
{ {
return FramebufferAttachment.DepthAttachment; return FramebufferAttachment.DepthAttachment;
} }
else
{ return FramebufferAttachment.StencilAttachment;
return FramebufferAttachment.StencilAttachment;
}
} }
public int GetColorLayerCount(int index) public int GetColorLayerCount(int index)

View file

@ -190,7 +190,7 @@ void main()
{ {
uint csHandle = _gd.Api.CreateShader(ShaderType.ComputeShader); uint csHandle = _gd.Api.CreateShader(ShaderType.ComputeShader);
string[] formatTable = new[] { "r8ui", "r16ui", "r32ui", "rg8ui", "rg16ui", "rg32ui", "rgba8ui", "rgba16ui", "rgba32ui" }; string[] formatTable = ["r8ui", "r16ui", "r32ui", "rg8ui", "rg16ui", "rg32ui", "rgba8ui", "rgba16ui", "rgba32ui"];
string srcFormat = formatTable[srcIndex]; string srcFormat = formatTable[srcIndex];
string dstFormat = formatTable[dstIndex]; string dstFormat = formatTable[dstIndex];

View file

@ -64,13 +64,13 @@ namespace Ryujinx.Graphics.OpenGL.Image
_gd.Api.BindTexture(target, Handle); _gd.Api.BindTexture(target, Handle);
int[] swizzleRgba = new int[] int[] swizzleRgba =
{ [
(int)Info.SwizzleR.Convert(), (int)Info.SwizzleR.Convert(),
(int)Info.SwizzleG.Convert(), (int)Info.SwizzleG.Convert(),
(int)Info.SwizzleB.Convert(), (int)Info.SwizzleB.Convert(),
(int)Info.SwizzleA.Convert(), (int)Info.SwizzleA.Convert()
}; ];
if (Info.Format == Format.A1B5G5R5Unorm) if (Info.Format == Format.A1B5G5R5Unorm)
{ {

View file

@ -76,13 +76,11 @@ namespace Ryujinx.Graphics.OpenGL
return handle; return handle;
} }
else
{ return Buffer.Create(Api, size);
return Buffer.Create(Api, size);
}
} }
public BufferHandle CreateBuffer(int size, GAL.BufferAccess access, BufferHandle storageHint) public BufferHandle CreateBuffer(int size, BufferAccess access, BufferHandle storageHint)
{ {
return CreateBuffer(size, access); return CreateBuffer(size, access);
} }
@ -118,10 +116,8 @@ namespace Ryujinx.Graphics.OpenGL
{ {
return new TextureBuffer(this, info); return new TextureBuffer(this, info);
} }
else
{ return ResourcePool.GetTextureOrNull(info) ?? new TextureStorage(this, info).CreateDefaultView();
return ResourcePool.GetTextureOrNull(info) ?? new TextureStorage(this, info).CreateDefaultView();
}
} }
public ITextureArray CreateTextureArray(int size, bool isBuffer) public ITextureArray CreateTextureArray(int size, bool isBuffer)

View file

@ -190,7 +190,7 @@ namespace Ryujinx.Graphics.OpenGL
Buffer.Copy(_api, vb.Buffer.Handle, tempVertexBuffer, vb.Buffer.Offset, currentTempVbOffset, vb.Buffer.Size); Buffer.Copy(_api, vb.Buffer.Handle, tempVertexBuffer, vb.Buffer.Offset, currentTempVbOffset, vb.Buffer.Size);
Buffer.Clear(_api, tempVertexBuffer, currentTempVbOffset + vb.Buffer.Size, (uint)(requiredSize - vb.Buffer.Size), 0); Buffer.Clear(_api, tempVertexBuffer, currentTempVbOffset + vb.Buffer.Size, (uint)(requiredSize - vb.Buffer.Size), 0);
_api.BindVertexBuffer((uint)vbIndex, tempVertexBuffer.ToUInt32(), (IntPtr)currentTempVbOffset, (uint)vb.Stride); _api.BindVertexBuffer((uint)vbIndex, tempVertexBuffer.ToUInt32(), currentTempVbOffset, (uint)vb.Stride);
currentTempVbOffset += requiredSize; currentTempVbOffset += requiredSize;
_vertexBuffersLimited |= 1u << vbIndex; _vertexBuffersLimited |= 1u << vbIndex;
@ -236,7 +236,7 @@ namespace Ryujinx.Graphics.OpenGL
ref var vb = ref _vertexBuffers[vbIndex]; ref var vb = ref _vertexBuffers[vbIndex];
_api.BindVertexBuffer((uint)vbIndex, vb.Buffer.Handle.ToUInt32(), (IntPtr)vb.Buffer.Offset, (uint)vb.Stride); _api.BindVertexBuffer((uint)vbIndex, vb.Buffer.Handle.ToUInt32(), vb.Buffer.Offset, (uint)vb.Stride);
buffersLimited &= ~(1u << vbIndex); buffersLimited &= ~(1u << vbIndex);
} }

View file

@ -83,7 +83,7 @@ namespace Ryujinx.Graphics.OpenGL
{ {
var swappedView = _gd.TextureCopy.BgraSwap(viewConverted); var swappedView = _gd.TextureCopy.BgraSwap(viewConverted);
viewConverted?.Dispose(); viewConverted.Dispose();
viewConverted = swappedView; viewConverted = swappedView;
} }

View file

@ -1,5 +1,4 @@
using Ryujinx.Graphics.OpenGL; using Ryujinx.Graphics.OpenGL;
using Silk.NET.OpenGL.Legacy;
using SPB.Graphics; using SPB.Graphics;
using SPB.Graphics.OpenGL; using SPB.Graphics.OpenGL;
using SPB.Platform; using SPB.Platform;
@ -38,9 +37,6 @@ namespace Ryujinx.UI
context.Initialize(window); context.Initialize(window);
context.MakeCurrent(window); context.MakeCurrent(window);
GL api = GL.GetApi(context.GetProcAddress);
context.MakeCurrent(null); context.MakeCurrent(null);
return new SPBOpenGLContext(context, window); return new SPBOpenGLContext(context, window);

View file

@ -1,5 +1,4 @@
using Ryujinx.Graphics.OpenGL; using Ryujinx.Graphics.OpenGL;
using Silk.NET.OpenGL.Legacy;
using SPB.Graphics; using SPB.Graphics;
using SPB.Graphics.OpenGL; using SPB.Graphics.OpenGL;
using SPB.Platform; using SPB.Platform;
@ -38,9 +37,6 @@ namespace Ryujinx.Ava.UI.Renderer
context.Initialize(window); context.Initialize(window);
context.MakeCurrent(window); context.MakeCurrent(window);
GL api = GL.GetApi(context.GetProcAddress);
context.MakeCurrent(null); context.MakeCurrent(null);
return new SPBOpenGLContext(context, window); return new SPBOpenGLContext(context, window);