mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-07-27 21:07:26 +02:00
chore: converted BufferHandle ToInt32 extension to an implicit int operator on BufferHandle directly.
This commit is contained in:
parent
15881cb385
commit
d60914ecec
8 changed files with 29 additions and 32 deletions
|
@ -1,3 +1,4 @@
|
|||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Ryujinx.Graphics.GAL
|
||||
|
@ -10,5 +11,7 @@ namespace Ryujinx.Graphics.GAL
|
|||
public static BufferHandle Null => new(0);
|
||||
|
||||
private BufferHandle(ulong value) => _value = value;
|
||||
|
||||
public static implicit operator int(BufferHandle handle) => (int)Unsafe.As<BufferHandle, ulong>(ref handle);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace Ryujinx.Graphics.OpenGL
|
|||
{
|
||||
public static void Clear(BufferHandle destination, int offset, int size, uint value)
|
||||
{
|
||||
GL.BindBuffer(BufferTarget.CopyWriteBuffer, destination.ToInt32());
|
||||
GL.BindBuffer(BufferTarget.CopyWriteBuffer, destination);
|
||||
|
||||
unsafe
|
||||
{
|
||||
|
@ -58,8 +58,8 @@ namespace Ryujinx.Graphics.OpenGL
|
|||
|
||||
public static void Copy(BufferHandle source, BufferHandle destination, int srcOffset, int dstOffset, int size)
|
||||
{
|
||||
GL.BindBuffer(BufferTarget.CopyReadBuffer, source.ToInt32());
|
||||
GL.BindBuffer(BufferTarget.CopyWriteBuffer, destination.ToInt32());
|
||||
GL.BindBuffer(BufferTarget.CopyReadBuffer, source);
|
||||
GL.BindBuffer(BufferTarget.CopyWriteBuffer, destination);
|
||||
|
||||
GL.CopyBufferSubData(
|
||||
BufferTarget.CopyReadBuffer,
|
||||
|
@ -86,7 +86,7 @@ namespace Ryujinx.Graphics.OpenGL
|
|||
{
|
||||
nint target = renderer.PersistentBuffers.Default.GetHostArray(size);
|
||||
|
||||
GL.BindBuffer(BufferTarget.CopyReadBuffer, buffer.ToInt32());
|
||||
GL.BindBuffer(BufferTarget.CopyReadBuffer, buffer);
|
||||
|
||||
GL.GetBufferSubData(BufferTarget.CopyReadBuffer, (nint)offset, size, target);
|
||||
|
||||
|
@ -96,13 +96,13 @@ namespace Ryujinx.Graphics.OpenGL
|
|||
|
||||
public static void Resize(BufferHandle handle, int size)
|
||||
{
|
||||
GL.BindBuffer(BufferTarget.CopyWriteBuffer, handle.ToInt32());
|
||||
GL.BindBuffer(BufferTarget.CopyWriteBuffer, handle);
|
||||
GL.BufferData(BufferTarget.CopyWriteBuffer, size, nint.Zero, BufferUsageHint.StreamCopy);
|
||||
}
|
||||
|
||||
public static void SetData(BufferHandle buffer, int offset, ReadOnlySpan<byte> data)
|
||||
{
|
||||
GL.BindBuffer(BufferTarget.CopyWriteBuffer, buffer.ToInt32());
|
||||
GL.BindBuffer(BufferTarget.CopyWriteBuffer, buffer);
|
||||
|
||||
unsafe
|
||||
{
|
||||
|
@ -115,7 +115,7 @@ namespace Ryujinx.Graphics.OpenGL
|
|||
|
||||
public static void Delete(BufferHandle buffer)
|
||||
{
|
||||
GL.DeleteBuffer(buffer.ToInt32());
|
||||
GL.DeleteBuffer(buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
using Ryujinx.Graphics.GAL;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
|
@ -14,10 +13,5 @@ namespace Ryujinx.Graphics.OpenGL
|
|||
|
||||
return Unsafe.As<ulong, T>(ref handle64);
|
||||
}
|
||||
|
||||
public static int ToInt32(this BufferHandle handle)
|
||||
{
|
||||
return (int)Unsafe.As<BufferHandle, ulong>(ref handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -97,7 +97,7 @@ namespace Ryujinx.Graphics.OpenGL.Image
|
|||
|
||||
SizedInternalFormat format = (SizedInternalFormat)FormatTable.GetFormatInfo(Info.Format).PixelInternalFormat;
|
||||
|
||||
GL.TexBufferRange(TextureBufferTarget.TextureBuffer, format, _buffer.ToInt32(), (nint)buffer.Offset, buffer.Size);
|
||||
GL.TexBufferRange(TextureBufferTarget.TextureBuffer, format, _buffer, (nint)buffer.Offset, buffer.Size);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
|
|
@ -320,7 +320,7 @@ namespace Ryujinx.Graphics.OpenGL.Image
|
|||
throw new NotSupportedException("Stride conversion for texture copy to buffer not supported.");
|
||||
}
|
||||
|
||||
GL.BindBuffer(BufferTarget.PixelPackBuffer, range.Handle.ToInt32());
|
||||
GL.BindBuffer(BufferTarget.PixelPackBuffer, range.Handle);
|
||||
|
||||
FormatInfo format = FormatTable.GetFormatInfo(Info.Format);
|
||||
if (format.PixelFormat == PixelFormat.DepthStencil)
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace Ryujinx.Graphics.OpenGL
|
|||
|
||||
public void Map(BufferHandle handle, int size)
|
||||
{
|
||||
GL.BindBuffer(BufferTarget.CopyWriteBuffer, handle.ToInt32());
|
||||
GL.BindBuffer(BufferTarget.CopyWriteBuffer, handle);
|
||||
nint ptr = GL.MapBufferRange(BufferTarget.CopyWriteBuffer, nint.Zero, size, BufferAccessMask.MapReadBit | BufferAccessMask.MapPersistentBit);
|
||||
|
||||
_maps[handle] = ptr;
|
||||
|
@ -36,7 +36,7 @@ namespace Ryujinx.Graphics.OpenGL
|
|||
{
|
||||
if (_maps.ContainsKey(handle))
|
||||
{
|
||||
GL.BindBuffer(BufferTarget.CopyWriteBuffer, handle.ToInt32());
|
||||
GL.BindBuffer(BufferTarget.CopyWriteBuffer, handle);
|
||||
GL.UnmapBuffer(BufferTarget.CopyWriteBuffer);
|
||||
|
||||
_maps.Remove(handle);
|
||||
|
@ -140,7 +140,7 @@ namespace Ryujinx.Graphics.OpenGL
|
|||
{
|
||||
EnsureBuffer(size);
|
||||
|
||||
GL.BindBuffer(BufferTarget.CopyReadBuffer, buffer.ToInt32());
|
||||
GL.BindBuffer(BufferTarget.CopyReadBuffer, buffer);
|
||||
GL.BindBuffer(BufferTarget.CopyWriteBuffer, _copyBufferHandle);
|
||||
|
||||
GL.CopyBufferSubData(BufferTarget.CopyReadBuffer, BufferTarget.CopyWriteBuffer, (nint)offset, nint.Zero, size);
|
||||
|
|
|
@ -587,7 +587,7 @@ namespace Ryujinx.Graphics.OpenGL
|
|||
|
||||
_vertexArray.SetRangeOfIndexBuffer();
|
||||
|
||||
GL.BindBuffer((BufferTarget)All.DrawIndirectBuffer, indirectBuffer.Handle.ToInt32());
|
||||
GL.BindBuffer((BufferTarget)All.DrawIndirectBuffer, indirectBuffer.Handle);
|
||||
|
||||
GL.DrawElementsIndirect(_primitiveType, _elementsType, (nint)indirectBuffer.Offset);
|
||||
|
||||
|
@ -608,8 +608,8 @@ namespace Ryujinx.Graphics.OpenGL
|
|||
|
||||
_vertexArray.SetRangeOfIndexBuffer();
|
||||
|
||||
GL.BindBuffer((BufferTarget)All.DrawIndirectBuffer, indirectBuffer.Handle.ToInt32());
|
||||
GL.BindBuffer((BufferTarget)All.ParameterBuffer, parameterBuffer.Handle.ToInt32());
|
||||
GL.BindBuffer((BufferTarget)All.DrawIndirectBuffer, indirectBuffer.Handle);
|
||||
GL.BindBuffer((BufferTarget)All.ParameterBuffer, parameterBuffer.Handle);
|
||||
|
||||
GL.MultiDrawElementsIndirectCount(
|
||||
_primitiveType,
|
||||
|
@ -634,7 +634,7 @@ namespace Ryujinx.Graphics.OpenGL
|
|||
|
||||
PreDrawVbUnbounded();
|
||||
|
||||
GL.BindBuffer((BufferTarget)All.DrawIndirectBuffer, indirectBuffer.Handle.ToInt32());
|
||||
GL.BindBuffer((BufferTarget)All.DrawIndirectBuffer, indirectBuffer.Handle);
|
||||
|
||||
GL.DrawArraysIndirect(_primitiveType, (nint)indirectBuffer.Offset);
|
||||
|
||||
|
@ -651,8 +651,8 @@ namespace Ryujinx.Graphics.OpenGL
|
|||
|
||||
PreDrawVbUnbounded();
|
||||
|
||||
GL.BindBuffer((BufferTarget)All.DrawIndirectBuffer, indirectBuffer.Handle.ToInt32());
|
||||
GL.BindBuffer((BufferTarget)All.ParameterBuffer, parameterBuffer.Handle.ToInt32());
|
||||
GL.BindBuffer((BufferTarget)All.DrawIndirectBuffer, indirectBuffer.Handle);
|
||||
GL.BindBuffer((BufferTarget)All.ParameterBuffer, parameterBuffer.Handle);
|
||||
|
||||
GL.MultiDrawArraysIndirectCount(
|
||||
_primitiveType,
|
||||
|
@ -1349,7 +1349,7 @@ namespace Ryujinx.Graphics.OpenGL
|
|||
|
||||
Buffer.Resize(_tfbs[i], buffer.Size);
|
||||
Buffer.Copy(buffer.Handle, _tfbs[i], buffer.Offset, 0, buffer.Size);
|
||||
GL.BindBufferBase(BufferRangeTarget.TransformFeedbackBuffer, i, _tfbs[i].ToInt32());
|
||||
GL.BindBufferBase(BufferRangeTarget.TransformFeedbackBuffer, i, _tfbs[i]);
|
||||
}
|
||||
|
||||
if (_tfEnabled)
|
||||
|
@ -1454,7 +1454,7 @@ namespace Ryujinx.Graphics.OpenGL
|
|||
continue;
|
||||
}
|
||||
|
||||
GL.BindBufferRange(target, assignment.Binding, buffer.Handle.ToInt32(), (nint)buffer.Offset, buffer.Size);
|
||||
GL.BindBufferRange(target, assignment.Binding, buffer.Handle, (nint)buffer.Offset, buffer.Size);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ namespace Ryujinx.Graphics.OpenGL
|
|||
minVertexCount = vertexCount;
|
||||
}
|
||||
|
||||
GL.BindVertexBuffer(bindingIndex, vb.Buffer.Handle.ToInt32(), (nint)vb.Buffer.Offset, vb.Stride);
|
||||
GL.BindVertexBuffer(bindingIndex, vb.Buffer.Handle, (nint)vb.Buffer.Offset, vb.Stride);
|
||||
GL.VertexBindingDivisor(bindingIndex, vb.Divisor);
|
||||
_vertexBuffersInUse |= 1u << bindingIndex;
|
||||
}
|
||||
|
@ -134,19 +134,19 @@ namespace Ryujinx.Graphics.OpenGL
|
|||
public void SetIndexBuffer(BufferRange range)
|
||||
{
|
||||
_indexBuffer = range;
|
||||
GL.BindBuffer(BufferTarget.ElementArrayBuffer, range.Handle.ToInt32());
|
||||
GL.BindBuffer(BufferTarget.ElementArrayBuffer, range.Handle);
|
||||
}
|
||||
|
||||
public void SetRangeOfIndexBuffer()
|
||||
{
|
||||
Buffer.Resize(_tempIndexBuffer, _indexBuffer.Size);
|
||||
Buffer.Copy(_indexBuffer.Handle, _tempIndexBuffer, _indexBuffer.Offset, 0, _indexBuffer.Size);
|
||||
GL.BindBuffer(BufferTarget.ElementArrayBuffer, _tempIndexBuffer.ToInt32());
|
||||
GL.BindBuffer(BufferTarget.ElementArrayBuffer, _tempIndexBuffer);
|
||||
}
|
||||
|
||||
public void RestoreIndexBuffer()
|
||||
{
|
||||
GL.BindBuffer(BufferTarget.ElementArrayBuffer, _indexBuffer.Handle.ToInt32());
|
||||
GL.BindBuffer(BufferTarget.ElementArrayBuffer, _indexBuffer.Handle);
|
||||
}
|
||||
|
||||
public void PreDraw(int vertexCount)
|
||||
|
@ -188,7 +188,7 @@ namespace Ryujinx.Graphics.OpenGL
|
|||
Buffer.Copy(vb.Buffer.Handle, tempVertexBuffer, vb.Buffer.Offset, currentTempVbOffset, vb.Buffer.Size);
|
||||
Buffer.Clear(tempVertexBuffer, currentTempVbOffset + vb.Buffer.Size, requiredSize - vb.Buffer.Size, 0);
|
||||
|
||||
GL.BindVertexBuffer(vbIndex, tempVertexBuffer.ToInt32(), (nint)currentTempVbOffset, vb.Stride);
|
||||
GL.BindVertexBuffer(vbIndex, tempVertexBuffer, (nint)currentTempVbOffset, vb.Stride);
|
||||
|
||||
currentTempVbOffset += requiredSize;
|
||||
_vertexBuffersLimited |= 1u << vbIndex;
|
||||
|
@ -234,7 +234,7 @@ namespace Ryujinx.Graphics.OpenGL
|
|||
|
||||
ref VertexBufferDescriptor vb = ref _vertexBuffers[vbIndex];
|
||||
|
||||
GL.BindVertexBuffer(vbIndex, vb.Buffer.Handle.ToInt32(), (nint)vb.Buffer.Offset, vb.Stride);
|
||||
GL.BindVertexBuffer(vbIndex, vb.Buffer.Handle, (nint)vb.Buffer.Offset, vb.Stride);
|
||||
|
||||
buffersLimited &= ~(1u << vbIndex);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue