diff options
author | apatrick@google.com <apatrick@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-15 21:51:41 +0000 |
---|---|---|
committer | apatrick@google.com <apatrick@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-15 21:51:41 +0000 |
commit | 973c0eda70048d5d9c6e7a02c14fb25e48a3d218 (patch) | |
tree | 22da99c6dc904d927d0ffb5d7311d7f878d9d84d /o3d/command_buffer | |
parent | a5a6e25bfb05924c0acb74ee42085b4456608c19 (diff) | |
download | chromium_src-973c0eda70048d5d9c6e7a02c14fb25e48a3d218.zip chromium_src-973c0eda70048d5d9c6e7a02c14fb25e48a3d218.tar.gz chromium_src-973c0eda70048d5d9c6e7a02c14fb25e48a3d218.tar.bz2 |
Made gyp file for command buffer libraries.
Gyp build works on Windows. Mac and linux won't work yet.
Fixed some warnings.
Switched from dxerr.lib to dxerr9.lib.
Implemented a Texture::SetRect case for DXT compressed textures.
Fixed division by zero for zero stride vertex buffers.
TEST=none
BUG=none
Review URL: http://codereview.chromium.org/200127
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26271 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d/command_buffer')
-rw-r--r-- | o3d/command_buffer/client/cross/cmd_buffer_helper.cc | 2 | ||||
-rw-r--r-- | o3d/command_buffer/client/cross/effect_helper.cc | 4 | ||||
-rw-r--r-- | o3d/command_buffer/command_buffer.gyp | 165 | ||||
-rw-r--r-- | o3d/command_buffer/common/cross/buffer_sync_api.h | 2 | ||||
-rw-r--r-- | o3d/command_buffer/common/cross/resource.h | 2 | ||||
-rw-r--r-- | o3d/command_buffer/common/cross/rpc.h | 2 | ||||
-rw-r--r-- | o3d/command_buffer/common/cross/rpc_fake.cc | 2 | ||||
-rw-r--r-- | o3d/command_buffer/common/cross/rpc_fake.h | 1 | ||||
-rw-r--r-- | o3d/command_buffer/common/cross/rpc_imc.cc | 2 | ||||
-rw-r--r-- | o3d/command_buffer/common/cross/rpc_imc.h | 2 | ||||
-rw-r--r-- | o3d/command_buffer/service/cross/gapi_decoder.cc | 12 | ||||
-rw-r--r-- | o3d/command_buffer/service/cross/texture_utils.h | 4 | ||||
-rw-r--r-- | o3d/command_buffer/service/win/d3d9/geometry_d3d9.cc | 10 | ||||
-rw-r--r-- | o3d/command_buffer/service/win/d3d9/sampler_d3d9.cc | 2 | ||||
-rw-r--r-- | o3d/command_buffer/service/win/d3d9/texture_d3d9.cc | 18 |
15 files changed, 203 insertions, 27 deletions
diff --git a/o3d/command_buffer/client/cross/cmd_buffer_helper.cc b/o3d/command_buffer/client/cross/cmd_buffer_helper.cc index 481f0c7..f844576 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 1f05dd8..ced1b3b 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 0000000..4e3df30 --- /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 a561205..62d6011 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 e6b6f09..5557d67 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 fb55a88..6e95ee2 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 ed09b90..028c753 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 c7727c5..11eb258 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 5d6c1f7..f5c3c9e 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 8e4aed4..097fb1c 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 d37f7e0..3087733 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 aa186b5..1f25ca2 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 b81dcc3..e5f32b9 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 928d577..3645a5d 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 121bf6f..d570fda 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) { |