diff --git a/3rdparty/fcpp/cpp.h b/3rdparty/fcpp/cpp.h
index b60c7399..c8084af7 100644
--- a/3rdparty/fcpp/cpp.h
+++ b/3rdparty/fcpp/cpp.h
@@ -202,7 +202,7 @@ typedef struct sizes {
  */
 
 #ifdef	nomacarg
-#define cput		output		/* cput concatenates tokens	*/
+#define cput		generate		/* cput concatenates tokens	*/
 #else
 #if COMMENT_INVISIBLE
 #define cput(c)         { if (c != TOK_SEP && c != COM_SEP) putchar(c); }
diff --git a/3rdparty/openctm/lib/compressMG2.c b/3rdparty/openctm/lib/compressMG2.c
index 78792834..064379a9 100644
--- a/3rdparty/openctm/lib/compressMG2.c
+++ b/3rdparty/openctm/lib/compressMG2.c
@@ -506,7 +506,7 @@ static void _ctmMakeNormalCoordSys(CTMfloat * aNormal, CTMfloat * aBasisAxes)
   x[2] =  aNormal[1];
 
   // Normalize the new X axis (note: |x[2]| = |x[0]|)
-  len = sqrtf(2.0 * x[0] * x[0] + x[1] * x[1]);
+  len = sqrtf(2.0f * x[0] * x[0] + x[1] * x[1]);
   if(len > 1.0e-20f)
   {
     len = 1.0f / len;
diff --git a/3rdparty/openctm/lib/openctm.c b/3rdparty/openctm/lib/openctm.c
index f1b9303a..03461201 100644
--- a/3rdparty/openctm/lib/openctm.c
+++ b/3rdparty/openctm/lib/openctm.c
@@ -913,7 +913,7 @@ CTMEXPORT void CTMCALL ctmFileComment(CTMcontext aContext,
   // Get length of string (if empty, do nothing)
   if(!aFileComment)
     return;
-  len = strlen(aFileComment);
+  len = (int)strlen(aFileComment);
   if(!len)
     return;
 
@@ -1005,7 +1005,7 @@ static _CTMfloatmap * _ctmAddFloatMap(_CTMcontext * self,
   if(aName)
   {
     // Get length of string (if empty, do nothing)
-    len = strlen(aName);
+    len = (CTMuint)strlen(aName);
     if(len)
     {
       // Copy the string
@@ -1024,7 +1024,7 @@ static _CTMfloatmap * _ctmAddFloatMap(_CTMcontext * self,
   if(aFileName)
   {
     // Get length of string (if empty, do nothing)
-    len = strlen(aFileName);
+    len = (CTMuint)strlen(aFileName);
     if(len)
     {
       // Copy the string
diff --git a/3rdparty/openctm/lib/stream.c b/3rdparty/openctm/lib/stream.c
index 5ed85b7a..5cd67cd0 100644
--- a/3rdparty/openctm/lib/stream.c
+++ b/3rdparty/openctm/lib/stream.c
@@ -155,7 +155,7 @@ void _ctmStreamWriteSTRING(_CTMcontext * self, const char * aValue)
 
   // Get string length
   if(aValue)
-    len = strlen(aValue);
+    len = (CTMuint)strlen(aValue);
   else
     len = 0;
 
@@ -194,7 +194,7 @@ int _ctmStreamReadPackedInts(_CTMcontext * self, CTMint * aData,
     self->mError = CTM_OUT_OF_MEMORY;
     return CTM_FALSE;
   }
-  _ctmStreamRead(self, (void *) packed, packedSize);
+  _ctmStreamRead(self, (void *) packed, (CTMuint)packedSize);
 
   // Allocate memory for interleaved array
   tmp = (unsigned char *) malloc(aCount * aSize * 4);
@@ -374,7 +374,7 @@ int _ctmStreamReadPackedFloats(_CTMcontext * self, CTMfloat * aData,
     self->mError = CTM_OUT_OF_MEMORY;
     return CTM_FALSE;
   }
-  _ctmStreamRead(self, (void *) packed, packedSize);
+  _ctmStreamRead(self, (void *) packed, (CTMuint)packedSize);
 
   // Allocate memory for interleaved array
   tmp = (unsigned char *) malloc(aCount * aSize * 4);
diff --git a/3rdparty/openctm/tools/3ds.cpp b/3rdparty/openctm/tools/3ds.cpp
index 62f0beae..10761894 100644
--- a/3rdparty/openctm/tools/3ds.cpp
+++ b/3rdparty/openctm/tools/3ds.cpp
@@ -25,7 +25,7 @@
 //     distribution.
 //-----------------------------------------------------------------------------
 
-#include <stdexcept>
+#include "common.h"
 #include <fstream>
 #include <vector>
 #include <list>
@@ -174,16 +174,16 @@ void Import_3DS(const char * aFileName, Mesh * aMesh)
   // Open the input file
   ifstream f(aFileName, ios::in | ios::binary);
   if(f.fail())
-    throw runtime_error("Could not open input file.");
+    throw_runtime_error("Could not open input file.");
 
   // Get file size
   f.seekg(0, ios::end);
-  uint32 fileSize = f.tellg();
+  uint32 fileSize = (uint32)f.tellg();
   f.seekg(0, ios::beg);
 
   // Check file size (rough initial check)
   if(fileSize < 6)
-    throw runtime_error("Invalid 3DS file format.");
+    throw_runtime_error("Invalid 3DS file format.");
 
   uint16 chunk, count;
   uint32 chunkLen;
@@ -192,7 +192,7 @@ void Import_3DS(const char * aFileName, Mesh * aMesh)
   chunk = ReadInt16(f);
   chunkLen = ReadInt32(f);
   if((chunk != CHUNK_MAIN) || (chunkLen != fileSize))
-    throw runtime_error("Invalid 3DS file format.");
+    throw_runtime_error("Invalid 3DS file format.");
 
   // Parse chunks, and store the data in a temporary list, objList...
   Obj3DS * obj = 0;
@@ -287,8 +287,8 @@ void Import_3DS(const char * aFileName, Mesh * aMesh)
   for(list<Obj3DS>::iterator o = objList.begin(); o != objList.end(); ++ o)
   {
     // Append...
-    uint32 idxOffset = aMesh->mIndices.size();
-    uint32 vertOffset = aMesh->mVertices.size();
+    uint32 idxOffset = (uint32)aMesh->mIndices.size();
+    uint32 vertOffset = (uint32)aMesh->mVertices.size();
     aMesh->mIndices.resize(idxOffset + (*o).mIndices.size());
     aMesh->mVertices.resize(vertOffset + (*o).mVertices.size());
     if(hasUVCoords)
@@ -317,7 +317,7 @@ void Export_3DS(const char * aFileName, Mesh * aMesh, Options &aOptions)
   // First, check that the mesh fits in a 3DS file (at most 65535 triangles
   // and 65535 vertices are supported).
   if((aMesh->mIndices.size() > (3*65535)) || (aMesh->mVertices.size() > 65535))
-    throw runtime_error("The mesh is too large to fit in a 3DS file.");
+    throw_runtime_error("The mesh is too large to fit in a 3DS file.");
 
   // What should we export?
   bool exportTexCoords = aMesh->HasTexCoords() && !aOptions.mNoTexCoords;
@@ -327,16 +327,16 @@ void Export_3DS(const char * aFileName, Mesh * aMesh, Options &aOptions)
   string matName("Material0");
 
   // Get mesh properties
-  uint32 triCount = aMesh->mIndices.size() / 3;
-  uint32 vertCount = aMesh->mVertices.size();
+  uint32 triCount = (uint32)(aMesh->mIndices.size() / 3);
+  uint32 vertCount = (uint32)aMesh->mVertices.size();
 
   // Calculate the material chunk size
   uint32 materialSize = 0;
   uint32 matGroupSize = 0;
   if(exportTexCoords && aMesh->mTexFileName.size() > 0)
   {
-    materialSize += 24 + matName.size() + 1 + aMesh->mTexFileName.size() + 1;
-    matGroupSize += 8 + matName.size() + 1 + 2 * triCount;
+    materialSize += 24 + (uint32)matName.size() + 1 + (uint32)aMesh->mTexFileName.size() + 1;
+    matGroupSize += 8 + (uint32)matName.size() + 1 + 2 * triCount;
   }
 
   // Calculate the mesh chunk size
@@ -345,12 +345,12 @@ void Export_3DS(const char * aFileName, Mesh * aMesh, Options &aOptions)
     triMeshSize += 8 + 8 * vertCount;
 
   // Calculate the total file size
-  uint32 fileSize = 38 + objName.size() + 1 + materialSize + triMeshSize;
+  uint32 fileSize = 38 + (uint32)objName.size() + 1 + materialSize + triMeshSize;
 
   // Open the output file
   ofstream f(aFileName, ios::out | ios::binary);
   if(f.fail())
-    throw runtime_error("Could not open output file.");
+    throw_runtime_error("Could not open output file.");
 
   // Write file header
   WriteInt16(f, CHUNK_MAIN);
@@ -361,7 +361,7 @@ void Export_3DS(const char * aFileName, Mesh * aMesh, Options &aOptions)
 
   // 3D Edit chunk
   WriteInt16(f, CHUNK_3DEDIT);
-  WriteInt32(f, 16 + materialSize + objName.size() + 1 + triMeshSize);
+  WriteInt32(f, 16 + materialSize + (uint32)objName.size() + 1 + triMeshSize);
   WriteInt16(f, CHUNK_MESH_VERSION);
   WriteInt32(f, 6 + 4);
   WriteInt32(f, 0x00000003);
@@ -372,19 +372,19 @@ void Export_3DS(const char * aFileName, Mesh * aMesh, Options &aOptions)
     WriteInt16(f, CHUNK_MAT_ENTRY);
     WriteInt32(f, materialSize);
     WriteInt16(f, CHUNK_MAT_NAME);
-    WriteInt32(f, 6 + matName.size() + 1);
-    f.write(matName.c_str(), matName.size() + 1);
+    WriteInt32(f, 6 + (uint32)matName.size() + 1);
+    f.write(matName.c_str(), (uint32)matName.size() + 1);
     WriteInt16(f, CHUNK_MAT_TEXMAP);
-    WriteInt32(f, 12 + aMesh->mTexFileName.size() + 1);
+    WriteInt32(f, 12 + (uint32)aMesh->mTexFileName.size() + 1);
     WriteInt16(f, CHUNK_MAT_MAPNAME);
-    WriteInt32(f, 6 + aMesh->mTexFileName.size() + 1);
-    f.write(aMesh->mTexFileName.c_str(), aMesh->mTexFileName.size() + 1);
+    WriteInt32(f, 6 + (uint32)aMesh->mTexFileName.size() + 1);
+    f.write(aMesh->mTexFileName.c_str(), (uint32)aMesh->mTexFileName.size() + 1);
   }
 
   // Object chunk
   WriteInt16(f, CHUNK_OBJECT);
-  WriteInt32(f, 6 + objName.size() + 1 + triMeshSize);
-  f.write(objName.c_str(), objName.size() + 1);
+  WriteInt32(f, 6 + (uint32)objName.size() + 1 + triMeshSize);
+  f.write(objName.c_str(), (uint32)objName.size() + 1);
 
   // Triangle Mesh chunk
   WriteInt16(f, CHUNK_TRIMESH);
diff --git a/3rdparty/openctm/tools/common.h b/3rdparty/openctm/tools/common.h
index 11c545b2..9a8b4eb4 100644
--- a/3rdparty/openctm/tools/common.h
+++ b/3rdparty/openctm/tools/common.h
@@ -30,6 +30,8 @@
 
 #include <string>
 
+void throw_runtime_error(std::string str);
+
 // Convert a string to upper case.
 std::string UpperCase(const std::string &aString);
 
diff --git a/3rdparty/openctm/tools/convoptions.cpp b/3rdparty/openctm/tools/convoptions.cpp
index bab301b5..95ac7f35 100644
--- a/3rdparty/openctm/tools/convoptions.cpp
+++ b/3rdparty/openctm/tools/convoptions.cpp
@@ -25,7 +25,7 @@
 //     distribution.
 //-----------------------------------------------------------------------------
 
-#include <stdexcept>
+#include "common.h"
 #include <string>
 #include <sstream>
 #include "convoptions.h"
@@ -106,7 +106,7 @@ void Options::GetFromArgs(int argc, char **argv, int aStartIdx)
       else if(upaxis == string("-Z"))
         mUpAxis = uaNZ;
       else
-        throw runtime_error("Invalid up axis (use X, Y, Z, -X, -Y or -Z).");
+        throw_runtime_error("Invalid up axis (use X, Y, Z, -X, -Y or -Z).");
     }
     else if(cmd == string("--flip"))
     {
@@ -139,13 +139,13 @@ void Options::GetFromArgs(int argc, char **argv, int aStartIdx)
       else if(method == string("MG2"))
         mMethod = CTM_METHOD_MG2;
       else
-        throw runtime_error("Invalid method (use RAW, MG1 or MG2).");
+        throw_runtime_error("Invalid method (use RAW, MG1 or MG2).");
     }
     else if((cmd == string("--level")) && (i < (argc - 1)))
     {
       CTMint val = GetIntArg(argv[i + 1]);
       if( (val < 0) || (val > 9) )
-        throw runtime_error("Invalid compression level (it must be in the range 0 - 9).");
+        throw_runtime_error("Invalid compression level (it must be in the range 0 - 9).");
       mLevel = CTMuint(val);
       ++ i;
     }
@@ -185,6 +185,6 @@ void Options::GetFromArgs(int argc, char **argv, int aStartIdx)
       ++ i;
     }
     else
-      throw runtime_error(string("Invalid argument: ") + cmd);
+      throw_runtime_error(string("Invalid argument: ") + cmd);
   }
 }
diff --git a/3rdparty/openctm/tools/ctm.cpp b/3rdparty/openctm/tools/ctm.cpp
index 7ed749d5..7f1d1b5d 100644
--- a/3rdparty/openctm/tools/ctm.cpp
+++ b/3rdparty/openctm/tools/ctm.cpp
@@ -25,7 +25,7 @@
 //     distribution.
 //-----------------------------------------------------------------------------
 
-#include <stdexcept>
+#include "common.h"
 #include <openctm.h>
 #include "ctm.h"
 
@@ -123,8 +123,8 @@ void Export_CTM(const char * aFileName, Mesh * aMesh, Options &aOptions)
   CTMfloat * normals = 0;
   if(aMesh->HasNormals() && !aOptions.mNoNormals)
     normals = &aMesh->mNormals[0].x;
-  ctm.DefineMesh((CTMfloat *) &aMesh->mVertices[0].x, aMesh->mVertices.size(),
-                 (const CTMuint*) &aMesh->mIndices[0], aMesh->mIndices.size() / 3,
+  ctm.DefineMesh((CTMfloat *) &aMesh->mVertices[0].x, (CTMuint)aMesh->mVertices.size(),
+                 (const CTMuint*) &aMesh->mIndices[0], (CTMuint)aMesh->mIndices.size() / 3,
                  normals);
 
   // Define texture coordinates
diff --git a/3rdparty/openctm/tools/ctmconv.cpp b/3rdparty/openctm/tools/ctmconv.cpp
index 62993aab..07e6811e 100644
--- a/3rdparty/openctm/tools/ctmconv.cpp
+++ b/3rdparty/openctm/tools/ctmconv.cpp
@@ -27,7 +27,7 @@
 //     distribution.
 //-----------------------------------------------------------------------------
 
-#include <stdexcept>
+#include "common.h"
 #include <vector>
 #include <iostream>
 #include <list>
@@ -113,7 +113,7 @@ static void PreProcessMesh(Mesh &aMesh, Options &aOptions)
   // Flip trianlges?
   if(aOptions.mFlipTriangles)
   {
-    CTMuint triCount = aMesh.mIndices.size() / 3;
+    CTMuint triCount = (CTMuint)(aMesh.mIndices.size() / 3);
     for(CTMuint i = 0; i < triCount; ++ i)
     {
       CTMuint tmp = aMesh.mIndices[i * 3];
@@ -131,6 +131,11 @@ static void PreProcessMesh(Mesh &aMesh, Options &aOptions)
   cout << 1000.0 * dt << " ms" << endl;
 }
 
+void throw_runtime_error(std::string str)
+{
+	cout << "Error: " << str << endl;
+	abort();
+}
 
 //-----------------------------------------------------------------------------
 // main()
@@ -141,94 +146,84 @@ int main(int argc, char ** argv)
   Options opt;
   string inFile;
   string outFile;
-  try
-  {
-    if(argc < 3)
-      throw runtime_error("Too few arguments.");
-    inFile = string(argv[1]);
-    outFile = string(argv[2]);
-    opt.GetFromArgs(argc, argv, 3);
-  }
-  catch(exception &e)
-  {
-    cout << "Error: " << e.what() << endl << endl;
-    cout << "Usage: " << argv[0] << " infile outfile [options]" << endl << endl;
-    cout << "Options:" << endl;
-    cout << endl << " Data manipulation (all formats)" << endl;
-    cout << "  --scale arg     Scale the mesh by a scalar factor." << endl;
-    cout << "  --upaxis arg    Set up axis (X, Y, Z, -X, -Y, -Z). If != Z, the mesh will" << endl;
-    cout << "                  be flipped." << endl;
-    cout << "  --flip          Flip triangle orientation." << endl;
-    cout << "  --calc-normals  If the source file does not contain any normals, calculate" << endl;
-    cout << "                  them." << endl;
-    cout << "  --no-normals    Do not export normals." << endl;
-    cout << "  --no-texcoords  Do not export texture coordinates." << endl;
-    cout << "  --no-colors     Do not export vertex colors." << endl;
-    cout << endl << " OpenCTM output" << endl;
-    cout << "  --method arg    Select compression method (RAW, MG1, MG2)" << endl;
-    cout << "  --level arg     Set the compression level (0 - 9)" << endl;
-    cout << endl << " OpenCTM MG2 method" << endl;
-    cout << "  --vprec arg     Set vertex precision" << endl;
-    cout << "  --vprecrel arg  Set vertex precision, relative method" << endl;
-    cout << "  --nprec arg     Set normal precision" << endl;
-    cout << "  --tprec arg     Set texture map precision" << endl;
-    cout << "  --cprec arg     Set color precision" << endl;
-    cout << endl << " Miscellaneous" << endl;
-    cout << "  --comment arg   Set the file comment (default is to use the comment" << endl;
-    cout << "                  from the input file, if any)." << endl;
-    cout << "  --texfile arg   Set the texture file name reference for the texture" << endl;
-    cout << "                  (default is to use the texture file name reference" << endl;
-    cout << "                  from the input file, if any)." << endl;
 
-    // Show supported formats
-    cout << endl << "Supported file formats:" << endl << endl;
-    list<string> formatList;
-    SupportedFormats(formatList);
-    for(list<string>::iterator i = formatList.begin(); i != formatList.end(); ++ i)
-      cout << "  " << (*i) << endl;
-    cout << endl;
+  if(argc < 3)
+  {
+	  cout << "Error: Too few arguments." << endl << endl;
+	  cout << "Usage: " << argv[0] << " infile outfile [options]" << endl << endl;
+	  cout << "Options:" << endl;
+	  cout << endl << " Data manipulation (all formats)" << endl;
+	  cout << "  --scale arg     Scale the mesh by a scalar factor." << endl;
+	  cout << "  --upaxis arg    Set up axis (X, Y, Z, -X, -Y, -Z). If != Z, the mesh will" << endl;
+	  cout << "                  be flipped." << endl;
+	  cout << "  --flip          Flip triangle orientation." << endl;
+	  cout << "  --calc-normals  If the source file does not contain any normals, calculate" << endl;
+	  cout << "                  them." << endl;
+	  cout << "  --no-normals    Do not export normals." << endl;
+	  cout << "  --no-texcoords  Do not export texture coordinates." << endl;
+	  cout << "  --no-colors     Do not export vertex colors." << endl;
+	  cout << endl << " OpenCTM output" << endl;
+	  cout << "  --method arg    Select compression method (RAW, MG1, MG2)" << endl;
+	  cout << "  --level arg     Set the compression level (0 - 9)" << endl;
+	  cout << endl << " OpenCTM MG2 method" << endl;
+	  cout << "  --vprec arg     Set vertex precision" << endl;
+	  cout << "  --vprecrel arg  Set vertex precision, relative method" << endl;
+	  cout << "  --nprec arg     Set normal precision" << endl;
+	  cout << "  --tprec arg     Set texture map precision" << endl;
+	  cout << "  --cprec arg     Set color precision" << endl;
+	  cout << endl << " Miscellaneous" << endl;
+	  cout << "  --comment arg   Set the file comment (default is to use the comment" << endl;
+	  cout << "                  from the input file, if any)." << endl;
+	  cout << "  --texfile arg   Set the texture file name reference for the texture" << endl;
+	  cout << "                  (default is to use the texture file name reference" << endl;
+	  cout << "                  from the input file, if any)." << endl;
 
-    return 0;
+	  // Show supported formats
+	  cout << endl << "Supported file formats:" << endl << endl;
+	  list<string> formatList;
+	  SupportedFormats(formatList);
+	  for(list<string>::iterator i = formatList.begin(); i != formatList.end(); ++ i)
+		  cout << "  " << (*i) << endl;
+	  cout << endl;
+
+	  return 0;
   }
 
-  try
-  {
-    // Define mesh
-    Mesh mesh;
+  inFile = string(argv[1]);
+  outFile = string(argv[2]);
+  opt.GetFromArgs(argc, argv, 3);
 
-    // Create a timer instance
-    SysTimer timer;
-    double dt;
+	// Define mesh
+	Mesh mesh;
 
-    // Load input file
-    cout << "Loading " << inFile << "... " << flush;
-    timer.Push();
-    ImportMesh(inFile.c_str(), &mesh);
-    dt = timer.PopDelta();
-    cout << 1000.0 * dt << " ms" << endl;
+	// Create a timer instance
+	SysTimer timer;
+	double dt;
 
-    // Manipulate the mesh
-    PreProcessMesh(mesh, opt);
+	// Load input file
+	cout << "Loading " << inFile << "... " << flush;
+	timer.Push();
+	ImportMesh(inFile.c_str(), &mesh);
+	dt = timer.PopDelta();
+	cout << 1000.0 * dt << " ms" << endl;
 
-    // Override comment?
-    if(opt.mComment.size() > 0)
-      mesh.mComment = opt.mComment;
+	// Manipulate the mesh
+	PreProcessMesh(mesh, opt);
 
-    // Override texture file name?
-    if(opt.mTexFileName.size() > 0)
-      mesh.mTexFileName = opt.mTexFileName;
+	// Override comment?
+	if(opt.mComment.size() > 0)
+	  mesh.mComment = opt.mComment;
 
-    // Save output file
-    cout << "Saving " << outFile << "... " << flush;
-    timer.Push();
-    ExportMesh(outFile.c_str(), &mesh, opt);
-    dt = timer.PopDelta();
-    cout << 1000.0 * dt << " ms" << endl;
-  }
-  catch(exception &e)
-  {
-    cout << "Error: " << e.what() << endl;
-  }
+	// Override texture file name?
+	if(opt.mTexFileName.size() > 0)
+	  mesh.mTexFileName = opt.mTexFileName;
+
+	// Save output file
+	cout << "Saving " << outFile << "... " << flush;
+	timer.Push();
+	ExportMesh(outFile.c_str(), &mesh, opt);
+	dt = timer.PopDelta();
+	cout << 1000.0 * dt << " ms" << endl;
 
   return 0;
 }
diff --git a/3rdparty/openctm/tools/dae.cpp b/3rdparty/openctm/tools/dae.cpp
index d4c4521d..5d18c473 100644
--- a/3rdparty/openctm/tools/dae.cpp
+++ b/3rdparty/openctm/tools/dae.cpp
@@ -26,7 +26,7 @@
 //     distribution.
 //-----------------------------------------------------------------------------
 
-#include <stdexcept>
+#include "common.h"
 #include <fstream>
 #include <sstream>
 #include <vector>
@@ -454,7 +454,7 @@ void Import_DAE(const char * aFileName, Mesh * aMesh)
           aMesh->mTexCoords.resize(texcoordOffset );
           
           for(size_t i = 0; i < indexVector.size(); ++i)
-            aMesh->mIndices[indicesOff + i] = indexVector[i];
+            aMesh->mIndices[indicesOff + i] = (unsigned int)indexVector[i];
           
           for(size_t i = 0; i < vertVector.size(); ++i)
             aMesh->mVertices[vertexOff + i] = vertVector[i];
@@ -469,7 +469,7 @@ void Import_DAE(const char * aFileName, Mesh * aMesh)
     }
   }
   else
-    throw runtime_error("Could not open input file.");
+    throw_runtime_error("Could not open input file.");
 }
 
 /// Dump a float array to an XML text node.
@@ -563,7 +563,7 @@ void Export_DAE(const char * aFileName, Mesh * aMesh, Options &aOptions)
   source_position->LinkEndChild(positions_array);
   positions_array->SetAttribute("id", "Mesh-1-positions-array");
   positions_array->SetAttribute("count", int(aMesh->mVertices.size() * 3));
-  FloatArrayToXML(positions_array, &aMesh->mVertices[0].x, aMesh->mVertices.size() * 3);
+  FloatArrayToXML(positions_array, &aMesh->mVertices[0].x, (unsigned int)aMesh->mVertices.size() * 3);
   TiXmlElement * positions_technique = new TiXmlElement("technique_common");
   source_position->LinkEndChild(positions_technique);
   TiXmlElement * positions_technique_accessor = new TiXmlElement("accessor");
@@ -596,7 +596,7 @@ void Export_DAE(const char * aFileName, Mesh * aMesh, Options &aOptions)
     source_normal->LinkEndChild(normals_array);
     normals_array->SetAttribute("id", "Mesh-1-normals-array");
     normals_array->SetAttribute("count", int(aMesh->mVertices.size() * 3));
-    FloatArrayToXML(normals_array, &aMesh->mNormals[0].x, aMesh->mNormals.size() * 3);
+    FloatArrayToXML(normals_array, &aMesh->mNormals[0].x, (unsigned int)aMesh->mNormals.size() * 3);
     TiXmlElement * normals_technique = new TiXmlElement("technique_common");
     source_normal->LinkEndChild(normals_technique);
     TiXmlElement * normals_technique_accessor = new TiXmlElement("accessor");
@@ -630,7 +630,7 @@ void Export_DAE(const char * aFileName, Mesh * aMesh, Options &aOptions)
     source_map1->LinkEndChild(map1_array);
     map1_array->SetAttribute("id", "Mesh-1-map1-array");
     map1_array->SetAttribute("count", int(aMesh->mVertices.size() * 3));
-    FloatArrayToXML(map1_array, &aMesh->mTexCoords[0].u, aMesh->mTexCoords.size() * 2);
+    FloatArrayToXML(map1_array, &aMesh->mTexCoords[0].u, (unsigned int)aMesh->mTexCoords.size() * 2);
     TiXmlElement * map1_technique = new TiXmlElement("technique_common");
     source_map1->LinkEndChild(map1_technique);
     TiXmlElement * map1_technique_accessor = new TiXmlElement("accessor");
@@ -721,5 +721,5 @@ void Export_DAE(const char * aFileName, Mesh * aMesh, Options &aOptions)
   // Save the XML document to a file
   xmlDoc.SaveFile(aFileName);
   if(xmlDoc.Error())
-    throw runtime_error(string(xmlDoc.ErrorDesc()));
+    throw_runtime_error(string(xmlDoc.ErrorDesc()));
 }
diff --git a/3rdparty/openctm/tools/lwo.cpp b/3rdparty/openctm/tools/lwo.cpp
index b61d06bc..9b1544ee 100644
--- a/3rdparty/openctm/tools/lwo.cpp
+++ b/3rdparty/openctm/tools/lwo.cpp
@@ -25,7 +25,7 @@
 //     distribution.
 //-----------------------------------------------------------------------------
 
-#include <stdexcept>
+#include "common.h"
 #include <fstream>
 #include <cstring>
 #include <string>
@@ -216,14 +216,14 @@ static void WriteVEC12(ostream &aStream, Vector3 aValue)
 /// Write a string to a stream (no zero termination).
 static void WriteString(ostream &aStream, const char * aString)
 {
-  int len = strlen(aString);
+  int len = (int)strlen(aString);
   aStream.write(aString, len);
 }
 
 /// Write a zero terminated string to a stream.
 static void WriteStringZ(ostream &aStream, const char * aString)
 {
-  int len = strlen(aString) + 1;
+  int len = (int)strlen(aString) + 1;
   aStream.write(aString, len);
   if(len & 1)
   {
@@ -262,8 +262,8 @@ static uint32 CalcPOLSSize(Mesh * aMesh)
 /// account, but exclude the name string (at least two bytes)...
 static uint32 CalcVMAPSize(Mesh * aMesh, uint32 aDimension)
 {
-  uint32 size = 6 + aMesh->mVertices.size() * (2 + 4 * aDimension);
-  uint32 maxIdx = aMesh->mVertices.size() - 1;
+  uint32 size = (uint32)(6 + aMesh->mVertices.size() * (2 + 4 * aDimension));
+  uint32 maxIdx = (uint32)(aMesh->mVertices.size() - 1);
   if(maxIdx >= 0x0000ff00)
     size += (maxIdx - 0x0000feff) * 2;
   return size;
@@ -280,14 +280,14 @@ void Import_LWO(const char * aFileName, Mesh * aMesh)
   // Open the input file
   ifstream f(aFileName, ios::in | ios::binary);
   if(f.fail())
-    throw runtime_error("Could not open input file.");
+    throw_runtime_error("Could not open input file.");
 
   // File header
   if(ReadString(f, 4) != string("FORM"))
-    throw runtime_error("Not a valid LWO file (missing FORM chunk).");
+    throw_runtime_error("Not a valid LWO file (missing FORM chunk).");
   uint32 fileSize = ReadU4(f);
   if(ReadString(f, 4) != string("LWO2"))
-    throw runtime_error("Not a valid LWO file (not LWO2 format).");
+    throw_runtime_error("Not a valid LWO file (not LWO2 format).");
 
   // Start with an empty mesh
   aMesh->Clear();
@@ -333,7 +333,7 @@ void Import_LWO(const char * aFileName, Mesh * aMesh)
       // Check point count
       uint32 newPoints = chunkSize / 12;
       if((newPoints * 12) != chunkSize)
-        throw runtime_error("Not a valid LWO file (invalid PNTS chunk).");
+        throw_runtime_error("Not a valid LWO file (invalid PNTS chunk).");
 
       // Read points (relative to current pivot point)
       aMesh->mVertices.resize(pointCount + newPoints);
@@ -347,7 +347,7 @@ void Import_LWO(const char * aFileName, Mesh * aMesh)
     {
       // POLS before PNTS?
       if(!havePoints)
-        throw runtime_error("Not a valid LWO file (POLS chunk before PNTS chunk).");
+        throw_runtime_error("Not a valid LWO file (POLS chunk before PNTS chunk).");
 
       // Check that we have a FACE or PTCH descriptor.
       string type = ReadString(f, 4);
@@ -424,7 +424,7 @@ void Import_LWO(const char * aFileName, Mesh * aMesh)
       if((type == string("RGB ")) || (type == string("RGBA")))
       {
         // Resize the mesh colors array
-        uint32 oldSize = aMesh->mColors.size();
+        uint32 oldSize = (uint32)aMesh->mColors.size();
         aMesh->mColors.resize(pointCount);
         for(uint32 i = oldSize; i < pointCount; ++ i)
           aMesh->mColors[i] = Vector4(1.0f, 1.0f, 1.0f, 1.0f);
@@ -456,7 +456,7 @@ void Import_LWO(const char * aFileName, Mesh * aMesh)
       else if((type == string("TXUV")))
       {
         // Resize the mesh UV array
-        uint32 oldSize = aMesh->mTexCoords.size();
+        uint32 oldSize = (uint32)aMesh->mTexCoords.size();
         aMesh->mTexCoords.resize(pointCount);
         for(uint32 i = oldSize; i < pointCount; ++ i)
           aMesh->mTexCoords[i] = Vector2(0.0f, 0.0f);
@@ -491,7 +491,7 @@ void Import_LWO(const char * aFileName, Mesh * aMesh)
   // Post-adjustment: color array (if any)
   if((aMesh->mColors.size() > 0) && (aMesh->mColors.size() < pointCount))
   {
-    uint32 oldSize = aMesh->mColors.size();
+    uint32 oldSize = (uint32)aMesh->mColors.size();
     aMesh->mColors.resize(pointCount);
     for(uint32 i = oldSize; i < pointCount; ++ i)
       aMesh->mColors[i] = Vector4(1.0f, 1.0f, 1.0f, 1.0f);
@@ -500,7 +500,7 @@ void Import_LWO(const char * aFileName, Mesh * aMesh)
   // Post-adjustment: texture coordinate array (if any)
   if((aMesh->mTexCoords.size() > 0) && (aMesh->mTexCoords.size() < pointCount))
   {
-    uint32 oldSize = aMesh->mTexCoords.size();
+    uint32 oldSize = (uint32)aMesh->mTexCoords.size();
     aMesh->mTexCoords.resize(pointCount);
     for(uint32 i = oldSize; i < pointCount; ++ i)
       aMesh->mTexCoords[i] = Vector2(0.0f, 0.0f);
@@ -515,7 +515,7 @@ void Export_LWO(const char * aFileName, Mesh * aMesh, Options &aOptions)
 {
   // Check if we can support this mesh (too many vertices?)
   if(aMesh->mVertices.size() > 0x00ffffff)
-    throw runtime_error("Too large mesh (not supported by the LWO file format).");
+    throw_runtime_error("Too large mesh (not supported by the LWO file format).");
 
   // What should we export?
   bool exportComment = (aMesh->mComment.size() > 0);
@@ -523,7 +523,7 @@ void Export_LWO(const char * aFileName, Mesh * aMesh, Options &aOptions)
   bool exportColors = aMesh->HasColors() && !aOptions.mNoColors;
 
   // Calculate the sizes of the individual chunks
-  uint32 textSize = aMesh->mComment.size() + 1;
+  uint32 textSize = (uint32)aMesh->mComment.size() + 1;
   if(textSize & 1) ++ textSize;
   uint32 tagsSize = 8;
   uint32 layrSize = 24;
@@ -548,7 +548,7 @@ void Export_LWO(const char * aFileName, Mesh * aMesh, Options &aOptions)
   // Open the output file
   ofstream f(aFileName, ios::out | ios::binary);
   if(f.fail())
-    throw runtime_error("Could not open output file.");
+    throw_runtime_error("Could not open output file.");
 
   // File header
   WriteString(f, "FORM");
diff --git a/3rdparty/openctm/tools/mesh.cpp b/3rdparty/openctm/tools/mesh.cpp
index 623b9912..c6a8947f 100644
--- a/3rdparty/openctm/tools/mesh.cpp
+++ b/3rdparty/openctm/tools/mesh.cpp
@@ -25,7 +25,7 @@
 //     distribution.
 //-----------------------------------------------------------------------------
 
-#include <stdexcept>
+#include "common.h"
 #include <openctm.h>
 #include <cmath>
 #include "mesh.h"
@@ -73,8 +73,8 @@ void Mesh::Clear()
 /// Automatic detection of the optimal normal calculation method
 Mesh::NormalCalcAlgo Mesh::DetectNormalCalculationMethod()
 {
-  unsigned int triCount = mIndices.size() / 3;
-  unsigned int vertexCount = mVertices.size();
+  unsigned int triCount = (unsigned int)(mIndices.size() / 3);
+  unsigned int vertexCount = (unsigned int)(mVertices.size() );
 
   // Calculate the mean edge length
   double meanEdgeLen = 0;
@@ -169,7 +169,7 @@ void Mesh::CalculateNormals(NormalCalcAlgo aAlgo)
     mNormals[i] = Vector3(0.0f, 0.0f, 0.0f);
 
   // Calculate sum of the flat normals of the neighbouring triangles
-  unsigned int triCount = mIndices.size() / 3;
+  unsigned int triCount = (unsigned int)(mIndices.size() / 3);
   for(unsigned int i = 0; i < triCount; ++ i)
   {
     // Calculate the weighted flat normal for this triangle
diff --git a/3rdparty/openctm/tools/meshio.cpp b/3rdparty/openctm/tools/meshio.cpp
index 52e84412..270641be 100644
--- a/3rdparty/openctm/tools/meshio.cpp
+++ b/3rdparty/openctm/tools/meshio.cpp
@@ -25,7 +25,7 @@
 //     distribution.
 //-----------------------------------------------------------------------------
 
-#include <stdexcept>
+#include "common.h"
 #include <string>
 #include <list>
 #include "mesh.h"
@@ -68,7 +68,7 @@ void ImportMesh(const char * aFileName, Mesh * aMesh)
   else if(fileExt == string(".WRL"))
     Import_WRL(aFileName, aMesh);
   else
-    throw runtime_error("Unknown input file extension.");
+    throw_runtime_error("Unknown input file extension.");
 }
 
 /// Export a mesh to a file.
@@ -94,7 +94,7 @@ void ExportMesh(const char * aFileName, Mesh * aMesh, Options &aOptions)
   else if(fileExt == string(".WRL"))
     Export_WRL(aFileName, aMesh, aOptions);
   else
-    throw runtime_error("Unknown output file extension.");
+    throw_runtime_error("Unknown output file extension.");
 }
 
 /// Return a list of supported formats.
diff --git a/3rdparty/openctm/tools/obj.cpp b/3rdparty/openctm/tools/obj.cpp
index 5ed49aa5..75e7012e 100644
--- a/3rdparty/openctm/tools/obj.cpp
+++ b/3rdparty/openctm/tools/obj.cpp
@@ -25,7 +25,7 @@
 //     distribution.
 //-----------------------------------------------------------------------------
 
-#include <stdexcept>
+#include "common.h"
 #include <fstream>
 #include <iomanip>
 #include <string>
@@ -108,9 +108,9 @@ class OBJFace {
             if(value > 0)
               value --;
             else if(value < 0)
-              throw runtime_error("Negative vertex references in OBJ files are not supported.");
+              throw_runtime_error("Negative vertex references in OBJ files are not supported.");
             else
-              throw runtime_error("Invalid index (zero) in OBJ file.");
+              throw_runtime_error("Invalid index (zero) in OBJ file.");
           }
           n.Set(j, value);
         }
@@ -150,7 +150,7 @@ void Import_OBJ(const char * aFileName, Mesh * aMesh)
   // Open the input file
   ifstream inFile(aFileName, ios::in);
   if(inFile.fail())
-    throw runtime_error("Could not open input file.");
+    throw_runtime_error("Could not open input file.");
 
   // Mesh description - parsed from the OBJ file
   list<Vector3> vertices;
@@ -201,7 +201,7 @@ void Import_OBJ(const char * aFileName, Mesh * aMesh)
   int triCount = 0;
   for(list<OBJFace>::iterator i = faces.begin(); i != faces.end(); ++ i)
   {
-    int nodeCount = (*i).mNodes.size();
+    int nodeCount = (int)((*i).mNodes.size());
     if(nodeCount >= 3)
       triCount += (nodeCount - 2);
   }
@@ -269,7 +269,7 @@ void Export_OBJ(const char * aFileName, Mesh * aMesh, Options &aOptions)
   // Open the output file
   ofstream f(aFileName, ios::out);
   if(f.fail())
-    throw runtime_error("Could not open output file.");
+    throw_runtime_error("Could not open output file.");
 
   // What should we export?
   bool exportTexCoords = aMesh->HasTexCoords() && !aOptions.mNoTexCoords;
@@ -312,7 +312,7 @@ void Export_OBJ(const char * aFileName, Mesh * aMesh, Options &aOptions)
   }
 
   // Write faces
-  unsigned int triCount = aMesh->mIndices.size() / 3;
+  unsigned int triCount = (unsigned int)(aMesh->mIndices.size() / 3);
   f << "s 1" << endl; // Put all faces in the same smoothing group
   for(unsigned int i = 0; i < triCount; ++ i)
   {
diff --git a/3rdparty/openctm/tools/off.cpp b/3rdparty/openctm/tools/off.cpp
index 6a40934d..ac427a72 100644
--- a/3rdparty/openctm/tools/off.cpp
+++ b/3rdparty/openctm/tools/off.cpp
@@ -32,7 +32,7 @@
 // http://people.sc.fsu.edu/~burkardt/data/off/off.html
 //-----------------------------------------------------------------------------
 
-#include <stdexcept>
+#include "common.h"
 #include <fstream>
 #include <iomanip>
 #include <string>
@@ -99,7 +99,7 @@ void Import_OFF(const char * aFileName, Mesh * aMesh)
   // Open the input file
   ifstream f(aFileName, ios::in);
   if(f.fail())
-    throw runtime_error("Could not open input file.");
+    throw_runtime_error("Could not open input file.");
 
   // Some state variables that we need...
   unsigned int numVertices;
@@ -110,16 +110,16 @@ void Import_OFF(const char * aFileName, Mesh * aMesh)
   // Read header
   ReadNextLine(f, line, comment);
   if(line != string("OFF"))
-    throw runtime_error("Not a valid OFF format file (missing OFF signature).");
+    throw_runtime_error("Not a valid OFF format file (missing OFF signature).");
   ReadNextLine(f, line, comment);
   sstr.clear();
   sstr.str(line);
   sstr >> numVertices;
   sstr >> numFaces;
   if(numVertices < 1)
-    throw runtime_error("Not a valid OFF format file (bad vertex count).");
+    throw_runtime_error("Not a valid OFF format file (bad vertex count).");
   if(numFaces < 1)
-    throw runtime_error("Not a valid OFF format file (bad face count).");
+    throw_runtime_error("Not a valid OFF format file (bad face count).");
 
   // Read vertices
   aMesh->mVertices.resize(numVertices);
@@ -199,7 +199,7 @@ void Export_OFF(const char * aFileName, Mesh * aMesh, Options &aOptions)
   // Open the output file
   ofstream f(aFileName, ios::out);
   if(f.fail())
-    throw runtime_error("Could not open output file.");
+    throw_runtime_error("Could not open output file.");
 
   // Mesh information
   unsigned int numVertices = (unsigned int) aMesh->mVertices.size();
diff --git a/3rdparty/openctm/tools/ply.cpp b/3rdparty/openctm/tools/ply.cpp
index 2bacaae4..fcbe18d2 100644
--- a/3rdparty/openctm/tools/ply.cpp
+++ b/3rdparty/openctm/tools/ply.cpp
@@ -26,7 +26,7 @@
 //-----------------------------------------------------------------------------
 
 #include <iostream>
-#include <stdexcept>
+#include "common.h"
 #include <string>
 #include <fstream>
 #include <iomanip>
@@ -169,9 +169,9 @@ void Import_PLY(const char * aFileName, Mesh * aMesh)
   // Open the PLY file
   p_ply ply = ply_open(aFileName, NULL);
   if(!ply)
-    throw runtime_error("Unable to open PLY file.");
+    throw_runtime_error("Unable to open PLY file.");
   if(!ply_read_header(ply))
-    throw runtime_error("Invalid PLY file.");
+    throw_runtime_error("Invalid PLY file.");
 
   // Get the file comment (if any)
   bool firstComment = true;
@@ -212,7 +212,7 @@ void Import_PLY(const char * aFileName, Mesh * aMesh)
 
   // Sanity check
   if((faceCount < 1) || (vertexCount < 1))
-    throw runtime_error("Empty PLY mesh - invalid file format?");
+    throw_runtime_error("Empty PLY mesh - invalid file format?");
 
   // Prepare the mesh
   aMesh->mIndices.resize(faceCount * 3);
@@ -223,7 +223,7 @@ void Import_PLY(const char * aFileName, Mesh * aMesh)
 
   // Read the PLY file
   if(!ply_read(ply))
-    throw runtime_error("Unable to load PLY file.");
+    throw_runtime_error("Unable to load PLY file.");
 
   // Close the PLY file
   ply_close(ply);
@@ -243,7 +243,7 @@ void Export_PLY(const char * aFileName, Mesh * aMesh, Options &aOptions)
   // Open the output file
   ofstream f(aFileName, ios::out | ios::binary);
   if(f.fail())
-    throw runtime_error("Could not open output file.");
+    throw_runtime_error("Could not open output file.");
 
   // Set floating point precision
   f << setprecision(8);
diff --git a/3rdparty/openctm/tools/stl.cpp b/3rdparty/openctm/tools/stl.cpp
index 70a6a720..cf07a607 100644
--- a/3rdparty/openctm/tools/stl.cpp
+++ b/3rdparty/openctm/tools/stl.cpp
@@ -25,7 +25,7 @@
 //     distribution.
 //-----------------------------------------------------------------------------
 
-#include <stdexcept>
+#include "common.h"
 #include <fstream>
 #include <string>
 #include <vector>
@@ -115,14 +115,14 @@ void Import_STL(const char * aFileName, Mesh * aMesh)
   // Open the input file
   ifstream f(aFileName, ios::in | ios::binary);
   if(f.fail())
-    throw runtime_error("Could not open input file.");
+    throw_runtime_error("Could not open input file.");
 
   // Get the file size
   f.seekg(0, ios::end);
   uint32 fileSize = (uint32) f.tellg();
   f.seekg(0, ios::beg);
   if(fileSize < 84)
-    throw runtime_error("Invalid format - not a valid STL file.");
+    throw_runtime_error("Invalid format - not a valid STL file.");
 
   // Read header (80 character comment + triangle count)
   char comment[81];
@@ -131,7 +131,7 @@ void Import_STL(const char * aFileName, Mesh * aMesh)
   aMesh->mComment = string(comment);
   uint32 triangleCount = ReadInt32(f);
   if(fileSize != (84 + triangleCount * 50))
-    throw runtime_error("Invalid format - not a valid STL file.");
+    throw_runtime_error("Invalid format - not a valid STL file.");
 
   if(triangleCount > 0)
   {
@@ -192,7 +192,7 @@ void Export_STL(const char * aFileName, Mesh * aMesh, Options &aOptions)
   // Open the output file
   ofstream f(aFileName, ios::out | ios::binary);
   if(f.fail())
-    throw runtime_error("Could not open output file.");
+    throw_runtime_error("Could not open output file.");
 
   // Write header (80-character comment + triangle count)
   char comment[80];
@@ -204,7 +204,7 @@ void Export_STL(const char * aFileName, Mesh * aMesh, Options &aOptions)
       comment[i] = 0;
   }
   f.write(comment, 80);
-  uint32 triangleCount = aMesh->mIndices.size() / 3;
+  uint32 triangleCount = (CTMuint)(aMesh->mIndices.size() / 3);
   WriteInt32(f, triangleCount);
 
   // Write the triangle data
diff --git a/3rdparty/openctm/tools/wrl.cpp b/3rdparty/openctm/tools/wrl.cpp
index e39286f3..00bdcb54 100644
--- a/3rdparty/openctm/tools/wrl.cpp
+++ b/3rdparty/openctm/tools/wrl.cpp
@@ -25,7 +25,7 @@
 //     distribution.
 //-----------------------------------------------------------------------------
 
-#include <stdexcept>
+#include "common.h"
 #include <fstream>
 #include <iomanip>
 #include <string>
@@ -55,14 +55,14 @@ class VRMLReader {
     char GetNextChar()
     {
       if(!mStream)
-        throw runtime_error("VRML input stream undefined.");
+        throw_runtime_error("VRML input stream undefined.");
       if(mBufPos >= mBufActual)
       {
         mBufPos = 0;
         if(!mStream->eof())
         {
           mStream->read(mBuffer, mBufSize);
-          mBufActual = mStream->gcount();
+          mBufActual = (int)(mStream->gcount());
         }
         else
           mBufActual = 0;
@@ -172,7 +172,7 @@ class VRMLReader {
       // Read the header
       string header = GetNextLine();
       if(header.substr(0, 10) != string("#VRML V2.0"))
-        throw runtime_error("Not a valid VRML 2.0 file.");
+        throw_runtime_error("Not a valid VRML 2.0 file.");
 
       // Read the rest of the file
       while(!mEndOfFile)
@@ -201,7 +201,7 @@ class VRMLReader {
 void Import_WRL(const char * aFileName, Mesh * aMesh)
 {
   // FIXME: The import functionality has not yet been fully implemented
-  throw runtime_error("VRML import is not yet supported.");
+  throw_runtime_error("VRML import is not yet supported.");
 
   // Clear the mesh
   aMesh->Clear();
@@ -209,7 +209,7 @@ void Import_WRL(const char * aFileName, Mesh * aMesh)
   // Open the input file
   ifstream f(aFileName, ios::in);
   if(f.fail())
-    throw runtime_error("Could not open input file.");
+    throw_runtime_error("Could not open input file.");
 
   // Initialize the reader object
   VRMLReader reader;
@@ -228,7 +228,7 @@ void Export_WRL(const char * aFileName, Mesh * aMesh, Options &aOptions)
   // Open the output file
   ofstream f(aFileName, ios::out);
   if(f.fail())
-    throw runtime_error("Could not open output file.");
+    throw_runtime_error("Could not open output file.");
 
   // Set floating point precision
   f << setprecision(8);
@@ -284,7 +284,7 @@ void Export_WRL(const char * aFileName, Mesh * aMesh, Options &aOptions)
 
   // Write faces
   f << "\t\t\t\tcoordIndex [" << endl;
-  unsigned int triCount = aMesh->mIndices.size() / 3;
+  unsigned int triCount = (unsigned int)(aMesh->mIndices.size() / 3);
   for(unsigned int i = 0; i < triCount; ++ i)
   {
     f << "\t\t\t\t\t" <<
diff --git a/README.md b/README.md
index 7197d81a..7047658b 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,9 @@
 bgfx
 ====
 
+What is it?
+-----------
+
 Cross-platform rendering library.
 
 Supported rendering backends:
@@ -65,7 +68,7 @@ directory link to directory without spaces in the path.
 
 ### Building for Native Client (Pepper 22) on Windows
 
-Download Native Client SDK from
+Download Native Client SDK from:  
 [https://developers.google.com/native-client/sdk/download](https://developers.google.com/native-client/sdk/download)
 
 	setx NACL <path to Native Client SDK directory>\toolchain\win_x86_newlib
@@ -84,7 +87,7 @@ Other platforms:
 
 	make -R <configuration>
 
-Configuration is <platform>-<debug/release><32/64>. For example:
+Configuration is `<platform>-<debug/release><32/64>`. For example:
 
 	linux-release32, nacl-debug64, android-release32, etc.
 
@@ -112,6 +115,69 @@ Geometry instancing.
 ### 06-bump
 Loading textures.
 
+Internals
+---------
+
+bgfx is using sort-based draw call bucketing. This means that submition order
+doesn't necessarily matches the rendering order. On the high level this allows
+submitting draw calls for all passes at one place, but on the low-level they
+will be sorted and ordered correctly. This sometimes creates undesired results
+usually for GUI rendering, where draw order should usually match submit order.
+bgfx provides way to enable sequential rendering for these cases (see 
+`bgfx::setViewSeq`).
+
+Internally All low-level rendering draw calls are issued inside single function
+`Context::rendererSubmit`. This function exist inside each renderer backend
+implementation.
+
+More detailed description of sort-based draw call bucketing can be found at:  
+[Order your graphics draw calls around!](http://realtimecollisiondetection.net/blog/?p=86)
+
+Customization
+-------------
+
+By default each platform has sane default values. For example on Windows default
+renderer is DirectX9, and on Linux it is OpenGL 2.1. On Windows platform all
+rendering backends are available. For OpenGL ES on desktop you can find more 
+information at:  
+[OpenGL ES 2.0 and EGL on desktop](http://www.g-truc.net/post-0457.html)
+
+All configuration settings are located inside [src/config.h](src/config.h).
+
+Every `BGFX_CONFIG_*` setting can be changed by passing defines thru compiler
+switches. For example setting preprocessor define `BGFX_CONFIG_RENDERER_OPENGL=1`
+on Windows will change backend renderer to OpenGL 2.1. on Windows. Since
+rendering APIs are platform specific, this obviously won't work nor make sense
+in all cases. Certain platforms have only single choice, for example the Native
+Client works only with OpenGL ES 2.0 renderer, using anything other than that
+will result in build errors.
+
+Tools
+-----
+
+### Shader Compiler (shaderc)
+
+bgfx cross-platform shader language is based on GLSL syntax. It's uses ANSI C
+preprocessor to transform GLSL like language syntax into HLSL. This technique
+has certain drawbacks, but overall it's simple and allows quick authoring of
+cross-platform shaders.
+
+### Texture Compiler (texturec)
+
+### Geometry Compiler (geometryc)
+
+Todo
+----
+
+ - Multiple render targets.
+ - BlendFuncSeparate and BlendEquationSeparate.
+ - Copy from texture to texture.
+ - Occlusion queries.
+ - OSX and iOS platforms.
+ - DX11: MSAA.
+ - GL: MSAA.
+ - GL: ARB_vertex_array_object + OES_vertex_array_object.
+
 Notice
 ------
 
@@ -127,8 +193,45 @@ http://www.stuckingeometry.com
 Project page  
 https://github.com/bkaradzic/bgfx
 
-License
--------
+3rd Party Libraries
+-------------------
+
+All required 3rd party libraries are included in bgfx repository in [3rdparty/](3rdparty/)
+directory.
+
+### edtaa3 (MIT)
+
+Contour Rendering by Distance Fields
+
+https://github.com/OpenGLInsights/OpenGLInsightsCode/tree/master/Chapter%2012%202D%20Shape%20Rendering%20by%20Distance%20Fields
+
+### fcpp (BSD)
+
+Frexx C preprocessor
+
+https://github.com/bagder/fcpp
+
+### glsl-optimizer (MIT)
+
+GLSL optimizer based on Mesa's GLSL compiler. Used in Unity for mobile shader
+optimization.
+
+https://github.com/aras-p/glsl-optimizer
+
+### OpenCTM (Zlib)
+
+OpenCTM � the Open Compressed Triangle Mesh file format � is a
+file format, a software library and a tool set for compression of 3D triangle
+meshes.
+
+http://openctm.sourceforge.net/
+
+### stb_image (Public Domain)
+
+http://nothings.org/stb_image.c
+
+License (BSD 2-clause)
+----------------------
 
 Copyright 2010-2012 Branimir Karadzic. All rights reserved.
 
diff --git a/examples/01-cubes/makefile b/examples/01-cubes/makefile
index 3d8f5374..3bb2f87f 100644
--- a/examples/01-cubes/makefile
+++ b/examples/01-cubes/makefile
@@ -5,6 +5,7 @@
 
 BGFX_DIR=../..
 RUNTIME_DIR=$(BGFX_DIR)/examples/runtime
+BUILD_DIR=../../.build
 
 include $(BGFX_DIR)/premake/shader.mk
 
diff --git a/examples/02-metaballs/makefile b/examples/02-metaballs/makefile
index 3d8f5374..3bb2f87f 100644
--- a/examples/02-metaballs/makefile
+++ b/examples/02-metaballs/makefile
@@ -5,6 +5,7 @@
 
 BGFX_DIR=../..
 RUNTIME_DIR=$(BGFX_DIR)/examples/runtime
+BUILD_DIR=../../.build
 
 include $(BGFX_DIR)/premake/shader.mk
 
diff --git a/examples/03-raymarch/makefile b/examples/03-raymarch/makefile
index 3d8f5374..3bb2f87f 100644
--- a/examples/03-raymarch/makefile
+++ b/examples/03-raymarch/makefile
@@ -5,6 +5,7 @@
 
 BGFX_DIR=../..
 RUNTIME_DIR=$(BGFX_DIR)/examples/runtime
+BUILD_DIR=../../.build
 
 include $(BGFX_DIR)/premake/shader.mk
 
diff --git a/examples/04-mesh/makefile b/examples/04-mesh/makefile
index 3d8f5374..3bb2f87f 100644
--- a/examples/04-mesh/makefile
+++ b/examples/04-mesh/makefile
@@ -5,6 +5,7 @@
 
 BGFX_DIR=../..
 RUNTIME_DIR=$(BGFX_DIR)/examples/runtime
+BUILD_DIR=../../.build
 
 include $(BGFX_DIR)/premake/shader.mk
 
diff --git a/examples/05-instancing/makefile b/examples/05-instancing/makefile
index 3d8f5374..3bb2f87f 100644
--- a/examples/05-instancing/makefile
+++ b/examples/05-instancing/makefile
@@ -5,6 +5,7 @@
 
 BGFX_DIR=../..
 RUNTIME_DIR=$(BGFX_DIR)/examples/runtime
+BUILD_DIR=../../.build
 
 include $(BGFX_DIR)/premake/shader.mk
 
diff --git a/examples/06-bump/bump.cpp b/examples/06-bump/bump.cpp
index c7ee52e2..4464f1e2 100644
--- a/examples/06-bump/bump.cpp
+++ b/examples/06-bump/bump.cpp
@@ -429,7 +429,7 @@ int _main_(int _argc, char** _argv)
 				}
 			}
 
-			uint16_t numInstances = (data - idb->data)/instanceStride;
+			uint16_t numInstances = (uint16_t)( (data - idb->data)/instanceStride);
 
 			// Set vertex and fragment shaders.
 			bgfx::setProgram(program);
diff --git a/examples/06-bump/makefile b/examples/06-bump/makefile
index 3d8f5374..3bb2f87f 100644
--- a/examples/06-bump/makefile
+++ b/examples/06-bump/makefile
@@ -5,6 +5,7 @@
 
 BGFX_DIR=../..
 RUNTIME_DIR=$(BGFX_DIR)/examples/runtime
+BUILD_DIR=../../.build
 
 include $(BGFX_DIR)/premake/shader.mk
 
diff --git a/examples/common/dbg.cpp b/examples/common/dbg.cpp
index dbd7eba4..3d8be1ee 100644
--- a/examples/common/dbg.cpp
+++ b/examples/common/dbg.cpp
@@ -11,6 +11,7 @@
 #include <ctype.h> // isprint
 
 #include "dbg.h"
+#include <bx/string.h>
 
 #if BX_COMPILER_MSVC
 #	define snprintf _snprintf
@@ -36,9 +37,15 @@ void dbgOutput(const char* _out)
 void dbgPrintfVargs(const char* _format, va_list _argList)
 {
 	char temp[8192];
-	vsnprintf(temp, sizeof(temp), _format, _argList);
-	temp[sizeof(temp)-1] = '\0';
-	dbgOutput(temp);
+	char* out = temp;
+	int32_t len = bx::vsnprintf(out, sizeof(temp), _format, _argList);
+	if (sizeof(temp) < len)
+	{
+		out = (char*)alloca(len+1);
+		len = bx::vsnprintf(out, len, _format, _argList);
+	}
+	out[len] = '\0';
+	dbgOutput(out);
 }
 
 void dbgPrintf(const char* _format, ...)
diff --git a/examples/runtime/shaders/dx11/fs_bump.bin b/examples/runtime/shaders/dx11/fs_bump.bin
index 7ffd8b16..453e9aed 100644
Binary files a/examples/runtime/shaders/dx11/fs_bump.bin and b/examples/runtime/shaders/dx11/fs_bump.bin differ
diff --git a/examples/runtime/shaders/dx11/fs_cubes.bin b/examples/runtime/shaders/dx11/fs_cubes.bin
index 96fcba26..edb799f9 100644
Binary files a/examples/runtime/shaders/dx11/fs_cubes.bin and b/examples/runtime/shaders/dx11/fs_cubes.bin differ
diff --git a/examples/runtime/shaders/dx11/fs_instancing.bin b/examples/runtime/shaders/dx11/fs_instancing.bin
index 96fcba26..edb799f9 100644
Binary files a/examples/runtime/shaders/dx11/fs_instancing.bin and b/examples/runtime/shaders/dx11/fs_instancing.bin differ
diff --git a/examples/runtime/shaders/dx11/fs_mesh.bin b/examples/runtime/shaders/dx11/fs_mesh.bin
index 36d0e7e5..f4a8c625 100644
Binary files a/examples/runtime/shaders/dx11/fs_mesh.bin and b/examples/runtime/shaders/dx11/fs_mesh.bin differ
diff --git a/examples/runtime/shaders/dx11/fs_metaballs.bin b/examples/runtime/shaders/dx11/fs_metaballs.bin
index 3b820921..cbd93d7a 100644
Binary files a/examples/runtime/shaders/dx11/fs_metaballs.bin and b/examples/runtime/shaders/dx11/fs_metaballs.bin differ
diff --git a/examples/runtime/shaders/dx11/fs_raymarching.bin b/examples/runtime/shaders/dx11/fs_raymarching.bin
index 1f56054b..ee9f53de 100644
Binary files a/examples/runtime/shaders/dx11/fs_raymarching.bin and b/examples/runtime/shaders/dx11/fs_raymarching.bin differ
diff --git a/examples/runtime/shaders/dx11/vs_bump.bin b/examples/runtime/shaders/dx11/vs_bump.bin
index 0e8bc9a0..942b7163 100644
Binary files a/examples/runtime/shaders/dx11/vs_bump.bin and b/examples/runtime/shaders/dx11/vs_bump.bin differ
diff --git a/examples/runtime/shaders/dx11/vs_cubes.bin b/examples/runtime/shaders/dx11/vs_cubes.bin
index 2fd2d2db..985db473 100644
Binary files a/examples/runtime/shaders/dx11/vs_cubes.bin and b/examples/runtime/shaders/dx11/vs_cubes.bin differ
diff --git a/examples/runtime/shaders/dx11/vs_instancing.bin b/examples/runtime/shaders/dx11/vs_instancing.bin
index a4b7c425..e61505d8 100644
Binary files a/examples/runtime/shaders/dx11/vs_instancing.bin and b/examples/runtime/shaders/dx11/vs_instancing.bin differ
diff --git a/examples/runtime/shaders/dx11/vs_mesh.bin b/examples/runtime/shaders/dx11/vs_mesh.bin
index a23d5340..0dbc2af8 100644
Binary files a/examples/runtime/shaders/dx11/vs_mesh.bin and b/examples/runtime/shaders/dx11/vs_mesh.bin differ
diff --git a/examples/runtime/shaders/dx11/vs_metaballs.bin b/examples/runtime/shaders/dx11/vs_metaballs.bin
index 31f7a317..aa218c8f 100644
Binary files a/examples/runtime/shaders/dx11/vs_metaballs.bin and b/examples/runtime/shaders/dx11/vs_metaballs.bin differ
diff --git a/examples/runtime/shaders/dx11/vs_raymarching.bin b/examples/runtime/shaders/dx11/vs_raymarching.bin
index 7b7d5ab4..0e3c8e2a 100644
Binary files a/examples/runtime/shaders/dx11/vs_raymarching.bin and b/examples/runtime/shaders/dx11/vs_raymarching.bin differ
diff --git a/examples/runtime/shaders/dx9/fs_bump.bin b/examples/runtime/shaders/dx9/fs_bump.bin
index 6cfb60d0..ed302f55 100644
Binary files a/examples/runtime/shaders/dx9/fs_bump.bin and b/examples/runtime/shaders/dx9/fs_bump.bin differ
diff --git a/examples/runtime/shaders/dx9/fs_cubes.bin b/examples/runtime/shaders/dx9/fs_cubes.bin
index fb14d875..d4f47682 100644
Binary files a/examples/runtime/shaders/dx9/fs_cubes.bin and b/examples/runtime/shaders/dx9/fs_cubes.bin differ
diff --git a/examples/runtime/shaders/dx9/fs_instancing.bin b/examples/runtime/shaders/dx9/fs_instancing.bin
index fb14d875..d4f47682 100644
Binary files a/examples/runtime/shaders/dx9/fs_instancing.bin and b/examples/runtime/shaders/dx9/fs_instancing.bin differ
diff --git a/examples/runtime/shaders/dx9/fs_mesh.bin b/examples/runtime/shaders/dx9/fs_mesh.bin
index 2600a8d0..f15a9d3a 100644
Binary files a/examples/runtime/shaders/dx9/fs_mesh.bin and b/examples/runtime/shaders/dx9/fs_mesh.bin differ
diff --git a/examples/runtime/shaders/dx9/fs_metaballs.bin b/examples/runtime/shaders/dx9/fs_metaballs.bin
index 88048478..f33293a3 100644
Binary files a/examples/runtime/shaders/dx9/fs_metaballs.bin and b/examples/runtime/shaders/dx9/fs_metaballs.bin differ
diff --git a/examples/runtime/shaders/dx9/fs_raymarching.bin b/examples/runtime/shaders/dx9/fs_raymarching.bin
index 94f0f6f4..277fbcf1 100644
Binary files a/examples/runtime/shaders/dx9/fs_raymarching.bin and b/examples/runtime/shaders/dx9/fs_raymarching.bin differ
diff --git a/examples/runtime/shaders/dx9/vs_bump.bin b/examples/runtime/shaders/dx9/vs_bump.bin
index 88382b8a..bef53239 100644
Binary files a/examples/runtime/shaders/dx9/vs_bump.bin and b/examples/runtime/shaders/dx9/vs_bump.bin differ
diff --git a/examples/runtime/shaders/dx9/vs_cubes.bin b/examples/runtime/shaders/dx9/vs_cubes.bin
index 01d66e86..8678ce34 100644
Binary files a/examples/runtime/shaders/dx9/vs_cubes.bin and b/examples/runtime/shaders/dx9/vs_cubes.bin differ
diff --git a/examples/runtime/shaders/dx9/vs_instancing.bin b/examples/runtime/shaders/dx9/vs_instancing.bin
index 84bd5828..6e3d001d 100644
Binary files a/examples/runtime/shaders/dx9/vs_instancing.bin and b/examples/runtime/shaders/dx9/vs_instancing.bin differ
diff --git a/examples/runtime/shaders/dx9/vs_mesh.bin b/examples/runtime/shaders/dx9/vs_mesh.bin
index 22ae1514..aa9460b9 100644
Binary files a/examples/runtime/shaders/dx9/vs_mesh.bin and b/examples/runtime/shaders/dx9/vs_mesh.bin differ
diff --git a/examples/runtime/shaders/dx9/vs_metaballs.bin b/examples/runtime/shaders/dx9/vs_metaballs.bin
index 8c80df24..0f9e0f12 100644
Binary files a/examples/runtime/shaders/dx9/vs_metaballs.bin and b/examples/runtime/shaders/dx9/vs_metaballs.bin differ
diff --git a/examples/runtime/shaders/dx9/vs_raymarching.bin b/examples/runtime/shaders/dx9/vs_raymarching.bin
index ade8b148..8b91c357 100644
Binary files a/examples/runtime/shaders/dx9/vs_raymarching.bin and b/examples/runtime/shaders/dx9/vs_raymarching.bin differ
diff --git a/examples/runtime/shaders/gles/fs_bump.bin b/examples/runtime/shaders/gles/fs_bump.bin
index 16a53b6a..ebd2f063 100644
Binary files a/examples/runtime/shaders/gles/fs_bump.bin and b/examples/runtime/shaders/gles/fs_bump.bin differ
diff --git a/examples/runtime/shaders/gles/fs_cubes.bin b/examples/runtime/shaders/gles/fs_cubes.bin
index d3812325..55250fc5 100644
Binary files a/examples/runtime/shaders/gles/fs_cubes.bin and b/examples/runtime/shaders/gles/fs_cubes.bin differ
diff --git a/examples/runtime/shaders/gles/fs_instancing.bin b/examples/runtime/shaders/gles/fs_instancing.bin
index d3812325..55250fc5 100644
Binary files a/examples/runtime/shaders/gles/fs_instancing.bin and b/examples/runtime/shaders/gles/fs_instancing.bin differ
diff --git a/examples/runtime/shaders/gles/fs_mesh.bin b/examples/runtime/shaders/gles/fs_mesh.bin
index 601f8ef5..9b50e885 100644
Binary files a/examples/runtime/shaders/gles/fs_mesh.bin and b/examples/runtime/shaders/gles/fs_mesh.bin differ
diff --git a/examples/runtime/shaders/gles/fs_metaballs.bin b/examples/runtime/shaders/gles/fs_metaballs.bin
index 8814e5be..03a036ae 100644
Binary files a/examples/runtime/shaders/gles/fs_metaballs.bin and b/examples/runtime/shaders/gles/fs_metaballs.bin differ
diff --git a/examples/runtime/shaders/gles/fs_raymarching.bin b/examples/runtime/shaders/gles/fs_raymarching.bin
index d7c70816..6add4db1 100644
Binary files a/examples/runtime/shaders/gles/fs_raymarching.bin and b/examples/runtime/shaders/gles/fs_raymarching.bin differ
diff --git a/examples/runtime/shaders/gles/vs_bump.bin b/examples/runtime/shaders/gles/vs_bump.bin
index d80c1728..7c05a132 100644
Binary files a/examples/runtime/shaders/gles/vs_bump.bin and b/examples/runtime/shaders/gles/vs_bump.bin differ
diff --git a/examples/runtime/shaders/gles/vs_cubes.bin b/examples/runtime/shaders/gles/vs_cubes.bin
index 8852fe25..c5309d25 100644
Binary files a/examples/runtime/shaders/gles/vs_cubes.bin and b/examples/runtime/shaders/gles/vs_cubes.bin differ
diff --git a/examples/runtime/shaders/gles/vs_instancing.bin b/examples/runtime/shaders/gles/vs_instancing.bin
index 694886a1..cfd14213 100644
Binary files a/examples/runtime/shaders/gles/vs_instancing.bin and b/examples/runtime/shaders/gles/vs_instancing.bin differ
diff --git a/examples/runtime/shaders/gles/vs_mesh.bin b/examples/runtime/shaders/gles/vs_mesh.bin
index e68de896..aaa78183 100644
Binary files a/examples/runtime/shaders/gles/vs_mesh.bin and b/examples/runtime/shaders/gles/vs_mesh.bin differ
diff --git a/examples/runtime/shaders/gles/vs_metaballs.bin b/examples/runtime/shaders/gles/vs_metaballs.bin
index 4889e741..5fc6059e 100644
Binary files a/examples/runtime/shaders/gles/vs_metaballs.bin and b/examples/runtime/shaders/gles/vs_metaballs.bin differ
diff --git a/examples/runtime/shaders/gles/vs_raymarching.bin b/examples/runtime/shaders/gles/vs_raymarching.bin
index a3d1ac14..61b8a8f7 100644
Binary files a/examples/runtime/shaders/gles/vs_raymarching.bin and b/examples/runtime/shaders/gles/vs_raymarching.bin differ
diff --git a/examples/runtime/shaders/glsl/fs_bump.bin b/examples/runtime/shaders/glsl/fs_bump.bin
index f3ccd023..204fa926 100644
Binary files a/examples/runtime/shaders/glsl/fs_bump.bin and b/examples/runtime/shaders/glsl/fs_bump.bin differ
diff --git a/examples/runtime/shaders/glsl/fs_cubes.bin b/examples/runtime/shaders/glsl/fs_cubes.bin
index 59695bd2..5453e145 100644
Binary files a/examples/runtime/shaders/glsl/fs_cubes.bin and b/examples/runtime/shaders/glsl/fs_cubes.bin differ
diff --git a/examples/runtime/shaders/glsl/fs_instancing.bin b/examples/runtime/shaders/glsl/fs_instancing.bin
index 59695bd2..5453e145 100644
Binary files a/examples/runtime/shaders/glsl/fs_instancing.bin and b/examples/runtime/shaders/glsl/fs_instancing.bin differ
diff --git a/examples/runtime/shaders/glsl/fs_mesh.bin b/examples/runtime/shaders/glsl/fs_mesh.bin
index eaf53d6b..3d29b1cc 100644
Binary files a/examples/runtime/shaders/glsl/fs_mesh.bin and b/examples/runtime/shaders/glsl/fs_mesh.bin differ
diff --git a/examples/runtime/shaders/glsl/fs_metaballs.bin b/examples/runtime/shaders/glsl/fs_metaballs.bin
index d5e35e88..5af416d7 100644
Binary files a/examples/runtime/shaders/glsl/fs_metaballs.bin and b/examples/runtime/shaders/glsl/fs_metaballs.bin differ
diff --git a/examples/runtime/shaders/glsl/fs_raymarching.bin b/examples/runtime/shaders/glsl/fs_raymarching.bin
index 3484bdc1..907a2b86 100644
Binary files a/examples/runtime/shaders/glsl/fs_raymarching.bin and b/examples/runtime/shaders/glsl/fs_raymarching.bin differ
diff --git a/examples/runtime/shaders/glsl/vs_bump.bin b/examples/runtime/shaders/glsl/vs_bump.bin
index 2de04a44..72324e94 100644
Binary files a/examples/runtime/shaders/glsl/vs_bump.bin and b/examples/runtime/shaders/glsl/vs_bump.bin differ
diff --git a/examples/runtime/shaders/glsl/vs_cubes.bin b/examples/runtime/shaders/glsl/vs_cubes.bin
index ebd20cfe..05467fda 100644
Binary files a/examples/runtime/shaders/glsl/vs_cubes.bin and b/examples/runtime/shaders/glsl/vs_cubes.bin differ
diff --git a/examples/runtime/shaders/glsl/vs_instancing.bin b/examples/runtime/shaders/glsl/vs_instancing.bin
index a425235d..9bdd6406 100644
Binary files a/examples/runtime/shaders/glsl/vs_instancing.bin and b/examples/runtime/shaders/glsl/vs_instancing.bin differ
diff --git a/examples/runtime/shaders/glsl/vs_mesh.bin b/examples/runtime/shaders/glsl/vs_mesh.bin
index d1772ea5..2fa0af63 100644
Binary files a/examples/runtime/shaders/glsl/vs_mesh.bin and b/examples/runtime/shaders/glsl/vs_mesh.bin differ
diff --git a/examples/runtime/shaders/glsl/vs_metaballs.bin b/examples/runtime/shaders/glsl/vs_metaballs.bin
index 4c0cff6f..6e1bb693 100644
Binary files a/examples/runtime/shaders/glsl/vs_metaballs.bin and b/examples/runtime/shaders/glsl/vs_metaballs.bin differ
diff --git a/examples/runtime/shaders/glsl/vs_raymarching.bin b/examples/runtime/shaders/glsl/vs_raymarching.bin
index 38bd7361..063bf2ef 100644
Binary files a/examples/runtime/shaders/glsl/vs_raymarching.bin and b/examples/runtime/shaders/glsl/vs_raymarching.bin differ
diff --git a/include/bgfx.h b/include/bgfx.h
index d91ffce5..9d15cc7a 100644
--- a/include/bgfx.h
+++ b/include/bgfx.h
@@ -230,6 +230,7 @@ namespace bgfx
 		enum Enum
 		{
 			MinimumRequiredSpecs = 1,
+			InvalidShader,
 			D3D9_UnableToCreateInterface,
 			D3D9_UnableToCreateDevice,
 			D3D9_UnableToCreateRenderTarget,
@@ -304,7 +305,10 @@ namespace bgfx
 			ARGB8,
 			ABGR16,
 			R5G6B5,
-
+			RGBA4,
+			RGB5A1,
+			RGB10A2,
+			
 			Count
 		};
 	};
@@ -453,7 +457,7 @@ namespace bgfx
 	///
 	///   BGFX_DEBUG_IFH - Infinitely fast hardware. When this flag is set
 	///     all rendering calls will be skipped. It's useful when profiling
-    ///     to quickly assess bottleneck between CPU and GPU.
+	///     to quickly assess bottleneck between CPU and GPU.
 	///
 	///   BGFX_DEBUG_STATS - Display internal statistics.
 	///
@@ -545,6 +549,11 @@ namespace bgfx
 	void destroyFragmentShader(FragmentShaderHandle _handle);
 
 	/// Create program with vertex and fragment shaders.
+	///
+	/// @param _vsh vertex shader.
+	/// @param _fsh fragment shader.
+	/// @returns Program handle if vertex shader output and fragment shader
+	/// input are matching, otherwise returns invalid program handle.
 	ProgramHandle createProgram(VertexShaderHandle _vsh, FragmentShaderHandle _fsh);
 
 	/// Destroy program.
diff --git a/premake/premake4.lua b/premake/premake4.lua
index da87919d..d3695679 100644
--- a/premake/premake4.lua
+++ b/premake/premake4.lua
@@ -264,9 +264,10 @@ function copyLib()
 end
 
 dofile "bgfx.lua"
-dofile "ddsdump.lua"
 dofile "makedisttex.lua"
 dofile "shaderc.lua"
+dofile "texturec.lua"
+dofile "geometryc.lua"
 dofile "openctm.lua"
 dofile "example-00-helloworld.lua"
 dofile "example-01-cubes.lua"
diff --git a/premake/shader.mk b/premake/shader.mk
index 31c6e7db..b7988dc5 100644
--- a/premake/shader.mk
+++ b/premake/shader.mk
@@ -35,8 +35,8 @@ FS_FLAGS=--platform android
 SHADER_PATH=shaders/gles
 else
 ifeq ($(TARGET), 4)
-VS_FLAGS=--platform linux -p 140
-FS_FLAGS=--platform linux -p 140
+VS_FLAGS=--platform linux -p 120
+FS_FLAGS=--platform linux -p 120
 SHADER_PATH=shaders/glsl
 endif
 endif
@@ -45,7 +45,7 @@ endif
 endif
 
 BUILD_OUTPUT_DIR=$(addprefix ./, $(RUNTIME_DIR)/$(SHADER_PATH))
-BUILD_INTERMEDIATE_DIR=$(addprefix $(BGFX_DIR)/.build/, $(SHADER_PATH))
+BUILD_INTERMEDIATE_DIR=$(addprefix $(BUILD_DIR)/, $(SHADER_PATH))
 
 VS_SOURCES=$(wildcard vs_*.sc)
 VS_DEPS=$(addprefix $(BUILD_INTERMEDIATE_DIR)/,$(addsuffix .bin.d, $(basename $(VS_SOURCES))))
diff --git a/premake/shaderc.lua b/premake/shaderc.lua
index 98b6242b..3f7453db 100644
--- a/premake/shaderc.lua
+++ b/premake/shaderc.lua
@@ -46,7 +46,8 @@ project "shaderc"
 	}
 
 	files {
-		BGFX_DIR .. "tools/shaderc.cpp",
+		BGFX_DIR .. "tools/shaderc/**.cpp",
+		BGFX_DIR .. "tools/shaderc/**.h",
 		FCPP_DIR .. "**.h",
 		FCPP_DIR .. "cpp1.c",
 		FCPP_DIR .. "cpp2.c",
diff --git a/premake/ddsdump.lua b/premake/texturec.lua
similarity index 66%
rename from premake/ddsdump.lua
rename to premake/texturec.lua
index 9c9917b4..d655e6f7 100644
--- a/premake/ddsdump.lua
+++ b/premake/texturec.lua
@@ -1,4 +1,4 @@
-project "ddsdump"
+project "texturec"
 	uuid "838801ee-7bc3-11e1-9f19-eae7d36e7d26"
 	kind "ConsoleApp"
 
@@ -10,7 +10,8 @@ project "ddsdump"
 
 	files {
 		BGFX_DIR .. "src/dds.*",
-		BGFX_DIR .. "tools/ddsdump.cpp",
+		BGFX_DIR .. "tools/texturec/**.cpp",
+		BGFX_DIR .. "tools/texturec/**.h",
 	}
 
 	links {
diff --git a/src/bgfx.cpp b/src/bgfx.cpp
index e205d4b8..4e48dd10 100644
--- a/src/bgfx.cpp
+++ b/src/bgfx.cpp
@@ -30,11 +30,11 @@ namespace bgfx
 #define BGFX_MAIN_THREAD_MAGIC 0x78666762
 
 #if BGFX_CONFIG_MULTITHREADED
-#	define BGFX_MAIN_THREAD() BX_CHECK(BGFX_MAIN_THREAD_MAGIC == s_threadIndex, "Must be called from main thread.")
-#	define BGFX_RENDER_THREAD() BX_CHECK(BGFX_MAIN_THREAD_MAGIC != s_threadIndex, "Must be called from render thread.")
+#	define BGFX_CHECK_MAIN_THREAD() BX_CHECK(BGFX_MAIN_THREAD_MAGIC == s_threadIndex, "Must be called from main thread.")
+#	define BGFX_CHECK_RENDER_THREAD() BX_CHECK(BGFX_MAIN_THREAD_MAGIC != s_threadIndex, "Must be called from render thread.")
 #else
-#	define BGFX_MAIN_THREAD()
-#	define BGFX_RENDER_THREAD()
+#	define BGFX_CHECK_MAIN_THREAD()
+#	define BGFX_CHECK_RENDER_THREAD()
 #endif // BGFX_CONFIG_MULTITHREADED
 
 	void fatalStub(Fatal::Enum _code, const char* _str)
@@ -197,6 +197,7 @@ namespace bgfx
 
 	void TextVideoMemBlitter::init()
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		m_decl.begin();
 		m_decl.add(Attrib::Position, 3, AttribType::Float);
 		m_decl.add(Attrib::Color0, 4, AttribType::Uint8, true);
@@ -250,6 +251,7 @@ namespace bgfx
 
 	void TextVideoMemBlitter::blit(const TextVideoMem& _mem)
 	{
+		BGFX_CHECK_RENDER_THREAD();
 		struct Vertex
 		{
 			float m_x;
@@ -360,6 +362,7 @@ namespace bgfx
 
 	void ClearQuad::init()
 	{
+		BGFX_CHECK_MAIN_THREAD();
 #if BGFX_CONFIG_RENDERER_DIRECT3D11
 		m_decl.begin();
 		m_decl.add(Attrib::Position, 3, AttribType::Float);
@@ -544,25 +547,31 @@ namespace bgfx
 
 	void shutdown()
 	{
-		BGFX_MAIN_THREAD();
+		BGFX_CHECK_MAIN_THREAD();
 		s_ctx.shutdown();
+
+		s_threadIndex = 0;
+		g_fatal = fatalStub;
+		g_realloc = reallocStub;
+		g_free = freeStub;
+		g_cache = cacheStub;
 	}
 
 	void reset(uint32_t _width, uint32_t _height, uint32_t _flags)
 	{
-		BGFX_MAIN_THREAD();
+		BGFX_CHECK_MAIN_THREAD();
 		s_ctx.reset(_width, _height, _flags);
 	}
 
 	void frame()
 	{
-		BGFX_MAIN_THREAD();
+		BGFX_CHECK_MAIN_THREAD();
 		s_ctx.frame();
 	}
 
 	bool renderFrame()
 	{
-		BGFX_RENDER_THREAD();
+		BGFX_CHECK_RENDER_THREAD();
 		return s_ctx.renderFrame();
 	}
 
@@ -618,7 +627,7 @@ namespace bgfx
 
 	void VertexDecl::end()
 	{
-		m_hash = hash(m_attributes, sizeof(m_attributes) );
+		m_hash = hashMurmur2A(m_attributes, sizeof(m_attributes) );
 	}
 
 	void VertexDecl::add(Attrib::Enum _attrib, uint8_t _num, AttribType::Enum _type, bool _normalized)
@@ -668,7 +677,7 @@ namespace bgfx
 #if BGFX_CONFIG_DEBUG
 		BX_TRACE("vertexdecl %08x (%08x), stride %d"
 			, _decl.m_hash
-			, hash(_decl.m_attributes, sizeof(_decl.m_attributes) )
+			, hashMurmur2A(_decl.m_attributes, sizeof(_decl.m_attributes) )
 			, _decl.m_stride
 			);
 
@@ -842,16 +851,19 @@ namespace bgfx
 
 	void setDebug(uint32_t _debug)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		s_ctx.m_debug = _debug;
 	}
 
 	void dbgTextClear(uint8_t _attr, bool _small)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		s_ctx.dbgTextClear(_attr, _small);
 	}
 
 	void dbgTextPrintf(uint16_t _x, uint16_t _y, uint8_t _attr, const char* _format, ...)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		va_list argList;
 		va_start(argList, _format);
 		s_ctx.dbgTextPrintfVargs(_x, _y, _attr, _format, argList);
@@ -860,11 +872,13 @@ namespace bgfx
 
 	IndexBufferHandle createIndexBuffer(const Memory* _mem)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		return s_ctx.createIndexBuffer(_mem);
 	}
 
 	void destroyIndexBuffer(IndexBufferHandle _handle)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		s_ctx.destroyIndexBuffer(_handle);
 	}
 
@@ -875,126 +889,148 @@ namespace bgfx
 
 	void destroyVertexBuffer(VertexBufferHandle _handle)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		s_ctx.destroyVertexBuffer(_handle);
 	}
 
 	DynamicIndexBufferHandle createDynamicIndexBuffer(uint16_t _num)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		return s_ctx.createDynamicIndexBuffer(_num);
 	}
 
 	DynamicIndexBufferHandle createDynamicIndexBuffer(const Memory* _mem)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		BX_CHECK(NULL != _mem, "_mem can't be NULL");
 		return s_ctx.createDynamicIndexBuffer(_mem);
 	}
 
 	void updateDynamicIndexBuffer(DynamicIndexBufferHandle _handle, const Memory* _mem)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		BX_CHECK(NULL != _mem, "_mem can't be NULL");
 		s_ctx.updateDynamicIndexBuffer(_handle, _mem);
 	}
 
 	void destroyDynamicIndexBuffer(DynamicIndexBufferHandle _handle)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		s_ctx.destroyDynamicIndexBuffer(_handle);
 	}
 
 	DynamicVertexBufferHandle createDynamicVertexBuffer(uint16_t _num, const VertexDecl& _decl)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		return s_ctx.createDynamicVertexBuffer(_num, _decl);
 	}
 
 	DynamicVertexBufferHandle createDynamicVertexBuffer(const Memory* _mem, const VertexDecl& _decl)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		BX_CHECK(NULL != _mem, "_mem can't be NULL");
 		return s_ctx.createDynamicVertexBuffer(_mem, _decl);
 	}
 
 	void updateDynamicVertexBuffer(DynamicVertexBufferHandle _handle, const Memory* _mem)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		BX_CHECK(NULL != _mem, "_mem can't be NULL");
 		s_ctx.updateDynamicVertexBuffer(_handle, _mem);
 	}
 
 	void destroyDynamicVertexBuffer(DynamicVertexBufferHandle _handle)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		s_ctx.destroyDynamicVertexBuffer(_handle);
 	}
 
 	bool checkAvailTransientIndexBuffer(uint16_t _num)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		return s_ctx.m_submit->checkAvailTransientIndexBuffer(_num);
 	}
 
 	void allocTransientIndexBuffer(TransientIndexBuffer* _tib, uint16_t _num)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		BX_CHECK(NULL != _tib, "_tib can't be NULL");
 		return s_ctx.allocTransientIndexBuffer(_tib, _num);
 	}
 
 	bool checkAvailTransientVertexBuffer(uint16_t _num, const VertexDecl& _decl)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		return s_ctx.m_submit->checkAvailTransientVertexBuffer(_num, _decl.m_stride);
 	}
 
 	void allocTransientVertexBuffer(TransientVertexBuffer* _tvb, uint16_t _num, const VertexDecl& _decl)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		BX_CHECK(NULL != _tvb, "_tvb can't be NULL");
 		return s_ctx.allocTransientVertexBuffer(_tvb, _num, _decl);
 	}
 
 	const InstanceDataBuffer* allocInstanceDataBuffer(uint16_t _num, uint16_t _stride)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		return s_ctx.allocInstanceDataBuffer(_num, _stride);
 	}
 
 	VertexShaderHandle createVertexShader(const Memory* _mem)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		BX_CHECK(NULL != _mem, "_mem can't be NULL");
 		return s_ctx.createVertexShader(_mem);
 	}
 
 	void destroyVertexShader(VertexShaderHandle _handle)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		s_ctx.destroyVertexShader(_handle);
 	}
 
 	FragmentShaderHandle createFragmentShader(const Memory* _mem)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		BX_CHECK(NULL != _mem, "_mem can't be NULL");
 		return s_ctx.createFragmentShader(_mem);
 	}
 
 	void destroyFragmentShader(FragmentShaderHandle _handle)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		s_ctx.destroyFragmentShader(_handle);
 	}
 
 	ProgramHandle createProgram(VertexShaderHandle _vsh, FragmentShaderHandle _fsh)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		return s_ctx.createProgram(_vsh, _fsh);
 	}
 
 	void destroyProgram(ProgramHandle _handle)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		s_ctx.destroyProgram(_handle);
 	}
 
 	TextureHandle createTexture(const Memory* _mem, uint32_t _flags, TextureInfo* _info)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		BX_CHECK(NULL != _mem, "_mem can't be NULL");
 		return s_ctx.createTexture(_mem, _flags, _info);
 	}
 
 	TextureHandle createTexture2D(uint16_t _width, uint16_t _height, uint8_t _numMips, TextureFormat::Enum _format, uint32_t _flags, const Memory* _mem)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		uint32_t size = sizeof(uint32_t)+sizeof(TextureCreate);
 		const bgfx::Memory* mem = alloc(size);
 
-		StreamWrite stream(mem->data, mem->size);
-		uint32_t magic = BGFX_MAGIC;
-		stream.write(magic);
+		bx::StaticMemoryBlockWriter writer(mem->data, mem->size);
+		uint32_t magic = BGFX_CHUNK_MAGIC_TEX;
+		bx::write(&writer, magic);
 
 		TextureCreate tc;
 		tc.m_flags = _flags;
@@ -1002,22 +1038,23 @@ namespace bgfx
 		tc.m_height = _height;
 		tc.m_depth = 0;
 		tc.m_numMips = _numMips;
-		tc.m_type = uint8_t(_format);
+		tc.m_format = uint8_t(_format);
 		tc.m_cubeMap = false;
 		tc.m_mem = _mem;
-		stream.write(tc);
+		bx::write(&writer, tc);
 
 		return s_ctx.createTexture(mem, _flags, NULL);
 	}
 
 	TextureHandle createTexture3D(uint16_t _width, uint16_t _height, uint16_t _depth, uint8_t _numMips, TextureFormat::Enum _format, uint32_t _flags, const Memory* _mem)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		uint32_t size = sizeof(uint32_t)+sizeof(TextureCreate);
 		const bgfx::Memory* mem = alloc(size);
 
-		StreamWrite stream(mem->data, mem->size);
-		uint32_t magic = BGFX_MAGIC;
-		stream.write(magic);
+		bx::StaticMemoryBlockWriter writer(mem->data, mem->size);
+		uint32_t magic = BGFX_CHUNK_MAGIC_TEX;
+		bx::write(&writer, magic);
 
 		TextureCreate tc;
 		tc.m_flags = _flags;
@@ -1025,22 +1062,23 @@ namespace bgfx
 		tc.m_height = _height;
 		tc.m_depth = _depth;
 		tc.m_numMips = _numMips;
-		tc.m_type = uint8_t(_format);
+		tc.m_format = uint8_t(_format);
 		tc.m_cubeMap = false;
 		tc.m_mem = _mem;
-		stream.write(tc);
+		bx::write(&writer, tc);
 
 		return s_ctx.createTexture(mem, _flags, NULL);
 	}
 
 	TextureHandle createTextureCube(uint16_t _sides, uint16_t _width, uint8_t _numMips, TextureFormat::Enum _format, uint32_t _flags, const Memory* _mem)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		uint32_t size = sizeof(uint32_t)+sizeof(TextureCreate);
 		const bgfx::Memory* mem = alloc(size);
 
-		StreamWrite stream(mem->data, mem->size);
-		uint32_t magic = BGFX_MAGIC;
-		stream.write(magic);
+		bx::StaticMemoryBlockWriter writer(mem->data, mem->size);
+		uint32_t magic = BGFX_CHUNK_MAGIC_TEX;
+		bx::write(&writer, magic);
 
 		TextureCreate tc;
 		tc.m_flags = _flags;
@@ -1048,21 +1086,23 @@ namespace bgfx
 		tc.m_sides = _sides;
 		tc.m_depth = 0;
 		tc.m_numMips = _numMips;
-		tc.m_type = uint8_t(_format);
+		tc.m_format = uint8_t(_format);
 		tc.m_cubeMap = true;
 		tc.m_mem = _mem;
-		stream.write(tc);
+		bx::write(&writer, tc);
 
 		return s_ctx.createTexture(mem, _flags, NULL);
 	}
 
 	void destroyTexture(TextureHandle _handle)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		s_ctx.destroyTexture(_handle);
 	}
 
 	void updateTexture2D(TextureHandle _handle, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const Memory* _mem)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		BX_CHECK(NULL != _mem, "_mem can't be NULL");
 		if (_width == 0
 		||  _height == 0)
@@ -1077,6 +1117,7 @@ namespace bgfx
 
 	void updateTexture3D(TextureHandle _handle, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _z, uint16_t _width, uint16_t _height, uint16_t _depth, const Memory* _mem)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		BX_CHECK(NULL != _mem, "_mem can't be NULL");
 		if (_width == 0
 		||  _height == 0
@@ -1092,6 +1133,7 @@ namespace bgfx
 
 	void updateTextureCube(TextureHandle _handle, uint8_t _side, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const Memory* _mem)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		BX_CHECK(NULL != _mem, "_mem can't be NULL");
 		if (_width == 0
 		||  _height == 0)
@@ -1106,126 +1148,151 @@ namespace bgfx
 
 	RenderTargetHandle createRenderTarget(uint16_t _width, uint16_t _height, uint32_t _flags, uint32_t _textureFlags)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		return s_ctx.createRenderTarget(_width, _height, _flags, _textureFlags);
 	}
 
 	void destroyRenderTarget(RenderTargetHandle _handle)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		s_ctx.destroyRenderTarget(_handle);
 	}
 
 	UniformHandle createUniform(const char* _name, UniformType::Enum _type, uint16_t _num)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		return s_ctx.createUniform(_name, _type, _num);
 	}
 
 	void destroyUniform(UniformHandle _handle)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		s_ctx.destroyUniform(_handle);
 	}
 
 	void setViewRect(uint8_t _id, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		s_ctx.setViewRect(_id, _x, _y, _width, _height);
 	}
 
 	void setViewRectMask(uint32_t _viewMask, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		s_ctx.setViewRectMask(_viewMask, _x, _y, _width, _height);
 	}
 
 	void setViewClear(uint8_t _id, uint8_t _flags, uint32_t _rgba, float _depth, uint8_t _stencil)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		s_ctx.setViewClear(_id, _flags, _rgba, _depth, _stencil);
 	}
 
 	void setViewClearMask(uint32_t _viewMask, uint8_t _flags, uint32_t _rgba, float _depth, uint8_t _stencil)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		s_ctx.setViewClearMask(_viewMask, _flags, _rgba, _depth, _stencil);
 	}
 
 	void setViewSeq(uint8_t _id, bool _enabled)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		s_ctx.setViewSeq(_id, _enabled);
 	}
 
 	void setViewSeqMask(uint32_t _viewMask, bool _enabled)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		s_ctx.setViewSeqMask(_viewMask, _enabled);
 	}
 
 	void setViewRenderTarget(uint8_t _id, RenderTargetHandle _handle)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		s_ctx.setViewRenderTarget(_id, _handle);
 	}
 
 	void setViewRenderTargetMask(uint32_t _mask, RenderTargetHandle _handle)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		s_ctx.setViewRenderTargetMask(_mask, _handle);
 	}
 
 	void setViewTransform(uint8_t _id, const void* _view, const void* _proj, uint8_t _other)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		s_ctx.m_submit->setViewTransform(_id, _view, _proj, _other);
 	}
 
 	void setViewTransformMask(uint32_t _viewMask, const void* _view, const void* _proj, uint8_t _other)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		s_ctx.m_submit->setViewTransformMask(_viewMask, _view, _proj, _other);
 	}
 
 	void setState(uint64_t _state)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		s_ctx.m_submit->setState(_state);
 	}
 
 	void setStencil(uint32_t _fstencil, uint32_t _bstencil)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		s_ctx.m_submit->setStencil(_fstencil, _bstencil);
 	}
 
 	uint32_t setTransform(const void* _mtx, uint16_t _num)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		return s_ctx.m_submit->setTransform(_mtx, _num);
 	}
 
 	void setTransform(uint32_t _cache, uint16_t _num)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		s_ctx.m_submit->setTransform(_cache, _num);
 	}
 
 	void setUniform(UniformHandle _handle, const void* _value, uint16_t _num)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		s_ctx.setUniform(_handle, _value, _num);
 	}
 
 	void setUniform(ProgramHandle _program, UniformHandle _handle, const void* _value)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		s_ctx.setUniform(_program, _handle, _value);
 	}
 
 	void setIndexBuffer(IndexBufferHandle _handle, uint32_t _firstIndex, uint32_t _numIndices)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		s_ctx.m_submit->setIndexBuffer(_handle, _firstIndex, _numIndices);
 	}
 
 	void setIndexBuffer(IndexBufferHandle _handle)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		s_ctx.m_submit->setIndexBuffer(_handle, BGFX_DRAW_WHOLE_INDEX_BUFFER, 0);
 	}
 
 	void setIndexBuffer(DynamicIndexBufferHandle _handle, uint32_t _firstIndex, uint32_t _numIndices)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		s_ctx.m_submit->setIndexBuffer(s_ctx.m_dynamicIndexBuffers[_handle.idx].m_handle, _firstIndex, _numIndices);
 	}
 
 	void setIndexBuffer(DynamicIndexBufferHandle _handle)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		s_ctx.m_submit->setIndexBuffer(s_ctx.m_dynamicIndexBuffers[_handle.idx].m_handle, BGFX_DRAW_WHOLE_INDEX_BUFFER, 0);
 	}
 
 	void setIndexBuffer(const TransientIndexBuffer* _tib, uint32_t _numIndices)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		BX_CHECK(NULL != _tib, "_tib can't be NULL");
 		uint32_t numIndices = uint32_min(_numIndices, _tib->size/2);
 		s_ctx.m_submit->setIndexBuffer(_tib, numIndices);
@@ -1233,52 +1300,62 @@ namespace bgfx
 
 	void setVertexBuffer(VertexBufferHandle _handle, uint32_t _numVertices)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		s_ctx.m_submit->setVertexBuffer(_handle, _numVertices);
 	}
 
 	void setVertexBuffer(DynamicVertexBufferHandle _handle, uint32_t _numVertices)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		s_ctx.m_submit->setVertexBuffer(s_ctx.m_dynamicVertexBuffers[_handle.idx], _numVertices);
 	}
 
 	void setVertexBuffer(const TransientVertexBuffer* _tvb, uint32_t _numVertices)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		BX_CHECK(NULL != _tvb, "_tvb can't be NULL");
 		s_ctx.m_submit->setVertexBuffer(_tvb, _numVertices);
 	}
 
 	void setInstanceDataBuffer(const InstanceDataBuffer* _idb, uint16_t _num)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		s_ctx.m_submit->setInstanceDataBuffer(_idb, _num);
 	}
 
 	void setProgram(ProgramHandle _handle)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		s_ctx.m_submit->setProgram(_handle);
 	}
 
 	void setTexture(uint8_t _stage, UniformHandle _sampler, TextureHandle _handle)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		s_ctx.m_submit->setTexture(_stage, _sampler, _handle);
 	}
 
 	void setTexture(uint8_t _stage, UniformHandle _sampler, RenderTargetHandle _handle, bool _depth)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		s_ctx.m_submit->setTexture(_stage, _sampler, _handle, _depth);
 	}
 
 	void submit(uint8_t _id, int32_t _depth)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		s_ctx.m_submit->submit(_id, _depth);
 	}
 
 	void submitMask(uint32_t _viewMask, int32_t _depth)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		s_ctx.m_submit->submitMask(_viewMask, _depth);
 	}
 
 	void saveScreenShot(const char* _filePath)
 	{
+		BGFX_CHECK_MAIN_THREAD();
 		uint32_t len = (uint32_t)strlen(_filePath)+1;
 		const Memory* mem = alloc(len);
 		memcpy(mem->data, _filePath, mem->size);
diff --git a/src/bgfx_p.h b/src/bgfx_p.h
index 2d7a9098..a463df24 100644
--- a/src/bgfx_p.h
+++ b/src/bgfx_p.h
@@ -27,6 +27,14 @@ extern void dbgPrintfData(const void* _data, uint32_t _size, const char* _format
 					dbgPrintf(BX_FILE_LINE_LITERAL "BGFX " _format "\n", ##__VA_ARGS__); \
 				} while(0)
 
+#	define BX_WARN(_condition, _format, ...) \
+				do { \
+					if (!(_condition) ) \
+					{ \
+						BX_TRACE(BX_FILE_LINE_LITERAL "WARN " _format, ##__VA_ARGS__); \
+					} \
+				} while(0)
+
 #	define BX_CHECK(_condition, _format, ...) \
 				do { \
 					if (!(_condition) ) \
@@ -56,6 +64,7 @@ extern void dbgPrintfData(const void* _data, uint32_t _size, const char* _format
 #include <bx/radixsort.h>
 #include <bx/ringbuffer.h>
 #include <bx/uint32_t.h>
+#include <bx/readerwriter.h>
 
 #if BX_PLATFORM_WINDOWS
 #	include <windows.h>
@@ -67,18 +76,11 @@ extern HWND g_bgfxHwnd;
 #	include <pthread.h>
 #endif // BX_PLATFORM_*
 
-#ifndef MAKEFOURCC
-#	define MAKEFOURCC(_a, _b, _c, _d) (0 \
-				| ( (uint32_t)(_a) \
-				| ( (uint32_t)(_b) << 8) \
-				| ( (uint32_t)(_c) << 16) \
-				| ( (uint32_t)(_d) << 24) \
-				) )
-#endif // MAKEFOURCC
-
 #include "dds.h"
 
-#define BGFX_MAGIC MAKEFOURCC('B','G','F','X')
+#define BGFX_CHUNK_MAGIC_FSH BX_MAKEFOURCC('F', 'S', 'H', 0x0)
+#define BGFX_CHUNK_MAGIC_TEX BX_MAKEFOURCC('T', 'E', 'X', 0x0)
+#define BGFX_CHUNK_MAGIC_VSH BX_MAKEFOURCC('V', 'S', 'H', 0x0)
 
 #if BGFX_CONFIG_USE_TINYSTL
 
@@ -174,7 +176,7 @@ namespace bgfx
 		};
 		uint16_t m_depth;
 		uint8_t m_numMips;
-		uint8_t m_type;
+		uint8_t m_format;
 		bool m_cubeMap;
 		const Memory* m_mem;
 	};
@@ -201,14 +203,6 @@ namespace bgfx
 		return _a < _b ? _b : _a;
 	}
 
-	inline uint32_t hash(const void* _data, uint32_t _size)
-	{
-		HashMurmur2A murmur;
-		murmur.begin();
-		murmur.add(_data, (int)_size);
-		return murmur.end();
-	}
-
 	inline uint32_t gcd(uint32_t _a, uint32_t _b)
 	{
 		do
@@ -413,113 +407,6 @@ namespace bgfx
 	const char* getPredefinedUniformName(PredefinedUniform::Enum _enum);
 	PredefinedUniform::Enum nameToPredefinedUniformEnum(const char* _name);
 
-	class StreamRead
-	{
-	public:
-		StreamRead(const void* _data, uint32_t _size)
-			: m_data( (uint8_t*)_data)
-			, m_size(_size)
-			, m_pos(0)
-		{
-		}
-
-		~StreamRead()
-		{
-		}
-
-		void skip(uint32_t _size)
-		{
-			BX_CHECK(m_size-m_pos >= _size, "Available %d, requested %d.", m_size-m_pos, _size);
-			m_pos += _size;
-		}
-
-		void read(void* _data, uint32_t _size)
-		{
-			BX_CHECK(m_size-m_pos >= _size, "Available %d, requested %d.", m_size-m_pos, _size);
-			memcpy(_data, &m_data[m_pos], _size);
-			m_pos += _size;
-		}
-
-		template<typename Ty>
-		void read(Ty& _value)
-		{
-			read(&_value, sizeof(Ty) );
-		}
-
-		const uint8_t* getDataPtr() const
-		{
-			return &m_data[m_pos];
-		}
-
-		uint32_t getPos() const
-		{
-			return m_pos;
-		}
-
-		void align(uint16_t _align)
-		{
-			m_pos = strideAlign(m_pos, _align);
-		}
-
-		uint32_t remaining() const
-		{
-			return m_size-m_pos;
-		}
-
-	private:
-		const uint8_t* m_data;
-		uint32_t m_size;
-		uint32_t m_pos;
-	};
-
-	class StreamWrite
-	{
-	public:
-		StreamWrite(void* _data, uint32_t _size)
-			: m_data( (uint8_t*)_data)
-			, m_size(_size)
-			, m_pos(0)
-		{
-		}
-
-		~StreamWrite()
-		{
-		}
-
-		void write(void* _data, uint32_t _size)
-		{
-			BX_CHECK(m_size-m_pos >= _size, "Write out of bounds. Available %d, requested %d.", m_size-m_pos, _size);
-			memcpy(&m_data[m_pos], _data, _size);
-			m_pos += _size;
-		}
-
-		template<typename Ty>
-		void write(Ty& _value)
-		{
-			write(&_value, sizeof(Ty) );
-		}
-
-		uint8_t* getDataPtr() const
-		{
-			return &m_data[m_pos];
-		}
-
-		uint32_t getPos() const
-		{
-			return m_pos;
-		}
-
-		void align(uint16_t _align)
-		{
-			m_pos = strideAlign(m_pos, _align);
-		}
-
-	private:
-		uint8_t* m_data;
-		uint32_t m_size;
-		uint32_t m_pos;
-	};
-
 	struct CommandBuffer
 	{
 		CommandBuffer()
@@ -1929,8 +1816,24 @@ namespace bgfx
 
 		VertexShaderHandle createVertexShader(const Memory* _mem)
 		{
+			bx::MemoryReader reader(_mem->data, _mem->size);
+
+			uint32_t magic;
+			bx::read(&reader, magic);
+
+			if (BGFX_CHUNK_MAGIC_VSH != magic)
+			{
+				BX_WARN(false, "Invalid vertex shader signature! 0x%08x", magic);
+				VertexShaderHandle invalid = BGFX_INVALID_HANDLE;
+				return invalid;
+			}
+
 			VertexShaderHandle handle = { m_vertexShaderHandle.alloc() };
-			m_vertexShaderRef[handle.idx] = 1;
+
+			VertexShaderRef& vsr = m_vertexShaderRef[handle.idx];
+			vsr.m_refCount = 1;
+			bx::read(&reader, vsr.m_outputHash);
+
 			CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::CreateVertexShader);
 			cmdbuf.write(handle);
 			cmdbuf.write(_mem);
@@ -1944,12 +1847,14 @@ namespace bgfx
 
 		void vertexShaderIncRef(VertexShaderHandle _handle)
 		{
-			++m_vertexShaderRef[_handle.idx];
+			VertexShaderRef& vsr = m_vertexShaderRef[_handle.idx];
+			++vsr.m_refCount;
 		}
 
 		void vertexShaderDecRef(VertexShaderHandle _handle)
 		{
-			int32_t refs = --m_vertexShaderRef[_handle.idx];
+			VertexShaderRef& vsr = m_vertexShaderRef[_handle.idx];
+			int32_t refs = --vsr.m_refCount;
 			if (0 == refs)
 			{
 				CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::DestroyVertexShader);
@@ -1960,8 +1865,24 @@ namespace bgfx
 
 		FragmentShaderHandle createFragmentShader(const Memory* _mem)
 		{
+			bx::MemoryReader reader(_mem->data, _mem->size);
+
+			uint32_t magic;
+			bx::read(&reader, magic);
+
+			if (BGFX_CHUNK_MAGIC_FSH != magic)
+			{
+				BX_WARN(false, "Invalid fragment shader signature! 0x%08x", magic);
+				FragmentShaderHandle invalid = BGFX_INVALID_HANDLE;
+				return invalid;
+			}
+
 			FragmentShaderHandle handle = { m_fragmentShaderHandle.alloc() };
-			m_fragmentShaderRef[handle.idx] = 1;
+
+			FragmentShaderRef& fsr = m_fragmentShaderRef[handle.idx];
+			fsr.m_refCount = 1;
+			bx::read(&reader, fsr.m_inputHash);
+
 			CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::CreateFragmentShader);
 			cmdbuf.write(handle);
 			cmdbuf.write(_mem);
@@ -1975,12 +1896,14 @@ namespace bgfx
 
 		void fragmentShaderIncRef(FragmentShaderHandle _handle)
 		{
-			++m_fragmentShaderRef[_handle.idx];
+			FragmentShaderRef& fsr = m_fragmentShaderRef[_handle.idx];
+			++fsr.m_refCount;
 		}
 
 		void fragmentShaderDecRef(FragmentShaderHandle _handle)
 		{
-			int32_t refs = --m_fragmentShaderRef[_handle.idx];
+			FragmentShaderRef& fsr = m_fragmentShaderRef[_handle.idx];
+			int32_t refs = --fsr.m_refCount;
 			if (0 == refs)
 			{
 				CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::DestroyFragmentShader);
@@ -1991,6 +1914,15 @@ namespace bgfx
 
 		ProgramHandle createProgram(VertexShaderHandle _vsh, FragmentShaderHandle _fsh)
 		{
+			const VertexShaderRef& vsr = m_vertexShaderRef[_vsh.idx];
+			const FragmentShaderRef& fsr = m_fragmentShaderRef[_fsh.idx];
+			if (vsr.m_outputHash != fsr.m_inputHash)
+			{
+				BX_WARN(vsr.m_outputHash == fsr.m_inputHash, "Vertex shader output doesn't match fragment shader input.");
+				ProgramHandle invalid = BGFX_INVALID_HANDLE;
+				return invalid;
+			}
+
 			ProgramHandle handle;
  			handle.idx = m_programHandle.alloc();
 
@@ -2859,8 +2791,19 @@ namespace bgfx
 		HandleAlloc m_renderTargetHandle;
 		HandleAlloc m_uniformHandle;
 
-		int32_t m_vertexShaderRef[BGFX_CONFIG_MAX_VERTEX_SHADERS];
-		int32_t m_fragmentShaderRef[BGFX_CONFIG_MAX_FRAGMENT_SHADERS];
+		struct VertexShaderRef
+		{
+			int32_t m_refCount;
+			uint32_t m_outputHash;
+		} m_vertexShaderRef[BGFX_CONFIG_MAX_VERTEX_SHADERS];
+
+		struct FragmentShaderRef
+		{
+			int32_t m_refCount;
+			uint32_t m_inputHash;
+
+		} m_fragmentShaderRef[BGFX_CONFIG_MAX_FRAGMENT_SHADERS];
+
 		struct ProgramRef
 		{
 			VertexShaderHandle m_vsh;
diff --git a/src/config.h b/src/config.h
index 8a632f36..5ff0769c 100644
--- a/src/config.h
+++ b/src/config.h
@@ -85,14 +85,21 @@
 #	define BGFX_CONFIG_DEBUG_PERFHUD 0
 #endif // BGFX_CONFIG_DEBUG_NVPERFHUD
 
+/// DX9 PIX markers
 #ifndef BGFX_CONFIG_DEBUG_PIX
 #	define BGFX_CONFIG_DEBUG_PIX 0
 #endif // BGFX_CONFIG_DEBUG_PIX
 
+/// AMD gDEBugger markers
 #ifndef BGFX_CONFIG_DEBUG_GREMEDY
 #	define BGFX_CONFIG_DEBUG_GREMEDY 0
 #endif // BGFX_CONFIG_DEBUG_GREMEDY
 
+/// DX11 object names
+#ifndef BGFX_CONFIG_DEBUG_OBJECT_NAME
+#	define BGFX_CONFIG_DEBUG_OBJECT_NAME BGFX_CONFIG_DEBUG
+#endif // BGFX_CONFIG_DEBUG_OBJECT_NAME
+
 #ifndef BGFX_CONFIG_MULTITHREADED
 #	define BGFX_CONFIG_MULTITHREADED ( (BX_PLATFORM_WINDOWS|BX_PLATFORM_XBOX360|BX_PLATFORM_NACL)&(!BGFX_CONFIG_RENDERER_NULL) )
 #endif // BGFX_CONFIG_MULTITHREADED
diff --git a/src/dds.cpp b/src/dds.cpp
index dd6a7b7a..316c621b 100644
--- a/src/dds.cpp
+++ b/src/dds.cpp
@@ -9,15 +9,15 @@
 namespace bgfx
 {
 
-#define DDS_MAGIC MAKEFOURCC('D','D','S',' ')
+#define DDS_MAGIC BX_MAKEFOURCC('D','D','S',' ')
 #define DDS_HEADER_SIZE 124
 #define DDS_IMAGE_DATA_OFFSET (DDS_HEADER_SIZE + 4)
 
-#define DDS_DXT1 MAKEFOURCC('D', 'X', 'T', '1')
-#define DDS_DXT2 MAKEFOURCC('D', 'X', 'T', '2')
-#define DDS_DXT3 MAKEFOURCC('D', 'X', 'T', '3')
-#define DDS_DXT4 MAKEFOURCC('D', 'X', 'T', '4')
-#define DDS_DXT5 MAKEFOURCC('D', 'X', 'T', '5')
+#define DDS_DXT1 BX_MAKEFOURCC('D', 'X', 'T', '1')
+#define DDS_DXT2 BX_MAKEFOURCC('D', 'X', 'T', '2')
+#define DDS_DXT3 BX_MAKEFOURCC('D', 'X', 'T', '3')
+#define DDS_DXT4 BX_MAKEFOURCC('D', 'X', 'T', '4')
+#define DDS_DXT5 BX_MAKEFOURCC('D', 'X', 'T', '5')
 
 #define D3DFMT_A16B16G16R16F 113
 
@@ -58,10 +58,10 @@ namespace bgfx
 
 bool isDds(const Memory* _mem)
 {
-	StreamRead stream(_mem->data, _mem->size);
+	bx::MemoryReader reader(_mem->data, _mem->size);
 
 	uint32_t magic;
-	stream.read(magic);
+	bx::read(&reader, magic);
 
 	return DDS_MAGIC == magic;
 }
@@ -294,11 +294,11 @@ void Mip::decode(uint8_t* _dst)
 		uint32_t width = m_width;
 		uint32_t height = m_height;
 
-		if (m_bpp == 1
-		||  m_bpp == 4
-		||  m_bpp == 8)
+		if (m_bpp == 8
+		||  m_bpp == 32
+		||  m_bpp == 64)
 		{
-			uint32_t pitch = m_width*m_bpp;
+			uint32_t pitch = m_width*m_bpp/8;
 			memcpy(_dst, src, pitch*height);
 		}
 		else
@@ -322,10 +322,10 @@ void Mip::decode(uint8_t* _dst)
 
 bool parseDds(Dds& _dds, const Memory* _mem)
 {
-	StreamRead stream(_mem->data, _mem->size);
+	bx::MemoryReader reader(_mem->data, _mem->size);
 
 	uint32_t magic;
-	stream.read(magic);
+	bx::read(&reader, magic);
 
 	if (DDS_MAGIC != magic)
 	{
@@ -333,7 +333,7 @@ bool parseDds(Dds& _dds, const Memory* _mem)
 	}
 
 	uint32_t headerSize;
-	stream.read(headerSize);
+	bx::read(&reader, headerSize);
 
 	if (headerSize < DDS_HEADER_SIZE)
 	{
@@ -341,7 +341,7 @@ bool parseDds(Dds& _dds, const Memory* _mem)
 	}
 
 	uint32_t flags;
-	stream.read(flags);
+	bx::read(&reader, flags);
 
 	if ( (flags & (DDSD_CAPS|DDSD_HEIGHT|DDSD_WIDTH|DDSD_PIXELFORMAT) ) != (DDSD_CAPS|DDSD_HEIGHT|DDSD_WIDTH|DDSD_PIXELFORMAT) )
 	{
@@ -349,47 +349,46 @@ bool parseDds(Dds& _dds, const Memory* _mem)
 	}
 
 	uint32_t height;
-	stream.read(height);
+	bx::read(&reader, height);
 
 	uint32_t width;
-	stream.read(width);
+	bx::read(&reader, width);
 
 	uint32_t pitch;
-	stream.read(pitch);
+	bx::read(&reader, pitch);
 
 	uint32_t depth;
-	stream.read(depth);
+	bx::read(&reader, depth);
 
 	uint32_t mips;
-	stream.read(mips);
+	bx::read(&reader, mips);
 
-	stream.skip(44); // reserved
-
-	stream.skip(4); // pixel format size
+	bx::skip(&reader, 44); // reserved
+	bx::skip(&reader, 4); // pixel format size
 
 	uint32_t pixelFlags;
-	stream.read(pixelFlags);
+	bx::read(&reader, pixelFlags);
 
 	uint32_t fourcc;
-	stream.read(fourcc);
+	bx::read(&reader, fourcc);
 
 	uint32_t rgbCount;
-	stream.read(rgbCount);
+	bx::read(&reader, rgbCount);
 
 	uint32_t rbitmask;
-	stream.read(rbitmask);
+	bx::read(&reader, rbitmask);
 
 	uint32_t gbitmask;
-	stream.read(gbitmask);
+	bx::read(&reader, gbitmask);
 
 	uint32_t bbitmask;
-	stream.read(bbitmask);
+	bx::read(&reader, bbitmask);
 
 	uint32_t abitmask;
-	stream.read(abitmask);
+	bx::read(&reader, abitmask);
 
 	uint32_t caps[4];
-	stream.read(caps);
+	bx::read(&reader, caps);
 
 	if ( (caps[0] & DDSCAPS_TEXTURE) == 0)
 	{
@@ -406,9 +405,9 @@ bool parseDds(Dds& _dds, const Memory* _mem)
 		}
 	}
 
-	stream.skip(4); // reserved
+	bx::skip(&reader, 4); // reserved
 
-	uint8_t bpp = 1;
+	uint8_t bpp = 0;
 	uint8_t blockSize = 1;
 	TextureFormat::Enum type = TextureFormat::Unknown;
 	bool hasAlpha = pixelFlags & DDPF_ALPHAPIXELS;
@@ -420,24 +419,27 @@ bool parseDds(Dds& _dds, const Memory* _mem)
 		case DDS_DXT1:
 			type = TextureFormat::Dxt1;
 			blockSize = 8;
+			bpp = 4;
 			break;
 
 		case DDS_DXT2:
 		case DDS_DXT3:
 			type = TextureFormat::Dxt3;
 			blockSize = 16;
+			bpp = 4;
 			break;
 
 		case DDS_DXT4:
 		case DDS_DXT5:
 			type = TextureFormat::Dxt5;
 			blockSize = 16;
+			bpp = 4;
 			break;
 
 		case D3DFMT_A16B16G16R16F:
 			type = TextureFormat::ABGR16;
 			blockSize = 8;
-			bpp = 8;
+			bpp = 64;
 			break;
 		}
 	}
@@ -448,20 +450,20 @@ bool parseDds(Dds& _dds, const Memory* _mem)
 		case DDPF_RGB:
 			type = TextureFormat::XRGB8;
 			blockSize = 3;
-			bpp = 3;
+			bpp = 24;
 			break;
 
 		case DDPF_RGB|DDPF_ALPHAPIXELS:
 			type = TextureFormat::ARGB8;
 			blockSize = 4;
-			bpp = 4;
+			bpp = 32;
 			break;
 
 		case DDPF_INDEXED:
 		case DDPF_LUMINANCE:
 		case DDPF_ALPHA:
 			type = TextureFormat::L8;
-			bpp = 1;
+			bpp = 8;
 			break;
 
 // 			type = TextureFormat::A8;
diff --git a/src/fs_clear_dx11.bin.h b/src/fs_clear_dx11.bin.h
index 47959dbf..4423a3c8 100644
--- a/src/fs_clear_dx11.bin.h
+++ b/src/fs_clear_dx11.bin.h
@@ -1,38 +1,39 @@
-static const uint8_t fs_clear_dx11[554] =
+static const uint8_t fs_clear_dx11[562] =
 {
-	0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
-	0x00, 0x00, 0x00, 0x14, 0x02, 0x44, 0x58, 0x42, 0x43, 0xda, 0x0f, 0xc3, 0x91, 0x70, 0x6f, 0xd4, // .....DXBC....po.
-	0x7b, 0xeb, 0xe0, 0x21, 0x07, 0x79, 0xd8, 0x54, 0xd4, 0x01, 0x00, 0x00, 0x00, 0x14, 0x02, 0x00, // {..!.y.T........
-	0x00, 0x05, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0xac, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, // .....4..........
-	0x00, 0x34, 0x01, 0x00, 0x00, 0x78, 0x01, 0x00, 0x00, 0x52, 0x44, 0x45, 0x46, 0x70, 0x00, 0x00, // .4...x...RDEFp..
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, // .............<..
-	0x00, 0x00, 0x05, 0xff, 0xff, 0x00, 0x91, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x52, 0x44, 0x31, // .........<...RD1
-	0x31, 0x3c, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, // 1<....... ...(..
-	0x00, 0x24, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4d, 0x69, 0x63, // .$...........Mic
-	0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, // rosoft (R) HLSL 
-	0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, // Shader Compiler 
-	0x39, 0x2e, 0x32, 0x39, 0x2e, 0x39, 0x35, 0x32, 0x2e, 0x33, 0x31, 0x31, 0x31, 0x00, 0xab, 0xab, // 9.29.952.3111...
-	0xab, 0x49, 0x53, 0x47, 0x4e, 0x4c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, // .ISGNL..........
-	0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, // .8..............
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .........D......
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x00, // ................
-	0x00, 0x53, 0x56, 0x5f, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x00, 0x43, 0x4f, 0x4c, // .SV_POSITION.COL
-	0x4f, 0x52, 0x00, 0xab, 0xab, 0x4f, 0x53, 0x47, 0x4e, 0x2c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, // OR...OSGN,......
-	0x00, 0x08, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ..... ..........
-	0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x53, 0x56, 0x5f, // .............SV_
-	0x54, 0x41, 0x52, 0x47, 0x45, 0x54, 0x00, 0xab, 0xab, 0x53, 0x48, 0x45, 0x58, 0x3c, 0x00, 0x00, // TARGET...SHEX<..
-	0x00, 0x50, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x6a, 0x08, 0x00, 0x01, 0x62, 0x10, 0x00, // .P.......j...b..
-	0x03, 0xf2, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x03, 0xf2, 0x20, 0x10, // .........e.... .
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0xf2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, // .....6.... .....
-	0x00, 0x46, 0x1e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x01, 0x53, 0x54, 0x41, // .F.......>...STA
-	0x54, 0x94, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // T...............
-	0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
-	0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
+	0x46, 0x53, 0x48, 0x00, 0xa4, 0x8b, 0xef, 0x49, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, // FSH....I........
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x02, 0x44, 0x58, 0x42, // .............DXB
+	0x43, 0xda, 0x0f, 0xc3, 0x91, 0x70, 0x6f, 0xd4, 0x7b, 0xeb, 0xe0, 0x21, 0x07, 0x79, 0xd8, 0x54, // C....po.{..!.y.T
+	0xd4, 0x01, 0x00, 0x00, 0x00, 0x14, 0x02, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, // .............4..
+	0x00, 0xac, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x34, 0x01, 0x00, 0x00, 0x78, 0x01, 0x00, // .........4...x..
+	0x00, 0x52, 0x44, 0x45, 0x46, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .RDEFp..........
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x05, 0xff, 0xff, 0x00, 0x91, 0x00, // .....<..........
+	0x00, 0x3c, 0x00, 0x00, 0x00, 0x52, 0x44, 0x31, 0x31, 0x3c, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, // .<...RD11<......
+	0x00, 0x20, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, // . ...(...$......
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x4d, 0x69, 0x63, 0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x20, 0x28, // .....Microsoft (
+	0x52, 0x29, 0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x20, 0x43, // R) HLSL Shader C
+	0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x39, 0x2e, 0x32, 0x39, 0x2e, 0x39, 0x35, 0x32, // ompiler 9.29.952
+	0x2e, 0x33, 0x31, 0x31, 0x31, 0x00, 0xab, 0xab, 0xab, 0x49, 0x53, 0x47, 0x4e, 0x4c, 0x00, 0x00, // .3111....ISGNL..
+	0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .........8......
+	0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, // ................
+	0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, // .D..............
+	0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x00, 0x00, 0x53, 0x56, 0x5f, 0x50, 0x4f, 0x53, 0x49, // .........SV_POSI
+	0x54, 0x49, 0x4f, 0x4e, 0x00, 0x43, 0x4f, 0x4c, 0x4f, 0x52, 0x00, 0xab, 0xab, 0x4f, 0x53, 0x47, // TION.COLOR...OSG
+	0x4e, 0x2c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, // N,........... ..
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
+	0x00, 0x0f, 0x00, 0x00, 0x00, 0x53, 0x56, 0x5f, 0x54, 0x41, 0x52, 0x47, 0x45, 0x54, 0x00, 0xab, // .....SV_TARGET..
+	0xab, 0x53, 0x48, 0x45, 0x58, 0x3c, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, // .SHEX<...P......
+	0x00, 0x6a, 0x08, 0x00, 0x01, 0x62, 0x10, 0x00, 0x03, 0xf2, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, // .j...b..........
+	0x00, 0x65, 0x00, 0x00, 0x03, 0xf2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, // .e.... ......6..
+	0x05, 0xf2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x1e, 0x10, 0x00, 0x01, 0x00, 0x00, // .. ......F......
+	0x00, 0x3e, 0x00, 0x00, 0x01, 0x53, 0x54, 0x41, 0x54, 0x94, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, // .>...STAT.......
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
-	0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,                                     // ..........
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
+	0x00, 0x00,                                                                                     // ..
 };
diff --git a/src/fs_debugfont_dx11.bin.h b/src/fs_debugfont_dx11.bin.h
index aa93167a..fcc54a45 100644
--- a/src/fs_debugfont_dx11.bin.h
+++ b/src/fs_debugfont_dx11.bin.h
@@ -1,61 +1,62 @@
-static const uint8_t fs_debugfont_dx11[922] =
+static const uint8_t fs_debugfont_dx11[930] =
 {
-	0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
-	0x00, 0x00, 0x00, 0x84, 0x03, 0x44, 0x58, 0x42, 0x43, 0x7f, 0x04, 0x32, 0xab, 0xf6, 0xa8, 0x90, // .....DXBC..2....
-	0xe5, 0x2c, 0xd4, 0x3b, 0xd7, 0xa9, 0x89, 0x79, 0xfd, 0x01, 0x00, 0x00, 0x00, 0x84, 0x03, 0x00, // .,.;...y........
-	0x00, 0x05, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x10, 0x01, 0x00, 0x00, 0x9c, 0x01, 0x00, // .....4..........
-	0x00, 0xd0, 0x01, 0x00, 0x00, 0xe8, 0x02, 0x00, 0x00, 0x52, 0x44, 0x45, 0x46, 0xd4, 0x00, 0x00, // .........RDEF...
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, // .............<..
-	0x00, 0x00, 0x05, 0xff, 0xff, 0x00, 0x91, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x52, 0x44, 0x31, // .............RD1
-	0x31, 0x3c, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, // 1<....... ...(..
-	0x00, 0x24, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, // .$...........|..
-	0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x8e, 0x00, 0x00, // ................
-	0x00, 0x02, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, // ................
-	0xff, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x75, 0x5f, 0x74, // .............u_t
-	0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x00, 0x75, // exColorSampler.u
-	0x5f, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, // _texColorTexture
-	0x00, 0x4d, 0x69, 0x63, 0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48, // .Microsoft (R) H
-	0x4c, 0x53, 0x4c, 0x20, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, // LSL Shader Compi
-	0x6c, 0x65, 0x72, 0x20, 0x39, 0x2e, 0x32, 0x39, 0x2e, 0x39, 0x35, 0x32, 0x2e, 0x33, 0x31, 0x31, // ler 9.29.952.311
-	0x31, 0x00, 0xab, 0xab, 0xab, 0x49, 0x53, 0x47, 0x4e, 0x84, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, // 1....ISGN.......
-	0x00, 0x08, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, // .....h..........
-	0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, // .............t..
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, // ................
-	0x00, 0x0f, 0x0f, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .....t..........
-	0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x00, 0x00, 0x7a, 0x00, 0x00, // .............z..
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, // ................
-	0x00, 0x03, 0x03, 0x00, 0x00, 0x53, 0x56, 0x5f, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x49, 0x4f, 0x4e, // .....SV_POSITION
-	0x00, 0x43, 0x4f, 0x4c, 0x4f, 0x52, 0x00, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x00, // .COLOR.TEXCOORD.
-	0xab, 0x4f, 0x53, 0x47, 0x4e, 0x2c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, // .OSGN,..........
-	0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, // . ..............
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x53, 0x56, 0x5f, 0x54, 0x41, 0x52, 0x47, // .........SV_TARG
-	0x45, 0x54, 0x00, 0xab, 0xab, 0x53, 0x48, 0x45, 0x58, 0x10, 0x01, 0x00, 0x00, 0x50, 0x00, 0x00, // ET...SHEX....P..
-	0x00, 0x44, 0x00, 0x00, 0x00, 0x6a, 0x08, 0x00, 0x01, 0x5a, 0x00, 0x00, 0x03, 0x00, 0x60, 0x10, // .D...j...Z....`.
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x58, 0x18, 0x00, 0x04, 0x00, 0x70, 0x10, 0x00, 0x00, 0x00, 0x00, // .....X....p.....
-	0x00, 0x55, 0x55, 0x00, 0x00, 0x62, 0x10, 0x00, 0x03, 0xf2, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, // .UU..b..........
-	0x00, 0x62, 0x10, 0x00, 0x03, 0xf2, 0x10, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x62, 0x10, 0x00, // .b...........b..
-	0x03, 0x32, 0x10, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x03, 0xf2, 0x20, 0x10, // .2.......e.... .
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, // .....h.......E..
-	0x8b, 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0x12, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, // .....CU.........
-	0x00, 0x46, 0x10, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, // .F.......F~.....
-	0x00, 0x00, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xf2, 0x00, 0x10, // ..`.............
-	0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x1e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x1e, 0x10, // .....F.......F..
-	0x80, 0x41, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xf2, 0x00, 0x10, // .A.......2......
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, // .............F..
-	0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x1e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, // .....F.......1..
-	0x07, 0x12, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, // .........:......
-	0x00, 0x01, 0x40, 0x00, 0x00, 0x81, 0x80, 0x80, 0x3b, 0x0d, 0x00, 0x04, 0x03, 0x0a, 0x00, 0x10, // ..@.....;.......
-	0x00, 0x01, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0xf2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, // .....6.... .....
-	0x00, 0x46, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x01, 0x53, 0x54, 0x41, // .F.......>...STA
-	0x54, 0x94, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // T...............
-	0x00, 0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
-	0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
+	0x46, 0x53, 0x48, 0x00, 0xb8, 0xbe, 0x22, 0x66, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, // FSH..."f........
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x84, 0x03, 0x44, 0x58, 0x42, // .............DXB
+	0x43, 0x7f, 0x04, 0x32, 0xab, 0xf6, 0xa8, 0x90, 0xe5, 0x2c, 0xd4, 0x3b, 0xd7, 0xa9, 0x89, 0x79, // C..2.....,.;...y
+	0xfd, 0x01, 0x00, 0x00, 0x00, 0x84, 0x03, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, // .............4..
+	0x00, 0x10, 0x01, 0x00, 0x00, 0x9c, 0x01, 0x00, 0x00, 0xd0, 0x01, 0x00, 0x00, 0xe8, 0x02, 0x00, // ................
+	0x00, 0x52, 0x44, 0x45, 0x46, 0xd4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .RDEF...........
+	0x00, 0x02, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x05, 0xff, 0xff, 0x00, 0x91, 0x00, // .....<..........
+	0x00, 0xa0, 0x00, 0x00, 0x00, 0x52, 0x44, 0x31, 0x31, 0x3c, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, // .....RD11<......
+	0x00, 0x20, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, // . ...(...$......
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .....|..........
 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, // ................
+	0x00, 0x01, 0x00, 0x00, 0x00, 0x8e, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, // ................
+	0x00, 0x04, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, // ................
+	0x00, 0x0d, 0x00, 0x00, 0x00, 0x75, 0x5f, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x53, // .....u_texColorS
+	0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x00, 0x75, 0x5f, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, // ampler.u_texColo
+	0x72, 0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x00, 0x4d, 0x69, 0x63, 0x72, 0x6f, 0x73, 0x6f, // rTexture.Microso
+	0x66, 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, 0x53, 0x68, 0x61, 0x64, // ft (R) HLSL Shad
+	0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x39, 0x2e, 0x32, 0x39, // er Compiler 9.29
+	0x2e, 0x39, 0x35, 0x32, 0x2e, 0x33, 0x31, 0x31, 0x31, 0x00, 0xab, 0xab, 0xab, 0x49, 0x53, 0x47, // .952.3111....ISG
+	0x4e, 0x84, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, // N............h..
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
+	0x00, 0x0f, 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .....t..........
+	0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x00, 0x00, 0x74, 0x00, 0x00, // .............t..
+	0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, // ................
+	0x00, 0x0f, 0x0f, 0x00, 0x00, 0x7a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .....z..........
+	0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x53, 0x56, 0x5f, // .............SV_
+	0x50, 0x4f, 0x53, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x00, 0x43, 0x4f, 0x4c, 0x4f, 0x52, 0x00, 0x54, // POSITION.COLOR.T
+	0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x00, 0xab, 0x4f, 0x53, 0x47, 0x4e, 0x2c, 0x00, 0x00, // EXCOORD..OSGN,..
+	0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ......... ......
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, // ................
+	0x00, 0x53, 0x56, 0x5f, 0x54, 0x41, 0x52, 0x47, 0x45, 0x54, 0x00, 0xab, 0xab, 0x53, 0x48, 0x45, // .SV_TARGET...SHE
+	0x58, 0x10, 0x01, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x6a, 0x08, 0x00, // X....P...D...j..
+	0x01, 0x5a, 0x00, 0x00, 0x03, 0x00, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x58, 0x18, 0x00, // .Z....`......X..
+	0x04, 0x00, 0x70, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0x62, 0x10, 0x00, // ..p......UU..b..
+	0x03, 0xf2, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x62, 0x10, 0x00, 0x03, 0xf2, 0x10, 0x10, // .........b......
+	0x00, 0x02, 0x00, 0x00, 0x00, 0x62, 0x10, 0x00, 0x03, 0x32, 0x10, 0x10, 0x00, 0x03, 0x00, 0x00, // .....b...2......
+	0x00, 0x65, 0x00, 0x00, 0x03, 0xf2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, // .e.... ......h..
+	0x02, 0x02, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, // .....E.......CU.
+	0x00, 0x12, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x10, 0x10, 0x00, 0x03, 0x00, 0x00, // .........F......
+	0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, // .F~.......`.....
+	0x00, 0x00, 0x00, 0x00, 0x08, 0xf2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x1e, 0x10, // .............F..
+	0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x1e, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, // .....F...A......
+	0x00, 0x32, 0x00, 0x00, 0x09, 0xf2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, // .2..............
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x1e, 0x10, // .....F.......F..
+	0x00, 0x02, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x07, 0x12, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, // .....1..........
+	0x00, 0x3a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x81, 0x80, 0x80, // .:........@.....
+	0x3b, 0x0d, 0x00, 0x04, 0x03, 0x0a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, // ;............6..
+	0x05, 0xf2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, // .. ......F......
+	0x00, 0x3e, 0x00, 0x00, 0x01, 0x53, 0x54, 0x41, 0x54, 0x94, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, // .>...STAT.......
+	0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, // ................
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
-	0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,                                     // ..........
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
+	0x00, 0x00,                                                                                     // ..
 };
diff --git a/src/fs_debugfont_dx9.bin.h b/src/fs_debugfont_dx9.bin.h
index d8e642e1..1da618f1 100644
--- a/src/fs_debugfont_dx9.bin.h
+++ b/src/fs_debugfont_dx9.bin.h
@@ -1,25 +1,26 @@
-static const uint8_t fs_debugfont_dx9[345] =
+static const uint8_t fs_debugfont_dx9[353] =
 {
-	0x00, 0x00, 0x54, 0x01, 0x01, 0x02, 0xff, 0xff, 0xfe, 0xff, 0x22, 0x00, 0x43, 0x54, 0x41, 0x42, // ..T.......".CTAB
-	0x1c, 0x00, 0x00, 0x00, 0x53, 0x00, 0x00, 0x00, 0x01, 0x02, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, // ....S...........
-	0x1c, 0x00, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, // ........L...0...
-	0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ........<.......
-	0x75, 0x5f, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0xab, 0x04, 0x00, 0x0c, 0x00, // u_texColor......
-	0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x73, 0x5f, 0x32, // ............ps_2
-	0x5f, 0x61, 0x00, 0x4d, 0x69, 0x63, 0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29, // _a.Microsoft (R)
-	0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, //  HLSL Shader Com
-	0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x39, 0x2e, 0x32, 0x39, 0x2e, 0x39, 0x35, 0x32, 0x2e, 0x33, // piler 9.29.952.3
-	0x31, 0x31, 0x31, 0x00, 0x51, 0x00, 0x00, 0x05, 0x00, 0x00, 0x0f, 0xa0, 0x81, 0x80, 0x80, 0xbb, // 111.Q...........
-	0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x02, // ................
-	0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x0f, 0x90, 0x1f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x80, // ................
-	0x01, 0x00, 0x0f, 0x90, 0x1f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x03, 0xb0, // ................
-	0x1f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x90, 0x00, 0x08, 0x0f, 0xa0, 0x42, 0x00, 0x00, 0x03, // ............B...
-	0x00, 0x00, 0x0f, 0x80, 0x00, 0x00, 0xe4, 0xb0, 0x00, 0x08, 0xe4, 0xa0, 0x01, 0x00, 0x00, 0x02, // ................
-	0x01, 0x00, 0x0f, 0x80, 0x01, 0x00, 0xe4, 0x90, 0x02, 0x00, 0x00, 0x03, 0x01, 0x00, 0x0f, 0x80, // ................
-	0x01, 0x00, 0xe4, 0x81, 0x00, 0x00, 0xe4, 0x90, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x0f, 0x80, // ................
-	0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0xe4, 0x80, 0x01, 0x00, 0xe4, 0x90, 0x02, 0x00, 0x00, 0x03, // ................
-	0x01, 0x00, 0x01, 0x80, 0x00, 0x00, 0xff, 0x80, 0x00, 0x00, 0x00, 0xa0, 0x58, 0x00, 0x00, 0x04, // ............X...
-	0x01, 0x00, 0x0f, 0x80, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x55, 0xa0, 0x00, 0x00, 0xaa, 0xa0, // ..........U.....
-	0x41, 0x00, 0x00, 0x01, 0x01, 0x00, 0x0f, 0x80, 0x01, 0x00, 0x00, 0x02, 0x00, 0x08, 0x0f, 0x80, // A...............
-	0x00, 0x00, 0xe4, 0x80, 0xff, 0xff, 0x00, 0x00, 0x00,                                           // .........
+	0x46, 0x53, 0x48, 0x00, 0xb8, 0xbe, 0x22, 0x66, 0x00, 0x00, 0x54, 0x01, 0x01, 0x02, 0xff, 0xff, // FSH..."f..T.....
+	0xfe, 0xff, 0x22, 0x00, 0x43, 0x54, 0x41, 0x42, 0x1c, 0x00, 0x00, 0x00, 0x53, 0x00, 0x00, 0x00, // ..".CTAB....S...
+	0x01, 0x02, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, // ................
+	0x4c, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, // L...0...........
+	0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x75, 0x5f, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, // <.......u_texCol
+	0x6f, 0x72, 0x00, 0xab, 0x04, 0x00, 0x0c, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, // or..............
+	0x00, 0x00, 0x00, 0x00, 0x70, 0x73, 0x5f, 0x32, 0x5f, 0x61, 0x00, 0x4d, 0x69, 0x63, 0x72, 0x6f, // ....ps_2_a.Micro
+	0x73, 0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, 0x53, 0x68, // soft (R) HLSL Sh
+	0x61, 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x39, 0x2e, // ader Compiler 9.
+	0x32, 0x39, 0x2e, 0x39, 0x35, 0x32, 0x2e, 0x33, 0x31, 0x31, 0x31, 0x00, 0x51, 0x00, 0x00, 0x05, // 29.952.3111.Q...
+	0x00, 0x00, 0x0f, 0xa0, 0x81, 0x80, 0x80, 0xbb, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x80, 0xbf, // ................
+	0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x0f, 0x90, // ................
+	0x1f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x0f, 0x90, 0x1f, 0x00, 0x00, 0x02, // ................
+	0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x03, 0xb0, 0x1f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x90, // ................
+	0x00, 0x08, 0x0f, 0xa0, 0x42, 0x00, 0x00, 0x03, 0x00, 0x00, 0x0f, 0x80, 0x00, 0x00, 0xe4, 0xb0, // ....B...........
+	0x00, 0x08, 0xe4, 0xa0, 0x01, 0x00, 0x00, 0x02, 0x01, 0x00, 0x0f, 0x80, 0x01, 0x00, 0xe4, 0x90, // ................
+	0x02, 0x00, 0x00, 0x03, 0x01, 0x00, 0x0f, 0x80, 0x01, 0x00, 0xe4, 0x81, 0x00, 0x00, 0xe4, 0x90, // ................
+	0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x0f, 0x80, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0xe4, 0x80, // ................
+	0x01, 0x00, 0xe4, 0x90, 0x02, 0x00, 0x00, 0x03, 0x01, 0x00, 0x01, 0x80, 0x00, 0x00, 0xff, 0x80, // ................
+	0x00, 0x00, 0x00, 0xa0, 0x58, 0x00, 0x00, 0x04, 0x01, 0x00, 0x0f, 0x80, 0x01, 0x00, 0x00, 0x80, // ....X...........
+	0x00, 0x00, 0x55, 0xa0, 0x00, 0x00, 0xaa, 0xa0, 0x41, 0x00, 0x00, 0x01, 0x01, 0x00, 0x0f, 0x80, // ..U.....A.......
+	0x01, 0x00, 0x00, 0x02, 0x00, 0x08, 0x0f, 0x80, 0x00, 0x00, 0xe4, 0x80, 0xff, 0xff, 0x00, 0x00, // ................
+	0x00,                                                                                           // .
 };
diff --git a/src/fs_debugfont_glsl.bin.h b/src/fs_debugfont_glsl.bin.h
index 933d4b9a..32c6cb1b 100644
--- a/src/fs_debugfont_glsl.bin.h
+++ b/src/fs_debugfont_glsl.bin.h
@@ -1,25 +1,26 @@
-static const uint8_t fs_debugfont_glsl[352] =
+static const uint8_t fs_debugfont_glsl[360] =
 {
-	0x23, 0x69, 0x66, 0x64, 0x65, 0x66, 0x20, 0x47, 0x4c, 0x5f, 0x45, 0x53, 0x0a, 0x70, 0x72, 0x65, // #ifdef GL_ES.pre
-	0x63, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x66, 0x6c, 0x6f, // cision highp flo
-	0x61, 0x74, 0x3b, 0x0a, 0x23, 0x65, 0x6e, 0x64, 0x69, 0x66, 0x20, 0x2f, 0x2f, 0x20, 0x47, 0x4c, // at;.#endif // GL
-	0x5f, 0x45, 0x53, 0x0a, 0x0a, 0x75, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x73, 0x61, 0x6d, // _ES..uniform sam
-	0x70, 0x6c, 0x65, 0x72, 0x32, 0x44, 0x20, 0x75, 0x5f, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, // pler2D u_texColo
-	0x72, 0x3b, 0x0a, 0x76, 0x61, 0x72, 0x79, 0x69, 0x6e, 0x67, 0x20, 0x76, 0x65, 0x63, 0x32, 0x20, // r;.varying vec2 
-	0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x3b, 0x0a, 0x76, 0x61, 0x72, // v_texcoord0;.var
-	0x79, 0x69, 0x6e, 0x67, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, // ying vec4 v_colo
-	0x72, 0x31, 0x3b, 0x0a, 0x76, 0x61, 0x72, 0x79, 0x69, 0x6e, 0x67, 0x20, 0x76, 0x65, 0x63, 0x34, // r1;.varying vec4
-	0x20, 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x3b, 0x0a, 0x76, 0x6f, 0x69, 0x64, 0x20, //  v_color0;.void 
-	0x6d, 0x61, 0x69, 0x6e, 0x20, 0x28, 0x29, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x76, 0x65, 0x63, 0x34, // main ().{.  vec4
-	0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, //  tmpvar_1;.  tmp
-	0x76, 0x61, 0x72, 0x5f, 0x31, 0x20, 0x3d, 0x20, 0x6d, 0x69, 0x78, 0x20, 0x28, 0x76, 0x5f, 0x63, // var_1 = mix (v_c
-	0x6f, 0x6c, 0x6f, 0x72, 0x31, 0x2c, 0x20, 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x2c, // olor1, v_color0,
-	0x20, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x32, 0x44, 0x20, 0x28, 0x75, 0x5f, 0x74, 0x65, //  texture2D (u_te
-	0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x2c, 0x20, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, // xColor, v_texcoo
-	0x72, 0x64, 0x30, 0x29, 0x2e, 0x78, 0x78, 0x78, 0x78, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x69, 0x66, // rd0).xxxx);.  if
-	0x20, 0x28, 0x28, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x2e, 0x77, 0x20, 0x3c, 0x20, //  ((tmpvar_1.w < 
-	0x30, 0x2e, 0x30, 0x30, 0x33, 0x39, 0x32, 0x31, 0x35, 0x37, 0x29, 0x29, 0x20, 0x7b, 0x0a, 0x20, // 0.00392157)) {. 
-	0x20, 0x20, 0x20, 0x64, 0x69, 0x73, 0x63, 0x61, 0x72, 0x64, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x3b, //    discard;.  };
-	0x0a, 0x20, 0x20, 0x67, 0x6c, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, // .  gl_FragColor 
-	0x3d, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, 0x00, // = tmpvar_1;.}...
+	0x46, 0x53, 0x48, 0x00, 0xb8, 0xbe, 0x22, 0x66, 0x23, 0x69, 0x66, 0x64, 0x65, 0x66, 0x20, 0x47, // FSH..."f#ifdef G
+	0x4c, 0x5f, 0x45, 0x53, 0x0a, 0x70, 0x72, 0x65, 0x63, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x68, // L_ES.precision h
+	0x69, 0x67, 0x68, 0x70, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x3b, 0x0a, 0x23, 0x65, 0x6e, 0x64, // ighp float;.#end
+	0x69, 0x66, 0x20, 0x2f, 0x2f, 0x20, 0x47, 0x4c, 0x5f, 0x45, 0x53, 0x0a, 0x0a, 0x75, 0x6e, 0x69, // if // GL_ES..uni
+	0x66, 0x6f, 0x72, 0x6d, 0x20, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x32, 0x44, 0x20, 0x75, // form sampler2D u
+	0x5f, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x3b, 0x0a, 0x76, 0x61, 0x72, 0x79, 0x69, // _texColor;.varyi
+	0x6e, 0x67, 0x20, 0x76, 0x65, 0x63, 0x32, 0x20, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, // ng vec2 v_texcoo
+	0x72, 0x64, 0x30, 0x3b, 0x0a, 0x76, 0x61, 0x72, 0x79, 0x69, 0x6e, 0x67, 0x20, 0x76, 0x65, 0x63, // rd0;.varying vec
+	0x34, 0x20, 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x31, 0x3b, 0x0a, 0x76, 0x61, 0x72, 0x79, // 4 v_color1;.vary
+	0x69, 0x6e, 0x67, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, // ing vec4 v_color
+	0x30, 0x3b, 0x0a, 0x76, 0x6f, 0x69, 0x64, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x20, 0x28, 0x29, 0x0a, // 0;.void main ().
+	0x7b, 0x0a, 0x20, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, // {.  vec4 tmpvar_
+	0x31, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x20, 0x3d, 0x20, // 1;.  tmpvar_1 = 
+	0x6d, 0x69, 0x78, 0x20, 0x28, 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x31, 0x2c, 0x20, 0x76, // mix (v_color1, v
+	0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x2c, 0x20, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, // _color0, texture
+	0x32, 0x44, 0x20, 0x28, 0x75, 0x5f, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x2c, 0x20, // 2D (u_texColor, 
+	0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x29, 0x2e, 0x78, 0x78, 0x78, // v_texcoord0).xxx
+	0x78, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x28, 0x74, 0x6d, 0x70, 0x76, 0x61, // x);.  if ((tmpva
+	0x72, 0x5f, 0x31, 0x2e, 0x77, 0x20, 0x3c, 0x20, 0x30, 0x2e, 0x30, 0x30, 0x33, 0x39, 0x32, 0x31, // r_1.w < 0.003921
+	0x35, 0x37, 0x29, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x64, 0x69, 0x73, 0x63, 0x61, // 57)) {.    disca
+	0x72, 0x64, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x20, 0x20, 0x67, 0x6c, 0x5f, 0x46, 0x72, // rd;.  };.  gl_Fr
+	0x61, 0x67, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, // agColor = tmpvar
+	0x5f, 0x31, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, 0x00,                                                 // _1;.}...
 };
diff --git a/src/glimports.h b/src/glimports.h
index d9620941..7dd5616b 100644
--- a/src/glimports.h
+++ b/src/glimports.h
@@ -30,6 +30,7 @@ GL_IMPORT(false, PFNGLGETINTEGERVPROC,                    glGetIntegerv);
 GL_IMPORT(false, PFNGLGETSTRINGPROC,                      glGetString);
 GL_IMPORT(false, PFNGLDRAWARRAYSPROC,                     glDrawArrays);
 GL_IMPORT(false, PFNGLBLENDFUNCPROC,                      glBlendFunc);
+GL_IMPORT(false, PFNGLBLENDEQUATIONPROC,                  glBlendEquation);
 GL_IMPORT(false, PFNGLPOINTSIZEPROC,                      glPointSize);
 GL_IMPORT(false, PFNGLCULLFACEPROC,                       glCullFace);
 GL_IMPORT(false, PFNGLCLEARPROC,                          glClear);
@@ -46,7 +47,9 @@ GL_IMPORT(false, PFNGLSTENCILOPPROC,                      glStencilOp);
 
 GL_IMPORT(false, PFNGLACTIVETEXTUREPROC,                  glActiveTexture);
 GL_IMPORT(false, PFNGLCOMPRESSEDTEXIMAGE2DPROC,           glCompressedTexImage2D);
+GL_IMPORT(false, PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC,        glCompressedTexSubImage2D);
 GL_IMPORT(false, PFNGLCOMPRESSEDTEXIMAGE3DPROC,           glCompressedTexImage3D);
+GL_IMPORT(false, PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC,        glCompressedTexSubImage3D);
 GL_IMPORT(false, PFNGLBINDBUFFERPROC,                     glBindBuffer);
 GL_IMPORT(false, PFNGLDELETEBUFFERSPROC,                  glDeleteBuffers);
 GL_IMPORT(false, PFNGLGENBUFFERSPROC,                     glGenBuffers);
@@ -131,6 +134,9 @@ GL_IMPORT(true,  PFNGLSTENCILFUNCSEPARATEPROC,            glStencilFuncSeparate)
 GL_IMPORT(true,  PFNGLSTENCILMASKSEPARATEPROC,            glStencilMaskSeparate);
 GL_IMPORT(true,  PFNGLSTENCILOPSEPARATEPROC,              glStencilOpSeparate);
 
+GL_IMPORT(true,  PFNGLBLENDFUNCSEPARATEPROC,              glBlendFuncSeparate);
+GL_IMPORT(true,  PFNGLBLENDEQUATIONSEPARATEPROC,          glBlendEquationSeparate);
+
 #if BGFX_CONFIG_DEBUG_GREMEDY						
 GL_IMPORT(true,  PFNGLSTRINGMARKERGREMEDYPROC,            glStringMarkerGREMEDY);
 GL_IMPORT(true,  PFNGLFRAMETERMINATORGREMEDYPROC,         glFrameTerminatorGREMEDY);
diff --git a/src/renderer_d3d11.cpp b/src/renderer_d3d11.cpp
index 615e917d..b194b33d 100644
--- a/src/renderer_d3d11.cpp
+++ b/src/renderer_d3d11.cpp
@@ -111,17 +111,27 @@ namespace bgfx
 		uint8_t m_bpp;
 	};
 
+#ifndef DXGI_FORMAT_B4G4R4A4_UNORM
+// Win8 only BS
+// https://blogs.msdn.com/b/chuckw/archive/2012/11/14/directx-11-1-and-windows-7.aspx?Redirected=true
+// http://msdn.microsoft.com/en-us/library/windows/desktop/bb173059%28v=vs.85%29.aspx
+#	define DXGI_FORMAT_B4G4R4A4_UNORM DXGI_FORMAT(115)
+#endif // DXGI_FORMAT_B4G4R4A4_UNORM
+
 	static const TextureFormatInfo s_textureFormat[TextureFormat::Count] =
 	{
-		{ DXGI_FORMAT_BC1_UNORM,          1 },
-		{ DXGI_FORMAT_BC2_UNORM,          1 },
-		{ DXGI_FORMAT_BC3_UNORM,          1 },
-		{ DXGI_FORMAT_UNKNOWN,            0 },
-		{ DXGI_FORMAT_R8_UNORM,           1 },
-		{ DXGI_FORMAT_B8G8R8A8_UNORM,     4 },
-		{ DXGI_FORMAT_B8G8R8A8_UNORM,     4 },
-		{ DXGI_FORMAT_R16G16B16A16_FLOAT, 8 },
-		{ DXGI_FORMAT_B5G6R5_UNORM,       2 },
+		{ DXGI_FORMAT_BC1_UNORM,          4  },
+		{ DXGI_FORMAT_BC2_UNORM,          4  },
+		{ DXGI_FORMAT_BC3_UNORM,          4  },
+		{ DXGI_FORMAT_UNKNOWN,            0  },
+		{ DXGI_FORMAT_R8_UNORM,           8  },
+		{ DXGI_FORMAT_B8G8R8A8_UNORM,     32 },
+		{ DXGI_FORMAT_B8G8R8A8_UNORM,     32 },
+		{ DXGI_FORMAT_R16G16B16A16_FLOAT, 64 },
+		{ DXGI_FORMAT_B5G6R5_UNORM,       16 },
+		{ DXGI_FORMAT_B4G4R4A4_UNORM,     16 },
+		{ DXGI_FORMAT_B5G5R5A1_UNORM,     16 },
+		{ DXGI_FORMAT_R10G10B10A2_UNORM,  32 },
 	};
 
 	static const D3D11_INPUT_ELEMENT_DESC s_attrib[Attrib::Count] =
@@ -205,6 +215,11 @@ namespace bgfx
 	struct TextureStage
 	{
 		TextureStage()
+		{
+			clear();
+		}
+
+		void clear()
 		{
 			memset(m_srv, 0, sizeof(m_srv) );
 			memset(m_sampler, 0, sizeof(m_sampler) );
@@ -214,6 +229,23 @@ namespace bgfx
 		ID3D11SamplerState* m_sampler[BGFX_STATE_TEX_COUNT];
 	};
 
+	static const GUID WKPDID_D3DDebugObjectName = { 0x429b8c22, 0x9188, 0x4b0c, { 0x87, 0x42, 0xac, 0xb0, 0xbf, 0x85, 0xc2, 0x00 } };
+
+	template <typename Ty>
+	static BX_NO_INLINE void setDebugObjectName(Ty* _interface, const char* _format, ...)
+	{
+#if BGFX_CONFIG_DEBUG_OBJECT_NAME
+		char temp[2048];
+		va_list argList;
+		va_start(argList, _format);
+		int size = uint32_min(sizeof(temp)-1, vsnprintf(temp, sizeof(temp), _format, argList) );
+		va_end(argList);
+		temp[size] = '\0';
+
+		_interface->SetPrivateData(WKPDID_D3DDebugObjectName, size, temp);
+#endif // BGFX_CONFIG_DEBUG_OBJECT_NAME
+	}
+
 	struct RendererContext
 	{
 		RendererContext()
@@ -372,6 +404,9 @@ namespace bgfx
 			DX_RELEASE(depthStencil, 0);
 
 			m_deviceCtx->OMSetRenderTargets(1, &m_backBufferColor, m_backBufferDepthStencil);
+
+			m_currentColor = m_backBufferColor;
+			m_currentDepthStencil = m_backBufferDepthStencil;
 		}
 
 		void flip()
@@ -460,37 +495,40 @@ namespace bgfx
 			if (_rt.idx == invalidHandle)
 			{
 				m_deviceCtx->OMSetRenderTargets(1, &m_backBufferColor, m_backBufferDepthStencil);
+				
+				m_currentColor = m_backBufferColor;
+				m_currentDepthStencil = m_backBufferDepthStencil;
 			}
 			else
 			{
+				invalidateTextureStage();
+
 				RenderTarget& renderTarget = m_renderTargets[_rt.idx];
-				m_deviceCtx->OMSetRenderTargets(1, &renderTarget.m_rtv, m_backBufferDepthStencil);
+				m_deviceCtx->OMSetRenderTargets(1, &renderTarget.m_rtv, renderTarget.m_dsv);
+
+				m_currentColor = renderTarget.m_rtv;
+				m_currentDepthStencil = renderTarget.m_dsv;
 			}
 		}
 
 		void clear(const Clear& _clear)
 		{
-//			DX_CHECK(s_renderCtx.m_device->SetRenderState(D3DRS_SCISSORTESTENABLE, TRUE) );
-//			DX_CHECK(s_renderCtx.m_device->SetScissorRect(&rc) );
-
-			if (BGFX_CLEAR_COLOR_BIT & _clear.m_flags)
+			if (NULL != m_currentColor
+			&&  BGFX_CLEAR_COLOR_BIT & _clear.m_flags)
 			{
 				uint32_t rgba = _clear.m_rgba;
 				float frgba[4] = { (rgba>>24)/255.0f, ( (rgba>>16)&0xff)/255.0f, ( (rgba>>8)&0xff)/255.0f, (rgba&0xff)/255.0f };
-//				DX_CHECK(s_renderCtx.m_device->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_RED|D3DCOLORWRITEENABLE_GREEN|D3DCOLORWRITEENABLE_BLUE|D3DCOLORWRITEENABLE_ALPHA) );
-				m_deviceCtx->ClearRenderTargetView(m_backBufferColor, frgba);
+				m_deviceCtx->ClearRenderTargetView(m_currentColor, frgba);
 			}
 
-			if ( (BGFX_CLEAR_DEPTH_BIT|BGFX_CLEAR_STENCIL_BIT) & _clear.m_flags)
+			if (NULL != m_currentDepthStencil
+			&& (BGFX_CLEAR_DEPTH_BIT|BGFX_CLEAR_STENCIL_BIT) & _clear.m_flags)
 			{
 				DWORD flags = 0;
 				flags |= (_clear.m_flags & BGFX_CLEAR_DEPTH_BIT) ? D3D11_CLEAR_DEPTH : 0;
 				flags |= (_clear.m_flags & BGFX_CLEAR_STENCIL_BIT) ? D3D11_CLEAR_STENCIL : 0;
-//				DX_CHECK(s_renderCtx.m_device->SetRenderState(D3DRS_ZWRITEENABLE, TRUE) );
-				m_deviceCtx->ClearDepthStencilView(m_backBufferDepthStencil, flags, _clear.m_depth, _clear.m_stencil);
+				m_deviceCtx->ClearDepthStencilView(m_currentDepthStencil, flags, _clear.m_depth, _clear.m_stencil);
 			}
-
-//			DX_CHECK(s_renderCtx.m_device->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE) );
 		}
 
 		void setInputLayout(const VertexDecl& _vertexDecl, const Program& _program, uint8_t _numInstanceData)
@@ -513,7 +551,6 @@ namespace bgfx
 					decl.m_attributes[ii] = attr == 0 ? 0xff : attr == 0xff ? 0 : attr;
 				}
 
-
 				D3D11_INPUT_ELEMENT_DESC* elem = fillVertexDecl(vertexElements, Attrib::Count, decl);
 				ptrdiff_t num = elem-vertexElements;
 
@@ -638,7 +675,7 @@ namespace bgfx
 
 				DX_CHECK(m_device->CreateDepthStencilState(&desc, &dss) );
 
-				m_depthStencilStateCache.add(_state, dss);
+				m_depthStencilStateCache.add(hash, dss);
 			}
 
 			m_deviceCtx->OMSetDepthStencilState(dss, ref);
@@ -661,12 +698,19 @@ namespace bgfx
 			ID3D11RasterizerState* rs = m_rasterizerStateCache.find(_state);
 			if (NULL == rs)
 			{
-				D3D11_RASTERIZER_DESC desc;
-				memset(&desc, 0, sizeof(desc) );
-				desc.FillMode = _wireframe ? D3D11_FILL_WIREFRAME : D3D11_FILL_SOLID;
-
 				uint32_t cull = (_state&BGFX_STATE_CULL_MASK)>>BGFX_STATE_CULL_SHIFT;
+
+				D3D11_RASTERIZER_DESC desc;
+				desc.FillMode = _wireframe ? D3D11_FILL_WIREFRAME : D3D11_FILL_SOLID;
 				desc.CullMode = s_cullMode[cull];
+				desc.FrontCounterClockwise = false;
+				desc.DepthBias = 0;
+				desc.DepthBiasClamp = 0.0f;
+				desc.SlopeScaledDepthBias = 0.0f;
+				desc.DepthClipEnable = false;
+				desc.ScissorEnable = false;
+				desc.MultisampleEnable = false;
+				desc.AntialiasedLineEnable = false;
 
 				DX_CHECK(m_device->CreateRasterizerState(&desc, &rs) );
 
@@ -682,6 +726,12 @@ namespace bgfx
 			m_deviceCtx->PSSetSamplers(0, BGFX_STATE_TEX_COUNT, m_textureStage.m_sampler);
 		}
 
+		void invalidateTextureStage()
+		{
+			m_textureStage.clear();
+			commitTextureStage();
+		}
+
 		void saveScreenShot(Memory* _mem)
 		{
 			ID3D11Texture2D* backBuffer;
@@ -704,7 +754,7 @@ namespace bgfx
 			{
 				if (backBufferDesc.SampleDesc.Count == 1)
 				{
-					m_deviceCtx->CopyResource(texture, backBuffer);
+					m_deviceCtx->CopyResource(texture, backBuffer);
 				}
 				else
 				{
@@ -715,8 +765,8 @@ namespace bgfx
 					if (SUCCEEDED(hr) )
 					{
 						m_deviceCtx->ResolveSubresource(resolve, 0, backBuffer, 0, desc.Format);
-						m_deviceCtx->CopyResource(texture, resolve);
-						DX_RELEASE(resolve, 0);
+						m_deviceCtx->CopyResource(texture, resolve);
+						DX_RELEASE(resolve, 0);
 					}
 				}
 
@@ -737,6 +787,8 @@ namespace bgfx
 		ID3D11DeviceContext* m_deviceCtx;
 		ID3D11RenderTargetView* m_backBufferColor;
 		ID3D11DepthStencilView* m_backBufferDepthStencil;
+		ID3D11RenderTargetView* m_currentColor;
+		ID3D11DepthStencilView* m_currentDepthStencil;
 
 		bool m_wireframe;
 
@@ -1059,25 +1111,28 @@ namespace bgfx
 					uint32_t m_abgr;
 				} * vertex = (Vertex*)m_vb->data;
 
+				const uint32_t abgr = bx::endianSwap(_clear.m_rgba);
+				const float depth = _clear.m_depth;
+
 				vertex->m_x = -1.0f;
 				vertex->m_y = -1.0f;
-				vertex->m_z = _clear.m_depth;
-				vertex->m_abgr = bx::endianSwap(_clear.m_rgba);
+				vertex->m_z = depth;
+				vertex->m_abgr = abgr;
 				vertex++;
 				vertex->m_x =  1.0f;
 				vertex->m_y = -1.0f;
-				vertex->m_z = _clear.m_depth;
-				vertex->m_abgr = bx::endianSwap(_clear.m_rgba);
+				vertex->m_z = depth;
+				vertex->m_abgr = abgr;
 				vertex++;
 				vertex->m_x =  1.0f;
 				vertex->m_y =  1.0f;
-				vertex->m_z = _clear.m_depth;
-				vertex->m_abgr = bx::endianSwap(_clear.m_rgba);
+				vertex->m_z = depth;
+				vertex->m_abgr = abgr;
 				vertex++;
 				vertex->m_x = -1.0f;
 				vertex->m_y =  1.0f;
-				vertex->m_z = _clear.m_depth;
-				vertex->m_abgr = bx::endianSwap(_clear.m_rgba);
+				vertex->m_z = depth;
+				vertex->m_abgr = abgr;
 			}
 
 			s_renderCtx.m_vertexBuffers[m_vb->handle.idx].update(0, 4*m_decl.m_stride, m_vb->data);
@@ -1094,17 +1149,21 @@ namespace bgfx
 
 	void Shader::create(bool _fragment, const Memory* _mem)
 	{
-		m_constantBuffer = ConstantBuffer::create(1024);
+		bx::MemoryReader reader(_mem->data, _mem->size);
 
-		StreamRead stream(_mem->data, _mem->size);
+		uint32_t magic;
+		bx::read(&reader, magic);
 
-		stream.read(m_attrMask, sizeof(m_attrMask) );
+		uint32_t iohash;
+		bx::read(&reader, iohash);
+
+		bx::read(&reader, m_attrMask, sizeof(m_attrMask) );
 
 		uint16_t count;
-		stream.read(count);
+		bx::read(&reader, count);
 
 		uint16_t size;
-		stream.read(size);
+		bx::read(&reader, size);
 
 		if (0 < size)
 		{
@@ -1125,70 +1184,75 @@ namespace bgfx
 
 		uint8_t fragmentBit = _fragment ? BGFX_UNIFORM_FRAGMENTBIT : 0;
 
-		for (uint32_t ii = 0; ii < count; ++ii)
+		if (0 < count)
 		{
-			uint8_t nameSize;
-			stream.read(nameSize);
+			m_constantBuffer = ConstantBuffer::create(1024);
 
-			char name[256];
-			stream.read(&name, nameSize);
-			name[nameSize] = '\0';
-
-			uint8_t type;
-			stream.read(type);
-
-			uint8_t num;
-			stream.read(num);
-
-			uint16_t regIndex;
-			stream.read(regIndex);
-
-			uint16_t regCount;
-			stream.read(regCount);
-
-			const char* kind = "invalid";
-
-			const void* data = NULL;
-			PredefinedUniform::Enum predefined = nameToPredefinedUniformEnum(name);
-			if (PredefinedUniform::Count != predefined)
+			for (uint32_t ii = 0; ii < count; ++ii)
 			{
-				kind = "predefined";
-				m_predefined[m_numPredefined].m_loc = regIndex;
-				m_predefined[m_numPredefined].m_count = regCount;
-				m_predefined[m_numPredefined].m_type = predefined|fragmentBit;
-				m_numPredefined++;
-			}
-			else
-			{
-				const UniformInfo* info = s_renderCtx.m_uniformReg.find(name);
-				UniformBuffer* uniform = info != NULL ? (UniformBuffer*)info->m_data : NULL;
+				uint8_t nameSize;
+				bx::read(&reader, nameSize);
 
-				if (NULL != uniform)
+				char name[256];
+				bx::read(&reader, &name, nameSize);
+				name[nameSize] = '\0';
+
+				uint8_t type;
+				bx::read(&reader, type);
+
+				uint8_t num;
+				bx::read(&reader, num);
+
+				uint16_t regIndex;
+				bx::read(&reader, regIndex);
+
+				uint16_t regCount;
+				bx::read(&reader, regCount);
+
+				const char* kind = "invalid";
+
+				const void* data = NULL;
+				PredefinedUniform::Enum predefined = nameToPredefinedUniformEnum(name);
+				if (PredefinedUniform::Count != predefined)
 				{
-					kind = "user";
-					data = uniform->m_data;
-					m_constantBuffer->writeUniformRef( (UniformType::Enum)(type|fragmentBit), regIndex, data, regCount);
+					kind = "predefined";
+					m_predefined[m_numPredefined].m_loc = regIndex;
+					m_predefined[m_numPredefined].m_count = regCount;
+					m_predefined[m_numPredefined].m_type = predefined|fragmentBit;
+					m_numPredefined++;
 				}
+				else
+				{
+					const UniformInfo* info = s_renderCtx.m_uniformReg.find(name);
+					UniformBuffer* uniform = info != NULL ? (UniformBuffer*)info->m_data : NULL;
+
+					if (NULL != uniform)
+					{
+						kind = "user";
+						data = uniform->m_data;
+						m_constantBuffer->writeUniformRef( (UniformType::Enum)(type|fragmentBit), regIndex, data, regCount);
+					}
+				}
+
+				BX_TRACE("\t%s: %s, type %2d, num %2d, r.index %3d, r.count %2d"
+					, kind
+					, name
+					, type
+					, num
+					, regIndex
+					, regCount
+					);
+				BX_UNUSED(kind);
 			}
 
-			BX_TRACE("\t%s: %s, type %2d, num %2d, r.index %3d, r.count %2d"
-				, kind
-				, name
-				, type
-				, num
-				, regIndex
-				, regCount
-				);
-			BX_UNUSED(kind);
+			m_constantBuffer->finish();
 		}
 
 		uint16_t shaderSize;
-		stream.read(shaderSize);
+		bx::read(&reader, shaderSize);
 
-		m_constantBuffer->finish();
-
-		const DWORD* code = (const DWORD*)stream.getDataPtr();
-		stream.skip(shaderSize);
+		const DWORD* code = (const DWORD*)reader.getDataPtr();
+		bx::skip(&reader, shaderSize);
 
 		if (_fragment)
 		{
@@ -1196,7 +1260,7 @@ namespace bgfx
 		}
 		else
 		{
-			m_hash = hash(code, shaderSize);
+			m_hash = hashMurmur2A(code, shaderSize);
 			m_code = alloc(shaderSize);
 			memcpy(m_code->data, code, shaderSize);
 
@@ -1234,8 +1298,6 @@ namespace bgfx
 
 		if (parseDds(dds, _mem) )
 		{
-			uint8_t bpp = dds.m_bpp;
-
 			bool decompress = false;
 
 			if (dds.m_cubeMap)
@@ -1281,16 +1343,16 @@ namespace bgfx
 						{
 							if (convert)
 							{
-								uint8_t* temp = (uint8_t*)g_realloc(NULL, mip.m_width*bpp*mip.m_height);
+								uint8_t* temp = (uint8_t*)g_realloc(NULL, mip.m_width*bpp*mip.m_height/8);
 								mip.decode(temp);
 
 								srd[kk].pSysMem = temp;
-								srd[kk].SysMemPitch = mip.m_width*bpp;
+								srd[kk].SysMemPitch = mip.m_width*bpp/8;
 							}
 							else
 							{
 								srd[kk].pSysMem = mip.m_data;
-								srd[kk].SysMemPitch = mip.m_width*mip.m_bpp;
+								srd[kk].SysMemPitch = mip.m_width*mip.m_bpp/8;
 							}
 
 							srd[kk].SysMemSlicePitch = mip.m_height*srd[kk].SysMemPitch;
@@ -1320,7 +1382,7 @@ namespace bgfx
 							}
 							else
 							{
-								srd[kk].SysMemPitch = mip.m_width*mip.m_bpp;
+								srd[kk].SysMemPitch = mip.m_width*mip.m_bpp/8;
 								srd[kk].SysMemSlicePitch = mip.m_height*srd[kk].SysMemPitch;
 							}
 
@@ -1407,22 +1469,22 @@ namespace bgfx
 		}
 		else
 		{
-			StreamRead stream(_mem->data, _mem->size);
+			bx::MemoryReader reader(_mem->data, _mem->size);
 
 			uint32_t magic;
-			stream.read(magic);
+			bx::read(&reader, magic);
 
-			if (BGFX_MAGIC == magic)
+			if (BGFX_CHUNK_MAGIC_TEX == magic)
 			{
 				TextureCreate tc;
-				stream.read(tc);
+				bx::read(&reader, tc);
 
 				D3D11_TEXTURE2D_DESC desc;
 				desc.Width = tc.m_width;
 				desc.Height = tc.m_height;
 				desc.MipLevels = tc.m_numMips;
 				desc.ArraySize = 1;
-				desc.Format = s_textureFormat[tc.m_type].m_fmt;
+				desc.Format = s_textureFormat[tc.m_format].m_fmt;
 				desc.SampleDesc.Count = 1;
 				desc.SampleDesc.Quality = 0;
 				desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
@@ -1436,14 +1498,14 @@ namespace bgfx
 					desc.Usage = D3D11_USAGE_IMMUTABLE;
 
 					D3D11_SUBRESOURCE_DATA* srd = (D3D11_SUBRESOURCE_DATA*)alloca(tc.m_numMips*sizeof(D3D11_SUBRESOURCE_DATA) );
-					uint32_t bpp = s_textureFormat[tc.m_type].m_bpp;
+					uint32_t bpp = s_textureFormat[tc.m_format].m_bpp;
 					uint8_t* data = tc.m_mem->data;
 
 					for (uint8_t side = 0, numSides = tc.m_cubeMap ? 6 : 1; side < numSides; ++side)
 					{
 						uint32_t width = tc.m_width;
 						uint32_t height = tc.m_height;
-						uint32_t depth = tc.m_depth;
+						uint32_t depth = tc.m_depth;
 
 						for (uint32_t lod = 0, num = tc.m_numMips; lod < num; ++lod)
 						{
@@ -1452,14 +1514,14 @@ namespace bgfx
 							depth = uint32_max(1, depth);
 
 							srd[lod].pSysMem = data;
-							srd[lod].SysMemPitch = width*bpp;
+							srd[lod].SysMemPitch = width*bpp/8;
 							srd[lod].SysMemSlicePitch = 0;
 
-							data += width*height*bpp;
+							data += width*height*bpp/8;
 
 							width >>= 1;
 							height >>= 1;
-							depth >>= 1;
+							depth >>= 1;
 						}
 					}
 
@@ -1493,16 +1555,16 @@ namespace bgfx
 		s_renderCtx.m_textureStage.m_sampler[_stage] = m_sampler;
 	}
 
-	void Texture::update(uint8_t _side, uint8_t _mip, const Rect& _rect, uint16_t _z, uint16_t _depth, const Memory* _mem)
-	{
+	void Texture::update(uint8_t _side, uint8_t _mip, const Rect& _rect, uint16_t _z, uint16_t _depth, const Memory* _mem)
+	{
 		ID3D11DeviceContext* deviceCtx = s_renderCtx.m_deviceCtx;
 
-		D3D11_BOX box;
-		box.left = _rect.m_x;
-		box.top = _rect.m_y;
-		box.right = box.left + _rect.m_width;
+		D3D11_BOX box;
+		box.left = _rect.m_x;
+		box.top = _rect.m_y;
+		box.right = box.left + _rect.m_width;
 		box.bottom = box.top + _rect.m_height;
-		box.front = _z;
+		box.front = _z;
 		box.back = box.front + _depth;
 
 		uint32_t subres = _mip + (_side * m_numMips);
@@ -1523,7 +1585,7 @@ namespace bgfx
 #else
 		deviceCtx->UpdateSubresource(m_ptr, subres, &box, _mem->data, _rect.m_width, 0); 
 #endif // 0
-	}
+	}
 
 	void RenderTarget::create(uint16_t _width, uint16_t _height, uint32_t _flags, uint32_t _textureFlags)
 	{
@@ -1532,6 +1594,7 @@ namespace bgfx
 		m_flags = _flags;
 
 		uint32_t colorFormat = (m_flags&BGFX_RENDER_TARGET_COLOR_MASK)>>BGFX_RENDER_TARGET_COLOR_SHIFT;
+		uint32_t depthFormat = (m_flags&BGFX_RENDER_TARGET_DEPTH_MASK)>>BGFX_RENDER_TARGET_DEPTH_SHIFT;
 
 		D3D11_TEXTURE2D_DESC desc;
 		desc.Width = _width;
@@ -1550,6 +1613,26 @@ namespace bgfx
 		DX_CHECK(s_renderCtx.m_device->CreateRenderTargetView(m_colorTexture, NULL, &m_rtv) );
 		DX_CHECK(s_renderCtx.m_device->CreateShaderResourceView(m_colorTexture, NULL, &m_srv) );
 
+		if (0 < depthFormat)
+		{
+			D3D11_TEXTURE2D_DESC desc;
+			desc.Width = _width;
+			desc.Height = _height;
+			desc.MipLevels = 1;
+			desc.ArraySize = 1;
+			desc.Format = s_depthFormat[colorFormat];
+			desc.SampleDesc.Count = 1;
+			desc.SampleDesc.Quality = 0;
+			desc.Usage = D3D11_USAGE_DEFAULT;
+			desc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
+			desc.CPUAccessFlags = 0;
+			desc.MiscFlags = 0;
+			
+			DX_CHECK(s_renderCtx.m_device->CreateTexture2D(&desc, NULL, &m_depthTexture) );
+			DX_CHECK(s_renderCtx.m_device->CreateDepthStencilView(m_depthTexture, NULL, &m_dsv) );
+//			DX_CHECK(s_renderCtx.m_device->CreateShaderResourceView(m_depthTexture, NULL, &m_srv) );
+		}
+
 		m_sampler = s_renderCtx.m_samplerStateCache.find(_flags);
 		if (NULL == m_sampler)
 		{
@@ -1578,6 +1661,8 @@ namespace bgfx
 		DX_RELEASE(m_srv, 0);
 		DX_RELEASE(m_rtv, 0);
 		DX_RELEASE(m_colorTexture, 0);
+		DX_RELEASE(m_dsv, 0);
+		DX_RELEASE(m_depthTexture, 0);
 
 		m_flags = 0;
 	}
@@ -1889,8 +1974,7 @@ namespace bgfx
 					s_renderCtx.setDepthStencilState(newFlags, newStencil);
 				}
 
-				if ( (BGFX_STATE_CULL_MASK
-					 |BGFX_STATE_ALPHA_MASK|BGFX_STATE_ALPHA_WRITE|BGFX_STATE_RGB_WRITE
+				if ( (BGFX_STATE_CULL_MASK|BGFX_STATE_ALPHA_MASK|BGFX_STATE_RGB_WRITE
 					 |BGFX_STATE_BLEND_MASK|BGFX_STATE_ALPHA_REF_MASK|BGFX_STATE_PT_MASK
 					 |BGFX_STATE_POINT_SIZE_MASK|BGFX_STATE_SRGBWRITE|BGFX_STATE_MSAA) & changedFlags)
 				{
@@ -1904,6 +1988,12 @@ namespace bgfx
 						s_renderCtx.setRasterizerState(newFlags, wireframe);
 					}
 
+					if ( (BGFX_STATE_ALPHA_TEST|BGFX_STATE_ALPHA_REF_MASK) & changedFlags)
+					{
+						uint32_t ref = (newFlags&BGFX_STATE_ALPHA_REF_MASK)>>BGFX_STATE_ALPHA_REF_SHIFT;
+						alphaRef = ref/255.0f;
+					}
+
 					uint8_t primIndex = uint8_t( (newFlags&BGFX_STATE_PT_MASK)>>BGFX_STATE_PT_SHIFT);
 					if (primType != s_primType[primIndex])
 					{
@@ -1950,8 +2040,7 @@ namespace bgfx
 
 					if (constantsChanged)
 					{
-						program.m_vsh->m_constantBuffer->commit();
-						program.m_fsh->m_constantBuffer->commit();
+						program.commit();
 					}
 
 					for (uint32_t ii = 0, num = program.m_numPredefined; ii < num; ++ii)
diff --git a/src/renderer_d3d11.h b/src/renderer_d3d11.h
index fb23f4df..162eeb78 100644
--- a/src/renderer_d3d11.h
+++ b/src/renderer_d3d11.h
@@ -199,6 +199,19 @@ namespace bgfx
 			m_fsh = NULL;
 		}
 
+		void commit()
+		{
+			if (NULL != m_vsh->m_constantBuffer)
+			{
+				m_vsh->m_constantBuffer->commit();
+			}
+
+			if (NULL != m_fsh->m_constantBuffer)
+			{
+				m_fsh->m_constantBuffer->commit();
+			}
+		}
+
 		const Shader* m_vsh;
 		const Shader* m_fsh;
 
@@ -224,10 +237,6 @@ namespace bgfx
 		{
 		}
 
-// 		void createTexture(uint32_t _width, uint32_t _height, uint8_t _numMips, D3DFORMAT _fmt);
-// 		void createVolumeTexture(uint32_t _width, uint32_t _height, uint32_t _depth, uint32_t _numMips, D3DFORMAT _fmt);
-// 		void createCubeTexture(uint32_t _edge, uint32_t _numMips, D3DFORMAT _fmt);
-
 		void create(const Memory* _mem, uint32_t _flags);
 
 		void destroy()
@@ -236,14 +245,14 @@ namespace bgfx
 			DX_RELEASE(m_ptr, 1);
 		}
 
-		void update(uint8_t _side, uint8_t _mip, const Rect& _rect, uint16_t _z, uint16_t _depth, const Memory* _mem);
+		void update(uint8_t _side, uint8_t _mip, const Rect& _rect, uint16_t _z, uint16_t _depth, const Memory* _mem);
 		void commit(uint8_t _stage);
 
 		union
 		{
 			ID3D11Resource* m_ptr;
 			ID3D11Texture2D* m_texture2d;
-			ID3D11Texture3D* m_texture3d;
+			ID3D11Texture3D* m_texture3d;
 		};
 
 		ID3D11ShaderResourceView* m_srv;
@@ -256,15 +265,14 @@ namespace bgfx
 	struct RenderTarget
 	{
 		RenderTarget()
-			: 
-//		m_rt(NULL)
-// 			, m_colorTexture(NULL)
-// 			, m_color(NULL)
-// 			, m_depthTexture(NULL)
-// 			, m_depth(NULL)
+			: m_colorTexture(NULL)
+ 			, m_depthTexture(NULL)
+			, m_rtv(NULL)
+ 			, m_dsv(NULL)
+			, m_srv(NULL)
 // 			, m_minFilter(D3DTEXF_LINEAR)
 // 			, m_magFilter(D3DTEXF_LINEAR)
-			 m_width(0)
+			, m_width(0)
 			, m_height(0)
 			, m_flags(0)
 			, m_depthOnly(false)
@@ -287,7 +295,9 @@ namespace bgfx
 // 		D3DTEXTUREFILTERTYPE m_magFilter;
 
 		ID3D11Texture2D* m_colorTexture;
+		ID3D11Texture2D* m_depthTexture;
 		ID3D11RenderTargetView* m_rtv;
+		ID3D11DepthStencilView* m_dsv;
 		ID3D11ShaderResourceView* m_srv;
 		ID3D11SamplerState* m_sampler;
 		uint16_t m_width;
diff --git a/src/renderer_d3d9.cpp b/src/renderer_d3d9.cpp
index 5aad557e..30d9e845 100644
--- a/src/renderer_d3d9.cpp
+++ b/src/renderer_d3d9.cpp
@@ -171,15 +171,18 @@ namespace bgfx
 
 	static const TextureFormatInfo s_textureFormat[TextureFormat::Count] =
 	{
-		{ D3DFMT_DXT1,         1 },
-		{ D3DFMT_DXT3,         1 },
-		{ D3DFMT_DXT5,         1 },
-		{ D3DFMT_UNKNOWN,      0 },
-		{ D3DFMT_L8,           1 },
-		{ D3DFMT_X8R8G8B8,     4 },
-		{ D3DFMT_A8R8G8B8,     4 },
-		{ D3DFMT_A16B16G16R16, 8 },
-		{ D3DFMT_R5G6B5,       2 },
+		{ D3DFMT_DXT1,         4  },
+		{ D3DFMT_DXT3,         4  },
+		{ D3DFMT_DXT5,         4  },
+		{ D3DFMT_UNKNOWN,      0  },
+		{ D3DFMT_L8,           8  },
+		{ D3DFMT_X8R8G8B8,     32 },
+		{ D3DFMT_A8R8G8B8,     32 },
+		{ D3DFMT_A16B16G16R16, 64 },
+		{ D3DFMT_R5G6B5,       16 },
+		{ D3DFMT_A4R4G4B4,     16 },
+		{ D3DFMT_A1R5G5B5,     16 },
+		{ D3DFMT_A2B10G10R10,  32 },
 	};
 
 	static ExtendedFormat s_extendedFormats[ExtendedFormat::Count] =
@@ -730,8 +733,8 @@ namespace bgfx
 			point.y = rc.top;
 			ClientToScreen(g_bgfxHwnd, &point);
 			uint8_t* data = (uint8_t*)rect.pBits;
-			uint32_t bpp = rect.Pitch/dm.Width;
-			saveTga( (const char*)_mem->data, m_params.BackBufferWidth, m_params.BackBufferHeight, rect.Pitch, &data[point.y*rect.Pitch+point.x*bpp]);
+			uint32_t bytesPerPixel = rect.Pitch/dm.Width;
+			saveTga( (const char*)_mem->data, m_params.BackBufferWidth, m_params.BackBufferHeight, rect.Pitch, &data[point.y*rect.Pitch+point.x*bytesPerPixel]);
 
 			DX_CHECK(surface->UnlockRect() );
 			DX_RELEASE(surface, 0);
@@ -993,11 +996,16 @@ namespace bgfx
 
 	void Shader::create(bool _fragment, const Memory* _mem)
 	{
-		m_constantBuffer = ConstantBuffer::create(1024);
+		bx::MemoryReader reader(_mem->data, _mem->size);
+
+		uint32_t magic;
+		bx::read(&reader, magic);
+
+		uint32_t iohash;
+		bx::read(&reader, iohash);
 
-		StreamRead stream(_mem->data, _mem->size);
 		uint16_t count;
-		stream.read(count);
+		bx::read(&reader, count);
 
 		m_numPredefined = 0;
 
@@ -1005,76 +1013,83 @@ namespace bgfx
 
 		uint8_t fragmentBit = _fragment ? BGFX_UNIFORM_FRAGMENTBIT : 0;
 
-		for (uint32_t ii = 0; ii < count; ++ii)
+		if (0 < count)
 		{
-			uint8_t nameSize;
-			stream.read(nameSize);
+			m_constantBuffer = ConstantBuffer::create(1024);
 
-			char name[256];
-			stream.read(&name, nameSize);
-			name[nameSize] = '\0';
-
-			uint8_t type;
-			stream.read(type);
-
-			uint8_t num;
-			stream.read(num);
-
-			uint16_t regIndex;
-			stream.read(regIndex);
-
-			uint16_t regCount;
-			stream.read(regCount);
-
-			const char* kind = "invalid";
-
-			const void* data = NULL;
-			PredefinedUniform::Enum predefined = nameToPredefinedUniformEnum(name);
-			if (PredefinedUniform::Count != predefined)
+			for (uint32_t ii = 0; ii < count; ++ii)
 			{
-				kind = "predefined";
-				m_predefined[m_numPredefined].m_loc = regIndex;
-				m_predefined[m_numPredefined].m_count = regCount;
-				m_predefined[m_numPredefined].m_type = predefined|fragmentBit;
-				m_numPredefined++;
-			}
-			else
-			{
-				const UniformInfo* info = s_renderCtx.m_uniformReg.find(name);
-				BX_CHECK(NULL != info, "User defined uniform '%s' is not found, it won't be set.", name);
-				if (NULL != info)
+				uint8_t nameSize;
+				bx::read(&reader, nameSize);
+
+				char name[256];
+				bx::read(&reader, &name, nameSize);
+				name[nameSize] = '\0';
+
+				uint8_t type;
+				bx::read(&reader, type);
+
+				uint8_t num;
+				bx::read(&reader, num);
+
+				uint16_t regIndex;
+				bx::read(&reader, regIndex);
+
+				uint16_t regCount;
+				bx::read(&reader, regCount);
+
+				const char* kind = "invalid";
+
+				const void* data = NULL;
+				PredefinedUniform::Enum predefined = nameToPredefinedUniformEnum(name);
+				if (PredefinedUniform::Count != predefined)
 				{
-					kind = "user";
-					data = info->m_data;
-					m_constantBuffer->writeUniformRef( (UniformType::Enum)(type|fragmentBit), regIndex, data, regCount);
+					kind = "predefined";
+					m_predefined[m_numPredefined].m_loc = regIndex;
+					m_predefined[m_numPredefined].m_count = regCount;
+					m_predefined[m_numPredefined].m_type = predefined|fragmentBit;
+					m_numPredefined++;
 				}
+				else
+				{
+					const UniformInfo* info = s_renderCtx.m_uniformReg.find(name);
+					BX_CHECK(NULL != info, "User defined uniform '%s' is not found, it won't be set.", name);
+					if (NULL != info)
+					{
+						kind = "user";
+						data = info->m_data;
+						m_constantBuffer->writeUniformRef( (UniformType::Enum)(type|fragmentBit), regIndex, data, regCount);
+					}
+				}
+
+				BX_TRACE("\t%s: %s, type %2d, num %2d, r.index %3d, r.count %2d"
+					, kind
+					, name
+					, type
+					, num
+					, regIndex
+					, regCount
+					);
+				BX_UNUSED(kind);
 			}
 
-			BX_TRACE("\t%s: %s, type %2d, num %2d, r.index %3d, r.count %2d"
-				, kind
-				, name
-				, type
-				, num
-				, regIndex
-				, regCount
-				);
-			BX_UNUSED(kind);
+			m_constantBuffer->finish();
 		}
 
 		uint16_t shaderSize;
-		stream.read(shaderSize);
+		bx::read(&reader, shaderSize);
 
-		m_constantBuffer->finish();
-
-		const DWORD* code = (const DWORD*)stream.getDataPtr();
+		const DWORD* code = (const DWORD*)reader.getDataPtr();
 
 		if (_fragment)
 		{
 			DX_CHECK(s_renderCtx.m_device->CreatePixelShader(code, (IDirect3DPixelShader9**)&m_ptr) );
+			BX_CHECK(NULL != m_ptr, "Failed to create fragment shader.");
 		}
 		else
 		{
 			DX_CHECK(s_renderCtx.m_device->CreateVertexShader(code, (IDirect3DVertexShader9**)&m_ptr) );
+			BX_CHECK(NULL != m_ptr, "Failed to create vertex shader.");
 		}
 	}
 
@@ -1234,23 +1249,25 @@ namespace bgfx
 
 		if (parseDds(dds, _mem) )
 		{
-			uint8_t bpp = dds.m_bpp;
+			const TextureFormatInfo& tfi = s_textureFormat[dds.m_type];
 
 			bool decompress = false;
 
 			if (dds.m_cubeMap)
 			{
-				createCubeTexture(dds.m_width, dds.m_numMips, s_textureFormat[dds.m_type].m_fmt);
+				createCubeTexture(dds.m_width, dds.m_numMips, tfi.m_fmt);
 			}
 			else if (dds.m_depth > 1)
 			{
-				createVolumeTexture(dds.m_width, dds.m_height, dds.m_depth, dds.m_numMips, s_textureFormat[dds.m_type].m_fmt);
+				createVolumeTexture(dds.m_width, dds.m_height, dds.m_depth, dds.m_numMips, tfi.m_fmt);
 			}
 			else
 			{
-				createTexture(dds.m_width, dds.m_height, dds.m_numMips, s_textureFormat[dds.m_type].m_fmt);
+				createTexture(dds.m_width, dds.m_height, dds.m_numMips, tfi.m_fmt);
 			}
 
+			uint8_t bpp = tfi.m_bpp;
+
 			if (decompress
 			||  TextureFormat::Unknown < dds.m_type)
 			{
@@ -1276,7 +1293,7 @@ namespace bgfx
 							if (width != mip.m_width
 							||  height != mip.m_height)
 							{
-								uint32_t srcpitch = mip.m_width*bpp;
+								uint32_t srcpitch = mip.m_width*bpp/8;
 
 								uint8_t* temp = (uint8_t*)g_realloc(NULL, srcpitch*mip.m_height);
 								mip.decode(temp);
@@ -1328,32 +1345,32 @@ namespace bgfx
 		}
 		else
 		{
-			StreamRead stream(_mem->data, _mem->size);
+			bx::MemoryReader reader(_mem->data, _mem->size);
 
 			uint32_t magic;
-			stream.read(magic);
+			bx::read(&reader, magic);
 
-			if (BGFX_MAGIC == magic)
+			if (BGFX_CHUNK_MAGIC_TEX == magic)
 			{
 				TextureCreate tc;
-				stream.read(tc);
+				bx::read(&reader, tc);
 
 				if (tc.m_cubeMap)
 				{
-					createCubeTexture(tc.m_width, tc.m_numMips, s_textureFormat[tc.m_type].m_fmt);
+					createCubeTexture(tc.m_width, tc.m_numMips, s_textureFormat[tc.m_format].m_fmt);
 				}
 				else if (tc.m_depth > 1)
 				{
-					createVolumeTexture(tc.m_width, tc.m_height, tc.m_depth, tc.m_numMips, s_textureFormat[tc.m_type].m_fmt);
+					createVolumeTexture(tc.m_width, tc.m_height, tc.m_depth, tc.m_numMips, s_textureFormat[tc.m_format].m_fmt);
 				}
 				else
 				{
-					createTexture(tc.m_width, tc.m_height, tc.m_numMips, s_textureFormat[tc.m_type].m_fmt);
+					createTexture(tc.m_width, tc.m_height, tc.m_numMips, s_textureFormat[tc.m_format].m_fmt);
 				}
 
 				if (NULL != tc.m_mem)
 				{
-					uint32_t bpp = s_textureFormat[tc.m_type].m_bpp;
+					uint32_t bpp = s_textureFormat[tc.m_format].m_bpp;
 					uint8_t* data = tc.m_mem->data;
 
 					for (uint8_t side = 0, numSides = tc.m_cubeMap ? 6 : 1; side < numSides; ++side)
@@ -1371,7 +1388,7 @@ namespace bgfx
 							uint32_t pitch;
 							uint32_t slicePitch;
 							uint8_t* dst = lock(side, lod, pitch, slicePitch);
-							uint32_t len = width*height*bpp;
+							uint32_t len = width*height*bpp/8;
 							memcpy(dst, data, len);
 							data += len;
 							unlock(side, lod);
@@ -1956,7 +1973,6 @@ namespace bgfx
 					PIX_BEGINEVENT(D3DCOLOR_RGBA(0xff, 0x00, 0x00, 0xff), "view");
 
 					view = key.m_view;
-
 					programIdx = invalidHandle;
 
 					if (m_render->m_rt[view].idx != rt.idx)
@@ -2080,9 +2096,9 @@ namespace bgfx
 				}
 
 				if ( (BGFX_STATE_CULL_MASK|BGFX_STATE_DEPTH_WRITE|BGFX_STATE_DEPTH_TEST_MASK
-					 |BGFX_STATE_ALPHA_MASK|BGFX_STATE_ALPHA_WRITE|BGFX_STATE_RGB_WRITE
-					 |BGFX_STATE_BLEND_MASK|BGFX_STATE_ALPHA_REF_MASK|BGFX_STATE_PT_MASK
-					 |BGFX_STATE_POINT_SIZE_MASK|BGFX_STATE_SRGBWRITE|BGFX_STATE_MSAA) & changedFlags)
+					 |BGFX_STATE_ALPHA_MASK|BGFX_STATE_RGB_WRITE|BGFX_STATE_BLEND_MASK
+					 |BGFX_STATE_ALPHA_REF_MASK|BGFX_STATE_PT_MASK|BGFX_STATE_POINT_SIZE_MASK
+					 |BGFX_STATE_SRGBWRITE|BGFX_STATE_MSAA) & changedFlags)
 				{
 					if (BGFX_STATE_CULL_MASK & changedFlags)
 					{
@@ -2192,8 +2208,7 @@ namespace bgfx
 
 					if (constantsChanged)
 					{
-						program.m_vsh->m_constantBuffer->commit();
-						program.m_fsh->m_constantBuffer->commit();
+						program.commit();
 					}
 
 					for (uint32_t ii = 0, num = program.m_numPredefined; ii < num; ++ii)
diff --git a/src/renderer_d3d9.h b/src/renderer_d3d9.h
index 3fc34372..d91a388a 100644
--- a/src/renderer_d3d9.h
+++ b/src/renderer_d3d9.h
@@ -71,43 +71,43 @@ namespace bgfx
 #endif // BGFX_CONFIG_DEBUG_PIX
 
 #	ifndef D3DFMT_ATI1
-#		define D3DFMT_ATI1 ( (D3DFORMAT)MAKEFOURCC('A','T','I','1') )
+#		define D3DFMT_ATI1 ( (D3DFORMAT)BX_MAKEFOURCC('A','T','I','1') )
 #	endif // D3DFMT_ATI1
 
 #	ifndef D3DFMT_ATI2
-#		define D3DFMT_ATI2 ( (D3DFORMAT)MAKEFOURCC('A','T','I','2') )
+#		define D3DFMT_ATI2 ( (D3DFORMAT)BX_MAKEFOURCC('A','T','I','2') )
 #	endif // D3DFMT_ATI2
 
 #	ifndef D3DFMT_ATOC
-#		define D3DFMT_ATOC ( (D3DFORMAT)MAKEFOURCC('A','T','O','C') )
+#		define D3DFMT_ATOC ( (D3DFORMAT)BX_MAKEFOURCC('A','T','O','C') )
 #	endif // D3DFMT_ATOC
 
 #	ifndef D3DFMT_DF16
-#		define D3DFMT_DF16 ( (D3DFORMAT)MAKEFOURCC('D','F','1','6') )
+#		define D3DFMT_DF16 ( (D3DFORMAT)BX_MAKEFOURCC('D','F','1','6') )
 #	endif // D3DFMT_DF16
 
 #	ifndef D3DFMT_DF24
-#		define D3DFMT_DF24 ( (D3DFORMAT)MAKEFOURCC('D','F','2','4') )
+#		define D3DFMT_DF24 ( (D3DFORMAT)BX_MAKEFOURCC('D','F','2','4') )
 #	endif // D3DFMT_DF24
 
 #	ifndef D3DFMT_INST
-#		define D3DFMT_INST ( (D3DFORMAT)MAKEFOURCC('I','N','S','T') )
+#		define D3DFMT_INST ( (D3DFORMAT)BX_MAKEFOURCC('I','N','S','T') )
 #	endif // D3DFMT_INST
 
 #	ifndef D3DFMT_INTZ
-#		define D3DFMT_INTZ ( (D3DFORMAT)MAKEFOURCC('I','N','T','Z') )
+#		define D3DFMT_INTZ ( (D3DFORMAT)BX_MAKEFOURCC('I','N','T','Z') )
 #	endif // D3DFMT_INTZ
 
 #	ifndef D3DFMT_NULL
-#		define D3DFMT_NULL ( (D3DFORMAT)MAKEFOURCC('N','U','L','L') )
+#		define D3DFMT_NULL ( (D3DFORMAT)BX_MAKEFOURCC('N','U','L','L') )
 #	endif // D3DFMT_NULL
 
 #	ifndef D3DFMT_RESZ
-#		define D3DFMT_RESZ ( (D3DFORMAT)MAKEFOURCC('R','E','S','Z') )
+#		define D3DFMT_RESZ ( (D3DFORMAT)BX_MAKEFOURCC('R','E','S','Z') )
 #	endif // D3DFMT_RESZ
 
 #	ifndef D3DFMT_RAWZ
-#		define D3DFMT_RAWZ ( (D3DFORMAT)MAKEFOURCC('R','A','W','Z') )
+#		define D3DFMT_RAWZ ( (D3DFORMAT)BX_MAKEFOURCC('R','A','W','Z') )
 #	endif // D3DFMT_RAWZ
 
 	struct ExtendedFormat
@@ -280,6 +280,19 @@ namespace bgfx
 			m_fsh = NULL;
 		}
 
+		void commit()
+		{
+			if (NULL != m_vsh->m_constantBuffer)
+			{
+				m_vsh->m_constantBuffer->commit();
+			}
+
+			if (NULL != m_fsh->m_constantBuffer)
+			{
+				m_fsh->m_constantBuffer->commit();
+			}
+		}
+
 		const Shader* m_vsh;
 		const Shader* m_fsh;
 
diff --git a/src/renderer_gl.cpp b/src/renderer_gl.cpp
index 47397cb4..408e9aa4 100644
--- a/src/renderer_gl.cpp
+++ b/src/renderer_gl.cpp
@@ -19,6 +19,9 @@
 #	define glGetProgramBinary glGetProgramBinaryOES
 #	define GL_PROGRAM_BINARY_LENGTH GL_PROGRAM_BINARY_LENGTH_OES
 #	define GL_HALF_FLOAT GL_HALF_FLOAT_OES
+#	define GL_RGB10_A2 GL_RGB10_A2_EXT
+#	define GL_UNSIGNED_INT_2_10_10_10_REV GL_UNSIGNED_INT_2_10_10_10_REV_EXT
+#	define GL_SAMPLER_3D GL_SAMPLER_3D_OES
 #endif // BGFX_CONFIG_RENDERER_OPENGLES2
 
 namespace bgfx
@@ -617,13 +620,19 @@ namespace bgfx
 			EXT_texture_compression_dxt1,
 			CHROMIUM_texture_compression_dxt3,
 			CHROMIUM_texture_compression_dxt5,
+			ARB_texture_float,
+			OES_texture_float,
+			OES_texture_float_linear,
+			OES_texture_half_float,
+			OES_texture_half_float_linear,
+			EXT_texture_type_2_10_10_10_REV,
+			EXT_texture_sRGB,
 			OES_standard_derivatives,
 			ARB_get_program_binary,
 			OES_get_program_binary,
 			EXT_framebuffer_blit,
 			ARB_timer_query,
 			EXT_timer_query,
-			EXT_texture_sRGB,
 			ARB_framebuffer_sRGB,
 			EXT_framebuffer_sRGB,
 			ARB_multisample,
@@ -631,11 +640,6 @@ namespace bgfx
 			ANGLE_translated_shader_source,
 			ARB_instanced_arrays,
 			ANGLE_instanced_arrays,
-			ARB_texture_float,
-			OES_texture_float,
-			OES_texture_float_linear,
-			OES_texture_half_float,
-			OES_texture_half_float_linear,
 			ARB_half_float_vertex,
 			OES_vertex_half_float,
 			ARB_vertex_type_2_10_10_10_rev,
@@ -662,13 +666,19 @@ namespace bgfx
 		{ "GL_EXT_texture_compression_dxt1",      false, true },
 		{ "GL_CHROMIUM_texture_compression_dxt3", false, true },
 		{ "GL_CHROMIUM_texture_compression_dxt5", false, true },
+		{ "GL_ARB_texture_float",                 false, true },
+		{ "GL_OES_texture_float",                 false, true },
+		{ "GL_OES_texture_float_linear",          false, true },
+		{ "GL_OES_texture_half_float",            false, true },
+		{ "GL_OES_texture_half_float_linear",     false, true },
+		{ "GL_EXT_texture_type_2_10_10_10_REV",   false, true },
+		{ "GL_EXT_texture_sRGB",                  false, true },
 		{ "GL_OES_standard_derivatives",          false, true },
 		{ "GL_ARB_get_program_binary",            false, true },
 		{ "GL_OES_get_program_binary",            false, false },
 		{ "GL_EXT_framebuffer_blit",              false, true },
 		{ "GL_ARB_timer_query",                   false, true },
 		{ "GL_EXT_timer_query",                   false, true },
-		{ "GL_EXT_texture_sRGB",                  false, true },
 		{ "GL_ARB_framebuffer_sRGB",              false, true },
 		{ "GL_EXT_framebuffer_sRGB",              false, true },
 		{ "GL_ARB_multisample",                   false, true },
@@ -676,11 +686,6 @@ namespace bgfx
 		{ "GL_ANGLE_translated_shader_source",    false, true },
 		{ "GL_ARB_instanced_arrays",              false, true },
 		{ "GL_ANGLE_instanced_arrays",            false, true },
-		{ "GL_ARB_texture_float",                 false, true },
-		{ "GL_OES_texture_float",                 false, true },
-		{ "GL_OES_texture_float_linear",          false, true },
-		{ "GL_OES_texture_half_float",            false, true },
-		{ "GL_OES_texture_half_float_linear",     false, true },
 		{ "GL_ARB_half_float_vertex",             false, true },
 		{ "GL_OES_vertex_half_float",             false, true },
 		{ "GL_ARB_vertex_type_2_10_10_10_rev",    false, true },
@@ -841,19 +846,22 @@ namespace bgfx
 
 	static const TextureFormatInfo s_textureFormat[TextureFormat::Count] =
 	{
-		{ GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_ZERO,      GL_ZERO,                 4 },
-		{ GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_ZERO,      GL_ZERO,                 4 },
-		{ GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_ZERO,      GL_ZERO,                 4 },
-		{ GL_ZERO,                          GL_ZERO,      GL_ZERO,                 0 },
-		{ GL_LUMINANCE,                     GL_LUMINANCE, GL_UNSIGNED_BYTE,        1 },
-		{ GL_RGBA,                          GL_RGBA,      GL_UNSIGNED_BYTE,        4 },
-		{ GL_RGBA,                          GL_RGBA,      GL_UNSIGNED_BYTE,        4 },
+		{ GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_ZERO,                        4  },
+		{ GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_ZERO,                        4  },
+		{ GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_ZERO,                        4  },
+		{ GL_ZERO,                          GL_ZERO,                          GL_ZERO,                        0  },
+		{ GL_LUMINANCE,                     GL_LUMINANCE,                     GL_UNSIGNED_BYTE,               8  },
+		{ GL_RGBA,                          GL_RGBA,                          GL_UNSIGNED_BYTE,               32 },
+		{ GL_RGBA,                          GL_RGBA,                          GL_UNSIGNED_BYTE,               32 },
 #if BGFX_CONFIG_RENDERER_OPENGL
-		{ GL_RGBA16,                        GL_RGBA,      GL_HALF_FLOAT,           8 },
+		{ GL_RGBA16,                        GL_RGBA,                          GL_HALF_FLOAT,                  64 },
 #else
-		{ GL_RGBA,                          GL_RGBA,      GL_UNSIGNED_BYTE,        8 },
+		{ GL_RGBA,                          GL_RGBA,                          GL_UNSIGNED_BYTE,               64 },
 #endif // BGFX_CONFIG_RENDERER_OPENGL
-		{ GL_RGB,                           GL_RGB,       GL_UNSIGNED_SHORT_5_6_5, 2 },
+		{ GL_RGB565,                        GL_RGB,                           GL_UNSIGNED_SHORT_5_6_5,        16 },
+		{ GL_RGBA4,                         GL_RGBA,                          GL_UNSIGNED_SHORT_4_4_4_4,      16 },
+		{ GL_RGB5_A1,                       GL_RGBA,                          GL_UNSIGNED_SHORT_5_5_5_1,      16 },
+		{ GL_RGB10_A2,                      GL_RGBA,                          GL_UNSIGNED_INT_2_10_10_10_REV, 32 },
 	};
 
 	const char* glslTypeName(GLuint _type)
@@ -877,7 +885,7 @@ namespace bgfx
 // 			GLSL_TYPE(GL_FLOAT_MAT4x3);
 // 			GLSL_TYPE(GL_SAMPLER_1D);
  			GLSL_TYPE(GL_SAMPLER_2D);
-//			GLSL_TYPE(GL_SAMPLER_3D);
+			GLSL_TYPE(GL_SAMPLER_3D);
 			GLSL_TYPE(GL_SAMPLER_CUBE);
 // 			GLSL_TYPE(GL_SAMPLER_1D_SHADOW);
 // 			GLSL_TYPE(GL_SAMPLER_2D_SHADOW);
@@ -936,10 +944,10 @@ namespace bgfx
 // 		case GL_FLOAT_MAT4x3:
 // 			break;
 
-		case GL_SAMPLER_2D:
-		case GL_SAMPLER_CUBE:
 // 		case GL_SAMPLER_1D:
-// 		case GL_SAMPLER_3D:
+		case GL_SAMPLER_2D:
+		case GL_SAMPLER_3D:
+		case GL_SAMPLER_CUBE:
 // 		case GL_SAMPLER_1D_SHADOW:
 // 		case GL_SAMPLER_2D_SHADOW:
 			return UniformType::Uniform1iv;
@@ -969,12 +977,12 @@ namespace bgfx
 				void* data = g_realloc(NULL, length);
 				g_cache(id, false, data, length);
 
-				StreamRead stream(data, length);
+				bx::MemoryReader reader(data, length);
 
 				GLenum format;
-				stream.read(format);
+				bx::read(&reader, format);
 
-				GL_CHECK(glProgramBinary(m_id, format, stream.getDataPtr(), stream.remaining() ) );
+				GL_CHECK(glProgramBinary(m_id, format, reader.getDataPtr(), (GLsizei)reader.remaining() ) );
 
 				g_free(data);
 			}
@@ -1347,7 +1355,7 @@ namespace bgfx
 					m_type = GL_UNSIGNED_BYTE;
 				}
 
-				uint8_t* bits = (uint8_t*)g_realloc(NULL, dds.m_width*dds.m_height*tfi.m_bpp);
+				uint8_t* bits = (uint8_t*)g_realloc(NULL, dds.m_width*dds.m_height*tfi.m_bpp/8);
 
 				for (uint8_t side = 0, numSides = dds.m_cubeMap ? 6 : 1; side < numSides; ++side)
 				{
@@ -1406,6 +1414,8 @@ namespace bgfx
 			}
 			else
 			{
+				m_compressed = true;
+
 				for (uint8_t side = 0, numSides = dds.m_cubeMap ? 6 : 1; side < numSides; ++side)
 				{
 					uint32_t width = dds.m_width;
@@ -1442,15 +1452,15 @@ namespace bgfx
 		}
 		else
 		{
-			StreamRead stream(_mem->data, _mem->size);
+			bx::MemoryReader reader(_mem->data, _mem->size);
 
 			uint32_t magic;
-			stream.read(magic);
+			bx::read(&reader, magic);
 
-			if (BGFX_MAGIC == magic)
+			if (BGFX_CHUNK_MAGIC_TEX == magic)
 			{
 				TextureCreate tc;
-				stream.read(tc);
+				bx::read(&reader, tc);
 
 				if (tc.m_cubeMap)
 				{
@@ -1471,10 +1481,11 @@ namespace bgfx
 				BX_CHECK(0 != m_id, "Failed to generate texture id.");
 				GL_CHECK(glBindTexture(m_target, m_id) );
 
-				const TextureFormatInfo& tfi = s_textureFormat[tc.m_type];
+				const TextureFormatInfo& tfi = s_textureFormat[tc.m_format];
 				GLenum internalFmt = tfi.m_internalFmt;
 				m_fmt = tfi.m_fmt;
 				m_type = tfi.m_type;
+				m_compressed = tc.m_format < TextureFormat::Unknown;
 
 				GLenum target = m_target;
 				if (tc.m_cubeMap)
@@ -1482,8 +1493,9 @@ namespace bgfx
 					target = GL_TEXTURE_CUBE_MAP_POSITIVE_X;
 				}
 
-				uint32_t bpp = s_textureFormat[tc.m_type].m_bpp;
+				uint32_t bpp = tfi.m_bpp;
 				uint8_t* data = NULL != tc.m_mem ? tc.m_mem->data : NULL;
+				uint32_t min = m_compressed ? 4 : 1;
 
 				for (uint8_t side = 0, numSides = tc.m_cubeMap ? 6 : 1; side < numSides; ++side)
 				{
@@ -1493,25 +1505,42 @@ namespace bgfx
 
 					for (uint32_t lod = 0, num = tc.m_numMips; lod < num; ++lod)
 					{
-						width = uint32_max(width, 1);
-						height = uint32_max(height, 1);
+						width = uint32_max(width, min);
+						height = uint32_max(height, min);
 						depth = uint32_max(1, depth);
+						uint32_t size = width*height*bpp/8;
 
-						texImage(target+side
-							, lod
-							, internalFmt
-							, width
-							, height
-							, depth
-							, 0
-							, m_fmt
-							, m_type
-							, data
-							);
+						if (m_compressed)
+						{
+							compressedTexImage(target+side
+								, lod
+								, internalFmt
+								, width
+								, height
+								, depth
+								, 0
+								, size
+								, data
+								);
+						}
+						else
+						{
+							texImage(target+side
+								, lod
+								, internalFmt
+								, width
+								, height
+								, depth
+								, 0
+								, m_fmt
+								, m_type
+								, data
+								);
+						}
 
 						if (NULL != data)
 						{
-							data += width*height*bpp;
+							data += size;
 						}
 
 						width >>= 1;
@@ -1623,6 +1652,20 @@ namespace bgfx
 		switch (m_target)
 		{
 		case GL_TEXTURE_2D:
+			if (m_compressed)
+			{
+				GL_CHECK(glCompressedTexSubImage2D(m_target
+					, _mip
+					, _rect.m_x
+					, _rect.m_y
+					, _rect.m_width
+					, _rect.m_height
+					, m_fmt
+					, _mem->size
+					, _mem->data
+					) );
+			}
+			else
 			{
 				GL_CHECK(glTexSubImage2D(m_target
 					, _mip
@@ -1638,6 +1681,20 @@ namespace bgfx
 			break;
 
 		case GL_TEXTURE_CUBE_MAP:
+			if (m_compressed)
+			{
+				GL_CHECK(glCompressedTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X+_side
+					, _mip
+					, _rect.m_x
+					, _rect.m_y
+					, _rect.m_width
+					, _rect.m_height
+					, m_fmt
+					, _mem->size
+					, _mem->data
+					) );
+			}
+			else
 			{
 				GL_CHECK(glTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X+_side
 					, _mip
@@ -1654,6 +1711,22 @@ namespace bgfx
 
 #if BGFX_CONFIG_RENDERER_OPENGL
 		case GL_TEXTURE_3D:
+			if (m_compressed)
+			{
+				GL_CHECK(glCompressedTexSubImage3D(m_target
+					, _mip
+					, _rect.m_x
+					, _rect.m_y
+					, _z
+					, _rect.m_width
+					, _rect.m_height
+					, _depth
+					, m_fmt
+					, _mem->size
+					, _mem->data
+					) );
+			}
+			else
 			{
 				GL_CHECK(glTexSubImage3D(m_target
 					, _mip
@@ -2091,7 +2164,7 @@ namespace bgfx
 
 	void Context::rendererCreateVertexShader(VertexShaderHandle _handle, Memory* _mem)
 	{
-		s_renderCtx.m_vertexShaders[_handle.idx].create(GL_VERTEX_SHADER, _mem->data);
+		s_renderCtx.m_vertexShaders[_handle.idx].create(GL_VERTEX_SHADER, _mem);
 	}
 
 	void Context::rendererDestroyVertexShader(VertexShaderHandle _handle)
@@ -2101,7 +2174,7 @@ namespace bgfx
 
 	void Context::rendererCreateFragmentShader(FragmentShaderHandle _handle, Memory* _mem)
 	{
-		s_renderCtx.m_fragmentShaders[_handle.idx].create(GL_FRAGMENT_SHADER, _mem->data);
+		s_renderCtx.m_fragmentShaders[_handle.idx].create(GL_FRAGMENT_SHADER, _mem);
 	}
 
 	void Context::rendererDestroyFragmentShader(FragmentShaderHandle _handle)
@@ -2329,7 +2402,7 @@ namespace bgfx
 // 						if (BGFX_STENCIL_FUNC_RMASK_MASK & bchanged)
 // 						{
 // 							uint32_t wmask = (bstencil&BGFX_STENCIL_FUNC_RMASK_MASK)>>BGFX_STENCIL_FUNC_RMASK_SHIFT;
-// 							BX_CHECK(glStencilMask(wmask) );
+// 							GL_CHECK(glStencilMask(wmask) );
 // 						}
 
 						for (uint32_t ii = 0, num = frontAndBack+1; ii < num; ++ii)
@@ -2362,9 +2435,8 @@ namespace bgfx
 				}
 
 				if ( (BGFX_STATE_CULL_MASK|BGFX_STATE_DEPTH_WRITE|BGFX_STATE_DEPTH_TEST_MASK
-				     |BGFX_STATE_ALPHA_MASK|BGFX_STATE_ALPHA_WRITE|BGFX_STATE_RGB_WRITE
-				     |BGFX_STATE_BLEND_MASK|BGFX_STATE_ALPHA_REF_MASK|BGFX_STATE_PT_MASK
-				     |BGFX_STATE_POINT_SIZE_MASK) & changedFlags)
+				     |BGFX_STATE_ALPHA_MASK|BGFX_STATE_RGB_WRITE|BGFX_STATE_BLEND_MASK
+					 |BGFX_STATE_ALPHA_REF_MASK|BGFX_STATE_PT_MASK|BGFX_STATE_POINT_SIZE_MASK) & changedFlags)
 				{
 					if (BGFX_STATE_CULL_MASK & changedFlags)
 					{
@@ -2478,7 +2550,7 @@ namespace bgfx
 
 					if (constantsChanged)
 					{
-						program.m_constantBuffer->commit();
+						program.commit();
 					}
 
 					for (uint32_t ii = 0, num = program.m_numPredefined; ii < num; ++ii)
diff --git a/src/renderer_gl.h b/src/renderer_gl.h
index ecbf0f45..a7695331 100644
--- a/src/renderer_gl.h
+++ b/src/renderer_gl.h
@@ -325,6 +325,9 @@ namespace bgfx
 		Texture()
 			: m_id(0)
 			, m_target(GL_TEXTURE_2D)
+			, m_fmt(GL_ZERO)
+			, m_type(GL_ZERO)
+			, m_compressed(false)
 		{
 		}
 
@@ -338,19 +341,30 @@ namespace bgfx
 		GLenum m_target;
 		GLenum m_fmt;
 		GLenum m_type;
+		bool m_compressed;
 	};
 
 	struct Shader
 	{
-		void create(GLenum _type, const uint8_t* _code)
+		void create(GLenum _type, Memory* _mem)
 		{
 			m_id = glCreateShader(_type);
 			m_type = _type;
 
+			bx::MemoryReader reader(_mem->data, _mem->size);
+			m_hash = hashMurmur2A(_mem->data, _mem->size);
+
+			uint32_t magic;
+			bx::read(&reader, magic);
+
+			uint32_t hash;
+			bx::read(&reader, hash);
+
+			const uint8_t* code = reader.getDataPtr();
+
 			if (0 != m_id)
 			{
-				m_hash = hash(_code, (uint32_t)strlen( (const char*)_code) );
-				GL_CHECK(glShaderSource(m_id, 1, (const GLchar**)&_code, NULL) );
+				GL_CHECK(glShaderSource(m_id, 1, (const GLchar**)&code, NULL) );
 				GL_CHECK(glCompileShader(m_id) );
 
 				GLint compiled = 0;
@@ -361,9 +375,10 @@ namespace bgfx
 					char log[1024];
 					GL_CHECK(glGetShaderInfoLog(m_id, sizeof(log), NULL, log) );
 					BX_TRACE("Failed to compile shader. %d: %s", compiled, log);
-					BX_TRACE("\n####\n%s\n####", _code);
+					BX_TRACE("\n####\n%s\n####", code);
 
 					GL_CHECK(glDeleteShader(m_id) );
+					BGFX_FATAL(false, bgfx::Fatal::InvalidShader, "Failed to compile shader.");
 				}
 			}
 		}
@@ -398,6 +413,11 @@ namespace bgfx
  		void init();
  		void bindAttributes(const VertexDecl& _vertexDecl, uint32_t _baseVertex = 0) const;
 		void bindInstanceData(uint32_t _stride, uint32_t _baseVertex = 0) const;
+
+		void commit()
+		{
+			m_constantBuffer->commit();
+		}
  
 		GLuint m_id;
 
diff --git a/src/renderer_null.cpp b/src/renderer_null.cpp
index 883755e8..d6682940 100644
--- a/src/renderer_null.cpp
+++ b/src/renderer_null.cpp
@@ -107,15 +107,15 @@ namespace bgfx
 
 	void Context::rendererCreateTexture(TextureHandle /*_handle*/, Memory* _mem, uint32_t /*_flags*/)
 	{
-		StreamRead stream(_mem->data, _mem->size);
+		bx::MemoryReader reader(_mem->data, _mem->size);
 
 		uint32_t magic;
-		stream.read(magic);
+		bx::read(&reader, magic);
 
-		if (BGFX_MAGIC == magic)
+		if (BGFX_CHUNK_MAGIC_TEX == magic)
 		{
 			TextureCreate tc;
-			stream.read(tc);
+			bx::read(&reader, tc);
 
 			if (NULL != tc.m_mem)
 			{
diff --git a/src/vs_clear_dx11.bin.h b/src/vs_clear_dx11.bin.h
index 20112fb2..53cb6aaf 100644
--- a/src/vs_clear_dx11.bin.h
+++ b/src/vs_clear_dx11.bin.h
@@ -1,44 +1,45 @@
-static const uint8_t vs_clear_dx11[650] =
+static const uint8_t vs_clear_dx11[658] =
 {
-	0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
-	0x00, 0x00, 0x00, 0x74, 0x02, 0x44, 0x58, 0x42, 0x43, 0x9f, 0x90, 0x55, 0x9a, 0x15, 0xd7, 0x4d, // ...t.DXBC..U...M
-	0x46, 0x12, 0x19, 0x32, 0x30, 0xa7, 0xfd, 0x7a, 0x83, 0x01, 0x00, 0x00, 0x00, 0x74, 0x02, 0x00, // F..20..z.....t..
-	0x00, 0x05, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0xac, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, // .....4..........
-	0x00, 0x50, 0x01, 0x00, 0x00, 0xd8, 0x01, 0x00, 0x00, 0x52, 0x44, 0x45, 0x46, 0x70, 0x00, 0x00, // .P.......RDEFp..
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, // .............<..
-	0x00, 0x00, 0x05, 0xfe, 0xff, 0x00, 0x91, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x52, 0x44, 0x31, // .........<...RD1
-	0x31, 0x3c, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, // 1<....... ...(..
-	0x00, 0x24, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4d, 0x69, 0x63, // .$...........Mic
-	0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, // rosoft (R) HLSL 
-	0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, // Shader Compiler 
-	0x39, 0x2e, 0x32, 0x39, 0x2e, 0x39, 0x35, 0x32, 0x2e, 0x33, 0x31, 0x31, 0x31, 0x00, 0xab, 0xab, // 9.29.952.3111...
-	0xab, 0x49, 0x53, 0x47, 0x4e, 0x48, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, // .ISGNH..........
-	0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, // .8..............
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .........A......
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x00, // ................
-	0x00, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x00, 0x43, 0x4f, 0x4c, 0x4f, 0x52, 0x00, // .POSITION.COLOR.
-	0xab, 0x4f, 0x53, 0x47, 0x4e, 0x4c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, // .OSGNL..........
-	0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, // .8..............
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .........D......
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, // ................
-	0x00, 0x53, 0x56, 0x5f, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x00, 0x43, 0x4f, 0x4c, // .SV_POSITION.COL
-	0x4f, 0x52, 0x00, 0xab, 0xab, 0x53, 0x48, 0x45, 0x58, 0x80, 0x00, 0x00, 0x00, 0x50, 0x00, 0x01, // OR...SHEX....P..
-	0x00, 0x20, 0x00, 0x00, 0x00, 0x6a, 0x08, 0x00, 0x01, 0x5f, 0x00, 0x00, 0x03, 0x72, 0x10, 0x10, // . ...j..._...r..
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x03, 0xf2, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, // ....._..........
-	0x00, 0x67, 0x00, 0x00, 0x04, 0xf2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, // .g.... .........
-	0x00, 0x65, 0x00, 0x00, 0x03, 0xf2, 0x20, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, // .e.... ......6..
-	0x05, 0x72, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x12, 0x10, 0x00, 0x00, 0x00, 0x00, // .r ......F......
-	0x00, 0x36, 0x00, 0x00, 0x05, 0x82, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, // .6.... .......@.
-	0x00, 0x00, 0x00, 0x80, 0x3f, 0x36, 0x00, 0x00, 0x05, 0xf2, 0x20, 0x10, 0x00, 0x01, 0x00, 0x00, // ....?6.... .....
-	0x00, 0x46, 0x1e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x01, 0x53, 0x54, 0x41, // .F.......>...STA
-	0x54, 0x94, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // T...............
-	0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
-	0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
+	0x56, 0x53, 0x48, 0x00, 0xa4, 0x8b, 0xef, 0x49, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, // VSH....I........
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x74, 0x02, 0x44, 0x58, 0x42, // ...........t.DXB
+	0x43, 0xda, 0x52, 0xa4, 0x82, 0x31, 0xef, 0x9d, 0x65, 0xc3, 0x64, 0xcc, 0x10, 0x3d, 0x4f, 0x86, // C.R..1..e.d..=O.
+	0x53, 0x01, 0x00, 0x00, 0x00, 0x74, 0x02, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, // S....t.......4..
+	0x00, 0xac, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0x50, 0x01, 0x00, 0x00, 0xd8, 0x01, 0x00, // .........P......
+	0x00, 0x52, 0x44, 0x45, 0x46, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .RDEFp..........
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x05, 0xfe, 0xff, 0x00, 0x91, 0x00, // .....<..........
+	0x00, 0x3c, 0x00, 0x00, 0x00, 0x52, 0x44, 0x31, 0x31, 0x3c, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, // .<...RD11<......
+	0x00, 0x20, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, // . ...(...$......
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x4d, 0x69, 0x63, 0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x20, 0x28, // .....Microsoft (
+	0x52, 0x29, 0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x20, 0x43, // R) HLSL Shader C
+	0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x39, 0x2e, 0x32, 0x39, 0x2e, 0x39, 0x35, 0x32, // ompiler 9.29.952
+	0x2e, 0x33, 0x31, 0x31, 0x31, 0x00, 0xab, 0xab, 0xab, 0x49, 0x53, 0x47, 0x4e, 0x48, 0x00, 0x00, // .3111....ISGNH..
+	0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .........8......
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x00, // ................
+	0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, // .>..............
+	0x00, 0x01, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, 0x43, 0x4f, 0x4c, 0x4f, 0x52, 0x00, 0x50, // .........COLOR.P
+	0x4f, 0x53, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x00, 0xab, 0x4f, 0x53, 0x47, 0x4e, 0x4c, 0x00, 0x00, // OSITION..OSGNL..
+	0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .........8......
+	0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, // ................
+	0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, // .D..............
+	0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x53, 0x56, 0x5f, 0x50, 0x4f, 0x53, 0x49, // .........SV_POSI
+	0x54, 0x49, 0x4f, 0x4e, 0x00, 0x43, 0x4f, 0x4c, 0x4f, 0x52, 0x00, 0xab, 0xab, 0x53, 0x48, 0x45, // TION.COLOR...SHE
+	0x58, 0x80, 0x00, 0x00, 0x00, 0x50, 0x00, 0x01, 0x00, 0x20, 0x00, 0x00, 0x00, 0x6a, 0x08, 0x00, // X....P... ...j..
+	0x01, 0x5f, 0x00, 0x00, 0x03, 0xf2, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, // ._..........._..
+	0x03, 0x72, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x67, 0x00, 0x00, 0x04, 0xf2, 0x20, 0x10, // .r.......g.... .
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x03, 0xf2, 0x20, 0x10, // .........e.... .
+	0x00, 0x01, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x72, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, // .....6...r .....
+	0x00, 0x46, 0x12, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x82, 0x20, 0x10, // .F.......6.... .
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x36, 0x00, 0x00, // ......@.....?6..
+	0x05, 0xf2, 0x20, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x1e, 0x10, 0x00, 0x00, 0x00, 0x00, // .. ......F......
+	0x00, 0x3e, 0x00, 0x00, 0x01, 0x53, 0x54, 0x41, 0x54, 0x94, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, // .>...STAT.......
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
-	0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,                                     // ..........
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
+	0x00, 0x00,                                                                                     // ..
 };
diff --git a/src/vs_debugfont_dx11.bin.h b/src/vs_debugfont_dx11.bin.h
index 5dfbefe3..d75ce223 100644
--- a/src/vs_debugfont_dx11.bin.h
+++ b/src/vs_debugfont_dx11.bin.h
@@ -1,96 +1,96 @@
-static const uint8_t vs_debugfont_dx11[1476] =
+static const uint8_t vs_debugfont_dx11[1484] =
 {
-	0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, // ................
-	0x00, 0xc0, 0x01, 0x0f, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x56, 0x69, 0x65, 0x77, 0x50, // ....u_modelViewP
-	0x72, 0x6f, 0x6a, 0x09, 0x00, 0x00, 0x01, 0x04, 0x00, 0x98, 0x05, 0x44, 0x58, 0x42, 0x43, 0x46, // roj........DXBCF
-	0xbf, 0xfc, 0xa7, 0xce, 0x2a, 0xea, 0x90, 0xbc, 0x31, 0x32, 0x0a, 0x66, 0x1f, 0xa2, 0x34, 0x01, // ....*...12.f..4.
-	0x00, 0x00, 0x00, 0x98, 0x05, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x88, // ...........4....
-	0x02, 0x00, 0x00, 0x10, 0x03, 0x00, 0x00, 0x9c, 0x03, 0x00, 0x00, 0xfc, 0x04, 0x00, 0x00, 0x52, // ...............R
-	0x44, 0x45, 0x46, 0x4c, 0x02, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, 0x01, // DEFL.......h....
-	0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x05, 0xfe, 0xff, 0x00, 0x91, 0x00, 0x00, 0x18, // ...<............
-	0x02, 0x00, 0x00, 0x52, 0x44, 0x31, 0x31, 0x3c, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x20, // ...RD11<....... 
-	0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, // ...(...$........
-	0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, // ................
-	0x00, 0x00, 0x00, 0x24, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x73, 0x00, 0xab, 0xab, 0xab, 0x5c, // ...$Globals.....
-	0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x00, // ................
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x98, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, // ...............@
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, // ................
-	0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xcc, // ................
-	0x01, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa8, // ...@...@........
+	0x56, 0x53, 0x48, 0x00, 0xb8, 0xbe, 0x22, 0x66, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, // VSH..."f........
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0xc0, 0x01, 0x0f, 0x75, 0x5f, 0x6d, 0x6f, // ............u_mo
+	0x64, 0x65, 0x6c, 0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x09, 0x00, 0x00, 0x01, 0x04, // delViewProj.....
+	0x00, 0x98, 0x05, 0x44, 0x58, 0x42, 0x43, 0x4e, 0x14, 0xcf, 0x18, 0xca, 0x5f, 0xd6, 0x83, 0xb0, // ...DXBCN...._...
+	0x52, 0x90, 0x95, 0x2f, 0xd3, 0xd3, 0x43, 0x01, 0x00, 0x00, 0x00, 0x98, 0x05, 0x00, 0x00, 0x05, // R../..C.........
+	0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x88, 0x02, 0x00, 0x00, 0x10, 0x03, 0x00, 0x00, 0x9c, // ...4............
+	0x03, 0x00, 0x00, 0xfc, 0x04, 0x00, 0x00, 0x52, 0x44, 0x45, 0x46, 0x4c, 0x02, 0x00, 0x00, 0x01, // .......RDEFL....
+	0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, // ...h.......<....
+	0x05, 0xfe, 0xff, 0x00, 0x91, 0x00, 0x00, 0x18, 0x02, 0x00, 0x00, 0x52, 0x44, 0x31, 0x31, 0x3c, // ...........RD11<
+	0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x24, // ....... ...(...$
+	0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x00, // ................
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
+	0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x47, 0x6c, 0x6f, 0x62, // ...........$Glob
+	0x61, 0x6c, 0x73, 0x00, 0xab, 0xab, 0xab, 0x5c, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x80, // als.............
+	0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x98, // ................
+	0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa8, // .......@........
 	0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, // ................
-	0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xd7, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x40, // ...............@
+	0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xcc, 0x01, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, // ...........@...@
 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, // ................
-	0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xdf, // ................
-	0x01, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa8, // .......@........
+	0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xd7, // ................
+	0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa8, // .......@........
 	0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, // ................
-	0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xeb, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x40, // ...............@
-	0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xa8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, // ................
-	0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xfb, // ................
-	0x01, 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa8, // ...@...@........
-	0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, // ................
-	0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x02, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x40, // ...............@
+	0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xdf, 0x01, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x40, // ...............@
 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, // ................
-	0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x75, // ...............u
-	0x5f, 0x76, 0x69, 0x65, 0x77, 0x00, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x78, 0x34, 0x00, 0x03, // _view.float4x4..
-	0x00, 0x03, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9f, // ................
-	0x01, 0x00, 0x00, 0x75, 0x5f, 0x76, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x00, 0x75, 0x5f, // ...u_viewProj.u_
-	0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x00, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x56, 0x69, 0x65, // model.u_modelVie
-	0x77, 0x00, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, // w.u_modelViewPro
-	0x6a, 0x00, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, // j.u_modelViewPro
-	0x6a, 0x58, 0x00, 0x75, 0x5f, 0x76, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x58, 0x00, 0x4d, // jX.u_viewProjX.M
-	0x69, 0x63, 0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48, 0x4c, 0x53, // icrosoft (R) HLS
-	0x4c, 0x20, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, // L Shader Compile
-	0x72, 0x20, 0x39, 0x2e, 0x32, 0x39, 0x2e, 0x39, 0x35, 0x32, 0x2e, 0x33, 0x31, 0x31, 0x31, 0x00, // r 9.29.952.3111.
-	0xab, 0xab, 0xab, 0x49, 0x53, 0x47, 0x4e, 0x80, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, // ...ISGN.........
-	0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, // ...h............
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, 0x71, 0x00, 0x00, 0x00, 0x00, // ...........q....
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, // ................
-	0x0f, 0x00, 0x00, 0x71, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, // ...q............
-	0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x00, // ...........w....
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, // ................
-	0x03, 0x00, 0x00, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x00, 0x43, 0x4f, 0x4c, 0x4f, // ...POSITION.COLO
-	0x52, 0x00, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x00, 0x4f, 0x53, 0x47, 0x4e, 0x84, // R.TEXCOORD.OSGN.
+	0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xeb, // ................
+	0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xa8, // .......@........
+	0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, // ................
+	0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xfb, 0x01, 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0x40, // ...........@...@
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, // ................
+	0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x0c, // ................
+	0x02, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa8, // .......@........
+	0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, // ................
+	0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x75, 0x5f, 0x76, 0x69, 0x65, 0x77, 0x00, 0x66, 0x6c, // .......u_view.fl
+	0x6f, 0x61, 0x74, 0x34, 0x78, 0x34, 0x00, 0x03, 0x00, 0x03, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, // oat4x4..........
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9f, 0x01, 0x00, 0x00, 0x75, 0x5f, 0x76, 0x69, 0x65, // ...........u_vie
+	0x77, 0x50, 0x72, 0x6f, 0x6a, 0x00, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x00, 0x75, 0x5f, // wProj.u_model.u_
+	0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x56, 0x69, 0x65, 0x77, 0x00, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, // modelView.u_mode
+	0x6c, 0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x00, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, // lViewProj.u_mode
+	0x6c, 0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x58, 0x00, 0x75, 0x5f, 0x76, 0x69, 0x65, // lViewProjX.u_vie
+	0x77, 0x50, 0x72, 0x6f, 0x6a, 0x58, 0x00, 0x4d, 0x69, 0x63, 0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, // wProjX.Microsoft
+	0x20, 0x28, 0x52, 0x29, 0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, //  (R) HLSL Shader
+	0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x39, 0x2e, 0x32, 0x39, 0x2e, 0x39, //  Compiler 9.29.9
+	0x35, 0x32, 0x2e, 0x33, 0x31, 0x31, 0x31, 0x00, 0xab, 0xab, 0xab, 0x49, 0x53, 0x47, 0x4e, 0x80, // 52.3111....ISGN.
 	0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, 0x00, // ...........h....
-	0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, // ................
-	0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, // ...t............
-	0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00, 0x01, // ...........t....
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0f, // ................
-	0x00, 0x00, 0x00, 0x7a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, // ...z............
-	0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x0c, 0x00, 0x00, 0x53, 0x56, 0x5f, 0x50, 0x4f, // ...........SV_PO
-	0x53, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x00, 0x43, 0x4f, 0x4c, 0x4f, 0x52, 0x00, 0x54, 0x45, 0x58, // SITION.COLOR.TEX
-	0x43, 0x4f, 0x4f, 0x52, 0x44, 0x00, 0xab, 0x53, 0x48, 0x45, 0x58, 0x58, 0x01, 0x00, 0x00, 0x50, // COORD..SHEXX...P
-	0x00, 0x01, 0x00, 0x56, 0x00, 0x00, 0x00, 0x6a, 0x08, 0x00, 0x01, 0x59, 0x00, 0x00, 0x04, 0x46, // ...V...j...Y...F
-	0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x03, 0x72, // . ........._...r
-	0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x03, 0xf2, 0x10, 0x10, 0x00, 0x01, // ......._........
-	0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x03, 0xf2, 0x10, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x5f, // ..._..........._
-	0x00, 0x00, 0x03, 0x32, 0x10, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x67, 0x00, 0x00, 0x04, 0xf2, // ...2.......g....
-	0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x03, 0xf2, //  ..........e....
-	0x20, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x03, 0xf2, 0x20, 0x10, 0x00, 0x02, //  ......e.... ...
-	0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x03, 0x32, 0x20, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x68, // ...e...2 ......h
-	0x00, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x08, 0xf2, 0x00, 0x10, 0x00, 0x00, // .......8........
-	0x00, 0x00, 0x00, 0x56, 0x15, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, 0x00, 0x00, // ...V.......F. ..
-	0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, 0x00, // .......2........
-	0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x06, // ...F. ..........
-	0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, // .......F.......2
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, // ................
+	0x0f, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, // ...h............
+	0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x00, 0x00, 0x6e, 0x00, 0x00, 0x00, 0x00, // ...........n....
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x07, // ................
+	0x07, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, // ...w............
+	0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x43, 0x4f, 0x4c, 0x4f, 0x52, // ...........COLOR
+	0x00, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x00, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, // .POSITION.TEXCOO
+	0x52, 0x44, 0x00, 0x4f, 0x53, 0x47, 0x4e, 0x84, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, // RD.OSGN.........
+	0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, // ...h............
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00, 0x00, // ...........t....
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, // ................
+	0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, // ...t............
+	0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x7a, 0x00, 0x00, 0x00, 0x00, // ...........z....
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, // ................
+	0x0c, 0x00, 0x00, 0x53, 0x56, 0x5f, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x00, 0x43, // ...SV_POSITION.C
+	0x4f, 0x4c, 0x4f, 0x52, 0x00, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x00, 0xab, 0x53, // OLOR.TEXCOORD..S
+	0x48, 0x45, 0x58, 0x58, 0x01, 0x00, 0x00, 0x50, 0x00, 0x01, 0x00, 0x56, 0x00, 0x00, 0x00, 0x6a, // HEXX...P...V...j
+	0x08, 0x00, 0x01, 0x59, 0x00, 0x00, 0x04, 0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, // ...Y...F. ......
+	0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x03, 0xf2, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5f, // ..._..........._
+	0x00, 0x00, 0x03, 0xf2, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x03, 0x72, // ..........._...r
+	0x10, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x03, 0x32, 0x10, 0x10, 0x00, 0x03, // ......._...2....
+	0x00, 0x00, 0x00, 0x67, 0x00, 0x00, 0x04, 0xf2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, // ...g.... .......
+	0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x03, 0xf2, 0x20, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x65, // ...e.... ......e
+	0x00, 0x00, 0x03, 0xf2, 0x20, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x03, 0x32, // .... ......e...2
+	0x20, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x38, //  ......h.......8
+	0x00, 0x00, 0x08, 0xf2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x56, 0x15, 0x10, 0x00, 0x02, // ...........V....
+	0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x32, // ...F. .........2
 	0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, 0x00, 0x00, // ...........F. ..
-	0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0xa6, 0x1a, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, // ...............F
-	0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xf2, 0x20, 0x10, 0x00, 0x00, // ............ ...
-	0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, 0x00, 0x00, // ...F.......F. ..
-	0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0xf2, 0x20, 0x10, 0x00, 0x01, // .......6.... ...
-	0x00, 0x00, 0x00, 0x46, 0x1e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0xf2, // ...F.......6....
-	0x20, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x1e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x36, //  ......F.......6
-	0x00, 0x00, 0x05, 0x32, 0x20, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x46, 0x10, 0x10, 0x00, 0x03, // ...2 ......F....
-	0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x01, 0x53, 0x54, 0x41, 0x54, 0x94, 0x00, 0x00, 0x00, 0x08, // ...>...STAT.....
-	0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, // ................
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, // ................
+	0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x06, 0x10, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, // ...............F
+	0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, 0x00, // .......2........
+	0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0xa6, // ...F. ..........
+	0x1a, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .......F........
+	0x00, 0x00, 0x08, 0xf2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x00, // .... ......F....
+	0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x36, // ...F. .........6
+	0x00, 0x00, 0x05, 0xf2, 0x20, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x1e, 0x10, 0x00, 0x00, // .... ......F....
+	0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0xf2, 0x20, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, // ...6.... ......F
+	0x1e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x32, 0x20, 0x10, 0x00, 0x03, // .......6...2 ...
+	0x00, 0x00, 0x00, 0x46, 0x10, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x01, 0x53, // ...F.......>...S
+	0x54, 0x41, 0x54, 0x94, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, // TAT.............
+	0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
+	0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, // ................
+	0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
-	0x00, 0x00, 0x00, 0x00,                                                                         // ....
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,                         // ............
 };
diff --git a/src/vs_debugfont_dx9.bin.h b/src/vs_debugfont_dx9.bin.h
index 4b333f4d..3626ce80 100644
--- a/src/vs_debugfont_dx9.bin.h
+++ b/src/vs_debugfont_dx9.bin.h
@@ -1,24 +1,25 @@
-static const uint8_t vs_debugfont_dx9[335] =
+static const uint8_t vs_debugfont_dx9[343] =
 {
-	0x01, 0x00, 0x0f, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x56, 0x69, 0x65, 0x77, 0x50, 0x72, // ...u_modelViewPr
-	0x6f, 0x6a, 0x09, 0x01, 0x00, 0x00, 0x04, 0x00, 0x34, 0x01, 0x00, 0x02, 0xfe, 0xff, 0xfe, 0xff, // oj......4.......
-	0x23, 0x00, 0x43, 0x54, 0x41, 0x42, 0x1c, 0x00, 0x00, 0x00, 0x57, 0x00, 0x00, 0x00, 0x00, 0x02, // #.CTAB....W.....
-	0xfe, 0xff, 0x01, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x50, 0x00, // ..............P.
-	0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x40, 0x00, // ..0...........@.
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x56, 0x69, 0x65, // ......u_modelVie
-	0x77, 0x50, 0x72, 0x6f, 0x6a, 0x00, 0x03, 0x00, 0x03, 0x00, 0x04, 0x00, 0x04, 0x00, 0x01, 0x00, // wProj...........
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x73, 0x5f, 0x32, 0x5f, 0x30, 0x00, 0x4d, 0x69, 0x63, // ......vs_2_0.Mic
-	0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, // rosoft (R) HLSL 
-	0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, // Shader Compiler 
-	0x39, 0x2e, 0x32, 0x39, 0x2e, 0x39, 0x35, 0x32, 0x2e, 0x33, 0x31, 0x31, 0x31, 0x00, 0x1f, 0x00, // 9.29.952.3111...
-	0x00, 0x02, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x0f, 0x90, 0x1f, 0x00, 0x00, 0x02, 0x0a, 0x00, // ................
-	0x00, 0x80, 0x01, 0x00, 0x0f, 0x90, 0x1f, 0x00, 0x00, 0x02, 0x0a, 0x00, 0x01, 0x80, 0x02, 0x00, // ................
-	0x0f, 0x90, 0x1f, 0x00, 0x00, 0x02, 0x05, 0x00, 0x00, 0x80, 0x03, 0x00, 0x0f, 0x90, 0x05, 0x00, // ................
-	0x00, 0x03, 0x00, 0x00, 0x0f, 0x80, 0x00, 0x00, 0x55, 0x90, 0x01, 0x00, 0xe4, 0xa0, 0x04, 0x00, // ........U.......
-	0x00, 0x04, 0x00, 0x00, 0x0f, 0x80, 0x00, 0x00, 0xe4, 0xa0, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, // ................
-	0xe4, 0x80, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x0f, 0x80, 0x02, 0x00, 0xe4, 0xa0, 0x00, 0x00, // ................
-	0xaa, 0x90, 0x00, 0x00, 0xe4, 0x80, 0x02, 0x00, 0x00, 0x03, 0x00, 0x00, 0x0f, 0xc0, 0x00, 0x00, // ................
-	0xe4, 0x80, 0x03, 0x00, 0xe4, 0xa0, 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x0f, 0xd0, 0x01, 0x00, // ................
-	0xe4, 0x90, 0x01, 0x00, 0x00, 0x02, 0x01, 0x00, 0x0f, 0xd0, 0x02, 0x00, 0xe4, 0x90, 0x01, 0x00, // ................
-	0x00, 0x02, 0x00, 0x00, 0x03, 0xe0, 0x03, 0x00, 0xe4, 0x90, 0xff, 0xff, 0x00, 0x00, 0x00,       // ...............
+	0x56, 0x53, 0x48, 0x00, 0xb8, 0xbe, 0x22, 0x66, 0x01, 0x00, 0x0f, 0x75, 0x5f, 0x6d, 0x6f, 0x64, // VSH..."f...u_mod
+	0x65, 0x6c, 0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x09, 0x01, 0x00, 0x00, 0x04, 0x00, // elViewProj......
+	0x34, 0x01, 0x00, 0x02, 0xfe, 0xff, 0xfe, 0xff, 0x23, 0x00, 0x43, 0x54, 0x41, 0x42, 0x1c, 0x00, // 4.......#.CTAB..
+	0x00, 0x00, 0x57, 0x00, 0x00, 0x00, 0x00, 0x02, 0xfe, 0xff, 0x01, 0x00, 0x00, 0x00, 0x1c, 0x00, // ..W.............
+	0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x02, 0x00, // ......P...0.....
+	0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x75, 0x5f, // ......@.......u_
+	0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x00, 0x03, 0x00, // modelViewProj...
+	0x03, 0x00, 0x04, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x73, // ..............vs
+	0x5f, 0x32, 0x5f, 0x30, 0x00, 0x4d, 0x69, 0x63, 0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x20, 0x28, // _2_0.Microsoft (
+	0x52, 0x29, 0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x20, 0x43, // R) HLSL Shader C
+	0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x39, 0x2e, 0x32, 0x39, 0x2e, 0x39, 0x35, 0x32, // ompiler 9.29.952
+	0x2e, 0x33, 0x31, 0x31, 0x31, 0x00, 0x1f, 0x00, 0x00, 0x02, 0x0a, 0x00, 0x00, 0x80, 0x00, 0x00, // .3111...........
+	0x0f, 0x90, 0x1f, 0x00, 0x00, 0x02, 0x0a, 0x00, 0x01, 0x80, 0x01, 0x00, 0x0f, 0x90, 0x1f, 0x00, // ................
+	0x00, 0x02, 0x00, 0x00, 0x00, 0x80, 0x02, 0x00, 0x0f, 0x90, 0x1f, 0x00, 0x00, 0x02, 0x05, 0x00, // ................
+	0x00, 0x80, 0x03, 0x00, 0x0f, 0x90, 0x05, 0x00, 0x00, 0x03, 0x00, 0x00, 0x0f, 0x80, 0x02, 0x00, // ................
+	0x55, 0x90, 0x01, 0x00, 0xe4, 0xa0, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x0f, 0x80, 0x00, 0x00, // U...............
+	0xe4, 0xa0, 0x02, 0x00, 0x00, 0x90, 0x00, 0x00, 0xe4, 0x80, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, // ................
+	0x0f, 0x80, 0x02, 0x00, 0xe4, 0xa0, 0x02, 0x00, 0xaa, 0x90, 0x00, 0x00, 0xe4, 0x80, 0x02, 0x00, // ................
+	0x00, 0x03, 0x00, 0x00, 0x0f, 0xc0, 0x00, 0x00, 0xe4, 0x80, 0x03, 0x00, 0xe4, 0xa0, 0x01, 0x00, // ................
+	0x00, 0x02, 0x00, 0x00, 0x0f, 0xd0, 0x00, 0x00, 0xe4, 0x90, 0x01, 0x00, 0x00, 0x02, 0x01, 0x00, // ................
+	0x0f, 0xd0, 0x01, 0x00, 0xe4, 0x90, 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x03, 0xe0, 0x03, 0x00, // ................
+	0xe4, 0x90, 0xff, 0xff, 0x00, 0x00, 0x00,                                                       // .......
 };
diff --git a/src/vs_debugfont_glsl.bin.h b/src/vs_debugfont_glsl.bin.h
index 6bbeb7d2..6ca4a20f 100644
--- a/src/vs_debugfont_glsl.bin.h
+++ b/src/vs_debugfont_glsl.bin.h
@@ -1,33 +1,33 @@
-static const uint8_t vs_debugfont_glsl[466] =
+static const uint8_t vs_debugfont_glsl[474] =
 {
-	0x23, 0x69, 0x66, 0x64, 0x65, 0x66, 0x20, 0x47, 0x4c, 0x5f, 0x45, 0x53, 0x0a, 0x70, 0x72, 0x65, // #ifdef GL_ES.pre
-	0x63, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x66, 0x6c, 0x6f, // cision highp flo
-	0x61, 0x74, 0x3b, 0x0a, 0x23, 0x65, 0x6e, 0x64, 0x69, 0x66, 0x20, 0x2f, 0x2f, 0x20, 0x47, 0x4c, // at;.#endif // GL
-	0x5f, 0x45, 0x53, 0x0a, 0x0a, 0x75, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x6d, 0x61, 0x74, // _ES..uniform mat
-	0x34, 0x20, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, // 4 u_modelViewPro
-	0x6a, 0x3b, 0x0a, 0x76, 0x61, 0x72, 0x79, 0x69, 0x6e, 0x67, 0x20, 0x76, 0x65, 0x63, 0x32, 0x20, // j;.varying vec2 
-	0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x3b, 0x0a, 0x76, 0x61, 0x72, // v_texcoord0;.var
-	0x79, 0x69, 0x6e, 0x67, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, // ying vec4 v_colo
-	0x72, 0x31, 0x3b, 0x0a, 0x76, 0x61, 0x72, 0x79, 0x69, 0x6e, 0x67, 0x20, 0x76, 0x65, 0x63, 0x34, // r1;.varying vec4
-	0x20, 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x3b, 0x0a, 0x61, 0x74, 0x74, 0x72, 0x69, //  v_color0;.attri
-	0x62, 0x75, 0x74, 0x65, 0x20, 0x76, 0x65, 0x63, 0x32, 0x20, 0x61, 0x5f, 0x74, 0x65, 0x78, 0x63, // bute vec2 a_texc
-	0x6f, 0x6f, 0x72, 0x64, 0x30, 0x3b, 0x0a, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, // oord0;.attribute
-	0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x61, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x31, 0x3b, 0x0a, //  vec4 a_color1;.
-	0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x61, // attribute vec4 a
-	0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x3b, 0x0a, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, // _color0;.attribu
-	0x74, 0x65, 0x20, 0x76, 0x65, 0x63, 0x33, 0x20, 0x61, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, // te vec3 a_positi
-	0x6f, 0x6e, 0x3b, 0x0a, 0x76, 0x6f, 0x69, 0x64, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x20, 0x28, 0x29, // on;.void main ()
-	0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, // .{.  vec4 tmpvar
-	0x5f, 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x2e, 0x77, // _1;.  tmpvar_1.w
-	0x20, 0x3d, 0x20, 0x31, 0x2e, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, //  = 1.0;.  tmpvar
-	0x5f, 0x31, 0x2e, 0x78, 0x79, 0x7a, 0x20, 0x3d, 0x20, 0x61, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, // _1.xyz = a_posit
-	0x69, 0x6f, 0x6e, 0x3b, 0x0a, 0x20, 0x20, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, // ion;.  gl_Positi
-	0x6f, 0x6e, 0x20, 0x3d, 0x20, 0x28, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x56, 0x69, 0x65, // on = (u_modelVie
-	0x77, 0x50, 0x72, 0x6f, 0x6a, 0x20, 0x2a, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, // wProj * tmpvar_1
-	0x29, 0x3b, 0x0a, 0x20, 0x20, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, // );.  v_texcoord0
-	0x20, 0x3d, 0x20, 0x61, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x3b, 0x0a, //  = a_texcoord0;.
-	0x20, 0x20, 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x20, 0x3d, 0x20, 0x61, 0x5f, 0x63, //   v_color0 = a_c
-	0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, // olor0;.  v_color
-	0x31, 0x20, 0x3d, 0x20, 0x61, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x31, 0x3b, 0x0a, 0x7d, 0x0a, // 1 = a_color1;.}.
-	0x0a, 0x00,                                                                                     // ..
+	0x56, 0x53, 0x48, 0x00, 0xb8, 0xbe, 0x22, 0x66, 0x23, 0x69, 0x66, 0x64, 0x65, 0x66, 0x20, 0x47, // VSH..."f#ifdef G
+	0x4c, 0x5f, 0x45, 0x53, 0x0a, 0x70, 0x72, 0x65, 0x63, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x68, // L_ES.precision h
+	0x69, 0x67, 0x68, 0x70, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x3b, 0x0a, 0x23, 0x65, 0x6e, 0x64, // ighp float;.#end
+	0x69, 0x66, 0x20, 0x2f, 0x2f, 0x20, 0x47, 0x4c, 0x5f, 0x45, 0x53, 0x0a, 0x0a, 0x75, 0x6e, 0x69, // if // GL_ES..uni
+	0x66, 0x6f, 0x72, 0x6d, 0x20, 0x6d, 0x61, 0x74, 0x34, 0x20, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, // form mat4 u_mode
+	0x6c, 0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x3b, 0x0a, 0x76, 0x61, 0x72, 0x79, 0x69, // lViewProj;.varyi
+	0x6e, 0x67, 0x20, 0x76, 0x65, 0x63, 0x32, 0x20, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, // ng vec2 v_texcoo
+	0x72, 0x64, 0x30, 0x3b, 0x0a, 0x76, 0x61, 0x72, 0x79, 0x69, 0x6e, 0x67, 0x20, 0x76, 0x65, 0x63, // rd0;.varying vec
+	0x34, 0x20, 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x31, 0x3b, 0x0a, 0x76, 0x61, 0x72, 0x79, // 4 v_color1;.vary
+	0x69, 0x6e, 0x67, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, // ing vec4 v_color
+	0x30, 0x3b, 0x0a, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x20, 0x76, 0x65, 0x63, // 0;.attribute vec
+	0x32, 0x20, 0x61, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x3b, 0x0a, 0x61, // 2 a_texcoord0;.a
+	0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x20, 0x76, 0x65, 0x63, 0x33, 0x20, 0x61, 0x5f, // ttribute vec3 a_
+	0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x3b, 0x0a, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, // position;.attrib
+	0x75, 0x74, 0x65, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x61, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, // ute vec4 a_color
+	0x31, 0x3b, 0x0a, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x20, 0x76, 0x65, 0x63, // 1;.attribute vec
+	0x34, 0x20, 0x61, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x3b, 0x0a, 0x76, 0x6f, 0x69, 0x64, // 4 a_color0;.void
+	0x20, 0x6d, 0x61, 0x69, 0x6e, 0x20, 0x28, 0x29, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x76, 0x65, 0x63, //  main ().{.  vec
+	0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, // 4 tmpvar_1;.  tm
+	0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x2e, 0x77, 0x20, 0x3d, 0x20, 0x31, 0x2e, 0x30, 0x3b, 0x0a, // pvar_1.w = 1.0;.
+	0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x2e, 0x78, 0x79, 0x7a, 0x20, 0x3d, //   tmpvar_1.xyz =
+	0x20, 0x61, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x3b, 0x0a, 0x20, 0x20, 0x67, //  a_position;.  g
+	0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x3d, 0x20, 0x28, 0x75, 0x5f, // l_Position = (u_
+	0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x20, 0x2a, 0x20, // modelViewProj * 
+	0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x76, 0x5f, 0x74, // tmpvar_1);.  v_t
+	0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x20, 0x3d, 0x20, 0x61, 0x5f, 0x74, 0x65, 0x78, // excoord0 = a_tex
+	0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, // coord0;.  v_colo
+	0x72, 0x30, 0x20, 0x3d, 0x20, 0x61, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x3b, 0x0a, 0x20, // r0 = a_color0;. 
+	0x20, 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x31, 0x20, 0x3d, 0x20, 0x61, 0x5f, 0x63, 0x6f, //  v_color1 = a_co
+	0x6c, 0x6f, 0x72, 0x31, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, 0x00,                                     // lor1;.}...
 };
diff --git a/tools/bin/shaderc.exe b/tools/bin/shaderc.exe
index a20695df..40acd5f1 100644
Binary files a/tools/bin/shaderc.exe and b/tools/bin/shaderc.exe differ
diff --git a/tools/shaderc.cpp b/tools/shaderc/shaderc.cpp
similarity index 78%
rename from tools/shaderc.cpp
rename to tools/shaderc/shaderc.cpp
index 704cd607..2b3f66d7 100644
--- a/tools/shaderc.cpp
+++ b/tools/shaderc/shaderc.cpp
@@ -13,6 +13,7 @@
 #include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
+#include <algorithm>
 #include <string>
 #include <vector>
 #include <unordered_map>
@@ -29,20 +30,18 @@ extern "C"
 #	define BX_TRACE(_format, ...) fprintf(stderr, "" _format "\n", ##__VA_ARGS__)
 #endif // DEBUG
 
-#define BX_NAMESPACE 1
+#define BGFX_CHUNK_MAGIC_VSH BX_MAKEFOURCC('V', 'S', 'H', 0x0)
+#define BGFX_CHUNK_MAGIC_FSH BX_MAKEFOURCC('F', 'S', 'H', 0x0)
+
 #include <bx/bx.h>
 
-#if BX_PLATFORM_LINUX
-#	include <stdarg.h>
-
-#	define _stricmp strcasecmp
-#	define _snprintf snprintf
-#endif // BX_PLATFORM_LINUX
-
 #include <bx/commandline.h>
 #include <bx/countof.h>
 #include <bx/endian.h>
 #include <bx/uint32_t.h>
+#include <bx/readerwriter.h>
+#include <bx/string.h>
+#include <bx/hash.h>
 
 #include "glsl_optimizer.h"
 
@@ -267,208 +266,128 @@ static uint32_t s_optimizationLevelDx11[4] =
 };
 #endif // BX_PLATFORM_WINDOWS
 
-class IStreamWriter
+int32_t writef(bx::WriterI* _writer, const char* _format, ...)
 {
-public:
-	virtual ~IStreamWriter() = 0;
-	virtual bool open() = 0;
-	virtual void close() = 0;
-	virtual void writef(const char* _format, ...) = 0;
-	virtual void write(const char* _str) = 0;
-	virtual void write(const void* _data, size_t _size) = 0;
+	va_list argList;
+	va_start(argList, _format);
 
-	template<typename Ty>
-	void write(Ty _value)
+	char temp[2048];
+
+	char* out = temp;
+	int32_t max = sizeof(temp);
+	int32_t len = bx::vsnprintf(out, max, _format, argList);
+	if (len > max)
 	{
-		write(&_value, sizeof(Ty) );
+		out = (char*)alloca(len);
+		len = bx::vsnprintf(out, len, _format, argList);
 	}
 
-	void writeString(const char* _str)
-	{
-		uint16_t len = (uint16_t)strlen(_str);
-		write(len);
-		write(_str);
-		char term = '\0';
-		write(term);
-	}
-};
+	len = _writer->write(out, len);
 
-IStreamWriter::~IStreamWriter()
-{
+	va_end(argList);
+
+	return len;
 }
 
-class FileWriter : public IStreamWriter
+class Bin2cWriter : public bx::CrtFileWriter
 {
 public:
-	FileWriter(const char* _filePath, bool _bigEndian = false)
-		: m_filePath(_filePath)
-		, m_file(NULL)
-		, m_bigEndian(_bigEndian)
+	Bin2cWriter(const char* _name)
+		: m_name(_name)
 	{
 	}
 
-	~FileWriter()
+	virtual ~Bin2cWriter()
 	{
 	}
 
-	bool open()
+	virtual int32_t close() BX_OVERRIDE
 	{
-		BX_CHECK(NULL == m_file, "Still open!");
-
-		m_file = fopen(m_filePath.c_str(), "wb");
-		return NULL != m_file;
+		generate();
+		return bx::CrtFileWriter::close();
 	}
 
-	void close()
+	virtual int32_t write(const void* _data, int32_t _size) BX_OVERRIDE
 	{
-		if (NULL != m_file)
-		{
-			fclose(m_file);
-			m_file = NULL;
-		}
-	}
-
-	void writef(const char* _format, ...)
-	{
-		if (NULL != m_file)
-		{
-			va_list argList;
-			va_start(argList, _format);
-
-			char temp[2048];
-			int len = vsnprintf(temp, sizeof(temp), _format, argList);
-			fwrite(temp, len, 1, m_file);
-
-			va_end(argList);
-		}
-	}
-
-	void write(const char* _str)
-	{
-		if (NULL != m_file)
-		{
-			fwrite(_str, strlen(_str), 1, m_file);
-		}
-	}
-
-	void write(const void* _data, size_t _size)
-	{
-		if (NULL != m_file)
-		{
-			fwrite(_data, _size, 1, m_file);
-		}
+		const char* data = (const char*)_data;
+		m_buffer.insert(m_buffer.end(), data, data+_size);
+		return _size;
 	}
 
 private:
-	std::string m_filePath;
-	FILE* m_file;
-	bool m_bigEndian;
-};
-
-class Bin2cStream : public IStreamWriter
-{
-public:
-	Bin2cStream(const char* _filePath, const char* _name)
-		: m_filePath(_filePath)
-		, m_name(_name)
-		, m_file(NULL)
+	void generate()
 	{
-	}
-
-	~Bin2cStream()
-	{
-	}
-
-	bool open()
-	{
-		BX_CHECK(NULL == m_file, "Still open!");
-
-		m_file = fopen(m_filePath.c_str(), "wb");
-		return NULL != m_file;
-	}
-
-	void close()
-	{
-		if (NULL != m_file)
-		{
 #define HEX_DUMP_WIDTH 16
 #define HEX_DUMP_SPACE_WIDTH 96
 #define HEX_DUMP_FORMAT "%-" BX_STRINGIZE(HEX_DUMP_SPACE_WIDTH) "." BX_STRINGIZE(HEX_DUMP_SPACE_WIDTH) "s"
-			const uint8_t* data = &m_buffer[0];
-			uint32_t size = m_buffer.size();
+		const uint8_t* data = &m_buffer[0];
+		uint32_t size = (uint32_t)m_buffer.size();
 
-			fprintf(m_file, "static const uint8_t %s[%d] =\n{\n", m_name.c_str(), size);
+		outf("static const uint8_t %s[%d] =\n{\n", m_name.c_str(), size);
 
-			if (NULL != data)
+		if (NULL != data)
+		{
+			char hex[HEX_DUMP_SPACE_WIDTH+1];
+			char ascii[HEX_DUMP_WIDTH+1];
+			uint32_t hexPos = 0;
+			uint32_t asciiPos = 0;
+			for (uint32_t ii = 0; ii < size; ++ii)
 			{
-				char hex[HEX_DUMP_SPACE_WIDTH+1];
-				char ascii[HEX_DUMP_WIDTH+1];
-				uint32_t hexPos = 0;
-				uint32_t asciiPos = 0;
-				for (uint32_t ii = 0; ii < size; ++ii)
-				{
-					_snprintf(&hex[hexPos], sizeof(hex)-hexPos, "0x%02x, ", data[asciiPos]);
-					hexPos += 6;
+				_snprintf(&hex[hexPos], sizeof(hex)-hexPos, "0x%02x, ", data[asciiPos]);
+				hexPos += 6;
 
-					ascii[asciiPos] = isprint(data[asciiPos]) && data[asciiPos] != '\\' ? data[asciiPos] : '.';
-					asciiPos++;
+				ascii[asciiPos] = isprint(data[asciiPos]) && data[asciiPos] != '\\' ? data[asciiPos] : '.';
+				asciiPos++;
 
-					if (HEX_DUMP_WIDTH == asciiPos)
-					{
-						ascii[asciiPos] = '\0';
-						fprintf(m_file, "\t" HEX_DUMP_FORMAT "// %s\n", hex, ascii);
-						data += asciiPos;
-						hexPos = 0;
-						asciiPos = 0;
-					}
-				}
-
-				if (0 != asciiPos)
+				if (HEX_DUMP_WIDTH == asciiPos)
 				{
 					ascii[asciiPos] = '\0';
-					fprintf(m_file, "\t" HEX_DUMP_FORMAT "// %s\n", hex, ascii);
+					outf("\t" HEX_DUMP_FORMAT "// %s\n", hex, ascii);
+					data += asciiPos;
+					hexPos = 0;
+					asciiPos = 0;
 				}
 			}
 
-			fprintf(m_file, "};\n");
+			if (0 != asciiPos)
+			{
+				ascii[asciiPos] = '\0';
+				outf("\t" HEX_DUMP_FORMAT "// %s\n", hex, ascii);
+			}
+		}
+
+		outf("};\n");
 #undef HEX_DUMP_WIDTH
 #undef HEX_DUMP_SPACE_WIDTH
 #undef HEX_DUMP_FORMAT
-
-			fclose(m_file);
-			m_file = NULL;
-		}
 	}
 
-	void writef(const char* _format, ...)
+	int32_t outf(const char* _format, ...)
 	{
 		va_list argList;
 		va_start(argList, _format);
 
 		char temp[2048];
-		int len = vsnprintf(temp, sizeof(temp), _format, argList);
-		m_buffer.insert(m_buffer.end(), temp, temp+len);
+		char* out = temp;
+		int32_t max = sizeof(temp);
+		int32_t len = bx::vsnprintf(out, max, _format, argList);
+		if (len > max)
+		{
+			out = (char*)alloca(len);
+			len = bx::vsnprintf(out, len, _format, argList);
+		}
+
+		int32_t size = bx::CrtFileWriter::write(out, len);
 
 		va_end(argList);
+
+		return size;
 	}
 
-	void write(const char* _str)
-	{
-		m_buffer.insert(m_buffer.end(), _str, _str+strlen(_str) );
-	}
-
-	void write(const void* _data, size_t _size)
-	{
-		const char* data = (const char*)_data;
-		m_buffer.insert(m_buffer.end(), data, data+_size);
-	}
-
-private:
 	std::string m_filePath;
 	std::string m_name;
 	typedef std::vector<uint8_t> Buffer;
 	Buffer m_buffer;
-	FILE* m_file;
 };
 
 struct Varying
@@ -492,7 +411,7 @@ public:
 		{
 			m_size = fsize(file);
 			m_data = new char[m_size+1];
-			m_size = fread(m_data, 1, m_size, file);
+			m_size = (uint32_t)fread(m_data, 1, m_size, file);
 			m_data[m_size] = '\0';
 			fclose(file);
 		}
@@ -508,90 +427,16 @@ public:
 		return m_data;
 	}
 
-	long int getSize() const
+	uint32_t getSize() const
 	{
 		return m_size;
 	}
 
 private:
 	char* m_data;
-	long int m_size;
+	uint32_t m_size;
 };
 
-const char* strnl(const char* _str)
-{
-	const char* eol = strstr(_str, "\n\r");
-	if (NULL != eol)
-	{
-		return eol + 2;
-	}
-
-	eol = strstr(_str, "\n");
-	if (NULL != eol)
-	{
-		return eol + 1;
-	}
-
-	return eol + strlen(_str);
-}
-
-const char* streol(const char* _str)
-{
-	const char* eol = strstr(_str, "\n\r");
-	if (NULL != eol)
-	{
-		return eol;
-	}
-
-	eol = strstr(_str, "\n");
-	if (NULL != eol)
-	{
-		return eol;
-	}
-
-	return eol + strlen(_str);
-}
-
-const char* strws(const char* _str)
-{
-	for (; isspace(*_str); ++_str);
-	return _str;
-}
-
-const char* strnws(const char* _str)
-{
-	for (; !isspace(*_str); ++_str);
-	return _str;
-}
-
-const char* strword(const char* _str)
-{
-	for (char ch = *_str++; isalnum(ch) || '_' == ch; ch = *_str++);
-	return _str-1;
-}
-
-const char* strmb(const char* _str, char _open, char _close)
-{
-	int count = 0;
-	for (char ch = *_str++; ch != '\0' && count >= 0; ch = *_str++)
-	{
-		if (ch == _open)
-		{
-			count++;
-		}
-		else if (ch == _close)
-		{
-			count--;
-			if (0 == count)
-			{
-				return _str-1;
-			}
-		}
-	}
-
-	return NULL;
-}
-
 void strins(char* _str, const char* _insert)
 {
 	size_t len = strlen(_insert);
@@ -630,7 +475,7 @@ private:
 	void skipLine()
 	{
 		const char* str = &m_str[m_pos];
-		const char* nl = strnl(str);
+		const char* nl = bx::strnl(str);
 		m_pos += (uint32_t)(nl - str);
 	}
 
@@ -662,7 +507,7 @@ void writeFile(const char* _filePath, void* _data, uint32_t _size)
 	}
 }
 
-bool compileGLSLShader(CommandLine& _cmdLine, const std::string& _code, IStreamWriter& _stream)
+bool compileGLSLShader(bx::CommandLine& _cmdLine, const std::string& _code, bx::WriterI* _writer)
 {
 	const glslopt_shader_type type = tolower(_cmdLine.findOption('\0', "type")[0]) == 'f' ? kGlslOptShaderFragment : kGlslOptShaderVertex;
 
@@ -683,36 +528,34 @@ bool compileGLSLShader(CommandLine& _cmdLine, const std::string& _code, IStreamW
 	const char* profile = _cmdLine.findOption('p');
 	if (NULL == profile)
 	{
-		_stream.write("#ifdef GL_ES\n");
-		_stream.write("precision highp float;\n");
-		_stream.write("#endif // GL_ES\n\n");
+		writef(_writer, "#ifdef GL_ES\n");
+		writef(_writer, "precision highp float;\n");
+		writef(_writer, "#endif // GL_ES\n\n");
 	}
 	else
 	{
-		_stream.writef("#version %s\n\n", profile);
+		writef(_writer, "#version %s\n\n", profile);
 	}
 
-	_stream.write(optimizedShader, strlen(optimizedShader) );
+	_writer->write(optimizedShader, (int32_t)strlen(optimizedShader) );
 	uint8_t nul = 0;
-	_stream.write(nul);
+	bx::write(_writer, nul);
 
 	glslopt_cleanup(ctx);
 
 	return true;
 }
 
-bool compileHLSLShaderDx9(CommandLine& _cmdLine, const std::string& _code, IStreamWriter& _stream)
+bool compileHLSLShaderDx9(bx::CommandLine& _cmdLine, const std::string& _code, bx::WriterI* _writer)
 {
 #if BX_PLATFORM_WINDOWS
 	const char* profile = _cmdLine.findOption('p');
 	if (NULL == profile)
 	{
-		printf("Shader profile must be specified.\n");
+		fprintf(stderr, "Shader profile must be specified.\n");
 		return false;
 	}
 
-	bool bigEndian = _cmdLine.hasArg('\0', "xbox360");
-
 	uint32_t flags = 0;
 	flags |= _cmdLine.hasArg('\0', "debug") ? D3DXSHADER_DEBUG : 0;
 	flags |= _cmdLine.hasArg('\0', "avoid-flow-control") ? D3DXSHADER_AVOID_FLOW_CONTROL : 0;
@@ -736,14 +579,13 @@ bool compileHLSLShaderDx9(CommandLine& _cmdLine, const std::string& _code, IStre
 
 	BX_TRACE("Profile: %s", profile);
 	BX_TRACE("Flags: 0x%08x", flags);
-	BX_TRACE("Big Endian: %s", bigEndian?"true":"false");
 
 	LPD3DXBUFFER code;
 	LPD3DXBUFFER errorMsg;
 	LPD3DXCONSTANTTABLE constantTable;
 
 	HRESULT hr = D3DXCompileShader(_code.c_str()
-		, _code.size()
+		, (uint32_t)_code.size()
 		, NULL
 		, NULL
 		, "main"
@@ -754,10 +596,10 @@ bool compileHLSLShaderDx9(CommandLine& _cmdLine, const std::string& _code, IStre
 		, &constantTable
 		);
 	if (FAILED(hr)
-	||  werror && NULL != errorMsg)
+	|| (werror && NULL != errorMsg) )
 	{
 		printCode(_code.c_str() );
-		fprintf(stderr, "Error: 0x%08x %s\n", hr, errorMsg->GetBufferPointer() );
+		fprintf(stderr, "Error: 0x%08x %s\n", (uint32_t)hr, (const char*)errorMsg->GetBufferPointer() );
 		return false;
 	}
 
@@ -765,7 +607,7 @@ bool compileHLSLShaderDx9(CommandLine& _cmdLine, const std::string& _code, IStre
 	hr = constantTable->GetDesc(&desc);
 	if (FAILED(hr) )
 	{
-		fprintf(stderr, "Error 0x%08x\n", hr);
+		fprintf(stderr, "Error 0x%08x\n", (uint32_t)hr);
 		return false;
 	}
 
@@ -809,19 +651,20 @@ bool compileHLSLShaderDx9(CommandLine& _cmdLine, const std::string& _code, IStre
 	}
 
 	uint16_t count = (uint16_t)uniforms.size();
-	_stream.write(count);
+	bx::write(_writer, count);
 
 	uint32_t fragmentBit = profile[0] == 'p' ? ConstantType::FragmentBit : 0;
 	for (UniformArray::const_iterator it = uniforms.begin(); it != uniforms.end(); ++it)
 	{
 		const Uniform& un = *it;
 		uint8_t nameSize = (uint8_t)un.name.size();
-		_stream.write(nameSize);
-		_stream.write(un.name.c_str(), nameSize);
-		_stream.write<uint8_t>(un.type|fragmentBit);
-		_stream.write(un.num);
-		_stream.write(un.regIndex);
-		_stream.write(un.regCount);
+		bx::write(_writer, nameSize);
+		_writer->write(un.name.c_str(), nameSize);
+		uint8_t type = un.type|fragmentBit;
+		bx::write(_writer, type);
+		bx::write(_writer, un.num);
+		bx::write(_writer, un.regIndex);
+		bx::write(_writer, un.regCount);
 
 		BX_TRACE("%s, %s, %d, %d, %d"
 			, un.name.c_str()
@@ -830,13 +673,14 @@ bool compileHLSLShaderDx9(CommandLine& _cmdLine, const std::string& _code, IStre
 			, un.regIndex
 			, un.regCount
 			);
+		BX_UNUSED(s_constantTypeName);
 	}
 
 	uint16_t shaderSize = (uint16_t)code->GetBufferSize();
-	_stream.write(shaderSize);
-	_stream.write(code->GetBufferPointer(), shaderSize);
+	bx::write(_writer, shaderSize);
+	_writer->write(code->GetBufferPointer(), shaderSize);
 	uint8_t nul = 0;
-	_stream.write(nul);
+	bx::write(_writer, nul);
 
 	if (_cmdLine.hasArg('\0', "disasm") )
 	{
@@ -879,18 +723,16 @@ bool compileHLSLShaderDx9(CommandLine& _cmdLine, const std::string& _code, IStre
 #endif // BX_PLATFORM_WINDOWS
 }
 
-bool compileHLSLShaderDx11(CommandLine& _cmdLine, const std::string& _code, IStreamWriter& _stream)
+bool compileHLSLShaderDx11(bx::CommandLine& _cmdLine, const std::string& _code, bx::WriterI* _writer)
 {
 #if BX_PLATFORM_WINDOWS
 	const char* profile = _cmdLine.findOption('p');
 	if (NULL == profile)
 	{
-		printf("Shader profile must be specified.\n");
+		fprintf(stderr, "Shader profile must be specified.\n");
 		return false;
 	}
 
-	bool bigEndian = _cmdLine.hasArg('\0', "xbox360");
-
 	uint32_t flags = D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY;
 	flags |= _cmdLine.hasArg('\0', "debug") ? D3DCOMPILE_DEBUG : 0;
 	flags |= _cmdLine.hasArg('\0', "avoid-flow-control") ? D3DCOMPILE_AVOID_FLOW_CONTROL : 0;
@@ -919,7 +761,6 @@ bool compileHLSLShaderDx11(CommandLine& _cmdLine, const std::string& _code, IStr
 
 	BX_TRACE("Profile: %s", profile);
 	BX_TRACE("Flags: 0x%08x", flags);
-	BX_TRACE("Big Endian: %s", bigEndian?"true":"false");
 
 	ID3DBlob* code;
 	ID3DBlob* errorMsg;
@@ -937,10 +778,10 @@ bool compileHLSLShaderDx11(CommandLine& _cmdLine, const std::string& _code, IStr
 		, &errorMsg
 		);
 	if (FAILED(hr)
-	||  werror && NULL != errorMsg)
+	|| (werror && NULL != errorMsg) )
 	{
 		printCode(_code.c_str() );
-		fprintf(stderr, BX_FILE_LINE_LITERAL "Error: 0x%08x %s\n", hr, (char*)errorMsg->GetBufferPointer() );
+		fprintf(stderr, BX_FILE_LINE_LITERAL "Error: 0x%08x %s\n", (uint32_t)hr, (char*)errorMsg->GetBufferPointer() );
 		errorMsg->Release();
 		return false;
 	}
@@ -955,7 +796,7 @@ bool compileHLSLShaderDx11(CommandLine& _cmdLine, const std::string& _code, IStr
 		);
 	if (FAILED(hr) )
 	{
-		fprintf(stderr, BX_FILE_LINE_LITERAL "Error: 0x%08x\n", hr);
+		fprintf(stderr, BX_FILE_LINE_LITERAL "Error: 0x%08x\n", (uint32_t)hr);
 		return false;
 	}
 
@@ -963,7 +804,7 @@ bool compileHLSLShaderDx11(CommandLine& _cmdLine, const std::string& _code, IStr
 	hr = reflect->GetDesc(&desc);
 	if (FAILED(hr) )
 	{
-		fprintf(stderr, BX_FILE_LINE_LITERAL "Error: 0x%08x\n", hr);
+		fprintf(stderr, BX_FILE_LINE_LITERAL "Error: 0x%08x\n", (uint32_t)hr);
 		return false;
 	}
 
@@ -995,7 +836,7 @@ bool compileHLSLShaderDx11(CommandLine& _cmdLine, const std::string& _code, IStr
 		}
 	}
 
-	_stream.write(attrMask, sizeof(attrMask) );
+	_writer->write(attrMask, sizeof(attrMask) );
 
 	BX_TRACE("Output:");
 	for (uint32_t ii = 0; ii < desc.OutputParameters; ++ii)
@@ -1084,21 +925,22 @@ bool compileHLSLShaderDx11(CommandLine& _cmdLine, const std::string& _code, IStr
 	}
 
 	uint16_t count = (uint16_t)uniforms.size();
-	_stream.write(count);
+	bx::write(_writer, count);
 
-	_stream.write(size);
+	bx::write(_writer, size);
 
 	uint32_t fragmentBit = profile[0] == 'p' ? ConstantType::FragmentBit : 0;
 	for (UniformArray::const_iterator it = uniforms.begin(); it != uniforms.end(); ++it)
 	{
 		const Uniform& un = *it;
 		uint8_t nameSize = (uint8_t)un.name.size();
-		_stream.write(nameSize);
-		_stream.write(un.name.c_str(), nameSize);
-		_stream.write<uint8_t>(un.type|fragmentBit);
-		_stream.write(un.num);
-		_stream.write(un.regIndex);
-		_stream.write(un.regCount);
+		bx::write(_writer, nameSize);
+		_writer->write(un.name.c_str(), nameSize);
+		uint8_t type = un.type|fragmentBit;
+		bx::write(_writer, type);
+		bx::write(_writer, un.num);
+		bx::write(_writer, un.regIndex);
+		bx::write(_writer, un.regCount);
 
 		BX_TRACE("%s, %s, %d, %d, %d"
 			, un.name.c_str()
@@ -1110,10 +952,10 @@ bool compileHLSLShaderDx11(CommandLine& _cmdLine, const std::string& _code, IStr
 	}
 
 	uint16_t shaderSize = (uint16_t)code->GetBufferSize();
-	_stream.write(shaderSize);
-	_stream.write(code->GetBufferPointer(), shaderSize);
+	bx::write(_writer, shaderSize);
+	_writer->write(code->GetBufferPointer(), shaderSize);
 	uint8_t nul = 0;
-	_stream.write(nul);
+	bx::write(_writer, nul);
 
 	if (_cmdLine.hasArg('\0', "disasm") )
 	{
@@ -1130,7 +972,7 @@ bool compileHLSLShaderDx11(CommandLine& _cmdLine, const std::string& _code, IStr
 			std::string ofp = _cmdLine.findOption('o');
 			ofp += ".disasm";
 
-			writeFile(ofp.c_str(), disasm->GetBufferPointer(), disasm->GetBufferSize() );
+			writeFile(ofp.c_str(), disasm->GetBufferPointer(), (uint32_t)disasm->GetBufferSize() );
 			disasm->Release();
 		}
 	}
@@ -1206,7 +1048,7 @@ struct Preprocessor
 	void setDefaultDefine(const char* _name)
 	{
 		char temp[1024];
-		_snprintf(temp, countof(temp)
+		bx::snprintf(temp, countof(temp)
 			, "#ifndef %s\n"
 			  "#	define %s 0\n"
 			  "#endif // %s\n"
@@ -1223,11 +1065,7 @@ struct Preprocessor
 	{
 		va_list argList;
 		va_start(argList, _format);
-
-		char temp[2048];
-		int len = vsnprintf(temp, sizeof(temp), _format, argList);
-		m_default += temp;
-
+		m_default += bx::stringPrintfVargs(_format, argList);
 		va_end(argList);
 	}
 
@@ -1242,6 +1080,7 @@ struct Preprocessor
 		m_fgetsPos = 0;
 
 		m_input = m_default;
+		m_input += "\n\n";
 		m_input += _input;
 
 		fppTag* tagptr = m_tagptr;
@@ -1300,7 +1139,7 @@ struct Preprocessor
 	{
 		char* result = &m_scratch[m_scratchPos];
 		strcpy(result, _str);
-		m_scratchPos += strlen(_str)+1;
+		m_scratchPos += (uint32_t)strlen(_str)+1;
 
 		return result;
 	}
@@ -1331,6 +1170,44 @@ const char* baseName(const char* _filePath)
 	return _filePath;
 }
 
+typedef std::vector<std::string> InOut;
+
+uint32_t parseInOut(InOut& _inout, const char* _str, const char* _eol)
+{
+	uint32_t hash = 0;
+	_str = bx::strws(_str);
+
+	if (_str < _eol)
+	{
+		const char* delim;
+		do
+		{
+			delim = strpbrk(_str, " ,");
+			if (NULL != delim)
+			{
+				delim = delim > _eol ? _eol : delim;
+				std::string token;
+				token.assign(_str, delim-_str);
+				_inout.push_back(token);
+				_str = bx::strws(delim + 1);
+			}
+		}
+		while (delim < _eol && NULL != delim);
+
+		std::sort(_inout.begin(), _inout.end() );
+
+		bx::HashMurmur2A murmur;
+		murmur.begin();
+		for (InOut::const_iterator it = _inout.begin(), itEnd = _inout.end(); it != itEnd; ++it)
+		{
+			murmur.add(it->c_str(), it->size() );
+		}
+		hash = murmur.end();
+	}
+
+	return hash;
+}
+
 // OpenGL #version Features Direct3D Features Shader Model
 // 2.1    120      vf       9.0      vf       2.0
 // 3.0    130
@@ -1382,7 +1259,7 @@ void help(const char* _error = NULL)
 
 int main(int _argc, const char* _argv[])
 {
-	CommandLine cmdLine(_argc, _argv);
+	bx::CommandLine cmdLine(_argc, _argv);
 
 	if (cmdLine.hasArg('h', "help") )
 	{
@@ -1443,7 +1320,7 @@ int main(int _argc, const char* _argv[])
 		if (NULL == bin2c)
 		{
 			bin2c = baseName(outFilePath);
-			uint32_t len = strlen(bin2c);
+			uint32_t len = (uint32_t)strlen(bin2c);
 			char* temp = (char*)alloca(len+1);
 			for (char *out = temp; *bin2c != '\0';)
 			{
@@ -1482,44 +1359,44 @@ int main(int _argc, const char* _argv[])
 
 	bool glsl = false;
 
-	if (0 == _stricmp(platform, "android") )
+	if (0 == bx::stricmp(platform, "android") )
 	{
 		preprocessor.setDefine("BX_PLATFORM_ANDROID=1");
 		preprocessor.setDefine("BGFX_SHADER_LANGUAGE_GLSL=1");
 		glsl = true;
 	}
-	else if (0 == _stricmp(platform, "ios") )
+	else if (0 == bx::stricmp(platform, "ios") )
 	{
 		preprocessor.setDefine("BX_PLATFORM_IOS=1");
 		preprocessor.setDefine("BGFX_SHADER_LANGUAGE_GLSL=1");
 		glsl = true;
 	}
-	else if (0 == _stricmp(platform, "linux") )
+	else if (0 == bx::stricmp(platform, "linux") )
 	{
 		preprocessor.setDefine("BX_PLATFORM_IOS=1");
 		preprocessor.setDefine("BGFX_SHADER_LANGUAGE_GLSL=1");
 		glsl = true;
 	}
-	else if (0 == _stricmp(platform, "nacl") )
+	else if (0 == bx::stricmp(platform, "nacl") )
 	{
 		preprocessor.setDefine("BX_PLATFORM_NACL=1");
 		preprocessor.setDefine("BGFX_SHADER_LANGUAGE_GLSL=1");
 		glsl = true;
 	}
-	else if (0 == _stricmp(platform, "osx") )
+	else if (0 == bx::stricmp(platform, "osx") )
 	{
 		preprocessor.setDefine("BX_PLATFORM_OSX=1");
 		preprocessor.setDefine("BGFX_SHADER_LANGUAGE_GLSL=1");
 		glsl = true;
 	}
-	else if (0 == _stricmp(platform, "windows") )
+	else if (0 == bx::stricmp(platform, "windows") )
 	{
 		preprocessor.setDefine("BX_PLATFORM_WINDOWS=1");
 		char temp[256];
-		_snprintf(temp, sizeof(temp), "BGFX_SHADER_LANGUAGE_HLSL=%d", hlsl);
+		bx::snprintf(temp, sizeof(temp), "BGFX_SHADER_LANGUAGE_HLSL=%d", hlsl);
 		preprocessor.setDefine(temp);
 	}
-	else if (0 == _stricmp(platform, "xbox360") )
+	else if (0 == bx::stricmp(platform, "xbox360") )
 	{
 		preprocessor.setDefine("BX_PLATFORM_XBOX360=1");
 		preprocessor.setDefine("BGFX_SHADER_LANGUAGE_HLSL=3");
@@ -1559,16 +1436,16 @@ int main(int _argc, const char* _argv[])
 		while (NULL != parse
 		   &&  *parse != '\0')
 		{
-			parse = strws(parse);
+			parse = bx::strws(parse);
 			const char* eol = strchr(parse, ';');
 			if (NULL != eol)
 			{
 				const char* type = parse;
-				const char* name = parse = strws(strword(parse) );
-				const char* column = parse = strws(strword(parse) );
-				const char* semantics = parse = strws(strnws(parse) );
-				const char* assign = parse = strws(strword(parse) );
-				const char* init = parse = strws(strnws(parse) );
+				const char* name = parse = bx::strws(bx::strword(parse) );
+				const char* column = parse = bx::strws(bx::strword(parse) );
+				const char* semantics = parse = bx::strws(bx::strnws(parse) );
+				const char* assign = parse = bx::strws(bx::strword(parse) );
+				const char* init = parse = bx::strws(bx::strnws(parse) );
 
 				if (type < eol
 				&&  name < eol
@@ -1577,9 +1454,9 @@ int main(int _argc, const char* _argv[])
 				&&  semantics < eol)
 				{
 					Varying var;
-					var.m_type.assign(type, strword(type)-type);
-					var.m_name.assign(name, strword(name)-name);
-					var.m_semantics.assign(semantics, strword(semantics)-semantics);
+					var.m_type.assign(type, bx::strword(type)-type);
+					var.m_name.assign(name, bx::strword(name)-name);
+					var.m_semantics.assign(semantics, bx::strword(semantics)-semantics);
 
 					if (assign < eol
 					&&  '=' == *assign
@@ -1596,69 +1473,34 @@ int main(int _argc, const char* _argv[])
 		}
 
 		const size_t padding = 16;
-		long int size = fsize(file);
+		uint32_t size = (uint32_t)fsize(file);
  		char* data = new char[size+padding];
- 		size = fread(data, 1, size, file);
+ 		size = (uint32_t)fread(data, 1, size, file);
 		memset(&data[size], 0, padding);
 		fclose(file);
 
-		typedef std::vector<std::string> InOut;
 		InOut shaderInputs;
 		InOut shaderOutputs;
+		uint32_t inputHash = 0;
+		uint32_t outputHash = 0;
 
 		const char* input = data;
 		while (input[0] == '$')
 		{
 			const char* str = input+1;
-			const char* eol = streol(str);
-			const char* nl = strnl(eol);
+			const char* eol = bx::streol(str);
+			const char* nl = bx::strnl(eol);
 			input = nl;
 
 			if (0 == strncmp(str, "input", 5) )
 			{
 				str += 5;
-				str = strws(str);
-
-				if (str < eol)
-				{
-					const char* delim;
-					do
-					{
-						delim = strpbrk(str, " ,");
-						if (NULL != delim)
-						{
-							delim = delim > eol ? eol : delim;
-							std::string token;
-							token.assign(str, delim-str);
-							shaderInputs.push_back(token);
-							str = strws(delim + 1);
-						}
-					}
-					while (delim < eol && NULL != delim);
-				}
+				inputHash = parseInOut(shaderInputs, str, eol);
 			}
 			else if (0 == strncmp(str, "output", 6) )
 			{
 				str += 6;
-				str = strws(str);
-
-				if (str < eol)
-				{
-					const char* delim;
-					do
-					{
-						delim = strpbrk(str, " ,");
-						if (NULL != delim)
-						{
-							delim = delim > eol ? eol : delim;
-							std::string token;
-							token.assign(str, delim-str);
-							shaderOutputs.push_back(token);
-							str = strws(delim + 1);
-						}
-					}
-					while (delim < eol && NULL != delim);
-				}
+				outputHash = parseInOut(shaderOutputs, str, eol);
 			}
 		}
 
@@ -1756,7 +1598,7 @@ int main(int _argc, const char* _argv[])
 					const char* brace = strstr(entry, "{");
 					if (NULL != brace)
 					{
-						const char* end = strmb(brace, '{', '}');
+						const char* end = bx::strmb(brace, '{', '}');
 						if (NULL != end)
 						{
 							strins(const_cast<char*>(end), "__RETURN__;\n");
@@ -1828,9 +1670,9 @@ int main(int _argc, const char* _argv[])
 
 			if (preprocessOnly)
 			{
-				FileWriter stream(outFilePath);
+				bx::CrtFileWriter writer;
 
-				if (!stream.open() )
+				if (0 != writer.open(outFilePath) )
 				{
 					fprintf(stderr, "Unable to open output file '%s'.", outFilePath);
 					return false;
@@ -1841,17 +1683,17 @@ int main(int _argc, const char* _argv[])
 					const char* profile = cmdLine.findOption('p');
 					if (NULL == profile)
 					{
-						stream.write("#ifdef GL_ES\n");
-						stream.write("precision highp float;\n");
-						stream.write("#endif // GL_ES\n\n");
+						writef(&writer, "#ifdef GL_ES\n");
+						writef(&writer, "precision highp float;\n");
+						writef(&writer, "#endif // GL_ES\n\n");
 					}
 					else
 					{
-						stream.writef("#version %s\n\n", profile);
+						writef(&writer, "#version %s\n\n", profile);
 					}
 				}
-				stream.write(preprocessor.m_preprocessed.c_str(), preprocessor.m_preprocessed.size() );
-				stream.close();
+				writer.write(preprocessor.m_preprocessed.c_str(), (int32_t)preprocessor.m_preprocessed.size() );
+				writer.close();
 
 				return EXIT_SUCCESS;
 			}
@@ -1859,45 +1701,52 @@ int main(int _argc, const char* _argv[])
 			bool compiled = false;
 
 			{
-				IStreamWriter* stream = NULL;
+				bx::CrtFileWriter* writer = NULL;
 
 				if (NULL != bin2c)
 				{
-					stream = new Bin2cStream(outFilePath, bin2c);
+					writer = new Bin2cWriter(bin2c);
 				}
 				else
 				{
-					stream = new FileWriter(outFilePath);
+					writer = new bx::CrtFileWriter;
 				}
 
-				if (!stream->open() )
+				if (0 != writer->open(outFilePath) )
 				{
 					fprintf(stderr, "Unable to open output file '%s'.", outFilePath);
 					return false;
 				}
 
+				if (fragment)
+				{
+					bx::write(writer, BGFX_CHUNK_MAGIC_FSH);
+					bx::write(writer, inputHash);
+				}
+				else
+				{
+					bx::write(writer, BGFX_CHUNK_MAGIC_VSH);
+					bx::write(writer, outputHash);
+				}
+
 				if (glsl)
 				{
-					compiled = compileGLSLShader(cmdLine, preprocessor.m_preprocessed, *stream);
+					compiled = compileGLSLShader(cmdLine, preprocessor.m_preprocessed, writer);
 				}
 				else
 				{
 					if (hlsl > 3)
 					{
-						compiled = compileHLSLShaderDx11(cmdLine, preprocessor.m_preprocessed, *stream);
+						compiled = compileHLSLShaderDx11(cmdLine, preprocessor.m_preprocessed, writer);
 					}
 					else
 					{
-						compiled = compileHLSLShaderDx9(cmdLine, preprocessor.m_preprocessed, *stream);
+						compiled = compileHLSLShaderDx9(cmdLine, preprocessor.m_preprocessed, writer);
 					}
 				}
 
-#if SHADERC_DEBUG
-				stream->writeString(filePath);
-#endif // SHADERC_DEBUG
-
-				stream->close();
-				delete stream;
+				writer->close();
+				delete writer;
 			}
 
 			if (compiled)
@@ -1906,14 +1755,11 @@ int main(int _argc, const char* _argv[])
 				{
 					std::string ofp = outFilePath;
 					ofp += ".d";
-					FileWriter stream(ofp.c_str() );
-					if (stream.open() )
+					bx::CrtFileWriter writer;
+					if (0 == writer.open(ofp.c_str() ) )
 					{
-						stream.write(outFilePath);
-						stream.write(":");
-						stream.write(preprocessor.m_depends.c_str() );
-						stream.write("\n");
-						stream.close();
+						writef(&writer, "%s : %s\n", outFilePath, preprocessor.m_depends.c_str() );
+						writer.close();
 					}
 				}
 
diff --git a/tools/ddsdump.cpp b/tools/texturec/texturec.cpp
similarity index 91%
rename from tools/ddsdump.cpp
rename to tools/texturec/texturec.cpp
index 351c282d..69886858 100644
--- a/tools/ddsdump.cpp
+++ b/tools/texturec/texturec.cpp
@@ -17,7 +17,6 @@ using namespace bgfx;
 #	define BX_TRACE(_format, ...) fprintf(stderr, "" _format "\n", ##__VA_ARGS__)
 #endif // DEBUG
 
-#define BX_NAMESPACE 1
 #include <bx/bx.h>
 #include <bx/commandline.h>
 #include <bx/uint32_t.h>
@@ -95,7 +94,7 @@ long int fsize(FILE* _file)
 
 int main(int _argc, const char* _argv[])
 {
-	CommandLine cmdLine(_argc, _argv);
+	bx::CommandLine cmdLine(_argc, _argv);
 
 	FILE* file = fopen(_argv[1], "rb");
 	uint32_t size = fsize(file);
@@ -157,7 +156,7 @@ int main(int _argc, const char* _argv[])
 						}
 
 						char filePath[256];
-						_snprintf(filePath, sizeof(filePath), "mip%d_%d.tga", side, lod);
+						bx::snprintf(filePath, sizeof(filePath), "mip%d_%d.tga", side, lod);
 
 						saveTga(filePath, width, height, dstpitch, bits);
 						free(bits);
@@ -176,7 +175,7 @@ int main(int _argc, const char* _argv[])
 				if (getRawImageData(dds, 0, lod, mem, mip) )
 				{
 					char filePath[256];
-					_snprintf(filePath, sizeof(filePath), "mip%d.bin", lod);
+					bx::snprintf(filePath, sizeof(filePath), "mip%d.bin", lod);
 					file = fopen(filePath, "wb");
 					fwrite(mip.m_data, 1, mip.m_size, file);
 					fclose(file);