//! \file
//!
//! The public interface for 3D graphics is based on a command buffer.
//!
//! This was chosen because it provides an easy way to separate the process of
//! writing commands from the process of reading those commands without
//! requiring too much overhead to keep the two processes in sync.
//!
//! You can use this info to write commands yourself. Most developers will use
//! the provided OpenGL ES 2.0 implementation that issues these commands for
//! them.
//!
//! Each command starts with a header. The header is 32 bits, where the first 21
//! bits define the number of 32 bit entries, including the header, the command
//! represents. The last 11 bits specify the command.
//!
//! Commands that send a variable amount of data have 1 to 3 ways to send that
//! data.
//!
//! Many commands can send their data in shared memory. The command will take
//! an id of the shared memory and an offset into that shared memory of where
//! the data lives. Commands are executed asynchronously, so the client
//! program must be careful to leave the data available until the command has
//! executed.
//!
//! Some commands have an 'immediate' version where the data appears directly
//! after the command in memory.
//!
//! A 3rd way of passing data is through Buckets. Buckets are identified by
//! number. You create a bucket with the command SetBucketSize, you can then
//! fill the bucket with SetBucketData commands. Once you've sent all your
//! data you can then issue a command that uses the bucket and takes a bucket
//! id for which bucket to use.
//!
//! Receiving data works similarly. Some commands return their data to shared
//! memory. Other commands return their data through buckets which can then be
//! queried with the GetBucketSize and GetBucketData commands. In either case
//! the data will not be available until the command executes.
//!
//! All commands and arguments are validated. If a command fails validation the
//! service will stop processing commands. It is the responsibility of the
//! client to never issue an invalid command.
//!
//! Examples of invalid commands.
//!  - A command's size does not match the command.
//!  - A command's size would address memory outside the command buffer
//!  - A shared memory id is invalid
//!  - A shared memory offset is out of range for the given shared memory
//!  - The size of the data a command would access in shared memory is out of
//!    range for the given shared memory buffer.
//!  - A result (in the transfer buffer) is not initialized to the
//!    failure case. For example, any command that returns a SizedResult
//!    will take a shared memory id and offset to where to store the result.
//!    That size field of the result must be set to 0 before issuing the
//!    the command. That way, if the command buffer service fails the
//!    client will see a 0 size.
//!
//! The docs are a little terse. For any command that corresponds to an OpenGL
//! ES 2.0 function the arguments should be clear by looking at the OpenGL ES
//! 2.0 documentation with minor caveats.
//!
//!  - Client side arrays are not supported at the command buffer level
//!    so DrawArrays and VertexAttribPointer only take offsets into buffers.
//!  - The commands GenBuffers, GetTextures, CreateProgram, CreateShader, etc
//!    take client side ids and register them with the service. It's up to the
//!    client to make up the ids.
//!  - For shared resources, it's still up to the client to make up ids.
//!    but to help keep them in sync with other threads the commands
//!    GenSharedIds, RegisterSharedIds and DeleteSharedIds can be used.
//!

//! The command header.
struct CommandHeader {
  Uint32 size:21;
  Uint32 command:11;
};


//! Used for some glGetXXX commands that return a result through a pointer. We
//! need to know if the command succeeded or not and the size of the result. If
//! the command failed its result size will 0.  You must set the size to 0
//! before issuing the command.
//!
//! To retrieve the data you might do something like this pseudo code:
//!
//!   GetAttachedShaders::Result* result = address-of-shared-memory
//!   int num_results = result->size / sizeof(GLuint);  // the type returned
//!   GLuint* results = &result->data;
//!   for (int ii = 0; ii < num_results; ++ii) {
//!     printf("%d\n", results[ii]);
//!   }
//!
template <typename T>
struct SizedResult {
  uint32 size;  // in bytes.
  T data;  // this is just here to get an offset.
};


//! A Noop command.
struct Noop {
  static const CommandId kCmdId = 0;

  CommandHeader header;
};

//! The SetToken command puts a token in the command stream that you can
//! use to check if that token has been passed in the command stream.
struct SetToken {
  static const CommandId kCmdId = 1;

  CommandHeader header;
  uint32 token;
};

//! The Jump command jumps to another place in the command buffer.
struct Jump {
  static const CommandId kCmdId = 3;

  CommandHeader header;
  uint32 offset;
};

//! The JumpRelative command jumps to another place in the command buffer
//! relative to the end of this command. In other words. JumpRelative with an
//! offset of zero is effectively a no-op.
struct JumpRelative {
  static const CommandId kCmdId = 4;

  CommandHeader header;
  int32 offset;
};

//! The Call command jumps to a subroutine which can be returned from with the
//! Return command.
struct Call {
  static const CommandId kCmdId = 5;

  CommandHeader header;
  uint32 offset;
};

//! The CallRelative command jumps to a subroutine using a relative offset. The
//! offset is relative to the end of this command..
struct CallRelative {
  static const CommandId kCmdId = 6;

  CommandHeader header;
  int32 offset;
};

//! Returns from a subroutine called by the Call or CallRelative commands.
struct Return {
  static const CommandId kCmdId = 7;

  CommandHeader header;
};

//! Sets the size of a bucket for collecting data on the service side.
//! This is a utility for gathering data on the service side so it can be used
//! all at once when some service side API is called. It removes the need to
//! add special commands just to support a particular API. For example, any API
//! command that needs a string needs a way to send that string to the API over
//! the command buffers. While you can require that the command buffer or
//! transfer buffer be large enough to hold the largest string you can send,
//! using this command removes that restriction by letting you send smaller
//! pieces over and build up the data on the service side.
//!
//! You can clear a bucket on the service side and thereby free memory by
//! sending a size of 0.
struct SetBucketSize {
  static const CommandId kCmdId = 8;

  CommandHeader header;
  uint32 bucket_id;
  uint32 size;
};

//! Sets the contents of a portion of a bucket on the service side from data in
//! shared memory.
//! See SetBucketSize.
struct SetBucketData {
  static const CommandId kCmdId = 9;

  CommandHeader header;
  uint32 bucket_id;
  uint32 offset;
  uint32 size;
  uint32 shared_memory_id;
  uint32 shared_memory_offset;
};

//! Sets the contents of a portion of a bucket on the service side from data in
//! the command buffer.
//! See SetBucketSize.
struct SetBucketDataImmediate {
  static const CommandId kCmdId = 10;

  CommandHeader header;
  uint32 bucket_id;
  uint32 offset;
  uint32 size;
};

//! Gets the size of a bucket the service has available. Sending a variable
//! size result back to the client, for example any API that returns a string,
//! is problematic since the largest thing you can send back is the size of
//! your shared memory. This command along with GetBucketData implements a way
//! to get a result a piece at a time to help solve that problem in a generic
//! way.
struct GetBucketSize {
  static const CommandId kCmdId = 11;

  typedef uint32 Result;

  CommandHeader header;
  uint32 bucket_id;
  uint32 shared_memory_id;
  uint32 shared_memory_offset;
};

//! Gets a piece of a result the service has available.
//! See GetBucketSize.
struct GetBucketData {
  static const CommandId kCmdId = 12;

  CommandHeader header;
  uint32 bucket_id;
  uint32 offset;
  uint32 size;
  uint32 shared_memory_id;
  uint32 shared_memory_offset;
};

// OpenGL ES 2.0 related commands.

//! Command that corresponds to glActiveTexture.
struct ActiveTexture {
  static const CommandId kCmdId = 256;

  CommandHeader header;
  uint32 texture;  //!< GLenum
};

//! Command that corresponds to glAttachShader.
struct AttachShader {
  static const CommandId kCmdId = 257;

  CommandHeader header;
  uint32 program;  //!< GLuint
  uint32 shader;  //!< GLuint
};

//! Command that corresponds to glBindAttribLocation.
struct BindAttribLocation {
  static const CommandId kCmdId = 258;

  CommandHeader header;
  uint32 program;  //!< GLuint
  uint32 index;  //!< GLuint
  uint32 name_shm_id;  //!< uint32
  uint32 name_shm_offset;  //!< uint32
  uint32 data_size;  //!< uint32
};

//! Immediate version of command that corresponds to glBindAttribLocation.
struct BindAttribLocationImmediate {
  static const CommandId kCmdId = 259;

  CommandHeader header;
  uint32 program;  //!< GLuint
  uint32 index;  //!< GLuint
  uint32 data_size;  //!< uint32
};

//! Bucket version of command that corresponds to glBindAttribLocation.
struct BindAttribLocationBucket {
  static const CommandId kCmdId = 432;

  CommandHeader header;
  uint32 program;  //!< GLuint
  uint32 index;  //!< GLuint
  uint32 name_bucket_id;  //!< uint32
};

//! Command that corresponds to glBindBuffer.
struct BindBuffer {
  static const CommandId kCmdId = 260;

  CommandHeader header;
  uint32 target;  //!< GLenum
  uint32 buffer;  //!< GLuint
};

//! Command that corresponds to glBindFramebuffer.
struct BindFramebuffer {
  static const CommandId kCmdId = 261;

  CommandHeader header;
  uint32 target;  //!< GLenum
  uint32 framebuffer;  //!< GLuint
};

//! Command that corresponds to glBindRenderbuffer.
struct BindRenderbuffer {
  static const CommandId kCmdId = 262;

  CommandHeader header;
  uint32 target;  //!< GLenum
  uint32 renderbuffer;  //!< GLuint
};

//! Command that corresponds to glBindTexture.
struct BindTexture {
  static const CommandId kCmdId = 263;

  CommandHeader header;
  uint32 target;  //!< GLenum
  uint32 texture;  //!< GLuint
};

//! Command that corresponds to glBlendColor.
struct BlendColor {
  static const CommandId kCmdId = 264;

  CommandHeader header;
  float red;  //!< GLclampf
  float green;  //!< GLclampf
  float blue;  //!< GLclampf
  float alpha;  //!< GLclampf
};

//! Command that corresponds to glBlendEquation.
struct BlendEquation {
  static const CommandId kCmdId = 265;

  CommandHeader header;
  uint32 mode;  //!< GLenum
};

//! Command that corresponds to glBlendEquationSeparate.
struct BlendEquationSeparate {
  static const CommandId kCmdId = 266;

  CommandHeader header;
  uint32 modeRGB;  //!< GLenum
  uint32 modeAlpha;  //!< GLenum
};

//! Command that corresponds to glBlendFunc.
struct BlendFunc {
  static const CommandId kCmdId = 267;

  CommandHeader header;
  uint32 sfactor;  //!< GLenum
  uint32 dfactor;  //!< GLenum
};

//! Command that corresponds to glBlendFuncSeparate.
struct BlendFuncSeparate {
  static const CommandId kCmdId = 268;

  CommandHeader header;
  uint32 srcRGB;  //!< GLenum
  uint32 dstRGB;  //!< GLenum
  uint32 srcAlpha;  //!< GLenum
  uint32 dstAlpha;  //!< GLenum
};

//! Command that corresponds to glBufferData.
struct BufferData {
  static const CommandId kCmdId = 269;

  CommandHeader header;
  uint32 target;  //!< GLenum
  int32 size;  //!< GLsizeiptr
  uint32 data_shm_id;  //!< uint32
  uint32 data_shm_offset;  //!< uint32
  uint32 usage;  //!< GLenum
};

//! Immediate version of command that corresponds to glBufferData.
struct BufferDataImmediate {
  static const CommandId kCmdId = 270;

  CommandHeader header;
  uint32 target;  //!< GLenum
  int32 size;  //!< GLsizeiptr
  uint32 usage;  //!< GLenum
};

//! Command that corresponds to glBufferSubData.
struct BufferSubData {
  static const CommandId kCmdId = 271;

  CommandHeader header;
  uint32 target;  //!< GLenum
  int32 offset;  //!< GLintptr
  int32 size;  //!< GLsizeiptr
  uint32 data_shm_id;  //!< uint32
  uint32 data_shm_offset;  //!< uint32
};

//! Immediate version of command that corresponds to glBufferSubData.
struct BufferSubDataImmediate {
  static const CommandId kCmdId = 272;

  CommandHeader header;
  uint32 target;  //!< GLenum
  int32 offset;  //!< GLintptr
  int32 size;  //!< GLsizeiptr
};

//! Command that corresponds to glCheckFramebufferStatus.
struct CheckFramebufferStatus {
  static const CommandId kCmdId = 273;

  typedef GLenum Result;

  CommandHeader header;
  uint32 target;  //!< GLenum
  uint32 result_shm_id;  //!< uint32
  uint32 result_shm_offset;  //!< uint32
};

//! Command that corresponds to glClear.
struct Clear {
  static const CommandId kCmdId = 274;

  CommandHeader header;
  uint32 mask;  //!< GLbitfield
};

//! Command that corresponds to glClearColor.
struct ClearColor {
  static const CommandId kCmdId = 275;

  CommandHeader header;
  float red;  //!< GLclampf
  float green;  //!< GLclampf
  float blue;  //!< GLclampf
  float alpha;  //!< GLclampf
};

//! Command that corresponds to glClearDepthf.
struct ClearDepthf {
  static const CommandId kCmdId = 276;

  CommandHeader header;
  float depth;  //!< GLclampf
};

//! Command that corresponds to glClearStencil.
struct ClearStencil {
  static const CommandId kCmdId = 277;

  CommandHeader header;
  int32 s;  //!< GLint
};

//! Command that corresponds to glColorMask.
struct ColorMask {
  static const CommandId kCmdId = 278;

  CommandHeader header;
  uint32 red;  //!< GLboolean
  uint32 green;  //!< GLboolean
  uint32 blue;  //!< GLboolean
  uint32 alpha;  //!< GLboolean
};

//! Command that corresponds to glCompileShader.
struct CompileShader {
  static const CommandId kCmdId = 279;

  CommandHeader header;
  uint32 shader;  //!< GLuint
};

//! Command that corresponds to glCompressedTexImage2D.
struct CompressedTexImage2D {
  static const CommandId kCmdId = 280;

  CommandHeader header;
  uint32 target;  //!< GLenum
  int32 level;  //!< GLint
  uint32 internalformat;  //!< GLenum
  int32 width;  //!< GLsizei
  int32 height;  //!< GLsizei
  int32 border;  //!< GLint
  int32 imageSize;  //!< GLsizei
  uint32 data_shm_id;  //!< uint32
  uint32 data_shm_offset;  //!< uint32
};

//! Immediate version of command that corresponds to glCompressedTexImage2D.
struct CompressedTexImage2DImmediate {
  static const CommandId kCmdId = 281;

  CommandHeader header;
  uint32 target;  //!< GLenum
  int32 level;  //!< GLint
  uint32 internalformat;  //!< GLenum
  int32 width;  //!< GLsizei
  int32 height;  //!< GLsizei
  int32 border;  //!< GLint
  int32 imageSize;  //!< GLsizei
};

//! Bucket version of command that corresponds to glCompressedTexImage2D.
struct CompressedTexImage2DBucket {
  static const CommandId kCmdId = 443;

  CommandHeader header;
  uint32 target;  //!< GLenum
  int32 level;  //!< GLint
  uint32 internalformat;  //!< GLenum
  int32 width;  //!< GLsizei
  int32 height;  //!< GLsizei
  int32 border;  //!< GLint
  uint32 bucket_id;  //!< GLuint
};

//! Command that corresponds to glCompressedTexSubImage2D.
struct CompressedTexSubImage2D {
  static const CommandId kCmdId = 282;

  CommandHeader header;
  uint32 target;  //!< GLenum
  int32 level;  //!< GLint
  int32 xoffset;  //!< GLint
  int32 yoffset;  //!< GLint
  int32 width;  //!< GLsizei
  int32 height;  //!< GLsizei
  uint32 format;  //!< GLenum
  int32 imageSize;  //!< GLsizei
  uint32 data_shm_id;  //!< uint32
  uint32 data_shm_offset;  //!< uint32
};

//! Immediate version of command that corresponds to glCompressedTexSubImage2D.
struct CompressedTexSubImage2DImmediate {
  static const CommandId kCmdId = 283;

  CommandHeader header;
  uint32 target;  //!< GLenum
  int32 level;  //!< GLint
  int32 xoffset;  //!< GLint
  int32 yoffset;  //!< GLint
  int32 width;  //!< GLsizei
  int32 height;  //!< GLsizei
  uint32 format;  //!< GLenum
  int32 imageSize;  //!< GLsizei
};

//! Bucket version of command that corresponds to glCompressedTexSubImage2D.
struct CompressedTexSubImage2DBucket {
  static const CommandId kCmdId = 444;

  CommandHeader header;
  uint32 target;  //!< GLenum
  int32 level;  //!< GLint
  int32 xoffset;  //!< GLint
  int32 yoffset;  //!< GLint
  int32 width;  //!< GLsizei
  int32 height;  //!< GLsizei
  uint32 format;  //!< GLenum
  uint32 bucket_id;  //!< GLuint
};

//! Command that corresponds to glCopyTexImage2D.
struct CopyTexImage2D {
  static const CommandId kCmdId = 284;

  CommandHeader header;
  uint32 target;  //!< GLenum
  int32 level;  //!< GLint
  uint32 internalformat;  //!< GLenum
  int32 x;  //!< GLint
  int32 y;  //!< GLint
  int32 width;  //!< GLsizei
  int32 height;  //!< GLsizei
  int32 border;  //!< GLint
};

//! Command that corresponds to glCopyTexSubImage2D.
struct CopyTexSubImage2D {
  static const CommandId kCmdId = 285;

  CommandHeader header;
  uint32 target;  //!< GLenum
  int32 level;  //!< GLint
  int32 xoffset;  //!< GLint
  int32 yoffset;  //!< GLint
  int32 x;  //!< GLint
  int32 y;  //!< GLint
  int32 width;  //!< GLsizei
  int32 height;  //!< GLsizei
};

//! Command that corresponds to glCreateProgram.
struct CreateProgram {
  static const CommandId kCmdId = 286;

  CommandHeader header;
  uint32 client_id;  //!< uint32
};

//! Command that corresponds to glCreateShader.
struct CreateShader {
  static const CommandId kCmdId = 287;

  CommandHeader header;
  uint32 type;  //!< GLenum
  uint32 client_id;  //!< uint32
};

//! Command that corresponds to glCullFace.
struct CullFace {
  static const CommandId kCmdId = 288;

  CommandHeader header;
  uint32 mode;  //!< GLenum
};

//! Command that corresponds to glDeleteBuffers.
struct DeleteBuffers {
  static const CommandId kCmdId = 289;

  CommandHeader header;
  int32 n;  //!< GLsizei
  uint32 buffers_shm_id;  //!< uint32
  uint32 buffers_shm_offset;  //!< uint32
};

//! Immediate version of command that corresponds to glDeleteBuffers.
struct DeleteBuffersImmediate {
  static const CommandId kCmdId = 290;

  CommandHeader header;
  int32 n;  //!< GLsizei
};

//! Command that corresponds to glDeleteFramebuffers.
struct DeleteFramebuffers {
  static const CommandId kCmdId = 291;

  CommandHeader header;
  int32 n;  //!< GLsizei
  uint32 framebuffers_shm_id;  //!< uint32
  uint32 framebuffers_shm_offset;  //!< uint32
};

//! Immediate version of command that corresponds to glDeleteFramebuffers.
struct DeleteFramebuffersImmediate {
  static const CommandId kCmdId = 292;

  CommandHeader header;
  int32 n;  //!< GLsizei
};

//! Command that corresponds to glDeleteProgram.
struct DeleteProgram {
  static const CommandId kCmdId = 293;

  CommandHeader header;
  uint32 program;  //!< GLuint
};

//! Command that corresponds to glDeleteRenderbuffers.
struct DeleteRenderbuffers {
  static const CommandId kCmdId = 294;

  CommandHeader header;
  int32 n;  //!< GLsizei
  uint32 renderbuffers_shm_id;  //!< uint32
  uint32 renderbuffers_shm_offset;  //!< uint32
};

//! Immediate version of command that corresponds to glDeleteRenderbuffers.
struct DeleteRenderbuffersImmediate {
  static const CommandId kCmdId = 295;

  CommandHeader header;
  int32 n;  //!< GLsizei
};

//! Command that corresponds to glDeleteShader.
struct DeleteShader {
  static const CommandId kCmdId = 296;

  CommandHeader header;
  uint32 shader;  //!< GLuint
};

//! Command that corresponds to glDeleteTextures.
struct DeleteTextures {
  static const CommandId kCmdId = 297;

  CommandHeader header;
  int32 n;  //!< GLsizei
  uint32 textures_shm_id;  //!< uint32
  uint32 textures_shm_offset;  //!< uint32
};

//! Immediate version of command that corresponds to glDeleteTextures.
struct DeleteTexturesImmediate {
  static const CommandId kCmdId = 298;

  CommandHeader header;
  int32 n;  //!< GLsizei
};

//! Command that corresponds to glDepthFunc.
struct DepthFunc {
  static const CommandId kCmdId = 299;

  CommandHeader header;
  uint32 func;  //!< GLenum
};

//! Command that corresponds to glDepthMask.
struct DepthMask {
  static const CommandId kCmdId = 300;

  CommandHeader header;
  uint32 flag;  //!< GLboolean
};

//! Command that corresponds to glDepthRangef.
struct DepthRangef {
  static const CommandId kCmdId = 301;

  CommandHeader header;
  float zNear;  //!< GLclampf
  float zFar;  //!< GLclampf
};

//! Command that corresponds to glDetachShader.
struct DetachShader {
  static const CommandId kCmdId = 302;

  CommandHeader header;
  uint32 program;  //!< GLuint
  uint32 shader;  //!< GLuint
};

//! Command that corresponds to glDisable.
struct Disable {
  static const CommandId kCmdId = 303;

  CommandHeader header;
  uint32 cap;  //!< GLenum
};

//! Command that corresponds to glDisableVertexAttribArray.
struct DisableVertexAttribArray {
  static const CommandId kCmdId = 304;

  CommandHeader header;
  uint32 index;  //!< GLuint
};

//! Command that corresponds to glDrawArrays.
struct DrawArrays {
  static const CommandId kCmdId = 305;

  CommandHeader header;
  uint32 mode;  //!< GLenum
  int32 first;  //!< GLint
  int32 count;  //!< GLsizei
};

//! Command that corresponds to glDrawElements.
struct DrawElements {
  static const CommandId kCmdId = 306;

  CommandHeader header;
  uint32 mode;  //!< GLenum
  int32 count;  //!< GLsizei
  uint32 type;  //!< GLenum
  uint32 index_offset;  //!< GLuint
};

//! Command that corresponds to glEnable.
struct Enable {
  static const CommandId kCmdId = 307;

  CommandHeader header;
  uint32 cap;  //!< GLenum
};

//! Command that corresponds to glEnableVertexAttribArray.
struct EnableVertexAttribArray {
  static const CommandId kCmdId = 308;

  CommandHeader header;
  uint32 index;  //!< GLuint
};

//! Command that corresponds to glFinish.
struct Finish {
  static const CommandId kCmdId = 309;

  CommandHeader header;
};

//! Command that corresponds to glFlush.
struct Flush {
  static const CommandId kCmdId = 310;

  CommandHeader header;
};

//! Command that corresponds to glFramebufferRenderbuffer.
struct FramebufferRenderbuffer {
  static const CommandId kCmdId = 311;

  CommandHeader header;
  uint32 target;  //!< GLenum
  uint32 attachment;  //!< GLenum
  uint32 renderbuffertarget;  //!< GLenum
  uint32 renderbuffer;  //!< GLuint
};

//! Command that corresponds to glFramebufferTexture2D.
struct FramebufferTexture2D {
  static const CommandId kCmdId = 312;

