mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2025-01-07 16:33:05 +00:00
Fix Vertex Offset Pointers
This commit is contained in:
parent
4aa0ea11d2
commit
62b838850b
2 changed files with 22 additions and 31 deletions
|
@ -419,13 +419,11 @@ namespace Ryujinx.Graphics.OpenGL
|
||||||
{
|
{
|
||||||
for (int quadIndex = 0; quadIndex < quadsCount; quadIndex++)
|
for (int quadIndex = 0; quadIndex < quadsCount; quadIndex++)
|
||||||
{
|
{
|
||||||
var indices = indexBaseOffset + quadIndex * 4 * indexElemSize;
|
|
||||||
|
|
||||||
_gd.Api.DrawElementsInstancedBaseVertexBaseInstance(
|
_gd.Api.DrawElementsInstancedBaseVertexBaseInstance(
|
||||||
PrimitiveType.TriangleFan,
|
PrimitiveType.TriangleFan,
|
||||||
4,
|
4,
|
||||||
_elementsType,
|
_elementsType,
|
||||||
in indices,
|
(void*)(indexBaseOffset + quadIndex * 4 * indexElemSize),
|
||||||
(uint)instanceCount,
|
(uint)instanceCount,
|
||||||
firstVertex,
|
firstVertex,
|
||||||
(uint)firstInstance);
|
(uint)firstInstance);
|
||||||
|
@ -435,13 +433,11 @@ namespace Ryujinx.Graphics.OpenGL
|
||||||
{
|
{
|
||||||
for (int quadIndex = 0; quadIndex < quadsCount; quadIndex++)
|
for (int quadIndex = 0; quadIndex < quadsCount; quadIndex++)
|
||||||
{
|
{
|
||||||
var indices = indexBaseOffset + quadIndex * 4 * indexElemSize;
|
|
||||||
|
|
||||||
_gd.Api.DrawElementsInstancedBaseInstance(
|
_gd.Api.DrawElementsInstancedBaseInstance(
|
||||||
PrimitiveType.TriangleFan,
|
PrimitiveType.TriangleFan,
|
||||||
4,
|
4,
|
||||||
_elementsType,
|
_elementsType,
|
||||||
in indices,
|
(void*)(indexBaseOffset + quadIndex * 4 * indexElemSize),
|
||||||
(uint)instanceCount,
|
(uint)instanceCount,
|
||||||
(uint)firstInstance);
|
(uint)firstInstance);
|
||||||
}
|
}
|
||||||
|
@ -450,13 +446,11 @@ namespace Ryujinx.Graphics.OpenGL
|
||||||
{
|
{
|
||||||
for (int quadIndex = 0; quadIndex < quadsCount; quadIndex++)
|
for (int quadIndex = 0; quadIndex < quadsCount; quadIndex++)
|
||||||
{
|
{
|
||||||
var indices = indexBaseOffset + quadIndex * 4 * indexElemSize;
|
|
||||||
|
|
||||||
_gd.Api.DrawElementsInstanced(
|
_gd.Api.DrawElementsInstanced(
|
||||||
PrimitiveType.TriangleFan,
|
PrimitiveType.TriangleFan,
|
||||||
4,
|
4,
|
||||||
_elementsType,
|
_elementsType,
|
||||||
in indices,
|
(void*)(indexBaseOffset + quadIndex * 4 * indexElemSize),
|
||||||
(uint)instanceCount);
|
(uint)instanceCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -479,14 +473,14 @@ namespace Ryujinx.Graphics.OpenGL
|
||||||
}
|
}
|
||||||
|
|
||||||
fixed (uint* countsPtr = counts)
|
fixed (uint* countsPtr = counts)
|
||||||
fixed (void* indicesPtr = indices)
|
fixed (void** indicesPtr = indices)
|
||||||
fixed (int* baseVerticesPtr = baseVertices)
|
fixed (int* baseVerticesPtr = baseVertices)
|
||||||
{
|
{
|
||||||
_gd.Api.MultiDrawElementsBaseVertex(
|
_gd.Api.MultiDrawElementsBaseVertex(
|
||||||
PrimitiveType.TriangleFan,
|
PrimitiveType.TriangleFan,
|
||||||
countsPtr,
|
countsPtr,
|
||||||
_elementsType,
|
_elementsType,
|
||||||
in indicesPtr,
|
indicesPtr,
|
||||||
(uint)quadsCount,
|
(uint)quadsCount,
|
||||||
baseVerticesPtr);
|
baseVerticesPtr);
|
||||||
}
|
}
|
||||||
|
@ -526,20 +520,20 @@ namespace Ryujinx.Graphics.OpenGL
|
||||||
}
|
}
|
||||||
|
|
||||||
fixed (uint* countsPtr = counts)
|
fixed (uint* countsPtr = counts)
|
||||||
fixed (void* indicesPtr = indices)
|
fixed (void** indicesPtr = indices)
|
||||||
fixed (int* baseVerticesPtr = baseVertices)
|
fixed (int* baseVerticesPtr = baseVertices)
|
||||||
{
|
{
|
||||||
_gd.Api.MultiDrawElementsBaseVertex(
|
_gd.Api.MultiDrawElementsBaseVertex(
|
||||||
PrimitiveType.TriangleFan,
|
PrimitiveType.TriangleFan,
|
||||||
countsPtr,
|
countsPtr,
|
||||||
_elementsType,
|
_elementsType,
|
||||||
in indicesPtr,
|
indicesPtr,
|
||||||
(uint)quadsCount,
|
(uint)quadsCount,
|
||||||
baseVerticesPtr);
|
baseVerticesPtr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawIndexedImpl(
|
private unsafe void DrawIndexedImpl(
|
||||||
int indexCount,
|
int indexCount,
|
||||||
int instanceCount,
|
int instanceCount,
|
||||||
IntPtr indexBaseOffset,
|
IntPtr indexBaseOffset,
|
||||||
|
@ -548,7 +542,7 @@ namespace Ryujinx.Graphics.OpenGL
|
||||||
{
|
{
|
||||||
if (firstInstance == 0 && firstVertex == 0 && instanceCount == 1)
|
if (firstInstance == 0 && firstVertex == 0 && instanceCount == 1)
|
||||||
{
|
{
|
||||||
_gd.Api.DrawElements(_primitiveType, (uint)indexCount, _elementsType, in indexBaseOffset);
|
_gd.Api.DrawElements(_primitiveType, (uint)indexCount, _elementsType, (void*)indexBaseOffset);
|
||||||
}
|
}
|
||||||
else if (firstInstance == 0 && instanceCount == 1)
|
else if (firstInstance == 0 && instanceCount == 1)
|
||||||
{
|
{
|
||||||
|
@ -556,7 +550,7 @@ namespace Ryujinx.Graphics.OpenGL
|
||||||
_primitiveType,
|
_primitiveType,
|
||||||
(uint)indexCount,
|
(uint)indexCount,
|
||||||
_elementsType,
|
_elementsType,
|
||||||
in indexBaseOffset,
|
(void*)indexBaseOffset,
|
||||||
firstVertex);
|
firstVertex);
|
||||||
}
|
}
|
||||||
else if (firstInstance == 0 && firstVertex == 0)
|
else if (firstInstance == 0 && firstVertex == 0)
|
||||||
|
@ -565,7 +559,7 @@ namespace Ryujinx.Graphics.OpenGL
|
||||||
_primitiveType,
|
_primitiveType,
|
||||||
(uint)indexCount,
|
(uint)indexCount,
|
||||||
_elementsType,
|
_elementsType,
|
||||||
in indexBaseOffset,
|
(void*)indexBaseOffset,
|
||||||
(uint)instanceCount);
|
(uint)instanceCount);
|
||||||
}
|
}
|
||||||
else if (firstInstance == 0)
|
else if (firstInstance == 0)
|
||||||
|
@ -574,7 +568,7 @@ namespace Ryujinx.Graphics.OpenGL
|
||||||
_primitiveType,
|
_primitiveType,
|
||||||
(uint)indexCount,
|
(uint)indexCount,
|
||||||
_elementsType,
|
_elementsType,
|
||||||
in indexBaseOffset,
|
(void*)indexBaseOffset,
|
||||||
(uint)instanceCount,
|
(uint)instanceCount,
|
||||||
firstVertex);
|
firstVertex);
|
||||||
}
|
}
|
||||||
|
@ -584,7 +578,7 @@ namespace Ryujinx.Graphics.OpenGL
|
||||||
_primitiveType,
|
_primitiveType,
|
||||||
(uint)indexCount,
|
(uint)indexCount,
|
||||||
_elementsType,
|
_elementsType,
|
||||||
in indexBaseOffset,
|
(void*)indexBaseOffset,
|
||||||
(uint)instanceCount,
|
(uint)instanceCount,
|
||||||
(uint)firstInstance);
|
(uint)firstInstance);
|
||||||
}
|
}
|
||||||
|
@ -594,7 +588,7 @@ namespace Ryujinx.Graphics.OpenGL
|
||||||
_primitiveType,
|
_primitiveType,
|
||||||
(uint)indexCount,
|
(uint)indexCount,
|
||||||
_elementsType,
|
_elementsType,
|
||||||
in indexBaseOffset,
|
(void*)indexBaseOffset,
|
||||||
(uint)instanceCount,
|
(uint)instanceCount,
|
||||||
firstVertex,
|
firstVertex,
|
||||||
(uint)firstInstance);
|
(uint)firstInstance);
|
||||||
|
@ -623,7 +617,7 @@ namespace Ryujinx.Graphics.OpenGL
|
||||||
PostDraw();
|
PostDraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawIndexedIndirectCount(BufferRange indirectBuffer, BufferRange parameterBuffer, int maxDrawCount, int stride)
|
public unsafe void DrawIndexedIndirectCount(BufferRange indirectBuffer, BufferRange parameterBuffer, int maxDrawCount, int stride)
|
||||||
{
|
{
|
||||||
if (!_program.IsLinked)
|
if (!_program.IsLinked)
|
||||||
{
|
{
|
||||||
|
@ -638,11 +632,10 @@ namespace Ryujinx.Graphics.OpenGL
|
||||||
_gd.Api.BindBuffer(BufferTargetARB.DrawIndirectBuffer, indirectBuffer.Handle.ToUInt32());
|
_gd.Api.BindBuffer(BufferTargetARB.DrawIndirectBuffer, indirectBuffer.Handle.ToUInt32());
|
||||||
_gd.Api.BindBuffer(BufferTargetARB.ParameterBuffer, parameterBuffer.Handle.ToUInt32());
|
_gd.Api.BindBuffer(BufferTargetARB.ParameterBuffer, parameterBuffer.Handle.ToUInt32());
|
||||||
|
|
||||||
var offset = indirectBuffer.Offset;
|
|
||||||
_gd.Api.MultiDrawElementsIndirectCount(
|
_gd.Api.MultiDrawElementsIndirectCount(
|
||||||
_primitiveType,
|
_primitiveType,
|
||||||
_elementsType,
|
_elementsType,
|
||||||
in offset,
|
(void*)indirectBuffer.Offset,
|
||||||
parameterBuffer.Offset,
|
parameterBuffer.Offset,
|
||||||
(uint)maxDrawCount,
|
(uint)maxDrawCount,
|
||||||
(uint)stride);
|
(uint)stride);
|
||||||
|
@ -652,7 +645,7 @@ namespace Ryujinx.Graphics.OpenGL
|
||||||
PostDraw();
|
PostDraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawIndirect(BufferRange indirectBuffer)
|
public unsafe void DrawIndirect(BufferRange indirectBuffer)
|
||||||
{
|
{
|
||||||
if (!_program.IsLinked)
|
if (!_program.IsLinked)
|
||||||
{
|
{
|
||||||
|
@ -664,13 +657,12 @@ namespace Ryujinx.Graphics.OpenGL
|
||||||
|
|
||||||
_gd.Api.BindBuffer(BufferTargetARB.DrawIndirectBuffer, indirectBuffer.Handle.ToUInt32());
|
_gd.Api.BindBuffer(BufferTargetARB.DrawIndirectBuffer, indirectBuffer.Handle.ToUInt32());
|
||||||
|
|
||||||
var offset = indirectBuffer.Offset;
|
_gd.Api.DrawArraysIndirect(_primitiveType, (void*)indirectBuffer.Offset);
|
||||||
_gd.Api.DrawArraysIndirect(_primitiveType, in offset);
|
|
||||||
|
|
||||||
PostDraw();
|
PostDraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawIndirectCount(BufferRange indirectBuffer, BufferRange parameterBuffer, int maxDrawCount, int stride)
|
public unsafe void DrawIndirectCount(BufferRange indirectBuffer, BufferRange parameterBuffer, int maxDrawCount, int stride)
|
||||||
{
|
{
|
||||||
if (!_program.IsLinked)
|
if (!_program.IsLinked)
|
||||||
{
|
{
|
||||||
|
@ -683,10 +675,9 @@ namespace Ryujinx.Graphics.OpenGL
|
||||||
_gd.Api.BindBuffer(BufferTargetARB.DrawIndirectBuffer, indirectBuffer.Handle.ToUInt32());
|
_gd.Api.BindBuffer(BufferTargetARB.DrawIndirectBuffer, indirectBuffer.Handle.ToUInt32());
|
||||||
_gd.Api.BindBuffer(BufferTargetARB.ParameterBuffer, parameterBuffer.Handle.ToUInt32());
|
_gd.Api.BindBuffer(BufferTargetARB.ParameterBuffer, parameterBuffer.Handle.ToUInt32());
|
||||||
|
|
||||||
var offset = indirectBuffer.Offset;
|
|
||||||
_gd.Api.MultiDrawArraysIndirectCount(
|
_gd.Api.MultiDrawArraysIndirectCount(
|
||||||
_primitiveType,
|
_primitiveType,
|
||||||
in offset,
|
(void*)indirectBuffer.Offset,
|
||||||
parameterBuffer.Offset,
|
parameterBuffer.Offset,
|
||||||
(uint)maxDrawCount,
|
(uint)maxDrawCount,
|
||||||
(uint)stride);
|
(uint)stride);
|
||||||
|
@ -1483,7 +1474,7 @@ namespace Ryujinx.Graphics.OpenGL
|
||||||
|
|
||||||
if (buffer.Handle == BufferHandle.Null)
|
if (buffer.Handle == BufferHandle.Null)
|
||||||
{
|
{
|
||||||
_gd.Api.BindBufferRange(target, (uint)assignment.Binding, 0, IntPtr.Zero, 0);
|
_gd.Api.BindBufferRange(target, (uint)assignment.Binding, 0, 0, 0);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ namespace Ryujinx.Graphics.OpenGL
|
||||||
{
|
{
|
||||||
if ((_vertexBuffersInUse & (1u << bindingIndex)) != 0)
|
if ((_vertexBuffersInUse & (1u << bindingIndex)) != 0)
|
||||||
{
|
{
|
||||||
_api.BindVertexBuffer((uint)bindingIndex, 0, IntPtr.Zero, 0);
|
_api.BindVertexBuffer((uint)bindingIndex, 0, 0, 0);
|
||||||
_vertexBuffersInUse &= ~(1u << bindingIndex);
|
_vertexBuffersInUse &= ~(1u << bindingIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue