Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: gpu/command_buffer/service/cmd_parser.h

Issue 558513003: command_buffer: Batch command processing to reduce handler overheads. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gpu/command_buffer/client/ring_buffer_test.cc ('k') | gpu/command_buffer/service/cmd_parser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This file contains the command parser class. 5 // This file contains the command parser class.
6 6
7 #ifndef GPU_COMMAND_BUFFER_SERVICE_CMD_PARSER_H_ 7 #ifndef GPU_COMMAND_BUFFER_SERVICE_CMD_PARSER_H_
8 #define GPU_COMMAND_BUFFER_SERVICE_CMD_PARSER_H_ 8 #define GPU_COMMAND_BUFFER_SERVICE_CMD_PARSER_H_
9 9
10 #include "gpu/command_buffer/common/constants.h" 10 #include "gpu/command_buffer/common/constants.h"
11 #include "gpu/command_buffer/common/cmd_buffer_common.h" 11 #include "gpu/command_buffer/common/cmd_buffer_common.h"
12 #include "gpu/gpu_export.h" 12 #include "gpu/gpu_export.h"
13 13
14 namespace gpu { 14 namespace gpu {
15 15
16 class AsyncAPIInterface; 16 class AsyncAPIInterface;
17 17
18 // Command parser class. This class parses commands from a shared memory 18 // Command parser class. This class parses commands from a shared memory
19 // buffer, to implement some asynchronous RPC mechanism. 19 // buffer, to implement some asynchronous RPC mechanism.
20 class GPU_EXPORT CommandParser { 20 class GPU_EXPORT CommandParser {
21 public: 21 public:
22 static const int kParseCommandsSlice = 20;
23
22 explicit CommandParser(AsyncAPIInterface* handler); 24 explicit CommandParser(AsyncAPIInterface* handler);
23 25
24 // Sets the buffer to read commands from. 26 // Sets the buffer to read commands from.
25 void SetBuffer( 27 void SetBuffer(
26 void* shm_address, 28 void* shm_address,
27 size_t shm_size, 29 size_t shm_size,
28 ptrdiff_t offset, 30 ptrdiff_t offset,
29 size_t size); 31 size_t size);
30 32
31 // Gets the "get" pointer. The get pointer is an index into the command 33 // Gets the "get" pointer. The get pointer is an index into the command
(...skipping 16 matching lines...) Expand all
48 50
49 // Gets the "put" pointer. The put pointer is an index into the command 51 // Gets the "put" pointer. The put pointer is an index into the command
50 // buffer considered as an array of CommandBufferEntry. 52 // buffer considered as an array of CommandBufferEntry.
51 CommandBufferOffset put() const { return put_; } 53 CommandBufferOffset put() const { return put_; }
52 54
53 // Checks whether there are commands to process. 55 // Checks whether there are commands to process.
54 bool IsEmpty() const { return put_ == get_; } 56 bool IsEmpty() const { return put_ == get_; }
55 57
56 // Processes one command, updating the get pointer. This will return an error 58 // Processes one command, updating the get pointer. This will return an error
57 // if there are no commands in the buffer. 59 // if there are no commands in the buffer.
58 error::Error ProcessCommand(); 60 error::Error ProcessCommands(int num_commands);
59 61
60 // Processes all commands until get == put. 62 // Processes all commands until get == put.
61 error::Error ProcessAllCommands(); 63 error::Error ProcessAllCommands();
62 64
63 // Reports an error.
64 void ReportError(unsigned int command_id, error::Error result);
65
66 private: 65 private:
67 CommandBufferOffset get_; 66 CommandBufferOffset get_;
68 CommandBufferOffset put_; 67 CommandBufferOffset put_;
69 CommandBufferEntry* buffer_; 68 CommandBufferEntry* buffer_;
70 int32 entry_count_; 69 int32 entry_count_;
71 AsyncAPIInterface* handler_; 70 AsyncAPIInterface* handler_;
72 }; 71 };
73 72
74 // This class defines the interface for an asynchronous API handler, that 73 // This class defines the interface for an asynchronous API handler, that
75 // is responsible for de-multiplexing commands and their arguments. 74 // is responsible for de-multiplexing commands and their arguments.
76 class AsyncAPIInterface { 75 class GPU_EXPORT AsyncAPIInterface {
77 public: 76 public:
78 AsyncAPIInterface() {} 77 AsyncAPIInterface() {}
79 virtual ~AsyncAPIInterface() {} 78 virtual ~AsyncAPIInterface() {}
80 79
81 // Executes a command. 80 // Executes a single command.
82 // Parameters: 81 // Parameters:
83 // command: the command index. 82 // command: the command index.
84 // arg_count: the number of CommandBufferEntry arguments. 83 // arg_count: the number of CommandBufferEntry arguments.
85 // cmd_data: the command data. 84 // cmd_data: the command data.
86 // Returns: 85 // Returns:
87 // error::kNoError if no error was found, one of 86 // error::kNoError if no error was found, one of
88 // error::Error otherwise. 87 // error::Error otherwise.
89 virtual error::Error DoCommand( 88 virtual error::Error DoCommand(
90 unsigned int command, 89 unsigned int command,
91 unsigned int arg_count, 90 unsigned int arg_count,
92 const void* cmd_data) = 0; 91 const void* cmd_data) = 0;
93 92
93 // Executes multiple commands.
94 // Parameters:
95 // num_commands: maximum number of commands to execute from buffer.
96 // buffer: pointer to first command entry to process.
97 // num_entries: number of sequential command buffer entries in buffer.
98 // entries_processed: if not 0, is set to the number of entries processed.
99 virtual error::Error DoCommands(unsigned int num_commands,
100 const void* buffer,
101 int num_entries,
102 int* entries_processed);
103
94 // Returns a name for a command. Useful for logging / debuging. 104 // Returns a name for a command. Useful for logging / debuging.
95 virtual const char* GetCommandName(unsigned int command_id) const = 0; 105 virtual const char* GetCommandName(unsigned int command_id) const = 0;
96 }; 106 };
97 107
98 } // namespace gpu 108 } // namespace gpu
99 109
100 #endif // GPU_COMMAND_BUFFER_SERVICE_CMD_PARSER_H_ 110 #endif // GPU_COMMAND_BUFFER_SERVICE_CMD_PARSER_H_
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/ring_buffer_test.cc ('k') | gpu/command_buffer/service/cmd_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698