Spanify Graphics Abstraction Layer (#1226)
* Spanify Graphics Abstraction Layer * Be explicit about BufferHandle size
This commit is contained in:
parent
cc8dbdd3fb
commit
5011640b30
24 changed files with 208 additions and 134 deletions
|
@ -1,6 +1,7 @@
|
|||
using OpenTK.Graphics.OpenGL;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Graphics.GAL;
|
||||
using Ryujinx.Graphics.OpenGL.Image;
|
||||
using Ryujinx.Graphics.OpenGL.Queries;
|
||||
using Ryujinx.Graphics.Shader;
|
||||
using System;
|
||||
|
@ -32,7 +33,7 @@ namespace Ryujinx.Graphics.OpenGL
|
|||
private ClipOrigin _clipOrigin;
|
||||
private ClipDepthMode _clipDepthMode;
|
||||
|
||||
private uint[] _componentMasks;
|
||||
private readonly uint[] _componentMasks;
|
||||
|
||||
private bool _scissor0Enable = false;
|
||||
|
||||
|
@ -43,6 +44,13 @@ namespace Ryujinx.Graphics.OpenGL
|
|||
_rasterizerDiscard = false;
|
||||
_clipOrigin = ClipOrigin.LowerLeft;
|
||||
_clipDepthMode = ClipDepthMode.NegativeOneToOne;
|
||||
|
||||
_componentMasks = new uint[Constants.MaxRenderTargets];
|
||||
|
||||
for (int index = 0; index < Constants.MaxRenderTargets; index++)
|
||||
{
|
||||
_componentMasks[index] = 0xf;
|
||||
}
|
||||
}
|
||||
|
||||
public void Barrier()
|
||||
|
@ -112,6 +120,11 @@ namespace Ryujinx.Graphics.OpenGL
|
|||
_framebuffer.SignalModified();
|
||||
}
|
||||
|
||||
public void CopyBuffer(BufferHandle source, BufferHandle destination, int srcOffset, int dstOffset, int size)
|
||||
{
|
||||
Buffer.Copy(source, destination, srcOffset, dstOffset, size);
|
||||
}
|
||||
|
||||
public void DispatchCompute(int groupsX, int groupsY, int groupsZ)
|
||||
{
|
||||
if (!_program.IsLinked)
|
||||
|
@ -631,7 +644,7 @@ namespace Ryujinx.Graphics.OpenGL
|
|||
|
||||
EnsureVertexArray();
|
||||
|
||||
_vertexArray.SetIndexBuffer((Buffer)buffer.Buffer);
|
||||
_vertexArray.SetIndexBuffer(buffer.Handle);
|
||||
}
|
||||
|
||||
public void SetPointSize(float size)
|
||||
|
@ -661,7 +674,6 @@ namespace Ryujinx.Graphics.OpenGL
|
|||
public void SetProgram(IProgram program)
|
||||
{
|
||||
_program = (Program)program;
|
||||
|
||||
_program.Bind();
|
||||
}
|
||||
|
||||
|
@ -679,12 +691,12 @@ namespace Ryujinx.Graphics.OpenGL
|
|||
_rasterizerDiscard = discard;
|
||||
}
|
||||
|
||||
public void SetRenderTargetColorMasks(uint[] componentMasks)
|
||||
public void SetRenderTargetColorMasks(ReadOnlySpan<uint> componentMasks)
|
||||
{
|
||||
_componentMasks = (uint[])componentMasks.Clone();
|
||||
|
||||
for (int index = 0; index < componentMasks.Length; index++)
|
||||
{
|
||||
_componentMasks[index] = componentMasks[index];
|
||||
|
||||
RestoreComponentMask(index);
|
||||
}
|
||||
}
|
||||
|
@ -823,21 +835,21 @@ namespace Ryujinx.Graphics.OpenGL
|
|||
GL.Enable(EnableCap.ClipDistance0 + index);
|
||||
}
|
||||
|
||||
public void SetVertexAttribs(VertexAttribDescriptor[] vertexAttribs)
|
||||
public void SetVertexAttribs(ReadOnlySpan<VertexAttribDescriptor> vertexAttribs)
|
||||
{
|
||||
EnsureVertexArray();
|
||||
|
||||
_vertexArray.SetVertexAttributes(vertexAttribs);
|
||||
}
|
||||
|
||||
public void SetVertexBuffers(VertexBufferDescriptor[] vertexBuffers)
|
||||
public void SetVertexBuffers(ReadOnlySpan<VertexBufferDescriptor> vertexBuffers)
|
||||
{
|
||||
EnsureVertexArray();
|
||||
|
||||
_vertexArray.SetVertexBuffers(vertexBuffers);
|
||||
}
|
||||
|
||||
public void SetViewports(int first, Viewport[] viewports)
|
||||
public void SetViewports(int first, ReadOnlySpan<Viewport> viewports)
|
||||
{
|
||||
bool flipY = false;
|
||||
|
||||
|
@ -906,18 +918,16 @@ namespace Ryujinx.Graphics.OpenGL
|
|||
? BufferRangeTarget.ShaderStorageBuffer
|
||||
: BufferRangeTarget.UniformBuffer;
|
||||
|
||||
if (buffer.Buffer == null)
|
||||
if (buffer.Handle == null)
|
||||
{
|
||||
GL.BindBufferRange(target, bindingPoint, 0, IntPtr.Zero, 0);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int bufferHandle = ((Buffer)buffer.Buffer).Handle;
|
||||
|
||||
IntPtr bufferOffset = (IntPtr)buffer.Offset;
|
||||
|
||||
GL.BindBufferRange(target, bindingPoint, bufferHandle, bufferOffset, buffer.Size);
|
||||
GL.BindBufferRange(target, bindingPoint, buffer.Handle.ToInt32(), bufferOffset, buffer.Size);
|
||||
}
|
||||
|
||||
private void SetOrigin(ClipOrigin origin)
|
||||
|
@ -997,15 +1007,12 @@ namespace Ryujinx.Graphics.OpenGL
|
|||
|
||||
private void RestoreComponentMask(int index)
|
||||
{
|
||||
if (_componentMasks != null)
|
||||
{
|
||||
GL.ColorMask(
|
||||
index,
|
||||
(_componentMasks[index] & 1u) != 0,
|
||||
(_componentMasks[index] & 2u) != 0,
|
||||
(_componentMasks[index] & 4u) != 0,
|
||||
(_componentMasks[index] & 8u) != 0);
|
||||
}
|
||||
GL.ColorMask(
|
||||
index,
|
||||
(_componentMasks[index] & 1u) != 0,
|
||||
(_componentMasks[index] & 2u) != 0,
|
||||
(_componentMasks[index] & 4u) != 0,
|
||||
(_componentMasks[index] & 8u) != 0);
|
||||
}
|
||||
|
||||
public void RestoreScissor0Enable()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue