Debugger, Pipeline

This commit is contained in:
Isaac Marovitz 2024-05-09 20:04:29 -04:00
parent 1d18ed2ba2
commit 0c88c23b30
No known key found for this signature in database
GPG key ID: 97250B2B09A132E1
2 changed files with 62 additions and 48 deletions

View file

@ -16,7 +16,7 @@ namespace Ryujinx.Graphics.OpenGL
public static void Initialize(GL gl, GraphicsDebugLevel logLevel)
{
// Disable everything
gl.DebugMessageControl(DebugSource.DontCare, DebugType.DontCare, DebugSeverity.DontCare, 0, (int[])null, false);
gl.DebugMessageControl(DebugSource.DontCare, DebugType.DontCare, DebugSeverity.DontCare, 0, (uint[])null, false);
if (logLevel == GraphicsDebugLevel.None)
{
@ -30,16 +30,16 @@ namespace Ryujinx.Graphics.OpenGL
if (logLevel == GraphicsDebugLevel.Error)
{
gl.DebugMessageControl(DebugSource.DontCare, DebugType.DebugTypeError, DebugSeverity.DontCare, 0, (int[])null, true);
gl.DebugMessageControl(DebugSource.DontCare, DebugType.DebugTypeError, DebugSeverity.DontCare, 0, (uint[])null, true);
}
else if (logLevel == GraphicsDebugLevel.Slowdowns)
{
gl.DebugMessageControl(DebugSource.DontCare, DebugType.DebugTypeError, DebugSeverity.DontCare, 0, (int[])null, true);
gl.DebugMessageControl(DebugSource.DontCare, DebugType.DebugTypePerformance, DebugSeverity.DontCare, 0, (int[])null, true);
gl.DebugMessageControl(DebugSource.DontCare, DebugType.DebugTypeError, DebugSeverity.DontCare, 0, (uint[])null, true);
gl.DebugMessageControl(DebugSource.DontCare, DebugType.DebugTypePerformance, DebugSeverity.DontCare, 0, (uint[])null, true);
}
else
{
gl.DebugMessageControl(DebugSource.DontCare, DebugType.DontCare, DebugSeverity.DontCare, 0, (int[])null, true);
gl.DebugMessageControl(DebugSource.DontCare, DebugType.DontCare, DebugSeverity.DontCare, 0, (uint[])null, true);
}
_counter = 0;
@ -61,7 +61,10 @@ namespace Ryujinx.Graphics.OpenGL
{
string msg = Marshal.PtrToStringUTF8(message).Replace('\n', ' ');
switch (type)
DebugType debugType = (DebugType)type;
DebugSource debugSource = (DebugSource)source;
switch (debugType)
{
case DebugType.DebugTypeError:
Logger.Error?.Print(LogClass.Gpu, $"{severity}: {msg}\nCallStack={Environment.StackTrace}", "GLERROR");
@ -76,7 +79,7 @@ namespace Ryujinx.Graphics.OpenGL
Logger.Info?.Print(LogClass.Gpu, $"}} ({id}) {severity}: {msg}", "GLINFO");
break;
default:
if (source == DebugSource.DebugSourceApplication)
if (debugSource == DebugSource.DebugSourceApplication)
{
Logger.Info?.Print(LogClass.Gpu, $"{type} {severity}: {msg}", "GLINFO");
}
@ -93,7 +96,7 @@ namespace Ryujinx.Graphics.OpenGL
{
int counter = Interlocked.Increment(ref _counter);
gl.PushDebugGroup(DebugSource.DebugSourceApplication, counter, dbgMsg.Length, dbgMsg);
gl.PushDebugGroup(DebugSource.DebugSourceApplication, (uint)counter, (uint)dbgMsg.Length, dbgMsg);
}
public static void PopGroup(GL gl)
@ -103,7 +106,7 @@ namespace Ryujinx.Graphics.OpenGL
public static void Print(GL gl, string dbgMsg, DebugType type = DebugType.DebugTypeMarker, DebugSeverity severity = DebugSeverity.DebugSeverityNotification, int id = 999999)
{
gl.DebugMessageInsert(DebugSource.DebugSourceApplication, type, id, severity, dbgMsg.Length, dbgMsg);
gl.DebugMessageInsert(DebugSource.DebugSourceApplication, type, (uint)id, severity, (uint)dbgMsg.Length, dbgMsg);
}
}
}

View file

@ -220,7 +220,7 @@ namespace Ryujinx.Graphics.OpenGL
PrepareForDispatch();
_api.DispatchCompute(groupsX, groupsY, groupsZ);
_api.DispatchCompute((uint)groupsX, (uint)groupsY, (uint)groupsZ);
}
public void Draw(int vertexCount, int instanceCount, int firstVertex, int firstInstance)
@ -256,10 +256,10 @@ namespace Ryujinx.Graphics.OpenGL
int firstInstance)
{
// TODO: Instanced rendering.
int quadsCount = vertexCount / 4;
uint quadsCount = (uint)(vertexCount / 4);
int[] firsts = new int[quadsCount];
int[] counts = new int[quadsCount];
uint[] counts = new uint[quadsCount];
for (int quadIndex = 0; quadIndex < quadsCount; quadIndex++)
{
@ -280,19 +280,19 @@ namespace Ryujinx.Graphics.OpenGL
int firstVertex,
int firstInstance)
{
int quadsCount = (vertexCount - 2) / 2;
uint quadsCount = (uint)((vertexCount - 2) / 2);
if (firstInstance != 0 || instanceCount != 1)
{
for (int quadIndex = 0; quadIndex < quadsCount; quadIndex++)
{
_api.DrawArraysInstancedBaseInstance(PrimitiveType.TriangleFan, firstVertex + quadIndex * 2, 4, instanceCount, firstInstance);
_api.DrawArraysInstancedBaseInstance(PrimitiveType.TriangleFan, firstVertex + quadIndex * 2, 4, (uint)instanceCount, (uint)firstInstance);
}
}
else
{
int[] firsts = new int[quadsCount];
int[] counts = new int[quadsCount];
uint[] counts = new uint[quadsCount];
firsts[0] = firstVertex;
counts[0] = 4;
@ -319,20 +319,20 @@ namespace Ryujinx.Graphics.OpenGL
{
if (firstInstance == 0 && instanceCount == 1)
{
_api.DrawArrays(_primitiveType, firstVertex, vertexCount);
_api.DrawArrays(_primitiveType, firstVertex, (uint)vertexCount);
}
else if (firstInstance == 0)
{
_api.DrawArraysInstanced(_primitiveType, firstVertex, vertexCount, instanceCount);
_api.DrawArraysInstanced(_primitiveType, firstVertex, (uint)vertexCount, (uint)instanceCount);
}
else
{
_api.DrawArraysInstancedBaseInstance(
_primitiveType,
firstVertex,
vertexCount,
instanceCount,
firstInstance);
(uint)vertexCount,
(uint)instanceCount,
(uint)firstInstance);
}
}
@ -398,7 +398,7 @@ namespace Ryujinx.Graphics.OpenGL
PostDraw();
}
private void DrawQuadsIndexedImpl(
private unsafe void DrawQuadsIndexedImpl(
int indexCount,
int instanceCount,
IntPtr indexBaseOffset,
@ -419,9 +419,9 @@ namespace Ryujinx.Graphics.OpenGL
4,
_elementsType,
indexBaseOffset + quadIndex * 4 * indexElemSize,
instanceCount,
(uint)instanceCount,
firstVertex,
firstInstance);
(uint)firstInstance);
}
}
else if (firstInstance != 0)
@ -433,8 +433,8 @@ namespace Ryujinx.Graphics.OpenGL
4,
_elementsType,
indexBaseOffset + quadIndex * 4 * indexElemSize,
instanceCount,
firstInstance);
(uint)instanceCount,
(uint)firstInstance);
}
}
else
@ -446,38 +446,43 @@ namespace Ryujinx.Graphics.OpenGL
4,
_elementsType,
indexBaseOffset + quadIndex * 4 * indexElemSize,
instanceCount);
(uint)instanceCount);
}
}
}
else
{
IntPtr[] indices = new IntPtr[quadsCount];
void*[] indices = new void*[quadsCount];
int[] counts = new int[quadsCount];
uint[] counts = new uint[quadsCount];
int[] baseVertices = new int[quadsCount];
for (int quadIndex = 0; quadIndex < quadsCount; quadIndex++)
{
indices[quadIndex] = indexBaseOffset + quadIndex * 4 * indexElemSize;
indices[quadIndex] = (void*)(indexBaseOffset + quadIndex * 4 * indexElemSize);
counts[quadIndex] = 4;
baseVertices[quadIndex] = firstVertex;
}
_api.MultiDrawElementsBaseVertex(
PrimitiveType.TriangleFan,
counts,
_elementsType,
indices,
quadsCount,
baseVertices);
fixed (uint* countsPtr = counts)
fixed (void* indicesPtr = indices)
fixed (int* baseVerticesPtr = baseVertices)
{
_api.MultiDrawElementsBaseVertex(
PrimitiveType.TriangleFan,
countsPtr,
_elementsType,
indicesPtr,
(uint)quadsCount,
baseVerticesPtr);
}
}
}
private void DrawQuadStripIndexedImpl(
private unsafe void DrawQuadStripIndexedImpl(
int indexCount,
int instanceCount,
IntPtr indexBaseOffset,
@ -488,13 +493,13 @@ namespace Ryujinx.Graphics.OpenGL
// TODO: Instanced rendering.
int quadsCount = (indexCount - 2) / 2;
IntPtr[] indices = new IntPtr[quadsCount];
void*[] indices = new void*[quadsCount];
int[] counts = new int[quadsCount];
uint[] counts = new uint[quadsCount];
int[] baseVertices = new int[quadsCount];
indices[0] = indexBaseOffset;
indices[0] = (void*)indexBaseOffset;
counts[0] = 4;
@ -502,20 +507,25 @@ namespace Ryujinx.Graphics.OpenGL
for (int quadIndex = 1; quadIndex < quadsCount; quadIndex++)
{
indices[quadIndex] = indexBaseOffset + quadIndex * 2 * indexElemSize;
indices[quadIndex] = (void*)(indexBaseOffset + quadIndex * 2 * indexElemSize);
counts[quadIndex] = 4;
baseVertices[quadIndex] = firstVertex;
}
_api.MultiDrawElementsBaseVertex(
PrimitiveType.TriangleFan,
counts,
_elementsType,
indices,
quadsCount,
baseVertices);
fixed (uint* countsPtr = counts)
fixed (void* indicesPtr = indices)
fixed (int* baseVerticesPtr = baseVertices)
{
_api.MultiDrawElementsBaseVertex(
PrimitiveType.TriangleFan,
countsPtr,
_elementsType,
indicesPtr,
(uint)quadsCount,
baseVerticesPtr);
}
}
private void DrawIndexedImpl(
@ -725,6 +735,7 @@ namespace Ryujinx.Graphics.OpenGL
_api.ClipControl(ClipControlOrigin.UpperLeft, ClipControlDepth.NegativeOneToOne);
_drawTexture.Draw(
_api,
view,
samp,
dstRegion.X1,