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
This commit is contained in:
parent
17f4ccf2d5
commit
f73a182b20
5 changed files with 133 additions and 46 deletions
|
@ -2,6 +2,7 @@ namespace Ryujinx.Graphics.Gal
|
|||
{
|
||||
public struct GalVertexAttrib
|
||||
{
|
||||
public int Index { get; private set; }
|
||||
public bool IsConst { get; private set; }
|
||||
public int Offset { get; private set; }
|
||||
|
||||
|
@ -11,12 +12,14 @@ namespace Ryujinx.Graphics.Gal
|
|||
public bool IsBgra { get; private set; }
|
||||
|
||||
public GalVertexAttrib(
|
||||
int Index,
|
||||
bool IsConst,
|
||||
int Offset,
|
||||
GalVertexAttribSize Size,
|
||||
GalVertexAttribType Type,
|
||||
bool IsBgra)
|
||||
{
|
||||
this.Index = Index;
|
||||
this.IsConst = IsConst;
|
||||
this.Offset = Offset;
|
||||
this.Size = Size;
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -261,13 +261,16 @@ namespace Ryujinx.Graphics.Gal.Shader
|
|||
|
||||
PrintBlockScope(SubScopeName, IdentationLevel + 1, Cond.Child);
|
||||
}
|
||||
else if (Node is ShaderIrAsg Asg && IsValidOutOper(Asg.Dst))
|
||||
else if (Node is ShaderIrAsg Asg)
|
||||
{
|
||||
string Expr = GetSrcExpr(Asg.Src, true);
|
||||
if (IsValidOutOper(Asg.Dst))
|
||||
{
|
||||
string Expr = GetSrcExpr(Asg.Src, true);
|
||||
|
||||
Expr = GetExprWithCast(Asg.Dst, Asg.Src, Expr);
|
||||
Expr = GetExprWithCast(Asg.Dst, Asg.Src, Expr);
|
||||
|
||||
SB.AppendLine(Identation + GetDstOperName(Asg.Dst) + " = " + Expr + ";");
|
||||
SB.AppendLine(Identation + GetDstOperName(Asg.Dst) + " = " + Expr + ";");
|
||||
}
|
||||
}
|
||||
else if (Node is ShaderIrOp Op)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue