Use D3D11 Debug Annotations when D3D9 is unavailable

Change-Id: I37ac5fe7f0b2fe5e71bd7f0afca55e9894f3463c
Reviewed-on: https://chromium-review.googlesource.com/224512
Tested-by: Austin Kinross <aukinros@microsoft.com>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
diff --git a/src/common/angleutils.cpp b/src/common/angleutils.cpp
index 2ced98d..c1367c4 100644
--- a/src/common/angleutils.cpp
+++ b/src/common/angleutils.cpp
@@ -5,26 +5,32 @@
 //
 
 #include "common/angleutils.h"
-
+#include "debug.h"
 #include <stdio.h>
 #include <vector>
 
+size_t FormatStringIntoVector(const char *fmt, va_list vararg, std::vector<char>& outBuffer)
+{
+    // Attempt to just print to the current buffer
+    int len = vsnprintf(&(outBuffer.front()), outBuffer.size(), fmt, vararg);
+    if (len < 0 || static_cast<size_t>(len) >= outBuffer.size())
+    {
+        // Buffer was not large enough, calculate the required size and resize the buffer
+        len = vsnprintf(NULL, 0, fmt, vararg);
+        outBuffer.resize(len + 1);
+
+        // Print again
+        len = vsnprintf(&(outBuffer.front()), outBuffer.size(), fmt, vararg);
+    }
+    ASSERT(len >= 0);
+    return static_cast<size_t>(len);
+}
+
 std::string FormatString(const char *fmt, va_list vararg)
 {
     static std::vector<char> buffer(512);
 
-    // Attempt to just print to the current buffer
-    int len = vsnprintf(&buffer[0], buffer.size(), fmt, vararg);
-    if (len < 0 || static_cast<size_t>(len) >= buffer.size())
-    {
-        // Buffer was not large enough, calculate the required size and resize the buffer
-        len = vsnprintf(NULL, 0, fmt, vararg);
-        buffer.resize(len + 1);
-
-        // Print again
-        vsnprintf(&buffer[0], buffer.size(), fmt, vararg);
-    }
-
+    size_t len = FormatStringIntoVector(fmt, vararg, buffer);
     return std::string(&buffer[0], len);
 }