Ensure that vertex attribute buffer index is valid on GPU (#3942)
* Ensure that vertex attribute buffer index is valid on GPU * Remove vertex buffer validation code from OpenGL * Remove some fields that are no longer necessary
This commit is contained in:
parent
af01100050
commit
8750b90a7f
2 changed files with 26 additions and 41 deletions
|
@ -10,13 +10,9 @@ namespace Ryujinx.Graphics.OpenGL
|
|||
{
|
||||
public int Handle { get; private set; }
|
||||
|
||||
private bool _needsAttribsUpdate;
|
||||
|
||||
private readonly VertexAttribDescriptor[] _vertexAttribs;
|
||||
private readonly VertexBufferDescriptor[] _vertexBuffers;
|
||||
|
||||
private int _vertexAttribsCount;
|
||||
private int _vertexBuffersCount;
|
||||
private int _minVertexCount;
|
||||
|
||||
private uint _vertexAttribsInUse;
|
||||
|
@ -76,9 +72,7 @@ namespace Ryujinx.Graphics.OpenGL
|
|||
_vertexBuffers[bindingIndex] = vb;
|
||||
}
|
||||
|
||||
_vertexBuffersCount = bindingIndex;
|
||||
_minVertexCount = minVertexCount;
|
||||
_needsAttribsUpdate = true;
|
||||
}
|
||||
|
||||
public void SetVertexAttributes(ReadOnlySpan<VertexAttribDescriptor> vertexAttribs)
|
||||
|
@ -131,8 +125,6 @@ namespace Ryujinx.Graphics.OpenGL
|
|||
_vertexAttribs[index] = attrib;
|
||||
}
|
||||
|
||||
_vertexAttribsCount = index;
|
||||
|
||||
for (; index < Constants.MaxVertexAttribs; index++)
|
||||
{
|
||||
DisableVertexAttrib(index);
|
||||
|
@ -160,13 +152,11 @@ namespace Ryujinx.Graphics.OpenGL
|
|||
public void PreDraw(int vertexCount)
|
||||
{
|
||||
LimitVertexBuffers(vertexCount);
|
||||
Validate();
|
||||
}
|
||||
|
||||
public void PreDrawVbUnbounded()
|
||||
{
|
||||
UnlimitVertexBuffers();
|
||||
Validate();
|
||||
}
|
||||
|
||||
public void LimitVertexBuffers(int vertexCount)
|
||||
|
@ -252,36 +242,6 @@ namespace Ryujinx.Graphics.OpenGL
|
|||
_vertexBuffersLimited = 0;
|
||||
}
|
||||
|
||||
public void Validate()
|
||||
{
|
||||
for (int attribIndex = 0; attribIndex < _vertexAttribsCount; attribIndex++)
|
||||
{
|
||||
VertexAttribDescriptor attrib = _vertexAttribs[attribIndex];
|
||||
|
||||
if (!attrib.IsZero)
|
||||
{
|
||||
if ((uint)attrib.BufferIndex >= _vertexBuffersCount)
|
||||
{
|
||||
DisableVertexAttrib(attribIndex);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (_vertexBuffers[attrib.BufferIndex].Buffer.Handle == BufferHandle.Null)
|
||||
{
|
||||
DisableVertexAttrib(attribIndex);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (_needsAttribsUpdate)
|
||||
{
|
||||
EnableVertexAttrib(attribIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_needsAttribsUpdate = false;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private void EnableVertexAttrib(int index)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue