diff --git a/o3d/command_buffer/client/cross/cmd_buffer_helper.cc b/o3d/command_buffer/client/cross/cmd_buffer_helper.cc
index 481f0c7011f12ed28e2eb15b5543d26dca3b3886..f8445767d673fd1a28bdabc7798832f6057d9138 100644
--- a/o3d/command_buffer/client/cross/cmd_buffer_helper.cc
+++ b/o3d/command_buffer/client/cross/cmd_buffer_helper.cc
@@ -162,7 +162,7 @@ void CommandBufferHelper::WaitForAvailableEntries(unsigned int count) {
     // buffer, so we need to wrap. We will add noops all the way to the end,
     // but we need to make sure get wraps first, actually that get is 1 or
     // more (since put will wrap to 0 after we add the noops).
-    DCHECK_LE(1, put_);
+    DCHECK_LE(1U, put_);
     Flush();
     while (get_ > put_ || get_ == 0) WaitForGetChange();
     // Add the noops. By convention, a noop is a command 0 with no args.
diff --git a/o3d/command_buffer/client/cross/effect_helper.cc b/o3d/command_buffer/client/cross/effect_helper.cc
index 1f05dd8e54f36b37aa66f70a190d6bd001355922..ced1b3b80224598d934d9b3deaf84d375ba804a8 100644
--- a/o3d/command_buffer/client/cross/effect_helper.cc
+++ b/o3d/command_buffer/client/cross/effect_helper.cc
@@ -175,7 +175,7 @@ bool EffectHelper::GetParamStrings(EffectParamDesc *desc) {
   const char *raw_desc_string = reinterpret_cast<char *>(raw_desc);
   if (raw_desc->name_offset) {
     DCHECK_LE(raw_desc->name_offset + raw_desc->name_size, raw_desc->size);
-    DCHECK_GT(raw_desc->name_size, 0);
+    DCHECK_GT(raw_desc->name_size, 0U);
     DCHECK_EQ(raw_desc_string[raw_desc->name_offset + raw_desc->name_size - 1],
               0);
     desc->name = String(raw_desc_string + raw_desc->name_offset,
@@ -186,7 +186,7 @@ bool EffectHelper::GetParamStrings(EffectParamDesc *desc) {
   if (raw_desc->semantic_offset) {
     DCHECK_LE(raw_desc->semantic_offset + raw_desc->semantic_size,
               raw_desc->size);
-    DCHECK_GT(raw_desc->semantic_size, 0);
+    DCHECK_GT(raw_desc->semantic_size, 0U);
     DCHECK_EQ(raw_desc_string[raw_desc->semantic_offset +
                               raw_desc->semantic_size - 1],
               0);
diff --git a/o3d/command_buffer/command_buffer.gyp b/o3d/command_buffer/command_buffer.gyp
new file mode 100644
index 0000000000000000000000000000000000000000..4e3df3009e964de6063d200ef1413dade938d88a
--- /dev/null
+++ b/o3d/command_buffer/command_buffer.gyp
@@ -0,0 +1,165 @@
+# Copyright (c) 2009 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+{
+  'variables': {
+    'chromium_code': 1,
+  },
+  'includes': [
+    '../build/common.gypi',
+  ],
+  'target_defaults': {
+    'include_dirs': [
+      '..',
+      '../..',
+      '../../<(gtestdir)',
+      '../../<(nacldir)',
+    ],
+    'defines': [
+    ],
+    'conditions': [
+      ['OS == "win"',
+        {
+          'include_dirs': [
+            '$(DXSDK_DIR)/Include',
+          ],
+        }
+      ],
+      ['OS == "mac" or OS == "linux"',
+        {
+          'include_dirs': [
+            '../../<(glewdir)/include',
+            '../../<(cgdir)/include',
+          ],
+        },
+      ],
+    ],
+  },
+  'targets': [
+    {
+      'target_name': 'command_buffer_common',
+      'type': 'static_library',
+      'dependencies': [
+        '../../native_client/src/shared/imc/imc.gyp:google_nacl_imc',
+        '../../native_client/src/shared/imc/imc.gyp:libgoogle_nacl_imc_c',
+        '../../native_client/src/shared/platform/platform.gyp:platform',
+        '../../native_client/src/trusted/desc/desc.gyp:nrd_xfer',
+        '../../native_client/src/trusted/service_runtime/service_runtime.gyp:gio',
+      ],
+      'sources': [
+        'common/cross/bitfield_helpers.h',
+        'common/cross/buffer_sync_api.cc',
+        'common/cross/buffer_sync_api.h',
+        'common/cross/cmd_buffer_format.h',
+        'common/cross/gapi_interface.h',
+        'common/cross/logging.h',
+        'common/cross/mocks.h',
+        'common/cross/resource.cc',
+        'common/cross/resource.h',
+        'common/cross/rpc.h',
+        'common/cross/rpc_imc.cc',
+        'common/cross/rpc_imc.h',
+        'common/cross/types.h',
+      ],
+    },
+    {
+      'target_name': 'command_buffer_client',
+      'type': 'static_library',
+      'dependencies': [
+        'command_buffer_common',
+      ],
+      'sources': [
+        'client/cross/buffer_sync_proxy.cc',
+        'client/cross/buffer_sync_proxy.h',
+        'client/cross/cmd_buffer_helper.cc',
+        'client/cross/cmd_buffer_helper.h',
+        'client/cross/effect_helper.cc',
+        'client/cross/effect_helper.h',
+        'client/cross/fenced_allocator.cc',
+        'client/cross/fenced_allocator.h',
+        'client/cross/id_allocator.cc',
+        'client/cross/id_allocator.h',
+      ],
+    },
+    {
+      'target_name': 'command_buffer_service',
+      'type': 'static_library',
+      'dependencies': [
+        'command_buffer_common',
+      ],
+      'sources': [
+        'service/cross/buffer_rpc.cc',
+        'service/cross/buffer_rpc.h',
+        'service/cross/cmd_buffer_engine.cc',
+        'service/cross/cmd_buffer_engine.h',
+        'service/cross/cmd_parser.cc',
+        'service/cross/cmd_parser.h',
+        'service/cross/effect_utils.cc',
+        'service/cross/effect_utils.h',
+        'service/cross/gapi_decoder.cc',
+        'service/cross/gapi_decoder.h',
+        'service/cross/mocks.h',
+        'service/cross/precompile.cc',
+        'service/cross/precompile.h',
+        'service/cross/resource.cc',
+        'service/cross/resource.h',
+        'service/cross/texture_utils.cc',
+        'service/cross/texture_utils.h',
+      ],
+      'conditions': [
+        ['OS == "win"',
+          {
+            'sources': [
+              'service/win/d3d9/d3d9_utils.h',
+              'service/win/d3d9/effect_d3d9.cc',
+              'service/win/d3d9/effect_d3d9.h',
+              'service/win/d3d9/gapi_d3d9.cc',
+              'service/win/d3d9/gapi_d3d9.h',
+              'service/win/d3d9/geometry_d3d9.cc',
+              'service/win/d3d9/geometry_d3d9.h',
+              'service/win/d3d9/render_surface_d3d9.cc',
+              'service/win/d3d9/render_surface_d3d9.h',
+              'service/win/d3d9/sampler_d3d9.cc',
+              'service/win/d3d9/sampler_d3d9.h',
+              'service/win/d3d9/states_d3d9.cc',
+              'service/win/d3d9/texture_d3d9.cc',
+              'service/win/d3d9/texture_d3d9.h',
+            ],  # 'sources'
+            'direct_dependent_settings': {
+              'include_dirs': [
+                '$(DXSDK_DIR)/Include',
+              ],
+            },  # 'direct_dependent_settings'
+          },
+        ],
+        ['OS == "mac" or OS == "linux"',
+          {
+            'sources': [
+              'service/cross/gl/effect_gl.cc',
+              'service/cross/gl/effect_gl.h',
+              'service/cross/gl/gapi_gl.cc',
+              'service/cross/gl/gapi_gl.h',
+              'service/cross/gl/geometry_gl.cc',
+              'service/cross/gl/geometry_gl.h',
+              'service/cross/gl/gl_utils.h',
+              'service/cross/gl/sampler_gl.cc',
+              'service/cross/gl/sampler_gl.h',
+              'service/cross/gl/states_gl.cc',
+              'service/cross/gl/texture_gl.cc',
+              'service/cross/gl/texture_gl.h',
+            ],  # 'sources'
+          },
+        ],
+        ['OS == "linux"',
+          {
+            'sources': [
+              'service/linux/x_utils.cc',
+              'service/linux/x_utils.h',
+            ],
+          },
+        ],
+      ],  # 'conditions'
+    },
+  ],
+}
diff --git a/o3d/command_buffer/common/cross/buffer_sync_api.h b/o3d/command_buffer/common/cross/buffer_sync_api.h
index a56120564f5573dd5b742ea6ec1feeaeba6b96d7..62d6011ee1daf33439e42bc5caacc9f20a7025be 100644
--- a/o3d/command_buffer/common/cross/buffer_sync_api.h
+++ b/o3d/command_buffer/common/cross/buffer_sync_api.h
@@ -41,7 +41,7 @@ namespace o3d {
 namespace command_buffer {
 
 // Command buffer type.
-typedef ptrdiff_t CommandBufferOffset;
+typedef size_t CommandBufferOffset;
 
 // Interface class for the Command Buffer Synchronous API.
 // This is the part of the command buffer API that is accessible through the
diff --git a/o3d/command_buffer/common/cross/resource.h b/o3d/command_buffer/common/cross/resource.h
index e6b6f09076b5a4f1e0932c3e375900187ebba125..5557d6765110ff065dd8f4c4cb0e25c6878c2673 100644
--- a/o3d/command_buffer/common/cross/resource.h
+++ b/o3d/command_buffer/common/cross/resource.h
@@ -197,7 +197,7 @@ unsigned int GetBlockSizeY(Format format);
 // down.
 static unsigned int GetMipMapDimension(unsigned int base,
                                        unsigned int level) {
-  DCHECK_GT(base, 0);
+  DCHECK_GT(base, 0U);
   return std::max(1U, base >> level);
 }
 }  // namespace texture
diff --git a/o3d/command_buffer/common/cross/rpc.h b/o3d/command_buffer/common/cross/rpc.h
index fb55a880ccbdaff786866203f06ac8a3c8e37790..6e95ee2269d2370e0f1051eed471a7ceea584f7b 100644
--- a/o3d/command_buffer/common/cross/rpc.h
+++ b/o3d/command_buffer/common/cross/rpc.h
@@ -35,7 +35,7 @@
 
 #include "base/basictypes.h"
 
-#include "third_party/native_client/googleclient/native_client/src/shared/imc/nacl_htp.h"
+#include "native_client/src/shared/imc/nacl_htp.h"
 
 namespace o3d {
 namespace command_buffer {
diff --git a/o3d/command_buffer/common/cross/rpc_fake.cc b/o3d/command_buffer/common/cross/rpc_fake.cc
index ed09b9010daf9f6b38303a2c19a05d0ca839d8aa..028c753d9a0719f5afedabf4b5cf01544a1f76af 100644
--- a/o3d/command_buffer/common/cross/rpc_fake.cc
+++ b/o3d/command_buffer/common/cross/rpc_fake.cc
@@ -141,7 +141,7 @@ bool RPCServer::Processor::ProcessMessage() {
   RPCMessage input;
   in_queue_->GetMessage(&input);
   RPCImplInterface::ReturnValue result = 0;
-  int continue_processing = true;
+  bool continue_processing = true;
   if (input.message_id == POISONED_MESSAGE_ID) {
     continue_processing = false;
   } else {
diff --git a/o3d/command_buffer/common/cross/rpc_fake.h b/o3d/command_buffer/common/cross/rpc_fake.h
index c7727c5ea6440e605d07855f0d9326176dd69bc0..11eb25813f059e7520e45636b49a381adf8c0ba6 100644
--- a/o3d/command_buffer/common/cross/rpc_fake.h
+++ b/o3d/command_buffer/common/cross/rpc_fake.h
@@ -40,6 +40,7 @@
 
 #include <windows.h>
 #include <queue>
+#include "base/scoped_ptr.h"
 #include "core/cross/types.h"
 #include "command_buffer/common/cross/rpc.h"
 
diff --git a/o3d/command_buffer/common/cross/rpc_imc.cc b/o3d/command_buffer/common/cross/rpc_imc.cc
index 5d6c1f7a7a620b774764aed4798eaa9693cb6e58..f5c3c9ed852ee7603a58c5a1d21a331212493f56 100644
--- a/o3d/command_buffer/common/cross/rpc_imc.cc
+++ b/o3d/command_buffer/common/cross/rpc_imc.cc
@@ -33,7 +33,7 @@
 #include <algorithm>
 #include "command_buffer/common/cross/logging.h"
 #include "command_buffer/common/cross/rpc_imc.h"
-#include "third_party/native_client/googleclient/native_client/src/shared/imc/nacl_htp.h"
+#include "native_client/src/shared/imc/nacl_htp.h"
 
 namespace o3d {
 namespace command_buffer {
diff --git a/o3d/command_buffer/common/cross/rpc_imc.h b/o3d/command_buffer/common/cross/rpc_imc.h
index 8e4aed48f29c636dc0e98efe83cb72ed6ff1db0e..097fb1c006a936b36f64d5a97cd14bdf6fc944e1 100644
--- a/o3d/command_buffer/common/cross/rpc_imc.h
+++ b/o3d/command_buffer/common/cross/rpc_imc.h
@@ -33,7 +33,7 @@
 #ifndef O3D_COMMAND_BUFFER_COMMON_CROSS_RPC_IMC_H_
 #define O3D_COMMAND_BUFFER_COMMON_CROSS_RPC_IMC_H_
 
-#include "third_party/native_client/googleclient/native_client/src/shared/imc/nacl_imc.h"
+#include "native_client/src/shared/imc/nacl_imc.h"
 #include "base/scoped_ptr.h"
 #include "command_buffer/common/cross/rpc.h"
 
diff --git a/o3d/command_buffer/service/cross/gapi_decoder.cc b/o3d/command_buffer/service/cross/gapi_decoder.cc
index d37f7e08461b3d735e98517fb46821a06784595f..30877337d86240feddfbb2a676a3ae9725e436a7 100644
--- a/o3d/command_buffer/service/cross/gapi_decoder.cc
+++ b/o3d/command_buffer/service/cross/gapi_decoder.cc
@@ -472,8 +472,10 @@ BufferSyncInterface::ParseError GAPIDecoder::DoCommand(
         Uint32 enables = args[0].value_uint32;
         if (cmd::Unused::Get(enables) != 0)
           return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
-        bool line_smooth = cmd::LineSmoothEnable::Get(enables);
-        bool point_sprite = cmd::PointSpriteEnable::Get(enables);
+        // !! to convert int to bool in a way that does not generate a
+        // warning in visual studio.
+        bool line_smooth = !!cmd::LineSmoothEnable::Get(enables);
+        bool point_sprite = !!cmd::PointSpriteEnable::Get(enables);
         float point_size = args[1].value_float;
         gapi_->SetPointLineRaster(line_smooth, point_sprite, point_size);
         return BufferSyncInterface::PARSE_NO_ERROR;
@@ -673,7 +675,7 @@ BufferSyncInterface::ParseError GAPIDecoder::DecodeCreateTexture2D(
         (unused != 0) || (format >= texture::NUM_FORMATS))
       return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
     if (levels == 0) levels = max_levels;
-    bool enable_render_surfaces = flags;
+    bool enable_render_surfaces = !!flags;
     return gapi_->CreateTexture2D(id, width, height, levels,
                                   static_cast<texture::Format>(format), flags,
                                   enable_render_surfaces);
@@ -707,7 +709,7 @@ BufferSyncInterface::ParseError GAPIDecoder::DecodeCreateTexture3D(
         (format >= texture::NUM_FORMATS))
       return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
     if (levels == 0) levels = max_levels;
-    bool enable_render_surfaces = flags;
+    bool enable_render_surfaces = !!flags;
     return gapi_->CreateTexture3D(id, width, height, depth, levels,
                                   static_cast<texture::Format>(format), flags,
                                   enable_render_surfaces);
@@ -736,7 +738,7 @@ BufferSyncInterface::ParseError GAPIDecoder::DecodeCreateTextureCube(
         (unused2 != 0) || (format >= texture::NUM_FORMATS))
       return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
     if (levels == 0) levels = max_levels;
-    bool enable_render_surfaces = flags;
+    bool enable_render_surfaces = !!flags;
     return gapi_->CreateTextureCube(id, side, levels,
                                     static_cast<texture::Format>(format),
                                     flags, enable_render_surfaces);
diff --git a/o3d/command_buffer/service/cross/texture_utils.h b/o3d/command_buffer/service/cross/texture_utils.h
index aa186b5e620a8370293e86e16729f2331d394646..1f25ca263ef491e3712d2c0e0b3634a12fa5b3eb 100644
--- a/o3d/command_buffer/service/cross/texture_utils.h
+++ b/o3d/command_buffer/service/cross/texture_utils.h
@@ -75,8 +75,8 @@ struct TransferInfo {
 // Round a value up, so that it is divisible by the block size.
 static inline unsigned int RoundToBlockSize(unsigned int base,
                                             unsigned int block) {
-  DCHECK_GT(base, 0);
-  DCHECK_GT(block, 0);
+  DCHECK_GT(base, 0U);
+  DCHECK_GT(block, 0U);
   return block + base - 1 - (base - 1) % block;
 }
 
diff --git a/o3d/command_buffer/service/win/d3d9/geometry_d3d9.cc b/o3d/command_buffer/service/win/d3d9/geometry_d3d9.cc
index b81dcc3f5c2d54fe82b5ef3e36fa169ce2b3074d..e5f32b92fe15fd04b7f936d089c830822ba35923 100644
--- a/o3d/command_buffer/service/win/d3d9/geometry_d3d9.cc
+++ b/o3d/command_buffer/service/win/d3d9/geometry_d3d9.cc
@@ -206,7 +206,15 @@ unsigned int VertexStructD3D9::SetStreams(GAPID3D9 *gapi) {
     }
     HR(d3d_device->SetStreamSource(i, vertex_buffer->d3d_vertex_buffer(), 0,
                                    pair.second));
-    max_vertices = std::min(max_vertices, vertex_buffer->size()/pair.second);
+
+    // TODO(apatrick): A zero size stride is valid. It means the first element
+    //    in the vertex buffer will be used for every vertex. There doesn't seem
+    //    to be enough information here to determine whether a zero stride
+    //    vertex buffer is big enough to contain a single element.
+    if (pair.second != 0) {
+      max_vertices = std::min(max_vertices,
+                              vertex_buffer->size() / pair.second);
+    }
   }
   return max_vertices;
 }
diff --git a/o3d/command_buffer/service/win/d3d9/sampler_d3d9.cc b/o3d/command_buffer/service/win/d3d9/sampler_d3d9.cc
index 928d5772adcdc2f6266a5cdbb7e5087350667893..3645a5d4f34cd8384838ac2cea23aea4b5cc75a5 100644
--- a/o3d/command_buffer/service/win/d3d9/sampler_d3d9.cc
+++ b/o3d/command_buffer/service/win/d3d9/sampler_d3d9.cc
@@ -116,7 +116,7 @@ void SamplerD3D9::SetStates(sampler::AddressingMode addressing_u,
   // These are validated in GAPIDecoder.cc
   DCHECK_NE(mag_filter, sampler::NONE);
   DCHECK_NE(min_filter, sampler::NONE);
-  DCHECK_GT(max_anisotropy, 0);
+  DCHECK_GT(max_anisotropy, 0U);
   d3d_address_u_ = AddressModeToD3D(addressing_u);
   d3d_address_v_ = AddressModeToD3D(addressing_v);
   d3d_address_w_ = AddressModeToD3D(addressing_w);
diff --git a/o3d/command_buffer/service/win/d3d9/texture_d3d9.cc b/o3d/command_buffer/service/win/d3d9/texture_d3d9.cc
index 121bf6f01017891a457c27d3afe029a6d390c46a..d570fda412616bd0902eeca2d8099188f6024755 100644
--- a/o3d/command_buffer/service/win/d3d9/texture_d3d9.cc
+++ b/o3d/command_buffer/service/win/d3d9/texture_d3d9.cc
@@ -92,9 +92,9 @@ Texture2DD3D9 *Texture2DD3D9::Create(GAPID3D9 *gapi,
                                      texture::Format format,
                                      unsigned int flags,
                                      bool enable_render_surfaces) {
-  DCHECK_GT(width, 0);
-  DCHECK_GT(height, 0);
-  DCHECK_GT(levels, 0);
+  DCHECK_GT(width, 0U);
+  DCHECK_GT(height, 0U);
+  DCHECK_GT(levels, 0U);
   D3DFORMAT d3d_format = D3DFormat(format);
   IDirect3DDevice9 *device = gapi->d3d_device();
   if (enable_render_surfaces) {
@@ -269,10 +269,10 @@ Texture3DD3D9 *Texture3DD3D9::Create(GAPID3D9 *gapi,
                                      texture::Format format,
                                      unsigned int flags,
                                      bool enable_render_surfaces) {
-  DCHECK_GT(width, 0);
-  DCHECK_GT(height, 0);
-  DCHECK_GT(depth, 0);
-  DCHECK_GT(levels, 0);
+  DCHECK_GT(width, 0U);
+  DCHECK_GT(height, 0U);
+  DCHECK_GT(depth, 0U);
+  DCHECK_GT(levels, 0U);
   D3DFORMAT d3d_format = D3DFormat(format);
   IDirect3DDevice9 *device = gapi->d3d_device();
   if (enable_render_surfaces) {
@@ -444,8 +444,8 @@ TextureCubeD3D9 *TextureCubeD3D9::Create(GAPID3D9 *gapi,
                                          texture::Format format,
                                          unsigned int flags,
                                          bool enable_render_surfaces) {
-  DCHECK_GT(side, 0);
-  DCHECK_GT(levels, 0);
+  DCHECK_GT(side, 0U);
+  DCHECK_GT(levels, 0U);
   D3DFORMAT d3d_format = D3DFormat(format);
   IDirect3DDevice9 *device = gapi->d3d_device();
   if (enable_render_surfaces) {
diff --git a/o3d/core/core.gyp b/o3d/core/core.gyp
index b38c8e776552ee1dd781042eaa8bce275a6e3522..9041471ceaec74dbc9d6199f23129f73da1afcca 100644
--- a/o3d/core/core.gyp
+++ b/o3d/core/core.gyp
@@ -308,6 +308,8 @@
       'type': 'static_library',
       'dependencies': [
         '../../skia/skia.gyp:skia',
+        '../command_buffer/command_buffer.gyp:command_buffer_client',
+        '../command_buffer/command_buffer.gyp:command_buffer_service',
       ],
       'sources': [
       ],
@@ -379,6 +381,42 @@
             ],
           },
         ],
+        ['renderer == "cb"',
+          {
+            'sources': [
+              'cross/command_buffer/buffer_cb.cc',
+              'cross/command_buffer/buffer_cb.h',
+              'cross/command_buffer/effect_cb.cc',
+              'cross/command_buffer/effect_cb.h',
+              'cross/command_buffer/install_check.cc',
+              'cross/command_buffer/install_check.h',
+              'cross/command_buffer/param_cache_cb.cc',
+              'cross/command_buffer/param_cache_cb.h',
+              'cross/command_buffer/primitive_cb.cc',
+              'cross/command_buffer/primitive_cb.h',
+              'cross/command_buffer/renderer_cb.cc',
+              'cross/command_buffer/renderer_cb.h',
+              'cross/command_buffer/render_surface_cb.cc',
+              'cross/command_buffer/render_surface_cb.h',
+              'cross/command_buffer/sampler_cb.cc',
+              'cross/command_buffer/sampler_cb.h',
+              'cross/command_buffer/states_cb.cc',
+              'cross/command_buffer/states_cb.h',
+              'cross/command_buffer/stream_bank_cb.cc',
+              'cross/command_buffer/stream_bank_cb.h',
+              'cross/command_buffer/texture_cb.cc',
+              'cross/command_buffer/texture_cb.h',
+            ],
+          },
+        ],
+        ['renderer == "cb" and OS == "win"',
+          {
+            'sources': [
+              'win/command_buffer/win32_cb_server.cc',
+              'win/command_buffer/win32_cb_server.h',
+            ],
+          },
+        ],
       ],
     },
     {
diff --git a/o3d/core/cross/command_buffer/renderer_cb.cc b/o3d/core/cross/command_buffer/renderer_cb.cc
index 4272c832a37c42c8342fab59f60a48c1f111ce23..e2d39980e16fe107d904989b4ab8b982b3b3d8b6 100644
--- a/o3d/core/cross/command_buffer/renderer_cb.cc
+++ b/o3d/core/cross/command_buffer/renderer_cb.cc
@@ -72,8 +72,8 @@ RendererCB::RendererCB(ServiceLocator* service_locator,
       cb_server_(NULL),
       frame_token_(0),
       state_manager_(new StateManager) {
-  DCHECK_GT(command_buffer_size, 0);
-  DCHECK_GT(transfer_memory_size, 0);
+  DCHECK_GT(command_buffer_size, 0U);
+  DCHECK_GT(transfer_memory_size, 0U);
   transfer_shm_ = command_buffer::CreateShm(transfer_memory_size);
   transfer_shm_address_ = command_buffer::MapShm(transfer_shm_,
                                                  transfer_memory_size);
diff --git a/o3d/core/cross/command_buffer/texture_cb.cc b/o3d/core/cross/command_buffer/texture_cb.cc
index 4c401f93ad6c3bc754be65c89d9350719dde7f6f..73f53fc4325b2903bc2d9e97afb3d9694622879c 100644
--- a/o3d/core/cross/command_buffer/texture_cb.cc
+++ b/o3d/core/cross/command_buffer/texture_cb.cc
@@ -106,13 +106,20 @@ void SetTextureDataBuffer(Texture::Format format,
                           unsigned int dst_pitch) {
   const uint8* src = static_cast<const uint8*>(src_data);
   uint8* dst = static_cast<uint8*>(dst_buffer);
-  size_t bytes_per_line = image::ComputePitch(format, src_width);
-  for (unsigned yy = 0; yy < src_height; ++yy) {
-    memcpy(dst, src, bytes_per_line);
+
+  size_t bytes_per_row = image::ComputePitch(format, src_width);
+  unsigned num_rows = src_height;
+  if (Texture::IsCompressedFormat(format)) {
+    num_rows = (num_rows + 3) / 4;
+  }
+
+  for (unsigned yy = 0; yy < num_rows; ++yy) {
+    memcpy(dst, src, bytes_per_row);
     src += src_pitch;
     dst += dst_pitch;
   }
 }
+
 // Sends the SET_TEXTURE_DATA command after formatting the args properly.
 void SetTextureData(RendererCB *renderer,
                     ResourceID texture_id,
@@ -402,7 +409,7 @@ bool Texture2DCB::PlatformSpecificLock(
     DCHECK_EQ(backing_bitmap_->width(), width());
     DCHECK_EQ(backing_bitmap_->height(), height());
     DCHECK_EQ(backing_bitmap_->format(), format());
-    DCHECK_GT(backing_bitmap_->num_mipmaps(), level);
+    DCHECK_GT(backing_bitmap_->num_mipmaps(), static_cast<unsigned int>(level));
     CopyBackResourceToBitmap(renderer_, resource_id_, level,
                              TextureCUBE::FACE_POSITIVE_X,
                              *backing_bitmap_.Get());
@@ -421,7 +428,7 @@ bool Texture2DCB::PlatformSpecificUnlock(int level) {
   DCHECK_EQ(backing_bitmap_->width(), width());
   DCHECK_EQ(backing_bitmap_->height(), height());
   DCHECK_EQ(backing_bitmap_->format(), format());
-  DCHECK_GT(backing_bitmap_->num_mipmaps(), level);
+  DCHECK_GT(backing_bitmap_->num_mipmaps(), static_cast<unsigned int>(level));
   if (LockedMode(level) != kReadOnly) {
     UpdateResourceFromBitmap(renderer_, resource_id_, level,
                              TextureCUBE::FACE_POSITIVE_X,
@@ -634,7 +641,7 @@ bool TextureCUBECB::PlatformSpecificLock(
     DCHECK_EQ(backing_bitmap->width(), edge_length());
     DCHECK_EQ(backing_bitmap->height(), edge_length());
     DCHECK_EQ(backing_bitmap->format(), format());
-    DCHECK_GT(backing_bitmap->num_mipmaps(), level);
+    DCHECK_GT(backing_bitmap->num_mipmaps(), static_cast<unsigned int>(level));
     CopyBackResourceToBitmap(renderer_, resource_id_, level,
                              TextureCUBE::FACE_POSITIVE_X, *backing_bitmap);
     has_levels_[face] |= 1 << level;
@@ -652,7 +659,7 @@ bool TextureCUBECB::PlatformSpecificUnlock(CubeFace face, int level) {
   DCHECK_EQ(backing_bitmap->width(), edge_length());
   DCHECK_EQ(backing_bitmap->height(), edge_length());
   DCHECK_EQ(backing_bitmap->format(), format());
-  DCHECK_GT(backing_bitmap->num_mipmaps(), level);
+  DCHECK_GT(backing_bitmap->num_mipmaps(), static_cast<unsigned int>(level));
 
   if (LockedMode(face, level) != kReadOnly) {
     UpdateResourceFromBitmap(renderer_, resource_id_, level, face,
diff --git a/o3d/core/cross/command_buffer/texture_cb.h b/o3d/core/cross/command_buffer/texture_cb.h
index e0e85d214e31fa06dc7640b0fe625bc905f166f0..31bbb69302df3433506c3632b51163e6fa6cb66d 100644
--- a/o3d/core/cross/command_buffer/texture_cb.h
+++ b/o3d/core/cross/command_buffer/texture_cb.h
@@ -112,7 +112,7 @@ class Texture2DCB : public Texture2D {
 
   // Returns true if the backing bitmap has the data for the level.
   bool HasLevel(unsigned int level) {
-    DCHECK_LT(level, levels());
+    DCHECK_LT(level, static_cast<unsigned int>(levels()));
     return (has_levels_ & (1 << level)) != 0;
   }
 
@@ -192,7 +192,7 @@ class TextureCUBECB : public TextureCUBE {
 
   // Returns true if the backing bitmap has the data for the level.
   bool HasLevel(CubeFace face, unsigned int level) {
-    DCHECK_LT(level, levels());
+    DCHECK_LT(level, static_cast<unsigned int>(levels()));
     return (has_levels_[face] & (1 << level)) != 0;
   }
 
diff --git a/o3d/core/win/d3d9/utils_d3d9.h b/o3d/core/win/d3d9/utils_d3d9.h
index 0bca546eda71fad7d95ccc174dddee473573777c..03d4ca545aa7804f8cde96035dd4a93770318ca0 100644
--- a/o3d/core/win/d3d9/utils_d3d9.h
+++ b/o3d/core/win/d3d9/utils_d3d9.h
@@ -37,7 +37,7 @@
 #define O3D_CORE_WIN_D3D9_UTILS_D3D9_H_
 
 #include <d3d9.h>
-#include <dxerr9.h>
+#include <dxerr.h>
 #include "base/logging.h"
 #include "core/cross/stream.h"
 
@@ -52,7 +52,7 @@ inline bool VerifyHResult(HRESULT hr, const char* file, int line,
   if (FAILED(hr)) {
     DLOG(ERROR) << "DX Error in file " << file
                 << " line " << line << L": "
-                << DXGetErrorString9(hr) << L": " << call;
+                << DXGetErrorString(hr) << L": " << call;
     return false;
   }
   return true;
diff --git a/o3d/plugin/plugin.gyp b/o3d/plugin/plugin.gyp
index 53c24a290d91cfc5ae9aafd9a75c1f3691fba0bd..a5b2ff6caa3d35bb590d4d7a7636e8c27d12f608 100644
--- a/o3d/plugin/plugin.gyp
+++ b/o3d/plugin/plugin.gyp
@@ -214,11 +214,11 @@
             },
           },
         ],
-        ['OS == "win" and renderer == "d3d9"',
+        ['OS == "win" and (renderer == "d3d9" or renderer == "cb")',
           {
             'link_settings': {
               'libraries': [
-                '"$(DXSDK_DIR)/Lib/x86/DxErr9.lib"',
+                '"$(DXSDK_DIR)/Lib/x86/DxErr.lib"',
                 '"$(DXSDK_DIR)/Lib/x86/d3dx9.lib"',
                 '-ld3d9.lib',
               ],
diff --git a/o3d/tests/tests.gyp b/o3d/tests/tests.gyp
index a8c676636febb0124bceda847514b9e4a944be53..36c9fa04fe7abd65a20aa7d8a817c1b8e358e9bc 100644
--- a/o3d/tests/tests.gyp
+++ b/o3d/tests/tests.gyp
@@ -162,7 +162,7 @@
               'editbin /SUBSYSTEM:CONSOLE $(OutDir)/$(TargetFileName)',
           },
         ],
-        ['OS == "win" and renderer == "d3d9"',
+        ['OS == "win" and (renderer == "d3d9" or renderer == "cb")',
           {
             'sources': [
               'common/win/dxcapture.cc',
@@ -173,7 +173,7 @@
             'msvs_settings': {
               'VCLinkerTool': {
                 'AdditionalDependencies': [
-                  '"$(DXSDK_DIR)/Lib/x86/DxErr9.lib"',
+                  '"$(DXSDK_DIR)/Lib/x86/DxErr.lib"',
                   '"$(DXSDK_DIR)/Lib/x86/d3dx9.lib"',
                   'd3d9.lib',
                 ],