summaryrefslogtreecommitdiffstats
path: root/o3d/command_buffer/service/cross
diff options
context:
space:
mode:
authorgman@google.com <gman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-23 00:45:08 +0000
committergman@google.com <gman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-23 00:45:08 +0000
commit2cc9523f46da42a8261d36f68154a9ce9ed6b471 (patch)
tree3f9ce2bedde7bbc4377447af3a01bd48516ce8ce /o3d/command_buffer/service/cross
parent8cd7d69565a1f4f9dfae797b8cd25bf18292a423 (diff)
downloadchromium_src-2cc9523f46da42a8261d36f68154a9ce9ed6b471.zip
chromium_src-2cc9523f46da42a8261d36f68154a9ce9ed6b471.tar.gz
chromium_src-2cc9523f46da42a8261d36f68154a9ce9ed6b471.tar.bz2
Change command buffer client code to use structures.
I didn't update the big_test although I'm happy to do that in another CL. I changed the CB renderer code to use this. The only place I didn't is the state handling code. I'll consider changing that in another CL. I changed DoCommand so it gets passed the entire command data including the command itself where as it used to get passed the command buffer entry after the command. I wanted to put the commands into the structures as I think it makes them easier to use since they can then correctly set their header. I could have left DoCommand as is but there would have been a lot of funky pointer math and I thought this change made it cleaner. Some questions I had while doing this. There are a few places in the code that use unsigned int instead of uint32. It seems we should use uint32 because unsigned int is not guarnteed to be 32bits. So for example ResourceID is unsigned int right now. The CMD::Set/CMD::Init/CommandBufferHelper commands are currently fairly untyped. For example DESTROY_TEXTURE takes a uint32 id. Should it take a ResourceID instead? DRAW should maybe take an enum for primitive_type? If we decide to do that I'd like to do it in another CL. There's no checking for overflow. We could add a bunch of DCHECK like DCHECK_LE(width, 65536) or DCHECK_LE(semantic_index, 16). I'd like to do those in another CL as well as I think we need to discuss what commands we want to change. All the code is in .h files because we want all of this code to inline. Theoretically this should be just as efficient as poking values into arrays in the opt builds. Review URL: http://codereview.chromium.org/212018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26886 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d/command_buffer/service/cross')
-rw-r--r--o3d/command_buffer/service/cross/buffer_rpc_test.cc8
-rw-r--r--o3d/command_buffer/service/cross/cmd_buffer_engine.cc54
-rw-r--r--o3d/command_buffer/service/cross/cmd_buffer_engine.h4
-rw-r--r--o3d/command_buffer/service/cross/cmd_buffer_engine_test.cc80
-rw-r--r--o3d/command_buffer/service/cross/cmd_parser.cc10
-rw-r--r--o3d/command_buffer/service/cross/cmd_parser.h4
-rw-r--r--o3d/command_buffer/service/cross/cmd_parser_test.cc46
-rw-r--r--o3d/command_buffer/service/cross/effect_utils.h2
-rw-r--r--o3d/command_buffer/service/cross/gapi_decoder.cc977
-rw-r--r--o3d/command_buffer/service/cross/gapi_decoder.h52
-rw-r--r--o3d/command_buffer/service/cross/gl/effect_gl.cc54
-rw-r--r--o3d/command_buffer/service/cross/gl/geometry_gl.cc76
-rw-r--r--o3d/command_buffer/service/cross/gl/sampler_gl.cc18
-rw-r--r--o3d/command_buffer/service/cross/gl/texture_gl.cc28
-rw-r--r--o3d/command_buffer/service/cross/mocks.h11
15 files changed, 627 insertions, 797 deletions
diff --git a/o3d/command_buffer/service/cross/buffer_rpc_test.cc b/o3d/command_buffer/service/cross/buffer_rpc_test.cc
index 42122b9..a0afd7b 100644
--- a/o3d/command_buffer/service/cross/buffer_rpc_test.cc
+++ b/o3d/command_buffer/service/cross/buffer_rpc_test.cc
@@ -151,8 +151,8 @@ TEST_F(BufferRPCImplTest, TestSignalGetChanges) {
// is properly forwarded.
TEST_F(BufferRPCImplTest, TestGetStatus) {
EXPECT_CALL(buffer_sync_mock(), GetStatus())
- .WillOnce(Return(BufferSyncInterface::PARSE_ERROR));
- EXPECT_EQ(BufferSyncInterface::PARSE_ERROR,
+ .WillOnce(Return(BufferSyncInterface::kParseError));
+ EXPECT_EQ(BufferSyncInterface::kParseError,
buffer_rpc_impl()->DoCall(BufferRPCImpl::GET_STATUS, NULL, 0, NULL,
0));
}
@@ -161,8 +161,8 @@ TEST_F(BufferRPCImplTest, TestGetStatus) {
// is properly forwarded.
TEST_F(BufferRPCImplTest, TestGetParseError) {
EXPECT_CALL(buffer_sync_mock(), GetParseError())
- .WillOnce(Return(BufferSyncInterface::PARSE_OUT_OF_BOUNDS));
- EXPECT_EQ(BufferSyncInterface::PARSE_OUT_OF_BOUNDS,
+ .WillOnce(Return(BufferSyncInterface::kParseOutOfBounds));
+ EXPECT_EQ(BufferSyncInterface::kParseOutOfBounds,
buffer_rpc_impl()->DoCall(BufferRPCImpl::GET_PARSE_ERROR, NULL, 0,
NULL, 0));
}
diff --git a/o3d/command_buffer/service/cross/cmd_buffer_engine.cc b/o3d/command_buffer/service/cross/cmd_buffer_engine.cc
index d96c63d..b39f993 100644
--- a/o3d/command_buffer/service/cross/cmd_buffer_engine.cc
+++ b/o3d/command_buffer/service/cross/cmd_buffer_engine.cc
@@ -47,10 +47,10 @@ CommandBufferEngine::CommandBufferEngine(AsyncAPIInterface *handler)
handler_(handler),
client_rpc_(NULL),
token_(0),
- status_(NOT_CONNECTED),
+ status_(kNotConnected),
signal_change_(false),
signal_rpc_message_id_(0),
- parse_error_(PARSE_NO_ERROR) {
+ parse_error_(kParseNoError) {
buffer_rpc_impl_.reset(new BufferRPCImpl(this));
}
@@ -58,13 +58,13 @@ CommandBufferEngine::~CommandBufferEngine() {}
// Inits the connection. Registers the client RPC service.
void CommandBufferEngine::InitConnection() {
- status_ = NO_BUFFER;
+ status_ = kNoBuffer;
}
// Closes the connection. Executes all remaining commands.
void CommandBufferEngine::CloseConnection() {
FinishParsing();
- status_ = NOT_CONNECTED;
+ status_ = kNotConnected;
parser_.reset(NULL);
}
@@ -113,13 +113,13 @@ void CommandBufferEngine::SetCommandBuffer(unsigned int shm_id,
<< "shared memory";
return;
}
- if (status_ == NOT_CONNECTED) return;
+ if (status_ == kNotConnected) return;
FinishParsing();
parser_.reset(new CommandParser(shared_memory_buffers_[shm_id].address,
shared_memory_buffers_[shm_id].size, offset,
size, start_get, handler_));
- status_ = PARSING;
- parse_error_ = PARSE_NO_ERROR;
+ status_ = kParsing;
+ parse_error_ = kParseNoError;
}
// Changes the put value.
@@ -145,12 +145,12 @@ unsigned int CommandBufferEngine::GetToken() {
// Executes commands until get is different from the value passed in. It will
// return immediately if the get value is already different, or if the engine
-// is not in the PARSING status, or if the buffer is empty. It will return -1
+// is not in the kParsing status, or if the buffer is empty. It will return -1
// if there is no current buffer.
CommandBufferOffset CommandBufferEngine::WaitGetChanges(
CommandBufferOffset current_value) {
if (parser_.get()) {
- while (status_ == PARSING &&
+ while (status_ == kParsing &&
parser_->get() == current_value &&
!parser_->IsEmpty()) {
ProcessOneCommand();
@@ -162,12 +162,12 @@ CommandBufferOffset CommandBufferEngine::WaitGetChanges(
}
// Signals the client when get gets different from the value passed in. If get
-// is already different, or if the engine is not in the PARSING status, that
+// is already different, or if the engine is not in the kParsing status, that
// will happen immediately, otherwise it will happen when commands get
// executed, moving the get pointer.
void CommandBufferEngine::SignalGetChanges(CommandBufferOffset current_value,
int rpc_message_id) {
- if (status_ != PARSING || parser_->get() != current_value) {
+ if (status_ != kParsing || parser_->get() != current_value) {
DoSignalChangedGet(rpc_message_id);
} else {
signal_change_ = true;
@@ -200,10 +200,10 @@ BufferSyncInterface::ParserStatus CommandBufferEngine::GetStatus() {
return status_;
}
-// Gets the current parse error, reset it to PARSE_NO_ERROR.
+// Gets the current parse error, reset it to kParseNoError.
BufferSyncInterface::ParseError CommandBufferEngine::GetParseError() {
ParseError error = parse_error_;
- parse_error_ = PARSE_NO_ERROR;
+ parse_error_ = kParseNoError;
return error;
}
@@ -211,32 +211,32 @@ BufferSyncInterface::ParseError CommandBufferEngine::GetParseError() {
// parsing error occurs.
void CommandBufferEngine::FinishParsing() {
// terminates current parsing, that is, execute all the commands
- // NOTE: status_ == PARSING implies parser_ != NULL
- while (status_ == PARSING && !parser_->IsEmpty()) {
+ // NOTE: status_ == kParsing implies parser_ != NULL
+ while (status_ == kParsing && !parser_->IsEmpty()) {
ProcessOneCommand();
}
}
// Processes one command from the command buffer. This must only be called when
-// in the PARSING status.
+// in the kParsing status.
// This will update the status_ and the parse_error_ fields if an error occurs.
void CommandBufferEngine::ProcessOneCommand() {
- DCHECK_EQ(PARSING, status_);
+ DCHECK_EQ(kParsing, status_);
DCHECK(parser_.get());
ParseError result = parser_->ProcessCommand();
switch (result) {
- case PARSE_NO_ERROR:
+ case kParseNoError:
break;
- case PARSE_OUT_OF_BOUNDS:
- case PARSE_INVALID_SIZE:
- status_ = PARSE_ERROR;
+ case kParseOutOfBounds:
+ case kParseInvalidSize:
+ status_ = kParseError;
// Always override the error, to properly signal the stopping condition.
parse_error_ = result;
break;
- case PARSE_INVALID_ARGUMENTS:
- case PARSE_UNKNOWN_COMMAND:
+ case kParseInvalidArguments:
+ case kParseUnknownCommand:
// Only set the error if it is not set already.
- if (parse_error_ == PARSE_NO_ERROR) {
+ if (parse_error_ == kParseNoError) {
parse_error_ = result;
}
break;
@@ -255,16 +255,16 @@ void CommandBufferEngine::DoMainLoop() {
while (DoWork()) { }
// Clean up if needed: execute all pending commands, then close the
// connection.
- if (status_ != NOT_CONNECTED) CloseConnection();
+ if (status_ != kNotConnected) CloseConnection();
}
bool CommandBufferEngine::HasWork() {
- return (status_ == PARSING && !parser_->IsEmpty()) ||
+ return (status_ == kParsing && !parser_->IsEmpty()) ||
process_interface_->HasMessage();
}
bool CommandBufferEngine::DoWork() {
- if (status_ == PARSING && !parser_->IsEmpty()) {
+ if (status_ == kParsing && !parser_->IsEmpty()) {
bool running = true;
// process as many messages as available but do not block.
while (process_interface_->HasMessage()) {
diff --git a/o3d/command_buffer/service/cross/cmd_buffer_engine.h b/o3d/command_buffer/service/cross/cmd_buffer_engine.h
index 824f4f6..572d98f 100644
--- a/o3d/command_buffer/service/cross/cmd_buffer_engine.h
+++ b/o3d/command_buffer/service/cross/cmd_buffer_engine.h
@@ -131,8 +131,8 @@ class CommandBufferEngine : public BufferSyncInterface {
// Gets the current parse error. The current parse error is set when the
// service is in the PARSE_ERROR status. It may also be set while in the
- // PARSING state, if a recoverable error (like PARSE_UNKNOWN_METHOD) was
- // encountered. Getting the error resets it to PARSE_NO_ERROR.
+ // kParsing state, if a recoverable error (like PARSE_UNKNOWN_METHOD) was
+ // encountered. Getting the error resets it to kParseNoError.
// Returns:
// The current parse error.
virtual ParseError GetParseError();
diff --git a/o3d/command_buffer/service/cross/cmd_buffer_engine_test.cc b/o3d/command_buffer/service/cross/cmd_buffer_engine_test.cc
index 14f56ec..c217e4c 100644
--- a/o3d/command_buffer/service/cross/cmd_buffer_engine_test.cc
+++ b/o3d/command_buffer/service/cross/cmd_buffer_engine_test.cc
@@ -133,21 +133,21 @@ TEST_F(CommandBufferEngineTest, TestInitialization) {
// Check initial state
EXPECT_TRUE(engine()->rpc_impl() != NULL);
EXPECT_TRUE(engine()->parser() == NULL);
- EXPECT_EQ(BufferSyncInterface::NOT_CONNECTED, engine()->GetStatus());
- EXPECT_EQ(BufferSyncInterface::PARSE_NO_ERROR, engine()->GetParseError());
+ EXPECT_EQ(BufferSyncInterface::kNotConnected, engine()->GetStatus());
+ EXPECT_EQ(BufferSyncInterface::kParseNoError, engine()->GetParseError());
EXPECT_EQ(-1, engine()->Get());
EXPECT_EQ(0, engine()->GetToken());
engine()->InitConnection();
- EXPECT_EQ(BufferSyncInterface::NO_BUFFER, engine()->GetStatus());
- EXPECT_EQ(BufferSyncInterface::PARSE_NO_ERROR, engine()->GetParseError());
+ EXPECT_EQ(BufferSyncInterface::kNoBuffer, engine()->GetStatus());
+ EXPECT_EQ(BufferSyncInterface::kParseNoError, engine()->GetParseError());
EXPECT_EQ(-1, engine()->Get());
CommandBufferEntry *entries = InitCommandBuffer(25, 5);
ASSERT_TRUE(entries != NULL);
- EXPECT_EQ(BufferSyncInterface::PARSING, engine()->GetStatus());
- EXPECT_EQ(BufferSyncInterface::PARSE_NO_ERROR, engine()->GetParseError());
+ EXPECT_EQ(BufferSyncInterface::kParsing, engine()->GetStatus());
+ EXPECT_EQ(BufferSyncInterface::kParseNoError, engine()->GetParseError());
EXPECT_EQ(5, engine()->Get());
EXPECT_TRUE(engine()->parser() != NULL);
@@ -157,8 +157,8 @@ TEST_F(CommandBufferEngineTest, TestInitialization) {
engine()->CloseConnection();
DestroyCommandBuffer();
- EXPECT_EQ(BufferSyncInterface::NOT_CONNECTED, engine()->GetStatus());
- EXPECT_EQ(BufferSyncInterface::PARSE_NO_ERROR, engine()->GetParseError());
+ EXPECT_EQ(BufferSyncInterface::kNotConnected, engine()->GetStatus());
+ EXPECT_EQ(BufferSyncInterface::kParseNoError, engine()->GetParseError());
EXPECT_EQ(-1, engine()->Get());
EXPECT_TRUE(engine()->parser() == NULL);
}
@@ -231,7 +231,7 @@ TEST_F(CommandBufferEngineTest, TestCommandProcessing) {
// Create a command buffer with 3 commands
put += AddCommandWithExpect(entries + put,
- BufferSyncInterface::PARSE_NO_ERROR,
+ BufferSyncInterface::kParseNoError,
0,
0,
NULL);
@@ -240,7 +240,7 @@ TEST_F(CommandBufferEngineTest, TestCommandProcessing) {
args1[0].value_uint32 = 3;
args1[1].value_float = 4.f;
put += AddCommandWithExpect(entries + put,
- BufferSyncInterface::PARSE_NO_ERROR,
+ BufferSyncInterface::kParseNoError,
1,
2,
args1);
@@ -249,7 +249,7 @@ TEST_F(CommandBufferEngineTest, TestCommandProcessing) {
args2[0].value_uint32 = 5;
args2[1].value_float = 6.f;
put += AddCommandWithExpect(entries + put,
- BufferSyncInterface::PARSE_NO_ERROR,
+ BufferSyncInterface::kParseNoError,
2,
2,
args2);
@@ -259,8 +259,8 @@ TEST_F(CommandBufferEngineTest, TestCommandProcessing) {
// Check that the parsing progresses, and that no error occurs.
CommandBufferOffset new_get = engine()->WaitGetChanges(get);
EXPECT_NE(get, new_get);
- ASSERT_EQ(BufferSyncInterface::PARSING, engine()->GetStatus());
- EXPECT_EQ(BufferSyncInterface::PARSE_NO_ERROR, engine()->GetParseError());
+ ASSERT_EQ(BufferSyncInterface::kParsing, engine()->GetStatus());
+ EXPECT_EQ(BufferSyncInterface::kParseNoError, engine()->GetParseError());
EXPECT_EQ(new_get, engine()->Get());
get = new_get;
}
@@ -283,7 +283,7 @@ TEST_F(CommandBufferEngineTest, TestCommandWrapping) {
// Create a command buffer with 3 commands
put += AddCommandWithExpect(entries + put,
- BufferSyncInterface::PARSE_NO_ERROR,
+ BufferSyncInterface::kParseNoError,
0,
0,
NULL);
@@ -292,7 +292,7 @@ TEST_F(CommandBufferEngineTest, TestCommandWrapping) {
args1[0].value_uint32 = 3;
args1[1].value_float = 4.f;
put += AddCommandWithExpect(entries + put,
- BufferSyncInterface::PARSE_NO_ERROR,
+ BufferSyncInterface::kParseNoError,
1,
2,
args1);
@@ -303,7 +303,7 @@ TEST_F(CommandBufferEngineTest, TestCommandWrapping) {
args2[0].value_uint32 = 5;
args2[1].value_float = 6.f;
put += AddCommandWithExpect(entries + put,
- BufferSyncInterface::PARSE_NO_ERROR,
+ BufferSyncInterface::kParseNoError,
2,
2,
args2);
@@ -313,8 +313,8 @@ TEST_F(CommandBufferEngineTest, TestCommandWrapping) {
// Check that the parsing progresses, and that no error occurs.
CommandBufferOffset new_get = engine()->WaitGetChanges(get);
EXPECT_NE(get, new_get);
- ASSERT_EQ(BufferSyncInterface::PARSING, engine()->GetStatus());
- EXPECT_EQ(BufferSyncInterface::PARSE_NO_ERROR, engine()->GetParseError());
+ ASSERT_EQ(BufferSyncInterface::kParsing, engine()->GetStatus());
+ EXPECT_EQ(BufferSyncInterface::kParseNoError, engine()->GetParseError());
EXPECT_EQ(new_get, engine()->Get());
get = new_get;
}
@@ -337,7 +337,7 @@ TEST_F(CommandBufferEngineTest, TestSetBufferAndClose) {
// Create a command buffer with 3 commands
put += AddCommandWithExpect(entries + put,
- BufferSyncInterface::PARSE_NO_ERROR,
+ BufferSyncInterface::kParseNoError,
0,
0,
NULL);
@@ -346,7 +346,7 @@ TEST_F(CommandBufferEngineTest, TestSetBufferAndClose) {
args1[0].value_uint32 = 3;
args1[1].value_float = 4.f;
put += AddCommandWithExpect(entries + put,
- BufferSyncInterface::PARSE_NO_ERROR,
+ BufferSyncInterface::kParseNoError,
1,
2,
args1);
@@ -355,7 +355,7 @@ TEST_F(CommandBufferEngineTest, TestSetBufferAndClose) {
args2[0].value_uint32 = 5;
args2[1].value_float = 6.f;
put += AddCommandWithExpect(entries + put,
- BufferSyncInterface::PARSE_NO_ERROR,
+ BufferSyncInterface::kParseNoError,
2,
2,
args2);
@@ -371,8 +371,8 @@ TEST_F(CommandBufferEngineTest, TestSetBufferAndClose) {
CommandBufferEntry *entries2 = static_cast<CommandBufferEntry *>(
engine()->GetSharedMemoryAddress(shm_id));
engine()->SetCommandBuffer(shm_id, 0, kShmSize, 0);
- EXPECT_EQ(BufferSyncInterface::PARSING, engine()->GetStatus());
- EXPECT_EQ(BufferSyncInterface::PARSE_NO_ERROR, engine()->GetParseError());
+ EXPECT_EQ(BufferSyncInterface::kParsing, engine()->GetStatus());
+ EXPECT_EQ(BufferSyncInterface::kParseNoError, engine()->GetParseError());
EXPECT_EQ(0, engine()->Get());
// Destroy the old command buffer.
@@ -381,7 +381,7 @@ TEST_F(CommandBufferEngineTest, TestSetBufferAndClose) {
get = engine()->Get();
put = get;
put += AddCommandWithExpect(entries2 + put,
- BufferSyncInterface::PARSE_NO_ERROR,
+ BufferSyncInterface::kParseNoError,
1,
2,
args1);
@@ -409,7 +409,7 @@ TEST_F(CommandBufferEngineTest, TestRecoverableError) {
// Create a command buffer with 3 commands, 2 of them generating errors
put += AddCommandWithExpect(entries + put,
- BufferSyncInterface::PARSE_NO_ERROR,
+ BufferSyncInterface::kParseNoError,
0,
0,
NULL);
@@ -418,7 +418,7 @@ TEST_F(CommandBufferEngineTest, TestRecoverableError) {
args1[0].value_uint32 = 3;
args1[1].value_float = 4.f;
put += AddCommandWithExpect(entries + put,
- BufferSyncInterface::PARSE_INVALID_ARGUMENTS,
+ BufferSyncInterface::kParseInvalidArguments,
1,
2,
args1);
@@ -427,7 +427,7 @@ TEST_F(CommandBufferEngineTest, TestRecoverableError) {
args2[0].value_uint32 = 5;
args2[1].value_float = 6.f;
put += AddCommandWithExpect(entries + put,
- BufferSyncInterface::PARSE_UNKNOWN_COMMAND,
+ BufferSyncInterface::kParseUnknownCommand,
2,
2,
args2);
@@ -437,7 +437,7 @@ TEST_F(CommandBufferEngineTest, TestRecoverableError) {
// Check that the parsing progresses, and that no error occurs.
CommandBufferOffset new_get = engine()->WaitGetChanges(get);
EXPECT_NE(get, new_get);
- ASSERT_EQ(BufferSyncInterface::PARSING, engine()->GetStatus());
+ ASSERT_EQ(BufferSyncInterface::kParsing, engine()->GetStatus());
EXPECT_EQ(new_get, engine()->Get());
get = new_get;
}
@@ -445,10 +445,10 @@ TEST_F(CommandBufferEngineTest, TestRecoverableError) {
Mock::VerifyAndClearExpectations(api_mock());
// Check that the error status was set to the first error.
- EXPECT_EQ(BufferSyncInterface::PARSE_INVALID_ARGUMENTS,
+ EXPECT_EQ(BufferSyncInterface::kParseInvalidArguments,
engine()->GetParseError());
// Check that the error status was reset after the query.
- EXPECT_EQ(BufferSyncInterface::PARSE_NO_ERROR, engine()->GetParseError());
+ EXPECT_EQ(BufferSyncInterface::kParseNoError, engine()->GetParseError());
engine()->CloseConnection();
DestroyCommandBuffer();
@@ -477,7 +477,7 @@ TEST_F(CommandBufferEngineTest, TestNonRecoverableError) {
// Create a command buffer with 3 commands, the last one overlapping the end
// of the buffer.
put += AddCommandWithExpect(entries + put,
- BufferSyncInterface::PARSE_NO_ERROR,
+ BufferSyncInterface::kParseNoError,
0,
0,
NULL);
@@ -486,7 +486,7 @@ TEST_F(CommandBufferEngineTest, TestNonRecoverableError) {
args1[0].value_uint32 = 3;
args1[1].value_float = 4.f;
put += AddCommandWithExpect(entries + put,
- BufferSyncInterface::PARSE_NO_ERROR,
+ BufferSyncInterface::kParseNoError,
1,
2,
args1);
@@ -514,12 +514,12 @@ TEST_F(CommandBufferEngineTest, TestNonRecoverableError) {
get = new_get;
}
// We should be in an error case now.
- EXPECT_EQ(BufferSyncInterface::PARSE_ERROR, engine()->GetStatus());
+ EXPECT_EQ(BufferSyncInterface::kParseError, engine()->GetStatus());
// Check that the error status was set to the first error.
- EXPECT_EQ(BufferSyncInterface::PARSE_OUT_OF_BOUNDS,
+ EXPECT_EQ(BufferSyncInterface::kParseOutOfBounds,
engine()->GetParseError());
// Check that the error status was reset after the query.
- EXPECT_EQ(BufferSyncInterface::PARSE_NO_ERROR, engine()->GetParseError());
+ EXPECT_EQ(BufferSyncInterface::kParseNoError, engine()->GetParseError());
// Check that the valid commands did happen.
Mock::VerifyAndClearExpectations(api_mock());
@@ -568,7 +568,7 @@ TEST_F(CommandBufferEngineTest, TestDoWork) {
process_mock()->Reset();
EXPECT_CALL(*process_mock(), HasMessage()).Times(AnyNumber());
put += AddCommandWithExpect(entries + put,
- BufferSyncInterface::PARSE_NO_ERROR,
+ BufferSyncInterface::kParseNoError,
0,
0,
NULL);
@@ -577,7 +577,7 @@ TEST_F(CommandBufferEngineTest, TestDoWork) {
args1[0].value_uint32 = 3;
args1[1].value_float = 4.f;
put += AddCommandWithExpect(entries + put,
- BufferSyncInterface::PARSE_NO_ERROR,
+ BufferSyncInterface::kParseNoError,
1,
2,
args1);
@@ -586,7 +586,7 @@ TEST_F(CommandBufferEngineTest, TestDoWork) {
args2[0].value_uint32 = 5;
args2[1].value_float = 6.f;
put += AddCommandWithExpect(entries + put,
- BufferSyncInterface::PARSE_NO_ERROR,
+ BufferSyncInterface::kParseNoError,
2,
2,
args2);
@@ -603,8 +603,8 @@ TEST_F(CommandBufferEngineTest, TestDoWork) {
EXPECT_FALSE(process_mock()->would_have_blocked());
get = engine()->Get();
EXPECT_EQ(put, get); // once we're done, we should have executed everything.
- ASSERT_EQ(BufferSyncInterface::PARSING, engine()->GetStatus());
- EXPECT_EQ(BufferSyncInterface::PARSE_NO_ERROR, engine()->GetParseError());
+ ASSERT_EQ(BufferSyncInterface::kParsing, engine()->GetStatus());
+ EXPECT_EQ(BufferSyncInterface::kParseNoError, engine()->GetParseError());
Mock::VerifyAndClearExpectations(process_mock());
Mock::VerifyAndClearExpectations(api_mock());
diff --git a/o3d/command_buffer/service/cross/cmd_parser.cc b/o3d/command_buffer/service/cross/cmd_parser.cc
index a640d3d..843d0b8 100644
--- a/o3d/command_buffer/service/cross/cmd_parser.cc
+++ b/o3d/command_buffer/service/cross/cmd_parser.cc
@@ -66,14 +66,14 @@ CommandParser::CommandParser(void *shm_address,
// - get_ is modified *after* the command has been executed.
BufferSyncInterface::ParseError CommandParser::ProcessCommand() {
CommandBufferOffset get = get_;
- if (get == put_) return BufferSyncInterface::PARSE_NO_ERROR;
+ if (get == put_) return BufferSyncInterface::kParseNoError;
CommandHeader header = buffer_[get].value_header;
- if (header.size == 0) return BufferSyncInterface::PARSE_INVALID_SIZE;
+ if (header.size == 0) return BufferSyncInterface::kParseInvalidSize;
if (header.size + get > entry_count_)
- return BufferSyncInterface::PARSE_OUT_OF_BOUNDS;
+ return BufferSyncInterface::kParseOutOfBounds;
BufferSyncInterface::ParseError result = handler_->DoCommand(
- header.command, header.size - 1, buffer_ + get + 1);
+ header.command, header.size - 1, buffer_ + get);
get_ = (get + header.size) % entry_count_;
return result;
}
@@ -85,7 +85,7 @@ BufferSyncInterface::ParseError CommandParser::ProcessAllCommands() {
BufferSyncInterface::ParseError error = ProcessCommand();
if (error) return error;
}
- return BufferSyncInterface::PARSE_NO_ERROR;
+ return BufferSyncInterface::kParseNoError;
}
} // namespace command_buffer
diff --git a/o3d/command_buffer/service/cross/cmd_parser.h b/o3d/command_buffer/service/cross/cmd_parser.h
index 9c3a145..425e8d9 100644
--- a/o3d/command_buffer/service/cross/cmd_parser.h
+++ b/o3d/command_buffer/service/cross/cmd_parser.h
@@ -97,14 +97,14 @@ class AsyncAPIInterface {
// Parameters:
// command: the command index.
// arg_count: the number of CommandBufferEntry arguments.
- // args: the arguments.
+ // cmd_data: the command data.
// Returns:
// BufferSyncInterface::NO_ERROR if no error was found, one of
// BufferSyncInterface::ParseError otherwise.
virtual BufferSyncInterface::ParseError DoCommand(
unsigned int command,
unsigned int arg_count,
- const void* args) = 0;
+ const void* cmd_data) = 0;
};
} // namespace command_buffer
diff --git a/o3d/command_buffer/service/cross/cmd_parser_test.cc b/o3d/command_buffer/service/cross/cmd_parser_test.cc
index a63489c..3d50d8a 100644
--- a/o3d/command_buffer/service/cross/cmd_parser_test.cc
+++ b/o3d/command_buffer/service/cross/cmd_parser_test.cc
@@ -115,8 +115,8 @@ TEST_F(CommandParserTest, TestSimple) {
parser->set_put(put);
EXPECT_EQ(put, parser->put());
- AddDoCommandExpect(BufferSyncInterface::PARSE_NO_ERROR, 123, 0, NULL);
- EXPECT_EQ(BufferSyncInterface::PARSE_NO_ERROR, parser->ProcessCommand());
+ AddDoCommandExpect(BufferSyncInterface::kParseNoError, 123, 0, NULL);
+ EXPECT_EQ(BufferSyncInterface::kParseNoError, parser->ProcessCommand());
EXPECT_EQ(put, parser->get());
Mock::VerifyAndClearExpectations(api_mock());
@@ -133,8 +133,8 @@ TEST_F(CommandParserTest, TestSimple) {
CommandBufferEntry param_array[2];
param_array[0].value_int32 = 2134;
param_array[1].value_float = 1.f;
- AddDoCommandExpect(BufferSyncInterface::PARSE_NO_ERROR, 456, 2, param_array);
- EXPECT_EQ(BufferSyncInterface::PARSE_NO_ERROR, parser->ProcessCommand());
+ AddDoCommandExpect(BufferSyncInterface::kParseNoError, 456, 2, param_array);
+ EXPECT_EQ(BufferSyncInterface::kParseNoError, parser->ProcessCommand());
EXPECT_EQ(put, parser->get());
Mock::VerifyAndClearExpectations(api_mock());
}
@@ -162,14 +162,14 @@ TEST_F(CommandParserTest, TestMultipleCommands) {
CommandBufferEntry param_array[2];
param_array[0].value_int32 = 5151;
- AddDoCommandExpect(BufferSyncInterface::PARSE_NO_ERROR, 789, 1, param_array);
+ AddDoCommandExpect(BufferSyncInterface::kParseNoError, 789, 1, param_array);
param_array[1].value_int32 = 3434;
- AddDoCommandExpect(BufferSyncInterface::PARSE_NO_ERROR, 2121, 1,
+ AddDoCommandExpect(BufferSyncInterface::kParseNoError, 2121, 1,
param_array+1);
- EXPECT_EQ(BufferSyncInterface::PARSE_NO_ERROR, parser->ProcessCommand());
+ EXPECT_EQ(BufferSyncInterface::kParseNoError, parser->ProcessCommand());
EXPECT_EQ(put_cmd2, parser->get());
- EXPECT_EQ(BufferSyncInterface::PARSE_NO_ERROR, parser->ProcessCommand());
+ EXPECT_EQ(BufferSyncInterface::kParseNoError, parser->ProcessCommand());
EXPECT_EQ(put, parser->get());
Mock::VerifyAndClearExpectations(api_mock());
@@ -188,12 +188,12 @@ TEST_F(CommandParserTest, TestMultipleCommands) {
EXPECT_EQ(put, parser->put());
param_array[0].value_int32 = 5656;
- AddDoCommandExpect(BufferSyncInterface::PARSE_NO_ERROR, 4545, 1, param_array);
+ AddDoCommandExpect(BufferSyncInterface::kParseNoError, 4545, 1, param_array);
param_array[1].value_int32 = 7878;
- AddDoCommandExpect(BufferSyncInterface::PARSE_NO_ERROR, 6767, 1,
+ AddDoCommandExpect(BufferSyncInterface::kParseNoError, 6767, 1,
param_array+1);
- EXPECT_EQ(BufferSyncInterface::PARSE_NO_ERROR, parser->ProcessAllCommands());
+ EXPECT_EQ(BufferSyncInterface::kParseNoError, parser->ProcessAllCommands());
EXPECT_EQ(put, parser->get());
Mock::VerifyAndClearExpectations(api_mock());
}
@@ -209,11 +209,11 @@ TEST_F(CommandParserTest, TestWrap) {
header.size = 1;
header.command = i;
buffer()[put++].value_header = header;
- AddDoCommandExpect(BufferSyncInterface::PARSE_NO_ERROR, i, 0, NULL);
+ AddDoCommandExpect(BufferSyncInterface::kParseNoError, i, 0, NULL);
}
parser->set_put(put);
EXPECT_EQ(put, parser->put());
- EXPECT_EQ(BufferSyncInterface::PARSE_NO_ERROR, parser->ProcessAllCommands());
+ EXPECT_EQ(BufferSyncInterface::kParseNoError, parser->ProcessAllCommands());
EXPECT_EQ(put, parser->get());
Mock::VerifyAndClearExpectations(api_mock());
@@ -225,13 +225,13 @@ TEST_F(CommandParserTest, TestWrap) {
buffer()[put++].value_int32 = 5;
CommandBufferEntry param;
param.value_int32 = 5;
- AddDoCommandExpect(BufferSyncInterface::PARSE_NO_ERROR, 3, 1, &param);
+ AddDoCommandExpect(BufferSyncInterface::kParseNoError, 3, 1, &param);
DCHECK_EQ(5, put);
put = 0;
parser->set_put(put);
EXPECT_EQ(put, parser->put());
- EXPECT_EQ(BufferSyncInterface::PARSE_NO_ERROR, parser->ProcessAllCommands());
+ EXPECT_EQ(BufferSyncInterface::kParseNoError, parser->ProcessAllCommands());
EXPECT_EQ(put, parser->get());
Mock::VerifyAndClearExpectations(api_mock());
@@ -241,10 +241,10 @@ TEST_F(CommandParserTest, TestWrap) {
buffer()[put++].value_header = header;
buffer()[put++].value_int32 = 6;
param.value_int32 = 6;
- AddDoCommandExpect(BufferSyncInterface::PARSE_NO_ERROR, 4, 1, &param);
+ AddDoCommandExpect(BufferSyncInterface::kParseNoError, 4, 1, &param);
parser->set_put(put);
EXPECT_EQ(put, parser->put());
- EXPECT_EQ(BufferSyncInterface::PARSE_NO_ERROR, parser->ProcessAllCommands());
+ EXPECT_EQ(BufferSyncInterface::kParseNoError, parser->ProcessAllCommands());
EXPECT_EQ(put, parser->get());
Mock::VerifyAndClearExpectations(api_mock());
}
@@ -262,7 +262,7 @@ TEST_F(CommandParserTest, TestError) {
parser->set_put(put);
EXPECT_EQ(put, parser->put());
- EXPECT_EQ(BufferSyncInterface::PARSE_INVALID_SIZE,
+ EXPECT_EQ(BufferSyncInterface::kParseInvalidSize,
parser->ProcessAllCommands());
// check that no DoCommand call was made.
Mock::VerifyAndClearExpectations(api_mock());
@@ -277,7 +277,7 @@ TEST_F(CommandParserTest, TestError) {
parser->set_put(put);
EXPECT_EQ(put, parser->put());
- EXPECT_EQ(BufferSyncInterface::PARSE_OUT_OF_BOUNDS,
+ EXPECT_EQ(BufferSyncInterface::kParseOutOfBounds,
parser->ProcessAllCommands());
// check that no DoCommand call was made.
Mock::VerifyAndClearExpectations(api_mock());
@@ -297,16 +297,16 @@ TEST_F(CommandParserTest, TestError) {
parser->set_put(put);
EXPECT_EQ(put, parser->put());
// have the first command fail to parse.
- AddDoCommandExpect(BufferSyncInterface::PARSE_UNKNOWN_COMMAND, 3, 0, NULL);
- EXPECT_EQ(BufferSyncInterface::PARSE_UNKNOWN_COMMAND,
+ AddDoCommandExpect(BufferSyncInterface::kParseUnknownCommand, 3, 0, NULL);
+ EXPECT_EQ(BufferSyncInterface::kParseUnknownCommand,
parser->ProcessAllCommands());
// check that only one command was executed, and that get reflects that
// correctly.
EXPECT_EQ(put_post_fail, parser->get());
Mock::VerifyAndClearExpectations(api_mock());
// make the second one succeed, and check that the parser recovered fine.
- AddDoCommandExpect(BufferSyncInterface::PARSE_NO_ERROR, 4, 0, NULL);
- EXPECT_EQ(BufferSyncInterface::PARSE_NO_ERROR, parser->ProcessAllCommands());
+ AddDoCommandExpect(BufferSyncInterface::kParseNoError, 4, 0, NULL);
+ EXPECT_EQ(BufferSyncInterface::kParseNoError, parser->ProcessAllCommands());
EXPECT_EQ(put, parser->get());
Mock::VerifyAndClearExpectations(api_mock());
}
diff --git a/o3d/command_buffer/service/cross/effect_utils.h b/o3d/command_buffer/service/cross/effect_utils.h
index 2402254..e4bad72 100644
--- a/o3d/command_buffer/service/cross/effect_utils.h
+++ b/o3d/command_buffer/service/cross/effect_utils.h
@@ -40,7 +40,7 @@
namespace o3d {
namespace command_buffer {
-// This function parses the data passed to the CREATE_EFFECT commands, which
+// This function parses the data passed to the CreateEffect commands, which
// follows the following format:
// vertex_program_entry \0 fragment_program_entry \0 effect_code
// It returns the various components.
diff --git a/o3d/command_buffer/service/cross/gapi_decoder.cc b/o3d/command_buffer/service/cross/gapi_decoder.cc
index aa9f019..e19b67a 100644
--- a/o3d/command_buffer/service/cross/gapi_decoder.cc
+++ b/o3d/command_buffer/service/cross/gapi_decoder.cc
@@ -43,30 +43,32 @@ namespace command_buffer {
namespace {
+// Returns the address of the first byte after a struct.
template <typename T>
const void* AddressAfterStruct(const T& pod) {
return reinterpret_cast<const uint8*>(&pod) + sizeof(pod);
}
+// Returns the size in bytes of the data of an Immediate command, a command with
+// its data inline in the command buffer.
template <typename T>
-unsigned int ImmediateSize(uint32 arg_count, const T& pod) {
- return (arg_count - sizeof(pod) / sizeof(uint32)) * sizeof(uint32);
-}
-
-// TODO(gman): Remove this.
-CommandBufferEntry* TempHack(const void* foo) {
- return reinterpret_cast<CommandBufferEntry*>(const_cast<void*>(foo));
+unsigned int ImmediateDataSize(uint32 arg_count, const T& pod) {
+ return static_cast<unsigned int>(
+ (arg_count + 1 - ComputeNumEntries(sizeof(pod))) *
+ sizeof(CommandBufferEntry)); // NOLINT
}
+// A struct to hold info about each command.
struct CommandInfo {
- int arg_flags;
- int arg_count;
+ int arg_flags; // How to handle the arguments for this command
+ int arg_count; // How many arguments are expected for this command.
};
+// A table of CommandInfo for all the commands.
const CommandInfo g_command_info[] = {
- #define O3D_COMMAND_BUFFER_CMD_OP(name) { \
- cmd::name::kArgFlags, \
- sizeof(cmd::name) / sizeof(uint32), }, \
+ #define O3D_COMMAND_BUFFER_CMD_OP(name) { \
+ cmd::name::kArgFlags, \
+ sizeof(cmd::name) / sizeof(CommandBufferEntry) - 1, }, /* NOLINT */ \
O3D_COMMAND_BUFFER_CMDS
@@ -83,355 +85,28 @@ const CommandInfo g_command_info[] = {
BufferSyncInterface::ParseError GAPIDecoder::DoCommand(
unsigned int command,
unsigned int arg_count,
- const void* args) {
+ const void* cmd_data) {
if (command < arraysize(g_command_info)) {
const CommandInfo& info = g_command_info[command];
- unsigned int info_arg_count = static_cast<unsigned int>(info.arg_count);
+ unsigned int info_arg_count = static_cast<unsigned int>(info.arg_count);
if ((info.arg_flags == cmd::kFixed && arg_count == info_arg_count) ||
(info.arg_flags == cmd::kAtLeastN && arg_count > info_arg_count)) {
switch (command) {
#define O3D_COMMAND_BUFFER_CMD_OP(name) \
case cmd::name::kCmdId: \
- return Handle_ ## name( \
+ return Handle ## name( \
arg_count, \
- *static_cast<const cmd::name*>(args)); \
+ *static_cast<const cmd::name*>(cmd_data)); \
O3D_COMMAND_BUFFER_CMDS
#undef O3D_COMMAND_BUFFER_CMD_OP
}
} else {
- return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ return BufferSyncInterface::kParseInvalidArguments;
}
}
- return BufferSyncInterface::PARSE_UNKNOWN_COMMAND;
-}
-
-
-// Decodes the SET_VERTEX_INPUT command.
-BufferSyncInterface::ParseError GAPIDecoder::DecodeSetVertexInput(
- unsigned int arg_count,
- CommandBufferEntry *args) {
- namespace cmd = set_vertex_input_cmd;
- if (arg_count != 5) return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
- ResourceID vertex_struct_id = args[0].value_uint32;
- unsigned int input_index = args[1].value_uint32;
- ResourceID vertex_buffer_id = args[2].value_uint32;
- unsigned int offset = args[3].value_uint32;
- unsigned int type_stride_semantic = args[4].value_uint32;
- unsigned int semantic_index = cmd::SemanticIndex::Get(type_stride_semantic);
- unsigned int semantic = cmd::Semantic::Get(type_stride_semantic);
- unsigned int type = cmd::Type::Get(type_stride_semantic);
- unsigned int stride = cmd::Stride::Get(type_stride_semantic);
- if (semantic >= vertex_struct::NUM_SEMANTICS ||
- type >= vertex_struct::NUM_TYPES || stride == 0)
- return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
- return gapi_->SetVertexInput(vertex_struct_id, input_index, vertex_buffer_id,
- offset, stride,
- static_cast<vertex_struct::Type>(type),
- static_cast<vertex_struct::Semantic>(semantic),
- semantic_index);
-}
-
-// Decodes the CREATE_TEXTURE_2D command.
-BufferSyncInterface::ParseError GAPIDecoder::DecodeCreateTexture2D(
- unsigned int arg_count,
- CommandBufferEntry *args) {
- if (arg_count == 3) {
- namespace cmd = create_texture_2d_cmd;
- unsigned int id = args[0].value_uint32;
- unsigned int width_height = args[1].value_uint32;
- unsigned int levels_format_flags = args[2].value_uint32;
- unsigned int width = cmd::Width::Get(width_height);
- unsigned int height = cmd::Height::Get(width_height);
- unsigned int levels = cmd::Levels::Get(levels_format_flags);
- unsigned int unused = cmd::Unused::Get(levels_format_flags);
- unsigned int format = cmd::Format::Get(levels_format_flags);
- unsigned int flags = cmd::Flags::Get(levels_format_flags);
- unsigned int max_levels =
- 1 + base::bits::Log2Ceiling(std::max(width, height));
- if ((width == 0) || (height == 0) || (levels > max_levels) ||
- (unused != 0) || (format >= texture::NUM_FORMATS))
- return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
- if (levels == 0) levels = max_levels;
- bool enable_render_surfaces = !!flags;
- return gapi_->CreateTexture2D(id, width, height, levels,
- static_cast<texture::Format>(format), flags,
- enable_render_surfaces);
- } else {
- return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
- }
-}
-
-// Decodes the CREATE_TEXTURE_3D command.
-BufferSyncInterface::ParseError GAPIDecoder::DecodeCreateTexture3D(
- unsigned int arg_count,
- CommandBufferEntry *args) {
- if (arg_count == 4) {
- namespace cmd = create_texture_3d_cmd;
- unsigned int id = args[0].value_uint32;
- unsigned int width_height = args[1].value_uint32;
- unsigned int depth_unused = args[2].value_uint32;
- unsigned int levels_format_flags = args[3].value_uint32;
- unsigned int width = cmd::Width::Get(width_height);
- unsigned int height = cmd::Height::Get(width_height);
- unsigned int depth = cmd::Depth::Get(depth_unused);
- unsigned int unused1 = cmd::Unused1::Get(depth_unused);
- unsigned int levels = cmd::Levels::Get(levels_format_flags);
- unsigned int unused2 = cmd::Unused2::Get(levels_format_flags);
- unsigned int format = cmd::Format::Get(levels_format_flags);
- unsigned int flags = cmd::Flags::Get(levels_format_flags);
- unsigned int max_levels =
- 1 + base::bits::Log2Ceiling(std::max(depth, std::max(width, height)));
- if ((width == 0) || (height == 0) || (depth == 0) ||
- (levels > max_levels) || (unused1 != 0) || (unused2 != 0) ||
- (format >= texture::NUM_FORMATS))
- return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
- if (levels == 0) levels = max_levels;
- bool enable_render_surfaces = !!flags;
- return gapi_->CreateTexture3D(id, width, height, depth, levels,
- static_cast<texture::Format>(format), flags,
- enable_render_surfaces);
- } else {
- return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
- }
-}
-
-// Decodes the CREATE_TEXTURE_CUBE command.
-BufferSyncInterface::ParseError GAPIDecoder::DecodeCreateTextureCube(
- unsigned int arg_count,
- CommandBufferEntry *args) {
- if (arg_count == 3) {
- namespace cmd = create_texture_cube_cmd;
- unsigned int id = args[0].value_uint32;
- unsigned int side_unused = args[1].value_uint32;
- unsigned int levels_format_flags = args[2].value_uint32;
- unsigned int side = cmd::Side::Get(side_unused);
- unsigned int unused1 = cmd::Unused1::Get(side_unused);
- unsigned int levels = cmd::Levels::Get(levels_format_flags);
- unsigned int unused2 = cmd::Unused2::Get(levels_format_flags);
- unsigned int format = cmd::Format::Get(levels_format_flags);
- unsigned int flags = cmd::Flags::Get(levels_format_flags);
- unsigned int max_levels = 1 + base::bits::Log2Ceiling(side);
- if ((side == 0) || (levels > max_levels) || (unused1 != 0) ||
- (unused2 != 0) || (format >= texture::NUM_FORMATS))
- return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
- if (levels == 0) levels = max_levels;
- bool enable_render_surfaces = !!flags;
- return gapi_->CreateTextureCube(id, side, levels,
- static_cast<texture::Format>(format),
- flags, enable_render_surfaces);
- } else {
- return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
- }
-}
-
-// Decodes the SET_TEXTURE_DATA command.
-BufferSyncInterface::ParseError GAPIDecoder::DecodeSetTextureData(
- unsigned int arg_count,
- CommandBufferEntry *args) {
- if (arg_count == 10) {
- namespace cmd = set_texture_data_cmd;
- unsigned int id = args[0].value_uint32;
- unsigned int x_y = args[1].value_uint32;
- unsigned int width_height = args[2].value_uint32;
- unsigned int z_depth = args[3].value_uint32;
- unsigned int level_face = args[4].value_uint32;
- unsigned int row_pitch = args[5].value_uint32;
- unsigned int slice_pitch = args[6].value_uint32;
- unsigned int size = args[7].value_uint32;
- unsigned int shm_id = args[8].value_uint32;
- unsigned int offset = args[9].value_uint32;
- unsigned int x = cmd::X::Get(x_y);
- unsigned int y = cmd::Y::Get(x_y);
- unsigned int width = cmd::Width::Get(width_height);
- unsigned int height = cmd::Height::Get(width_height);
- unsigned int z = cmd::Z::Get(z_depth);
- unsigned int depth = cmd::Depth::Get(z_depth);
- unsigned int level = cmd::Level::Get(level_face);
- unsigned int face = cmd::Face::Get(level_face);
- unsigned int unused = cmd::Unused::Get(level_face);
- const void *data = GetAddressAndCheckSize(shm_id, offset, size);
- if (face >= 6 || unused != 0 || !data)
- return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
- return gapi_->SetTextureData(id, x, y, z, width, height, depth, level,
- static_cast<texture::Face>(face), row_pitch,
- slice_pitch, size, data);
-
- } else {
- return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
- }
-}
-
-// Decodes the SET_TEXTURE_DATA_IMMEDIATE command.
-BufferSyncInterface::ParseError GAPIDecoder::DecodeSetTextureDataImmediate(
- unsigned int arg_count,
- CommandBufferEntry *args) {
- if (arg_count > 8) {
- namespace cmd = set_texture_data_immediate_cmd;
- unsigned int id = args[0].value_uint32;
- unsigned int x_y = args[1].value_uint32;
- unsigned int width_height = args[2].value_uint32;
- unsigned int z_depth = args[3].value_uint32;
- unsigned int level_face = args[4].value_uint32;
- unsigned int row_pitch = args[5].value_uint32;
- unsigned int slice_pitch = args[6].value_uint32;
- unsigned int size = args[7].value_uint32;
- unsigned int x = cmd::X::Get(x_y);
- unsigned int y = cmd::Y::Get(x_y);
- unsigned int width = cmd::Width::Get(width_height);
- unsigned int height = cmd::Height::Get(width_height);
- unsigned int z = cmd::Z::Get(z_depth);
- unsigned int depth = cmd::Depth::Get(z_depth);
- unsigned int level = cmd::Level::Get(level_face);
- unsigned int face = cmd::Face::Get(level_face);
- unsigned int unused = cmd::Unused::Get(level_face);
- if (face >= 6 || unused != 0 ||
- size > (arg_count - 5) * sizeof(args[0]))
- return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
- return gapi_->SetTextureData(id, x, y, z, width, height, depth, level,
- static_cast<texture::Face>(face), row_pitch,
- slice_pitch, size, args + 8);
- } else {
- return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
- }
-}
-
-// Decodes the GET_TEXTURE_DATA command.
-BufferSyncInterface::ParseError GAPIDecoder::DecodeGetTextureData(
- unsigned int arg_count,
- CommandBufferEntry *args) {
- if (arg_count == 10) {
- namespace cmd = get_texture_data_cmd;
- unsigned int id = args[0].value_uint32;
- unsigned int x_y = args[1].value_uint32;
- unsigned int width_height = args[2].value_uint32;
- unsigned int z_depth = args[3].value_uint32;
- unsigned int level_face = args[4].value_uint32;
- unsigned int row_pitch = args[5].value_uint32;
- unsigned int slice_pitch = args[6].value_uint32;
- unsigned int size = args[7].value_uint32;
- unsigned int shm_id = args[8].value_uint32;
- unsigned int offset = args[9].value_uint32;
- unsigned int x = cmd::X::Get(x_y);
- unsigned int y = cmd::Y::Get(x_y);
- unsigned int width = cmd::Width::Get(width_height);
- unsigned int height = cmd::Height::Get(width_height);
- unsigned int z = cmd::Z::Get(z_depth);
- unsigned int depth = cmd::Depth::Get(z_depth);
- unsigned int level = cmd::Level::Get(level_face);
- unsigned int face = cmd::Face::Get(level_face);
- unsigned int unused = cmd::Unused::Get(level_face);
- void *data = GetAddressAndCheckSize(shm_id, offset, size);
- if (face >= 6 || unused != 0 || !data)
- return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
- return gapi_->GetTextureData(id, x, y, z, width, height, depth, level,
- static_cast<texture::Face>(face), row_pitch,
- slice_pitch, size, data);
-
- } else {
- return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
- }
-}
-
-// Decodes the SET_SAMPLER_STATES command.
-BufferSyncInterface::ParseError GAPIDecoder::DecodeSetSamplerStates(
- unsigned int arg_count,
- CommandBufferEntry *args) {
- namespace cmd = set_sampler_states;
- if (arg_count != 2)
- return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
- ResourceID id = args[0].value_uint32;
- Uint32 arg = args[1].value_uint32;
- if (cmd::Unused::Get(arg) != 0)
- return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
- unsigned int address_u_value = cmd::AddressingU::Get(arg);
- unsigned int address_v_value = cmd::AddressingV::Get(arg);
- unsigned int address_w_value = cmd::AddressingW::Get(arg);
- unsigned int mag_filter_value = cmd::MagFilter::Get(arg);
- unsigned int min_filter_value = cmd::MinFilter::Get(arg);
- unsigned int mip_filter_value = cmd::MipFilter::Get(arg);
- unsigned int max_anisotropy = cmd::MaxAnisotropy::Get(arg);
- if (address_u_value >= sampler::NUM_ADDRESSING_MODE ||
- address_v_value >= sampler::NUM_ADDRESSING_MODE ||
- address_w_value >= sampler::NUM_ADDRESSING_MODE ||
- mag_filter_value >= sampler::NUM_FILTERING_MODE ||
- min_filter_value >= sampler::NUM_FILTERING_MODE ||
- mip_filter_value >= sampler::NUM_FILTERING_MODE ||
- mag_filter_value == sampler::NONE ||
- min_filter_value == sampler::NONE ||
- max_anisotropy == 0) {
- return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
- }
- gapi_->SetSamplerStates(
- id,
- static_cast<sampler::AddressingMode>(address_u_value),
- static_cast<sampler::AddressingMode>(address_v_value),
- static_cast<sampler::AddressingMode>(address_w_value),
- static_cast<sampler::FilteringMode>(mag_filter_value),
- static_cast<sampler::FilteringMode>(min_filter_value),
- static_cast<sampler::FilteringMode>(mip_filter_value),
- max_anisotropy);
- return BufferSyncInterface::PARSE_NO_ERROR;
-}
-
-// Decodes the SET_STENCIL_TEST command.
-BufferSyncInterface::ParseError GAPIDecoder::DecodeSetStencilTest(
- unsigned int arg_count,
- CommandBufferEntry *args) {
- namespace cmd = set_stencil_test;
- if (arg_count != 2)
- return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
- Uint32 arg0 = args[0].value_uint32;
- Uint32 arg1 = args[1].value_uint32;
- if (cmd::Unused0::Get(arg0) != 0 ||
- cmd::Unused1::Get(arg1) != 0 ||
- cmd::Unused2::Get(arg1) != 0)
- return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
- unsigned int write_mask = cmd::WriteMask::Get(arg0);
- unsigned int compare_mask = cmd::CompareMask::Get(arg0);
- unsigned int ref = cmd::ReferenceValue::Get(arg0);
- bool enable = cmd::Enable::Get(arg0) != 0;
- bool separate_ccw = cmd::SeparateCCW::Get(arg0) != 0;
- gapi_->SetStencilTest(enable, separate_ccw, write_mask, compare_mask, ref,
- arg1);
- return BufferSyncInterface::PARSE_NO_ERROR;
-}
-
-// Decodes the SET_BLENDING command.
-BufferSyncInterface::ParseError GAPIDecoder::DecodeSetBlending(
- unsigned int arg_count,
- CommandBufferEntry *args) {
- namespace cmd = set_blending;
- if (arg_count != 1)
- return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
- Uint32 arg = args[0].value_uint32;
- bool enable = cmd::Enable::Get(arg) != 0;
- bool separate_alpha = cmd::SeparateAlpha::Get(arg) != 0;
- unsigned int color_eq = cmd::ColorEq::Get(arg);
- unsigned int color_src = cmd::ColorSrcFunc::Get(arg);
- unsigned int color_dst = cmd::ColorDstFunc::Get(arg);
- unsigned int alpha_eq = cmd::AlphaEq::Get(arg);
- unsigned int alpha_src = cmd::AlphaSrcFunc::Get(arg);
- unsigned int alpha_dst = cmd::AlphaDstFunc::Get(arg);
- if (cmd::Unused0::Get(arg) != 0 ||
- cmd::Unused1::Get(arg) != 0 ||
- color_eq >= GAPIInterface::NUM_BLEND_EQ ||
- color_src >= GAPIInterface::NUM_BLEND_FUNC ||
- color_dst >= GAPIInterface::NUM_BLEND_FUNC ||
- alpha_eq >= GAPIInterface::NUM_BLEND_EQ ||
- alpha_src >= GAPIInterface::NUM_BLEND_FUNC ||
- alpha_dst >= GAPIInterface::NUM_BLEND_FUNC)
- return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
- gapi_->SetBlending(enable,
- separate_alpha,
- static_cast<GAPIInterface::BlendEq>(color_eq),
- static_cast<GAPIInterface::BlendFunc>(color_src),
- static_cast<GAPIInterface::BlendFunc>(color_dst),
- static_cast<GAPIInterface::BlendEq>(alpha_eq),
- static_cast<GAPIInterface::BlendFunc>(alpha_src),
- static_cast<GAPIInterface::BlendFunc>(alpha_dst));
- return BufferSyncInterface::PARSE_NO_ERROR;
+ return BufferSyncInterface::kParseUnknownCommand;
}
void *GAPIDecoder::GetAddressAndCheckSize(unsigned int shm_id,
@@ -444,426 +119,586 @@ void *GAPIDecoder::GetAddressAndCheckSize(unsigned int shm_id,
return static_cast<char *>(shm_addr) + offset;
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_NOOP(
+BufferSyncInterface::ParseError GAPIDecoder::HandleNoop(
uint32 arg_count,
- const cmd::NOOP& args) {
- return BufferSyncInterface::PARSE_NO_ERROR;
+ const cmd::Noop& args) {
+ return BufferSyncInterface::kParseNoError;
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_TOKEN(
+BufferSyncInterface::ParseError GAPIDecoder::HandleSetToken(
uint32 arg_count,
- const cmd::SET_TOKEN& args) {
+ const cmd::SetToken& args) {
engine_->set_token(args.token);
- return BufferSyncInterface::PARSE_NO_ERROR;
+ return BufferSyncInterface::kParseNoError;
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_BEGIN_FRAME(
+BufferSyncInterface::ParseError GAPIDecoder::HandleBeginFrame(
uint32 arg_count,
- const cmd::BEGIN_FRAME& args) {
+ const cmd::BeginFrame& args) {
gapi_->BeginFrame();
- return BufferSyncInterface::PARSE_NO_ERROR;
+ return BufferSyncInterface::kParseNoError;
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_END_FRAME(
+BufferSyncInterface::ParseError GAPIDecoder::HandleEndFrame(
uint32 arg_count,
- const cmd::END_FRAME& args) {
+ const cmd::EndFrame& args) {
gapi_->EndFrame();
- return BufferSyncInterface::PARSE_NO_ERROR;
+ return BufferSyncInterface::kParseNoError;
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_CLEAR(
+BufferSyncInterface::ParseError GAPIDecoder::HandleClear(
uint32 arg_count,
- const cmd::CLEAR& args) {
+ const cmd::Clear& args) {
// Pull out some values so they can't be changed by another thread after we've
// validated them.
uint32 buffers = args.buffers;
if (buffers & ~GAPIInterface::ALL_BUFFERS)
- return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ return BufferSyncInterface::kParseInvalidArguments;
RGBA rgba;
rgba.red = args.red;
rgba.green = args.green;
rgba.blue = args.blue;
rgba.alpha = args.alpha;
gapi_->Clear(buffers, rgba, args.depth, args.stencil);
- return BufferSyncInterface::PARSE_NO_ERROR;
+ return BufferSyncInterface::kParseNoError;
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_VIEWPORT(
+BufferSyncInterface::ParseError GAPIDecoder::HandleSetViewport(
uint32 arg_count,
- const cmd::SET_VIEWPORT& args) {
+ const cmd::SetViewport& args) {
gapi_->SetViewport(args.left,
args.top,
args.width,
args.height,
args.z_min,
args.z_max);
- return BufferSyncInterface::PARSE_NO_ERROR;
+ return BufferSyncInterface::kParseNoError;
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_CREATE_VERTEX_BUFFER(
+BufferSyncInterface::ParseError GAPIDecoder::HandleCreateVertexBuffer(
uint32 arg_count,
- const cmd::CREATE_VERTEX_BUFFER& args) {
+ const cmd::CreateVertexBuffer& args) {
return gapi_->CreateVertexBuffer(args.id, args.size, args.flags);
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_DESTROY_VERTEX_BUFFER(
+BufferSyncInterface::ParseError GAPIDecoder::HandleDestroyVertexBuffer(
uint32 arg_count,
- const cmd::DESTROY_VERTEX_BUFFER& args) {
+ const cmd::DestroyVertexBuffer& args) {
return gapi_->DestroyVertexBuffer(args.id);
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_VERTEX_BUFFER_DATA_IMMEDIATE(
+BufferSyncInterface::ParseError GAPIDecoder::HandleSetVertexBufferDataImmediate(
uint32 arg_count,
- const cmd::SET_VERTEX_BUFFER_DATA_IMMEDIATE& args) {
+ const cmd::SetVertexBufferDataImmediate& args) {
return gapi_->SetVertexBufferData(args.id, args.offset,
- ImmediateSize(arg_count, args),
+ ImmediateDataSize(arg_count, args),
AddressAfterStruct(args));
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_VERTEX_BUFFER_DATA(
+BufferSyncInterface::ParseError GAPIDecoder::HandleSetVertexBufferData(
uint32 arg_count,
- const cmd::SET_VERTEX_BUFFER_DATA& args) {
+ const cmd::SetVertexBufferData& args) {
// Pull out some values so they can't be changed by another thread after we've
// validated them.
uint32 size = args.size;
void *data = GetAddressAndCheckSize(args.shared_memory.id,
args.shared_memory.offset,
size);
- if (!data) return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ if (!data) return BufferSyncInterface::kParseInvalidArguments;
return gapi_->SetVertexBufferData(args.id, args.offset, size, data);
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_GET_VERTEX_BUFFER_DATA(
+BufferSyncInterface::ParseError GAPIDecoder::HandleGetVertexBufferData(
uint32 arg_count,
- const cmd::GET_VERTEX_BUFFER_DATA& args) {
+ const cmd::GetVertexBufferData& args) {
// Pull out some values so they can't be changed by another thread after we've
// validated them.
uint32 size = args.size;
void *data = GetAddressAndCheckSize(args.shared_memory.id,
args.shared_memory.offset,
size);
- if (!data) return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ if (!data) return BufferSyncInterface::kParseInvalidArguments;
return gapi_->GetVertexBufferData(args.id, args.offset, size, data);
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_CREATE_INDEX_BUFFER(
+BufferSyncInterface::ParseError GAPIDecoder::HandleCreateIndexBuffer(
uint32 arg_count,
- const cmd::CREATE_INDEX_BUFFER& args) {
+ const cmd::CreateIndexBuffer& args) {
return gapi_->CreateIndexBuffer(args.id, args.size, args.flags);
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_DESTROY_INDEX_BUFFER(
+BufferSyncInterface::ParseError GAPIDecoder::HandleDestroyIndexBuffer(
uint32 arg_count,
- const cmd::DESTROY_INDEX_BUFFER& args) {
+ const cmd::DestroyIndexBuffer& args) {
return gapi_->DestroyIndexBuffer(args.id);
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_INDEX_BUFFER_DATA_IMMEDIATE(
+BufferSyncInterface::ParseError GAPIDecoder::HandleSetIndexBufferDataImmediate(
uint32 arg_count,
- const cmd::SET_INDEX_BUFFER_DATA_IMMEDIATE& args) {
+ const cmd::SetIndexBufferDataImmediate& args) {
return gapi_->SetIndexBufferData(args.id, args.offset,
- ImmediateSize(arg_count, args),
+ ImmediateDataSize(arg_count, args),
AddressAfterStruct(args));
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_INDEX_BUFFER_DATA(
+BufferSyncInterface::ParseError GAPIDecoder::HandleSetIndexBufferData(
uint32 arg_count,
- const cmd::SET_INDEX_BUFFER_DATA& args) {
+ const cmd::SetIndexBufferData& args) {
// Pull out some values so they can't be changed by another thread after we've
// validated them.
uint32 size = args.size;
void *data = GetAddressAndCheckSize(args.shared_memory.id,
args.shared_memory.offset,
size);
- if (!data) return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ if (!data) return BufferSyncInterface::kParseInvalidArguments;
return gapi_->SetIndexBufferData(args.id, args.offset, size, data);
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_GET_INDEX_BUFFER_DATA(
+BufferSyncInterface::ParseError GAPIDecoder::HandleGetIndexBufferData(
uint32 arg_count,
- const cmd::GET_INDEX_BUFFER_DATA& args) {
+ const cmd::GetIndexBufferData& args) {
// Pull out some values so they can't be changed by another thread after we've
// validated them.
uint32 size = args.size;
void *data = GetAddressAndCheckSize(args.shared_memory.id,
args.shared_memory.offset,
size);
- if (!data) return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ if (!data) return BufferSyncInterface::kParseInvalidArguments;
return gapi_->GetIndexBufferData(args.id, args.offset, size, data);
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_CREATE_VERTEX_STRUCT(
+BufferSyncInterface::ParseError GAPIDecoder::HandleCreateVertexStruct(
uint32 arg_count,
- const cmd::CREATE_VERTEX_STRUCT& args) {
+ const cmd::CreateVertexStruct& args) {
return gapi_->CreateVertexStruct(args.id, args.input_count);
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_DESTROY_VERTEX_STRUCT(
+BufferSyncInterface::ParseError GAPIDecoder::HandleDestroyVertexStruct(
uint32 arg_count,
- const cmd::DESTROY_VERTEX_STRUCT& args) {
+ const cmd::DestroyVertexStruct& args) {
return gapi_->DestroyVertexStruct(args.id);
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_VERTEX_INPUT(
+BufferSyncInterface::ParseError GAPIDecoder::HandleSetVertexInput(
uint32 arg_count,
- const cmd::SET_VERTEX_INPUT& args) {
- // TODO(gman): fix.
- return DecodeSetVertexInput(arg_count, TempHack(&args));
+ const cmd::SetVertexInput& args) {
+ namespace cmd = set_vertex_input_cmd;
+ unsigned int type_stride_semantic = args.fixme4;
+ unsigned int semantic_index = cmd::SemanticIndex::Get(type_stride_semantic);
+ unsigned int semantic = cmd::Semantic::Get(type_stride_semantic);
+ unsigned int type = cmd::Type::Get(type_stride_semantic);
+ unsigned int stride = cmd::Stride::Get(type_stride_semantic);
+ if (semantic >= vertex_struct::NUM_SEMANTICS ||
+ type >= vertex_struct::NUM_TYPES || stride == 0)
+ return BufferSyncInterface::kParseInvalidArguments;
+ return gapi_->SetVertexInput(
+ args.vertex_struct_id, args.input_index, args.vertex_buffer_id,
+ args.offset, stride,
+ static_cast<vertex_struct::Type>(type),
+ static_cast<vertex_struct::Semantic>(semantic),
+ semantic_index);
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_VERTEX_STRUCT(
+BufferSyncInterface::ParseError GAPIDecoder::HandleSetVertexStruct(
uint32 arg_count,
- const cmd::SET_VERTEX_STRUCT& args) {
+ const cmd::SetVertexStruct& args) {
return gapi_->SetVertexStruct(args.id);
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_DRAW(
+BufferSyncInterface::ParseError GAPIDecoder::HandleDraw(
uint32 arg_count,
- const cmd::DRAW& args) {
+ const cmd::Draw& args) {
// Pull out some values so they can't be changed by another thread after we've
// validated them.
uint32 primitive_type = args.primitive_type;
if (primitive_type >= GAPIInterface::MAX_PRIMITIVE_TYPE)
- return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ return BufferSyncInterface::kParseInvalidArguments;
return gapi_->Draw(
static_cast<GAPIInterface::PrimitiveType>(primitive_type),
args.first, args.count);
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_DRAW_INDEXED(
+BufferSyncInterface::ParseError GAPIDecoder::HandleDrawIndexed(
uint32 arg_count,
- const cmd::DRAW_INDEXED& args) {
+ const cmd::DrawIndexed& args) {
// Pull out some values so they can't be changed by another thread after we've
// validated them.
uint32 primitive_type = args.primitive_type;
if (primitive_type >= GAPIInterface::MAX_PRIMITIVE_TYPE)
- return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ return BufferSyncInterface::kParseInvalidArguments;
return gapi_->DrawIndexed(
static_cast<GAPIInterface::PrimitiveType>(primitive_type),
args.index_buffer_id,
args.first, args.count, args.min_index, args.max_index);
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_CREATE_EFFECT(
+BufferSyncInterface::ParseError GAPIDecoder::HandleCreateEffect(
uint32 arg_count,
- const cmd::CREATE_EFFECT& args) {
+ const cmd::CreateEffect& args) {
// Pull out some values so they can't be changed by another thread after we've
// validated them.
uint32 size = args.size;
void *data = GetAddressAndCheckSize(args.shared_memory.id,
args.shared_memory.offset,
size);
- if (!data) return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ if (!data) return BufferSyncInterface::kParseInvalidArguments;
return gapi_->CreateEffect(args.id, size, data);
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_CREATE_EFFECT_IMMEDIATE(
+BufferSyncInterface::ParseError GAPIDecoder::HandleCreateEffectImmediate(
uint32 arg_count,
- const cmd::CREATE_EFFECT_IMMEDIATE& args) {
+ const cmd::CreateEffectImmediate& args) {
// Pull out some values so they can't be changed by another thread after we've
// validated them.
uint32 size = args.size;
- if (size > ImmediateSize(arg_count, args))
- return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ uint32 data_size = ImmediateDataSize(arg_count, args);
+ if (size > data_size)
+ return BufferSyncInterface::kParseInvalidArguments;
return gapi_->CreateEffect(args.id, size, AddressAfterStruct(args));
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_DESTROY_EFFECT(
+BufferSyncInterface::ParseError GAPIDecoder::HandleDestroyEffect(
uint32 arg_count,
- const cmd::DESTROY_EFFECT& args) {
+ const cmd::DestroyEffect& args) {
return gapi_->DestroyEffect(args.id);
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_EFFECT(
+BufferSyncInterface::ParseError GAPIDecoder::HandleSetEffect(
uint32 arg_count,
- const cmd::SET_EFFECT& args) {
+ const cmd::SetEffect& args) {
return gapi_->SetEffect(args.id);
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_GET_PARAM_COUNT(
+BufferSyncInterface::ParseError GAPIDecoder::HandleGetParamCount(
uint32 arg_count,
- const cmd::GET_PARAM_COUNT& args) {
+ const cmd::GetParamCount& args) {
// Pull out some values so they can't be changed by another thread after we've
// validated them.
uint32 size = args.size;
void *data = GetAddressAndCheckSize(args.shared_memory.id,
args.shared_memory.offset,
size);
- if (!data) return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ if (!data) return BufferSyncInterface::kParseInvalidArguments;
return gapi_->GetParamCount(args.id, size, data);
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_CREATE_PARAM(
+BufferSyncInterface::ParseError GAPIDecoder::HandleCreateParam(
uint32 arg_count,
- const cmd::CREATE_PARAM& args) {
+ const cmd::CreateParam& args) {
return gapi_->CreateParam(args.param_id, args.effect_id, args.index);
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_CREATE_PARAM_BY_NAME(
+BufferSyncInterface::ParseError GAPIDecoder::HandleCreateParamByName(
uint32 arg_count,
- const cmd::CREATE_PARAM_BY_NAME& args) {
+ const cmd::CreateParamByName& args) {
// Pull out some values so they can't be changed by another thread after we've
// validated them.
uint32 size = args.size;
void *data = GetAddressAndCheckSize(args.shared_memory.id,
args.shared_memory.offset,
size);
- if (!data) return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ if (!data) return BufferSyncInterface::kParseInvalidArguments;
return gapi_->CreateParamByName(args.param_id, args.effect_id, size,
data);
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_CREATE_PARAM_BY_NAME_IMMEDIATE(
+BufferSyncInterface::ParseError GAPIDecoder::HandleCreateParamByNameImmediate(
uint32 arg_count,
- const cmd::CREATE_PARAM_BY_NAME_IMMEDIATE& args) {
+ const cmd::CreateParamByNameImmediate& args) {
// Pull out some values so they can't be changed by another thread after we've
// validated them.
uint32 size = args.size;
- if (size > ImmediateSize(arg_count, args))
- return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ uint32 data_size = ImmediateDataSize(arg_count, args);
+ if (size > data_size)
+ return BufferSyncInterface::kParseInvalidArguments;
return gapi_->CreateParamByName(args.param_id, args.effect_id, size,
AddressAfterStruct(args));
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_DESTROY_PARAM(
+BufferSyncInterface::ParseError GAPIDecoder::HandleDestroyParam(
uint32 arg_count,
- const cmd::DESTROY_PARAM& args) {
+ const cmd::DestroyParam& args) {
return gapi_->DestroyParam(args.id);
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_PARAM_DATA(
+BufferSyncInterface::ParseError GAPIDecoder::HandleSetParamData(
uint32 arg_count,
- const cmd::SET_PARAM_DATA& args) {
+ const cmd::SetParamData& args) {
// Pull out some values so they can't be changed by another thread after we've
// validated them.
uint32 size = args.size;
void *data = GetAddressAndCheckSize(args.shared_memory.id,
args.shared_memory.offset,
size);
- if (!data) return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ if (!data) return BufferSyncInterface::kParseInvalidArguments;
return gapi_->SetParamData(args.id, size, data);
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_PARAM_DATA_IMMEDIATE(
+BufferSyncInterface::ParseError GAPIDecoder::HandleSetParamDataImmediate(
uint32 arg_count,
- const cmd::SET_PARAM_DATA_IMMEDIATE& args) {
+ const cmd::SetParamDataImmediate& args) {
// Pull out some values so they can't be changed by another thread after we've
// validated them.
uint32 size = args.size;
- if (size > ImmediateSize(arg_count, args))
- return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ uint32 data_size = ImmediateDataSize(arg_count, args);
+ if (size > data_size)
+ return BufferSyncInterface::kParseInvalidArguments;
return gapi_->SetParamData(args.id, size, AddressAfterStruct(args));
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_GET_PARAM_DESC(
+BufferSyncInterface::ParseError GAPIDecoder::HandleGetParamDesc(
uint32 arg_count,
- const cmd::GET_PARAM_DESC& args) {
+ const cmd::GetParamDesc& args) {
// Pull out some values so they can't be changed by another thread after we've
// validated them.
uint32 size = args.size;
void *data = GetAddressAndCheckSize(args.shared_memory.id,
args.shared_memory.offset,
size);
- if (!data) return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ if (!data) return BufferSyncInterface::kParseInvalidArguments;
return gapi_->GetParamDesc(args.id, size, data);
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_GET_STREAM_COUNT(
+BufferSyncInterface::ParseError GAPIDecoder::HandleGetStreamCount(
uint32 arg_count,
- const cmd::GET_STREAM_COUNT& args) {
+ const cmd::GetStreamCount& args) {
// Pull out some values so they can't be changed by another thread after we've
// validated them.
uint32 size = args.size;
void *data = GetAddressAndCheckSize(args.shared_memory.id,
args.shared_memory.offset,
size);
- if (!data) return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ if (!data) return BufferSyncInterface::kParseInvalidArguments;
return gapi_->GetStreamCount(args.id, size, data);
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_GET_STREAM_DESC(
+BufferSyncInterface::ParseError GAPIDecoder::HandleGetStreamDesc(
uint32 arg_count,
- const cmd::GET_STREAM_DESC& args) {
+ const cmd::GetStreamDesc& args) {
// Pull out some values so they can't be changed by another thread after we've
// validated them.
uint32 size = args.size;
void *data = GetAddressAndCheckSize(args.shared_memory.id,
args.shared_memory.offset,
size);
- if (!data) return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ if (!data) return BufferSyncInterface::kParseInvalidArguments;
return gapi_->GetStreamDesc(args.id, args.index, size, data);
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_DESTROY_TEXTURE(
+BufferSyncInterface::ParseError GAPIDecoder::HandleDestroyTexture(
uint32 arg_count,
- const cmd::DESTROY_TEXTURE& args) {
+ const cmd::DestroyTexture& args) {
return gapi_->DestroyTexture(args.id);
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_CREATE_TEXTURE_2D(
- uint32 arg_count,
- const cmd::CREATE_TEXTURE_2D& args) {
- // TODO(gman): fix.
- return DecodeCreateTexture2D(arg_count, TempHack(&args));
-}
-
-BufferSyncInterface::ParseError GAPIDecoder::Handle_CREATE_TEXTURE_3D(
- uint32 arg_count,
- const cmd::CREATE_TEXTURE_3D& args) {
- // TODO(gman): fix.
- return DecodeCreateTexture3D(arg_count, TempHack(&args));
-}
-
-BufferSyncInterface::ParseError GAPIDecoder::Handle_CREATE_TEXTURE_CUBE(
- uint32 arg_count,
- const cmd::CREATE_TEXTURE_CUBE& args) {
- // TODO(gman): fix.
- return DecodeCreateTextureCube(arg_count, TempHack(&args));
-}
-
-BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_TEXTURE_DATA(
- uint32 arg_count,
- const cmd::SET_TEXTURE_DATA& args) {
- // TODO(gman): fix.
- return DecodeSetTextureData(arg_count, TempHack(&args));
-}
-
-BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_TEXTURE_DATA_IMMEDIATE(
- uint32 arg_count,
- const cmd::SET_TEXTURE_DATA_IMMEDIATE& args) {
- // TODO(gman): fix.
- return DecodeSetTextureDataImmediate(arg_count, TempHack(&args));
-}
-
-BufferSyncInterface::ParseError GAPIDecoder::Handle_GET_TEXTURE_DATA(
+BufferSyncInterface::ParseError GAPIDecoder::HandleCreateTexture2d(
uint32 arg_count,
- const cmd::GET_TEXTURE_DATA& args) {
- // TODO(gman): fix.
- return DecodeGetTextureData(arg_count, TempHack(&args));
+ const cmd::CreateTexture2d& args) {
+ namespace cmd = create_texture_2d_cmd;
+ unsigned int width_height = args.fixme1;
+ unsigned int levels_format_flags = args.fixme2;
+ unsigned int width = cmd::Width::Get(width_height);
+ unsigned int height = cmd::Height::Get(width_height);
+ unsigned int levels = cmd::Levels::Get(levels_format_flags);
+ unsigned int unused = cmd::Unused::Get(levels_format_flags);
+ unsigned int format = cmd::Format::Get(levels_format_flags);
+ unsigned int flags = cmd::Flags::Get(levels_format_flags);
+ unsigned int max_levels =
+ 1 + base::bits::Log2Ceiling(std::max(width, height));
+ if ((width == 0) || (height == 0) || (levels > max_levels) ||
+ (unused != 0) || (format >= texture::NUM_FORMATS) || (levels == 0))
+ return BufferSyncInterface::kParseInvalidArguments;
+ bool enable_render_surfaces = !!flags;
+ return gapi_->CreateTexture2D(args.texture_id, width, height, levels,
+ static_cast<texture::Format>(format), flags,
+ enable_render_surfaces);
+}
+
+BufferSyncInterface::ParseError GAPIDecoder::HandleCreateTexture3d(
+ uint32 arg_count,
+ const cmd::CreateTexture3d& args) {
+ namespace cmd = create_texture_3d_cmd;
+ unsigned int width_height = args.fixme1;
+ unsigned int depth_unused = args.fixme2;
+ unsigned int levels_format_flags = args.fixme3;
+ unsigned int width = cmd::Width::Get(width_height);
+ unsigned int height = cmd::Height::Get(width_height);
+ unsigned int depth = cmd::Depth::Get(depth_unused);
+ unsigned int unused1 = cmd::Unused1::Get(depth_unused);
+ unsigned int levels = cmd::Levels::Get(levels_format_flags);
+ unsigned int unused2 = cmd::Unused2::Get(levels_format_flags);
+ unsigned int format = cmd::Format::Get(levels_format_flags);
+ unsigned int flags = cmd::Flags::Get(levels_format_flags);
+ unsigned int max_levels =
+ 1 + base::bits::Log2Ceiling(std::max(depth, std::max(width, height)));
+ if ((width == 0) || (height == 0) || (depth == 0) ||
+ (levels > max_levels) || (unused1 != 0) || (unused2 != 0) ||
+ (format >= texture::NUM_FORMATS) || (levels == 0))
+ return BufferSyncInterface::kParseInvalidArguments;
+ bool enable_render_surfaces = !!flags;
+ return gapi_->CreateTexture3D(args.texture_id, width, height, depth, levels,
+ static_cast<texture::Format>(format), flags,
+ enable_render_surfaces);
+}
+
+BufferSyncInterface::ParseError GAPIDecoder::HandleCreateTextureCube(
+ uint32 arg_count,
+ const cmd::CreateTextureCube& args) {
+ namespace cmd = create_texture_cube_cmd;
+ unsigned int side_unused = args.edge_length;
+ unsigned int levels_format_flags = args.fixme2;
+ unsigned int side = cmd::Side::Get(side_unused);
+ unsigned int unused1 = cmd::Unused1::Get(side_unused);
+ unsigned int levels = cmd::Levels::Get(levels_format_flags);
+ unsigned int unused2 = cmd::Unused2::Get(levels_format_flags);
+ unsigned int format = cmd::Format::Get(levels_format_flags);
+ unsigned int flags = cmd::Flags::Get(levels_format_flags);
+ unsigned int max_levels = 1 + base::bits::Log2Ceiling(side);
+ if ((side == 0) || (levels > max_levels) || (unused1 != 0) ||
+ (unused2 != 0) || (format >= texture::NUM_FORMATS) || (levels == 0))
+ return BufferSyncInterface::kParseInvalidArguments;
+ bool enable_render_surfaces = !!flags;
+ return gapi_->CreateTextureCube(args.texture_id, side, levels,
+ static_cast<texture::Format>(format),
+ flags, enable_render_surfaces);
+}
+
+BufferSyncInterface::ParseError GAPIDecoder::HandleSetTextureData(
+ uint32 arg_count,
+ const cmd::SetTextureData& args) {
+ namespace cmd = set_texture_data_cmd;
+ unsigned int x_y = args.fixme1;
+ unsigned int width_height = args.fixme2;
+ unsigned int z_depth = args.fixme3;
+ unsigned int level_face = args.fixme4;
+ unsigned int size = args.size;
+ unsigned int x = cmd::X::Get(x_y);
+ unsigned int y = cmd::Y::Get(x_y);
+ unsigned int width = cmd::Width::Get(width_height);
+ unsigned int height = cmd::Height::Get(width_height);
+ unsigned int z = cmd::Z::Get(z_depth);
+ unsigned int depth = cmd::Depth::Get(z_depth);
+ unsigned int level = cmd::Level::Get(level_face);
+ unsigned int face = cmd::Face::Get(level_face);
+ unsigned int unused = cmd::Unused::Get(level_face);
+ const void *data = GetAddressAndCheckSize(args.shared_memory.id,
+ args.shared_memory.offset, size);
+ if (face >= 6 || unused != 0 || !data)
+ return BufferSyncInterface::kParseInvalidArguments;
+ return gapi_->SetTextureData(
+ args.texture_id, x, y, z, width, height, depth, level,
+ static_cast<texture::Face>(face), args.row_pitch,
+ args.slice_pitch, size, data);
+}
+
+BufferSyncInterface::ParseError GAPIDecoder::HandleSetTextureDataImmediate(
+ uint32 arg_count,
+ const cmd::SetTextureDataImmediate& args) {
+ namespace cmd = set_texture_data_immediate_cmd;
+ unsigned int x_y = args.fixme1;
+ unsigned int width_height = args.fixme2;
+ unsigned int z_depth = args.fixme3;
+ unsigned int level_face = args.fixme4;
+ unsigned int size = args.size;
+ unsigned int x = cmd::X::Get(x_y);
+ unsigned int y = cmd::Y::Get(x_y);
+ unsigned int width = cmd::Width::Get(width_height);
+ unsigned int height = cmd::Height::Get(width_height);
+ unsigned int z = cmd::Z::Get(z_depth);
+ unsigned int depth = cmd::Depth::Get(z_depth);
+ unsigned int level = cmd::Level::Get(level_face);
+ unsigned int face = cmd::Face::Get(level_face);
+ unsigned int unused = cmd::Unused::Get(level_face);
+ uint32 data_size = ImmediateDataSize(arg_count, args);
+ if (face >= 6 || unused != 0 ||
+ size > data_size)
+ return BufferSyncInterface::kParseInvalidArguments;
+ return gapi_->SetTextureData(
+ args.texture_id, x, y, z, width, height, depth, level,
+ static_cast<texture::Face>(face), args.row_pitch,
+ args.slice_pitch, size, AddressAfterStruct(args));
+}
+
+BufferSyncInterface::ParseError GAPIDecoder::HandleGetTextureData(
+ uint32 arg_count,
+ const cmd::GetTextureData& args) {
+ namespace cmd = get_texture_data_cmd;
+ unsigned int x_y = args.fixme1;
+ unsigned int width_height = args.fixme2;
+ unsigned int z_depth = args.fixme3;
+ unsigned int level_face = args.fixme4;
+ unsigned int size = args.size;
+ unsigned int x = cmd::X::Get(x_y);
+ unsigned int y = cmd::Y::Get(x_y);
+ unsigned int width = cmd::Width::Get(width_height);
+ unsigned int height = cmd::Height::Get(width_height);
+ unsigned int z = cmd::Z::Get(z_depth);
+ unsigned int depth = cmd::Depth::Get(z_depth);
+ unsigned int level = cmd::Level::Get(level_face);
+ unsigned int face = cmd::Face::Get(level_face);
+ unsigned int unused = cmd::Unused::Get(level_face);
+ void *data = GetAddressAndCheckSize(args.shared_memory.id,
+ args.shared_memory.offset, size);
+ if (face >= 6 || unused != 0 || !data)
+ return BufferSyncInterface::kParseInvalidArguments;
+ return gapi_->GetTextureData(
+ args.texture_id, x, y, z, width, height, depth, level,
+ static_cast<texture::Face>(face), args.row_pitch,
+ args.slice_pitch, size, data);
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_CREATE_SAMPLER(
+BufferSyncInterface::ParseError GAPIDecoder::HandleCreateSampler(
uint32 arg_count,
- const cmd::CREATE_SAMPLER& args) {
+ const cmd::CreateSampler& args) {
return gapi_->CreateSampler(args.id);
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_DESTROY_SAMPLER(
+BufferSyncInterface::ParseError GAPIDecoder::HandleDestroySampler(
uint32 arg_count,
- const cmd::DESTROY_SAMPLER& args) {
+ const cmd::DestroySampler& args) {
return gapi_->DestroySampler(args.id);
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_SAMPLER_STATES(
+BufferSyncInterface::ParseError GAPIDecoder::HandleSetSamplerStates(
uint32 arg_count,
- const cmd::SET_SAMPLER_STATES& args) {
- // TODO(gman): fix.
- return DecodeSetSamplerStates(arg_count, TempHack(&args));
+ const cmd::SetSamplerStates& args) {
+ namespace cmd = set_sampler_states;
+ Uint32 arg = args.fixme1;
+ if (cmd::Unused::Get(arg) != 0)
+ return BufferSyncInterface::kParseInvalidArguments;
+ unsigned int address_u_value = cmd::AddressingU::Get(arg);
+ unsigned int address_v_value = cmd::AddressingV::Get(arg);
+ unsigned int address_w_value = cmd::AddressingW::Get(arg);
+ unsigned int mag_filter_value = cmd::MagFilter::Get(arg);
+ unsigned int min_filter_value = cmd::MinFilter::Get(arg);
+ unsigned int mip_filter_value = cmd::MipFilter::Get(arg);
+ unsigned int max_anisotropy = cmd::MaxAnisotropy::Get(arg);
+ if (address_u_value >= sampler::NUM_ADDRESSING_MODE ||
+ address_v_value >= sampler::NUM_ADDRESSING_MODE ||
+ address_w_value >= sampler::NUM_ADDRESSING_MODE ||
+ mag_filter_value >= sampler::NUM_FILTERING_MODE ||
+ min_filter_value >= sampler::NUM_FILTERING_MODE ||
+ mip_filter_value >= sampler::NUM_FILTERING_MODE ||
+ mag_filter_value == sampler::NONE ||
+ min_filter_value == sampler::NONE ||
+ max_anisotropy == 0) {
+ return BufferSyncInterface::kParseInvalidArguments;
+ }
+ gapi_->SetSamplerStates(
+ args.id,
+ static_cast<sampler::AddressingMode>(address_u_value),
+ static_cast<sampler::AddressingMode>(address_v_value),
+ static_cast<sampler::AddressingMode>(address_w_value),
+ static_cast<sampler::FilteringMode>(mag_filter_value),
+ static_cast<sampler::FilteringMode>(min_filter_value),
+ static_cast<sampler::FilteringMode>(mip_filter_value),
+ max_anisotropy);
+ return BufferSyncInterface::kParseNoError;
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_SAMPLER_BORDER_COLOR(
+BufferSyncInterface::ParseError GAPIDecoder::HandleSetSamplerBorderColor(
uint32 arg_count,
- const cmd::SET_SAMPLER_BORDER_COLOR& args) {
+ const cmd::SetSamplerBorderColor& args) {
RGBA rgba;
rgba.red = args.red;
rgba.green = args.green;
@@ -872,19 +707,19 @@ BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_SAMPLER_BORDER_COLOR(
return gapi_->SetSamplerBorderColor(args.id, rgba);
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_SAMPLER_TEXTURE(
+BufferSyncInterface::ParseError GAPIDecoder::HandleSetSamplerTexture(
uint32 arg_count,
- const cmd::SET_SAMPLER_TEXTURE& args) {
+ const cmd::SetSamplerTexture& args) {
return gapi_->SetSamplerTexture(args.id, args.texture_id);
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_SCISSOR(
+BufferSyncInterface::ParseError GAPIDecoder::HandleSetScissor(
uint32 arg_count,
- const cmd::SET_SCISSOR& args) {
+ const cmd::SetScissor& args) {
namespace cmd = set_scissor;
Uint32 x_y_enable = args.fixme0;
if (cmd::Unused::Get(x_y_enable) != 0)
- return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ return BufferSyncInterface::kParseInvalidArguments;
unsigned int x = cmd::X::Get(x_y_enable);
unsigned int y = cmd::Y::Get(x_y_enable);
bool enable = cmd::Enable::Get(x_y_enable) != 0;
@@ -892,32 +727,32 @@ BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_SCISSOR(
unsigned int width = cmd::Width::Get(width_height);
unsigned int height = cmd::Height::Get(width_height);
gapi_->SetScissor(enable, x, y, width, height);
- return BufferSyncInterface::PARSE_NO_ERROR;
+ return BufferSyncInterface::kParseNoError;
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_POLYGON_OFFSET(
+BufferSyncInterface::ParseError GAPIDecoder::HandleSetPolygonOffset(
uint32 arg_count,
- const cmd::SET_POLYGON_OFFSET& args) {
+ const cmd::SetPolygonOffset& args) {
gapi_->SetPolygonOffset(args.slope_factor, args.units);
- return BufferSyncInterface::PARSE_NO_ERROR;
+ return BufferSyncInterface::kParseNoError;
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_POINT_LINE_RASTER(
+BufferSyncInterface::ParseError GAPIDecoder::HandleSetPointLineRaster(
uint32 arg_count,
- const cmd::SET_POINT_LINE_RASTER& args) {
+ const cmd::SetPointLineRaster& args) {
namespace cmd = set_point_line_raster;
Uint32 enables = args.fixme0;
if (cmd::Unused::Get(enables) != 0)
- return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ return BufferSyncInterface::kParseInvalidArguments;
bool line_smooth = !!cmd::LineSmoothEnable::Get(enables);
bool point_sprite = !!cmd::PointSpriteEnable::Get(enables);
gapi_->SetPointLineRaster(line_smooth, point_sprite, args.point_size);
- return BufferSyncInterface::PARSE_NO_ERROR;
+ return BufferSyncInterface::kParseNoError;
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_POLYGON_RASTER(
+BufferSyncInterface::ParseError GAPIDecoder::HandleSetPolygonRaster(
uint32 arg_count,
- const cmd::SET_POLYGON_RASTER& args) {
+ const cmd::SetPolygonRaster& args) {
namespace cmd = set_polygon_raster;
Uint32 fill_cull = args.fixme0;
unsigned int fill_value = cmd::FillMode::Get(fill_cull);
@@ -925,20 +760,20 @@ BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_POLYGON_RASTER(
if (cmd::Unused::Get(fill_cull) != 0 ||
fill_value >= GAPIInterface::NUM_POLYGON_MODE ||
cull_value >= GAPIInterface::NUM_FACE_CULL_MODE)
- return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ return BufferSyncInterface::kParseInvalidArguments;
gapi_->SetPolygonRaster(
static_cast<GAPIInterface::PolygonMode>(fill_value),
static_cast<GAPIInterface::FaceCullMode>(cull_value));
- return BufferSyncInterface::PARSE_NO_ERROR;
+ return BufferSyncInterface::kParseNoError;
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_ALPHA_TEST(
+BufferSyncInterface::ParseError GAPIDecoder::HandleSetAlphaTest(
uint32 arg_count,
- const cmd::SET_ALPHA_TEST& args) {
+ const cmd::SetAlphaTest& args) {
namespace cmd = set_alpha_test;
Uint32 func_enable = args.fixme0;
if (cmd::Unused::Get(func_enable) != 0)
- return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ return BufferSyncInterface::kParseInvalidArguments;
// Check that the bitmask get cannot generate values outside of the
// allowed range.
COMPILE_ASSERT(cmd::Func::kMask < GAPIInterface::NUM_COMPARISON,
@@ -947,16 +782,16 @@ BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_ALPHA_TEST(
static_cast<GAPIInterface::Comparison>(cmd::Func::Get(func_enable));
bool enable = cmd::Enable::Get(func_enable) != 0;
gapi_->SetAlphaTest(enable, args.value, comp);
- return BufferSyncInterface::PARSE_NO_ERROR;
+ return BufferSyncInterface::kParseNoError;
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_DEPTH_TEST(
+BufferSyncInterface::ParseError GAPIDecoder::HandleSetDepthTest(
uint32 arg_count,
- const cmd::SET_DEPTH_TEST& args) {
+ const cmd::SetDepthTest& args) {
namespace cmd = set_depth_test;
Uint32 func_enable = args.fixme0;
if (cmd::Unused::Get(func_enable) != 0)
- return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ return BufferSyncInterface::kParseInvalidArguments;
// Check that the bitmask get cannot generate values outside of the
// allowed range.
COMPILE_ASSERT(cmd::Func::kMask < GAPIInterface::NUM_COMPARISON,
@@ -966,53 +801,93 @@ BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_DEPTH_TEST(
bool write_enable = cmd::WriteEnable::Get(func_enable) != 0;
bool enable = cmd::Enable::Get(func_enable) != 0;
gapi_->SetDepthTest(enable, write_enable, comp);
- return BufferSyncInterface::PARSE_NO_ERROR;
+ return BufferSyncInterface::kParseNoError;
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_STENCIL_TEST(
+BufferSyncInterface::ParseError GAPIDecoder::HandleSetStencilTest(
uint32 arg_count,
- const cmd::SET_STENCIL_TEST& args) {
- // TODO(gman): fix.
- return DecodeSetStencilTest(arg_count, TempHack(&args));
+ const cmd::SetStencilTest& args) {
+ namespace cmd = set_stencil_test;
+ Uint32 arg0 = args.fixme0;
+ Uint32 arg1 = args.fixme1;
+ if (cmd::Unused0::Get(arg0) != 0 ||
+ cmd::Unused1::Get(arg1) != 0 ||
+ cmd::Unused2::Get(arg1) != 0)
+ return BufferSyncInterface::kParseInvalidArguments;
+ unsigned int write_mask = cmd::WriteMask::Get(arg0);
+ unsigned int compare_mask = cmd::CompareMask::Get(arg0);
+ unsigned int ref = cmd::ReferenceValue::Get(arg0);
+ bool enable = cmd::Enable::Get(arg0) != 0;
+ bool separate_ccw = cmd::SeparateCCW::Get(arg0) != 0;
+ gapi_->SetStencilTest(enable, separate_ccw, write_mask, compare_mask, ref,
+ arg1);
+ return BufferSyncInterface::kParseNoError;
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_COLOR_WRITE(
+BufferSyncInterface::ParseError GAPIDecoder::HandleSetColorWrite(
uint32 arg_count,
- const cmd::SET_COLOR_WRITE& args) {
+ const cmd::SetColorWrite& args) {
namespace cmd = set_color_write;
Uint32 enables = args.flags;
if (cmd::Unused::Get(enables) != 0)
- return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ return BufferSyncInterface::kParseInvalidArguments;
bool red = cmd::RedMask::Get(enables) != 0;
bool green = cmd::GreenMask::Get(enables) != 0;
bool blue = cmd::BlueMask::Get(enables) != 0;
bool alpha = cmd::AlphaMask::Get(enables) != 0;
bool dither = cmd::DitherEnable::Get(enables) != 0;
gapi_->SetColorWrite(red, green, blue, alpha, dither);
- return BufferSyncInterface::PARSE_NO_ERROR;
+ return BufferSyncInterface::kParseNoError;
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_BLENDING(
+BufferSyncInterface::ParseError GAPIDecoder::HandleSetBlending(
uint32 arg_count,
- const cmd::SET_BLENDING& args) {
- return DecodeSetBlending(arg_count, TempHack(&args));
+ const cmd::SetBlending& args) {
+ namespace cmd = set_blending;
+ Uint32 arg = args.fixme0;
+ bool enable = cmd::Enable::Get(arg) != 0;
+ bool separate_alpha = cmd::SeparateAlpha::Get(arg) != 0;
+ unsigned int color_eq = cmd::ColorEq::Get(arg);
+ unsigned int color_src = cmd::ColorSrcFunc::Get(arg);
+ unsigned int color_dst = cmd::ColorDstFunc::Get(arg);
+ unsigned int alpha_eq = cmd::AlphaEq::Get(arg);
+ unsigned int alpha_src = cmd::AlphaSrcFunc::Get(arg);
+ unsigned int alpha_dst = cmd::AlphaDstFunc::Get(arg);
+ if (cmd::Unused0::Get(arg) != 0 ||
+ cmd::Unused1::Get(arg) != 0 ||
+ color_eq >= GAPIInterface::NUM_BLEND_EQ ||
+ color_src >= GAPIInterface::NUM_BLEND_FUNC ||
+ color_dst >= GAPIInterface::NUM_BLEND_FUNC ||
+ alpha_eq >= GAPIInterface::NUM_BLEND_EQ ||
+ alpha_src >= GAPIInterface::NUM_BLEND_FUNC ||
+ alpha_dst >= GAPIInterface::NUM_BLEND_FUNC)
+ return BufferSyncInterface::kParseInvalidArguments;
+ gapi_->SetBlending(enable,
+ separate_alpha,
+ static_cast<GAPIInterface::BlendEq>(color_eq),
+ static_cast<GAPIInterface::BlendFunc>(color_src),
+ static_cast<GAPIInterface::BlendFunc>(color_dst),
+ static_cast<GAPIInterface::BlendEq>(alpha_eq),
+ static_cast<GAPIInterface::BlendFunc>(alpha_src),
+ static_cast<GAPIInterface::BlendFunc>(alpha_dst));
+ return BufferSyncInterface::kParseNoError;
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_BLENDING_COLOR(
+BufferSyncInterface::ParseError GAPIDecoder::HandleSetBlendingColor(
uint32 arg_count,
- const cmd::SET_BLENDING_COLOR& args) {
+ const cmd::SetBlendingColor& args) {
RGBA rgba;
rgba.red = args.red;
rgba.green = args.green;
rgba.blue = args.blue;
rgba.alpha = args.alpha;
gapi_->SetBlendingColor(rgba);
- return BufferSyncInterface::PARSE_NO_ERROR;
+ return BufferSyncInterface::kParseNoError;
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_CREATE_RENDER_SURFACE(
+BufferSyncInterface::ParseError GAPIDecoder::HandleCreateRenderSurface(
uint32 arg_count,
- const cmd::CREATE_RENDER_SURFACE& args) {
+ const cmd::CreateRenderSurface& args) {
namespace cmd = create_render_surface_cmd;
unsigned int width_height = args.fixme1;
unsigned int width = cmd::Width::Get(width_height);
@@ -1024,39 +899,39 @@ BufferSyncInterface::ParseError GAPIDecoder::Handle_CREATE_RENDER_SURFACE(
side, args.texture_id);
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_DESTROY_RENDER_SURFACE(
+BufferSyncInterface::ParseError GAPIDecoder::HandleDestroyRenderSurface(
uint32 arg_count,
- const cmd::DESTROY_RENDER_SURFACE& args) {
+ const cmd::DestroyRenderSurface& args) {
return gapi_->DestroyRenderSurface(args.id);
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_CREATE_DEPTH_SURFACE(
+BufferSyncInterface::ParseError GAPIDecoder::HandleCreateDepthSurface(
uint32 arg_count,
- const cmd::CREATE_DEPTH_SURFACE& args) {
- namespace cmd = create_render_surface_cmd;
+ const cmd::CreateDepthSurface& args) {
+ namespace cmd = create_depth_surface_cmd;
unsigned int width_height = args.fixme1;
unsigned int width = cmd::Width::Get(width_height);
unsigned int height = cmd::Height::Get(width_height);
return gapi_->CreateDepthSurface(args.id, width, height);
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_DESTROY_DEPTH_SURFACE(
+BufferSyncInterface::ParseError GAPIDecoder::HandleDestroyDepthSurface(
uint32 arg_count,
- const cmd::DESTROY_DEPTH_SURFACE& args) {
+ const cmd::DestroyDepthSurface& args) {
return gapi_->DestroyDepthSurface(args.id);
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_RENDER_SURFACE(
+BufferSyncInterface::ParseError GAPIDecoder::HandleSetRenderSurface(
uint32 arg_count,
- const cmd::SET_RENDER_SURFACE& args) {
+ const cmd::SetRenderSurface& args) {
return gapi_->SetRenderSurface(args.render_surface_id, args.depth_surface_id);
}
-BufferSyncInterface::ParseError GAPIDecoder::Handle_SET_BACK_SURFACES(
+BufferSyncInterface::ParseError GAPIDecoder::HandleSetBackSurfaces(
uint32 arg_count,
- const cmd::SET_BACK_SURFACES& args) {
+ const cmd::SetBackSurfaces& args) {
gapi_->SetBackSurfaces();
- return BufferSyncInterface::PARSE_NO_ERROR;
+ return BufferSyncInterface::kParseNoError;
}
} // namespace command_buffer
diff --git a/o3d/command_buffer/service/cross/gapi_decoder.h b/o3d/command_buffer/service/cross/gapi_decoder.h
index 67b1806..a9af75c 100644
--- a/o3d/command_buffer/service/cross/gapi_decoder.h
+++ b/o3d/command_buffer/service/cross/gapi_decoder.h
@@ -52,14 +52,8 @@ class GAPIDecoder : public AsyncAPIInterface {
explicit GAPIDecoder(GAPIInterface *gapi) : gapi_(gapi), engine_(NULL) {}
virtual ~GAPIDecoder() {}
- // Executes a command.
- // Parameters:
- // command: the command index.
- // arg_count: the number of CommandBufferEntry arguments.
- // args: the arguments.
- // Returns:
- // BufferSyncInterface::NO_ERROR if no error was found, one of
- // BufferSyncInterface::ParseError otherwise.
+
+ // Overridden from AsyncAPIInterface.
virtual ParseError DoCommand(unsigned int command,
unsigned int arg_count,
const void* args);
@@ -68,46 +62,6 @@ class GAPIDecoder : public AsyncAPIInterface {
// to.
void set_engine(CommandBufferEngine *engine) { engine_ = engine; }
private:
- // Decodes the SET_VERTEX_INPUT command.
- ParseError DecodeSetVertexInput(unsigned int arg_count,
- CommandBufferEntry *args);
-
- // Decodes the CREATE_TEXTURE_2D command.
- ParseError DecodeCreateTexture2D(unsigned int arg_count,
- CommandBufferEntry *args);
-
- // Decodes the CREATE_TEXTURE_3D command.
- ParseError DecodeCreateTexture3D(unsigned int arg_count,
- CommandBufferEntry *args);
-
- // Decodes the CREATE_TEXTURE_CUBE command.
- ParseError DecodeCreateTextureCube(unsigned int arg_count,
- CommandBufferEntry *args);
-
- // Decodes the SET_TEXTURE_DATA command.
- ParseError DecodeSetTextureData(unsigned int arg_count,
- CommandBufferEntry *args);
-
- // Decodes the SET_TEXTURE_DATA_IMMEDIATE command.
- ParseError DecodeSetTextureDataImmediate(unsigned int arg_count,
- CommandBufferEntry *args);
-
- // Decodes the GET_TEXTURE_DATA command.
- ParseError DecodeGetTextureData(unsigned int arg_count,
- CommandBufferEntry *args);
-
- // Decodes the SET_SAMPLER_STATES command.
- ParseError DecodeSetSamplerStates(unsigned int arg_count,
- CommandBufferEntry *args);
-
- // Decodes the SET_STENCIL_TEST command.
- ParseError DecodeSetStencilTest(unsigned int arg_count,
- CommandBufferEntry *args);
-
- // Decodes the SET_BLENDING command.
- ParseError DecodeSetBlending(unsigned int arg_count,
- CommandBufferEntry *args);
-
// Gets the address of shared memory data, given a shared memory ID and an
// offset. Also checks that the size is consistent with the shared memory
// size.
@@ -125,7 +79,7 @@ class GAPIDecoder : public AsyncAPIInterface {
// Generate a member function prototype for each command in an automated and
// typesafe way.
#define O3D_COMMAND_BUFFER_CMD_OP(name) \
- ParseError Handle_ ## name( \
+ ParseError Handle ## name( \
unsigned int arg_count, \
const cmd::name& args); \
diff --git a/o3d/command_buffer/service/cross/gl/effect_gl.cc b/o3d/command_buffer/service/cross/gl/effect_gl.cc
index c2c49e3..3c0baf6 100644
--- a/o3d/command_buffer/service/cross/gl/effect_gl.cc
+++ b/o3d/command_buffer/service/cross/gl/effect_gl.cc
@@ -720,27 +720,27 @@ BufferSyncInterface::ParseError GAPIGL::CreateEffect(ResourceID id,
&vertex_program_entry,
&fragment_program_entry,
&effect_code)) {
- return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ return BufferSyncInterface::kParseInvalidArguments;
}
EffectGL * effect = EffectGL::Create(this, effect_code,
vertex_program_entry,
fragment_program_entry);
- if (!effect) return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ if (!effect) return BufferSyncInterface::kParseInvalidArguments;
effects_.Assign(id, effect);
- return BufferSyncInterface::PARSE_NO_ERROR;
+ return BufferSyncInterface::kParseNoError;
}
BufferSyncInterface::ParseError GAPIGL::DestroyEffect(ResourceID id) {
if (id == current_effect_id_) DirtyEffect();
return effects_.Destroy(id) ?
- BufferSyncInterface::PARSE_NO_ERROR :
- BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ BufferSyncInterface::kParseNoError :
+ BufferSyncInterface::kParseInvalidArguments;
}
BufferSyncInterface::ParseError GAPIGL::SetEffect(ResourceID id) {
DirtyEffect();
current_effect_id_ = id;
- return BufferSyncInterface::PARSE_NO_ERROR;
+ return BufferSyncInterface::kParseNoError;
}
BufferSyncInterface::ParseError GAPIGL::GetParamCount(ResourceID id,
@@ -748,20 +748,20 @@ BufferSyncInterface::ParseError GAPIGL::GetParamCount(ResourceID id,
void *data) {
EffectGL *effect = effects_.Get(id);
if (!effect || size < sizeof(Uint32)) // NOLINT
- return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ return BufferSyncInterface::kParseInvalidArguments;
*static_cast<Uint32 *>(data) = effect->GetParamCount();
- return BufferSyncInterface::PARSE_NO_ERROR;
+ return BufferSyncInterface::kParseNoError;
}
BufferSyncInterface::ParseError GAPIGL::CreateParam(ResourceID param_id,
ResourceID effect_id,
unsigned int index) {
EffectGL *effect = effects_.Get(effect_id);
- if (!effect) return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ if (!effect) return BufferSyncInterface::kParseInvalidArguments;
EffectParamGL *param = effect->CreateParam(index);
- if (!param) return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ if (!param) return BufferSyncInterface::kParseInvalidArguments;
effect_params_.Assign(param_id, param);
- return BufferSyncInterface::PARSE_NO_ERROR;
+ return BufferSyncInterface::kParseNoError;
}
BufferSyncInterface::ParseError GAPIGL::CreateParamByName(ResourceID param_id,
@@ -769,38 +769,38 @@ BufferSyncInterface::ParseError GAPIGL::CreateParamByName(ResourceID param_id,
unsigned int size,
const void *name) {
EffectGL *effect = effects_.Get(effect_id);
- if (!effect) return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ if (!effect) return BufferSyncInterface::kParseInvalidArguments;
std::string string_name(static_cast<const char *>(name), size);
EffectParamGL *param = effect->CreateParamByName(string_name.c_str());
- if (!param) return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ if (!param) return BufferSyncInterface::kParseInvalidArguments;
effect_params_.Assign(param_id, param);
- return BufferSyncInterface::PARSE_NO_ERROR;
+ return BufferSyncInterface::kParseNoError;
}
BufferSyncInterface::ParseError GAPIGL::DestroyParam(ResourceID id) {
return effect_params_.Destroy(id) ?
- BufferSyncInterface::PARSE_NO_ERROR :
- BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ BufferSyncInterface::kParseNoError :
+ BufferSyncInterface::kParseInvalidArguments;
}
BufferSyncInterface::ParseError GAPIGL::SetParamData(ResourceID id,
unsigned int size,
const void *data) {
EffectParamGL *param = effect_params_.Get(id);
- if (!param) return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ if (!param) return BufferSyncInterface::kParseInvalidArguments;
return param->SetData(this, size, data) ?
- BufferSyncInterface::PARSE_NO_ERROR :
- BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ BufferSyncInterface::kParseNoError :
+ BufferSyncInterface::kParseInvalidArguments;
}
BufferSyncInterface::ParseError GAPIGL::GetParamDesc(ResourceID id,
unsigned int size,
void *data) {
EffectParamGL *param = effect_params_.Get(id);
- if (!param) return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ if (!param) return BufferSyncInterface::kParseInvalidArguments;
return param->GetDesc(size, data) ?
- BufferSyncInterface::PARSE_NO_ERROR :
- BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ BufferSyncInterface::kParseNoError :
+ BufferSyncInterface::kParseInvalidArguments;
}
BufferSyncInterface::ParseError GAPIGL::GetStreamCount(
@@ -809,9 +809,9 @@ BufferSyncInterface::ParseError GAPIGL::GetStreamCount(
void *data) {
EffectGL *effect = effects_.Get(id);
if (!effect || size < sizeof(Uint32)) // NOLINT
- return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ return BufferSyncInterface::kParseInvalidArguments;
*static_cast<Uint32 *>(data) = effect->GetStreamCount();
- return BufferSyncInterface::PARSE_NO_ERROR;
+ return BufferSyncInterface::kParseNoError;
}
BufferSyncInterface::ParseError GAPIGL::GetStreamDesc(ResourceID id,
@@ -819,10 +819,10 @@ BufferSyncInterface::ParseError GAPIGL::GetStreamDesc(ResourceID id,
unsigned int size,
void *data) {
EffectGL *effect = effects_.Get(id);
- if (!effect) return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ if (!effect) return BufferSyncInterface::kParseInvalidArguments;
return effect->GetStreamDesc(index, size, data) ?
- BufferSyncInterface::PARSE_NO_ERROR :
- BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ BufferSyncInterface::kParseNoError :
+ BufferSyncInterface::kParseInvalidArguments;
}
// If the current effect is valid, call End on it, and tag for revalidation.
diff --git a/o3d/command_buffer/service/cross/gl/geometry_gl.cc b/o3d/command_buffer/service/cross/gl/geometry_gl.cc
index c6e1dc8..58bf819 100644
--- a/o3d/command_buffer/service/cross/gl/geometry_gl.cc
+++ b/o3d/command_buffer/service/cross/gl/geometry_gl.cc
@@ -311,13 +311,13 @@ BufferSyncInterface::ParseError GAPIGL::CreateVertexBuffer(ResourceID id,
VertexBufferGL *vertex_buffer = new VertexBufferGL(size, flags);
vertex_buffer->Create();
vertex_buffers_.Assign(id, vertex_buffer);
- return BufferSyncInterface::PARSE_NO_ERROR;
+ return BufferSyncInterface::kParseNoError;
}
BufferSyncInterface::ParseError GAPIGL::DestroyVertexBuffer(ResourceID id) {
return vertex_buffers_.Destroy(id) ?
- BufferSyncInterface::PARSE_NO_ERROR :
- BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ BufferSyncInterface::kParseNoError :
+ BufferSyncInterface::kParseInvalidArguments;
}
BufferSyncInterface::ParseError GAPIGL::SetVertexBufferData(ResourceID id,
@@ -325,10 +325,10 @@ BufferSyncInterface::ParseError GAPIGL::SetVertexBufferData(ResourceID id,
unsigned int size,
const void *data) {
VertexBufferGL *vertex_buffer = vertex_buffers_.Get(id);
- if (!vertex_buffer) return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ if (!vertex_buffer) return BufferSyncInterface::kParseInvalidArguments;
return vertex_buffer->SetData(offset, size, data) ?
- BufferSyncInterface::PARSE_NO_ERROR :
- BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ BufferSyncInterface::kParseNoError :
+ BufferSyncInterface::kParseInvalidArguments;
}
BufferSyncInterface::ParseError GAPIGL::GetVertexBufferData(ResourceID id,
@@ -336,10 +336,10 @@ BufferSyncInterface::ParseError GAPIGL::GetVertexBufferData(ResourceID id,
unsigned int size,
void *data) {
VertexBufferGL *vertex_buffer = vertex_buffers_.Get(id);
- if (!vertex_buffer) return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ if (!vertex_buffer) return BufferSyncInterface::kParseInvalidArguments;
return vertex_buffer->GetData(offset, size, data) ?
- BufferSyncInterface::PARSE_NO_ERROR :
- BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ BufferSyncInterface::kParseNoError :
+ BufferSyncInterface::kParseInvalidArguments;
}
BufferSyncInterface::ParseError GAPIGL::CreateIndexBuffer(ResourceID id,
@@ -348,13 +348,13 @@ BufferSyncInterface::ParseError GAPIGL::CreateIndexBuffer(ResourceID id,
IndexBufferGL *index_buffer = new IndexBufferGL(size, flags);
index_buffer->Create();
index_buffers_.Assign(id, index_buffer);
- return BufferSyncInterface::PARSE_NO_ERROR;
+ return BufferSyncInterface::kParseNoError;
}
BufferSyncInterface::ParseError GAPIGL::DestroyIndexBuffer(ResourceID id) {
return index_buffers_.Destroy(id) ?
- BufferSyncInterface::PARSE_NO_ERROR :
- BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ BufferSyncInterface::kParseNoError :
+ BufferSyncInterface::kParseInvalidArguments;
}
BufferSyncInterface::ParseError GAPIGL::SetIndexBufferData(ResourceID id,
@@ -362,10 +362,10 @@ BufferSyncInterface::ParseError GAPIGL::SetIndexBufferData(ResourceID id,
unsigned int size,
const void *data) {
IndexBufferGL *index_buffer = index_buffers_.Get(id);
- if (!index_buffer) return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ if (!index_buffer) return BufferSyncInterface::kParseInvalidArguments;
return index_buffer->SetData(offset, size, data) ?
- BufferSyncInterface::PARSE_NO_ERROR :
- BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ BufferSyncInterface::kParseNoError :
+ BufferSyncInterface::kParseInvalidArguments;
}
BufferSyncInterface::ParseError GAPIGL::GetIndexBufferData(ResourceID id,
@@ -373,10 +373,10 @@ BufferSyncInterface::ParseError GAPIGL::GetIndexBufferData(ResourceID id,
unsigned int size,
void *data) {
IndexBufferGL *index_buffer = index_buffers_.Get(id);
- if (!index_buffer) return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ if (!index_buffer) return BufferSyncInterface::kParseInvalidArguments;
return index_buffer->GetData(offset, size, data) ?
- BufferSyncInterface::PARSE_NO_ERROR :
- BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ BufferSyncInterface::kParseNoError :
+ BufferSyncInterface::kParseInvalidArguments;
}
BufferSyncInterface::ParseError GAPIGL::CreateVertexStruct(
@@ -385,14 +385,14 @@ BufferSyncInterface::ParseError GAPIGL::CreateVertexStruct(
if (id == current_vertex_struct_) validate_streams_ = true;
VertexStructGL *vertex_struct = new VertexStructGL(input_count);
vertex_structs_.Assign(id, vertex_struct);
- return BufferSyncInterface::PARSE_NO_ERROR;
+ return BufferSyncInterface::kParseNoError;
}
BufferSyncInterface::ParseError GAPIGL::DestroyVertexStruct(ResourceID id) {
if (id == current_vertex_struct_) validate_streams_ = true;
return vertex_structs_.Destroy(id) ?
- BufferSyncInterface::PARSE_NO_ERROR :
- BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ BufferSyncInterface::kParseNoError :
+ BufferSyncInterface::kParseInvalidArguments;
}
BufferSyncInterface::ParseError GAPIGL::SetVertexInput(
@@ -407,22 +407,22 @@ BufferSyncInterface::ParseError GAPIGL::SetVertexInput(
switch (semantic) {
case vertex_struct::POSITION:
if (semantic_index != 0) {
- return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ return BufferSyncInterface::kParseInvalidArguments;
}
break;
case vertex_struct::NORMAL:
if (semantic_index != 0) {
- return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ return BufferSyncInterface::kParseInvalidArguments;
}
break;
case vertex_struct::COLOR:
if (semantic_index >= 2) {
- return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ return BufferSyncInterface::kParseInvalidArguments;
}
break;
case vertex_struct::TEX_COORD:
if (semantic_index >= 8) {
- return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ return BufferSyncInterface::kParseInvalidArguments;
}
break;
default:
@@ -432,16 +432,16 @@ BufferSyncInterface::ParseError GAPIGL::SetVertexInput(
if (vertex_buffer_id == current_vertex_struct_) validate_streams_ = true;
VertexStructGL *vertex_struct = vertex_structs_.Get(vertex_struct_id);
if (!vertex_struct || input_index >= vertex_struct->count())
- return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ return BufferSyncInterface::kParseInvalidArguments;
vertex_struct->SetInput(input_index, vertex_buffer_id, offset, stride, type,
semantic, semantic_index);
- return BufferSyncInterface::PARSE_NO_ERROR;
+ return BufferSyncInterface::kParseNoError;
}
BufferSyncInterface::ParseError GAPIGL::SetVertexStruct(ResourceID id) {
current_vertex_struct_ = id;
validate_streams_ = true;
- return BufferSyncInterface::PARSE_NO_ERROR;
+ return BufferSyncInterface::kParseNoError;
}
bool GAPIGL::ValidateStreams() {
@@ -497,20 +497,20 @@ BufferSyncInterface::ParseError GAPIGL::Draw(PrimitiveType primitive_type,
unsigned int first,
unsigned int count) {
if (validate_effect_ && !ValidateEffect()) {
- return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ return BufferSyncInterface::kParseInvalidArguments;
}
DCHECK(current_effect_);
if (validate_streams_ && !ValidateStreams()) {
- return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ return BufferSyncInterface::kParseInvalidArguments;
}
GLenum gl_mode = GL_POINTS;
PrimitiveTypeToGL(primitive_type, &gl_mode, &count);
if (first + count > max_vertices_) {
- return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ return BufferSyncInterface::kParseInvalidArguments;
}
glDrawArrays(gl_mode, first, count);
CHECK_GL_ERROR();
- return BufferSyncInterface::PARSE_NO_ERROR;
+ return BufferSyncInterface::kParseNoError;
}
BufferSyncInterface::ParseError GAPIGL::DrawIndexed(
@@ -521,16 +521,16 @@ BufferSyncInterface::ParseError GAPIGL::DrawIndexed(
unsigned int min_index,
unsigned int max_index) {
IndexBufferGL *index_buffer = index_buffers_.Get(index_buffer_id);
- if (!index_buffer) return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ if (!index_buffer) return BufferSyncInterface::kParseInvalidArguments;
if (validate_effect_ && !ValidateEffect()) {
- return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ return BufferSyncInterface::kParseInvalidArguments;
}
DCHECK(current_effect_);
if (validate_streams_ && !ValidateStreams()) {
- return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ return BufferSyncInterface::kParseInvalidArguments;
}
if ((min_index >= max_vertices_) || (max_index > max_vertices_)) {
- return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ return BufferSyncInterface::kParseInvalidArguments;
}
GLenum gl_mode = GL_POINTS;
PrimitiveTypeToGL(primitive_type, &gl_mode, &count);
@@ -541,12 +541,12 @@ BufferSyncInterface::ParseError GAPIGL::DrawIndexed(
sizeof(GLuint) : sizeof(GLushort); // NOLINT
GLuint offset = first * index_size;
if (offset + count * index_size > index_buffer->size()) {
- return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ return BufferSyncInterface::kParseInvalidArguments;
}
glDrawRangeElements(gl_mode, min_index, max_index, count, index_type,
OffsetToPtr(offset));
CHECK_GL_ERROR();
- return BufferSyncInterface::PARSE_NO_ERROR;
+ return BufferSyncInterface::kParseNoError;
}
} // namespace command_buffer
diff --git a/o3d/command_buffer/service/cross/gl/sampler_gl.cc b/o3d/command_buffer/service/cross/gl/sampler_gl.cc
index cbd1d1b..6bcc9488 100644
--- a/o3d/command_buffer/service/cross/gl/sampler_gl.cc
+++ b/o3d/command_buffer/service/cross/gl/sampler_gl.cc
@@ -178,7 +178,7 @@ BufferSyncInterface::ParseError GAPIGL::CreateSampler(
// Dirty effect, because this sampler id may be used.
DirtyEffect();
samplers_.Assign(id, new SamplerGL());
- return BufferSyncInterface::PARSE_NO_ERROR;
+ return BufferSyncInterface::kParseNoError;
}
// Destroys the Sampler resource.
@@ -186,8 +186,8 @@ BufferSyncInterface::ParseError GAPIGL::DestroySampler(ResourceID id) {
// Dirty effect, because this sampler id may be used.
DirtyEffect();
return samplers_.Destroy(id) ?
- BufferSyncInterface::PARSE_NO_ERROR :
- BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ BufferSyncInterface::kParseNoError :
+ BufferSyncInterface::kParseInvalidArguments;
}
BufferSyncInterface::ParseError GAPIGL::SetSamplerStates(
@@ -201,12 +201,12 @@ BufferSyncInterface::ParseError GAPIGL::SetSamplerStates(
unsigned int max_anisotropy) {
SamplerGL *sampler = samplers_.Get(id);
if (!sampler)
- return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ return BufferSyncInterface::kParseInvalidArguments;
// Dirty effect, because this sampler id may be used.
DirtyEffect();
sampler->SetStates(addressing_u, addressing_v, addressing_w,
mag_filter, min_filter, mip_filter, max_anisotropy);
- return BufferSyncInterface::PARSE_NO_ERROR;
+ return BufferSyncInterface::kParseNoError;
}
BufferSyncInterface::ParseError GAPIGL::SetSamplerBorderColor(
@@ -214,11 +214,11 @@ BufferSyncInterface::ParseError GAPIGL::SetSamplerBorderColor(
const RGBA &color) {
SamplerGL *sampler = samplers_.Get(id);
if (!sampler)
- return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ return BufferSyncInterface::kParseInvalidArguments;
// Dirty effect, because this sampler id may be used.
DirtyEffect();
sampler->SetBorderColor(color);
- return BufferSyncInterface::PARSE_NO_ERROR;
+ return BufferSyncInterface::kParseNoError;
}
BufferSyncInterface::ParseError GAPIGL::SetSamplerTexture(
@@ -226,11 +226,11 @@ BufferSyncInterface::ParseError GAPIGL::SetSamplerTexture(
ResourceID texture_id) {
SamplerGL *sampler = samplers_.Get(id);
if (!sampler)
- return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ return BufferSyncInterface::kParseInvalidArguments;
// Dirty effect, because this sampler id may be used.
DirtyEffect();
sampler->SetTexture(texture_id);
- return BufferSyncInterface::PARSE_NO_ERROR;
+ return BufferSyncInterface::kParseNoError;
}
diff --git a/o3d/command_buffer/service/cross/gl/texture_gl.cc b/o3d/command_buffer/service/cross/gl/texture_gl.cc
index 8280b77..6dcdd09 100644
--- a/o3d/command_buffer/service/cross/gl/texture_gl.cc
+++ b/o3d/command_buffer/service/cross/gl/texture_gl.cc
@@ -631,8 +631,8 @@ BufferSyncInterface::ParseError GAPIGL::DestroyTexture(ResourceID id) {
// Dirty effect, because this texture id may be used.
DirtyEffect();
return textures_.Destroy(id) ?
- BufferSyncInterface::PARSE_NO_ERROR :
- BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ BufferSyncInterface::kParseNoError :
+ BufferSyncInterface::kParseInvalidArguments;
}
// Creates a 2D texture resource.
@@ -646,11 +646,11 @@ BufferSyncInterface::ParseError GAPIGL::CreateTexture2D(
bool enable_render_surfaces) {
Texture2DGL *texture = Texture2DGL::Create(
width, height, levels, format, flags, enable_render_surfaces);
- if (!texture) return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ if (!texture) return BufferSyncInterface::kParseInvalidArguments;
// Dirty effect, because this texture id may be used.
DirtyEffect();
textures_.Assign(id, texture);
- return BufferSyncInterface::PARSE_NO_ERROR;
+ return BufferSyncInterface::kParseNoError;
}
// Creates a 3D texture resource.
@@ -665,11 +665,11 @@ BufferSyncInterface::ParseError GAPIGL::CreateTexture3D(
bool enable_render_surfaces) {
Texture3DGL *texture = Texture3DGL::Create(
width, height, depth, levels, format, flags, enable_render_surfaces);
- if (!texture) return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ if (!texture) return BufferSyncInterface::kParseInvalidArguments;
// Dirty effect, because this texture id may be used.
DirtyEffect();
textures_.Assign(id, texture);
- return BufferSyncInterface::PARSE_NO_ERROR;
+ return BufferSyncInterface::kParseNoError;
}
// Creates a cube map texture resource.
@@ -682,11 +682,11 @@ BufferSyncInterface::ParseError GAPIGL::CreateTextureCube(
bool enable_render_surfaces) {
TextureCubeGL *texture = TextureCubeGL::Create(
side, levels, format, flags, enable_render_surfaces);
- if (!texture) return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ if (!texture) return BufferSyncInterface::kParseInvalidArguments;
// Dirty effect, because this texture id may be used.
DirtyEffect();
textures_.Assign(id, texture);
- return BufferSyncInterface::PARSE_NO_ERROR;
+ return BufferSyncInterface::kParseNoError;
}
// Copies the data into a texture resource.
@@ -706,15 +706,15 @@ BufferSyncInterface::ParseError GAPIGL::SetTextureData(
const void *data) {
TextureGL *texture = textures_.Get(id);
if (!texture)
- return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ return BufferSyncInterface::kParseInvalidArguments;
Volume volume = {x, y, z, width, height, depth};
// Dirty effect: SetData may need to call glBindTexture which will mess up the
// sampler parameters.
DirtyEffect();
return texture->SetData(volume, level, face, row_pitch, slice_pitch,
size, data) ?
- BufferSyncInterface::PARSE_NO_ERROR :
- BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ BufferSyncInterface::kParseNoError :
+ BufferSyncInterface::kParseInvalidArguments;
}
// Copies the data from a texture resource.
@@ -734,15 +734,15 @@ BufferSyncInterface::ParseError GAPIGL::GetTextureData(
void *data) {
TextureGL *texture = textures_.Get(id);
if (!texture)
- return BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ return BufferSyncInterface::kParseInvalidArguments;
Volume volume = {x, y, z, width, height, depth};
// Dirty effect: GetData may need to call glBindTexture which will mess up the
// sampler parameters.
DirtyEffect();
return texture->GetData(volume, level, face, row_pitch, slice_pitch,
size, data) ?
- BufferSyncInterface::PARSE_NO_ERROR :
- BufferSyncInterface::PARSE_INVALID_ARGUMENTS;
+ BufferSyncInterface::kParseNoError :
+ BufferSyncInterface::kParseInvalidArguments;
}
} // namespace command_buffer
diff --git a/o3d/command_buffer/service/cross/mocks.h b/o3d/command_buffer/service/cross/mocks.h
index 353ff0c..dbd4c62 100644
--- a/o3d/command_buffer/service/cross/mocks.h
+++ b/o3d/command_buffer/service/cross/mocks.h
@@ -52,7 +52,7 @@ class AsyncAPIMock : public AsyncAPIInterface {
public:
AsyncAPIMock() {
testing::DefaultValue<BufferSyncInterface::ParseError>::Set(
- BufferSyncInterface::PARSE_NO_ERROR);
+ BufferSyncInterface::kParseNoError);
}
// Predicate that matches args passed to DoCommand, by looking at the values.
@@ -60,11 +60,12 @@ class AsyncAPIMock : public AsyncAPIInterface {
public:
IsArgs(unsigned int arg_count, const void* args)
: arg_count_(arg_count),
- args_(static_cast<CommandBufferEntry*>(const_cast<void*>(args))) { }
+ args_(static_cast<CommandBufferEntry*>(const_cast<void*>(args))) {
+ }
bool operator() (const void* _args) const {
const CommandBufferEntry* args =
- static_cast<const CommandBufferEntry*>(_args);
+ static_cast<const CommandBufferEntry*>(_args) + 1;
for (unsigned int i = 0; i < arg_count_; ++i) {
if (args[i].value_uint32 != args_[i].value_uint32) return false;
}
@@ -79,9 +80,9 @@ class AsyncAPIMock : public AsyncAPIInterface {
MOCK_METHOD3(DoCommand, BufferSyncInterface::ParseError(
unsigned int command,
unsigned int arg_count,
- const void* args));
+ const void* cmd_data));
- // Sets the engine, to forward SET_TOKEN commands to it.
+ // Sets the engine, to forward SetToken commands to it.
void set_engine(CommandBufferEngine *engine) { engine_ = engine; }
// Forwards the SetToken commands to the engine.