Refactoring VertexArrays

BUG=angle:676
Change-Id: If17b05ab667d79adcaacfbd1811ed92c0ce47fff
Reviewed-on: https://chromium-review.googlesource.com/203294
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Tested-by: Geoff Lang <geofflang@chromium.org>
diff --git a/src/libGLESv2/renderer/Renderer.h b/src/libGLESv2/renderer/Renderer.h
index 3d1e294..cb20bac 100644
--- a/src/libGLESv2/renderer/Renderer.h
+++ b/src/libGLESv2/renderer/Renderer.h
@@ -30,7 +30,7 @@
 class InfoLog;
 class ProgramBinary;
 struct LinkedVarying;
-class VertexAttribute;
+struct VertexAttribute;
 class Buffer;
 class Texture;
 class Framebuffer;
@@ -47,6 +47,7 @@
 class IndexBuffer;
 class QueryImpl;
 class FenceImpl;
+class VertexArrayImpl;
 class BufferStorage;
 struct TranslatedIndexData;
 class ShaderExecutable;
@@ -233,6 +234,9 @@
     virtual IndexBuffer *createIndexBuffer() = 0;
     virtual BufferStorage *createBufferStorage() = 0;
 
+    // Vertex Array creation
+    virtual VertexArrayImpl *createVertexArray() = 0;
+
     // Query and Fence creation
     virtual QueryImpl *createQuery(GLenum type) = 0;
     virtual FenceImpl *createFence() = 0;
diff --git a/src/libGLESv2/renderer/VertexArrayImpl.h b/src/libGLESv2/renderer/VertexArrayImpl.h
new file mode 100644
index 0000000..93f34e4
--- /dev/null
+++ b/src/libGLESv2/renderer/VertexArrayImpl.h
@@ -0,0 +1,30 @@
+//
+// Copyright 2014 The ANGLE Project Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+
+// VertexAttribImpl.h: Defines the abstract rx::VertexAttribImpl class.
+
+#ifndef LIBGLESV2_RENDERER_VERTEXARRAYIMPL_H_
+#define LIBGLESV2_RENDERER_VERTEXARRAYIMPL_H_
+
+#include "common/angleutils.h"
+#include "libGLESv2/Buffer.h"
+#include "libGLESv2/VertexAttribute.h"
+
+namespace rx
+{
+
+class VertexArrayImpl
+{
+  public:
+    virtual void setElementArrayBuffer(const gl::Buffer *buffer) = 0;
+    virtual void setAttribute(size_t idx, const gl::VertexAttribute &attr) = 0;
+    virtual void setAttributeDivisor(size_t idx, GLuint divisor) = 0;
+    virtual void enableAttribute(size_t idx, bool enabledState) = 0;
+};
+
+}
+
+#endif // LIBGLESV2_RENDERER_VERTEXARRAYIMPL_H_
diff --git a/src/libGLESv2/renderer/VertexBuffer.cpp b/src/libGLESv2/renderer/VertexBuffer.cpp
index 8adfb5b..87d023f 100644
--- a/src/libGLESv2/renderer/VertexBuffer.cpp
+++ b/src/libGLESv2/renderer/VertexBuffer.cpp
@@ -127,10 +127,10 @@
     return true;
 }
 