  CommandHeader header;
  uint32 target;  //!< GLenum
  uint32 attachment;  //!< GLenum
  uint32 textarget;  //!< GLenum
  uint32 texture;  //!< GLuint
  int32 level;  //!< GLint
};

//! Command that corresponds to glFrontFace.
struct FrontFace {
  static const CommandId kCmdId = 313;

  CommandHeader header;
  uint32 mode;  //!< GLenum
};

//! Command that corresponds to glGenBuffers.
struct GenBuffers {
  static const CommandId kCmdId = 314;

  CommandHeader header;
  int32 n;  //!< GLsizei
  uint32 buffers_shm_id;  //!< uint32
  uint32 buffers_shm_offset;  //!< uint32
};

//! Immediate version of command that corresponds to glGenBuffers.
struct GenBuffersImmediate {
  static const CommandId kCmdId = 315;

  CommandHeader header;
  int32 n;  //!< GLsizei
};

//! Command that corresponds to glGenerateMipmap.
struct GenerateMipmap {
  static const CommandId kCmdId = 316;

  CommandHeader header;
  uint32 target;  //!< GLenum
};

//! Command that corresponds to glGenFramebuffers.
struct GenFramebuffers {
  static const CommandId kCmdId = 317;

  CommandHeader header;
  int32 n;  //!< GLsizei
  uint32 framebuffers_shm_id;  //!< uint32
  uint32 framebuffers_shm_offset;  //!< uint32
};

//! Immediate version of command that corresponds to glGenFramebuffers.
struct GenFramebuffersImmediate {
  static const CommandId kCmdId = 318;

  CommandHeader header;
  int32 n;  //!< GLsizei
};

//! Command that corresponds to glGenRenderbuffers.
struct GenRenderbuffers {
  static const CommandId kCmdId = 319;

  CommandHeader header;
  int32 n;  //!< GLsizei
  uint32 renderbuffers_shm_id;  //!< uint32
  uint32 renderbuffers_shm_offset;  //!< uint32
};

//! Immediate version of command that corresponds to glGenRenderbuffers.
struct GenRenderbuffersImmediate {
  static const CommandId kCmdId = 320;

  CommandHeader header;
  int32 n;  //!< GLsizei
};

//! Command that corresponds to glGenTextures.
struct GenTextures {
  static const CommandId kCmdId = 321;

  CommandHeader header;
  int32 n;  //!< GLsizei
  uint32 textures_shm_id;  //!< uint32
  uint32 textures_shm_offset;  //!< uint32
};

//! Immediate version of command that corresponds to glGenTextures.
struct GenTexturesImmediate {
  static const CommandId kCmdId = 322;

  CommandHeader header;
  int32 n;  //!< GLsizei
};

//! Command that corresponds to glGetActiveAttrib.
struct GetActiveAttrib {
  static const CommandId kCmdId = 323;

  struct Result {
    int32 success;
    int32 size;
    uint32 type;
  };

  CommandHeader header;
  uint32 program;  //!< GLuint
  uint32 index;  //!< GLuint
  uint32 name_bucket_id;  //!< uint32
  uint32 result_shm_id;  //!< uint32
  uint32 result_shm_offset;  //!< uint32
};

//! Command that corresponds to glGetActiveUniform.
struct GetActiveUniform {
  static const CommandId kCmdId = 324;

  struct Result {
    int32 success;
    int32 size;
    uint32 type;
  };

  CommandHeader header;
  uint32 program;  //!< GLuint
  uint32 index;  //!< GLuint
  uint32 name_bucket_id;  //!< uint32
  uint32 result_shm_id;  //!< uint32
  uint32 result_shm_offset;  //!< uint32
};

//! Command that corresponds to glGetAttachedShaders.
struct GetAttachedShaders {
  static const CommandId kCmdId = 325;

  typedef SizedResult<GLuint> Result;

  CommandHeader header;
  uint32 program;  //!< GLuint
  uint32 result_shm_id;  //!< uint32
  uint32 result_shm_offset;  //!< uint32
  uint32 result_size;  //!< uint32
};

//! Command that corresponds to glGetAttribLocation.
struct GetAttribLocation {
  static const CommandId kCmdId = 326;

  typedef GLint Result;

  CommandHeader header;
  uint32 program;
  uint32 name_shm_id;
  uint32 name_shm_offset;
  uint32 location_shm_id;
  uint32 location_shm_offset;
  uint32 data_size;
};

//! Immediate version of command that corresponds to glGetAttribLocation.
struct GetAttribLocationImmediate {
  static const CommandId kCmdId = 327;

  typedef GLint Result;

  CommandHeader header;
  uint32 program;
  uint32 location_shm_id;
  uint32 location_shm_offset;
  uint32 data_size;
};

//! Bucket version of command that corresponds to glGetAttribLocation.
struct GetAttribLocationBucket {
  static const CommandId kCmdId = 434;

  typedef GLint Result;

  CommandHeader header;
  uint32 program;
  uint32 name_bucket_id;
  uint32 location_shm_id;
  uint32 location_shm_offset;
};

//! Command that corresponds to glGetBooleanv.
struct GetBooleanv {
  static const CommandId kCmdId = 328;

  typedef SizedResult<GLboolean> Result;

  CommandHeader header;
  uint32 pname;  //!< GLenum
  uint32 params_shm_id;  //!< uint32
  uint32 params_shm_offset;  //!< uint32
};

//! Command that corresponds to glGetBufferParameteriv.
struct GetBufferParameteriv {
  static const CommandId kCmdId = 329;

  typedef SizedResult<GLint> Result;

  CommandHeader header;
  uint32 target;  //!< GLenum
  uint32 pname;  //!< GLenum
  uint32 params_shm_id;  //!< uint32
  uint32 params_shm_offset;  //!< uint32
};

//! Command that corresponds to glGetError.
struct GetError {
  static const CommandId kCmdId = 330;

  typedef GLenum Result;

  CommandHeader header;
  uint32 result_shm_id;  //!< uint32
  uint32 result_shm_offset;  //!< uint32
};

//! Command that corresponds to glGetFloatv.
struct GetFloatv {
  static const CommandId kCmdId = 331;

  typedef SizedResult<GLfloat> Result;

  CommandHeader header;
  uint32 pname;  //!< GLenum
  uint32 params_shm_id;  //!< uint32
  uint32 params_shm_offset;  //!< uint32
};

//! Command that corresponds to glGetFramebufferAttachmentParameteriv.
struct GetFramebufferAttachmentParameteriv {
  static const CommandId kCmdId = 332;

  typedef SizedResult<GLint> Result;

  CommandHeader header;
  uint32 target;  //!< GLenum
  uint32 attachment;  //!< GLenum
  uint32 pname;  //!< GLenum
  uint32 params_shm_id;  //!< uint32
  uint32 params_shm_offset;  //!< uint32
};

//! Command that corresponds to glGetIntegerv.
struct GetIntegerv {
  static const CommandId kCmdId = 333;

  typedef SizedResult<GLint> Result;

  CommandHeader header;
  uint32 pname;  //!< GLenum
  uint32 params_shm_id;  //!< uint32
  uint32 params_shm_offset;  //!< uint32
};

//! Command that corresponds to glGetProgramiv.
struct GetProgramiv {
  static const CommandId kCmdId = 334;

  typedef SizedResult<GLint> Result;

  CommandHeader header;
  uint32 program;  //!< GLuint
  uint32 pname;  //!< GLenum
  uint32 params_shm_id;  //!< uint32
  uint32 params_shm_offset;  //!< uint32
};

//! Command that corresponds to glGetProgramInfoLog.
struct GetProgramInfoLog {
  static const CommandId kCmdId = 335;

  CommandHeader header;
  uint32 program;  //!< GLuint
  uint32 bucket_id;  //!< uint32
};

//! Command that corresponds to glGetRenderbufferParameteriv.
struct GetRenderbufferParameteriv {
  static const CommandId kCmdId = 336;

  typedef SizedResult<GLint> Result;

  CommandHeader header;
  uint32 target;  //!< GLenum
  uint32 pname;  //!< GLenum
  uint32 params_shm_id;  //!< uint32
  uint32 params_shm_offset;  //!< uint32
};

//! Command that corresponds to glGetShaderiv.
struct GetShaderiv {
  static const CommandId kCmdId = 337;

  typedef SizedResult<GLint> Result;

  CommandHeader header;
  uint32 shader;  //!< GLuint
  uint32 pname;  //!< GLenum
  uint32 params_shm_id;  //!< uint32
  uint32 params_shm_offset;  //!< uint32
};

//! Command that corresponds to glGetShaderInfoLog.
struct GetShaderInfoLog {
  static const CommandId kCmdId = 338;

  CommandHeader header;
  uint32 shader;  //!< GLuint
  uint32 bucket_id;  //!< uint32
};

//! Command that corresponds to glGetShaderPrecisionFormat.
struct GetShaderPrecisionFormat {
  static const CommandId kCmdId = 339;

  struct Result {
    int32 success;
    int32 min_range;
    int32 max_range;
    int32 precision;
  };

  CommandHeader header;
  uint32 shadertype;  //!< GLenum
  uint32 precisiontype;  //!< GLenum
  uint32 result_shm_id;  //!< uint32
  uint32 result_shm_offset;  //!< uint32
};

//! Command that corresponds to glGetShaderSource.
struct GetShaderSource {
  static const CommandId kCmdId = 340;

  CommandHeader header;
  uint32 shader;  //!< GLuint
  uint32 bucket_id;  //!< uint32
};

//! Command that corresponds to glGetString.
struct GetString {
  static const CommandId kCmdId = 341;

  CommandHeader header;
  uint32 name;  //!< GLenum
  uint32 bucket_id;  //!< uint32
};

//! Command that corresponds to glGetTexParameterfv.
struct GetTexParameterfv {
  static const CommandId kCmdId = 342;

  typedef SizedResult<GLfloat> Result;

  CommandHeader header;
  uint32 target;  //!< GLenum
  uint32 pname;  //!< GLenum
  uint32 params_shm_id;  //!< uint32
  uint32 params_shm_offset;  //!< uint32
};

//! Command that corresponds to glGetTexParameteriv.
struct GetTexParameteriv {
  static const CommandId kCmdId = 343;

  typedef SizedResult<GLint> Result;

  CommandHeader header;
  uint32 target;  //!< GLenum
  uint32 pname;  //!< GLenum
  uint32 params_shm_id;  //!< uint32
  uint32 params_shm_offset;  //!< uint32
};

//! Command that corresponds to glGetUniformLocation.
struct GetUniformLocation {
  static const CommandId kCmdId = 346;

  typedef GLint Result;

  CommandHeader header;
  uint32 program;
  uint32 name_shm_id;
  uint32 name_shm_offset;
  uint32 location_shm_id;
  uint32 location_shm_offset;
  uint32 data_size;
};

//! Immediate version of command that corresponds to glGetUniformLocation.
struct GetUniformLocationImmediate {
  static const CommandId kCmdId = 347;

  typedef GLint Result;

  CommandHeader header;
  uint32 program;
  uint32 location_shm_id;
  uint32 location_shm_offset;
  uint32 data_size;
};

//! Bucket version of command that corresponds to glGetUniformLocation.
struct GetUniformLocationBucket {
  static const CommandId kCmdId = 433;

  typedef GLint Result;

  CommandHeader header;
  uint32 program;
  uint32 name_bucket_id;
  uint32 location_shm_id;
  uint32 location_shm_offset;
};


//! Command that corresponds to glGetUniformfv.
struct GetUniformfv {
  static const CommandId kCmdId = 344;

  typedef SizedResult<GLfloat> Result;

  CommandHeader header;
  uint32 program;  //!< GLuint
  int32 location;  //!< GLint
  uint32 params_shm_id;  //!< uint32
  uint32 params_shm_offset;  //!< uint32
};

//! Command that corresponds to glGetUniformiv.
struct GetUniformiv {
  static const CommandId kCmdId = 345;

  typedef SizedResult<GLint> Result;

  CommandHeader header;
  uint32 program;  //!< GLuint
  int32 location;  //!< GLint
  uint32 params_shm_id;  //!< uint32
  uint32 params_shm_offset;  //!< uint32
};

//! Command that corresponds to glGetVertexAttribfv.
struct GetVertexAttribfv {
  static const CommandId kCmdId = 348;

  typedef SizedResult<GLfloat> Result;

  CommandHeader header;
  uint32 index;  //!< GLuint
  uint32 pname;  //!< GLenum
  uint32 params_shm_id;  //!< uint32
  uint32 params_shm_offset;  //!< uint32
};

//! Command that corresponds to glGetVertexAttribiv.
struct GetVertexAttribiv {
  static const CommandId kCmdId = 349;

  typedef SizedResult<GLint> Result;

  CommandHeader header;
  uint32 index;  //!< GLuint
  uint32 pname;  //!< GLenum
  uint32 params_shm_id;  //!< uint32
  uint32 params_shm_offset;  //!< uint32
};

//! Command that corresponds to glGetVertexAttribPointerv.
struct GetVertexAttribPointerv {
  static const CommandId kCmdId = 350;

  typedef SizedResult<GLuint> Result;

  CommandHeader header;
  uint32 index;  //!< GLuint
  uint32 pname;  //!< GLenum
  uint32 pointer_shm_id;  //!< uint32
  uint32 pointer_shm_offset;  //!< uint32
};

//! Command that corresponds to glHint.
struct Hint {
  static const CommandId kCmdId = 351;

  CommandHeader header;
  uint32 target;  //!< GLenum
  uint32 mode;  //!< GLenum
};

//! Command that corresponds to glIsBuffer.
struct IsBuffer {
  static const CommandId kCmdId = 352;

  typedef uint32 Result;

  CommandHeader header;
  uint32 buffer;  //!< GLuint
  uint32 result_shm_id;  //!< uint32
  uint32 result_shm_offset;  //!< uint32
};

//! Command that corresponds to glIsEnabled.
struct IsEnabled {
  static const CommandId kCmdId = 353;

  typedef uint32 Result;

  CommandHeader header;
  uint32 cap;  //!< GLenum
  uint32 result_shm_id;  //!< uint32
  uint32 result_shm_offset;  //!< uint32
};

//! Command that corresponds to glIsFramebuffer.
struct IsFramebuffer {
  static const CommandId kCmdId = 354;

  typedef uint32 Result;

  CommandHeader header;
  uint32 framebuffer;  //!< GLuint
  uint32 result_shm_id;  //!< uint32
  uint32 result_shm_offset;  //!< uint32
};

//! Command that corresponds to glIsProgram.
struct IsProgram {
  static const CommandId kCmdId = 355;

  typedef uint32 Result;

  CommandHeader header;
  uint32 program;  //!< GLuint
  uint32 result_shm_id;  //!< uint32
  uint32 result_shm_offset;  //!< uint32
};

//! Command that corresponds to glIsRenderbuffer.
struct IsRenderbuffer {
  static const CommandId kCmdId = 356;

  typedef uint32 Result;

  CommandHeader header;
  uint32 renderbuffer;  //!< GLuint
  uint32 result_shm_id;  //!< uint32
  uint32 result_shm_offset;  //!< uint32
};

//! Command that corresponds to glIsShader.
struct IsShader {
  static const CommandId kCmdId = 357;

  typedef uint32 Result;

  CommandHeader header;
  uint32 shader;  //!< GLuint
  uint32 result_shm_id;  //!< uint32
  uint32 result_shm_offset;  //!< uint32
};

//! Command that corresponds to glIsTexture.
struct IsTexture {
  static const CommandId kCmdId = 358;

  typedef uint32 Result;

  CommandHeader header;
  uint32 texture;  //!< GLuint
  uint32 result_shm_id;  //!< uint32
  uint32 result_shm_offset;  //!< uint32
};

//! Command that corresponds to glLineWidth.
struct LineWidth {
  static const CommandId kCmdId = 359;

  CommandHeader header;
  float width;  //!< GLfloat
};

//! Command that corresponds to glLinkProgram.
struct LinkProgram {
  static const CommandId kCmdId = 360;

  CommandHeader header;
  uint32 program;  //!< GLuint
};

//! Command that corresponds to glPixelStorei.
struct PixelStorei {
  static const CommandId kCmdId = 361;

  CommandHeader header;
  uint32 pname;  //!< GLenum
  int32 param;  //!< GLint
};

//! Command that corresponds to glPolygonOffset.
struct PolygonOffset {
  static const CommandId kCmdId = 362;

  CommandHeader header;
  float factor;  //!< GLfloat
  float units;  //!< GLfloat
};

//! Command that corresponds to glReadPixels.
//! ReadPixels has the result separated from the pixel buffer so that
//! it is easier to specify the result going to some specific place
//! that exactly fits the rectangle of pixels.
struct ReadPixels {
  static const CommandId kCmdId = 363;

  typedef uint32 Result;

  CommandHeader header;
  int32 x;  //!< GLint
  int32 y;  //!< GLint
  int32 width;  //!< GLsizei
  int32 height;  //!< GLsizei
  uint32 format;  //!< GLenum
  uint32 type;  //!< GLenum
  uint32 pixels_shm_id;  //!< uint32
  uint32 pixels_shm_offset;  //!< uint32
  uint32 result_shm_id;  //!< uint32
  uint32 result_shm_offset;  //!< uint32
};

//! Command that corresponds to glReleaseShaderCompiler.
struct ReleaseShaderCompiler {
  static const CommandId kCmdId = 437;

  CommandHeader header;
};

//! Command that corresponds to glRenderbufferStorage.
struct RenderbufferStorage {
  static const CommandId kCmdId = 364;

  CommandHeader header;
  uint32 target;  //!< GLenum
  uint32 internalformat;  //!< GLenum
  int32 width;  //!< GLsizei
  int32 height;  //!< GLsizei
};

//! Command that corresponds to glSampleCoverage.
struct SampleCoverage {
  static const CommandId kCmdId = 365;

  CommandHeader header;
  float value;  //!< GLclampf
  uint32 invert;  //!< GLboolean
};

//! Command that corresponds to glScissor.
struct Scissor {
  static const CommandId kCmdId = 366;

  CommandHeader header;
  int32 x;  //!< GLint
  int32 y;  //!< GLint
  int32 width;  //!< GLsizei
  int32 height;  //!< GLsizei
};

//! Command that corresponds to glShaderBinary.
struct ShaderBinary {
  static const CommandId kCmdId = 436;

  CommandHeader header;
  int32 n;  //!< GLsizei
  uint32 shaders_shm_id;  //!< uint32
  uint32 shaders_shm_offset;  //!< uint32
  uint32 binaryformat;  //!< GLenum
  uint32 binary_shm_id;  //!< uint32
  uint32 binary_shm_offset;  //!< uint32
  int32 length;  //!< GLsizei
};

//! Command that corresponds to glShaderSource.
struct ShaderSource {
  static const CommandId kCmdId = 367;

  CommandHeader header;
  uint32 shader;  //!< GLuint
  uint32 data_shm_id;  //!< uint32
  uint32 data_shm_offset;  //!< uint32
  uint32 data_size;  //!< uint32
};

//! Immediate version of command that corresponds to glShaderSource.
struct ShaderSourceImmediate {
  static const CommandId kCmdId = 368;

  CommandHeader header;
  uint32 shader;  //!< GLuint
  uint32 data_size;  //!< uint32
};

//! Bucket version of command that corresponds to glShaderSource.
struct ShaderSourceBucket {
  static const CommandId kCmdId = 435;

  CommandHeader header;
  uint32 shader;  //!< GLuint
  uint32 data_bucket_id;  //!< uint32
};

//! Command that corresponds to glStencilFunc.
struct StencilFunc {
  static const CommandId kCmdId = 369;

  CommandHeader header;
  uint32 func;  //!< GLenum
  int32 ref;  //!< GLint
  uint32 mask;  //!< GLuint
};

//! Command that corresponds to glStencilFuncSeparate.
struct StencilFuncSeparate {
  static const CommandId kCmdId = 370;

  CommandHeader header;
  uint32 face;  //!< GLenum
  uint32 func;  //!< GLenum
  int32 ref;  //!< GLint
  uint32 mask;  //!< GLuint
};

//! Command that corresponds to glStencilMask.
struct StencilMask {
  static const CommandId kCmdId = 371;

  CommandHeader header;
  uint32 mask;  //!< GLuint
};

//! Command that corresponds to glStencilMaskSeparate.
struct StencilMaskSeparate {
  static const CommandId kCmdId = 372;

  CommandHeader header;
  uint32 face;  //!< GLenum
  uint32 mask;  //!< GLuint
};

//! Command that corresponds to glStencilOp.
struct StencilOp {
  static const CommandId kCmdId = 373;

  CommandHeader header;
  uint32 fail;  //!< GLenum
  uint32 zfail;  //!< GLenum
  uint32 zpass;  //!< GLenum
};

//! Command that corresponds to glStencilOpSeparate.
struct StencilOpSeparate {
  static const CommandId kCmdId = 374;

  CommandHeader header;
  uint32 face;  //!< GLenum
  uint32 fail;  //!< GLenum
  uint32 zfail;  //!< GLenum
  uint32 zpass;  //!< GLenum
};

//! Command that corresponds to glTexImage2D.
struct TexImage2D {
  static const CommandId kCmdId = 375;

  CommandHeader header;
  uint32 target;  //!< GLenum
  int32 level;  //!< GLint
  int32 internalformat;  //!< GLint
  int32 width;  //!< GLsizei
  int32 height;  //!< GLsizei
  int32 border;  //!< GLint
  uint32 format;  //!< GLenum
  uint32 type;  //!< GLenum
  uint32 pixels_shm_id;  //!< uint32
  uint32 pixels_shm_offset;  //!< uint32
};

//! Immediate version of command that corresponds to glTexImage2D.
struct TexImage2DImmediate {
  static const CommandId kCmdId = 376;

  CommandHeader header;
  uint32 target;  //!< GLenum
  int32 level;  //!< GLint
  int32 internalformat;  //!< GLint
  int32 width;  //!< GLsizei
  int32 height;  //!< GLsizei
  int32 border;  //!< GLint
  uint32 format;  //!< GLenum
  uint32 type;  //!< GLenum
};

//! Command that corresponds to glTexParameterf.
struct TexParameterf {
  static const CommandId kCmdId = 377;

  CommandHeader header;
  uint32 target;  //!< GLenum
  uint32 pname;  //!< GLenum
  float param;  //!< GLfloat
};

//! Command that corresponds to glTexParameterfv.
struct TexParameterfv {
  static const CommandId kCmdId = 378;

  CommandHeader header;
  uint32 target;  //!< GLenum
  uint32 pname;  //!< GLenum
  uint32 params_shm_id;  //!< uint32
  uint32 params_shm_offset;  //!< uint32
};

//! Immediate version of command that corresponds to glTexParameterfv.
struct TexParameterfvImmediate {
  static const CommandId kCmdId = 379;

  CommandHeader header;
  uint32 target;  //!< GLenum
  uint32 pname;  //!< GLenum
};

//! Command that corresponds to glTexParameteri.
struct TexParameteri {
  static const CommandId kCmdId = 380;

  CommandHeader header;
  uint32 target;  //!< GLenum
  uint32 pname;  //!< GLenum
  int32 param;  //!< GLint
};

//! Command that corresponds to glTexParameteriv.
struct TexParameteriv {
  static const CommandId kCmdId = 381;

  CommandHeader header;
  uint32 target;  //!< GLenum
  uint32 pname;  //!< GLenum
  uint32 params_shm_id;  //!< uint32
  uint32 params_shm_offset;  //!< uint32
};

//! Immediate version of command that corresponds to glTexParameteriv.
struct TexParameterivImmediate {
  static const CommandId kCmdId = 382;

  CommandHeader header;
  uint32 target;  //!< GLenum
  uint32 pname;  //!< GLenum
};

//! Command that corresponds to glTexSubImage2D.
struct TexSubImage2D {
  static const CommandId kCmdId = 383;

  CommandHeader header;
  uint32 target;  //!< GLenum
  int32 level;  //!< GLint
  int32 xoffset;  //!< GLint
  int32 yoffset;  //!< GLint
  int32 width;  //!< GLsizei
  int32 height;  //!< GLsizei
  uint32 format;  //!< GLenum
  uint32 type;  //!< GLenum
  uint32 pixels_shm_id;  //!< uint32
  uint32 pixels_shm_offset;  //!< uint32
};

//! Immediate version of command that corresponds to glTexSubImage2D.
struct TexSubImage2DImmediate {
  static const CommandId kCmdId = 384;

  CommandHeader header;
  uint32 target;  //!< GLenum
  int32 level;  //!< GLint
  int32 xoffset;  //!< GLint
  int32 yoffset;  //!< GLint
  int32 width;  //!< GLsizei
  int32 height;  //!< GLsizei
  uint32 format;  //!< GLenum
  uint32 type;  //!< GLenum
};

//! Command that corresponds to glUniform1f.
struct Uniform1f {
  static const CommandId kCmdId = 385;

  CommandHeader header;
  int32 location;  //!< GLint
  float x;  //!< GLfloat
};

//! Command that corresponds to glUniform1fv.
struct Uniform1fv {
  static const CommandId kCmdId = 386;

  CommandHeader header;
  int32 location;  //!< GLint
  int32 count;  //!< GLsizei
  uint32 v_shm_id;  //!< uint32
  uint32 v_shm_offset;  //!< uint32
};

//! Immediate version of command that corresponds to glUniform1fv.
struct Uniform1fvImmediate {
  static const CommandId kCmdId = 387;

  CommandHeader header;
  int32 location;  //!< GLint
  int32 count;  //!< GLsizei
};

//! Command that corresponds to glUniform1i.
struct Uniform1i {
  static const CommandId kCmdId = 388;

  CommandHeader header;
  int32 location;  //!< GLint
  int32 x;  //!< GLint
};

//! Command that corresponds to glUniform1iv.
struct Uniform1iv {
  static const CommandId kCmdId = 389;

  CommandHeader header;
  int32 location;  //!< GLint
  int32 count;  //!< GLsizei
  uint32 v_shm_id;  //!< uint32
  uint32 v_shm_offset;  //!< uint32
};

//! Immediate version of command that corresponds to glUniform1iv.
struct Uniform1ivImmediate {
  static const CommandId kCmdId = 390;

  CommandHeader header;
  int32 location;  //!< GLint
  int32 count;  //!< GLsizei
};

//! Command that corresponds to glUniform2f.
struct Uniform2f {
  static const CommandId kCmdId = 391;

  CommandHeader header;
  int32 location;  //!< GLint
  float x;  //!< GLfloat
  float y;  //!< GLfloat
};

//! Command that corresponds to glUniform2fv.
struct Uniform2fv {
  static const CommandId kCmdId = 392;

  CommandHeader header;
  int32 location;  //!< GLint
  int32 count;  //!< GLsizei
  uint32 v_shm_id;  //!< uint32
  uint32 v_shm_offset;  //!< uint32
};

//! Immediate version of command that corresponds to glUniform2fv.
struct Uniform2fvImmediate {
  static const CommandId kCmdId = 393;

  CommandHeader header;
  int32 location;  //!< GLint
  int32 count;  //!< GLsizei
};

//! Command that corresponds to glUniform2i.
struct Uniform2i {
  static const CommandId kCmdId = 394;

  CommandHeader header;
  int32 location;  //!< GLint
  int32 x;  //!< GLint
  int32 y;  //!< GLint
};

//! Command that corresponds to glUniform2iv.
struct Uniform2iv {
  static const CommandId kCmdId = 395;

  CommandHeader header;
  int32 location;  //!< GLint
  int32 count;  //!< GLsizei
  uint32 v_shm_id;  //!< uint32
  uint32 v_shm_offset;  //!< uint32
};

//! Immediate version of command that corresponds to glUniform2iv.
struct Uniform2ivImmediate {
  static const CommandId kCmdId = 396;

  CommandHeader header;
  int32 location;  //!< GLint
  int32 count;  //!< GLsizei
};

//! Command that corresponds to glUniform3f.
struct Uniform3f {
  static const CommandId kCmdId = 397;

  CommandHeader header;
  int32 location;  //!< GLint
  float x;  //!< GLfloat
  float y;  //!< GLfloat
  float z;  //!< GLfloat
};

//! Command that corresponds to glUniform3fv.
struct Uniform3fv {
  static const CommandId kCmdId = 398;

  CommandHeader header;
  int32 location;  //!< GLint
  int32 count;  //!< GLsizei
  uint32 v_shm_id;  //!< uint32
  uint32 v_shm_offset;  //!< uint32
};

//! Immediate version of command that corresponds to glUniform3fv.
struct Uniform3fvImmediate {
  static const CommandId kCmdId = 399;

  CommandHeader header;
  int32 location;  //!< GLint
  int32 count;  //!< GLsizei
};

//! Command that corresponds to glUniform3i.
struct Uniform3i {
  static const CommandId kCmdId = 400;

  CommandHeader header;
  int32 location;  //!< GLint
  int32 x;  //!< GLint
  int32 y;  //!< GLint
  int32 z;  //!< GLint
};

//! Command that corresponds to glUniform3iv.
struct Uniform3iv {
  static const CommandId kCmdId = 401;

  CommandHeader header;
  int32 location;  //!< GLint
  int32 count;  //!< GLsizei
  uint32 v_shm_id;  //!< uint32
  uint32 v_shm_offset;  //!< uint32
};

//! Immediate version of command that corresponds to glUniform3iv.
struct Uniform3ivImmediate {
  static const CommandId kCmdId = 402;

  CommandHeader header;
  int32 location;  //!< GLint
  int32 count;  //!< GLsizei
};

//! Command that corresponds to glUniform4f.
struct Uniform4f {
  static const CommandId kCmdId = 403;

  CommandHeader header;
  int32 location;  //!< GLint
  float x;  //!< GLfloat
  float y;  //!< GLfloat
  float z;  //!< GLfloat
  float w;  //!< GLfloat
};

//! Command that corresponds to glUniform4fv.
struct Uniform4fv {
  static const CommandId kCmdId = 404;

  CommandHeader header;
  int32 location;  //!< GLint
  int32 count;  //!< GLsizei
  uint32 v_shm_id;  //!< uint32
  uint32 v_shm_offset;  //!< uint32
};

//! Immediate version of command that corresponds to glUniform4fv.
struct Uniform4fvImmediate {
  static const CommandId kCmdId = 405;

  CommandHeader header;
  int32 location;  //!< GLint
  int32 count;  //!< GLsizei
};

//! Command that corresponds to glUniform4i.
struct Uniform4i {
  static const CommandId kCmdId = 406;

  CommandHeader header;
  int32 location;  //!< GLint
  int32 x;  //!< GLint
  int32 y;  //!< GLint
  int32 z;  //!< GLint
  int32 w;  //!< GLint
};

//! Command that corresponds to glUniform4iv.
struct Uniform4iv {
  static const CommandId kCmdId = 407;

  CommandHeader header;
  int32 location;  //!< GLint
  int32 count;  //!< GLsizei
  uint32 v_shm_id;  //!< uint32
  uint32 v_shm_offset;  //!< uint32
};

//! Immediate version of command that corresponds to glUniform4iv.
struct Uniform4ivImmediate {
  static const CommandId kCmdId = 408;

  CommandHeader header;
  int32 location;  //!< GLint
  int32 count;  //!< GLsizei
};

//! Command that corresponds to glUniformMatrix2fv.
struct UniformMatrix2fv {
  static const CommandId kCmdId = 409;

  CommandHeader header;
  int32 location;  //!< GLint
  int32 count;  //!< GLsizei
  uint32 transpose;  //!< GLboolean
  uint32 value_shm_id;  //!< uint32
  uint32 value_shm_offset;  //!< uint32
};

//! Immediate version of command that corresponds to glUniformMatrix2fv.
struct UniformMatrix2fvImmediate {
  static const CommandId kCmdId = 410;

  CommandHeader header;
  int32 location;  //!< GLint
  int32 count;  //!< GLsizei
  uint32 transpose;  //!< GLboolean
};

//! Command that corresponds to glUniformMatrix3fv.
struct UniformMatrix3fv {
  static const CommandId kCmdId = 411;

  CommandHeader header;
  int32 location;  //!< GLint
  int32 count;  //!< GLsizei
  uint32 transpose;  //!< GLboolean
  uint32 value_shm_id;  //!< uint32
  uint32 value_shm_offset;  //!< uint32
};

//! Immediate version of command that corresponds to glUniformMatrix3fv.
struct UniformMatrix3fvImmediate {
  static const CommandId kCmdId = 412;

  CommandHeader header;
  int32 location;  //!< GLint
  int32 count;  //!< GLsizei
  uint32 transpose;  //!< GLboolean
};

//! Command that corresponds to glUniformMatrix4fv.
struct UniformMatrix4fv {
  static const CommandId kCmdId = 413;

  CommandHeader header;
  int32 location;  //!< GLint
  int32 count;  //!< GLsizei
  uint32 transpose;  //!< GLboolean
  uint32 value_shm_id;  //!< uint32
  uint32 value_shm_offset;  //!< uint32
};

//! Immediate version of command that corresponds to glUniformMatrix4fv.
struct UniformMatrix4fvImmediate {
  static const CommandId kCmdId = 414;

  CommandHeader header;
  int32 location;  //!< GLint
  int32 count;  //!< GLsizei
  uint32 transpose;  //!< GLboolean
};

//! Command that corresponds to glUseProgram.
struct UseProgram {
  static const CommandId kCmdId = 415;

  CommandHeader header;
  uint32 program;  //!< GLuint
};

//! Command that corresponds to glValidateProgram.
struct ValidateProgram {
  static const CommandId kCmdId = 416;

  CommandHeader header;
  uint32 program;  //!< GLuint
};

//! Command that corresponds to glVertexAttrib1f.
struct VertexAttrib1f {
  static const CommandId kCmdId = 417;

  CommandHeader header;
  uint32 indx;  //!< GLuint
  float x;  //!< GLfloat
};

//! Command that corresponds to glVertexAttrib1fv.
struct VertexAttrib1fv {
  static const CommandId kCmdId = 418;

  CommandHeader header;
  uint32 indx;  //!< GLuint
  uint32 values_shm_id;  //!< uint32
  uint32 values_shm_offset;  //!< uint32
};

//! Immediate version of command that corresponds to glVertexAttrib1fv.
struct VertexAttrib1fvImmediate {
  static const CommandId kCmdId = 419;

  CommandHeader header;
  uint32 indx;  //!< GLuint
};

//! Command that corresponds to glVertexAttrib2f.
struct VertexAttrib2f {
  static const CommandId kCmdId = 420;

  CommandHeader header;
  uint32 indx;  //!< GLuint
  float x;  //!< GLfloat
  float y;  //!< GLfloat
};

//! Command that corresponds to glVertexAttrib2fv.
struct VertexAttrib2fv {
  static const CommandId kCmdId = 421;

  CommandHeader header;
  uint32 indx;  //!< GLuint
  uint32 values_shm_id;  //!< uint32
  uint32 values_shm_offset;  //!< uint32
};

//! Immediate version of command that corresponds to glVertexAttrib2fv.
struct VertexAttrib2fvImmediate {
  static const CommandId kCmdId = 422;

  CommandHeader header;
  uint32 indx;  //!< GLuint
};

//! Command that corresponds to glVertexAttrib3f.
struct VertexAttrib3f {
  static const CommandId kCmdId = 423;

  CommandHeader header;
  uint32 indx;  //!< GLuint
  float x;  //!< GLfloat
  float y;  //!< GLfloat
  float z;  //!< GLfloat
};

//! Command that corresponds to glVertexAttrib3fv.
struct VertexAttrib3fv {
  static const CommandId kCmdId = 424;

  CommandHeader header;
  uint32 indx;  //!< GLuint
  uint32 values_shm_id;  //!< uint32
  uint32 values_shm_offset;  //!< uint32
};

//! Immediate version of command that corresponds to glVertexAttrib3fv.
struct VertexAttrib3fvImmediate {
  static const CommandId kCmdId = 425;

  CommandHeader header;
  uint32 indx;  //!< GLuint
};

//! Command that corresponds to glVertexAttrib4f.
struct VertexAttrib4f {
  static const CommandId kCmdId = 426;

  CommandHeader header;
  uint32 indx;  //!< GLuint
  float x;  //!< GLfloat
  float y;  //!< GLfloat
  float z;  //!< GLfloat
  float w;  //!< GLfloat
};

//! Command that corresponds to glVertexAttrib4fv.
struct VertexAttrib4fv {
  static const CommandId kCmdId = 427;

  CommandHeader header;
  uint32 indx;  //!< GLuint
  uint32 values_shm_id;  //!< uint32
  uint32 values_shm_offset;  //!< uint32
};

//! Immediate version of command that corresponds to glVertexAttrib4fv.
struct VertexAttrib4fvImmediate {
  static const CommandId kCmdId = 428;

  CommandHeader header;
  uint32 indx;  //!< GLuint
};

//! Command that corresponds to glVertexAttribPointer.
struct VertexAttribPointer {
  static const CommandId kCmdId = 429;

  CommandHeader header;
  uint32 indx;  //!< GLuint
  int32 size;  //!< GLint
  uint32 type;  //!< GLenum
  uint32 normalized;  //!< GLboolean
  int32 stride;  //!< GLsizei
  uint32 offset;  //!< GLuint
};

//! Command that corresponds to glViewport.
struct Viewport {
  static const CommandId kCmdId = 430;

  CommandHeader header;
  int32 x;  //!< GLint
  int32 y;  //!< GLint
  int32 width;  //!< GLsizei
  int32 height;  //!< GLsizei
};

//! Command that corresponds to SwapBuffers.
struct SwapBuffers {
  static const CommandId kCmdId = 431;

  CommandHeader header;
};

//! Command that corresponds to GetMaxValueInBuffer.
struct GetMaxValueInBuffer {
  static const CommandId kCmdId = 436;

  typedef GLuint Result;

  CommandHeader header;
  uint32 buffer_id;  //!< GLuint
  int32 count;  //!< GLsizei
  uint32 type;  //!< GLenum
  uint32 offset;  //!< GLuint
  uint32 result_shm_id;  //!< uint32
  uint32 result_shm_offset;  //!< uint32
};

//! Command that generates shared ids for contexts that share resources.
struct GenSharedIds {
  static const CommandId kCmdId = 439;

  CommandHeader header;
  uint32 namespace_id;  //!< GLuint
  uint32 id_offset;  //!< GLuint
  int32 n;  //!< GLsizei
  uint32 ids_shm_id;  //!< uint32
  uint32 ids_shm_offset;  //!< uint32
};

//! Command that deletes shared ids.
struct DeleteSharedIds {
  static const CommandId kCmdId = 440;

  CommandHeader header;
  uint32 namespace_id;  //!< GLuint
  int32 n;  //!< GLsizei
  uint32 ids_shm_id;  //!< uint32
  uint32 ids_shm_offset;  //!< uint32
};

//! Command that registers shared ids. It is an error to attempt
//! to register an id that is already registered.
struct RegisterSharedIds {
  static const CommandId kCmdId = 441;

  CommandHeader header;
  uint32 namespace_id;  //!< GLuint
  int32 n;  //!< GLsizei
  uint32 ids_shm_id;  //!< uint32
  uint32 ids_shm_offset;  //!< uint32
};

//! Command that enables features. The bucket should contain the feature string.
struct CommandBufferEnable {
  static const CommandId kCmdId = 442;

  typedef GLint Result;

  CommandHeader header;
  uint32 bucket_id;  //!< GLuint
  uint32 result_shm_id;  //!< uint32
  uint32 result_shm_offset;  //!< uint32
};