summaryrefslogtreecommitdiffstats
path: root/o3d
diff options
context:
space:
mode:
authorgman@google.com <gman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-12 23:09:29 +0000
committergman@google.com <gman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-12 23:09:29 +0000
commit634ab7f997c79bb8fd7fda9ea0295a296e30d0a5 (patch)
tree34e3d352021ead39a3ea6228f6e4388429634382 /o3d
parent0189bbd4cc569eaec4c6664109659c32fed8e4b7 (diff)
downloadchromium_src-634ab7f997c79bb8fd7fda9ea0295a296e30d0a5.zip
chromium_src-634ab7f997c79bb8fd7fda9ea0295a296e30d0a5.tar.gz
chromium_src-634ab7f997c79bb8fd7fda9ea0295a296e30d0a5.tar.bz2
Add a DLOG error to the command buffer and remove
a little of the macro magic. Also, fix the build. Renderer_cb was missing some functions. I seems like it would be really good if we could add something like this to the non-debug version because developers need an easy way to check for errors. Maybe these errors can go to the chrome error console or something, at least in chrome. Review URL: http://codereview.chromium.org/267061 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28753 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d')
-rw-r--r--o3d/command_buffer/command_buffer.gyp1
-rw-r--r--o3d/command_buffer/common/build.scons1
-rw-r--r--o3d/command_buffer/common/cross/cmd_buffer_format.cc59
-rw-r--r--o3d/command_buffer/common/cross/cmd_buffer_format.h134
-rw-r--r--o3d/command_buffer/service/cross/cmd_parser.cc7
-rw-r--r--o3d/command_buffer/service/cross/gapi_decoder.cc4
-rw-r--r--o3d/command_buffer/service/cross/gapi_decoder.h2
-rw-r--r--o3d/core/cross/command_buffer/renderer_cb.h34
8 files changed, 173 insertions, 69 deletions
diff --git a/o3d/command_buffer/command_buffer.gyp b/o3d/command_buffer/command_buffer.gyp
index f86fb11..810ee0f 100644
--- a/o3d/command_buffer/command_buffer.gyp
+++ b/o3d/command_buffer/command_buffer.gyp
@@ -44,6 +44,7 @@
'common/cross/buffer_sync_api.cc',
'common/cross/buffer_sync_api.h',
'common/cross/cmd_buffer_format.h',
+ 'common/cross/cmd_buffer_format.cc',
'common/cross/gapi_interface.h',
'common/cross/logging.h',
'common/cross/mocks.h',
diff --git a/o3d/command_buffer/common/build.scons b/o3d/command_buffer/common/build.scons
index 0aefd76..93f96bb 100644
--- a/o3d/command_buffer/common/build.scons
+++ b/o3d/command_buffer/common/build.scons
@@ -32,6 +32,7 @@ Import('env')
INPUTS = [
'cross/buffer_sync_api.cc',
+ 'cross/cmd_buffer_format.cc',
'cross/resource.cc',
'cross/rpc_imc.cc',
]
diff --git a/o3d/command_buffer/common/cross/cmd_buffer_format.cc b/o3d/command_buffer/common/cross/cmd_buffer_format.cc
new file mode 100644
index 0000000..0cefbc6c
--- /dev/null
+++ b/o3d/command_buffer/common/cross/cmd_buffer_format.cc
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2009, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+// This file contains the binary format definition of the command buffer and
+// command buffer commands.
+
+#include "command_buffer/common/cross/cmd_buffer_format.h"
+
+namespace o3d {
+namespace command_buffer {
+
+const char* GetCommandName(CommandId id) {
+ static const char* const names[] = {
+
+ #define O3D_COMMAND_BUFFER_CMD_OP(name) # name,
+
+ O3D_COMMAND_BUFFER_CMDS(O3D_COMMAND_BUFFER_CMD_OP)
+
+ #undef O3D_COMMAND_BUFFER_CMD_OP
+
+ };
+
+ return (static_cast<int>(id) >= 0 && static_cast<int>(id) < kNumCommands) ?
+ names[id] : "*unknown-command*";
+}
+
+} // namespace command_buffer
+} // namespace o3d
+
+
diff --git a/o3d/command_buffer/common/cross/cmd_buffer_format.h b/o3d/command_buffer/common/cross/cmd_buffer_format.h
index cd19dc3..3c5e567 100644
--- a/o3d/command_buffer/common/cross/cmd_buffer_format.h
+++ b/o3d/command_buffer/common/cross/cmd_buffer_format.h
@@ -76,84 +76,86 @@ namespace command_buffer {
// COMMAND_NAME is the name of your command structure.
//
// NOTE: THE ORDER OF THESE MUST NOT CHANGE (their id is derived by order)
-#define O3D_COMMAND_BUFFER_CMDS \
- O3D_COMMAND_BUFFER_CMD_OP(Noop) /* 0 */ \
- O3D_COMMAND_BUFFER_CMD_OP(SetToken) /* 1 */ \
- O3D_COMMAND_BUFFER_CMD_OP(BeginFrame) /* 2 */ \
- O3D_COMMAND_BUFFER_CMD_OP(EndFrame) /* 3 */ \
- O3D_COMMAND_BUFFER_CMD_OP(Clear) /* 4 */ \
- O3D_COMMAND_BUFFER_CMD_OP(CreateVertexBuffer) /* 5 */ \
- O3D_COMMAND_BUFFER_CMD_OP(DestroyVertexBuffer) /* 6 */ \
- O3D_COMMAND_BUFFER_CMD_OP(SetVertexBufferData) /* 7 */ \
- O3D_COMMAND_BUFFER_CMD_OP(SetVertexBufferDataImmediate) /* 8 */ \
- O3D_COMMAND_BUFFER_CMD_OP(GetVertexBufferData) /* 9 */ \
- O3D_COMMAND_BUFFER_CMD_OP(CreateIndexBuffer) /* 10 */ \
- O3D_COMMAND_BUFFER_CMD_OP(DestroyIndexBuffer) /* 11 */ \
- O3D_COMMAND_BUFFER_CMD_OP(SetIndexBufferData) /* 12 */ \
- O3D_COMMAND_BUFFER_CMD_OP(SetIndexBufferDataImmediate) /* 13 */ \
- O3D_COMMAND_BUFFER_CMD_OP(GetIndexBufferData) /* 14 */ \
- O3D_COMMAND_BUFFER_CMD_OP(CreateVertexStruct) /* 15 */ \
- O3D_COMMAND_BUFFER_CMD_OP(DestroyVertexStruct) /* 16 */ \
- O3D_COMMAND_BUFFER_CMD_OP(SetVertexInput) /* 17 */ \
- O3D_COMMAND_BUFFER_CMD_OP(SetVertexStruct) /* 18 */ \
- O3D_COMMAND_BUFFER_CMD_OP(Draw) /* 19 */ \
- O3D_COMMAND_BUFFER_CMD_OP(DrawIndexed) /* 20 */ \
- O3D_COMMAND_BUFFER_CMD_OP(CreateEffect) /* 21 */ \
- O3D_COMMAND_BUFFER_CMD_OP(CreateEffectImmediate) /* 22 */ \
- O3D_COMMAND_BUFFER_CMD_OP(DestroyEffect) /* 23 */ \
- O3D_COMMAND_BUFFER_CMD_OP(SetEffect) /* 24 */ \
- O3D_COMMAND_BUFFER_CMD_OP(GetParamCount) /* 25 */ \
- O3D_COMMAND_BUFFER_CMD_OP(CreateParam) /* 26 */ \
- O3D_COMMAND_BUFFER_CMD_OP(CreateParamByName) /* 27 */ \
- O3D_COMMAND_BUFFER_CMD_OP(CreateParamByNameImmediate) /* 28 */ \
- O3D_COMMAND_BUFFER_CMD_OP(DestroyParam) /* 29 */ \
- O3D_COMMAND_BUFFER_CMD_OP(SetParamData) /* 30 */ \
- O3D_COMMAND_BUFFER_CMD_OP(SetParamDataImmediate) /* 31 */ \
- O3D_COMMAND_BUFFER_CMD_OP(GetParamDesc) /* 32 */ \
- O3D_COMMAND_BUFFER_CMD_OP(GetStreamCount) /* 33 */ \
- O3D_COMMAND_BUFFER_CMD_OP(GetStreamDesc) /* 34 */ \
- O3D_COMMAND_BUFFER_CMD_OP(DestroyTexture) /* 35 */ \
- O3D_COMMAND_BUFFER_CMD_OP(CreateTexture2d) /* 36 */ \
- O3D_COMMAND_BUFFER_CMD_OP(CreateTexture3d) /* 37 */ \
- O3D_COMMAND_BUFFER_CMD_OP(CreateTextureCube) /* 38 */ \
- O3D_COMMAND_BUFFER_CMD_OP(SetTextureData) /* 39 */ \
- O3D_COMMAND_BUFFER_CMD_OP(SetTextureDataImmediate) /* 40 */ \
- O3D_COMMAND_BUFFER_CMD_OP(GetTextureData) /* 41 */ \
- O3D_COMMAND_BUFFER_CMD_OP(CreateSampler) /* 42 */ \
- O3D_COMMAND_BUFFER_CMD_OP(DestroySampler) /* 43 */ \
- O3D_COMMAND_BUFFER_CMD_OP(SetSamplerStates) /* 44 */ \
- O3D_COMMAND_BUFFER_CMD_OP(SetSamplerBorderColor) /* 45 */ \
- O3D_COMMAND_BUFFER_CMD_OP(SetSamplerTexture) /* 46 */ \
- O3D_COMMAND_BUFFER_CMD_OP(SetViewport) /* 47 */ \
- O3D_COMMAND_BUFFER_CMD_OP(SetScissor) /* 48 */ \
- O3D_COMMAND_BUFFER_CMD_OP(SetPointLineRaster) /* 49 */ \
- O3D_COMMAND_BUFFER_CMD_OP(SetPolygonRaster) /* 50 */ \
- O3D_COMMAND_BUFFER_CMD_OP(SetPolygonOffset) /* 51 */ \
- O3D_COMMAND_BUFFER_CMD_OP(SetAlphaTest) /* 52 */ \
- O3D_COMMAND_BUFFER_CMD_OP(SetDepthTest) /* 53 */ \
- O3D_COMMAND_BUFFER_CMD_OP(SetStencilTest) /* 54 */ \
- O3D_COMMAND_BUFFER_CMD_OP(SetBlending) /* 55 */ \
- O3D_COMMAND_BUFFER_CMD_OP(SetBlendingColor) /* 56 */ \
- O3D_COMMAND_BUFFER_CMD_OP(SetColorWrite) /* 57 */ \
- O3D_COMMAND_BUFFER_CMD_OP(CreateRenderSurface) /* 58 */ \
- O3D_COMMAND_BUFFER_CMD_OP(DestroyRenderSurface) /* 59 */ \
- O3D_COMMAND_BUFFER_CMD_OP(CreateDepthSurface) /* 60 */ \
- O3D_COMMAND_BUFFER_CMD_OP(DestroyDepthSurface) /* 61 */ \
- O3D_COMMAND_BUFFER_CMD_OP(SetRenderSurface) /* 62 */ \
- O3D_COMMAND_BUFFER_CMD_OP(SetBackSurfaces) /* 63 */ \
+#define O3D_COMMAND_BUFFER_CMDS(OP) \
+ OP(Noop) /* 0 */ \
+ OP(SetToken) /* 1 */ \
+ OP(BeginFrame) /* 2 */ \
+ OP(EndFrame) /* 3 */ \
+ OP(Clear) /* 4 */ \
+ OP(CreateVertexBuffer) /* 5 */ \
+ OP(DestroyVertexBuffer) /* 6 */ \
+ OP(SetVertexBufferData) /* 7 */ \
+ OP(SetVertexBufferDataImmediate) /* 8 */ \
+ OP(GetVertexBufferData) /* 9 */ \
+ OP(CreateIndexBuffer) /* 10 */ \
+ OP(DestroyIndexBuffer) /* 11 */ \
+ OP(SetIndexBufferData) /* 12 */ \
+ OP(SetIndexBufferDataImmediate) /* 13 */ \
+ OP(GetIndexBufferData) /* 14 */ \
+ OP(CreateVertexStruct) /* 15 */ \
+ OP(DestroyVertexStruct) /* 16 */ \
+ OP(SetVertexInput) /* 17 */ \
+ OP(SetVertexStruct) /* 18 */ \
+ OP(Draw) /* 19 */ \
+ OP(DrawIndexed) /* 20 */ \
+ OP(CreateEffect) /* 21 */ \
+ OP(CreateEffectImmediate) /* 22 */ \
+ OP(DestroyEffect) /* 23 */ \
+ OP(SetEffect) /* 24 */ \
+ OP(GetParamCount) /* 25 */ \
+ OP(CreateParam) /* 26 */ \
+ OP(CreateParamByName) /* 27 */ \
+ OP(CreateParamByNameImmediate) /* 28 */ \
+ OP(DestroyParam) /* 29 */ \
+ OP(SetParamData) /* 30 */ \
+ OP(SetParamDataImmediate) /* 31 */ \
+ OP(GetParamDesc) /* 32 */ \
+ OP(GetStreamCount) /* 33 */ \
+ OP(GetStreamDesc) /* 34 */ \
+ OP(DestroyTexture) /* 35 */ \
+ OP(CreateTexture2d) /* 36 */ \
+ OP(CreateTexture3d) /* 37 */ \
+ OP(CreateTextureCube) /* 38 */ \
+ OP(SetTextureData) /* 39 */ \
+ OP(SetTextureDataImmediate) /* 40 */ \
+ OP(GetTextureData) /* 41 */ \
+ OP(CreateSampler) /* 42 */ \
+ OP(DestroySampler) /* 43 */ \
+ OP(SetSamplerStates) /* 44 */ \
+ OP(SetSamplerBorderColor) /* 45 */ \
+ OP(SetSamplerTexture) /* 46 */ \
+ OP(SetViewport) /* 47 */ \
+ OP(SetScissor) /* 48 */ \
+ OP(SetPointLineRaster) /* 49 */ \
+ OP(SetPolygonRaster) /* 50 */ \
+ OP(SetPolygonOffset) /* 51 */ \
+ OP(SetAlphaTest) /* 52 */ \
+ OP(SetDepthTest) /* 53 */ \
+ OP(SetStencilTest) /* 54 */ \
+ OP(SetBlending) /* 55 */ \
+ OP(SetBlendingColor) /* 56 */ \
+ OP(SetColorWrite) /* 57 */ \
+ OP(CreateRenderSurface) /* 58 */ \
+ OP(DestroyRenderSurface) /* 59 */ \
+ OP(CreateDepthSurface) /* 60 */ \
+ OP(DestroyDepthSurface) /* 61 */ \
+ OP(SetRenderSurface) /* 62 */ \
+ OP(SetBackSurfaces) /* 63 */ \
// GAPI commands.
enum CommandId {
#define O3D_COMMAND_BUFFER_CMD_OP(name) k ## name,
- O3D_COMMAND_BUFFER_CMDS
+ O3D_COMMAND_BUFFER_CMDS(O3D_COMMAND_BUFFER_CMD_OP)
#undef O3D_COMMAND_BUFFER_CMD_OP
kNumCommands,
};
+const char* GetCommandName(CommandId id);
+
namespace cmd {
enum ArgFlags {
kFixed = 0x0,
diff --git a/o3d/command_buffer/service/cross/cmd_parser.cc b/o3d/command_buffer/service/cross/cmd_parser.cc
index ffe1d09..0d450268 100644
--- a/o3d/command_buffer/service/cross/cmd_parser.cc
+++ b/o3d/command_buffer/service/cross/cmd_parser.cc
@@ -74,6 +74,13 @@ BufferSyncInterface::ParseError CommandParser::ProcessCommand() {
return BufferSyncInterface::kParseOutOfBounds;
BufferSyncInterface::ParseError result = handler_->DoCommand(
header.command, header.size - 1, buffer_ + get);
+ // TODO(gman): If you want to log errors this is the best place to catch them.
+ // It seems like we need an official way to turn on a debug mode and
+ // get these errors.
+ if (result != BufferSyncInterface::kParseNoError) {
+ DLOG(INFO) << "Error: " << result << " for Command "
+ << GetCommandName(static_cast<CommandId>(header.command));
+ }
get_ = (get + header.size) % entry_count_;
return result;
}
diff --git a/o3d/command_buffer/service/cross/gapi_decoder.cc b/o3d/command_buffer/service/cross/gapi_decoder.cc
index 9a4be8a..db55421 100644
--- a/o3d/command_buffer/service/cross/gapi_decoder.cc
+++ b/o3d/command_buffer/service/cross/gapi_decoder.cc
@@ -70,7 +70,7 @@ const CommandInfo g_command_info[] = {
cmd::name::kArgFlags, \
sizeof(cmd::name) / sizeof(CommandBufferEntry) - 1, }, /* NOLINT */ \
- O3D_COMMAND_BUFFER_CMDS
+ O3D_COMMAND_BUFFER_CMDS(O3D_COMMAND_BUFFER_CMD_OP)
#undef O3D_COMMAND_BUFFER_CMD_OP
};
@@ -98,7 +98,7 @@ BufferSyncInterface::ParseError GAPIDecoder::DoCommand(
arg_count, \
*static_cast<const cmd::name*>(cmd_data)); \
- O3D_COMMAND_BUFFER_CMDS
+ O3D_COMMAND_BUFFER_CMDS(O3D_COMMAND_BUFFER_CMD_OP)
#undef O3D_COMMAND_BUFFER_CMD_OP
}
diff --git a/o3d/command_buffer/service/cross/gapi_decoder.h b/o3d/command_buffer/service/cross/gapi_decoder.h
index e75376c..8779cf2 100644
--- a/o3d/command_buffer/service/cross/gapi_decoder.h
+++ b/o3d/command_buffer/service/cross/gapi_decoder.h
@@ -83,7 +83,7 @@ class GAPIDecoder : public AsyncAPIInterface {
unsigned int arg_count, \
const cmd::name& args); \
- O3D_COMMAND_BUFFER_CMDS
+ O3D_COMMAND_BUFFER_CMDS(O3D_COMMAND_BUFFER_CMD_OP)
#undef O3D_COMMAND_BUFFER_CMD_OP
diff --git a/o3d/core/cross/command_buffer/renderer_cb.h b/o3d/core/cross/command_buffer/renderer_cb.h
index 6a12c72..643e05e 100644
--- a/o3d/core/cross/command_buffer/renderer_cb.h
+++ b/o3d/core/cross/command_buffer/renderer_cb.h
@@ -36,6 +36,7 @@
#define O3D_CORE_CROSS_COMMAND_BUFFER_RENDERER_CB_H_
#include "core/cross/precompile.h"
+#include <vector>
#include "core/cross/renderer.h"
#include "command_buffer/common/cross/rpc.h"
#include "command_buffer/common/cross/resource.h"
@@ -79,6 +80,39 @@ class RendererCB : public Renderer {
// Destroy() should be called before Init() is called again.
virtual void Destroy();
+ // Overridden from Renderer.
+ virtual bool GoFullscreen(const DisplayWindow& display,
+ int mode_id) {
+ // TODO(gman): implement this.
+ return false;
+ }
+
+ // Overridden from Renderer.
+ virtual bool CancelFullscreen(const DisplayWindow& display,
+ int width, int height) {
+ // TODO(gman): implement this.
+ return false;
+ }
+
+ // Tells whether we're currently displayed fullscreen or not.
+ virtual bool fullscreen() const {
+ // TODO(gman): implement this.
+ return false;
+ }
+
+ // Get a vector of the available fullscreen display modes.
+ // Clears *modes on error.
+ virtual void GetDisplayModes(std::vector<DisplayMode> *modes) {
+ // TODO(gman): implement this.
+ }
+
+ // Get a single fullscreen display mode by id.
+ // Returns true on success, false on error.
+ virtual bool GetDisplayMode(int id, DisplayMode *mode) {
+ // TODO(gman): implement this.
+ return false;
+ }
+
// Creates a StreamBank, returning a platform specific implementation class.
virtual StreamBank::Ref CreateStreamBank();