-bool VertexBufferInterface::reserveVertexSpace(const gl::VertexAttribute &attribute, GLsizei count, GLsizei instances)
+bool VertexBufferInterface::reserveVertexSpace(const gl::VertexAttribute &attrib, GLsizei count, GLsizei instances)
 {
     unsigned int requiredSpace;
-    if (!mVertexBuffer->getSpaceRequired(attribute, count, instances, &requiredSpace))
+    if (!mVertexBuffer->getSpaceRequired(attrib, count, instances, &requiredSpace))
     {
         return false;
     }
@@ -157,7 +157,7 @@
 bool VertexBufferInterface::directStoragePossible(const gl::VertexAttribute &attrib,
                                                   const gl::VertexAttribCurrentValueData &currentValue) const
 {
-    gl::Buffer *buffer = attrib.mBoundBuffer.get();
+    gl::Buffer *buffer = attrib.buffer.get();
     BufferStorage *storage = buffer ? buffer->getStorage() : NULL;
 
     if (!storage || !storage->supportsDirectBinding())
@@ -171,7 +171,7 @@
     size_t alignment = 4;
     bool requiresConversion = false;
 
-    if (attrib.mType != GL_FLOAT)
+    if (attrib.type != GL_FLOAT)
     {
         gl::VertexFormat vertexFormat(attrib, currentValue.Type);
 
@@ -182,8 +182,8 @@
         requiresConversion = (mRenderer->getVertexConversionType(vertexFormat) & VERTEX_CONVERT_CPU) != 0;
     }
 
-    bool isAligned = (static_cast<size_t>(attrib.stride()) % alignment == 0) &&
-                     (static_cast<size_t>(attrib.mOffset) % alignment == 0);
+    bool isAligned = (static_cast<size_t>(ComputeVertexAttributeStride(attrib)) % alignment == 0) &&
+                     (static_cast<size_t>(attrib.offset) % alignment == 0);
 
     return !requiresConversion && isAligned;
 }
@@ -226,17 +226,17 @@
 {
 }
 
-bool StaticVertexBufferInterface::lookupAttribute(const gl::VertexAttribute &attribute, unsigned int *outStreamOffset)
+bool StaticVertexBufferInterface::lookupAttribute(const gl::VertexAttribute &attrib, unsigned int *outStreamOffset)
 {
     for (unsigned int element = 0; element < mCache.size(); element++)
     {
-        if (mCache[element].type == attribute.mType &&
-            mCache[element].size == attribute.mSize &&
-            mCache[element].stride == attribute.stride() &&
-            mCache[element].normalized == attribute.mNormalized &&
-            mCache[element].pureInteger == attribute.mPureInteger)
+        if (mCache[element].type == attrib.type &&
+            mCache[element].size == attrib.size &&
+            mCache[element].stride == ComputeVertexAttributeStride(attrib) &&
+            mCache[element].normalized == attrib.normalized &&
+            mCache[element].pureInteger == attrib.pureInteger)
         {
-            if (mCache[element].attributeOffset == attribute.mOffset % attribute.stride())
+            if (mCache[element].attributeOffset == attrib.offset % ComputeVertexAttributeStride(attrib))
             {
                 if (outStreamOffset)
                 {
@@ -275,8 +275,8 @@
     unsigned int streamOffset;
     if (VertexBufferInterface::storeVertexAttributes(attrib, currentValue, start, count, instances, &streamOffset))
     {
-        int attributeOffset = attrib.mOffset % attrib.stride();
-        VertexElement element = { attrib.mType, attrib.mSize, attrib.stride(), attrib.mNormalized, attrib.mPureInteger, attributeOffset, streamOffset };
+        int attributeOffset = attrib.offset % ComputeVertexAttributeStride(attrib);
+        VertexElement element = { attrib.type, attrib.size, ComputeVertexAttributeStride(attrib), attrib.normalized, attrib.pureInteger, attributeOffset, streamOffset };
         mCache.push_back(element);
 
         if (outStreamOffset)
diff --git a/src/libGLESv2/renderer/VertexBuffer.h b/src/libGLESv2/renderer/VertexBuffer.h
index d4cdf9e..d492de7 100644
--- a/src/libGLESv2/renderer/VertexBuffer.h
+++ b/src/libGLESv2/renderer/VertexBuffer.h
@@ -14,7 +14,7 @@
 
 namespace gl
 {
-class VertexAttribute;
+struct VertexAttribute;
 struct VertexAttribCurrentValueData;
 }
 
diff --git a/src/libGLESv2/renderer/VertexDataManager.cpp b/src/libGLESv2/renderer/VertexDataManager.cpp
index 6aad5eb..4381b80 100644
--- a/src/libGLESv2/renderer/VertexDataManager.cpp
+++ b/src/libGLESv2/renderer/VertexDataManager.cpp
@@ -27,7 +27,7 @@
 namespace rx
 {
 
-static int ElementsInBuffer(const gl::VertexAttribute &attribute, unsigned int size)
+static int ElementsInBuffer(const gl::VertexAttribute &attrib, unsigned int size)
 {
     // Size cannot be larger than a GLsizei
     if (size > static_cast<unsigned int>(std::numeric_limits<int>::max()))
@@ -35,19 +35,19 @@
         size = static_cast<unsigned int>(std::numeric_limits<int>::max());
     }
 
-    GLsizei stride = attribute.stride();
-    return (size - attribute.mOffset % stride + (stride - attribute.typeSize())) / stride;
+    GLsizei stride = ComputeVertexAttributeStride(attrib);
+    return (size - attrib.offset % stride + (stride - ComputeVertexAttributeTypeSize(attrib))) / stride;
 }
 
-static int StreamingBufferElementCount(const gl::VertexAttribute &attribute, int vertexDrawCount, int instanceDrawCount)
+static int StreamingBufferElementCount(const gl::VertexAttribute &attrib, int vertexDrawCount, int instanceDrawCount)
 {
     // For instanced rendering, we draw "instanceDrawCount" sets of "vertexDrawCount" vertices.
     //
     // A vertex attribute with a positive divisor loads one instanced vertex for every set of
     // non-instanced vertices, and the instanced vertex index advances once every "mDivisor" instances.
-    if (instanceDrawCount > 0 && attribute.mDivisor > 0)
+    if (instanceDrawCount > 0 && attrib.divisor > 0)
     {
-        return instanceDrawCount / attribute.mDivisor;
+        return instanceDrawCount / attrib.divisor;
     }
 
     return vertexDrawCount;
@@ -100,9 +100,9 @@
     // Invalidate static buffers that don't contain matching attributes
     for (int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++)
     {
-        if (translated[i].active && attribs[i].mArrayEnabled)
+        if (translated[i].active && attribs[i].enabled)
         {
-            gl::Buffer *buffer = attribs[i].mBoundBuffer.get();
+            gl::Buffer *buffer = attribs[i].buffer.get();
             StaticVertexBufferInterface *staticBuffer = buffer ? buffer->getStaticVertexBuffer() : NULL;
 
             if (staticBuffer && staticBuffer->getBufferSize() > 0 && !staticBuffer->lookupAttribute(attribs[i], NULL) &&
@@ -116,9 +116,9 @@
     // Reserve the required space in the buffers
     for (int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++)
     {
-        if (translated[i].active && attribs[i].mArrayEnabled)
+        if (translated[i].active && attribs[i].enabled)
         {
-            gl::Buffer *buffer = attribs[i].mBoundBuffer.get();
+            gl::Buffer *buffer = attribs[i].buffer.get();
             StaticVertexBufferInterface *staticBuffer = buffer ? buffer->getStaticVertexBuffer() : NULL;
             VertexBufferInterface *vertexBuffer = staticBuffer ? staticBuffer : static_cast<VertexBufferInterface*>(mStreamingBuffer);
 
@@ -160,11 +160,11 @@
     {
         if (translated[i].active)
         {
-            if (attribs[i].mArrayEnabled)
+            if (attribs[i].enabled)
             {
-                gl::Buffer *buffer = attribs[i].mBoundBuffer.get();
+                gl::Buffer *buffer = attribs[i].buffer.get();
 
-                if (!buffer && attribs[i].mPointer == NULL)
+                if (!buffer && attribs[i].pointer == NULL)
                 {
                     // This is an application error that would normally result in a crash, but we catch it and return an error
                     ERR("An enabled vertex array has no buffer and no pointer.");
@@ -182,8 +182,8 @@
 
                 if (directStorage)
                 {
-                    outputElementSize = attribs[i].stride();
-                    streamOffset = attribs[i].mOffset + outputElementSize * start;
+                    outputElementSize = ComputeVertexAttributeStride(attribs[i]);
+                    streamOffset = attribs[i].offset + outputElementSize * start;
                 }
                 else if (staticBuffer)
                 {
@@ -196,7 +196,7 @@
                     {
                         // Convert the entire buffer
                         int totalCount = ElementsInBuffer(attribs[i], storage->getSize());
-                        int startIndex = attribs[i].mOffset / attribs[i].stride();
+                        int startIndex = attribs[i].offset / ComputeVertexAttributeStride(attribs[i]);
 
                         if (!staticBuffer->storeVertexAttributes(attribs[i], currentValues[i], -startIndex, totalCount,
                                                                  0, &streamOffset))
@@ -205,8 +205,8 @@
                         }
                     }
 
-                    unsigned int firstElementOffset = (attribs[i].mOffset / attribs[i].stride()) * outputElementSize;
-                    unsigned int startOffset = (instances == 0 || attribs[i].mDivisor == 0) ? start * outputElementSize : 0;
+                    unsigned int firstElementOffset = (attribs[i].offset / ComputeVertexAttributeStride(attribs[i])) * outputElementSize;
+                    unsigned int startOffset = (instances == 0 || attribs[i].divisor == 0) ? start * outputElementSize : 0;
                     if (streamOffset + firstElementOffset + startOffset < streamOffset)
                     {
                         return GL_OUT_OF_MEMORY;
@@ -228,7 +228,7 @@
                 translated[i].storage = directStorage ? storage : NULL;
                 translated[i].vertexBuffer = vertexBuffer->getVertexBuffer();
                 translated[i].serial = directStorage ? storage->getSerial() : vertexBuffer->getSerial();
-                translated[i].divisor = attribs[i].mDivisor;
+                translated[i].divisor = attribs[i].divisor;
 
                 translated[i].attribute = &attribs[i];
                 translated[i].currentValueType = currentValues[i].Type;
@@ -276,13 +276,13 @@
 
     for (int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++)
     {
-        if (translated[i].active && attribs[i].mArrayEnabled)
+        if (translated[i].active && attribs[i].enabled)
         {
-            gl::Buffer *buffer = attribs[i].mBoundBuffer.get();
+            gl::Buffer *buffer = attribs[i].buffer.get();
 
             if (buffer)
             {
-                buffer->promoteStaticUsage(count * attribs[i].typeSize());
+                buffer->promoteStaticUsage(count * ComputeVertexAttributeTypeSize(attribs[i]));
             }
         }
     }
diff --git a/src/libGLESv2/renderer/VertexDataManager.h b/src/libGLESv2/renderer/VertexDataManager.h
index 1a69245..2ce8f7f 100644
--- a/src/libGLESv2/renderer/VertexDataManager.h
+++ b/src/libGLESv2/renderer/VertexDataManager.h
@@ -16,7 +16,7 @@
 
 namespace gl
 {
-class VertexAttribute;
+struct VertexAttribute;
 class ProgramBinary;
 struct VertexAttribCurrentValueData;
 }
diff --git a/src/libGLESv2/renderer/d3d11/Renderer11.cpp b/src/libGLESv2/renderer/d3d11/Renderer11.cpp
index 5ff4c59..a90b2cd 100644
--- a/src/libGLESv2/renderer/d3d11/Renderer11.cpp
+++ b/src/libGLESv2/renderer/d3d11/Renderer11.cpp
@@ -31,6 +31,7 @@
 #include "libGLESv2/renderer/d3d11/Blit11.h"
 #include "libGLESv2/renderer/d3d11/Clear11.h"
 #include "libGLESv2/renderer/d3d11/PixelTransfer11.h"
+#include "libGLESv2/renderer/d3d11/VertexArray11.h"
 #include "libEGL/Display.h"
 
 // Enable ANGLE_SKIP_DXGI_1_2_CHECK if there is not a possibility of using cross-process
@@ -2796,6 +2797,11 @@
     return new BufferStorage11(this);
 }
 
+VertexArrayImpl *Renderer11::createVertexArray()
+{
+    return new VertexArray11(this);
+}
+
 QueryImpl *Renderer11::createQuery(GLenum type)
 {
     return new Query11(this, type);
diff --git a/src/libGLESv2/renderer/d3d11/Renderer11.h b/src/libGLESv2/renderer/d3d11/Renderer11.h
index 8fe39ab..e940599 100644
--- a/src/libGLESv2/renderer/d3d11/Renderer11.h
+++ b/src/libGLESv2/renderer/d3d11/Renderer11.h
@@ -189,6 +189,9 @@
     virtual IndexBuffer *createIndexBuffer();
     virtual BufferStorage *createBufferStorage();
 
+    // Vertex Array creation
+    virtual VertexArrayImpl *createVertexArray();
+
     // Query and Fence creation
     virtual QueryImpl *createQuery(GLenum type);
     virtual FenceImpl *createFence();
diff --git a/src/libGLESv2/renderer/d3d11/VertexArray11.h b/src/libGLESv2/renderer/d3d11/VertexArray11.h
new file mode 100644
index 0000000..abe96ea
--- /dev/null
+++ b/src/libGLESv2/renderer/d3d11/VertexArray11.h
@@ -0,0 +1,42 @@
+//
+// Copyright 2014 The ANGLE Project Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+
+// VertexArray11.h: Defines the rx::VertexArray11 class which implements rx::VertexArrayImpl.
+
+#ifndef LIBGLESV2_RENDERER_VERTEXARRAY11_H_
+#define LIBGLESV2_RENDERER_VERTEXARRAY11_H_
+
+#include "libGLESv2/renderer/VertexArrayImpl.h"
+#include "libGLESv2/renderer/d3d11/Renderer11.h"
+
+namespace rx
+{
+class Renderer11;
+
+class VertexArray11 : public VertexArrayImpl
+{
+  public:
+    VertexArray11(rx::Renderer11 *renderer)
+        : VertexArrayImpl(),
+          mRenderer(renderer)
+    {
+    }
+    virtual ~VertexArray11() { }
+
+    virtual void setElementArrayBuffer(const gl::Buffer *buffer) { }
+    virtual void setAttribute(size_t idx, const gl::VertexAttribute &attr) { }
+    virtual void setAttributeDivisor(size_t idx, GLuint divisor) { }
+    virtual void enableAttribute(size_t idx, bool enabledState) { }
+
+  private:
+    DISALLOW_COPY_AND_ASSIGN(VertexArray11);
+
+    rx::Renderer11 *mRenderer;
+};
+
+}
+
+#endif // LIBGLESV2_RENDERER_VERTEXARRAY11_H_
diff --git a/src/libGLESv2/renderer/d3d11/VertexBuffer11.cpp b/src/libGLESv2/renderer/d3d11/VertexBuffer11.cpp
index d69668d..f6e252f 100644
--- a/src/libGLESv2/renderer/d3d11/VertexBuffer11.cpp
+++ b/src/libGLESv2/renderer/d3d11/VertexBuffer11.cpp
@@ -71,8 +71,8 @@
 {
     if (mBuffer)
     {
-        gl::Buffer *buffer = attrib.mBoundBuffer.get();
-        int inputStride = attrib.stride();
+        gl::Buffer *buffer = attrib.buffer.get();
+        int inputStride = ComputeVertexAttributeStride(attrib);
         ID3D11DeviceContext *dxContext = mRenderer->getDeviceContext();
 
         D3D11_MAPPED_SUBRESOURCE mappedResource;
@@ -86,16 +86,16 @@
         char* output = reinterpret_cast<char*>(mappedResource.pData) + offset;
 
         const char *input = NULL;
-        if (attrib.mArrayEnabled)
+        if (attrib.enabled)
         {
             if (buffer)
             {
                 BufferStorage *storage = buffer->getStorage();
-                input = static_cast<const char*>(storage->getData()) + static_cast<int>(attrib.mOffset);
+                input = static_cast<const char*>(storage->getData()) + static_cast<int>(attrib.offset);
             }
             else
             {
-                input = static_cast<const char*>(attrib.mPointer);
+                input = static_cast<const char*>(attrib.pointer);
             }
         }
         else
@@ -103,7 +103,7 @@
             input = reinterpret_cast<const char*>(currentValue.FloatValues);
         }
 
-        if (instances == 0 || attrib.mDivisor == 0)
+        if (instances == 0 || attrib.divisor == 0)
         {
             input += inputStride * start;
         }
@@ -128,22 +128,22 @@
                                       GLsizei instances, unsigned int *outSpaceRequired) const
 {
     unsigned int elementCount = 0;
-    if (attrib.mArrayEnabled)
+    if (attrib.enabled)
     {
-        if (instances == 0 || attrib.mDivisor == 0)
+        if (instances == 0 || attrib.divisor == 0)
         {
             elementCount = count;
         }
         else
         {
-            if (static_cast<unsigned int>(instances) < std::numeric_limits<unsigned int>::max() - (attrib.mDivisor - 1))
+            if (static_cast<unsigned int>(instances) < std::numeric_limits<unsigned int>::max() - (attrib.divisor - 1))
             {
                 // Round up
-                elementCount = rx::roundUp(static_cast<unsigned int>(instances), attrib.mDivisor);
+                elementCount = rx::roundUp(static_cast<unsigned int>(instances), attrib.divisor);
             }
             else
             {
-                elementCount = instances / attrib.mDivisor;
+                elementCount = instances / attrib.divisor;
             }
         }
 
diff --git a/src/libGLESv2/renderer/d3d9/Renderer9.cpp b/src/libGLESv2/renderer/d3d9/Renderer9.cpp
index 23eb2be..05916d8 100644
--- a/src/libGLESv2/renderer/d3d9/Renderer9.cpp
+++ b/src/libGLESv2/renderer/d3d9/Renderer9.cpp
@@ -30,6 +30,7 @@
 #include "libGLESv2/renderer/d3d9/BufferStorage9.h"
 #include "libGLESv2/renderer/d3d9/Query9.h"
 #include "libGLESv2/renderer/d3d9/Fence9.h"
+#include "libGLESv2/renderer/d3d9/VertexArray9.h"
 #include "libGLESv2/angletypes.h"
 
 #include "libEGL/Display.h"
@@ -611,6 +612,11 @@
     return new BufferStorage9();
 }
 
+VertexArrayImpl *Renderer9::createVertexArray()
+{
+    return new VertexArray9(this);
+}
+
 QueryImpl *Renderer9::createQuery(GLenum type)
 {
     return new Query9(this, type);
diff --git a/src/libGLESv2/renderer/d3d9/Renderer9.h b/src/libGLESv2/renderer/d3d9/Renderer9.h
index ecf310d..71fc69f 100644
--- a/src/libGLESv2/renderer/d3d9/Renderer9.h
+++ b/src/libGLESv2/renderer/d3d9/Renderer9.h
@@ -191,6 +191,9 @@
     virtual IndexBuffer *createIndexBuffer();
     virtual BufferStorage *createBufferStorage();
 
+    // Vertex Array creation
+    virtual VertexArrayImpl *createVertexArray();
+
     // Query and Fence creation
     virtual QueryImpl *createQuery(GLenum type);
     virtual FenceImpl *createFence();
diff --git a/src/libGLESv2/renderer/d3d9/VertexArray9.h b/src/libGLESv2/renderer/d3d9/VertexArray9.h
new file mode 100644
index 0000000..bee63bb
--- /dev/null
+++ b/src/libGLESv2/renderer/d3d9/VertexArray9.h
@@ -0,0 +1,43 @@
+//
+// Copyright 2014 The ANGLE Project Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+
+// VertexArray9.h: Defines the rx::VertexArray9 class which implements rx::VertexArrayImpl.
+
+#ifndef LIBGLESV2_RENDERER_VERTEXARRAY9_H_
+#define LIBGLESV2_RENDERER_VERTEXARRAY9_H_
+
+#include "libGLESv2/renderer/VertexArrayImpl.h"
+#include "libGLESv2/renderer/d3d9/Renderer9.h"
+
+namespace rx
+{
+class Renderer9;
+
+class VertexArray9 : public VertexArrayImpl
+{
+  public:
+    VertexArray9(rx::Renderer9 *renderer)
+        : VertexArrayImpl(),
+          mRenderer(renderer)
+    {
+    }
+
+    virtual ~VertexArray9() { }
+
+    virtual void setElementArrayBuffer(const gl::Buffer *buffer) { }
+    virtual void setAttribute(size_t idx, const gl::VertexAttribute &attr) { }
+    virtual void setAttributeDivisor(size_t idx, GLuint divisor) { }
+    virtual void enableAttribute(size_t idx, bool enabledState) { }
+
+  private:
+    DISALLOW_COPY_AND_ASSIGN(VertexArray9);
+
+    rx::Renderer9 *mRenderer;
+};
+
+}
+
+#endif // LIBGLESV2_RENDERER_VERTEXARRAY9_H_
diff --git a/src/libGLESv2/renderer/d3d9/VertexBuffer9.cpp b/src/libGLESv2/renderer/d3d9/VertexBuffer9.cpp
index 42ddfca..be9f21a 100644
--- a/src/libGLESv2/renderer/d3d9/VertexBuffer9.cpp
+++ b/src/libGLESv2/renderer/d3d9/VertexBuffer9.cpp
@@ -70,10 +70,10 @@
 {
     if (mVertexBuffer)
     {
-        gl::Buffer *buffer = attrib.mBoundBuffer.get();
+        gl::Buffer *buffer = attrib.buffer.get();
 
-        int inputStride = attrib.stride();
-        int elementSize = attrib.typeSize();
+        int inputStride = gl::ComputeVertexAttributeStride(attrib);
+        int elementSize = gl::ComputeVertexAttributeTypeSize(attrib);
 
         DWORD lockFlags = mDynamicUsage ? D3DLOCK_NOOVERWRITE : 0;
 
@@ -94,16 +94,16 @@
         }
 
         const char *input = NULL;
-        if (attrib.mArrayEnabled)
+        if (attrib.enabled)
         {
             if (buffer)
             {
                 BufferStorage *storage = buffer->getStorage();
-                input = static_cast<const char*>(storage->getData()) + static_cast<int>(attrib.mOffset);
+                input = static_cast<const char*>(storage->getData()) + static_cast<int>(attrib.offset);
             }
             else
             {
-                input = static_cast<const char*>(attrib.mPointer);
+                input = static_cast<const char*>(attrib.pointer);
             }
         }
         else
@@ -111,7 +111,7 @@
             input = reinterpret_cast<const char*>(currentValue.FloatValues);
         }
 
-        if (instances == 0 || attrib.mDivisor == 0)
+        if (instances == 0 || attrib.divisor == 0)
         {
             input += inputStride * start;
         }
@@ -205,23 +205,23 @@
     gl::VertexFormat vertexFormat(attrib, GL_FLOAT);
     unsigned int elementSize = d3d9::GetVertexElementSize(vertexFormat);
 
-    if (attrib.mArrayEnabled)
+    if (attrib.enabled)
     {
         unsigned int elementCount = 0;
-        if (instances == 0 || attrib.mDivisor == 0)
+        if (instances == 0 || attrib.divisor == 0)
         {
             elementCount = count;
         }
         else
         {
-            if (static_cast<unsigned int>(instances) < std::numeric_limits<unsigned int>::max() - (attrib.mDivisor - 1))
+            if (static_cast<unsigned int>(instances) < std::numeric_limits<unsigned int>::max() - (attrib.divisor - 1))
             {
                 // Round up
-                elementCount = (static_cast<unsigned int>(instances) + (attrib.mDivisor - 1)) / attrib.mDivisor;
+                elementCount = (static_cast<unsigned int>(instances) + (attrib.divisor - 1)) / attrib.divisor;
             }
             else
             {
-                elementCount = static_cast<unsigned int>(instances) / attrib.mDivisor;
+                elementCount = static_cast<unsigned int>(instances) / attrib.divisor;
             }
         }