D3D11: Move more state into StateManager11.

This moves the input layout cache and vertex and index data managers
and related info into the state manager. This makes it easier to
manage the state application with regards to dirty bits.

Also updates the dirty current value handling in StateManager11.

BUG=angleproject:1156
BUG=angleproject:2052

Change-Id: I8de968a1f8416363aa1c49d9e9da129942d21275
Reviewed-on: https://chromium-review.googlesource.com/616783
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/renderer/d3d/VertexDataManager.cpp b/src/libANGLE/renderer/d3d/VertexDataManager.cpp
index a73448b..f5c6cf0 100644
--- a/src/libANGLE/renderer/d3d/VertexDataManager.cpp
+++ b/src/libANGLE/renderer/d3d/VertexDataManager.cpp
@@ -113,6 +113,7 @@
 TranslatedAttribute::TranslatedAttribute()
     : active(false),
       attribute(nullptr),
+      binding(nullptr),
       currentValueType(GL_NONE),
       baseOffset(0),
       usesFirstVertexOffset(false),
@@ -176,9 +177,7 @@
     }
 }
 
-VertexDataManager::CurrentValueState::CurrentValueState()
-    : buffer(nullptr),
-      offset(0)
+VertexDataManager::CurrentValueState::CurrentValueState() : buffer(), offset(0)
 {
     data.FloatValues[0] = std::numeric_limits<float>::quiet_NaN();
     data.FloatValues[1] = std::numeric_limits<float>::quiet_NaN();
@@ -189,26 +188,33 @@
 
 VertexDataManager::CurrentValueState::~CurrentValueState()
 {
-    SafeDelete(buffer);
 }
 
 VertexDataManager::VertexDataManager(BufferFactoryD3D *factory)
-    : mFactory(factory),
-      mStreamingBuffer(nullptr),
-      // TODO(jmadill): use context caps
-      mCurrentValueCache(gl::MAX_VERTEX_ATTRIBS)
+    : mFactory(factory), mStreamingBuffer(), mCurrentValueCache(gl::MAX_VERTEX_ATTRIBS)
 {
-    mStreamingBuffer = new StreamingVertexBufferInterface(factory, INITIAL_STREAM_BUFFER_SIZE);
-
-    if (!mStreamingBuffer)
-    {
-        ERR() << "Failed to allocate the streaming vertex buffer.";
-    }
 }
 
 VertexDataManager::~VertexDataManager()
 {
-    SafeDelete(mStreamingBuffer);
+}
+
+gl::Error VertexDataManager::initialize()
+{
+    mStreamingBuffer.reset(
+        new StreamingVertexBufferInterface(mFactory, INITIAL_STREAM_BUFFER_SIZE));
+    if (!mStreamingBuffer)
+    {
+        return gl::OutOfMemory() << "Failed to allocate the streaming vertex buffer.";
+    }
+
+    return gl::NoError();
+}
+
+void VertexDataManager::deinitialize()
+{
+    mStreamingBuffer.reset();
+    mCurrentValueCache.clear();
 }
 
 gl::Error VertexDataManager::prepareVertexData(const gl::State &state,
@@ -398,7 +404,7 @@
     };
 
     // Will trigger unmapping on return.
-    StreamingBufferUnmapper localUnmapper(mStreamingBuffer);
+    StreamingBufferUnmapper localUnmapper(mStreamingBuffer.get());
 
     // Reserve the required space for the dynamic buffers.
     for (auto attribIndex : dynamicAttribsMask)
@@ -522,11 +528,11 @@
                                                size_t attribIndex)
 {
     CurrentValueState *cachedState = &mCurrentValueCache[attribIndex];
-    auto *&buffer                  = cachedState->buffer;
+    auto &buffer                   = cachedState->buffer;
 
     if (!buffer)
     {
-        buffer = new StreamingVertexBufferInterface(mFactory, CONSTANT_VERTEX_BUFFER_SIZE);
+        buffer.reset(new StreamingVertexBufferInterface(mFactory, CONSTANT_VERTEX_BUFFER_SIZE));
     }
 
     if (cachedState->data != currentValue)