diff options
| author | gdkchan <gab.dark.100@gmail.com> | 2018-04-29 17:58:38 -0300 |
|---|---|---|
| committer | gdkchan <gab.dark.100@gmail.com> | 2018-04-29 17:58:38 -0300 |
| commit | f73a182b20970f993abc1f1329dfab1e5d3b3354 (patch) | |
| tree | ad46e02d29560b013713291f236b953a601e2d5f /Ryujinx.Graphics/Gal/OpenGL/OGLRasterizer.cs | |
| parent | 17f4ccf2d552b9646097282818d82525a3d902cf (diff) | |
Properly support multiple vertex buffers, stub 2 ioctls, fix a shader issue, change the way how the vertex buffer size is calculated for the buffers with limit = 0
Diffstat (limited to 'Ryujinx.Graphics/Gal/OpenGL/OGLRasterizer.cs')
| -rw-r--r-- | Ryujinx.Graphics/Gal/OpenGL/OGLRasterizer.cs | 53 |
1 files changed, 16 insertions, 37 deletions
diff --git a/Ryujinx.Graphics/Gal/OpenGL/OGLRasterizer.cs b/Ryujinx.Graphics/Gal/OpenGL/OGLRasterizer.cs index b1504563..5b115446 100644 --- a/Ryujinx.Graphics/Gal/OpenGL/OGLRasterizer.cs +++ b/Ryujinx.Graphics/Gal/OpenGL/OGLRasterizer.cs @@ -44,12 +44,6 @@ namespace Ryujinx.Graphics.Gal.OpenGL { GalVertexAttribSize._11_11_10, VertexAttribPointerType.Int } //? }; - private struct VbInfo - { - public int VaoHandle; - public int VboHandle; - } - private struct IbInfo { public int IboHandle; @@ -58,13 +52,15 @@ namespace Ryujinx.Graphics.Gal.OpenGL public DrawElementsType Type; } - private VbInfo[] VertexBuffers; + private int VaoHandle; + + private int[] VertexBuffers; private IbInfo IndexBuffer; public OGLRasterizer() { - VertexBuffers = new VbInfo[32]; + VertexBuffers = new int[32]; IndexBuffer = new IbInfo(); } @@ -100,28 +96,19 @@ namespace Ryujinx.Graphics.Gal.OpenGL { EnsureVbInitialized(VbIndex); - VbInfo Vb = VertexBuffers[VbIndex]; - IntPtr Length = new IntPtr(Buffer.Length); - GL.BindBuffer(BufferTarget.ArrayBuffer, Vb.VboHandle); + GL.BindBuffer(BufferTarget.ArrayBuffer, VertexBuffers[VbIndex]); GL.BufferData(BufferTarget.ArrayBuffer, Length, Buffer, BufferUsageHint.StreamDraw); GL.BindBuffer(BufferTarget.ArrayBuffer, 0); - GL.BindVertexArray(Vb.VaoHandle); + GL.BindVertexArray(VaoHandle); - for (int Attr = 0; Attr < 16; Attr++) + foreach (GalVertexAttrib Attrib in Attribs) { - GL.DisableVertexAttribArray(Attr); - } + GL.EnableVertexAttribArray(Attrib.Index); - for (int Index = 0; Index < Attribs.Length; Index++) - { - GalVertexAttrib Attrib = Attribs[Index]; - - GL.EnableVertexAttribArray(Index); - - GL.BindBuffer(BufferTarget.ArrayBuffer, Vb.VboHandle); + GL.BindBuffer(BufferTarget.ArrayBuffer, VertexBuffers[VbIndex]); bool Unsigned = Attrib.Type == GalVertexAttribType.Unorm || @@ -146,7 +133,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL int Size = AttribElements[Attrib.Size]; int Offset = Attrib.Offset; - GL.VertexAttribPointer(Index, Size, Type, Normalize, Stride, Offset); + GL.VertexAttribPointer(Attrib.Index, Size, Type, Normalize, Stride, Offset); } GL.BindVertexArray(0); @@ -174,20 +161,16 @@ namespace Ryujinx.Graphics.Gal.OpenGL return; } - VbInfo Vb = VertexBuffers[VbIndex]; - - GL.BindVertexArray(Vb.VaoHandle); + GL.BindVertexArray(VaoHandle); GL.DrawArrays(OGLEnumConverter.GetPrimitiveType(PrimType), First, PrimCount); } public void DrawElements(int VbIndex, int First, GalPrimitiveType PrimType) { - VbInfo Vb = VertexBuffers[VbIndex]; - PrimitiveType Mode = OGLEnumConverter.GetPrimitiveType(PrimType); - GL.BindVertexArray(Vb.VaoHandle); + GL.BindVertexArray(VaoHandle); GL.BindBuffer(BufferTarget.ElementArrayBuffer, IndexBuffer.IboHandle); @@ -196,19 +179,15 @@ namespace Ryujinx.Graphics.Gal.OpenGL private void EnsureVbInitialized(int VbIndex) { - VbInfo Vb = VertexBuffers[VbIndex]; - - if (Vb.VaoHandle == 0) + if (VaoHandle == 0) { - Vb.VaoHandle = GL.GenVertexArray(); + VaoHandle = GL.GenVertexArray(); } - if (Vb.VboHandle == 0) + if (VertexBuffers[VbIndex] == 0) { - Vb.VboHandle = GL.GenBuffer(); + VertexBuffers[VbIndex] = GL.GenBuffer(); } - - VertexBuffers[VbIndex] = Vb; } private void EnsureIbInitialized() |
