Refactor to remove Ib from quadhelper methods
This commit is contained in:
parent
3bcdf6fe9f
commit
7599160dcf
2 changed files with 17 additions and 17 deletions
|
@ -691,11 +691,11 @@ namespace Ryujinx.Graphics.Graphics3d
|
||||||
|
|
||||||
if (PrimType == GalPrimitiveType.Quads)
|
if (PrimType == GalPrimitiveType.Quads)
|
||||||
{
|
{
|
||||||
Buffer = QuadHelper.ConvertIbQuadsToTris(Buffer, IndexEntrySize, IndexCount);
|
Buffer = QuadHelper.ConvertQuadsToTris(Buffer, IndexEntrySize, IndexCount);
|
||||||
}
|
}
|
||||||
else /* if (PrimType == GalPrimitiveType.QuadStrip) */
|
else /* if (PrimType == GalPrimitiveType.QuadStrip) */
|
||||||
{
|
{
|
||||||
Buffer = QuadHelper.ConvertIbQuadStripToTris(Buffer, IndexEntrySize, IndexCount);
|
Buffer = QuadHelper.ConvertQuadStripToTris(Buffer, IndexEntrySize, IndexCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
Gpu.Renderer.Rasterizer.CreateIbo(IboKey, IbSize, Buffer);
|
Gpu.Renderer.Rasterizer.CreateIbo(IboKey, IbSize, Buffer);
|
||||||
|
@ -710,11 +710,11 @@ namespace Ryujinx.Graphics.Graphics3d
|
||||||
{
|
{
|
||||||
if (PrimType == GalPrimitiveType.Quads)
|
if (PrimType == GalPrimitiveType.Quads)
|
||||||
{
|
{
|
||||||
Gpu.Renderer.Rasterizer.SetIndexArray(QuadHelper.ConvertIbSizeQuadsToTris(IbSize), IndexFormat);
|
Gpu.Renderer.Rasterizer.SetIndexArray(QuadHelper.ConvertSizeQuadsToTris(IbSize), IndexFormat);
|
||||||
}
|
}
|
||||||
else /* if (PrimType == GalPrimitiveType.QuadStrip) */
|
else /* if (PrimType == GalPrimitiveType.QuadStrip) */
|
||||||
{
|
{
|
||||||
Gpu.Renderer.Rasterizer.SetIndexArray(QuadHelper.ConvertIbSizeQuadStripToTris(IbSize), IndexFormat);
|
Gpu.Renderer.Rasterizer.SetIndexArray(QuadHelper.ConvertSizeQuadStripToTris(IbSize), IndexFormat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -803,9 +803,9 @@ namespace Ryujinx.Graphics.Graphics3d
|
||||||
if (Stride == 0)
|
if (Stride == 0)
|
||||||
{
|
{
|
||||||
if (PrimType == GalPrimitiveType.Quads)
|
if (PrimType == GalPrimitiveType.Quads)
|
||||||
ModifiedVbSize = QuadHelper.ConvertIbSizeQuadsToTris(ModifiedVbSize);
|
ModifiedVbSize = QuadHelper.ConvertSizeQuadsToTris(ModifiedVbSize);
|
||||||
else if (PrimType == GalPrimitiveType.QuadStrip)
|
else if (PrimType == GalPrimitiveType.QuadStrip)
|
||||||
ModifiedVbSize = QuadHelper.ConvertIbSizeQuadStripToTris(ModifiedVbSize);
|
ModifiedVbSize = QuadHelper.ConvertSizeQuadStripToTris(ModifiedVbSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VboCached = Gpu.Renderer.Rasterizer.IsVboCached(VboKey, ModifiedVbSize);
|
bool VboCached = Gpu.Renderer.Rasterizer.IsVboCached(VboKey, ModifiedVbSize);
|
||||||
|
@ -818,9 +818,9 @@ namespace Ryujinx.Graphics.Graphics3d
|
||||||
byte[] data = Vmm.ReadBytes(VbPosition, VbSize);
|
byte[] data = Vmm.ReadBytes(VbPosition, VbSize);
|
||||||
|
|
||||||
if (PrimType == GalPrimitiveType.Quads)
|
if (PrimType == GalPrimitiveType.Quads)
|
||||||
data = QuadHelper.ConvertIbQuadsToTris(data, Stride, (int)(VbSize / Stride));
|
data = QuadHelper.ConvertQuadsToTris(data, Stride, (int)(VbSize / Stride));
|
||||||
else
|
else
|
||||||
data = QuadHelper.ConvertIbQuadStripToTris(data, Stride, (int)(VbSize / Stride));
|
data = QuadHelper.ConvertQuadStripToTris(data, Stride, (int)(VbSize / Stride));
|
||||||
Gpu.Renderer.Rasterizer.CreateVbo(VboKey, data);
|
Gpu.Renderer.Rasterizer.CreateVbo(VboKey, data);
|
||||||
}
|
}
|
||||||
else if (Vmm.TryGetHostAddress(VbPosition, VbSize, out IntPtr VbPtr))
|
else if (Vmm.TryGetHostAddress(VbPosition, VbSize, out IntPtr VbPtr))
|
||||||
|
@ -887,9 +887,9 @@ namespace Ryujinx.Graphics.Graphics3d
|
||||||
//vertex of a quad, if it points to the middle of a
|
//vertex of a quad, if it points to the middle of a
|
||||||
//quad (First % 4 != 0 for Quads) then it will not work properly.
|
//quad (First % 4 != 0 for Quads) then it will not work properly.
|
||||||
if (PrimType == GalPrimitiveType.Quads)
|
if (PrimType == GalPrimitiveType.Quads)
|
||||||
IndexFirst = QuadHelper.ConvertIbSizeQuadsToTris(IndexFirst);
|
IndexFirst = QuadHelper.ConvertSizeQuadsToTris(IndexFirst);
|
||||||
else // QuadStrip
|
else // QuadStrip
|
||||||
IndexFirst = QuadHelper.ConvertIbSizeQuadStripToTris(IndexFirst);
|
IndexFirst = QuadHelper.ConvertSizeQuadStripToTris(IndexFirst);
|
||||||
|
|
||||||
PrimType = GalPrimitiveType.Triangles;
|
PrimType = GalPrimitiveType.Triangles;
|
||||||
}
|
}
|
||||||
|
@ -910,12 +910,12 @@ namespace Ryujinx.Graphics.Graphics3d
|
||||||
//vertex of a quad, if it points to the middle of a
|
//vertex of a quad, if it points to the middle of a
|
||||||
//quad (First % 4 != 0 for Quads) then it will not work properly.
|
//quad (First % 4 != 0 for Quads) then it will not work properly.
|
||||||
if (PrimType == GalPrimitiveType.Quads)
|
if (PrimType == GalPrimitiveType.Quads)
|
||||||
VertexFirst = QuadHelper.ConvertIbSizeQuadsToTris(VertexFirst);
|
VertexFirst = QuadHelper.ConvertSizeQuadsToTris(VertexFirst);
|
||||||
else // QuadStrip
|
else // QuadStrip
|
||||||
VertexFirst = QuadHelper.ConvertIbSizeQuadStripToTris(VertexFirst);
|
VertexFirst = QuadHelper.ConvertSizeQuadStripToTris(VertexFirst);
|
||||||
|
|
||||||
PrimType = GalPrimitiveType.Triangles;
|
PrimType = GalPrimitiveType.Triangles;
|
||||||
VertexCount = QuadHelper.ConvertIbSizeQuadsToTris(VertexCount);
|
VertexCount = QuadHelper.ConvertSizeQuadsToTris(VertexCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
Gpu.Renderer.Rasterizer.DrawArrays(VertexFirst, VertexCount, PrimType);
|
Gpu.Renderer.Rasterizer.DrawArrays(VertexFirst, VertexCount, PrimType);
|
||||||
|
|
|
@ -4,17 +4,17 @@ namespace Ryujinx.Graphics
|
||||||
{
|
{
|
||||||
static class QuadHelper
|
static class QuadHelper
|
||||||
{
|
{
|
||||||
public static int ConvertIbSizeQuadsToTris(int Size)
|
public static int ConvertSizeQuadsToTris(int Size)
|
||||||
{
|
{
|
||||||
return Size <= 0 ? 0 : (Size / 4) * 6;
|
return Size <= 0 ? 0 : (Size / 4) * 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int ConvertIbSizeQuadStripToTris(int Size)
|
public static int ConvertSizeQuadStripToTris(int Size)
|
||||||
{
|
{
|
||||||
return Size <= 1 ? 0 : ((Size - 2) / 2) * 6;
|
return Size <= 1 ? 0 : ((Size - 2) / 2) * 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] ConvertIbQuadsToTris(byte[] Data, int EntrySize, int Count)
|
public static byte[] ConvertQuadsToTris(byte[] Data, int EntrySize, int Count)
|
||||||
{
|
{
|
||||||
int PrimitivesCount = Count / 4;
|
int PrimitivesCount = Count / 4;
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ namespace Ryujinx.Graphics
|
||||||
return Output;
|
return Output;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] ConvertIbQuadStripToTris(byte[] Data, int EntrySize, int Count)
|
public static byte[] ConvertQuadStripToTris(byte[] Data, int EntrySize, int Count)
|
||||||
{
|
{
|
||||||
int PrimitivesCount = (Count - 2) / 2;
|
int PrimitivesCount = (Count - 2) / 2;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue