| OLD | NEW |
| 1 //! \file | 1 //! \file |
| 2 //! | 2 //! |
| 3 //! The public interface for 3D graphics is based on a commmand buffer. | 3 //! The public interface for 3D graphics is based on a command buffer. |
| 4 //! | 4 //! |
| 5 //! This was choosen because it provides an easy way to separate the process | 5 //! This was chosen because it provides an easy way to separate the process of |
| 6 //! writing commands from the process reading those commands without requiring | 6 //! writing commands from the process of reading those commands without |
| 7 //! too much overhead to keep the two processes in sync. | 7 //! requiring too much overhead to keep the two processes in sync. |
| 8 //! | 8 //! |
| 9 //! You can use this info to write commands yourself. Most developers will use | 9 //! You can use this info to write commands yourself. Most developers will use |
| 10 //! the provided OpenGL ES 2.0 implementation that issues these commands for | 10 //! the provided OpenGL ES 2.0 implementation that issues these commands for |
| 11 //! them. | 11 //! them. |
| 12 //! | 12 //! |
| 13 //! Each command starts with a header. The header is 32 bits where the first 21 | 13 //! Each command starts with a header. The header is 32 bits, where the first 21 |
| 14 //! bits define the number of 32 bit entries, including the header, the command | 14 //! bits define the number of 32 bit entries, including the header, the command |
| 15 //! represnts. The last 11 bits specify the specific command. | 15 //! represents. The last 11 bits specify the command. |
| 16 //! | 16 //! |
| 17 //! Commands that send a variable amount of data have 1 to 3 ways to send that | 17 //! Commands that send a variable amount of data have 1 to 3 ways to send that |
| 18 //! data. | 18 //! data. |
| 19 //! | 19 //! |
| 20 //! For many commands they can send their data in shared memory. The command | 20 //! Many commands can send their data in shared memory. The command will take |
| 21 //! will take an id of the shared memory and an offset into that shared memory | 21 //! an id of the shared memory and an offset into that shared memory of where |
| 22 //! of where the data lives. Commands are executed asynchronously so the client | 22 //! the data lives. Commands are executed asynchronously, so the client |
| 23 //! program must be careful to leave the data available until the command has | 23 //! program must be careful to leave the data available until the command has |
| 24 //! executed. | 24 //! executed. |
| 25 //! | 25 //! |
| 26 //! Some commands have an 'immediate' version where the data appears directly | 26 //! Some commands have an 'immediate' version where the data appears directly |
| 27 //! after the command in memory. | 27 //! after the command in memory. |
| 28 //! | 28 //! |
| 29 //! A 3rd way of passing data is through Buckets. Buckets are indentified by | 29 //! A 3rd way of passing data is through Buckets. Buckets are identified by |
| 30 //! number. You create a bucket with the command SetBucketSize, you can then | 30 //! number. You create a bucket with the command SetBucketSize, you can then |
| 31 //! fill the bucket with SetBucketData commands. Once you've sent all your | 31 //! fill the bucket with SetBucketData commands. Once you've sent all your |
| 32 //! data you can then issue a command that uses the bucket and takes a bucket | 32 //! data you can then issue a command that uses the bucket and takes a bucket |
| 33 //! id for which bucket to use. | 33 //! id for which bucket to use. |
| 34 //! | 34 //! |
| 35 //! Receiving data works similarly. Some commands return their data to shared | 35 //! Receiving data works similarly. Some commands return their data to shared |
| 36 //! memory. Other commands return their data through buckets which can then be | 36 //! memory. Other commands return their data through buckets which can then be |
| 37 //! queried with the GetBucketSize and GetBucketData commands. In either case | 37 //! queried with the GetBucketSize and GetBucketData commands. In either case |
| 38 //! the data will not be available until the command executes. | 38 //! the data will not be available until the command executes. |
| 39 //! | 39 //! |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 Uint32 size:21; | 74 Uint32 size:21; |
| 75 Uint32 command:11; | 75 Uint32 command:11; |
| 76 }; | 76 }; |
| 77 | 77 |
| 78 | 78 |
| 79 //! Used for some glGetXXX commands that return a result through a pointer. We | 79 //! Used for some glGetXXX commands that return a result through a pointer. We |
| 80 //! need to know if the command succeeded or not and the size of the result. If | 80 //! need to know if the command succeeded or not and the size of the result. If |
| 81 //! the command failed its result size will 0. You must set the size to 0 | 81 //! the command failed its result size will 0. You must set the size to 0 |
| 82 //! before issuing the command. | 82 //! before issuing the command. |
| 83 //! | 83 //! |
| 84 //! To retreive the data you might do something like this pseudo code: | 84 //! To retrieve the data you might do something like this pseudo code: |
| 85 //! | 85 //! |
| 86 //! GetAttachedShaders::Result* result = address-of-shared-memory | 86 //! GetAttachedShaders::Result* result = address-of-shared-memory |
| 87 //! int num_results = result->size / sizeof(GLuint); // the type returned | 87 //! int num_results = result->size / sizeof(GLuint); // the type returned |
| 88 //! GLuint* results = &result->data; | 88 //! GLuint* results = &result->data; |
| 89 //! for (int ii = 0; ii < num_results; ++ii) { | 89 //! for (int ii = 0; ii < num_results; ++ii) { |
| 90 //! printf("%d\n", results[ii]); | 90 //! printf("%d\n", results[ii]); |
| 91 //! } | 91 //! } |
| 92 //! | 92 //! |
| 93 template <typename T> | 93 template <typename T> |
| 94 struct SizedResult { | 94 struct SizedResult { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 116 //! The Jump command jumps to another place in the command buffer. | 116 //! The Jump command jumps to another place in the command buffer. |
| 117 struct Jump { | 117 struct Jump { |
| 118 static const CommandId kCmdId = 3; | 118 static const CommandId kCmdId = 3; |
| 119 | 119 |
| 120 CommandHeader header; | 120 CommandHeader header; |
| 121 uint32 offset; | 121 uint32 offset; |
| 122 }; | 122 }; |
| 123 | 123 |
| 124 //! The JumpRelative command jumps to another place in the command buffer | 124 //! The JumpRelative command jumps to another place in the command buffer |
| 125 //! relative to the end of this command. In other words. JumpRelative with an | 125 //! relative to the end of this command. In other words. JumpRelative with an |
| 126 //! offset of zero is effectively a noop. | 126 //! offset of zero is effectively a no-op. |
| 127 struct JumpRelative { | 127 struct JumpRelative { |
| 128 static const CommandId kCmdId = 4; | 128 static const CommandId kCmdId = 4; |
| 129 | 129 |
| 130 CommandHeader header; | 130 CommandHeader header; |
| 131 int32 offset; | 131 int32 offset; |
| 132 }; | 132 }; |
| 133 | 133 |
| 134 //! The Call command jumps to a subroutine which can be returned from with the | 134 //! The Call command jumps to a subroutine which can be returned from with the |
| 135 //! Return command. | 135 //! Return command. |
| 136 struct Call { | 136 struct Call { |
| (...skipping 2103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2240 struct RegisterSharedIds { | 2240 struct RegisterSharedIds { |
| 2241 static const CommandId kCmdId = 441; | 2241 static const CommandId kCmdId = 441; |
| 2242 | 2242 |
| 2243 CommandHeader header; | 2243 CommandHeader header; |
| 2244 uint32 namespace_id; //!< GLuint | 2244 uint32 namespace_id; //!< GLuint |
| 2245 int32 n; //!< GLsizei | 2245 int32 n; //!< GLsizei |
| 2246 uint32 ids_shm_id; //!< uint32 | 2246 uint32 ids_shm_id; //!< uint32 |
| 2247 uint32 ids_shm_offset; //!< uint32 | 2247 uint32 ids_shm_offset; //!< uint32 |
| 2248 }; | 2248 }; |
| 2249 | 2249 |
| 2250 //! Command that enables or disables command buffer specific features. | 2250 //! Command that enables features. The bucket should contain the feature string. |
| 2251 struct CommandBufferEnable { | 2251 struct CommandBufferEnable { |
| 2252 static const CommandId kCmdId = 442; | 2252 static const CommandId kCmdId = 442; |
| 2253 | 2253 |
| 2254 typedef GLint Result; |
| 2255 |
| 2254 CommandHeader header; | 2256 CommandHeader header; |
| 2255 uint32 cap; //!< GLenum | 2257 uint32 bucket_id; //!< GLuint |
| 2256 uint32 enable; //!< GLboolean | 2258 uint32 result_shm_id; //!< uint32 |
| 2259 uint32 result_shm_offset; //!< uint32 |
| 2257 }; | 2260 }; |
| 2258 | 2261 |
| 2262 |
| OLD | NEW |