mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2025-08-02 01:12:25 -07:00
Some small sync primitive fixes, logging fixes, started to implement the 2D engine on the GPU, fixed DrawArrays, implemented a few more shader instructions, made a start on nvdrv refactor, etc...
This commit is contained in:
@@ -270,6 +270,31 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||
}
|
||||
}
|
||||
|
||||
public void GetBufferData(long Tag, Action<byte[]> Callback)
|
||||
{
|
||||
if (Fbs.TryGetValue(Tag, out FrameBuffer Fb))
|
||||
{
|
||||
GL.BindFramebuffer(FramebufferTarget.ReadFramebuffer, Fb.Handle);
|
||||
|
||||
byte[] Data = new byte[Fb.Width * Fb.Height * 4];
|
||||
|
||||
(PixelFormat Format, PixelType Type) = OGLEnumConverter.GetTextureFormat(GalTextureFormat.A8B8G8R8);
|
||||
|
||||
GL.ReadPixels(
|
||||
0,
|
||||
0,
|
||||
Fb.Width,
|
||||
Fb.Height,
|
||||
Format,
|
||||
Type,
|
||||
Data);
|
||||
|
||||
Callback(Data);
|
||||
|
||||
GL.BindFramebuffer(FramebufferTarget.ReadFramebuffer, CurrFbHandle);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetViewport(Rect Viewport)
|
||||
{
|
||||
GL.Viewport(
|
||||
|
@@ -48,8 +48,6 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||
{
|
||||
public int VaoHandle;
|
||||
public int VboHandle;
|
||||
|
||||
public int PrimCount;
|
||||
}
|
||||
|
||||
private struct IbInfo
|
||||
@@ -102,8 +100,6 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||
{
|
||||
EnsureVbInitialized(VbIndex);
|
||||
|
||||
VertexBuffers[VbIndex].PrimCount = Buffer.Length / Stride;
|
||||
|
||||
VbInfo Vb = VertexBuffers[VbIndex];
|
||||
|
||||
IntPtr Length = new IntPtr(Buffer.Length);
|
||||
@@ -171,29 +167,24 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||
GL.BindBuffer(BufferTarget.ElementArrayBuffer, 0);
|
||||
}
|
||||
|
||||
public void DrawArrays(int VbIndex, GalPrimitiveType PrimType)
|
||||
public void DrawArrays(int VbIndex, int First, int PrimCount, GalPrimitiveType PrimType)
|
||||
{
|
||||
VbInfo Vb = VertexBuffers[VbIndex];
|
||||
|
||||
if (Vb.PrimCount == 0)
|
||||
if (PrimCount == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
VbInfo Vb = VertexBuffers[VbIndex];
|
||||
|
||||
GL.BindVertexArray(Vb.VaoHandle);
|
||||
|
||||
GL.DrawArrays(OGLEnumConverter.GetPrimitiveType(PrimType), 0, Vb.PrimCount);
|
||||
GL.DrawArrays(OGLEnumConverter.GetPrimitiveType(PrimType), First, PrimCount);
|
||||
}
|
||||
|
||||
public void DrawElements(int VbIndex, int First, GalPrimitiveType PrimType)
|
||||
{
|
||||
VbInfo Vb = VertexBuffers[VbIndex];
|
||||
|
||||
if (Vb.PrimCount == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
PrimitiveType Mode = OGLEnumConverter.GetPrimitiveType(PrimType);
|
||||
|
||||
GL.BindVertexArray(Vb.VaoHandle);
|
||||
|
@@ -146,6 +146,11 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||
ActionsQueue.Enqueue(() => FrameBuffer.SetViewport(X, Y, Width, Height));
|
||||
}
|
||||
|
||||
public void GetFrameBufferData(long Tag, Action<byte[]> Callback)
|
||||
{
|
||||
ActionsQueue.Enqueue(() => FrameBuffer.GetBufferData(Tag, Callback));
|
||||
}
|
||||
|
||||
public void ClearBuffers(int RtIndex, GalClearBufferFlags Flags)
|
||||
{
|
||||
ActionsQueue.Enqueue(() => Rasterizer.ClearBuffers(RtIndex, Flags));
|
||||
@@ -173,14 +178,14 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||
ActionsQueue.Enqueue(() => Rasterizer.SetIndexArray(Buffer, Format));
|
||||
}
|
||||
|
||||
public void DrawArrays(int VbIndex, GalPrimitiveType PrimType)
|
||||
public void DrawArrays(int VbIndex, int First, int PrimCount, GalPrimitiveType PrimType)
|
||||
{
|
||||
if ((uint)VbIndex > 31)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(VbIndex));
|
||||
}
|
||||
|
||||
ActionsQueue.Enqueue(() => Rasterizer.DrawArrays(VbIndex, PrimType));
|
||||
ActionsQueue.Enqueue(() => Rasterizer.DrawArrays(VbIndex, First, PrimCount, PrimType));
|
||||
}
|
||||
|
||||
public void DrawElements(int VbIndex, int First, GalPrimitiveType PrimType)
|
||||
|
Reference in New Issue
Block a user