From 8750b90a7f5e76cdff991a137ec8c2eed0db00dd Mon Sep 17 00:00:00 2001
From: gdkchan <gab.dark.100@gmail.com>
Date: Wed, 30 Nov 2022 18:06:40 -0300
Subject: 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
---
 Ryujinx.Graphics.OpenGL/VertexArray.cs | 40 ----------------------------------
 1 file changed, 40 deletions(-)

(limited to 'Ryujinx.Graphics.OpenGL/VertexArray.cs')

diff --git a/Ryujinx.Graphics.OpenGL/VertexArray.cs b/Ryujinx.Graphics.OpenGL/VertexArray.cs
index d466199d..7d22033e 100644
--- a/Ryujinx.Graphics.OpenGL/VertexArray.cs
+++ b/Ryujinx.Graphics.OpenGL/VertexArray.cs
@@ -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)
         {
-- 
cgit v1.2.3-70-g09d2