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/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;
}
}