diff options
author | gman@google.com <gman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-16 22:43:18 +0000 |
---|---|---|
committer | gman@google.com <gman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-16 22:43:18 +0000 |
commit | f9be34d622561d5599603b41d1c43d595e503426 (patch) | |
tree | fda8c9434f7f94395edb78eb584aaa3715773977 /o3d | |
parent | 8c5f59092a8b4c9d16773e06df405890140c63cd (diff) | |
download | chromium_src-f9be34d622561d5599603b41d1c43d595e503426.zip chromium_src-f9be34d622561d5599603b41d1c43d595e503426.tar.gz chromium_src-f9be34d622561d5599603b41d1c43d595e503426.tar.bz2 |
GLES2.0 command buffers version 0.00001
There's a HUGE amount of TODO here that I will do in
following CLs but I wanted to get this in so people
can comment and see progress. Assuming there are no
bugs (cough) it should be possible to get a GLES2.0
program up with this assuming setup is implemented.
A few things:
*) Many files are auto geneated. They are generally
made as _autogen.h files and inlcuded into .cc files.
That way, as .h files they can be added to gyp but
not get compiled and it leaves the parts that
are better hand edtied outside of the auto generated
files.
*) there is a special switch to generate the
id tests. That's because the IDs MUST NOT CHANGE
and so therefore should not be auto generated.
*) I'm deliberately choosing to checkin the auto
generated files. I think it's important that changes
be explicitly reviewed instead of just reviewing
the generator. So, the generator is run manaually
for now.
*) I will end up most likely copying and pasting
the relavent lines from GLES2/gl2.h direclty
into the builder. The problem with reading it
directly is that changing the gl2.h file changes
the commands but commands are NOT ALLOWED TO CHANGE
once we ship and putting the lines directly in
the builder will make this more explicit.
TODOs:
*) Wrap glGetError with our own error bits so
some of our commands can set those bits.
*) Auto generate unit_tests. I'll work on this
once I get a demo working because I want to be
able to let others use this ASAP.
*) I want to change a few low level things
related to immediate commands. One of the problems
with this system is the commands are generated
from gl2.h instead of designed like they were
with O3D. In O3D, each command that passes
data has an explicit size. In GL, some sizes
are implicit like glTexImage2D. For an
Immediate cmd, a command where the data
follows the cmd, the cmd needs to know the size
of the data.
This is a problem because that size needs to be
known in 3 places. (1) where space is allocated
in the command buffer to write the command (2)
when the header to the command is filled out and
(3) When the address of the next command is
computed when not using the GLES2CmdHelper.
Currently it is computed in all 3 places instead
of just once. I need to think about how to refactor
so that that info is only computed once.
It might mean one more level of indirection. So,
for example, you look at
BindAttribLocationImmediate you'll see it
takes a const char* and inserts the name into
the command buffer for you. It might need to be
that that structure expects you to put it in
yourself and some higher-level thing like the
GLES2CmdHelper deals with putting the data in?
I'm not sure. I like the idea that calling
Cmd::Init or Cmd::Set makes the command perfect,
no outside stuff needed.
Thoughts are welcome.
*) We need to change the CMD header to either
a 32bit command followed by a 32bit size OR
a 10-11bit command followed by a 21-22bit size.
That would allow for say 256 common commands and
768 specific commands. Enough? The
issue is that the Immediate commands are
FAR MORE EASY TO USE because no synchronization
is required. So for things like
BindAttribLocation it's much much easier to use
the Immediate version. The problem is, with an
8bit size, the largest amount of data you can
pass is 1024 bytes. That's not large enough
for a shader and certainly not enough for a
buffer or texture and it would be nice
to be able to to use those commands as often
as possible in NaCl apps.
*) I need to track glPixelStore
*) Need to fix several commands that need
a size.
*) Need a ton of work on validation. We
need to make sure no enums not specified
by GLES2.0 can make it through to the
underlying GL. Also many places need
to check that the size of data about to be
accessed is valid for the given shared
memory or immediate data.
*) I'm planning to implement a named bucket system.
The specific issue is that some commands take
an arbitarily large amount of data. glBufferData,
glTexImage2D, glShaderSource, glGetShaderSource,
etc.
Right now if your command buffer or shared memory
segment is too small to transfer the data you'd
have to allocate a bigger one. Rather than
force that solution on you I want to implement
versions of those commands that use named buckets.
The bucket commands would let you Set a bucket
or append to a bucket and then you could reference
those buckets with the commands above. Example
int bucket_id = 123
cmdSetBucket(bucket_id, "first part of shader text");
cmdAppendBucket(bucket_id, "next part of shader text");
cmdShaderSourceByBucket(shaderId, bucket_id);
These bucket management commands would be added to the
common command buffer stuff so they could be used with
any command buffer. This is mostly useful for GLES2
emuliation and exposing command buffers stuff to
JavaScript like WeBGL. If you are writing a NaCl app
and talking direclty to the command buffers then you
can allocate your own shader memory the size of the
largest piece you need, or use other methods but
for example in the case of WebGL or GLES2 emu there
are no limits.
buffers
*) Should we add some kind of error reporter to
the service that the client can get
a handle on so that you can easily check for
errors? I suppose calling glGetError once a
frame is good enough? The advantage of a
service side is that it could more easily
tell you about "mal-formed command" and other
parse / validation errors that don't fit
glGetError.
*) There are several unimplemented commands.
Questions:
*) Should I separate calling GL from decoding the
same way O3D decodes, then calls GAPI? At this
point and it would slow down the decoder so I
don't really see a point but I can put
it on a low-prioirty todo if we want it later.
*) Should we support client side indices with
glDrawElements. They would have to be copied
to the server and verified every single call to
glDrawElements so it wouldn't be useful except
for porting code. The argument against is that
glVertexAttribPointer can also take client side
data and yet I don't think that data is used
at the call and therefore can not be validated
so if we can't do one maybe there's no point in
doing the other.
Review URL: http://codereview.chromium.org/394013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32109 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d')
25 files changed, 21237 insertions, 4 deletions
diff --git a/o3d/gpu/command_buffer/build_gles2_cmd_buffer.py b/o3d/gpu/command_buffer/build_gles2_cmd_buffer.py new file mode 100644 index 0000000..e62195f --- /dev/null +++ b/o3d/gpu/command_buffer/build_gles2_cmd_buffer.py @@ -0,0 +1,2212 @@ +#!/usr/bin/python +# +# Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +"""code generator for GL command buffers.""" + +import os +import os.path +import sys +import re +from optparse import OptionParser + +_SIZE_OF_UINT32 = 4 +_SIZE_OF_COMMAND_HEADER = 4 +_FIRST_SPECIFIC_COMMAND_ID = 1024 + +_LICENSE = "\n".join([ + "// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.", + "// Use of this source code is governed by a BSD-style license that can be", + "// found in the LICENSE file.", + "", +]) + +# This table specifies types and other special data for the commands that +# will be generated. +# +# type: defines which handler will be used to generate code. +# DecoderFunc: defines which function to call in the decoder to execute the +# corresponding GL command. If not specified the GL command will +# be called directly. +# cmd_args: The arguments to use for the command. This overrides generating +# them based on the GL function arguments. +# immediate: Whether or not to generate an immediate command for the GL +# function. The default is if there is exactly 1 pointer argument +# in the GL function an immediate command is generated. +# needs_size: If true a data_size field is added to the command. +# data_type: The type of data the command uses. For PUTn or PUT types. +# count: The number of units per element. For PUTn or PUT types. + +_FUNCTION_INFO = { + 'BindAttribLocation': {'type': 'GLchar'}, + 'BindBuffer': {'DecoderFunc': 'DoBindBuffer'}, + 'BufferData': {'type': 'Data'}, + 'BufferSubData': {'type': 'Data'}, + 'ClearDepthf': {'DecoderFunc': 'glClearDepth'}, + 'CompressedTexImage2D': {'type': 'Data'}, + 'CompressedTexSubImage2D': {'type': 'Data'}, + 'CreateProgram': {'type': 'Create'}, + 'CreateShader': {'type': 'Create'}, + 'DeleteBuffers': {'type': 'DELn'}, + 'DeleteFramebuffers': {'type': 'DELn'}, + 'DeleteProgram': {'DecoderFunc': 'DoDeleteProgram'}, + 'DeleteRenderbuffers': {'type': 'DELn'}, + 'DeleteShader': {'DecoderFunc': 'DoDeleteShader'}, + 'DeleteTextures': {'type': 'DELn'}, + 'DepthRangef': {'DecoderFunc': 'glDepthRange'}, + 'DrawElements': { + 'type': 'Manual', + 'cmd_args': 'GLenum mode, GLsizei count, GLenum type, GLuint index_offset', + }, + 'GenBuffers': {'type': 'GENn'}, + 'GenFramebuffers': {'type': 'GENn'}, + 'GenRenderbuffers': {'type': 'GENn'}, + 'GenTextures': {'type': 'GENn'}, + 'GetActiveAttrib': {'type': 'Custom'}, + 'GetActiveUniform': {'type': 'Custom'}, + 'GetAttachedShaders': {'type': 'Custom'}, + 'GetAttribLocation': {'type': 'GLchar'}, + 'GetBooleanv': {'type': 'GETn'}, + 'GetBufferParameteriv': {'type': 'GETn'}, + 'GetError': {'type': 'Is'}, + 'GetFloatv': {'type': 'GETn'}, + 'GetFramebufferAttachmentParameteriv': {'type': 'GETn'}, + 'GetIntegerv': {'type': 'GETn'}, + 'GetProgramiv': {'type': 'GETn'}, + 'GetProgramInfoLog': {'type': 'STRn'}, + 'GetRenderbufferParameteriv': {'type': 'GETn'}, + 'GetShaderiv': {'type': 'GETn'}, + 'GetShaderInfoLog': {'type': 'STRn'}, + 'GetShaderPrecisionFormat': {'type': 'Custom'}, + 'GetShaderSource': {'type': 'STRn'}, + 'GetTexParameterfv': {'type': 'GETn'}, + 'GetTexParameteriv': {'type': 'GETn'}, + 'GetUniformfv': {'type': 'Custom', 'immediate': False}, + 'GetUniformiv': {'type': 'Custom', 'immediate': False}, + 'GetUniformLocation': {'type': 'GLchar'}, + 'GetVertexAttribfv': {'type': 'GETn'}, + 'GetVertexAttribiv': {'type': 'GETn'}, + 'GetVertexAttribPointerv': {'type': 'Custom', 'immediate': False}, + 'IsBuffer': {'type': 'Is'}, + 'IsEnabled': {'type': 'Is'}, + 'IsFramebuffer': {'type': 'Is'}, + 'IsProgram': {'type': 'Is'}, + 'IsRenderbuffer': {'type': 'Is'}, + 'IsShader': {'type': 'Is'}, + 'IsTexture': {'type': 'Is'}, + 'PixelStorei': {'type': 'Custom'}, + 'ReadPixels': {'type': 'Custom', 'immediate': False}, + 'ReleaseShaderCompiler': {'type': 'Noop'}, + 'ShaderBinary': {'type': 'Noop'}, + 'ShaderSource': { + 'type': 'Manual', + 'immediate': True, + 'needs_size': True, + 'cmd_args': + 'GLuint shader, GLsizei count, const char* data', + }, + 'TexImage2D': {'type': 'Data'}, + 'TexParameterfv': {'type': 'PUT', 'data_type': 'GLfloat', 'count': 1}, + 'TexParameteriv': {'type': 'PUT', 'data_type': 'GLint', 'count': 1}, + 'TexSubImage2D': {'type': 'Data'}, + 'Uniform1fv': {'type': 'PUTn', 'data_type': 'GLfloat', 'count': 1}, + 'Uniform1iv': {'type': 'PUTn', 'data_type': 'GLint', 'count': 1}, + 'Uniform2fv': {'type': 'PUTn', 'data_type': 'GLfloat', 'count': 2}, + 'Uniform2iv': {'type': 'PUTn', 'data_type': 'GLint', 'count': 2}, + 'Uniform3fv': {'type': 'PUTn', 'data_type': 'GLfloat', 'count': 3}, + 'Uniform3iv': {'type': 'PUTn', 'data_type': 'GLint', 'count': 3}, + 'Uniform4fv': {'type': 'PUTn', 'data_type': 'GLfloat', 'count': 4}, + 'Uniform4iv': {'type': 'PUTn', 'data_type': 'GLint', 'count': 4}, + 'UniformMatrix2fv': {'type': 'PUTn', 'data_type': 'GLfloat', 'count': 4}, + 'UniformMatrix3fv': {'type': 'PUTn', 'data_type': 'GLfloat', 'count': 9}, + 'UniformMatrix4fv': {'type': 'PUTn', 'data_type': 'GLfloat', 'count': 16}, + 'VertexAttrib1fv': {'type': 'PUT', 'data_type': 'GLfloat', 'count': 1}, + 'VertexAttrib2fv': {'type': 'PUT', 'data_type': 'GLfloat', 'count': 2}, + 'VertexAttrib3fv': {'type': 'PUT', 'data_type': 'GLfloat', 'count': 3}, + 'VertexAttrib4fv': {'type': 'PUT', 'data_type': 'GLfloat', 'count': 4}, + 'VertexAttribPointer': { + 'type': 'Manual', + 'cmd_args': 'GLuint indx, GLint size, GLenum type, GLboolean normalized, ' + 'GLsizei stride, GLuint offset', + }, +} + + +class CWriter(object): + """Writes to a file formatting it for Google's style guidelines.""" + + def __init__(self, filename): + self.filename = filename + self.file = open(filename, "w") + + def Write(self, string): + """Writes a string to a file spliting if it's > 80 characters.""" + lines = string.splitlines() + num_lines = len(lines) + for ii in range(0, num_lines): + self.__WriteLine(lines[ii], ii < (num_lines - 1) or string[-1] == '\n') + + def __FindSplit(self, string): + """Finds a place to split a string.""" + splitter = string.find('=') + if splitter >= 0 and not string[splitter + 1] == '=': + return splitter + parts = string.split('(') + if len(parts) > 1: + splitter = len(parts[0]) + for ii in range(1, len(parts)): + if not parts[ii - 1][-3:] == "if ": + return splitter + splitter += len(parts[ii]) + 1 + done = False + end = len(string) + last_splitter = -1 + while not done: + splitter = string[0:end].rfind(',') + if splitter < 0: + return last_splitter + elif splitter >= 80: + end = splitter + else: + return splitter + + def __WriteLine(self, line, ends_with_eol): + """Given a signle line, writes it to a file, splitting if it's > 80 chars""" + if len(line) >= 80: + i = self.__FindSplit(line) + if i > 0: + line1 = line[0:i + 1] + self.file.write(line1 + '\n') + match = re.match("( +)", line1) + indent = "" + if match: + indent = match.group(1) + splitter = line[i] + if not splitter == ',': + indent = " " + indent + self.__WriteLine(indent + line[i + 1:].lstrip(), True) + return + self.file.write(line) + if ends_with_eol: + self.file.write('\n') + + def Close(self): + """Close the file.""" + self.file.close() + + +class TypeHandler(object): + """This class emits code for a particular type of function.""" + + def __init__(self): + pass + + def InitFunction(self, func): + """Add or adjust anything type specific for this function.""" + if func.GetInfo('needs_size'): + func.AddCmdArg(CmdArg('data_size', 'uint32')) + + def AddImmediateFunction(self, generator, func): + """Adds an immediate version of a function.""" + # Generate an immediate command if there is only 1 pointer arg. + immediate = func.GetInfo('immediate') # can be True, False or None + if immediate == True or immediate == None: + if func.num_pointer_args == 1 or immediate: + generator.AddFunction(ImmediateFunction(func)) + + def WriteHandlerImplementation(self, func, file): + """Writes the handler implementation for this command.""" + file.Write(" parse_error::ParseError result =\n") + file.Write(" Validate%s(this, arg_count%s);\n" % + (func.name, func.MakeOriginalArgString("", True))) + file.Write(" if (result != parse_error::kParseNoError) {\n") + file.Write(" return result;\n") + file.Write(" }\n") + file.Write(" %s(%s);\n" % + (func.GetGLFunctionName(), func.MakeOriginalArgString(""))) + + def WriteCmdSizeTest(self, func, file): + """Writes the size test for a command.""" + file.Write(" EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT\n") + + def WriteFormatTest(self, func, file): + """Writes a format test for a command.""" + file.Write("TEST(GLES2FormatTest, %s) {\n" % func.name) + file.Write(" %s cmd = { 0, };\n" % func.name) + file.Write(" void* next_cmd = cmd.Set(\n") + file.Write(" &cmd") + args = func.GetCmdArgs() + value = 11 + for arg in args: + file.Write(",\n static_cast<%s>(%d)" % (arg.type, value)) + value += 1 + file.Write(");\n") + value = 11 + file.Write(" EXPECT_EQ(%s::kCmdId, cmd.header.command);\n" % func.name) + func.type_handler.WriteCmdSizeTest(func, file) + for arg in args: + file.Write(" EXPECT_EQ(static_cast<%s>(%d), cmd.%s);\n" % + (arg.type, value, arg.name)) + value += 1 + file.Write("}\n") + file.Write("\n") + + def WriteImmediateFormatTest(self, func, file): + """Writes a format test for an immediate version of a command.""" + file.Write("TEST(GLES2FormatTest, %s) {\n" % func.name) + file.Write(" int8 buf[256] = { 0, };\n") + file.Write(" %s& cmd = *static_cast<%s*>(static_cast<void*>(&buf));\n" % + (func.name, func.name)) + file.Write(" void* next_cmd = cmd.Set(\n") + file.Write(" &cmd") + args = func.GetCmdArgs() + value = 11 + for arg in args: + file.Write(",\n static_cast<%s>(%d)" % (arg.type, value)) + value += 1 + file.Write(");\n") + value = 11 + file.Write(" EXPECT_EQ(%s::kCmdId, cmd.header.command);\n" % func.name) + func.type_handler.WriteImmediateCmdSizeTest(func, file) + for arg in args: + file.Write(" EXPECT_EQ(static_cast<%s>(%d), cmd.%s);\n" % + (arg.type, value, arg.name)) + value += 1 + file.Write("}\n") + file.Write("\n") + + def WriteImmediateCmdSizeTest(self, func, file): + """Writes a size test for an immediate version of a command.""" + file.Write(" // TODO(gman): Compute correct size.\n") + file.Write(" EXPECT_EQ(sizeof(cmd), cmd.header.size * 4);\n") + + def WriteImmediateHandlerImplementation (self, func, file): + """Writes the handler impl for the immediate version of a command.""" + file.Write(" // Immediate version.\n") + file.Write(" parse_error::ParseError result =\n") + file.Write(" Validate%s(this, arg_count%s);\n" % + (func.name, func.MakeOriginalArgString("", True))) + file.Write(" if (result != parse_error::kParseNoError) {\n") + file.Write(" return result;\n") + file.Write(" }\n") + file.Write(" %s(%s);\n" % + (func.GetGLFunctionName(), func.MakeOriginalArgString(""))) + + def WriteServiceImplementation(self, func, file): + """Writes the service implementation for a command.""" + file.Write( + "parse_error::ParseError GLES2Decoder::Handle%s(\n" % func.name) + file.Write( + " unsigned int arg_count, const gles2::%s& c) {\n" % func.name) + for arg in func.GetOriginalArgs(): + arg.WriteGetCode(file) + func.WriteHandlerImplementation(file) + file.Write(" return parse_error::kParseNoError;\n") + file.Write("}\n") + file.Write("\n") + + def WriteImmediateServiceImplementation(self, func, file): + """Writes the service implementation for an immediate version of command.""" + file.Write( + "parse_error::ParseError GLES2Decoder::Handle%s(\n" % func.name) + file.Write( + " unsigned int arg_count, const gles2::%s& c) {\n" % func.name) + for arg in func.GetOriginalArgs(): + arg.WriteGetCode(file) + func.WriteHandlerImplementation(file) + file.Write(" return parse_error::kParseNoError;\n") + file.Write("}\n") + file.Write("\n") + + def WriteImmediateValidationCode(self, func, file): + """Writes the validation code for an immediate version of a command.""" + pass + + def WriteGLES2ImplementationHeader(self, func, file): + """Writes the GLES2 Implemention declaration.""" + if func.can_auto_generate: + file.Write("%s %s(%s) {\n" % + (func.return_type, func.original_name, + func.MakeTypedOriginalArgString(""))) + file.Write(" helper_->%s(%s);\n" % + (func.name, func.MakeOriginalArgString(""))) + file.Write("}\n") + file.Write("\n") + else: + file.Write("%s %s(%s);\n" % + (func.return_type, func.original_name, + func.MakeTypedOriginalArgString(""))) + file.Write("\n") + + def WriteGLES2ImplementationImpl(self, func, file): + """Writes the GLES2 Implemention definition.""" + if not func.can_auto_generate: + file.Write("%s GLES2Implementation::%s(%s) {\n" % + (func.return_type, func.original_name, + func.MakeTypedOriginalArgString(""))) + if not func.return_type == "void": + file.Write(" return 0;\n") + file.Write("}\n") + file.Write("\n") + + def WriteImmediateCmdComputeSize(self, func, file): + """Writes the size computation code for the immediate version of a cmd.""" + file.Write(" static uint32 ComputeSize(uint32 size_in_bytes) {\n") + file.Write(" return static_cast<uint32>(\n") + file.Write(" sizeof(ValueType) + // NOLINT\n") + file.Write(" RoundSizeToMultipleOfEntries(size_in_bytes));\n") + file.Write(" }\n") + file.Write("\n") + + def WriteImmediateCmdSetHeader(self, func, file): + """Writes the SetHeader function for the immediate version of a cmd.""" + file.Write(" void SetHeader(uint32 size_in_bytes) {\n") + file.Write(" header.SetCmdByTotalSize<ValueType>(size_in_bytes);\n") + file.Write(" }\n") + file.Write("\n") + + def WriteImmediateCmdInit(self, func, file): + """Writes the Init function for the immediate version of a command.""" + file.Write(" void Init(%s) {\n" % func.MakeTypedCmdArgString("_")) + file.Write(" SetHeader(0); // TODO(gman): pass in correct size\n") + args = func.GetCmdArgs() + for arg in args: + file.Write(" %s = _%s;\n" % (arg.name, arg.name)) + file.Write(" }\n") + file.Write("\n") + + def WriteImmediateCmdSet(self, func, file): + """Writes the Set function for the immediate version of a command.""" + copy_args = func.MakeCmdArgString("_", False) + file.Write(" void* Set(void* cmd%s) {\n" % + func.MakeTypedCmdArgString("_", True)) + file.Write(" // TODO(gman): compute correct size.\n") + file.Write(" const uint32 size = ComputeSize(0);\n") + file.Write(" static_cast<ValueType*>(cmd)->Init(%s);\n" % copy_args) + file.Write(" return NextImmediateCmdAddressTotalSize<ValueType>(" + "cmd, size);\n") + file.Write(" }\n") + file.Write("\n") + + def WriteImmediateCmdHelper(self, func, file): + """Writes the cmd helper definition for the immediate version of a cmd.""" + args = func.MakeCmdArgString("") + file.Write(" void %s(%s) {\n" % + (func.name, func.MakeTypedCmdArgString(""))) + file.Write(" const uint32 s = 0; // TODO(gman): compute correct size\n") + file.Write(" gles2::%s& c = " + "GetImmediateCmdSpaceTotalSize<gles2::%s>(s);\n" % + (func.name, func.name)) + file.Write(" c.Init(%s);\n" % args) + file.Write(" }\n\n") + + +class CustomHandler(TypeHandler): + """Handler for commands that are auto-generated but require minor tweaks.""" + + def __init__(self): + TypeHandler.__init__(self) + + def WriteServiceImplementation(self, func, file): + """Overrriden from TypeHandler.""" + pass + + def WriteImmediateCmdGetTotalSize(self, func, file): + """Overrriden from TypeHandler.""" + file.Write(" uint32 total_size = 0; // TODO(gman): get correct size.") + + def WriteImmediateCmdInit(self, func, file): + """Overrriden from TypeHandler.""" + file.Write(" void Init(%s) {\n" % func.MakeTypedCmdArgString("_")) + self.WriteImmediateCmdGetTotalSize(func, file) + file.Write(" SetHeader(total_size);\n") + args = func.GetCmdArgs() + for arg in args: + file.Write(" %s = _%s;\n" % (arg.name, arg.name)) + file.Write(" }\n") + file.Write("\n") + + def WriteImmediateCmdSet(self, func, file): + """Overrriden from TypeHandler.""" + copy_args = func.MakeCmdArgString("_", False) + file.Write(" void* Set(void* cmd%s) {\n" % + func.MakeTypedCmdArgString("_", True)) + self.WriteImmediateCmdGetTotalSize(func, file) + file.Write(" static_cast<ValueType*>(cmd)->Init(%s);\n" % copy_args) + file.Write(" return NextImmediateCmdAddressTotalSize<ValueType>(" + "cmd, total_size);\n") + file.Write(" }\n") + file.Write("\n") + + +class TodoHandler(CustomHandler): + """Handle for commands that are not yet implemented.""" + + def WriteImmediateFormatTest(self, func, file): + """Overrriden from TypeHandler.""" + pass + + +class ManualHandler(CustomHandler): + """Handler for commands that must be written by hand.""" + + def __init__(self): + CustomHandler.__init__(self) + + def WriteServiceImplementation(self, func, file): + """Overrriden from TypeHandler.""" + pass + + def WriteImmediateServiceImplementation(self, func, file): + """Overrriden from TypeHandler.""" + pass + + def WriteImmediateFormatTest(self, func, file): + """Overrriden from TypeHandler.""" + file.Write("// TODO(gman): Implement test for %s\n" % func.name) + + def WriteGLES2ImplementationHeader(self, func, file): + """Overrriden from TypeHandler.""" + file.Write("%s %s(%s);\n" % + (func.return_type, func.original_name, + func.MakeTypedOriginalArgString(""))) + file.Write("\n") + + def WriteGLES2ImplementationImpl(self, func, file): + """Overrriden from TypeHandler.""" + pass + + def WriteImmediateCmdGetTotalSize(self, func, file): + """Overrriden from TypeHandler.""" + # TODO(gman): Move this data to _FUNCTION_INFO? + if func.name == 'ShaderSourceImmediate': + file.Write(" uint32 total_size = ComputeSize(_data_size);\n") + else: + CustomHandler.WriteImmediateCmdGetTotalSize(self, func, file) + + +class DataHandler(CustomHandler): + """Handler for glBufferData, glBufferSubData, glTexImage2D, glTexSubImage2D, + glCompressedTexImage2D, glCompressedTexImageSub2D.""" + def __init__(self): + CustomHandler.__init__(self) + + def WriteServiceImplementation(self, func, file): + """Overrriden from TypeHandler.""" + file.Write( + "parse_error::ParseError GLES2Decoder::Handle%s(\n" % func.name) + file.Write( + " unsigned int arg_count, const gles2::%s& c) {\n" % func.name) + for arg in func.GetCmdArgs(): + arg.WriteGetCode(file) + + # TODO(gman): Move this data to _FUNCTION_INFO? + if func.name == 'BufferData': + file.Write(" uint32 data_size = size;\n") + elif func.name == 'BufferSubData': + file.Write(" uint32 data_size = size;\n") + elif func.name == 'CompressedTexImage2D': + file.Write(" uint32 data_size = imageSize;\n") + elif func.name == 'CompressedTexSubImage2D': + file.Write(" uint32 data_size = imageSize;\n") + elif func.name == 'TexImage2D': + file.Write(" uint32 pixels_size = GLES2Util::ComputeImageDataSize(\n") + file.Write(" width, height, format, type, unpack_alignment_);\n") + elif func.name == 'TexSubImage2D': + file.Write(" uint32 pixels_size = GLES2Util::ComputeImageDataSize(\n") + file.Write(" width, height, format, type, unpack_alignment_);\n") + else: + file.Write(" uint32 data_size = 0; // TODO(gman): get correct size!\n") + + for arg in func.GetOriginalArgs(): + arg.WriteGetAddress(file) + func.WriteHandlerImplementation(file) + file.Write(" return parse_error::kParseNoError;\n") + file.Write("}\n") + file.Write("\n") + + def WriteImmediateCmdGetTotalSize(self, func, file): + """Overrriden from TypeHandler.""" + # TODO(gman): Move this data to _FUNCTION_INFO? + if func.name == 'BufferDataImmediate': + file.Write(" uint32 total_size = ComputeSize(_size);\n") + elif func.name == 'BufferSubDataImmediate': + file.Write(" uint32 total_size = ComputeSize(_size);\n") + elif func.name == 'CompressedTexImage2DImmediate': + file.Write(" uint32 total_size = ComputeSize(_imageSize);\n") + elif func.name == 'CompressedTexSubImage2DImmediate': + file.Write(" uint32 total_size = ComputeSize(_imageSize);\n") + elif func.name == 'TexImage2DImmediate': + file.Write( + " uint32 total_size = 0; // TODO(gman): get correct size\n") + elif func.name == 'TexSubImage2DImmediate': + file.Write( + " uint32 total_size = 0; // TODO(gman): get correct size\n") + + def WriteImmediateCmdSizeTest(self, func, file): + """Overrriden from TypeHandler.""" + # TODO(gman): Move this data to _FUNCTION_INFO? + if func.name == 'BufferDataImmediate': + file.Write(" uint32 total_size = cmd.ComputeSize(cmd.size);\n") + elif func.name == 'BufferSubDataImmediate': + file.Write(" uint32 total_size = cmd.ComputeSize(cmd.size);\n") + elif func.name == 'CompressedTexImage2DImmediate': + file.Write(" uint32 total_size = cmd.ComputeSize(cmd.imageSize);\n") + elif func.name == 'CompressedTexSubImage2DImmediate': + file.Write(" uint32 total_size = cmd.ComputeSize(cmd.imageSize);\n") + elif func.name == 'TexImage2DImmediate': + file.Write( + " uint32 total_size = 0; // TODO(gman): get correct size\n") + elif func.name == 'TexSubImage2DImmediate': + file.Write( + " uint32 total_size = 0; // TODO(gman): get correct size\n") + file.Write(" EXPECT_EQ(sizeof(cmd), total_size);\n") + + def WriteImmediateFormatTest(self, func, file): + """Overrriden from TypeHandler.""" + # TODO(gman): Remove this exception. + file.Write("// TODO(gman): Implement test for %s\n" % func.name) + return + + def WriteGLES2ImplementationImpl(self, func, file): + """Overrriden from TypeHandler.""" + pass + + +class GENnHandler(TypeHandler): + """Handler for glGen___ type functions.""" + + def __init__(self): + TypeHandler.__init__(self) + + def InitFunction(self, func): + """Overrriden from TypeHandler.""" + pass + + def WriteHandlerImplementation (self, func, file): + """Overrriden from TypeHandler.""" + file.Write(" parse_error::ParseError result =\n") + file.Write(" Validate%s(this, arg_count%s);\n" % + (func.name, func.MakeOriginalArgString("", True))) + file.Write(" if (result != parse_error::kParseNoError) {\n") + file.Write(" return result;\n") + file.Write(" }\n") + file.Write(" GenGLObjects<GL%sHelper>(n, %s);\n" % + (func.name, func.GetLastOriginalArg().name)) + + def WriteImmediateHandlerImplementation(self, func, file): + """Overrriden from TypeHandler.""" + file.Write(" parse_error::ParseError result =\n") + file.Write(" Validate%s(this, arg_count%s);\n" % + (func.name, func.MakeOriginalArgString("", True))) + file.Write(" if (result != parse_error::kParseNoError) {\n") + file.Write(" return result;\n") + file.Write(" }\n") + file.Write(" GenGLObjects<GL%sHelper>(n, %s);\n" % + (func.original_name, func.GetLastOriginalArg().name)) + + def WriteGLES2ImplementationHeader(self, func, file): + """Overrriden from TypeHandler.""" + file.Write("%s %s(%s) {\n" % + (func.return_type, func.original_name, + func.MakeTypedOriginalArgString(""))) + file.Write(" MakeIds(%s);\n" % func.MakeOriginalArgString("")) + file.Write(" helper_->%sImmediate(%s);\n" % + (func.name, func.MakeOriginalArgString(""))) + file.Write("}\n") + file.Write("\n") + + def WriteGLES2ImplementationImpl(self, func, file): + """Overrriden from TypeHandler.""" + pass + + def WriteImmediateCmdComputeSize(self, func, file): + """Overrriden from TypeHandler.""" + file.Write(" static uint32 ComputeDataSize(GLsizei n) {\n") + file.Write( + " return static_cast<uint32>(sizeof(GLuint) * n); // NOLINT\n") + file.Write(" }\n") + file.Write("\n") + file.Write(" static uint32 ComputeSize(GLsizei n) {\n") + file.Write(" return static_cast<uint32>(\n") + file.Write(" sizeof(ValueType) + ComputeDataSize(n)); // NOLINT\n") + file.Write(" }\n") + file.Write("\n") + + def WriteImmediateCmdSetHeader(self, func, file): + """Overrriden from TypeHandler.""" + file.Write(" void SetHeader(GLsizei n) {\n") + file.Write(" header.SetCmdByTotalSize<ValueType>(ComputeSize(n));\n") + file.Write(" }\n") + file.Write("\n") + + def WriteImmediateCmdInit(self, func, file): + """Overrriden from TypeHandler.""" + last_arg = func.GetLastOriginalArg() + file.Write(" void Init(%s, %s _%s) {\n" % + (func.MakeTypedCmdArgString("_"), + last_arg.type, last_arg.name)) + file.Write(" SetHeader(_n);\n") + args = func.GetCmdArgs() + for arg in args: + file.Write(" %s = _%s;\n" % (arg.name, arg.name)) + file.Write(" memcpy(ImmediateDataAddress(this),\n") + file.Write(" _%s, ComputeDataSize(_n));\n" % last_arg.name) + file.Write(" }\n") + file.Write("\n") + + def WriteImmediateCmdSet(self, func, file): + """Overrriden from TypeHandler.""" + last_arg = func.GetLastOriginalArg() + copy_args = func.MakeCmdArgString("_", False) + file.Write(" void* Set(void* cmd%s, %s _%s) {\n" % + (func.MakeTypedCmdArgString("_", True), + last_arg.type, last_arg.name)) + file.Write(" static_cast<ValueType*>(cmd)->Init(%s, _%s);\n" % + (copy_args, last_arg.name)) + file.Write(" const uint32 size = ComputeSize(_n);\n") + file.Write(" return NextImmediateCmdAddressTotalSize<ValueType>(" + "cmd, size);\n") + file.Write(" }\n") + file.Write("\n") + + def WriteImmediateCmdHelper(self, func, file): + """Overrriden from TypeHandler.""" + args = func.MakeOriginalArgString("") + file.Write(" void %s(%s) {\n" % + (func.name, func.MakeTypedOriginalArgString(""))) + file.Write(" const uint32 size = gles2::%s::ComputeSize(n);\n" % + func.name) + file.Write(" gles2::%s& c = " + "GetImmediateCmdSpaceTotalSize<gles2::%s>(size);\n" % + (func.name, func.name)) + file.Write(" c.Init(%s);\n" % args) + file.Write(" }\n\n") + + def WriteImmediateFormatTest(self, func, file): + """Overrriden from TypeHandler.""" + file.Write("TEST(GLES2FormatTest, %s) {\n" % func.name) + file.Write(" static GLuint ids[] = { 12, 23, 34, };\n") + file.Write(" int8 buf[256] = { 0, };\n") + file.Write(" %s& cmd = *static_cast<%s*>(static_cast<void*>(&buf));\n" % + (func.name, func.name)) + file.Write(" void* next_cmd = cmd.Set(\n") + file.Write(" &cmd") + args = func.GetCmdArgs() + value = 11 + for arg in args: + file.Write(",\n static_cast<%s>(%d)" % (arg.type, value)) + value += 1 + file.Write(",\n ids);\n") + args = func.GetCmdArgs() + value = 11 + file.Write(" EXPECT_EQ(%s::kCmdId, cmd.header.command);\n" % func.name) + file.Write(" EXPECT_EQ(sizeof(cmd) +\n") + file.Write(" RoundSizeToMultipleOfEntries(cmd.n * 4),\n") + file.Write(" cmd.header.size * 4); // NOLINT\n") + for arg in args: + file.Write(" EXPECT_EQ(static_cast<%s>(%d), cmd.%s);\n" % + (arg.type, value, arg.name)) + value += 1 + file.Write(" // TODO(gman): Check that ids were inserted;\n") + file.Write("}\n") + file.Write("\n") + + +class CreateHandler(TypeHandler): + """Handler for glCreate___ type functions.""" + + def __init__(self): + TypeHandler.__init__(self) + + def InitFunction(self, func): + """Overrriden from TypeHandler.""" + func.AddCmdArg(CmdArg("client_id", 'uint32')) + + def WriteHandlerImplementation (self, func, file): + """Overrriden from TypeHandler.""" + file.Write(" uint32 client_id = c.client_id;\n") + file.Write(" parse_error::ParseError result =\n") + file.Write(" Validate%s(this, arg_count%s);\n" % + (func.name, func.MakeOriginalArgString("", True))) + file.Write(" if (result != parse_error::kParseNoError) {\n") + file.Write(" return result;\n") + file.Write(" }\n") + file.Write(" %sHelper(%s);\n" % + (func.name, func.MakeCmdArgString(""))) + + def WriteGLES2ImplementationHeader(self, func, file): + """Overrriden from TypeHandler.""" + file.Write("%s %s(%s) {\n" % + (func.return_type, func.original_name, + func.MakeTypedOriginalArgString(""))) + file.Write(" GLuint client_id;\n") + file.Write(" MakeIds(1, &client_id);\n") + file.Write(" helper_->%s(%s);\n" % + (func.name, func.MakeCmdArgString(""))) + file.Write(" return client_id;\n") + file.Write("}\n") + file.Write("\n") + + def WriteGLES2ImplementationImpl(self, func, file): + """Overrriden from TypeHandler.""" + pass + + +class DELnHandler(TypeHandler): + """Handler for glDelete___ type functions.""" + + def __init__(self): + TypeHandler.__init__(self) + + def WriteHandlerImplementation (self, func, file): + """Overrriden from TypeHandler.""" + file.Write(" parse_error::ParseError result =\n") + file.Write(" Validate%s(this, arg_count%s);\n" % + (func.name, func.MakeOriginalArgString("", True))) + file.Write(" if (result != parse_error::kParseNoError) {\n") + file.Write(" return result;\n") + file.Write(" }\n") + file.Write(" DeleteGLObjects<GL%sHelper>(n, %s);\n" % + (func.name, func.GetLastOriginalArg().name)) + + def WriteImmediateHandlerImplementation (self, func, file): + """Overrriden from TypeHandler.""" + file.Write(" parse_error::ParseError result =\n") + file.Write(" Validate%s(this, arg_count%s);\n" % + (func.name, func.MakeOriginalArgString("", True))) + file.Write(" if (result != parse_error::kParseNoError) {\n") + file.Write(" return result;\n") + file.Write(" }\n") + file.Write(" DeleteGLObjects<GL%sHelper>(n, %s);\n" % + (func.original_name, func.GetLastOriginalArg().name)) + + def WriteGLES2ImplementationHeader(self, func, file): + """Overrriden from TypeHandler.""" + file.Write("%s %s(%s) {\n" % + (func.return_type, func.original_name, + func.MakeTypedOriginalArgString(""))) + file.Write(" FreeIds(%s);\n" % func.MakeOriginalArgString("")) + file.Write(" helper_->%sImmediate(%s);\n" % + (func.name, func.MakeOriginalArgString(""))) + file.Write("}\n") + file.Write("\n") + + def WriteGLES2ImplementationImpl(self, func, file): + """Overrriden from TypeHandler.""" + pass + + def WriteImmediateCmdComputeSize(self, func, file): + """Overrriden from TypeHandler.""" + file.Write(" static uint32 ComputeDataSize(GLsizei n) {\n") + file.Write( + " return static_cast<uint32>(sizeof(GLuint) * n); // NOLINT\n") + file.Write(" }\n") + file.Write("\n") + file.Write(" static uint32 ComputeSize(GLsizei n) {\n") + file.Write(" return static_cast<uint32>(\n") + file.Write(" sizeof(ValueType) + ComputeDataSize(n)); // NOLINT\n") + file.Write(" }\n") + file.Write("\n") + + def WriteImmediateCmdSetHeader(self, func, file): + """Overrriden from TypeHandler.""" + file.Write(" void SetHeader(GLsizei n) {\n") + file.Write(" header.SetCmdByTotalSize<ValueType>(ComputeSize(n));\n") + file.Write(" }\n") + file.Write("\n") + + def WriteImmediateCmdInit(self, func, file): + """Overrriden from TypeHandler.""" + last_arg = func.GetLastOriginalArg() + file.Write(" void Init(%s, %s _%s) {\n" % + (func.MakeTypedCmdArgString("_"), + last_arg.type, last_arg.name)) + file.Write(" SetHeader(_n);\n") + args = func.GetCmdArgs() + for arg in args: + file.Write(" %s = _%s;\n" % (arg.name, arg.name)) + file.Write(" memcpy(ImmediateDataAddress(this),\n") + file.Write(" _%s, ComputeDataSize(_n));\n" % last_arg.name) + file.Write(" }\n") + file.Write("\n") + + def WriteImmediateCmdSet(self, func, file): + """Overrriden from TypeHandler.""" + last_arg = func.GetLastOriginalArg() + copy_args = func.MakeCmdArgString("_", False) + file.Write(" void* Set(void* cmd%s, %s _%s) {\n" % + (func.MakeTypedCmdArgString("_", True), + last_arg.type, last_arg.name)) + file.Write(" static_cast<ValueType*>(cmd)->Init(%s, _%s);\n" % + (copy_args, last_arg.name)) + file.Write(" const uint32 size = ComputeSize(_n);\n") + file.Write(" return NextImmediateCmdAddressTotalSize<ValueType>(" + "cmd, size);\n") + file.Write(" }\n") + file.Write("\n") + + def WriteImmediateCmdHelper(self, func, file): + """Overrriden from TypeHandler.""" + args = func.MakeOriginalArgString("") + file.Write(" void %s(%s) {\n" % + (func.name, func.MakeTypedOriginalArgString(""))) + file.Write(" const uint32 size = gles2::%s::ComputeSize(n);\n" % + func.name) + file.Write(" gles2::%s& c = " + "GetImmediateCmdSpaceTotalSize<gles2::%s>(size);\n" % + (func.name, func.name)) + file.Write(" c.Init(%s);\n" % args) + file.Write(" }\n\n") + + def WriteImmediateFormatTest(self, func, file): + """Overrriden from TypeHandler.""" + file.Write("TEST(GLES2FormatTest, %s) {\n" % func.name) + file.Write(" static GLuint ids[] = { 12, 23, 34, };\n") + file.Write(" int8 buf[256] = { 0, };\n") + file.Write(" %s& cmd = *static_cast<%s*>(static_cast<void*>(&buf));\n" % + (func.name, func.name)) + file.Write(" void* next_cmd = cmd.Set(\n") + file.Write(" &cmd") + args = func.GetCmdArgs() + value = 11 + for arg in args: + file.Write(",\n static_cast<%s>(%d)" % (arg.type, value)) + value += 1 + file.Write(",\n ids);\n") + args = func.GetCmdArgs() + value = 11 + file.Write(" EXPECT_EQ(%s::kCmdId, cmd.header.command);\n" % func.name) + file.Write(" EXPECT_EQ(sizeof(cmd) +\n") + file.Write(" RoundSizeToMultipleOfEntries(cmd.n * 4),\n") + file.Write(" cmd.header.size * 4); // NOLINT\n") + for arg in args: + file.Write(" EXPECT_EQ(static_cast<%s>(%d), cmd.%s);\n" % + (arg.type, value, arg.name)) + value += 1 + file.Write(" // TODO(gman): Check that ids were inserted;\n") + file.Write("}\n") + file.Write("\n") + + +class GETnHandler(TypeHandler): + """Handler for GETn for glGetBooleanv, glGetFloatv, ... type functions.""" + + def __init__(self): + TypeHandler.__init__(self) + + def AddImmediateFunction(self, generator, func): + """Overrriden from TypeHandler.""" + pass + + def WriteServiceImplementation(self, func, file): + """Overrriden from TypeHandler.""" + file.Write( + "parse_error::ParseError GLES2Decoder::Handle%s(\n" % func.name) + file.Write( + " unsigned int arg_count, const gles2::%s& c) {\n" % func.name) + last_arg = func.GetLastOriginalArg() + + all_but_last_args = func.GetOriginalArgs()[:-1] + for arg in all_but_last_args: + arg.WriteGetCode(file) + + file.Write(" %s params;\n" % last_arg.type) + file.Write(" GLsizei num_values = util_.GLGetNumValuesReturned(pname);\n") + file.Write(" uint32 params_size = num_values * sizeof(*params);\n") + file.Write(" params = GetSharedMemoryAs<%s>(\n" % last_arg.type) + file.Write(" c.params_shm_id, c.params_shm_offset, params_size);\n") + func.WriteHandlerImplementation(file) + file.Write(" return parse_error::kParseNoError;\n") + file.Write("}\n") + file.Write("\n") + + def WriteGLES2ImplementationHeader(self, func, file): + """Overrriden from TypeHandler.""" + file.Write("%s %s(%s) {\n" % + (func.return_type, func.original_name, + func.MakeTypedOriginalArgString(""))) + all_but_last_args = func.GetOriginalArgs()[:-1] + arg_string = ( + ", ".join(["%s" % arg.name for arg in all_but_last_args])) + file.Write(" helper_->%s(%s, shared_memory_.GetId(), 0);\n" % + (func.name, arg_string)) + file.Write(" int32 token = helper_->InsertToken();\n") + file.Write(" helper_->WaitForToken(token);\n") + file.Write(" GLsizei num_values = util_.GLGetNumValuesReturned(pname);\n") + file.Write(" memcpy(params, shared_memory_.GetAddress(0),\n") + file.Write(" num_values * sizeof(*params));\n") + file.Write("}\n") + file.Write("\n") + + def WriteGLES2ImplementationImpl(self, func, file): + """Overrriden from TypeHandler.""" + pass + + +class PUTHandler(TypeHandler): + """Handler for glTexParameter_v, glVertexAttrib_v functions.""" + + def __init__(self): + TypeHandler.__init__(self) + + def WriteImmediateValidationCode(self, func, file): + """Overrriden from TypeHandler.""" + file.Write(" if (!CheckImmediateDataSize<%s>(" + "arg_count, 1, sizeof(%s), %d)) {\n" % + (func.name, func.info.data_type, func.info.count)) + file.Write(" return parse_error::kParseOutOfBounds;\n") + file.Write(" }\n") + + def WriteGLES2ImplementationHeader(self, func, file): + """Overrriden from TypeHandler.""" + file.Write("%s %s(%s) {\n" % + (func.return_type, func.original_name, + func.MakeTypedOriginalArgString(""))) + file.Write(" helper_->%sImmediate(%s);\n" % + (func.name, func.MakeOriginalArgString(""))) + file.Write("}\n") + file.Write("\n") + + def WriteGLES2ImplementationImpl(self, func, file): + """Overrriden from TypeHandler.""" + pass + + def WriteImmediateCmdComputeSize(self, func, file): + """Overrriden from TypeHandler.""" + file.Write(" static uint32 ComputeDataSize() {\n") + file.Write(" return static_cast<uint32>(\n") + file.Write(" sizeof(%s) * %d); // NOLINT\n" % + (func.info.data_type, func.info.count)) + file.Write(" }\n") + file.Write("\n") + file.Write(" static uint32 ComputeSize() {\n") + file.Write(" return static_cast<uint32>(\n") + file.Write( + " sizeof(ValueType) + ComputeDataSize()); // NOLINT\n") + file.Write(" }\n") + file.Write("\n") + + def WriteImmediateCmdSetHeader(self, func, file): + """Overrriden from TypeHandler.""" + file.Write(" void SetHeader() {\n") + file.Write( + " header.SetCmdByTotalSize<ValueType>(ComputeSize());\n") + file.Write(" }\n") + file.Write("\n") + + def WriteImmediateCmdInit(self, func, file): + """Overrriden from TypeHandler.""" + last_arg = func.GetLastOriginalArg() + file.Write(" void Init(%s, %s _%s) {\n" % + (func.MakeTypedCmdArgString("_"), + last_arg.type, last_arg.name)) + file.Write(" SetHeader();\n") + args = func.GetCmdArgs() + for arg in args: + file.Write(" %s = _%s;\n" % (arg.name, arg.name)) + file.Write(" memcpy(ImmediateDataAddress(this),\n") + file.Write(" _%s, ComputeDataSize());\n" % last_arg.name) + file.Write(" }\n") + file.Write("\n") + + def WriteImmediateCmdSet(self, func, file): + """Overrriden from TypeHandler.""" + last_arg = func.GetLastOriginalArg() + copy_args = func.MakeCmdArgString("_", False) + file.Write(" void* Set(void* cmd%s, %s _%s) {\n" % + (func.MakeTypedCmdArgString("_", True), + last_arg.type, last_arg.name)) + file.Write(" static_cast<ValueType*>(cmd)->Init(%s, _%s);\n" % + (copy_args, last_arg.name)) + file.Write(" const uint32 size = ComputeSize();\n") + file.Write(" return NextImmediateCmdAddressTotalSize<ValueType>(" + "cmd, size);\n") + file.Write(" }\n") + file.Write("\n") + + def WriteImmediateCmdHelper(self, func, file): + """Overrriden from TypeHandler.""" + args = func.MakeOriginalArgString("") + file.Write(" void %s(%s) {\n" % + (func.name, func.MakeTypedOriginalArgString(""))) + file.Write(" const uint32 size = gles2::%s::ComputeSize();\n" % + func.name) + file.Write(" gles2::%s& c = " + "GetImmediateCmdSpaceTotalSize<gles2::%s>(size);\n" % + (func.name, func.name)) + file.Write(" c.Init(%s);\n" % args) + file.Write(" }\n\n") + + def WriteImmediateFormatTest(self, func, file): + """Overrriden from TypeHandler.""" + file.Write("TEST(GLES2FormatTest, %s) {\n" % func.name) + file.Write(" const int kSomeBaseValueToTestWith = 51;\n") + file.Write(" static %s data[] = {\n" % func.info.data_type) + for v in range(0, func.info.count): + file.Write(" static_cast<%s>(kSomeBaseValueToTestWith + %d),\n" % + (func.info.data_type, v)) + file.Write(" };\n") + file.Write(" int8 buf[256] = { 0, };\n") + file.Write(" %s& cmd = *static_cast<%s*>(static_cast<void*>(&buf));\n" % + (func.name, func.name)) + file.Write(" void* next_cmd = cmd.Set(\n") + file.Write(" &cmd") + args = func.GetCmdArgs() + value = 11 + for arg in args: + file.Write(",\n static_cast<%s>(%d)" % (arg.type, value)) + value += 1 + file.Write(",\n data);\n") + args = func.GetCmdArgs() + value = 11 + file.Write(" EXPECT_EQ(%s::kCmdId, cmd.header.command);\n" % func.name) + file.Write(" EXPECT_EQ(sizeof(cmd) +\n") + file.Write(" RoundSizeToMultipleOfEntries(sizeof(data)),\n") + file.Write(" cmd.header.size * 4); // NOLINT\n") + for arg in args: + file.Write(" EXPECT_EQ(static_cast<%s>(%d), cmd.%s);\n" % + (arg.type, value, arg.name)) + value += 1 + file.Write(" // TODO(gman): Check that data was inserted;\n") + file.Write("}\n") + file.Write("\n") + + +class PUTnHandler(TypeHandler): + """Handler for PUTn 'glUniform__v' type functions.""" + + def __init__(self): + TypeHandler.__init__(self) + + def WriteImmediateValidationCode(self, func, file): + """Overrriden from TypeHandler.""" + file.Write(" if (!CheckImmediateDataSize<%s>(" + "arg_count, count, sizeof(%s), %d)) {\n" % + (func.name, func.info.data_type, func.info.count)) + file.Write(" return parse_error::kParseOutOfBounds;\n") + file.Write(" }\n") + + def WriteGLES2ImplementationHeader(self, func, file): + """Overrriden from TypeHandler.""" + file.Write("%s %s(%s) {\n" % + (func.return_type, func.original_name, + func.MakeTypedOriginalArgString(""))) + file.Write(" helper_->%sImmediate(%s);\n" % + (func.name, func.MakeOriginalArgString(""))) + file.Write("}\n") + file.Write("\n") + + def WriteGLES2ImplementationImpl(self, func, file): + """Overrriden from TypeHandler.""" + pass + + def WriteImmediateCmdComputeSize(self, func, file): + """Overrriden from TypeHandler.""" + file.Write(" static uint32 ComputeDataSize(GLsizei count) {\n") + file.Write(" return static_cast<uint32>(\n") + file.Write(" sizeof(%s) * %d * count); // NOLINT\n" % + (func.info.data_type, func.info.count)) + file.Write(" }\n") + file.Write("\n") + file.Write(" static uint32 ComputeSize(GLsizei count) {\n") + file.Write(" return static_cast<uint32>(\n") + file.Write( + " sizeof(ValueType) + ComputeDataSize(count)); // NOLINT\n") + file.Write(" }\n") + file.Write("\n") + + def WriteImmediateCmdSetHeader(self, func, file): + """Overrriden from TypeHandler.""" + file.Write(" void SetHeader(GLsizei count) {\n") + file.Write( + " header.SetCmdByTotalSize<ValueType>(ComputeSize(count));\n") + file.Write(" }\n") + file.Write("\n") + + def WriteImmediateCmdInit(self, func, file): + """Overrriden from TypeHandler.""" + last_arg = func.GetLastOriginalArg() + file.Write(" void Init(%s, %s _%s) {\n" % + (func.MakeTypedCmdArgString("_"), + last_arg.type, last_arg.name)) + file.Write(" SetHeader(_count);\n") + args = func.GetCmdArgs() + for arg in args: + file.Write(" %s = _%s;\n" % (arg.name, arg.name)) + file.Write(" memcpy(ImmediateDataAddress(this),\n") + file.Write(" _%s, ComputeDataSize(_count));\n" % last_arg.name) + file.Write(" }\n") + file.Write("\n") + + def WriteImmediateCmdSet(self, func, file): + """Overrriden from TypeHandler.""" + last_arg = func.GetLastOriginalArg() + copy_args = func.MakeCmdArgString("_", False) + file.Write(" void* Set(void* cmd%s, %s _%s) {\n" % + (func.MakeTypedCmdArgString("_", True), + last_arg.type, last_arg.name)) + file.Write(" static_cast<ValueType*>(cmd)->Init(%s, _%s);\n" % + (copy_args, last_arg.name)) + file.Write(" const uint32 size = ComputeSize(_count);\n") + file.Write(" return NextImmediateCmdAddressTotalSize<ValueType>(" + "cmd, size);\n") + file.Write(" }\n") + file.Write("\n") + + def WriteImmediateCmdHelper(self, func, file): + """Overrriden from TypeHandler.""" + args = func.MakeOriginalArgString("") + file.Write(" void %s(%s) {\n" % + (func.name, func.MakeTypedOriginalArgString(""))) + file.Write(" const uint32 size = gles2::%s::ComputeSize(count);\n" % + func.name) + file.Write(" gles2::%s& c = " + "GetImmediateCmdSpaceTotalSize<gles2::%s>(size);\n" % + (func.name, func.name)) + file.Write(" c.Init(%s);\n" % args) + file.Write(" }\n\n") + + def WriteImmediateFormatTest(self, func, file): + """Overrriden from TypeHandler.""" + file.Write("TEST(GLES2FormatTest, %s) {\n" % func.name) + file.Write(" const int kSomeBaseValueToTestWith = 51;\n") + file.Write(" static %s data[] = {\n" % func.info.data_type) + for v in range(0, func.info.count * 2): + file.Write(" static_cast<%s>(kSomeBaseValueToTestWith + %d),\n" % + (func.info.data_type, v)) + file.Write(" };\n") + file.Write(" int8 buf[256] = { 0, };\n") + file.Write(" %s& cmd = *static_cast<%s*>(static_cast<void*>(&buf));\n" % + (func.name, func.name)) + file.Write(" void* next_cmd = cmd.Set(\n") + file.Write(" &cmd") + args = func.GetCmdArgs() + value = 1 + for arg in args: + file.Write(",\n static_cast<%s>(%d)" % (arg.type, value)) + value += 1 + file.Write(",\n data);\n") + args = func.GetCmdArgs() + value = 1 + file.Write(" EXPECT_EQ(%s::kCmdId, cmd.header.command);\n" % func.name) + file.Write(" EXPECT_EQ(sizeof(cmd) +\n") + file.Write(" RoundSizeToMultipleOfEntries(sizeof(data)),\n") + file.Write(" cmd.header.size * 4); // NOLINT\n") + for arg in args: + file.Write(" EXPECT_EQ(static_cast<%s>(%d), cmd.%s);\n" % + (arg.type, value, arg.name)) + value += 1 + file.Write(" // TODO(gman): Check that data was inserted;\n") + file.Write("}\n") + file.Write("\n") + + +class GLcharHandler(TypeHandler): + """Handler for glBindAttrLoc, glGetAttibLoc, glGetUniformLoc.""" + + def __init__(self): + TypeHandler.__init__(self) + + def InitFunction(self, func): + """Overrriden from TypeHandler.""" + func.AddCmdArg(CmdArg('data_size', 'uint32')) + + def WriteServiceImplementation(self, func, file): + """Overrriden from TypeHandler.""" + file.Write( + "parse_error::ParseError GLES2Decoder::Handle%s(\n" % func.name) + file.Write( + " unsigned int arg_count, const gles2::%s& c) {\n" % func.name) + last_arg = func.GetLastOriginalArg() + + all_but_last_arg = func.GetOriginalArgs()[:-1] + for arg in all_but_last_arg: + arg.WriteGetCode(file) + + file.Write(" uint32 name_size = c.data_size;\n") + file.Write(" const char* name = GetSharedMemoryAs<%s>(\n" % + last_arg.type) + file.Write(" c.%s_shm_id, c.%s_shm_offset, name_size);\n" % + (last_arg.name, last_arg.name)) + file.Write(" parse_error::ParseError result =\n") + file.Write(" Validate%s(this, arg_count%s);\n" % + (func.name, func.MakeOriginalArgString("", True))) + file.Write(" if (result != parse_error::kParseNoError) {\n") + file.Write(" return result;\n") + file.Write(" }\n") + arg_string = ", ".join(["%s" % arg.name for arg in all_but_last_arg]) + file.Write(" String name_str(name, name_size);\n") + file.Write(" %s(%s, name_str.c_str());\n" % + (func.GetGLFunctionName(), arg_string)) + file.Write(" return parse_error::kParseNoError;\n") + file.Write("}\n") + file.Write("\n") + + def WriteImmediateServiceImplementation(self, func, file): + """Overrriden from TypeHandler.""" + file.Write( + "parse_error::ParseError GLES2Decoder::Handle%s(\n" % func.name) + file.Write( + " unsigned int arg_count, const gles2::%s& c) {\n" % func.name) + last_arg = func.GetLastOriginalArg() + + all_but_last_arg = func.GetOriginalArgs()[:-1] + for arg in all_but_last_arg: + arg.WriteGetCode(file) + + file.Write(" uint32 name_size = c.data_size;\n") + file.Write( + " const char* name = GetImmediateDataAs<const char*>(c);\n") + file.Write(" // TODO(gman): Make sure validate checks arg_count\n") + file.Write(" // covers data_size.\n") + file.Write(" parse_error::ParseError result =\n") + file.Write(" Validate%s(this, arg_count%s);\n" % + (func.name, func.MakeOriginalArgString("", True))) + file.Write(" if (result != parse_error::kParseNoError) {\n") + file.Write(" return result;\n") + file.Write(" }\n") + arg_string = ", ".join(["%s" % arg.name for arg in all_but_last_arg]) + file.Write(" String name_str(name, name_size);\n") + file.Write(" %s(%s, name_str.c_str());\n" % + (func.GetGLFunctionName(), arg_string)) + file.Write(" return parse_error::kParseNoError;\n") + file.Write("}\n") + file.Write("\n") + + def WriteGLES2ImplementationHeader(self, func, file): + """Overrriden from TypeHandler.""" + file.Write("%s %s(%s) {\n" % + (func.return_type, func.original_name, + func.MakeTypedOriginalArgString(""))) + file.Write(" // TODO(gman): This needs to change to use SendString.\n") + file.Write(" helper_->%sImmediate(%s);\n" % + (func.name, func.MakeOriginalArgString(""))) + file.Write("}\n") + file.Write("\n") + + def WriteGLES2ImplementationImpl(self, func, file): + """Overrriden from TypeHandler.""" + pass + + def WriteImmediateCmdComputeSize(self, func, file): + """Overrriden from TypeHandler.""" + file.Write(" static uint32 ComputeDataSize(const char* s) {\n") + file.Write(" return strlen(s);\n") + file.Write(" }\n") + file.Write("\n") + file.Write(" static uint32 ComputeSize(const char* s) {\n") + file.Write(" return static_cast<uint32>(\n") + file.Write(" sizeof(ValueType) + ComputeDataSize(s)); // NOLINT\n") + file.Write(" }\n") + file.Write("\n") + + def WriteImmediateCmdSetHeader(self, func, file): + """Overrriden from TypeHandler.""" + file.Write(" void SetHeader(const char* s) {\n") + file.Write(" header.SetCmdByTotalSize<ValueType>(ComputeSize(s));\n") + file.Write(" }\n") + file.Write("\n") + + def WriteImmediateCmdInit(self, func, file): + """Overrriden from TypeHandler.""" + last_arg = func.GetLastOriginalArg() + file.Write(" void Init(%s) {\n" % func.MakeTypedOriginalArgString("_")) + file.Write(" SetHeader(_%s);\n" % last_arg.name) + args = func.GetCmdArgs()[:-1] + for arg in args: + file.Write(" %s = _%s;\n" % (arg.name, arg.name)) + file.Write(" data_size = strlen(_%s);\n" % last_arg.name) + file.Write(" memcpy(ImmediateDataAddress(this), _%s, data_size);\n" % + last_arg.name) + file.Write(" }\n") + file.Write("\n") + + def WriteImmediateCmdSet(self, func, file): + """Overrriden from TypeHandler.""" + last_arg = func.GetLastOriginalArg() + file.Write(" void* Set(void* cmd%s) {\n" % + func.MakeTypedOriginalArgString("_", True)) + file.Write(" static_cast<ValueType*>(cmd)->Init(%s);\n" % + func.MakeOriginalArgString("_")) + file.Write(" const uint32 size = ComputeSize(_%s);\n" % last_arg.name) + file.Write(" return NextImmediateCmdAddressTotalSize<ValueType>(" + "cmd, size);\n") + file.Write(" }\n") + file.Write("\n") + + def WriteImmediateCmdHelper(self, func, file): + """Overrriden from TypeHandler.""" + args = func.MakeOriginalArgString("") + last_arg = func.GetLastOriginalArg() + file.Write(" void %s(%s) {\n" % + (func.name, func.MakeTypedOriginalArgString(""))) + file.Write(" const uint32 size = gles2::%s::ComputeSize(%s);\n" % + (func.name, last_arg.name)) + file.Write(" gles2::%s& c = GetImmediateCmdSpaceTotalSize<gles2::%s>(" + "size);\n" % + (func.name, func.name)) + file.Write(" c.Init(%s);\n" % args) + file.Write(" }\n\n") + + def WriteImmediateFormatTest(self, func, file): + """Overrriden from TypeHandler.""" + file.Write("TEST(GLES2FormatTest, %s) {\n" % func.name) + file.Write(" int8 buf[256] = { 0, };\n") + file.Write(" %s& cmd = *static_cast<%s*>(static_cast<void*>(&buf));\n" % + (func.name, func.name)) + file.Write(" static const char* const test_str = \"test string\";\n") + file.Write(" void* next_cmd = cmd.Set(\n") + file.Write(" &cmd") + all_but_last_arg = func.GetCmdArgs()[:-1] + value = 11 + for arg in all_but_last_arg: + file.Write(",\n static_cast<%s>(%d)" % (arg.type, value)) + value += 1 + file.Write(",\n test_str);\n") + value = 11 + file.Write(" EXPECT_EQ(%s::kCmdId, cmd.header.command);\n" % func.name) + file.Write(" EXPECT_EQ(sizeof(cmd) + // NOLINT\n") + file.Write(" RoundSizeToMultipleOfEntries(strlen(test_str)),\n") + file.Write(" cmd.header.size * 4);\n") + for arg in all_but_last_arg: + file.Write(" EXPECT_EQ(static_cast<%s>(%d), cmd.%s);\n" % + (arg.type, value, arg.name)) + value += 1 + file.Write(" // TODO(gman): check that string got copied.\n") + file.Write("}\n") + file.Write("\n") + + +class IsHandler(TypeHandler): + """Handler for glIs____ type and glGetError functions.""" + + def __init__(self): + TypeHandler.__init__(self) + + def InitFunction(self, func): + """Overrriden from TypeHandler.""" + func.AddCmdArg(CmdArg("result_shm_id", 'uint32')) + func.AddCmdArg(CmdArg("result_shm_offset", 'uint32')) + + def WriteServiceImplementation(self, func, file): + """Overrriden from TypeHandler.""" + file.Write( + "parse_error::ParseError GLES2Decoder::Handle%s(\n" % func.name) + file.Write( + " unsigned int arg_count, const gles2::%s& c) {\n" % func.name) + args = func.GetOriginalArgs() + for arg in args: + arg.WriteGetCode(file) + + file.Write(" %s* result_dst = GetSharedMemoryAs<%s*>(\n" % + (func.return_type, func.return_type)) + file.Write( + " c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));\n") + file.Write(" parse_error::ParseError result =\n") + file.Write(" Validate%s(this, arg_count%s);\n" % + (func.name, func.MakeOriginalArgString("", True))) + file.Write(" if (result != parse_error::kParseNoError) {\n") + file.Write(" return result;\n") + file.Write(" }\n") + file.Write(" *result_dst = %s(%s);\n" % + (func.GetGLFunctionName(), func.MakeOriginalArgString(""))) + file.Write(" return parse_error::kParseNoError;\n") + file.Write("}\n") + file.Write("\n") + + def WriteGLES2ImplementationHeader(self, func, file): + """Overrriden from TypeHandler.""" + file.Write("%s %s(%s) {\n" % + (func.return_type, func.original_name, + func.MakeTypedOriginalArgString(""))) + arg_string = func.MakeOriginalArgString("") + comma = "" + if len(arg_string) > 0: + comma = ", " + file.Write(" helper_->%s(%s%sshared_memory_.GetId(), 0);\n" % + (func.name, arg_string, comma)) + file.Write(" int32 token = helper_->InsertToken();\n") + file.Write(" helper_->WaitForToken(token);\n") + file.Write(" return *shared_memory_.GetAddressAs<%s*>(0);\n" % + func.return_type) + file.Write("}\n") + file.Write("\n") + + def WriteGLES2ImplementationImpl(self, func, file): + """Overrriden from TypeHandler.""" + pass + + +class STRnHandler(TypeHandler): + """Handler for GetProgramInfoLog, GetShaderInfoLog and GetShaderSource.""" + + def __init__(self): + TypeHandler.__init__(self) + + def WriteGLES2ImplementationHeader(self, func, file): + """Overrriden from TypeHandler.""" + file.Write("// TODO(gman): Implement this\n") + TypeHandler.WriteGLES2ImplementationHeader(self, func, file) + + +class FunctionInfo(object): + """Holds info about a function.""" + + def __init__(self, info, type_handler): + for key in info: + setattr(self, key, info[key]) + self.type_handler = type_handler + if not 'type' in info: + self.type = '' + + +class CmdArg(object): + """A class used to represent arguments at the command buffer level.""" + cmd_type_map_ = { + 'GLfloat': 'float', + 'GLclampf': 'float', + } + + def __init__(self, name, type): + self.name = name + self.type = type + + if type in self.cmd_type_map_: + self.cmd_type = self.cmd_type_map_[type] + else: + self.cmd_type = 'uint32' + + def WriteGetCode(self, file): + file.Write(" %s %s = static_cast<%s>(c.%s);\n" % + (self.type, self.name, self.type, self.name)) + + +class Argument(object): + """A class that represents a function argument.""" + + def __init__(self, name, type): + self.name = name + self.type = type + + def AddCmdArgs(self, args): + """Adds command arguments for this argument to the given list.""" + return args.append(CmdArg(self.name, self.type)) + + def WriteGetCode(self, file): + """Writes the code to get an argument from a command structure.""" + file.Write(" %s %s = static_cast<%s>(c.%s);\n" % + (self.type, self.name, self.type, self.name)) + + def WriteValidationCode(self, file): + """Writes the validation code for an argument.""" + pass + + def WriteGetAddress(self, file): + """Writes the code to get the address this argument refers to.""" + pass + + def GetImmediateVersion(self): + """Gets the immediate version of this argument.""" + return self + + +class ImmediatePointerArgument(Argument): + """A class that represents an immediate argument to a function. + + An immediate argument is one where the data follows the command. + """ + + def __init__(self, name, type): + Argument.__init__(self, name, type) + + def AddCmdArgs(self, args): + """Overridden from Argument.""" + pass + + def WriteGetCode(self, file): + """Overridden from Argument.""" + file.Write( + " %s %s = GetImmediateDataAs<%s>(c);\n" % + (self.type, self.name, self.type)) + + def WriteValidationCode(self, file): + """Overridden from Argument.""" + file.Write(" if (%s == NULL) {\n" % self.name) + file.Write(" return parse_error::kParseOutOfBounds;\n") + file.Write(" }\n") + + def GetImmediateVersion(self): + """Overridden from Argument.""" + return None + + +class PointerArgument(Argument): + """A class that represents a pointer argument to a function.""" + + def __init__(self, name, type): + Argument.__init__(self, name, type) + + def AddCmdArgs(self, args): + """Overridden from Argument.""" + args.append(CmdArg("%s_shm_id" % self.name, 'uint32')) + args.append(CmdArg("%s_shm_offset" % self.name, 'uint32')) + + def WriteGetCode(self, file): + """Overridden from Argument.""" + file.Write( + " %s %s = GetSharedMemoryAs<%s>(\n" % + (self.type, self.name, self.type)) + file.Write( + " c.%s_shm_id, c.%s_shm_offset, 0 /* TODO(gman): size */);\n" % + (self.name, self.name)) + + def WriteGetAddress(self, file): + """Overridden from Argument.""" + file.Write( + " %s %s = GetSharedMemoryAs<%s>(\n" % + (self.type, self.name, self.type)) + file.Write( + " %s_shm_id, %s_shm_offset, %s_size);\n" % + (self.name, self.name, self.name)) + + def WriteValidationCode(self, file): + """Overridden from Argument.""" + file.Write(" if (%s == NULL) {\n" % self.name) + file.Write(" return parse_error::kParseOutOfBounds;\n") + file.Write(" }\n") + + def GetImmediateVersion(self): + """Overridden from Argument.""" + return ImmediatePointerArgument(self.name, self.type) + + +class Function(object): + """A class that represents a function.""" + + def __init__(self, name, info, return_type, original_args, args_for_cmds, + cmd_args, num_pointer_args): + self.name = name + self.original_name = name + self.info = info + self.type_handler = info.type_handler + self.return_type = return_type + self.original_args = original_args + self.num_pointer_args = num_pointer_args + self.can_auto_generate = num_pointer_args == 0 and return_type == "void" + self.cmd_args = cmd_args + self.args_for_cmds = args_for_cmds + self.type_handler.InitFunction(self) + + def IsType(self, type_name): + """Returns true if function is a certain type.""" + return self.info.type == type_name + + def GetInfo(self, name): + """Returns a value from the function info for this function.""" + if hasattr(self.info, name): + return getattr(self.info, name) + return None + + def GetGLFunctionName(self): + """Gets the function to call to execute GL for this command.""" + if self.GetInfo('DecoderFunc'): + return self.GetInfo('DecoderFunc') + return "gl%s" % self.original_name + + def AddCmdArg(self, arg): + """Adds a cmd argument to this function.""" + self.cmd_args.append(arg) + + def GetCmdArgs(self): + """Gets the command args for this function.""" + return self.cmd_args + + def GetOriginalArgs(self): + """Gets the original arguments to this function.""" + return self.original_args + + def GetLastOriginalArg(self): + """Gets the last original argument to this function.""" + return self.original_args[len(self.original_args) - 1] + + def __GetArgList(self, arg_string, add_comma): + """Adds a comma if arg_string is not empty and add_comma is true.""" + comma = "" + if add_comma and len(arg_string): + comma = ", " + return "%s%s" % (comma, arg_string) + + def MakeTypedOriginalArgString(self, prefix, add_comma = False): + """Gets a list of arguments as they arg in GL.""" + args = self.GetOriginalArgs() + arg_string = ", ".join( + ["%s %s%s" % (arg.type, prefix, arg.name) for arg in args]) + return self.__GetArgList(arg_string, add_comma) + + def MakeOriginalArgString(self, prefix, add_comma = False): + """Gets the list of arguments as they are in GL.""" + args = self.GetOriginalArgs() + arg_string = ", ".join( + ["%s%s" % (prefix, arg.name) for arg in args]) + return self.__GetArgList(arg_string, add_comma) + + def MakeTypedCmdArgString(self, prefix, add_comma = False): + """Gets a typed list of arguments as they need to be for command buffers.""" + args = self.GetCmdArgs() + arg_string = ", ".join( + ["%s %s%s" % (arg.type, prefix, arg.name) for arg in args]) + return self.__GetArgList(arg_string, add_comma) + + def MakeCmdArgString(self, prefix, add_comma = False): + """Gets the list of arguments as they need to be for command buffers.""" + args = self.GetCmdArgs() + arg_string = ", ".join( + ["%s%s" % (prefix, arg.name) for arg in args]) + return self.__GetArgList(arg_string, add_comma) + + def WriteHandlerImplementation(self, file): + """Writes the handler implementation for this command.""" + self.type_handler.WriteHandlerImplementation(self, file) + + def WriteValidationCode(self, file): + """Writes the validation code for a command.""" + pass + + def WriteCmdArgFlag(self, file): + """Writes the cmd kArgFlags constant.""" + file.Write(" static const cmd::ArgFlags kArgFlags = cmd::kFixed;\n") + + def WriteCmdComputeSize(self, file): + """Writes the ComputeSize function for the command.""" + file.Write(" static uint32 ComputeSize() {\n") + file.Write( + " return static_cast<uint32>(sizeof(ValueType)); // NOLINT\n") + file.Write(" }\n") + file.Write("\n") + + def WriteCmdSetHeader(self, file): + """Writes the cmd's SetHeader function.""" + file.Write(" void SetHeader() {\n") + file.Write(" header.SetCmd<ValueType>();\n") + file.Write(" }\n") + file.Write("\n") + + def WriteCmdInit(self, file): + """Writes the cmd's Init function.""" + file.Write(" void Init(%s) {\n" % self.MakeTypedCmdArgString("_")) + file.Write(" SetHeader();\n") + args = self.GetCmdArgs() + for arg in args: + file.Write(" %s = _%s;\n" % (arg.name, arg.name)) + file.Write(" }\n") + file.Write("\n") + + def WriteCmdSet(self, file): + """Writes the cmd's Set function.""" + copy_args = self.MakeCmdArgString("_", False) + file.Write(" void* Set(void* cmd%s) {\n" % + self.MakeTypedCmdArgString("_", True)) + file.Write(" static_cast<ValueType*>(cmd)->Init(%s);\n" % copy_args) + file.Write(" return NextCmdAddress<ValueType>(cmd);\n") + file.Write(" }\n") + file.Write("\n") + + def WriteStruct(self, file): + """Writes a structure that matched the arguments to the function.""" + file.Write("struct %s {\n" % self.name) + file.Write(" typedef %s ValueType;\n" % self.name) + file.Write(" static const CommandId kCmdId = k%s;\n" % self.name) + self.WriteCmdArgFlag(file) + file.Write("\n") + + self.WriteCmdComputeSize(file) + self.WriteCmdSetHeader(file) + self.WriteCmdInit(file) + self.WriteCmdSet(file) + + file.Write(" command_buffer::CommandHeader header;\n") + args = self.GetCmdArgs() + for arg in args: + file.Write(" %s %s;\n" % (arg.cmd_type, arg.name)) + file.Write("};\n") + file.Write("\n") + + size = len(args) * _SIZE_OF_UINT32 + _SIZE_OF_COMMAND_HEADER + file.Write("COMPILE_ASSERT(sizeof(%s) == %d,\n" % (self.name, size)) + file.Write(" Sizeof_%s_is_not_%d);\n" % (self.name, size)) + file.Write("COMPILE_ASSERT(offsetof(%s, header) == 0,\n" % self.name) + file.Write(" OffsetOf_%s_header_not_0);\n" % self.name) + offset = _SIZE_OF_COMMAND_HEADER + for arg in args: + file.Write("COMPILE_ASSERT(offsetof(%s, %s) == %d,\n" % + (self.name, arg.name, offset)) + file.Write(" OffsetOf_%s_%s_not_%d);\n" % + (self.name, arg.name, offset)) + offset += _SIZE_OF_UINT32 + file.Write("\n") + + def WriteCmdHelper(self, file): + """Writes the cmd's helper.""" + args = self.MakeCmdArgString("") + file.Write(" void %s(%s) {\n" % + (self.name, self.MakeTypedCmdArgString(""))) + file.Write(" gles2::%s& c = GetCmdSpace<gles2::%s>();\n" % + (self.name, self.name)) + file.Write(" c.Init(%s);\n" % args) + file.Write(" }\n\n") + + def WriteServiceImplementation(self, file): + """Writes the service implementation for a command.""" + self.type_handler.WriteServiceImplementation(self, file) + + def WriteGLES2ImplementationHeader(self, file): + """Writes the GLES2 Implemention declaration.""" + self.type_handler.WriteGLES2ImplementationHeader(self, file) + + def WriteGLES2ImplementationImpl(self, file): + """Writes the GLES2 Implemention definition.""" + self.type_handler.WriteGLES2ImplementationImpl(self, file) + + def WriteFormatTest(self, file): + """Writes the cmd's format test.""" + self.type_handler.WriteFormatTest(self, file) + + +class ImmediateFunction(Function): + """A class that represnets an immediate function command.""" + + def __init__(self, func): + new_args = [] + for arg in func.GetOriginalArgs(): + new_arg = arg.GetImmediateVersion() + if new_arg: + new_args.append(new_arg) + + cmd_args = [] + new_args_for_cmds = [] + for arg in func.args_for_cmds: + new_arg = arg.GetImmediateVersion() + if new_arg: + new_args_for_cmds.append(new_arg) + new_arg.AddCmdArgs(cmd_args) + + Function.__init__( + self, + "%sImmediate" % func.name, + func.info, + func.return_type, + new_args, + new_args_for_cmds, + cmd_args, + 0) + self.original_name = func.name + + def WriteServiceImplementation(self, file): + """Overridden from Function""" + self.type_handler.WriteImmediateServiceImplementation(self, file) + + def WriteHandlerImplementation(self, file): + """Overridden from Function""" + self.type_handler.WriteImmediateHandlerImplementation(self, file) + + def WriteValidationCode(self, file): + """Overridden from Function""" + self.type_handler.WriteImmediateValidationCode(self, file) + + def WriteCmdArgFlag(self, file): + """Overridden from Function""" + file.Write(" static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN;\n") + + def WriteCmdComputeSize(self, file): + """Overridden from Function""" + self.type_handler.WriteImmediateCmdComputeSize(self, file) + + def WriteCmdSetHeader(self, file): + """Overridden from Function""" + self.type_handler.WriteImmediateCmdSetHeader(self, file) + + def WriteCmdInit(self, file): + """Overridden from Function""" + self.type_handler.WriteImmediateCmdInit(self, file) + + def WriteCmdSet(self, file): + """Overridden from Function""" + self.type_handler.WriteImmediateCmdSet(self, file) + + def WriteCmdHelper(self, file): + """Overridden from Function""" + self.type_handler.WriteImmediateCmdHelper(self, file) + + def WriteFormatTest(self, file): + """Overridden from Function""" + self.type_handler.WriteImmediateFormatTest(self, file) + + +class GLGenerator(object): + """A class to generate GL command buffers.""" + + _function_re = re.compile(r'GL_APICALL(.*?)GL_APIENTRY (.*?) \((.*?)\);') + _non_alnum_re = re.compile(r'[^a-zA-Z0-9]') + + def __init__(self, verbose): + self.original_functions = [] + self.functions = [] + self.verbose = verbose + self._function_info = {} + self._empty_type_handler = TypeHandler() + self._empty_function_info = FunctionInfo({}, self._empty_type_handler) + + self._type_handlers = { + 'Create': CreateHandler(), + 'Custom': CustomHandler(), + 'Data': DataHandler(), + 'DELn': DELnHandler(), + 'GENn': GENnHandler(), + 'GETn': GETnHandler(), + 'GLchar': GLcharHandler(), + 'Is': IsHandler(), + 'Manual': ManualHandler(), + 'PUT': PUTHandler(), + 'PUTn': PUTnHandler(), + 'STRn': STRnHandler(), + 'Todo': TodoHandler(), + } + + for func_name in _FUNCTION_INFO: + info = _FUNCTION_INFO[func_name] + type = '' + if 'type' in info: + type = info['type'] + self._function_info[func_name] = FunctionInfo(info, + self.GetTypeHandler(type)) + + def AddFunction(self, func): + """Adds a function.""" + self.functions.append(func) + + def GetTypeHandler(self, name): + """Gets a type info for the given type.""" + if name in self._type_handlers: + return self._type_handlers[name] + return self._empty_type_handler + + def GetFunctionInfo(self, name): + """Gets a type info for the given function name.""" + if name in self._function_info: + return self._function_info[name] + return self._empty_function_info + + def Log(self, msg): + """Prints something if verbose is true.""" + if self.verbose: + print msg + + def WriteHeader(self, file): + """Writes header to file""" + file.Write( + "// This file is auto-generated. DO NOT EDIT!\n" + "\n") + + def WriteLicense(self, file): + """Writes the license.""" + file.Write(_LICENSE) + + def WriteNamespaceOpen(self, file): + """Writes the code for the namespace.""" + file.Write("namespace command_buffer {\n") + file.Write("namespace gles2 {\n") + file.Write("\n") + + def WriteNamespaceClose(self, file): + """Writes the code to close the namespace.""" + file.Write("} // namespace gles2\n") + file.Write("} // namespace command_buffer\n") + file.Write("\n") + + def MakeGuard(self, filename): + """Creates a header guard id.""" + base = os.path.dirname(os.path.dirname(os.path.dirname( + os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))) + hpath = os.path.abspath(filename)[len(base) + 1:] + return self._non_alnum_re.sub('_', hpath).upper() + + def ParseArgs(self, arg_string): + """Parses a function arg string.""" + args = [] + num_pointer_args = 0 + parts = arg_string.split(',') + for arg in parts: + arg_parts = arg.split() + if len(arg_parts) == 1 and arg_parts[0] == 'void': + pass + # Is this a pointer argument? + elif arg.find('*') >= 0: + num_pointer_args += 1 + args.append(PointerArgument( + arg_parts[-1], + " ".join(arg_parts[0:-1]))) + else: + args.append(Argument( + arg_parts[-1], + " ".join(arg_parts[0:-1]))) + return (args, num_pointer_args) + + def ParseGLH(self, filename): + """Parses the GL2.h file and extracts the functions""" + file = open(filename, "r") + for line in file.readlines(): + match = self._function_re.match(line) + if match: + func_name = match.group(2)[2:] + func_info = self.GetFunctionInfo(func_name) + if func_info.type != 'Noop': + return_type = match.group(1).strip() + arg_string = match.group(3) + (args, num_pointer_args) = self.ParseArgs(arg_string) + args_for_cmds = args + if hasattr(func_info, 'cmd_args'): + (args_for_cmds, num_pointer_args) = ( + self.ParseArgs(getattr(func_info, 'cmd_args'))) + cmd_args = [] + for arg in args_for_cmds: + arg.AddCmdArgs(cmd_args) + f = Function(func_name, func_info, return_type, args, args_for_cmds, + cmd_args, num_pointer_args) + self.original_functions.append(f) + self.AddFunction(f) + f.type_handler.AddImmediateFunction(self, f) + file.close() + + self.Log("Auto Generated Functions : %d" % + len([f for f in self.functions if f.can_auto_generate or + (not f.IsType('') and not f.IsType('Custom') and + not f.IsType('Todo'))])) + + funcs = [f for f in self.functions if not f.can_auto_generate and + (f.IsType('') or f.IsType('Custom') or f.IsType('Todo'))] + self.Log("Non Auto Generated Functions: %d" % len(funcs)) + + for f in funcs: + self.Log(" %-10s %-20s gl%s" % (f.info.type, f.return_type, f.name)) + + def WriteFormat(self, filename): + """Writes the command buffer format""" + guard = self.MakeGuard(filename) + file = CWriter(filename) + self.WriteHeader(file) + file.Write("\n") + file.Write("#ifndef %s\n" % guard) + file.Write("#define %s\n" % guard) + file.Write("\n") + file.Write( + "#include \"gpu/command_buffer/common/gles2_cmd_utils.h\"\n") + file.Write( + "#include \"gpu/command_buffer/common/cmd_buffer_common.h\"\n") + file.Write("\n") + + self.WriteNamespaceOpen(file) + + file.Write("#define GLES2_COMMAND_LIST(OP) \\\n") + command_id = _FIRST_SPECIFIC_COMMAND_ID + for func in self.functions: + file.Write(" %-60s /* %d */ \\\n" % ("OP(%s)" % func.name, command_id)) + command_id += 1 + file.Write("\n") + + file.Write("enum CommandId {\n") + file.Write(" kStartPoint = cmd::kLastCommonId, " + "// All GLES2 commands start after this.\n") + file.Write("#define GLES2_CMD_OP(name) k ## name,\n") + file.Write(" GLES2_COMMAND_LIST(GLES2_CMD_OP)\n") + file.Write("#undef GLES2_CMD_OP\n") + file.Write(" kNumCommands\n") + file.Write("};\n") + file.Write("\n") + file.Write("#pragma pack(push, 1)\n") + file.Write("\n") + + for func in self.functions: + func.WriteStruct(file) + + self.WriteNamespaceClose(file) + + file.Write("#pragma pack(pop)\n") + file.Write("\n") + file.Write("#endif // %s\n" % guard) + file.Close() + + def WriteFormatTest(self, filename): + """Writes the command buffer format test.""" + file = CWriter(filename) + self.WriteHeader(file) + file.Write("// This file contains unit tests for gles2 commmands\n") + file.Write("// It is included by gles2_cmd_format_test.cc\n") + file.Write("\n") + + for func in self.functions: + func.WriteFormatTest(file) + + file.Close() + + def WriteCommandIdTest(self, filename): + """Writes the command id test.""" + file = CWriter(filename) + self.WriteLicense(file) + file.Write("// This file contains unit tests for gles2 commmand ids\n") + file.Write("\n") + file.Write("#include \"tests/common/win/testing_common.h\"\n") + file.Write("#include \"gpu/command_buffer/common/gles2_cmd_format.h\"\n") + file.Write("\n") + + self.WriteNamespaceOpen(file) + + file.Write("// *** These IDs MUST NOT CHANGE!!! ***\n") + file.Write("// Changing them will break all client programs.\n") + file.Write("TEST(GLES2CommandIdTest, CommandIdsMatch) {\n") + command_id = 1024 + for func in self.functions: + file.Write(" COMPILE_ASSERT(%s::kCmdId == %d,\n" % + (func.name, command_id)) + file.Write(" GLES2_%s_kCmdId_mismatch);\n" % func.name) + command_id += 1 + + file.Write("}\n") + + self.WriteNamespaceClose(file) + + file.Close() + + def WriteCmdHelperHeader(self, filename): + """Writes the gles2 command helper.""" + file = CWriter(filename) + + for func in self.functions: + func.WriteCmdHelper(file) + + file.Close() + + def WriteServiceImplementation(self, filename): + """Writes the service decorder implementation.""" + file = CWriter(filename) + self.WriteHeader(file) + file.Write("// It is included by gles2_cmd_decoder.cc\n") + file.Write("\n") + + for func in self.functions: + func.WriteServiceImplementation(file) + + file.Close() + + def WriteServiceValidation(self, filename): + file = CWriter(filename) + self.WriteLicense(file) + file.Write("\n") + self.WriteNamespaceOpen(file) + file.Write("namespace {\n") + file.Write("\n") + for func in self.functions: + file.Write("parse_error::ParseError Validate%s(\n" % func.name) + file.Write(" GLES2Decoder* decoder, unsigned int arg_count%s) {\n" % + func.MakeTypedOriginalArgString("", True)) + for arg in func.GetOriginalArgs(): + arg.WriteValidationCode(file) + func.WriteValidationCode(file) + file.Write(" return parse_error::kParseNoError;\n") + file.Write("}\n") + file.Write("} // anonymous namespace\n") + self.WriteNamespaceClose(file) + file.Close() + + def WriteGLES2LibHeader(self, filename): + """Writes the GLES2 lib header.""" + file = CWriter(filename) + self.WriteHeader(file) + file.Write("\n") + file.Write("// These functions emluate GLES2 over command buffers.\n") + file.Write("\n") + file.Write("\n") + + for func in self.original_functions: + file.Write("inline %s gl%s(%s) {\n" % + (func.return_type, func.name, + func.MakeTypedOriginalArgString(""))) + return_string = "return " + if func.return_type == "void": + return_string = "" + file.Write(" %sg_gl_impl->%s(%s);\n" % + (return_string, func.original_name, + func.MakeOriginalArgString(""))) + file.Write("}\n") + + file.Write("\n") + + file.Close() + + def WriteGLES2ImplementationHeader(self, filename): + """Writes the GLES2 helper header.""" + file = CWriter(filename) + self.WriteHeader(file) + file.Write( + "// This file is included by gles2_implementation.h to declare the\n") + file.Write("// GL api functions.\n") + for func in self.original_functions: + func.WriteGLES2ImplementationHeader(file) + file.Close() + + def WriteGLES2ImplementationImpl(self, filename): + """Writes the gles2 helper implementation.""" + file = CWriter(filename) + self.WriteLicense(file) + file.Write("\n") + file.Write("// A class to emluate GLES2 over command buffers.\n") + file.Write("\n") + file.Write( + "#include \"gpu/command_buffer/client/gles2_implementation.h\"\n") + file.Write("\n") + self.WriteNamespaceOpen(file) + for func in self.original_functions: + func.WriteGLES2ImplementationImpl(file) + file.Write("\n") + + self.WriteNamespaceClose(file) + file.Close() + + +def main(argv): + """This is the main function.""" + parser = OptionParser() + parser.add_option( + "-g", "--generate-implementation-templates", action="store_true", + help="generates files that are generally hand edited..") + parser.add_option( + "--generate-command-id-tests", action="store_true", + help="generate tests for commands ids. Commands MUST not change ID!") + parser.add_option( + "-v", "--verbose", action="store_true", + help="prints more output.") + + (options, args) = parser.parse_args(args=argv) + + gen = GLGenerator(options.verbose) + gen.ParseGLH("common/GLES2/gl2.h") + gen.WriteFormat("common/gles2_cmd_format.h") + gen.WriteFormatTest("common/gles2_cmd_format_test_autogen.h") + gen.WriteGLES2ImplementationHeader("client/gles2_implementation_autogen.h") + gen.WriteGLES2LibHeader("client/gles2_lib_autogen.h") + gen.WriteCmdHelperHeader("client/gles2_cmd_helper_autogen.h") + gen.WriteServiceImplementation("service/gles2_cmd_decoder_autogen.h") + + if options.generate_implementation_templates: + gen.WriteGLES2ImplementationImpl("client/gles2_implementation_gen.h") + gen.WriteServiceValidation("service/gles2_cmd_decoder_validate.h") + + if options.generate_command_id_tests: + gen.WriteCommandIdTest("common/gles2_cmd_id_test.cc") + + +if __name__ == '__main__': + main(sys.argv[1:]) + diff --git a/o3d/gpu/command_buffer/client/cmd_buffer_helper.h b/o3d/gpu/command_buffer/client/cmd_buffer_helper.h index d63a53e..f416baa 100644 --- a/o3d/gpu/command_buffer/client/cmd_buffer_helper.h +++ b/o3d/gpu/command_buffer/client/cmd_buffer_helper.h @@ -162,9 +162,18 @@ class CommandBufferHelper { // Typed version of GetSpace for immediate commands. template <typename T> - T& GetImmediateCmdSpace(size_t space) { + T& GetImmediateCmdSpace(size_t data_space) { COMPILE_ASSERT(T::kArgFlags == cmd::kAtLeastN, Cmd_kArgFlags_not_kAtLeastN); - uint32 space_needed = ComputeNumEntries(sizeof(T) + space); + uint32 space_needed = ComputeNumEntries(sizeof(T) + data_space); + void* data = GetSpace(space_needed); + return *reinterpret_cast<T*>(data); + } + + // Typed version of GetSpace for immediate commands. + template <typename T> + T& GetImmediateCmdSpaceTotalSize(size_t total_space) { + COMPILE_ASSERT(T::kArgFlags == cmd::kAtLeastN, Cmd_kArgFlags_not_kAtLeastN); + uint32 space_needed = ComputeNumEntries(total_space); void* data = GetSpace(space_needed); return *reinterpret_cast<T*>(data); } diff --git a/o3d/gpu/command_buffer/client/gles2_cmd_helper.cc b/o3d/gpu/command_buffer/client/gles2_cmd_helper.cc new file mode 100644 index 0000000..1dff914 --- /dev/null +++ b/o3d/gpu/command_buffer/client/gles2_cmd_helper.cc @@ -0,0 +1,14 @@ +// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "gpu/command_buffer/client/gles2_cmd_helper.h" + +namespace command_buffer { + +// Currently this is a place holder. + +} // namespace command_buffer + + + diff --git a/o3d/gpu/command_buffer/client/gles2_cmd_helper.h b/o3d/gpu/command_buffer/client/gles2_cmd_helper.h new file mode 100644 index 0000000..87f3054 --- /dev/null +++ b/o3d/gpu/command_buffer/client/gles2_cmd_helper.h @@ -0,0 +1,39 @@ +// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef GPU_COMMAND_BUFFER_CLIENT_GLES2_CMD_HELPER_H +#define GPU_COMMAND_BUFFER_CLIENT_GLES2_CMD_HELPER_H + +#include "gpu/command_buffer/client/cmd_buffer_helper.h" +#include "gpu/command_buffer/common/gles2_cmd_utils.h" +#include "gpu/command_buffer/common/gles2_cmd_format.h" + +namespace command_buffer { +namespace gles2 { + +// A class that helps write GL command buffers. +class GLES2CmdHelper : public CommandBufferHelper { + public: + GLES2CmdHelper( + NPP npp, + const gpu_plugin::NPObjectPointer<gpu_plugin::CommandBuffer>& + command_buffer) + : CommandBufferHelper(npp, command_buffer) { + } + virtual ~GLES2CmdHelper() { + } + + // Include the auto-generated part of this class. We split this because it + // means we can easily edit the non-auto generated parts right here in this + // file instead of having to edit some template or the code generator. + #include "gpu/command_buffer/client/gles2_cmd_helper_autogen.h" + + DISALLOW_COPY_AND_ASSIGN(GLES2CmdHelper); +}; + +} // namespace gles2 +} // namespace command_buffer + +#endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_CMD_HELPER_H + diff --git a/o3d/gpu/command_buffer/client/gles2_cmd_helper_autogen.h b/o3d/gpu/command_buffer/client/gles2_cmd_helper_autogen.h new file mode 100644 index 0000000..9af93cd --- /dev/null +++ b/o3d/gpu/command_buffer/client/gles2_cmd_helper_autogen.h @@ -0,0 +1,1138 @@ + void ActiveTexture(GLenum texture) { + gles2::ActiveTexture& c = GetCmdSpace<gles2::ActiveTexture>(); + c.Init(texture); + } + + void AttachShader(GLuint program, GLuint shader) { + gles2::AttachShader& c = GetCmdSpace<gles2::AttachShader>(); + c.Init(program, shader); + } + + void BindAttribLocation( + GLuint program, GLuint index, uint32 name_shm_id, uint32 name_shm_offset, + uint32 data_size) { + gles2::BindAttribLocation& c = GetCmdSpace<gles2::BindAttribLocation>(); + c.Init(program, index, name_shm_id, name_shm_offset, data_size); + } + + void BindAttribLocationImmediate( + GLuint program, GLuint index, const char* name) { + const uint32 size = gles2::BindAttribLocationImmediate::ComputeSize(name); + gles2::BindAttribLocationImmediate& c = + GetImmediateCmdSpaceTotalSize<gles2::BindAttribLocationImmediate>( + size); + c.Init(program, index, name); + } + + void BindBuffer(GLenum target, GLuint buffer) { + gles2::BindBuffer& c = GetCmdSpace<gles2::BindBuffer>(); + c.Init(target, buffer); + } + + void BindFramebuffer(GLenum target, GLuint framebuffer) { + gles2::BindFramebuffer& c = GetCmdSpace<gles2::BindFramebuffer>(); + c.Init(target, framebuffer); + } + + void BindRenderbuffer(GLenum target, GLuint renderbuffer) { + gles2::BindRenderbuffer& c = GetCmdSpace<gles2::BindRenderbuffer>(); + c.Init(target, renderbuffer); + } + + void BindTexture(GLenum target, GLuint texture) { + gles2::BindTexture& c = GetCmdSpace<gles2::BindTexture>(); + c.Init(target, texture); + } + + void BlendColor( + GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) { + gles2::BlendColor& c = GetCmdSpace<gles2::BlendColor>(); + c.Init(red, green, blue, alpha); + } + + void BlendEquation(GLenum mode) { + gles2::BlendEquation& c = GetCmdSpace<gles2::BlendEquation>(); + c.Init(mode); + } + + void BlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) { + gles2::BlendEquationSeparate& c = + GetCmdSpace<gles2::BlendEquationSeparate>(); + c.Init(modeRGB, modeAlpha); + } + + void BlendFunc(GLenum sfactor, GLenum dfactor) { + gles2::BlendFunc& c = GetCmdSpace<gles2::BlendFunc>(); + c.Init(sfactor, dfactor); + } + + void BlendFuncSeparate( + GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) { + gles2::BlendFuncSeparate& c = GetCmdSpace<gles2::BlendFuncSeparate>(); + c.Init(srcRGB, dstRGB, srcAlpha, dstAlpha); + } + + void BufferData( + GLenum target, GLsizeiptr size, uint32 data_shm_id, + uint32 data_shm_offset, GLenum usage) { + gles2::BufferData& c = GetCmdSpace<gles2::BufferData>(); + c.Init(target, size, data_shm_id, data_shm_offset, usage); + } + + void BufferDataImmediate(GLenum target, GLsizeiptr size, GLenum usage) { + const uint32 s = 0; // TODO(gman): compute correct size + gles2::BufferDataImmediate& c = + GetImmediateCmdSpaceTotalSize<gles2::BufferDataImmediate>(s); + c.Init(target, size, usage); + } + + void BufferSubData( + GLenum target, GLintptr offset, GLsizeiptr size, uint32 data_shm_id, + uint32 data_shm_offset) { + gles2::BufferSubData& c = GetCmdSpace<gles2::BufferSubData>(); + c.Init(target, offset, size, data_shm_id, data_shm_offset); + } + + void BufferSubDataImmediate( + GLenum target, GLintptr offset, GLsizeiptr size) { + const uint32 s = 0; // TODO(gman): compute correct size + gles2::BufferSubDataImmediate& c = + GetImmediateCmdSpaceTotalSize<gles2::BufferSubDataImmediate>(s); + c.Init(target, offset, size); + } + + void CheckFramebufferStatus(GLenum target) { + gles2::CheckFramebufferStatus& c = + GetCmdSpace<gles2::CheckFramebufferStatus>(); + c.Init(target); + } + + void Clear(GLbitfield mask) { + gles2::Clear& c = GetCmdSpace<gles2::Clear>(); + c.Init(mask); + } + + void ClearColor( + GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) { + gles2::ClearColor& c = GetCmdSpace<gles2::ClearColor>(); + c.Init(red, green, blue, alpha); + } + + void ClearDepthf(GLclampf depth) { + gles2::ClearDepthf& c = GetCmdSpace<gles2::ClearDepthf>(); + c.Init(depth); + } + + void ClearStencil(GLint s) { + gles2::ClearStencil& c = GetCmdSpace<gles2::ClearStencil>(); + c.Init(s); + } + + void ColorMask( + GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) { + gles2::ColorMask& c = GetCmdSpace<gles2::ColorMask>(); + c.Init(red, green, blue, alpha); + } + + void CompileShader(GLuint shader) { + gles2::CompileShader& c = GetCmdSpace<gles2::CompileShader>(); + c.Init(shader); + } + + void CompressedTexImage2D( + GLenum target, GLint level, GLenum internalformat, GLsizei width, + GLsizei height, GLint border, GLsizei imageSize, uint32 data_shm_id, + uint32 data_shm_offset) { + gles2::CompressedTexImage2D& c = + GetCmdSpace<gles2::CompressedTexImage2D>(); + c.Init( + target, level, internalformat, width, height, border, imageSize, + data_shm_id, data_shm_offset); + } + + void CompressedTexImage2DImmediate( + GLenum target, GLint level, GLenum internalformat, GLsizei width, + GLsizei height, GLint border, GLsizei imageSize) { + const uint32 s = 0; // TODO(gman): compute correct size + gles2::CompressedTexImage2DImmediate& c = + GetImmediateCmdSpaceTotalSize<gles2::CompressedTexImage2DImmediate>(s); + c.Init(target, level, internalformat, width, height, border, imageSize); + } + + void CompressedTexSubImage2D( + GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, + GLsizei height, GLenum format, GLsizei imageSize, uint32 data_shm_id, + uint32 data_shm_offset) { + gles2::CompressedTexSubImage2D& c = + GetCmdSpace<gles2::CompressedTexSubImage2D>(); + c.Init( + target, level, xoffset, yoffset, width, height, format, imageSize, + data_shm_id, data_shm_offset); + } + + void CompressedTexSubImage2DImmediate( + GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, + GLsizei height, GLenum format, GLsizei imageSize) { + const uint32 s = 0; // TODO(gman): compute correct size + gles2::CompressedTexSubImage2DImmediate& c = + GetImmediateCmdSpaceTotalSize<gles2::CompressedTexSubImage2DImmediate>( + s); + c.Init(target, level, xoffset, yoffset, width, height, format, imageSize); + } + + void CopyTexImage2D( + GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, + GLsizei width, GLsizei height, GLint border) { + gles2::CopyTexImage2D& c = GetCmdSpace<gles2::CopyTexImage2D>(); + c.Init(target, level, internalformat, x, y, width, height, border); + } + + void CopyTexSubImage2D( + GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, + GLint y, GLsizei width, GLsizei height) { + gles2::CopyTexSubImage2D& c = GetCmdSpace<gles2::CopyTexSubImage2D>(); + c.Init(target, level, xoffset, yoffset, x, y, width, height); + } + + void CreateProgram(uint32 client_id) { + gles2::CreateProgram& c = GetCmdSpace<gles2::CreateProgram>(); + c.Init(client_id); + } + + void CreateShader(GLenum type, uint32 client_id) { + gles2::CreateShader& c = GetCmdSpace<gles2::CreateShader>(); + c.Init(type, client_id); + } + + void CullFace(GLenum mode) { + gles2::CullFace& c = GetCmdSpace<gles2::CullFace>(); + c.Init(mode); + } + + void DeleteBuffers( + GLsizei n, uint32 buffers_shm_id, uint32 buffers_shm_offset) { + gles2::DeleteBuffers& c = GetCmdSpace<gles2::DeleteBuffers>(); + c.Init(n, buffers_shm_id, buffers_shm_offset); + } + + void DeleteBuffersImmediate(GLsizei n, const GLuint* buffers) { + const uint32 size = gles2::DeleteBuffersImmediate::ComputeSize(n); + gles2::DeleteBuffersImmediate& c = + GetImmediateCmdSpaceTotalSize<gles2::DeleteBuffersImmediate>(size); + c.Init(n, buffers); + } + + void DeleteFramebuffers( + GLsizei n, uint32 framebuffers_shm_id, uint32 framebuffers_shm_offset) { + gles2::DeleteFramebuffers& c = GetCmdSpace<gles2::DeleteFramebuffers>(); + c.Init(n, framebuffers_shm_id, framebuffers_shm_offset); + } + + void DeleteFramebuffersImmediate(GLsizei n, const GLuint* framebuffers) { + const uint32 size = gles2::DeleteFramebuffersImmediate::ComputeSize(n); + gles2::DeleteFramebuffersImmediate& c = + GetImmediateCmdSpaceTotalSize<gles2::DeleteFramebuffersImmediate>( + size); + c.Init(n, framebuffers); + } + + void DeleteProgram(GLuint program) { + gles2::DeleteProgram& c = GetCmdSpace<gles2::DeleteProgram>(); + c.Init(program); + } + + void DeleteRenderbuffers( + GLsizei n, uint32 renderbuffers_shm_id, + uint32 renderbuffers_shm_offset) { + gles2::DeleteRenderbuffers& c = GetCmdSpace<gles2::DeleteRenderbuffers>(); + c.Init(n, renderbuffers_shm_id, renderbuffers_shm_offset); + } + + void DeleteRenderbuffersImmediate(GLsizei n, const GLuint* renderbuffers) { + const uint32 size = gles2::DeleteRenderbuffersImmediate::ComputeSize(n); + gles2::DeleteRenderbuffersImmediate& c = + GetImmediateCmdSpaceTotalSize<gles2::DeleteRenderbuffersImmediate>( + size); + c.Init(n, renderbuffers); + } + + void DeleteShader(GLuint shader) { + gles2::DeleteShader& c = GetCmdSpace<gles2::DeleteShader>(); + c.Init(shader); + } + + void DeleteTextures( + GLsizei n, uint32 textures_shm_id, uint32 textures_shm_offset) { + gles2::DeleteTextures& c = GetCmdSpace<gles2::DeleteTextures>(); + c.Init(n, textures_shm_id, textures_shm_offset); + } + + void DeleteTexturesImmediate(GLsizei n, const GLuint* textures) { + const uint32 size = gles2::DeleteTexturesImmediate::ComputeSize(n); + gles2::DeleteTexturesImmediate& c = + GetImmediateCmdSpaceTotalSize<gles2::DeleteTexturesImmediate>(size); + c.Init(n, textures); + } + + void DepthFunc(GLenum func) { + gles2::DepthFunc& c = GetCmdSpace<gles2::DepthFunc>(); + c.Init(func); + } + + void DepthMask(GLboolean flag) { + gles2::DepthMask& c = GetCmdSpace<gles2::DepthMask>(); + c.Init(flag); + } + + void DepthRangef(GLclampf zNear, GLclampf zFar) { + gles2::DepthRangef& c = GetCmdSpace<gles2::DepthRangef>(); + c.Init(zNear, zFar); + } + + void DetachShader(GLuint program, GLuint shader) { + gles2::DetachShader& c = GetCmdSpace<gles2::DetachShader>(); + c.Init(program, shader); + } + + void Disable(GLenum cap) { + gles2::Disable& c = GetCmdSpace<gles2::Disable>(); + c.Init(cap); + } + + void DisableVertexAttribArray(GLuint index) { + gles2::DisableVertexAttribArray& c = + GetCmdSpace<gles2::DisableVertexAttribArray>(); + c.Init(index); + } + + void DrawArrays(GLenum mode, GLint first, GLsizei count) { + gles2::DrawArrays& c = GetCmdSpace<gles2::DrawArrays>(); + c.Init(mode, first, count); + } + + void DrawElements( + GLenum mode, GLsizei count, GLenum type, GLuint index_offset) { + gles2::DrawElements& c = GetCmdSpace<gles2::DrawElements>(); + c.Init(mode, count, type, index_offset); + } + + void Enable(GLenum cap) { + gles2::Enable& c = GetCmdSpace<gles2::Enable>(); + c.Init(cap); + } + + void EnableVertexAttribArray(GLuint index) { + gles2::EnableVertexAttribArray& c = + GetCmdSpace<gles2::EnableVertexAttribArray>(); + c.Init(index); + } + + void Finish() { + gles2::Finish& c = GetCmdSpace<gles2::Finish>(); + c.Init(); + } + + void Flush() { + gles2::Flush& c = GetCmdSpace<gles2::Flush>(); + c.Init(); + } + + void FramebufferRenderbuffer( + GLenum target, GLenum attachment, GLenum renderbuffertarget, + GLuint renderbuffer) { + gles2::FramebufferRenderbuffer& c = + GetCmdSpace<gles2::FramebufferRenderbuffer>(); + c.Init(target, attachment, renderbuffertarget, renderbuffer); + } + + void FramebufferTexture2D( + GLenum target, GLenum attachment, GLenum textarget, GLuint texture, + GLint level) { + gles2::FramebufferTexture2D& c = + GetCmdSpace<gles2::FramebufferTexture2D>(); + c.Init(target, attachment, textarget, texture, level); + } + + void FrontFace(GLenum mode) { + gles2::FrontFace& c = GetCmdSpace<gles2::FrontFace>(); + c.Init(mode); + } + + void GenBuffers( + GLsizei n, uint32 buffers_shm_id, uint32 buffers_shm_offset) { + gles2::GenBuffers& c = GetCmdSpace<gles2::GenBuffers>(); + c.Init(n, buffers_shm_id, buffers_shm_offset); + } + + void GenBuffersImmediate(GLsizei n, GLuint* buffers) { + const uint32 size = gles2::GenBuffersImmediate::ComputeSize(n); + gles2::GenBuffersImmediate& c = + GetImmediateCmdSpaceTotalSize<gles2::GenBuffersImmediate>(size); + c.Init(n, buffers); + } + + void GenerateMipmap(GLenum target) { + gles2::GenerateMipmap& c = GetCmdSpace<gles2::GenerateMipmap>(); + c.Init(target); + } + + void GenFramebuffers( + GLsizei n, uint32 framebuffers_shm_id, uint32 framebuffers_shm_offset) { + gles2::GenFramebuffers& c = GetCmdSpace<gles2::GenFramebuffers>(); + c.Init(n, framebuffers_shm_id, framebuffers_shm_offset); + } + + void GenFramebuffersImmediate(GLsizei n, GLuint* framebuffers) { + const uint32 size = gles2::GenFramebuffersImmediate::ComputeSize(n); + gles2::GenFramebuffersImmediate& c = + GetImmediateCmdSpaceTotalSize<gles2::GenFramebuffersImmediate>(size); + c.Init(n, framebuffers); + } + + void GenRenderbuffers( + GLsizei n, uint32 renderbuffers_shm_id, + uint32 renderbuffers_shm_offset) { + gles2::GenRenderbuffers& c = GetCmdSpace<gles2::GenRenderbuffers>(); + c.Init(n, renderbuffers_shm_id, renderbuffers_shm_offset); + } + + void GenRenderbuffersImmediate(GLsizei n, GLuint* renderbuffers) { + const uint32 size = gles2::GenRenderbuffersImmediate::ComputeSize(n); + gles2::GenRenderbuffersImmediate& c = + GetImmediateCmdSpaceTotalSize<gles2::GenRenderbuffersImmediate>(size); + c.Init(n, renderbuffers); + } + + void GenTextures( + GLsizei n, uint32 textures_shm_id, uint32 textures_shm_offset) { + gles2::GenTextures& c = GetCmdSpace<gles2::GenTextures>(); + c.Init(n, textures_shm_id, textures_shm_offset); + } + + void GenTexturesImmediate(GLsizei n, GLuint* textures) { + const uint32 size = gles2::GenTexturesImmediate::ComputeSize(n); + gles2::GenTexturesImmediate& c = + GetImmediateCmdSpaceTotalSize<gles2::GenTexturesImmediate>(size); + c.Init(n, textures); + } + + void GetActiveAttrib( + GLuint program, GLuint index, GLsizei bufsize, uint32 length_shm_id, + uint32 length_shm_offset, uint32 size_shm_id, uint32 size_shm_offset, + uint32 type_shm_id, uint32 type_shm_offset, uint32 name_shm_id, + uint32 name_shm_offset) { + gles2::GetActiveAttrib& c = GetCmdSpace<gles2::GetActiveAttrib>(); + c.Init( + program, index, bufsize, length_shm_id, length_shm_offset, size_shm_id, + size_shm_offset, type_shm_id, type_shm_offset, name_shm_id, + name_shm_offset); + } + + void GetActiveUniform( + GLuint program, GLuint index, GLsizei bufsize, uint32 length_shm_id, + uint32 length_shm_offset, uint32 size_shm_id, uint32 size_shm_offset, + uint32 type_shm_id, uint32 type_shm_offset, uint32 name_shm_id, + uint32 name_shm_offset) { + gles2::GetActiveUniform& c = GetCmdSpace<gles2::GetActiveUniform>(); + c.Init( + program, index, bufsize, length_shm_id, length_shm_offset, size_shm_id, + size_shm_offset, type_shm_id, type_shm_offset, name_shm_id, + name_shm_offset); + } + + void GetAttachedShaders( + GLuint program, GLsizei maxcount, uint32 count_shm_id, + uint32 count_shm_offset, uint32 shaders_shm_id, + uint32 shaders_shm_offset) { + gles2::GetAttachedShaders& c = GetCmdSpace<gles2::GetAttachedShaders>(); + c.Init( + program, maxcount, count_shm_id, count_shm_offset, shaders_shm_id, + shaders_shm_offset); + } + + void GetAttribLocation( + GLuint program, uint32 name_shm_id, uint32 name_shm_offset, + uint32 data_size) { + gles2::GetAttribLocation& c = GetCmdSpace<gles2::GetAttribLocation>(); + c.Init(program, name_shm_id, name_shm_offset, data_size); + } + + void GetAttribLocationImmediate(GLuint program, const char* name) { + const uint32 size = gles2::GetAttribLocationImmediate::ComputeSize(name); + gles2::GetAttribLocationImmediate& c = + GetImmediateCmdSpaceTotalSize<gles2::GetAttribLocationImmediate>(size); + c.Init(program, name); + } + + void GetBooleanv( + GLenum pname, uint32 params_shm_id, uint32 params_shm_offset) { + gles2::GetBooleanv& c = GetCmdSpace<gles2::GetBooleanv>(); + c.Init(pname, params_shm_id, params_shm_offset); + } + + void GetBufferParameteriv( + GLenum target, GLenum pname, uint32 params_shm_id, + uint32 params_shm_offset) { + gles2::GetBufferParameteriv& c = + GetCmdSpace<gles2::GetBufferParameteriv>(); + c.Init(target, pname, params_shm_id, params_shm_offset); + } + + void GetError(uint32 result_shm_id, uint32 result_shm_offset) { + gles2::GetError& c = GetCmdSpace<gles2::GetError>(); + c.Init(result_shm_id, result_shm_offset); + } + + void GetFloatv( + GLenum pname, uint32 params_shm_id, uint32 params_shm_offset) { + gles2::GetFloatv& c = GetCmdSpace<gles2::GetFloatv>(); + c.Init(pname, params_shm_id, params_shm_offset); + } + + void GetFramebufferAttachmentParameteriv( + GLenum target, GLenum attachment, GLenum pname, uint32 params_shm_id, + uint32 params_shm_offset) { + gles2::GetFramebufferAttachmentParameteriv& c = + GetCmdSpace<gles2::GetFramebufferAttachmentParameteriv>(); + c.Init(target, attachment, pname, params_shm_id, params_shm_offset); + } + + void GetIntegerv( + GLenum pname, uint32 params_shm_id, uint32 params_shm_offset) { + gles2::GetIntegerv& c = GetCmdSpace<gles2::GetIntegerv>(); + c.Init(pname, params_shm_id, params_shm_offset); + } + + void GetProgramiv( + GLuint program, GLenum pname, uint32 params_shm_id, + uint32 params_shm_offset) { + gles2::GetProgramiv& c = GetCmdSpace<gles2::GetProgramiv>(); + c.Init(program, pname, params_shm_id, params_shm_offset); + } + + void GetProgramInfoLog( + GLuint program, GLsizei bufsize, uint32 length_shm_id, + uint32 length_shm_offset, uint32 infolog_shm_id, + uint32 infolog_shm_offset) { + gles2::GetProgramInfoLog& c = GetCmdSpace<gles2::GetProgramInfoLog>(); + c.Init( + program, bufsize, length_shm_id, length_shm_offset, infolog_shm_id, + infolog_shm_offset); + } + + void GetRenderbufferParameteriv( + GLenum target, GLenum pname, uint32 params_shm_id, + uint32 params_shm_offset) { + gles2::GetRenderbufferParameteriv& c = + GetCmdSpace<gles2::GetRenderbufferParameteriv>(); + c.Init(target, pname, params_shm_id, params_shm_offset); + } + + void GetShaderiv( + GLuint shader, GLenum pname, uint32 params_shm_id, + uint32 params_shm_offset) { + gles2::GetShaderiv& c = GetCmdSpace<gles2::GetShaderiv>(); + c.Init(shader, pname, params_shm_id, params_shm_offset); + } + + void GetShaderInfoLog( + GLuint shader, GLsizei bufsize, uint32 length_shm_id, + uint32 length_shm_offset, uint32 infolog_shm_id, + uint32 infolog_shm_offset) { + gles2::GetShaderInfoLog& c = GetCmdSpace<gles2::GetShaderInfoLog>(); + c.Init( + shader, bufsize, length_shm_id, length_shm_offset, infolog_shm_id, + infolog_shm_offset); + } + + void GetShaderPrecisionFormat( + GLenum shadertype, GLenum precisiontype, uint32 range_shm_id, + uint32 range_shm_offset, uint32 precision_shm_id, + uint32 precision_shm_offset) { + gles2::GetShaderPrecisionFormat& c = + GetCmdSpace<gles2::GetShaderPrecisionFormat>(); + c.Init( + shadertype, precisiontype, range_shm_id, range_shm_offset, + precision_shm_id, precision_shm_offset); + } + + void GetShaderSource( + GLuint shader, GLsizei bufsize, uint32 length_shm_id, + uint32 length_shm_offset, uint32 source_shm_id, + uint32 source_shm_offset) { + gles2::GetShaderSource& c = GetCmdSpace<gles2::GetShaderSource>(); + c.Init( + shader, bufsize, length_shm_id, length_shm_offset, source_shm_id, + source_shm_offset); + } + + void GetString(GLenum name) { + gles2::GetString& c = GetCmdSpace<gles2::GetString>(); + c.Init(name); + } + + void GetTexParameterfv( + GLenum target, GLenum pname, uint32 params_shm_id, + uint32 params_shm_offset) { + gles2::GetTexParameterfv& c = GetCmdSpace<gles2::GetTexParameterfv>(); + c.Init(target, pname, params_shm_id, params_shm_offset); + } + + void GetTexParameteriv( + GLenum target, GLenum pname, uint32 params_shm_id, + uint32 params_shm_offset) { + gles2::GetTexParameteriv& c = GetCmdSpace<gles2::GetTexParameteriv>(); + c.Init(target, pname, params_shm_id, params_shm_offset); + } + + void GetUniformfv( + GLuint program, GLint location, uint32 params_shm_id, + uint32 params_shm_offset) { + gles2::GetUniformfv& c = GetCmdSpace<gles2::GetUniformfv>(); + c.Init(program, location, params_shm_id, params_shm_offset); + } + + void GetUniformiv( + GLuint program, GLint location, uint32 params_shm_id, + uint32 params_shm_offset) { + gles2::GetUniformiv& c = GetCmdSpace<gles2::GetUniformiv>(); + c.Init(program, location, params_shm_id, params_shm_offset); + } + + void GetUniformLocation( + GLuint program, uint32 name_shm_id, uint32 name_shm_offset, + uint32 data_size) { + gles2::GetUniformLocation& c = GetCmdSpace<gles2::GetUniformLocation>(); + c.Init(program, name_shm_id, name_shm_offset, data_size); + } + + void GetUniformLocationImmediate(GLuint program, const char* name) { + const uint32 size = gles2::GetUniformLocationImmediate::ComputeSize(name); + gles2::GetUniformLocationImmediate& c = + GetImmediateCmdSpaceTotalSize<gles2::GetUniformLocationImmediate>( + size); + c.Init(program, name); + } + + void GetVertexAttribfv( + GLuint index, GLenum pname, uint32 params_shm_id, + uint32 params_shm_offset) { + gles2::GetVertexAttribfv& c = GetCmdSpace<gles2::GetVertexAttribfv>(); + c.Init(index, pname, params_shm_id, params_shm_offset); + } + + void GetVertexAttribiv( + GLuint index, GLenum pname, uint32 params_shm_id, + uint32 params_shm_offset) { + gles2::GetVertexAttribiv& c = GetCmdSpace<gles2::GetVertexAttribiv>(); + c.Init(index, pname, params_shm_id, params_shm_offset); + } + + void GetVertexAttribPointerv( + GLuint index, GLenum pname, uint32 pointer_shm_id, + uint32 pointer_shm_offset) { + gles2::GetVertexAttribPointerv& c = + GetCmdSpace<gles2::GetVertexAttribPointerv>(); + c.Init(index, pname, pointer_shm_id, pointer_shm_offset); + } + + void Hint(GLenum target, GLenum mode) { + gles2::Hint& c = GetCmdSpace<gles2::Hint>(); + c.Init(target, mode); + } + + void IsBuffer( + GLuint buffer, uint32 result_shm_id, uint32 result_shm_offset) { + gles2::IsBuffer& c = GetCmdSpace<gles2::IsBuffer>(); + c.Init(buffer, result_shm_id, result_shm_offset); + } + + void IsEnabled(GLenum cap, uint32 result_shm_id, uint32 result_shm_offset) { + gles2::IsEnabled& c = GetCmdSpace<gles2::IsEnabled>(); + c.Init(cap, result_shm_id, result_shm_offset); + } + + void IsFramebuffer( + GLuint framebuffer, uint32 result_shm_id, uint32 result_shm_offset) { + gles2::IsFramebuffer& c = GetCmdSpace<gles2::IsFramebuffer>(); + c.Init(framebuffer, result_shm_id, result_shm_offset); + } + + void IsProgram( + GLuint program, uint32 result_shm_id, uint32 result_shm_offset) { + gles2::IsProgram& c = GetCmdSpace<gles2::IsProgram>(); + c.Init(program, result_shm_id, result_shm_offset); + } + + void IsRenderbuffer( + GLuint renderbuffer, uint32 result_shm_id, uint32 result_shm_offset) { + gles2::IsRenderbuffer& c = GetCmdSpace<gles2::IsRenderbuffer>(); + c.Init(renderbuffer, result_shm_id, result_shm_offset); + } + + void IsShader( + GLuint shader, uint32 result_shm_id, uint32 result_shm_offset) { + gles2::IsShader& c = GetCmdSpace<gles2::IsShader>(); + c.Init(shader, result_shm_id, result_shm_offset); + } + + void IsTexture( + GLuint texture, uint32 result_shm_id, uint32 result_shm_offset) { + gles2::IsTexture& c = GetCmdSpace<gles2::IsTexture>(); + c.Init(texture, result_shm_id, result_shm_offset); + } + + void LineWidth(GLfloat width) { + gles2::LineWidth& c = GetCmdSpace<gles2::LineWidth>(); + c.Init(width); + } + + void LinkProgram(GLuint program) { + gles2::LinkProgram& c = GetCmdSpace<gles2::LinkProgram>(); + c.Init(program); + } + + void PixelStorei(GLenum pname, GLint param) { + gles2::PixelStorei& c = GetCmdSpace<gles2::PixelStorei>(); + c.Init(pname, param); + } + + void PolygonOffset(GLfloat factor, GLfloat units) { + gles2::PolygonOffset& c = GetCmdSpace<gles2::PolygonOffset>(); + c.Init(factor, units); + } + + void ReadPixels( + GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, + GLenum type, uint32 pixels_shm_id, uint32 pixels_shm_offset) { + gles2::ReadPixels& c = GetCmdSpace<gles2::ReadPixels>(); + c.Init( + x, y, width, height, format, type, pixels_shm_id, pixels_shm_offset); + } + + void RenderbufferStorage( + GLenum target, GLenum internalformat, GLsizei width, GLsizei height) { + gles2::RenderbufferStorage& c = GetCmdSpace<gles2::RenderbufferStorage>(); + c.Init(target, internalformat, width, height); + } + + void SampleCoverage(GLclampf value, GLboolean invert) { + gles2::SampleCoverage& c = GetCmdSpace<gles2::SampleCoverage>(); + c.Init(value, invert); + } + + void Scissor(GLint x, GLint y, GLsizei width, GLsizei height) { + gles2::Scissor& c = GetCmdSpace<gles2::Scissor>(); + c.Init(x, y, width, height); + } + + void ShaderSource( + GLuint shader, GLsizei count, uint32 data_shm_id, uint32 data_shm_offset, + uint32 data_size) { + gles2::ShaderSource& c = GetCmdSpace<gles2::ShaderSource>(); + c.Init(shader, count, data_shm_id, data_shm_offset, data_size); + } + + void ShaderSourceImmediate(GLuint shader, GLsizei count, uint32 data_size) { + const uint32 s = 0; // TODO(gman): compute correct size + gles2::ShaderSourceImmediate& c = + GetImmediateCmdSpaceTotalSize<gles2::ShaderSourceImmediate>(s); + c.Init(shader, count, data_size); + } + + void StencilFunc(GLenum func, GLint ref, GLuint mask) { + gles2::StencilFunc& c = GetCmdSpace<gles2::StencilFunc>(); + c.Init(func, ref, mask); + } + + void StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) { + gles2::StencilFuncSeparate& c = GetCmdSpace<gles2::StencilFuncSeparate>(); + c.Init(face, func, ref, mask); + } + + void StencilMask(GLuint mask) { + gles2::StencilMask& c = GetCmdSpace<gles2::StencilMask>(); + c.Init(mask); + } + + void StencilMaskSeparate(GLenum face, GLuint mask) { + gles2::StencilMaskSeparate& c = GetCmdSpace<gles2::StencilMaskSeparate>(); + c.Init(face, mask); + } + + void StencilOp(GLenum fail, GLenum zfail, GLenum zpass) { + gles2::StencilOp& c = GetCmdSpace<gles2::StencilOp>(); + c.Init(fail, zfail, zpass); + } + + void StencilOpSeparate( + GLenum face, GLenum fail, GLenum zfail, GLenum zpass) { + gles2::StencilOpSeparate& c = GetCmdSpace<gles2::StencilOpSeparate>(); + c.Init(face, fail, zfail, zpass); + } + + void TexImage2D( + GLenum target, GLint level, GLint internalformat, GLsizei width, + GLsizei height, GLint border, GLenum format, GLenum type, + uint32 pixels_shm_id, uint32 pixels_shm_offset) { + gles2::TexImage2D& c = GetCmdSpace<gles2::TexImage2D>(); + c.Init( + target, level, internalformat, width, height, border, format, type, + pixels_shm_id, pixels_shm_offset); + } + + void TexImage2DImmediate( + GLenum target, GLint level, GLint internalformat, GLsizei width, + GLsizei height, GLint border, GLenum format, GLenum type) { + const uint32 s = 0; // TODO(gman): compute correct size + gles2::TexImage2DImmediate& c = + GetImmediateCmdSpaceTotalSize<gles2::TexImage2DImmediate>(s); + c.Init(target, level, internalformat, width, height, border, format, type); + } + + void TexParameterf(GLenum target, GLenum pname, GLfloat param) { + gles2::TexParameterf& c = GetCmdSpace<gles2::TexParameterf>(); + c.Init(target, pname, param); + } + + void TexParameterfv( + GLenum target, GLenum pname, uint32 params_shm_id, + uint32 params_shm_offset) { + gles2::TexParameterfv& c = GetCmdSpace<gles2::TexParameterfv>(); + c.Init(target, pname, params_shm_id, params_shm_offset); + } + + void TexParameterfvImmediate( + GLenum target, GLenum pname, const GLfloat* params) { + const uint32 size = gles2::TexParameterfvImmediate::ComputeSize(); + gles2::TexParameterfvImmediate& c = + GetImmediateCmdSpaceTotalSize<gles2::TexParameterfvImmediate>(size); + c.Init(target, pname, params); + } + + void TexParameteri(GLenum target, GLenum pname, GLint param) { + gles2::TexParameteri& c = GetCmdSpace<gles2::TexParameteri>(); + c.Init(target, pname, param); + } + + void TexParameteriv( + GLenum target, GLenum pname, uint32 params_shm_id, + uint32 params_shm_offset) { + gles2::TexParameteriv& c = GetCmdSpace<gles2::TexParameteriv>(); + c.Init(target, pname, params_shm_id, params_shm_offset); + } + + void TexParameterivImmediate( + GLenum target, GLenum pname, const GLint* params) { + const uint32 size = gles2::TexParameterivImmediate::ComputeSize(); + gles2::TexParameterivImmediate& c = + GetImmediateCmdSpaceTotalSize<gles2::TexParameterivImmediate>(size); + c.Init(target, pname, params); + } + + void TexSubImage2D( + GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, + GLsizei height, GLenum format, GLenum type, uint32 pixels_shm_id, + uint32 pixels_shm_offset) { + gles2::TexSubImage2D& c = GetCmdSpace<gles2::TexSubImage2D>(); + c.Init( + target, level, xoffset, yoffset, width, height, format, type, + pixels_shm_id, pixels_shm_offset); + } + + void TexSubImage2DImmediate( + GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, + GLsizei height, GLenum format, GLenum type) { + const uint32 s = 0; // TODO(gman): compute correct size + gles2::TexSubImage2DImmediate& c = + GetImmediateCmdSpaceTotalSize<gles2::TexSubImage2DImmediate>(s); + c.Init(target, level, xoffset, yoffset, width, height, format, type); + } + + void Uniform1f(GLint location, GLfloat x) { + gles2::Uniform1f& c = GetCmdSpace<gles2::Uniform1f>(); + c.Init(location, x); + } + + void Uniform1fv( + GLint location, GLsizei count, uint32 v_shm_id, uint32 v_shm_offset) { + gles2::Uniform1fv& c = GetCmdSpace<gles2::Uniform1fv>(); + c.Init(location, count, v_shm_id, v_shm_offset); + } + + void Uniform1fvImmediate(GLint location, GLsizei count, const GLfloat* v) { + const uint32 size = gles2::Uniform1fvImmediate::ComputeSize(count); + gles2::Uniform1fvImmediate& c = + GetImmediateCmdSpaceTotalSize<gles2::Uniform1fvImmediate>(size); + c.Init(location, count, v); + } + + void Uniform1i(GLint location, GLint x) { + gles2::Uniform1i& c = GetCmdSpace<gles2::Uniform1i>(); + c.Init(location, x); + } + + void Uniform1iv( + GLint location, GLsizei count, uint32 v_shm_id, uint32 v_shm_offset) { + gles2::Uniform1iv& c = GetCmdSpace<gles2::Uniform1iv>(); + c.Init(location, count, v_shm_id, v_shm_offset); + } + + void Uniform1ivImmediate(GLint location, GLsizei count, const GLint* v) { + const uint32 size = gles2::Uniform1ivImmediate::ComputeSize(count); + gles2::Uniform1ivImmediate& c = + GetImmediateCmdSpaceTotalSize<gles2::Uniform1ivImmediate>(size); + c.Init(location, count, v); + } + + void Uniform2f(GLint location, GLfloat x, GLfloat y) { + gles2::Uniform2f& c = GetCmdSpace<gles2::Uniform2f>(); + c.Init(location, x, y); + } + + void Uniform2fv( + GLint location, GLsizei count, uint32 v_shm_id, uint32 v_shm_offset) { + gles2::Uniform2fv& c = GetCmdSpace<gles2::Uniform2fv>(); + c.Init(location, count, v_shm_id, v_shm_offset); + } + + void Uniform2fvImmediate(GLint location, GLsizei count, const GLfloat* v) { + const uint32 size = gles2::Uniform2fvImmediate::ComputeSize(count); + gles2::Uniform2fvImmediate& c = + GetImmediateCmdSpaceTotalSize<gles2::Uniform2fvImmediate>(size); + c.Init(location, count, v); + } + + void Uniform2i(GLint location, GLint x, GLint y) { + gles2::Uniform2i& c = GetCmdSpace<gles2::Uniform2i>(); + c.Init(location, x, y); + } + + void Uniform2iv( + GLint location, GLsizei count, uint32 v_shm_id, uint32 v_shm_offset) { + gles2::Uniform2iv& c = GetCmdSpace<gles2::Uniform2iv>(); + c.Init(location, count, v_shm_id, v_shm_offset); + } + + void Uniform2ivImmediate(GLint location, GLsizei count, const GLint* v) { + const uint32 size = gles2::Uniform2ivImmediate::ComputeSize(count); + gles2::Uniform2ivImmediate& c = + GetImmediateCmdSpaceTotalSize<gles2::Uniform2ivImmediate>(size); + c.Init(location, count, v); + } + + void Uniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) { + gles2::Uniform3f& c = GetCmdSpace<gles2::Uniform3f>(); + c.Init(location, x, y, z); + } + + void Uniform3fv( + GLint location, GLsizei count, uint32 v_shm_id, uint32 v_shm_offset) { + gles2::Uniform3fv& c = GetCmdSpace<gles2::Uniform3fv>(); + c.Init(location, count, v_shm_id, v_shm_offset); + } + + void Uniform3fvImmediate(GLint location, GLsizei count, const GLfloat* v) { + const uint32 size = gles2::Uniform3fvImmediate::ComputeSize(count); + gles2::Uniform3fvImmediate& c = + GetImmediateCmdSpaceTotalSize<gles2::Uniform3fvImmediate>(size); + c.Init(location, count, v); + } + + void Uniform3i(GLint location, GLint x, GLint y, GLint z) { + gles2::Uniform3i& c = GetCmdSpace<gles2::Uniform3i>(); + c.Init(location, x, y, z); + } + + void Uniform3iv( + GLint location, GLsizei count, uint32 v_shm_id, uint32 v_shm_offset) { + gles2::Uniform3iv& c = GetCmdSpace<gles2::Uniform3iv>(); + c.Init(location, count, v_shm_id, v_shm_offset); + } + + void Uniform3ivImmediate(GLint location, GLsizei count, const GLint* v) { + const uint32 size = gles2::Uniform3ivImmediate::ComputeSize(count); + gles2::Uniform3ivImmediate& c = + GetImmediateCmdSpaceTotalSize<gles2::Uniform3ivImmediate>(size); + c.Init(location, count, v); + } + + void Uniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) { + gles2::Uniform4f& c = GetCmdSpace<gles2::Uniform4f>(); + c.Init(location, x, y, z, w); + } + + void Uniform4fv( + GLint location, GLsizei count, uint32 v_shm_id, uint32 v_shm_offset) { + gles2::Uniform4fv& c = GetCmdSpace<gles2::Uniform4fv>(); + c.Init(location, count, v_shm_id, v_shm_offset); + } + + void Uniform4fvImmediate(GLint location, GLsizei count, const GLfloat* v) { + const uint32 size = gles2::Uniform4fvImmediate::ComputeSize(count); + gles2::Uniform4fvImmediate& c = + GetImmediateCmdSpaceTotalSize<gles2::Uniform4fvImmediate>(size); + c.Init(location, count, v); + } + + void Uniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) { + gles2::Uniform4i& c = GetCmdSpace<gles2::Uniform4i>(); + c.Init(location, x, y, z, w); + } + + void Uniform4iv( + GLint location, GLsizei count, uint32 v_shm_id, uint32 v_shm_offset) { + gles2::Uniform4iv& c = GetCmdSpace<gles2::Uniform4iv>(); + c.Init(location, count, v_shm_id, v_shm_offset); + } + + void Uniform4ivImmediate(GLint location, GLsizei count, const GLint* v) { + const uint32 size = gles2::Uniform4ivImmediate::ComputeSize(count); + gles2::Uniform4ivImmediate& c = + GetImmediateCmdSpaceTotalSize<gles2::Uniform4ivImmediate>(size); + c.Init(location, count, v); + } + + void UniformMatrix2fv( + GLint location, GLsizei count, GLboolean transpose, uint32 value_shm_id, + uint32 value_shm_offset) { + gles2::UniformMatrix2fv& c = GetCmdSpace<gles2::UniformMatrix2fv>(); + c.Init(location, count, transpose, value_shm_id, value_shm_offset); + } + + void UniformMatrix2fvImmediate( + GLint location, GLsizei count, GLboolean transpose, + const GLfloat* value) { + const uint32 size = gles2::UniformMatrix2fvImmediate::ComputeSize(count); + gles2::UniformMatrix2fvImmediate& c = + GetImmediateCmdSpaceTotalSize<gles2::UniformMatrix2fvImmediate>(size); + c.Init(location, count, transpose, value); + } + + void UniformMatrix3fv( + GLint location, GLsizei count, GLboolean transpose, uint32 value_shm_id, + uint32 value_shm_offset) { + gles2::UniformMatrix3fv& c = GetCmdSpace<gles2::UniformMatrix3fv>(); + c.Init(location, count, transpose, value_shm_id, value_shm_offset); + } + + void UniformMatrix3fvImmediate( + GLint location, GLsizei count, GLboolean transpose, + const GLfloat* value) { + const uint32 size = gles2::UniformMatrix3fvImmediate::ComputeSize(count); + gles2::UniformMatrix3fvImmediate& c = + GetImmediateCmdSpaceTotalSize<gles2::UniformMatrix3fvImmediate>(size); + c.Init(location, count, transpose, value); + } + + void UniformMatrix4fv( + GLint location, GLsizei count, GLboolean transpose, uint32 value_shm_id, + uint32 value_shm_offset) { + gles2::UniformMatrix4fv& c = GetCmdSpace<gles2::UniformMatrix4fv>(); + c.Init(location, count, transpose, value_shm_id, value_shm_offset); + } + + void UniformMatrix4fvImmediate( + GLint location, GLsizei count, GLboolean transpose, + const GLfloat* value) { + const uint32 size = gles2::UniformMatrix4fvImmediate::ComputeSize(count); + gles2::UniformMatrix4fvImmediate& c = + GetImmediateCmdSpaceTotalSize<gles2::UniformMatrix4fvImmediate>(size); + c.Init(location, count, transpose, value); + } + + void UseProgram(GLuint program) { + gles2::UseProgram& c = GetCmdSpace<gles2::UseProgram>(); + c.Init(program); + } + + void ValidateProgram(GLuint program) { + gles2::ValidateProgram& c = GetCmdSpace<gles2::ValidateProgram>(); + c.Init(program); + } + + void VertexAttrib1f(GLuint indx, GLfloat x) { + gles2::VertexAttrib1f& c = GetCmdSpace<gles2::VertexAttrib1f>(); + c.Init(indx, x); + } + + void VertexAttrib1fv( + GLuint indx, uint32 values_shm_id, uint32 values_shm_offset) { + gles2::VertexAttrib1fv& c = GetCmdSpace<gles2::VertexAttrib1fv>(); + c.Init(indx, values_shm_id, values_shm_offset); + } + + void VertexAttrib1fvImmediate(GLuint indx, const GLfloat* values) { + const uint32 size = gles2::VertexAttrib1fvImmediate::ComputeSize(); + gles2::VertexAttrib1fvImmediate& c = + GetImmediateCmdSpaceTotalSize<gles2::VertexAttrib1fvImmediate>(size); + c.Init(indx, values); + } + + void VertexAttrib2f(GLuint indx, GLfloat x, GLfloat y) { + gles2::VertexAttrib2f& c = GetCmdSpace<gles2::VertexAttrib2f>(); + c.Init(indx, x, y); + } + + void VertexAttrib2fv( + GLuint indx, uint32 values_shm_id, uint32 values_shm_offset) { + gles2::VertexAttrib2fv& c = GetCmdSpace<gles2::VertexAttrib2fv>(); + c.Init(indx, values_shm_id, values_shm_offset); + } + + void VertexAttrib2fvImmediate(GLuint indx, const GLfloat* values) { + const uint32 size = gles2::VertexAttrib2fvImmediate::ComputeSize(); + gles2::VertexAttrib2fvImmediate& c = + GetImmediateCmdSpaceTotalSize<gles2::VertexAttrib2fvImmediate>(size); + c.Init(indx, values); + } + + void VertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z) { + gles2::VertexAttrib3f& c = GetCmdSpace<gles2::VertexAttrib3f>(); + c.Init(indx, x, y, z); + } + + void VertexAttrib3fv( + GLuint indx, uint32 values_shm_id, uint32 values_shm_offset) { + gles2::VertexAttrib3fv& c = GetCmdSpace<gles2::VertexAttrib3fv>(); + c.Init(indx, values_shm_id, values_shm_offset); + } + + void VertexAttrib3fvImmediate(GLuint indx, const GLfloat* values) { + const uint32 size = gles2::VertexAttrib3fvImmediate::ComputeSize(); + gles2::VertexAttrib3fvImmediate& c = + GetImmediateCmdSpaceTotalSize<gles2::VertexAttrib3fvImmediate>(size); + c.Init(indx, values); + } + + void VertexAttrib4f( + GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w) { + gles2::VertexAttrib4f& c = GetCmdSpace<gles2::VertexAttrib4f>(); + c.Init(indx, x, y, z, w); + } + + void VertexAttrib4fv( + GLuint indx, uint32 values_shm_id, uint32 values_shm_offset) { + gles2::VertexAttrib4fv& c = GetCmdSpace<gles2::VertexAttrib4fv>(); + c.Init(indx, values_shm_id, values_shm_offset); + } + + void VertexAttrib4fvImmediate(GLuint indx, const GLfloat* values) { + const uint32 size = gles2::VertexAttrib4fvImmediate::ComputeSize(); + gles2::VertexAttrib4fvImmediate& c = + GetImmediateCmdSpaceTotalSize<gles2::VertexAttrib4fvImmediate>(size); + c.Init(indx, values); + } + + void VertexAttribPointer( + GLuint indx, GLint size, GLenum type, GLboolean normalized, + GLsizei stride, GLuint offset) { + gles2::VertexAttribPointer& c = GetCmdSpace<gles2::VertexAttribPointer>(); + c.Init(indx, size, type, normalized, stride, offset); + } + + void Viewport(GLint x, GLint y, GLsizei width, GLsizei height) { + gles2::Viewport& c = GetCmdSpace<gles2::Viewport>(); + c.Init(x, y, width, height); + } + diff --git a/o3d/gpu/command_buffer/client/gles2_implementation.cc b/o3d/gpu/command_buffer/client/gles2_implementation.cc new file mode 100644 index 0000000..c13d63c --- /dev/null +++ b/o3d/gpu/command_buffer/client/gles2_implementation.cc @@ -0,0 +1,141 @@ +// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// A class to emluate GLES2 over command buffers. + +#include "gpu/command_buffer/client/gles2_implementation.h" +#include "gpu/command_buffer/client/gles2_implementation_gen.h" +#include "gpu/command_buffer/common/gles2_cmd_utils.h" + +namespace command_buffer { +namespace gles2 { + +GLES2Implementation::GLES2Implementation( + GLES2CmdHelper* helper, + ResourceId shared_memory_id, + void* shared_memory_address) + : util_(0), // TODO(gman): Get real number of compressed texture formats. + helper_(helper), + shared_memory_(shared_memory_id, shared_memory_address), + pack_alignment_(4), + unpack_alignment_(4) { +} + +void GLES2Implementation::MakeIds(GLsizei n, GLuint* ids) { + for (GLsizei ii = 0; ii < n; ++ii) { + ids[ii] = id_allocator_.AllocateID(); + } +} + +void GLES2Implementation::FreeIds(GLsizei n, const GLuint* ids) { + for (GLsizei ii = 0; ii < n; ++ii) { + id_allocator_.FreeID(ids[ii]); + } +} + +void GLES2Implementation::ShaderSource( + GLuint shader, GLsizei count, const char** string, const GLint* length) { + // TODO(gman): change to use buckets and check that there is enough room. + uint32* offsets = shared_memory_.GetAddressAs<uint32*>(0); + char* strings = reinterpret_cast<char*>(offsets + count); + + uint32 offset = count * sizeof(*offsets); + for (GLsizei ii = 0; ii < count; ++ii) { + uint32 len = length ? length[ii] : strlen(string[ii]); + memcpy(strings + offset, string[ii], len); + offset += len; + offsets[ii] = offset; + } + + helper_->ShaderSource(shader, count, shared_memory_.GetId(), 0, offset); + // TODO(gman): Should insert token but not wait until we need shared memory + // again. Really, I should implement a shared memory manager that puts + // things in the next unused part of shared memory and only blocks + // when it needs more memory. + int32 token = helper_->InsertToken(); + helper_->WaitForToken(token); +} + +void GLES2Implementation::BufferData( + GLenum target, GLsizeiptr size, const void* data, GLenum usage) { + // TODO(gman): Switch to use buckets alwayst or at least if no room in shared + // memory. + memcpy(shared_memory_.GetAddress(0), data, size); + helper_->BufferData(target, size, shared_memory_.GetId(), 0, usage); + int32 token = helper_->InsertToken(); + helper_->WaitForToken(token); +} + +void GLES2Implementation::BufferSubData( + GLenum target, GLintptr offset, GLsizeiptr size, const void* data) { + // TODO(gman): Switch to use buckets alwayst or at least if no room in shared + // memory. + memcpy(shared_memory_.GetAddress(0), data, size); + helper_->BufferSubData(target, offset, size, shared_memory_.GetId(), 0); + int32 token = helper_->InsertToken(); + helper_->WaitForToken(token); +} + +void GLES2Implementation::CompressedTexImage2D( + GLenum target, GLint level, GLenum internalformat, GLsizei width, + GLsizei height, GLint border, GLsizei imageSize, const void* data) { + // TODO(gman): Switch to use buckets alwayst or at least if no room in shared + // memory. + memcpy(shared_memory_.GetAddress(0), data, imageSize); + helper_->CompressedTexImage2D( + target, level, internalformat, width, height, border, imageSize, + shared_memory_.GetId(), 0); + int32 token = helper_->InsertToken(); + helper_->WaitForToken(token); +} + +void GLES2Implementation::CompressedTexSubImage2D( + GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, + GLsizei height, GLenum format, GLsizei imageSize, const void* data) { + // TODO(gman): Switch to use buckets alwayst or at least if no room in shared + // memory. + memcpy(shared_memory_.GetAddress(0), data, imageSize); + helper_->CompressedTexSubImage2D( + target, level, xoffset, yoffset, width, height, format, imageSize, + shared_memory_.GetId(), 0); + int32 token = helper_->InsertToken(); + helper_->WaitForToken(token); +} + +void GLES2Implementation::TexImage2D( + GLenum target, GLint level, GLint internalformat, GLsizei width, + GLsizei height, GLint border, GLenum format, GLenum type, + const void* pixels) { + // TODO(gman): Switch to use buckets alwayst or at least if no room in shared + // memory. + uint32 pixels_size = GLES2Util::ComputeImageDataSize( + width, height, format, type, unpack_alignment_); + memcpy(shared_memory_.GetAddress(0), pixels, pixels_size); + helper_->TexImage2D( + target, level, internalformat, width, height, border, format, type, + shared_memory_.GetId(), 0); + int32 token = helper_->InsertToken(); + helper_->WaitForToken(token); +} + +void GLES2Implementation::TexSubImage2D( + GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, + GLsizei height, GLenum format, GLenum type, const void* pixels) { + // TODO(gman): Switch to use buckets alwayst or at least if no room in shared + // memory. + uint32 pixels_size = GLES2Util::ComputeImageDataSize( + width, height, format, type, unpack_alignment_); + memcpy(shared_memory_.GetAddress(0), pixels, pixels_size); + helper_->TexSubImage2D( + target, level, xoffset, yoffset, width, height, format, type, + shared_memory_.GetId(), 0); + int32 token = helper_->InsertToken(); + helper_->WaitForToken(token); +} + + +} // namespace gles2 +} // namespace command_buffer + + diff --git a/o3d/gpu/command_buffer/client/gles2_implementation.h b/o3d/gpu/command_buffer/client/gles2_implementation.h new file mode 100644 index 0000000..c8484ec --- /dev/null +++ b/o3d/gpu/command_buffer/client/gles2_implementation.h @@ -0,0 +1,93 @@ +// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef GPU_COMMAND_BUFFER_CLIENT_GLES2_HELPER_H +#define GPU_COMMAND_BUFFER_CLIENT_GLES2_HELPER_H + +#include "gpu/command_buffer/client/gles2_cmd_helper.h" +#include "gpu/command_buffer/client/id_allocator.h" + +namespace command_buffer { +namespace gles2 { + +// A class to help with shared memory. +class SharedMemoryHelper { + public: + SharedMemoryHelper( + unsigned int id, + void* address) + : id_(id), + address_(address) { + } + + unsigned int GetOffset(void* address) const { + return static_cast<int8*>(address) - + static_cast<int8*>(address_); + } + + void* GetAddress(unsigned int offset) const { + return static_cast<int8*>(address_) + offset; + } + + template <typename T> + T GetAddressAs(unsigned int offset) const { + return static_cast<T>(GetAddress(offset)); + } + + unsigned int GetId() const { + return id_; + } + + private: + ResourceId id_; + void* address_; + + DISALLOW_COPY_AND_ASSIGN(SharedMemoryHelper); +}; + +// This class emulates GLES2 over command buffers. It can be used by a client +// program so that the program does not need deal with shared memory and command +// buffer management. See gl2_lib.h. Note that there is a performance gain to +// be had by changing your code to use command buffers directly by using the +// GLES2CmdHelper but that entails changing your code to use and deal with +// shared memory and synchronization issues. +class GLES2Implementation { + public: + GLES2Implementation( + GLES2CmdHelper* helper, + ResourceId shared_memory_id, + void* shared_memory); + + // Include the auto-generated part of this class. We split this because + // it means we can easily edit the non-auto generated parts right here in + // this file instead of having to edit some template or the code generator. + #include "gpu/command_buffer/client/gles2_implementation_autogen.h" + + private: + // Makes a set of Ids for glGen___ functions. + void MakeIds(GLsizei n, GLuint* ids); + + // Frees a set of Ids for glDelete___ functions. + void FreeIds(GLsizei n, const GLuint* ids); + + GLES2Util util_; + GLES2CmdHelper* helper_; + IdAllocator id_allocator_; + SharedMemoryHelper shared_memory_; + + // pack alignment as last set by glPixelStorei + GLint pack_alignment_; + + // unpack alignment as last set by glPixelStorei + GLint unpack_alignment_; + + DISALLOW_COPY_AND_ASSIGN(GLES2Implementation); +}; + + +} // namespace gles2 +} // namespace command_buffer + +#endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_HELPER_H + diff --git a/o3d/gpu/command_buffer/client/gles2_implementation_autogen.h b/o3d/gpu/command_buffer/client/gles2_implementation_autogen.h new file mode 100644 index 0000000..0d86245 --- /dev/null +++ b/o3d/gpu/command_buffer/client/gles2_implementation_autogen.h @@ -0,0 +1,670 @@ +// This file is auto-generated. DO NOT EDIT! + +// This file is included by gles2_implementation.h to declare the +// GL api functions. +void ActiveTexture(GLenum texture) { + helper_->ActiveTexture(texture); +} + +void AttachShader(GLuint program, GLuint shader) { + helper_->AttachShader(program, shader); +} + +void BindAttribLocation(GLuint program, GLuint index, const char* name) { + // TODO(gman): This needs to change to use SendString. + helper_->BindAttribLocationImmediate(program, index, name); +} + +void BindBuffer(GLenum target, GLuint buffer) { + helper_->BindBuffer(target, buffer); +} + +void BindFramebuffer(GLenum target, GLuint framebuffer) { + helper_->BindFramebuffer(target, framebuffer); +} + +void BindRenderbuffer(GLenum target, GLuint renderbuffer) { + helper_->BindRenderbuffer(target, renderbuffer); +} + +void BindTexture(GLenum target, GLuint texture) { + helper_->BindTexture(target, texture); +} + +void BlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) { + helper_->BlendColor(red, green, blue, alpha); +} + +void BlendEquation(GLenum mode) { + helper_->BlendEquation(mode); +} + +void BlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) { + helper_->BlendEquationSeparate(modeRGB, modeAlpha); +} + +void BlendFunc(GLenum sfactor, GLenum dfactor) { + helper_->BlendFunc(sfactor, dfactor); +} + +void BlendFuncSeparate( + GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) { + helper_->BlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha); +} + +void BufferData( + GLenum target, GLsizeiptr size, const void* data, GLenum usage); + +void BufferSubData( + GLenum target, GLintptr offset, GLsizeiptr size, const void* data); + +GLenum CheckFramebufferStatus(GLenum target); + +void Clear(GLbitfield mask) { + helper_->Clear(mask); +} + +void ClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) { + helper_->ClearColor(red, green, blue, alpha); +} + +void ClearDepthf(GLclampf depth) { + helper_->ClearDepthf(depth); +} + +void ClearStencil(GLint s) { + helper_->ClearStencil(s); +} + +void ColorMask( + GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) { + helper_->ColorMask(red, green, blue, alpha); +} + +void CompileShader(GLuint shader) { + helper_->CompileShader(shader); +} + +void CompressedTexImage2D( + GLenum target, GLint level, GLenum internalformat, GLsizei width, + GLsizei height, GLint border, GLsizei imageSize, const void* data); + +void CompressedTexSubImage2D( + GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, + GLsizei height, GLenum format, GLsizei imageSize, const void* data); + +void CopyTexImage2D( + GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, + GLsizei width, GLsizei height, GLint border) { + helper_->CopyTexImage2D( + target, level, internalformat, x, y, width, height, border); +} + +void CopyTexSubImage2D( + GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, + GLsizei width, GLsizei height) { + helper_->CopyTexSubImage2D( + target, level, xoffset, yoffset, x, y, width, height); +} + +GLuint CreateProgram() { + GLuint client_id; + MakeIds(1, &client_id); + helper_->CreateProgram(client_id); + return client_id; +} + +GLuint CreateShader(GLenum type) { + GLuint client_id; + MakeIds(1, &client_id); + helper_->CreateShader(type, client_id); + return client_id; +} + +void CullFace(GLenum mode) { + helper_->CullFace(mode); +} + +void DeleteBuffers(GLsizei n, const GLuint* buffers) { + FreeIds(n, buffers); + helper_->DeleteBuffersImmediate(n, buffers); +} + +void DeleteFramebuffers(GLsizei n, const GLuint* framebuffers) { + FreeIds(n, framebuffers); + helper_->DeleteFramebuffersImmediate(n, framebuffers); +} + +void DeleteProgram(GLuint program) { + helper_->DeleteProgram(program); +} + +void DeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers) { + FreeIds(n, renderbuffers); + helper_->DeleteRenderbuffersImmediate(n, renderbuffers); +} + +void DeleteShader(GLuint shader) { + helper_->DeleteShader(shader); +} + +void DeleteTextures(GLsizei n, const GLuint* textures) { + FreeIds(n, textures); + helper_->DeleteTexturesImmediate(n, textures); +} + +void DepthFunc(GLenum func) { + helper_->DepthFunc(func); +} + +void DepthMask(GLboolean flag) { + helper_->DepthMask(flag); +} + +void DepthRangef(GLclampf zNear, GLclampf zFar) { + helper_->DepthRangef(zNear, zFar); +} + +void DetachShader(GLuint program, GLuint shader) { + helper_->DetachShader(program, shader); +} + +void Disable(GLenum cap) { + helper_->Disable(cap); +} + +void DisableVertexAttribArray(GLuint index) { + helper_->DisableVertexAttribArray(index); +} + +void DrawArrays(GLenum mode, GLint first, GLsizei count) { + helper_->DrawArrays(mode, first, count); +} + +void DrawElements( + GLenum mode, GLsizei count, GLenum type, const void* indices); + +void Enable(GLenum cap) { + helper_->Enable(cap); +} + +void EnableVertexAttribArray(GLuint index) { + helper_->EnableVertexAttribArray(index); +} + +void Finish() { + helper_->Finish(); +} + +void Flush() { + helper_->Flush(); +} + +void FramebufferRenderbuffer( + GLenum target, GLenum attachment, GLenum renderbuffertarget, + GLuint renderbuffer) { + helper_->FramebufferRenderbuffer( + target, attachment, renderbuffertarget, renderbuffer); +} + +void FramebufferTexture2D( + GLenum target, GLenum attachment, GLenum textarget, GLuint texture, + GLint level) { + helper_->FramebufferTexture2D(target, attachment, textarget, texture, level); +} + +void FrontFace(GLenum mode) { + helper_->FrontFace(mode); +} + +void GenBuffers(GLsizei n, GLuint* buffers) { + MakeIds(n, buffers); + helper_->GenBuffersImmediate(n, buffers); +} + +void GenerateMipmap(GLenum target) { + helper_->GenerateMipmap(target); +} + +void GenFramebuffers(GLsizei n, GLuint* framebuffers) { + MakeIds(n, framebuffers); + helper_->GenFramebuffersImmediate(n, framebuffers); +} + +void GenRenderbuffers(GLsizei n, GLuint* renderbuffers) { + MakeIds(n, renderbuffers); + helper_->GenRenderbuffersImmediate(n, renderbuffers); +} + +void GenTextures(GLsizei n, GLuint* textures) { + MakeIds(n, textures); + helper_->GenTexturesImmediate(n, textures); +} + +void GetActiveAttrib( + GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, + GLenum* type, char* name); + +void GetActiveUniform( + GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, + GLenum* type, char* name); + +void GetAttachedShaders( + GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders); + +int GetAttribLocation(GLuint program, const char* name) { + // TODO(gman): This needs to change to use SendString. + helper_->GetAttribLocationImmediate(program, name); +} + +void GetBooleanv(GLenum pname, GLboolean* params) { + helper_->GetBooleanv(pname, shared_memory_.GetId(), 0); + int32 token = helper_->InsertToken(); + helper_->WaitForToken(token); + GLsizei num_values = util_.GLGetNumValuesReturned(pname); + memcpy(params, shared_memory_.GetAddress(0), + num_values * sizeof(*params)); +} + +void GetBufferParameteriv(GLenum target, GLenum pname, GLint* params) { + helper_->GetBufferParameteriv(target, pname, shared_memory_.GetId(), 0); + int32 token = helper_->InsertToken(); + helper_->WaitForToken(token); + GLsizei num_values = util_.GLGetNumValuesReturned(pname); + memcpy(params, shared_memory_.GetAddress(0), + num_values * sizeof(*params)); +} + +GLenum GetError() { + helper_->GetError(shared_memory_.GetId(), 0); + int32 token = helper_->InsertToken(); + helper_->WaitForToken(token); + return *shared_memory_.GetAddressAs<GLenum*>(0); +} + +void GetFloatv(GLenum pname, GLfloat* params) { + helper_->GetFloatv(pname, shared_memory_.GetId(), 0); + int32 token = helper_->InsertToken(); + helper_->WaitForToken(token); + GLsizei num_values = util_.GLGetNumValuesReturned(pname); + memcpy(params, shared_memory_.GetAddress(0), + num_values * sizeof(*params)); +} + +void GetFramebufferAttachmentParameteriv( + GLenum target, GLenum attachment, GLenum pname, GLint* params) { + helper_->GetFramebufferAttachmentParameteriv( + target, attachment, pname, shared_memory_.GetId(), 0); + int32 token = helper_->InsertToken(); + helper_->WaitForToken(token); + GLsizei num_values = util_.GLGetNumValuesReturned(pname); + memcpy(params, shared_memory_.GetAddress(0), + num_values * sizeof(*params)); +} + +void GetIntegerv(GLenum pname, GLint* params) { + helper_->GetIntegerv(pname, shared_memory_.GetId(), 0); + int32 token = helper_->InsertToken(); + helper_->WaitForToken(token); + GLsizei num_values = util_.GLGetNumValuesReturned(pname); + memcpy(params, shared_memory_.GetAddress(0), + num_values * sizeof(*params)); +} + +void GetProgramiv(GLuint program, GLenum pname, GLint* params) { + helper_->GetProgramiv(program, pname, shared_memory_.GetId(), 0); + int32 token = helper_->InsertToken(); + helper_->WaitForToken(token); + GLsizei num_values = util_.GLGetNumValuesReturned(pname); + memcpy(params, shared_memory_.GetAddress(0), + num_values * sizeof(*params)); +} + +// TODO(gman): Implement this +void GetProgramInfoLog( + GLuint program, GLsizei bufsize, GLsizei* length, char* infolog); + +void GetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params) { + helper_->GetRenderbufferParameteriv( + target, pname, shared_memory_.GetId(), 0); + int32 token = helper_->InsertToken(); + helper_->WaitForToken(token); + GLsizei num_values = util_.GLGetNumValuesReturned(pname); + memcpy(params, shared_memory_.GetAddress(0), + num_values * sizeof(*params)); +} + +void GetShaderiv(GLuint shader, GLenum pname, GLint* params) { + helper_->GetShaderiv(shader, pname, shared_memory_.GetId(), 0); + int32 token = helper_->InsertToken(); + helper_->WaitForToken(token); + GLsizei num_values = util_.GLGetNumValuesReturned(pname); + memcpy(params, shared_memory_.GetAddress(0), + num_values * sizeof(*params)); +} + +// TODO(gman): Implement this +void GetShaderInfoLog( + GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog); + +void GetShaderPrecisionFormat( + GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision); + +// TODO(gman): Implement this +void GetShaderSource( + GLuint shader, GLsizei bufsize, GLsizei* length, char* source); + +const GLubyte* GetString(GLenum name); + +void GetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) { + helper_->GetTexParameterfv(target, pname, shared_memory_.GetId(), 0); + int32 token = helper_->InsertToken(); + helper_->WaitForToken(token); + GLsizei num_values = util_.GLGetNumValuesReturned(pname); + memcpy(params, shared_memory_.GetAddress(0), + num_values * sizeof(*params)); +} + +void GetTexParameteriv(GLenum target, GLenum pname, GLint* params) { + helper_->GetTexParameteriv(target, pname, shared_memory_.GetId(), 0); + int32 token = helper_->InsertToken(); + helper_->WaitForToken(token); + GLsizei num_values = util_.GLGetNumValuesReturned(pname); + memcpy(params, shared_memory_.GetAddress(0), + num_values * sizeof(*params)); +} + +void GetUniformfv(GLuint program, GLint location, GLfloat* params); + +void GetUniformiv(GLuint program, GLint location, GLint* params); + +int GetUniformLocation(GLuint program, const char* name) { + // TODO(gman): This needs to change to use SendString. + helper_->GetUniformLocationImmediate(program, name); +} + +void GetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params) { + helper_->GetVertexAttribfv(index, pname, shared_memory_.GetId(), 0); + int32 token = helper_->InsertToken(); + helper_->WaitForToken(token); + GLsizei num_values = util_.GLGetNumValuesReturned(pname); + memcpy(params, shared_memory_.GetAddress(0), + num_values * sizeof(*params)); +} + +void GetVertexAttribiv(GLuint index, GLenum pname, GLint* params) { + helper_->GetVertexAttribiv(index, pname, shared_memory_.GetId(), 0); + int32 token = helper_->InsertToken(); + helper_->WaitForToken(token); + GLsizei num_values = util_.GLGetNumValuesReturned(pname); + memcpy(params, shared_memory_.GetAddress(0), + num_values * sizeof(*params)); +} + +void GetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer); + +void Hint(GLenum target, GLenum mode) { + helper_->Hint(target, mode); +} + +GLboolean IsBuffer(GLuint buffer) { + helper_->IsBuffer(buffer, shared_memory_.GetId(), 0); + int32 token = helper_->InsertToken(); + helper_->WaitForToken(token); + return *shared_memory_.GetAddressAs<GLboolean*>(0); +} + +GLboolean IsEnabled(GLenum cap) { + helper_->IsEnabled(cap, shared_memory_.GetId(), 0); + int32 token = helper_->InsertToken(); + helper_->WaitForToken(token); + return *shared_memory_.GetAddressAs<GLboolean*>(0); +} + +GLboolean IsFramebuffer(GLuint framebuffer) { + helper_->IsFramebuffer(framebuffer, shared_memory_.GetId(), 0); + int32 token = helper_->InsertToken(); + helper_->WaitForToken(token); + return *shared_memory_.GetAddressAs<GLboolean*>(0); +} + +GLboolean IsProgram(GLuint program) { + helper_->IsProgram(program, shared_memory_.GetId(), 0); + int32 token = helper_->InsertToken(); + helper_->WaitForToken(token); + return *shared_memory_.GetAddressAs<GLboolean*>(0); +} + +GLboolean IsRenderbuffer(GLuint renderbuffer) { + helper_->IsRenderbuffer(renderbuffer, shared_memory_.GetId(), 0); + int32 token = helper_->InsertToken(); + helper_->WaitForToken(token); + return *shared_memory_.GetAddressAs<GLboolean*>(0); +} + +GLboolean IsShader(GLuint shader) { + helper_->IsShader(shader, shared_memory_.GetId(), 0); + int32 token = helper_->InsertToken(); + helper_->WaitForToken(token); + return *shared_memory_.GetAddressAs<GLboolean*>(0); +} + +GLboolean IsTexture(GLuint texture) { + helper_->IsTexture(texture, shared_memory_.GetId(), 0); + int32 token = helper_->InsertToken(); + helper_->WaitForToken(token); + return *shared_memory_.GetAddressAs<GLboolean*>(0); +} + +void LineWidth(GLfloat width) { + helper_->LineWidth(width); +} + +void LinkProgram(GLuint program) { + helper_->LinkProgram(program); +} + +void PixelStorei(GLenum pname, GLint param) { + helper_->PixelStorei(pname, param); +} + +void PolygonOffset(GLfloat factor, GLfloat units) { + helper_->PolygonOffset(factor, units); +} + +void ReadPixels( + GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, + void* pixels); + +void RenderbufferStorage( + GLenum target, GLenum internalformat, GLsizei width, GLsizei height) { + helper_->RenderbufferStorage(target, internalformat, width, height); +} + +void SampleCoverage(GLclampf value, GLboolean invert) { + helper_->SampleCoverage(value, invert); +} + +void Scissor(GLint x, GLint y, GLsizei width, GLsizei height) { + helper_->Scissor(x, y, width, height); +} + +void ShaderSource( + GLuint shader, GLsizei count, const char** string, const GLint* length); + +void StencilFunc(GLenum func, GLint ref, GLuint mask) { + helper_->StencilFunc(func, ref, mask); +} + +void StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) { + helper_->StencilFuncSeparate(face, func, ref, mask); +} + +void StencilMask(GLuint mask) { + helper_->StencilMask(mask); +} + +void StencilMaskSeparate(GLenum face, GLuint mask) { + helper_->StencilMaskSeparate(face, mask); +} + +void StencilOp(GLenum fail, GLenum zfail, GLenum zpass) { + helper_->StencilOp(fail, zfail, zpass); +} + +void StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) { + helper_->StencilOpSeparate(face, fail, zfail, zpass); +} + +void TexImage2D( + GLenum target, GLint level, GLint internalformat, GLsizei width, + GLsizei height, GLint border, GLenum format, GLenum type, + const void* pixels); + +void TexParameterf(GLenum target, GLenum pname, GLfloat param) { + helper_->TexParameterf(target, pname, param); +} + +void TexParameterfv(GLenum target, GLenum pname, const GLfloat* params) { + helper_->TexParameterfvImmediate(target, pname, params); +} + +void TexParameteri(GLenum target, GLenum pname, GLint param) { + helper_->TexParameteri(target, pname, param); +} + +void TexParameteriv(GLenum target, GLenum pname, const GLint* params) { + helper_->TexParameterivImmediate(target, pname, params); +} + +void TexSubImage2D( + GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, + GLsizei height, GLenum format, GLenum type, const void* pixels); + +void Uniform1f(GLint location, GLfloat x) { + helper_->Uniform1f(location, x); +} + +void Uniform1fv(GLint location, GLsizei count, const GLfloat* v) { + helper_->Uniform1fvImmediate(location, count, v); +} + +void Uniform1i(GLint location, GLint x) { + helper_->Uniform1i(location, x); +} + +void Uniform1iv(GLint location, GLsizei count, const GLint* v) { + helper_->Uniform1ivImmediate(location, count, v); +} + +void Uniform2f(GLint location, GLfloat x, GLfloat y) { + helper_->Uniform2f(location, x, y); +} + +void Uniform2fv(GLint location, GLsizei count, const GLfloat* v) { + helper_->Uniform2fvImmediate(location, count, v); +} + +void Uniform2i(GLint location, GLint x, GLint y) { + helper_->Uniform2i(location, x, y); +} + +void Uniform2iv(GLint location, GLsizei count, const GLint* v) { + helper_->Uniform2ivImmediate(location, count, v); +} + +void Uniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) { + helper_->Uniform3f(location, x, y, z); +} + +void Uniform3fv(GLint location, GLsizei count, const GLfloat* v) { + helper_->Uniform3fvImmediate(location, count, v); +} + +void Uniform3i(GLint location, GLint x, GLint y, GLint z) { + helper_->Uniform3i(location, x, y, z); +} + +void Uniform3iv(GLint location, GLsizei count, const GLint* v) { + helper_->Uniform3ivImmediate(location, count, v); +} + +void Uniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) { + helper_->Uniform4f(location, x, y, z, w); +} + +void Uniform4fv(GLint location, GLsizei count, const GLfloat* v) { + helper_->Uniform4fvImmediate(location, count, v); +} + +void Uniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) { + helper_->Uniform4i(location, x, y, z, w); +} + +void Uniform4iv(GLint location, GLsizei count, const GLint* v) { + helper_->Uniform4ivImmediate(location, count, v); +} + +void UniformMatrix2fv( + GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) { + helper_->UniformMatrix2fvImmediate(location, count, transpose, value); +} + +void UniformMatrix3fv( + GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) { + helper_->UniformMatrix3fvImmediate(location, count, transpose, value); +} + +void UniformMatrix4fv( + GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) { + helper_->UniformMatrix4fvImmediate(location, count, transpose, value); +} + +void UseProgram(GLuint program) { + helper_->UseProgram(program); +} + +void ValidateProgram(GLuint program) { + helper_->ValidateProgram(program); +} + +void VertexAttrib1f(GLuint indx, GLfloat x) { + helper_->VertexAttrib1f(indx, x); +} + +void VertexAttrib1fv(GLuint indx, const GLfloat* values) { + helper_->VertexAttrib1fvImmediate(indx, values); +} + +void VertexAttrib2f(GLuint indx, GLfloat x, GLfloat y) { + helper_->VertexAttrib2f(indx, x, y); +} + +void VertexAttrib2fv(GLuint indx, const GLfloat* values) { + helper_->VertexAttrib2fvImmediate(indx, values); +} + +void VertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z) { + helper_->VertexAttrib3f(indx, x, y, z); +} + +void VertexAttrib3fv(GLuint indx, const GLfloat* values) { + helper_->VertexAttrib3fvImmediate(indx, values); +} + +void VertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w) { + helper_->VertexAttrib4f(indx, x, y, z, w); +} + +void VertexAttrib4fv(GLuint indx, const GLfloat* values) { + helper_->VertexAttrib4fvImmediate(indx, values); +} + +void VertexAttribPointer( + GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, + const void* ptr); + +void Viewport(GLint x, GLint y, GLsizei width, GLsizei height) { + helper_->Viewport(x, y, width, height); +} + diff --git a/o3d/gpu/command_buffer/client/gles2_implementation_gen.h b/o3d/gpu/command_buffer/client/gles2_implementation_gen.h new file mode 100644 index 0000000..848a2f5 --- /dev/null +++ b/o3d/gpu/command_buffer/client/gles2_implementation_gen.h @@ -0,0 +1,70 @@ +// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// A class to emluate GLES2 over command buffers. + +#include "gpu/command_buffer/client/gles2_implementation.h" + +namespace command_buffer { +namespace gles2 { + +GLenum GLES2Implementation::CheckFramebufferStatus(GLenum target) { + return 0; +} + +void GLES2Implementation::GetActiveAttrib( + GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, + GLenum* type, char* name) { +} + +void GLES2Implementation::GetActiveUniform( + GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, + GLenum* type, char* name) { +} + +void GLES2Implementation::GetAttachedShaders( + GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) { +} + +void GLES2Implementation::GetProgramInfoLog( + GLuint program, GLsizei bufsize, GLsizei* length, char* infolog) { +} + +void GLES2Implementation::GetShaderInfoLog( + GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog) { +} + +void GLES2Implementation::GetShaderPrecisionFormat( + GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) { +} + +void GLES2Implementation::GetShaderSource( + GLuint shader, GLsizei bufsize, GLsizei* length, char* source) { +} + +const GLubyte* GLES2Implementation::GetString(GLenum name) { + return 0; +} + +void GLES2Implementation::GetUniformfv( + GLuint program, GLint location, GLfloat* params) { +} + +void GLES2Implementation::GetUniformiv( + GLuint program, GLint location, GLint* params) { +} + +void GLES2Implementation::GetVertexAttribPointerv( + GLuint index, GLenum pname, void** pointer) { +} + +void GLES2Implementation::ReadPixels( + GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, + void* pixels) { +} + + +} // namespace gles2 +} // namespace command_buffer + diff --git a/o3d/gpu/command_buffer/client/gles2_lib.cc b/o3d/gpu/command_buffer/client/gles2_lib.cc new file mode 100644 index 0000000..924eb19 --- /dev/null +++ b/o3d/gpu/command_buffer/client/gles2_lib.cc @@ -0,0 +1,15 @@ +// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "gpu/command_buffer/client/gles2_lib.h" + +namespace gles2 { + +// Currently this is a place holder. + +} // namespace gles2 + + + + diff --git a/o3d/gpu/command_buffer/client/gles2_lib.h b/o3d/gpu/command_buffer/client/gles2_lib.h new file mode 100644 index 0000000..6cb413f --- /dev/null +++ b/o3d/gpu/command_buffer/client/gles2_lib.h @@ -0,0 +1,24 @@ +// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// These functions emluate GLES2 over command buffers. + +#ifndef GPU_COMMAND_BUFFER_CLIENT_GLES2_LIB_H +#define GPU_COMMAND_BUFFER_CLIENT_GLES2_LIB_H + +#include "gpu/command_buffer/client/gles2_implementation.h" + +namespace gles2 { + +extern ::command_buffer::gles2::GLES2Implementation* g_gl_impl; + +// Include the auto-generated part of this file. We split this because it means +// we can easily edit the non-auto generated parts right here in this file +// instead of having to edit some template or the code generator. +#include "gpu/command_buffer/client/gles2_lib_autogen.h" + +} // namespace gles2 + +#endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_LIB_H + diff --git a/o3d/gpu/command_buffer/client/gles2_lib_autogen.h b/o3d/gpu/command_buffer/client/gles2_lib_autogen.h new file mode 100644 index 0000000..d928c8c --- /dev/null +++ b/o3d/gpu/command_buffer/client/gles2_lib_autogen.h @@ -0,0 +1,493 @@ +// This file is auto-generated. DO NOT EDIT! + + +// These functions emluate GLES2 over command buffers. + + +inline void glActiveTexture(GLenum texture) { + g_gl_impl->ActiveTexture(texture); +} +inline void glAttachShader(GLuint program, GLuint shader) { + g_gl_impl->AttachShader(program, shader); +} +inline void glBindAttribLocation( + GLuint program, GLuint index, const char* name) { + g_gl_impl->BindAttribLocation(program, index, name); +} +inline void glBindBuffer(GLenum target, GLuint buffer) { + g_gl_impl->BindBuffer(target, buffer); +} +inline void glBindFramebuffer(GLenum target, GLuint framebuffer) { + g_gl_impl->BindFramebuffer(target, framebuffer); +} +inline void glBindRenderbuffer(GLenum target, GLuint renderbuffer) { + g_gl_impl->BindRenderbuffer(target, renderbuffer); +} +inline void glBindTexture(GLenum target, GLuint texture) { + g_gl_impl->BindTexture(target, texture); +} +inline void glBlendColor( + GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) { + g_gl_impl->BlendColor(red, green, blue, alpha); +} +inline void glBlendEquation(GLenum mode) { + g_gl_impl->BlendEquation(mode); +} +inline void glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) { + g_gl_impl->BlendEquationSeparate(modeRGB, modeAlpha); +} +inline void glBlendFunc(GLenum sfactor, GLenum dfactor) { + g_gl_impl->BlendFunc(sfactor, dfactor); +} +inline void glBlendFuncSeparate( + GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) { + g_gl_impl->BlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha); +} +inline void glBufferData( + GLenum target, GLsizeiptr size, const void* data, GLenum usage) { + g_gl_impl->BufferData(target, size, data, usage); +} +inline void glBufferSubData( + GLenum target, GLintptr offset, GLsizeiptr size, const void* data) { + g_gl_impl->BufferSubData(target, offset, size, data); +} +inline GLenum glCheckFramebufferStatus(GLenum target) { + return g_gl_impl->CheckFramebufferStatus(target); +} +inline void glClear(GLbitfield mask) { + g_gl_impl->Clear(mask); +} +inline void glClearColor( + GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) { + g_gl_impl->ClearColor(red, green, blue, alpha); +} +inline void glClearDepthf(GLclampf depth) { + g_gl_impl->ClearDepthf(depth); +} +inline void glClearStencil(GLint s) { + g_gl_impl->ClearStencil(s); +} +inline void glColorMask( + GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) { + g_gl_impl->ColorMask(red, green, blue, alpha); +} +inline void glCompileShader(GLuint shader) { + g_gl_impl->CompileShader(shader); +} +inline void glCompressedTexImage2D( + GLenum target, GLint level, GLenum internalformat, GLsizei width, + GLsizei height, GLint border, GLsizei imageSize, const void* data) { + g_gl_impl->CompressedTexImage2D( + target, level, internalformat, width, height, border, imageSize, data); +} +inline void glCompressedTexSubImage2D( + GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, + GLsizei height, GLenum format, GLsizei imageSize, const void* data) { + g_gl_impl->CompressedTexSubImage2D( + target, level, xoffset, yoffset, width, height, format, imageSize, data); +} +inline void glCopyTexImage2D( + GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, + GLsizei width, GLsizei height, GLint border) { + g_gl_impl->CopyTexImage2D( + target, level, internalformat, x, y, width, height, border); +} +inline void glCopyTexSubImage2D( + GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, + GLsizei width, GLsizei height) { + g_gl_impl->CopyTexSubImage2D( + target, level, xoffset, yoffset, x, y, width, height); +} +inline GLuint glCreateProgram() { + return g_gl_impl->CreateProgram(); +} +inline GLuint glCreateShader(GLenum type) { + return g_gl_impl->CreateShader(type); +} +inline void glCullFace(GLenum mode) { + g_gl_impl->CullFace(mode); +} +inline void glDeleteBuffers(GLsizei n, const GLuint* buffers) { + g_gl_impl->DeleteBuffers(n, buffers); +} +inline void glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers) { + g_gl_impl->DeleteFramebuffers(n, framebuffers); +} +inline void glDeleteProgram(GLuint program) { + g_gl_impl->DeleteProgram(program); +} +inline void glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers) { + g_gl_impl->DeleteRenderbuffers(n, renderbuffers); +} +inline void glDeleteShader(GLuint shader) { + g_gl_impl->DeleteShader(shader); +} +inline void glDeleteTextures(GLsizei n, const GLuint* textures) { + g_gl_impl->DeleteTextures(n, textures); +} +inline void glDepthFunc(GLenum func) { + g_gl_impl->DepthFunc(func); +} +inline void glDepthMask(GLboolean flag) { + g_gl_impl->DepthMask(flag); +} +inline void glDepthRangef(GLclampf zNear, GLclampf zFar) { + g_gl_impl->DepthRangef(zNear, zFar); +} +inline void glDetachShader(GLuint program, GLuint shader) { + g_gl_impl->DetachShader(program, shader); +} +inline void glDisable(GLenum cap) { + g_gl_impl->Disable(cap); +} +inline void glDisableVertexAttribArray(GLuint index) { + g_gl_impl->DisableVertexAttribArray(index); +} +inline void glDrawArrays(GLenum mode, GLint first, GLsizei count) { + g_gl_impl->DrawArrays(mode, first, count); +} +inline void glDrawElements( + GLenum mode, GLsizei count, GLenum type, const void* indices) { + g_gl_impl->DrawElements(mode, count, type, indices); +} +inline void glEnable(GLenum cap) { + g_gl_impl->Enable(cap); +} +inline void glEnableVertexAttribArray(GLuint index) { + g_gl_impl->EnableVertexAttribArray(index); +} +inline void glFinish() { + g_gl_impl->Finish(); +} +inline void glFlush() { + g_gl_impl->Flush(); +} +inline void glFramebufferRenderbuffer( + GLenum target, GLenum attachment, GLenum renderbuffertarget, + GLuint renderbuffer) { + g_gl_impl->FramebufferRenderbuffer( + target, attachment, renderbuffertarget, renderbuffer); +} +inline void glFramebufferTexture2D( + GLenum target, GLenum attachment, GLenum textarget, GLuint texture, + GLint level) { + g_gl_impl->FramebufferTexture2D( + target, attachment, textarget, texture, level); +} +inline void glFrontFace(GLenum mode) { + g_gl_impl->FrontFace(mode); +} +inline void glGenBuffers(GLsizei n, GLuint* buffers) { + g_gl_impl->GenBuffers(n, buffers); +} +inline void glGenerateMipmap(GLenum target) { + g_gl_impl->GenerateMipmap(target); +} +inline void glGenFramebuffers(GLsizei n, GLuint* framebuffers) { + g_gl_impl->GenFramebuffers(n, framebuffers); +} +inline void glGenRenderbuffers(GLsizei n, GLuint* renderbuffers) { + g_gl_impl->GenRenderbuffers(n, renderbuffers); +} +inline void glGenTextures(GLsizei n, GLuint* textures) { + g_gl_impl->GenTextures(n, textures); +} +inline void glGetActiveAttrib( + GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, + GLenum* type, char* name) { + g_gl_impl->GetActiveAttrib( + program, index, bufsize, length, size, type, name); +} +inline void glGetActiveUniform( + GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, + GLenum* type, char* name) { + g_gl_impl->GetActiveUniform( + program, index, bufsize, length, size, type, name); +} +inline void glGetAttachedShaders( + GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) { + g_gl_impl->GetAttachedShaders(program, maxcount, count, shaders); +} +inline int glGetAttribLocation(GLuint program, const char* name) { + return g_gl_impl->GetAttribLocation(program, name); +} +inline void glGetBooleanv(GLenum pname, GLboolean* params) { + g_gl_impl->GetBooleanv(pname, params); +} +inline void glGetBufferParameteriv( + GLenum target, GLenum pname, GLint* params) { + g_gl_impl->GetBufferParameteriv(target, pname, params); +} +inline GLenum glGetError() { + return g_gl_impl->GetError(); +} +inline void glGetFloatv(GLenum pname, GLfloat* params) { + g_gl_impl->GetFloatv(pname, params); +} +inline void glGetFramebufferAttachmentParameteriv( + GLenum target, GLenum attachment, GLenum pname, GLint* params) { + g_gl_impl->GetFramebufferAttachmentParameteriv( + target, attachment, pname, params); +} +inline void glGetIntegerv(GLenum pname, GLint* params) { + g_gl_impl->GetIntegerv(pname, params); +} +inline void glGetProgramiv(GLuint program, GLenum pname, GLint* params) { + g_gl_impl->GetProgramiv(program, pname, params); +} +inline void glGetProgramInfoLog( + GLuint program, GLsizei bufsize, GLsizei* length, char* infolog) { + g_gl_impl->GetProgramInfoLog(program, bufsize, length, infolog); +} +inline void glGetRenderbufferParameteriv( + GLenum target, GLenum pname, GLint* params) { + g_gl_impl->GetRenderbufferParameteriv(target, pname, params); +} +inline void glGetShaderiv(GLuint shader, GLenum pname, GLint* params) { + g_gl_impl->GetShaderiv(shader, pname, params); +} +inline void glGetShaderInfoLog( + GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog) { + g_gl_impl->GetShaderInfoLog(shader, bufsize, length, infolog); +} +inline void glGetShaderPrecisionFormat( + GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) { + g_gl_impl->GetShaderPrecisionFormat( + shadertype, precisiontype, range, precision); +} +inline void glGetShaderSource( + GLuint shader, GLsizei bufsize, GLsizei* length, char* source) { + g_gl_impl->GetShaderSource(shader, bufsize, length, source); +} +inline const GLubyte* glGetString(GLenum name) { + return g_gl_impl->GetString(name); +} +inline void glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) { + g_gl_impl->GetTexParameterfv(target, pname, params); +} +inline void glGetTexParameteriv(GLenum target, GLenum pname, GLint* params) { + g_gl_impl->GetTexParameteriv(target, pname, params); +} +inline void glGetUniformfv(GLuint program, GLint location, GLfloat* params) { + g_gl_impl->GetUniformfv(program, location, params); +} +inline void glGetUniformiv(GLuint program, GLint location, GLint* params) { + g_gl_impl->GetUniformiv(program, location, params); +} +inline int glGetUniformLocation(GLuint program, const char* name) { + return g_gl_impl->GetUniformLocation(program, name); +} +inline void glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params) { + g_gl_impl->GetVertexAttribfv(index, pname, params); +} +inline void glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params) { + g_gl_impl->GetVertexAttribiv(index, pname, params); +} +inline void glGetVertexAttribPointerv( + GLuint index, GLenum pname, void** pointer) { + g_gl_impl->GetVertexAttribPointerv(index, pname, pointer); +} +inline void glHint(GLenum target, GLenum mode) { + g_gl_impl->Hint(target, mode); +} +inline GLboolean glIsBuffer(GLuint buffer) { + return g_gl_impl->IsBuffer(buffer); +} +inline GLboolean glIsEnabled(GLenum cap) { + return g_gl_impl->IsEnabled(cap); +} +inline GLboolean glIsFramebuffer(GLuint framebuffer) { + return g_gl_impl->IsFramebuffer(framebuffer); +} +inline GLboolean glIsProgram(GLuint program) { + return g_gl_impl->IsProgram(program); +} +inline GLboolean glIsRenderbuffer(GLuint renderbuffer) { + return g_gl_impl->IsRenderbuffer(renderbuffer); +} +inline GLboolean glIsShader(GLuint shader) { + return g_gl_impl->IsShader(shader); +} +inline GLboolean glIsTexture(GLuint texture) { + return g_gl_impl->IsTexture(texture); +} +inline void glLineWidth(GLfloat width) { + g_gl_impl->LineWidth(width); +} +inline void glLinkProgram(GLuint program) { + g_gl_impl->LinkProgram(program); +} +inline void glPixelStorei(GLenum pname, GLint param) { + g_gl_impl->PixelStorei(pname, param); +} +inline void glPolygonOffset(GLfloat factor, GLfloat units) { + g_gl_impl->PolygonOffset(factor, units); +} +inline void glReadPixels( + GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, + void* pixels) { + g_gl_impl->ReadPixels(x, y, width, height, format, type, pixels); +} +inline void glRenderbufferStorage( + GLenum target, GLenum internalformat, GLsizei width, GLsizei height) { + g_gl_impl->RenderbufferStorage(target, internalformat, width, height); +} +inline void glSampleCoverage(GLclampf value, GLboolean invert) { + g_gl_impl->SampleCoverage(value, invert); +} +inline void glScissor(GLint x, GLint y, GLsizei width, GLsizei height) { + g_gl_impl->Scissor(x, y, width, height); +} +inline void glShaderSource( + GLuint shader, GLsizei count, const char** string, const GLint* length) { + g_gl_impl->ShaderSource(shader, count, string, length); +} +inline void glStencilFunc(GLenum func, GLint ref, GLuint mask) { + g_gl_impl->StencilFunc(func, ref, mask); +} +inline void glStencilFuncSeparate( + GLenum face, GLenum func, GLint ref, GLuint mask) { + g_gl_impl->StencilFuncSeparate(face, func, ref, mask); +} +inline void glStencilMask(GLuint mask) { + g_gl_impl->StencilMask(mask); +} +inline void glStencilMaskSeparate(GLenum face, GLuint mask) { + g_gl_impl->StencilMaskSeparate(face, mask); +} +inline void glStencilOp(GLenum fail, GLenum zfail, GLenum zpass) { + g_gl_impl->StencilOp(fail, zfail, zpass); +} +inline void glStencilOpSeparate( + GLenum face, GLenum fail, GLenum zfail, GLenum zpass) { + g_gl_impl->StencilOpSeparate(face, fail, zfail, zpass); +} +inline void glTexImage2D( + GLenum target, GLint level, GLint internalformat, GLsizei width, + GLsizei height, GLint border, GLenum format, GLenum type, + const void* pixels) { + g_gl_impl->TexImage2D( + target, level, internalformat, width, height, border, format, type, + pixels); +} +inline void glTexParameterf(GLenum target, GLenum pname, GLfloat param) { + g_gl_impl->TexParameterf(target, pname, param); +} +inline void glTexParameterfv( + GLenum target, GLenum pname, const GLfloat* params) { + g_gl_impl->TexParameterfv(target, pname, params); +} +inline void glTexParameteri(GLenum target, GLenum pname, GLint param) { + g_gl_impl->TexParameteri(target, pname, param); +} +inline void glTexParameteriv( + GLenum target, GLenum pname, const GLint* params) { + g_gl_impl->TexParameteriv(target, pname, params); +} +inline void glTexSubImage2D( + GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, + GLsizei height, GLenum format, GLenum type, const void* pixels) { + g_gl_impl->TexSubImage2D( + target, level, xoffset, yoffset, width, height, format, type, pixels); +} +inline void glUniform1f(GLint location, GLfloat x) { + g_gl_impl->Uniform1f(location, x); +} +inline void glUniform1fv(GLint location, GLsizei count, const GLfloat* v) { + g_gl_impl->Uniform1fv(location, count, v); +} +inline void glUniform1i(GLint location, GLint x) { + g_gl_impl->Uniform1i(location, x); +} +inline void glUniform1iv(GLint location, GLsizei count, const GLint* v) { + g_gl_impl->Uniform1iv(location, count, v); +} +inline void glUniform2f(GLint location, GLfloat x, GLfloat y) { + g_gl_impl->Uniform2f(location, x, y); +} +inline void glUniform2fv(GLint location, GLsizei count, const GLfloat* v) { + g_gl_impl->Uniform2fv(location, count, v); +} +inline void glUniform2i(GLint location, GLint x, GLint y) { + g_gl_impl->Uniform2i(location, x, y); +} +inline void glUniform2iv(GLint location, GLsizei count, const GLint* v) { + g_gl_impl->Uniform2iv(location, count, v); +} +inline void glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) { + g_gl_impl->Uniform3f(location, x, y, z); +} +inline void glUniform3fv(GLint location, GLsizei count, const GLfloat* v) { + g_gl_impl->Uniform3fv(location, count, v); +} +inline void glUniform3i(GLint location, GLint x, GLint y, GLint z) { + g_gl_impl->Uniform3i(location, x, y, z); +} +inline void glUniform3iv(GLint location, GLsizei count, const GLint* v) { + g_gl_impl->Uniform3iv(location, count, v); +} +inline void glUniform4f( + GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) { + g_gl_impl->Uniform4f(location, x, y, z, w); +} +inline void glUniform4fv(GLint location, GLsizei count, const GLfloat* v) { + g_gl_impl->Uniform4fv(location, count, v); +} +inline void glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) { + g_gl_impl->Uniform4i(location, x, y, z, w); +} +inline void glUniform4iv(GLint location, GLsizei count, const GLint* v) { + g_gl_impl->Uniform4iv(location, count, v); +} +inline void glUniformMatrix2fv( + GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) { + g_gl_impl->UniformMatrix2fv(location, count, transpose, value); +} +inline void glUniformMatrix3fv( + GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) { + g_gl_impl->UniformMatrix3fv(location, count, transpose, value); +} +inline void glUniformMatrix4fv( + GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) { + g_gl_impl->UniformMatrix4fv(location, count, transpose, value); +} +inline void glUseProgram(GLuint program) { + g_gl_impl->UseProgram(program); +} +inline void glValidateProgram(GLuint program) { + g_gl_impl->ValidateProgram(program); +} +inline void glVertexAttrib1f(GLuint indx, GLfloat x) { + g_gl_impl->VertexAttrib1f(indx, x); +} +inline void glVertexAttrib1fv(GLuint indx, const GLfloat* values) { + g_gl_impl->VertexAttrib1fv(indx, values); +} +inline void glVertexAttrib2f(GLuint indx, GLfloat x, GLfloat y) { + g_gl_impl->VertexAttrib2f(indx, x, y); +} +inline void glVertexAttrib2fv(GLuint indx, const GLfloat* values) { + g_gl_impl->VertexAttrib2fv(indx, values); +} +inline void glVertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z) { + g_gl_impl->VertexAttrib3f(indx, x, y, z); +} +inline void glVertexAttrib3fv(GLuint indx, const GLfloat* values) { + g_gl_impl->VertexAttrib3fv(indx, values); +} +inline void glVertexAttrib4f( + GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w) { + g_gl_impl->VertexAttrib4f(indx, x, y, z, w); +} +inline void glVertexAttrib4fv(GLuint indx, const GLfloat* values) { + g_gl_impl->VertexAttrib4fv(indx, values); +} +inline void glVertexAttribPointer( + GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, + const void* ptr) { + g_gl_impl->VertexAttribPointer(indx, size, type, normalized, stride, ptr); +} +inline void glViewport(GLint x, GLint y, GLsizei width, GLsizei height) { + g_gl_impl->Viewport(x, y, width, height); +} + diff --git a/o3d/gpu/command_buffer/common/cmd_buffer_common.h b/o3d/gpu/command_buffer/common/cmd_buffer_common.h index 0e44f86..b17b135 100644 --- a/o3d/gpu/command_buffer/common/cmd_buffer_common.h +++ b/o3d/gpu/command_buffer/common/cmd_buffer_common.h @@ -80,11 +80,20 @@ struct CommandHeader { Init(T::kCmdId, ComputeNumEntries(sizeof(T))); // NOLINT } + // Sets the header by a size in bytes of the immediate data after the command. + template <typename T> + void SetCmdBySize(uint32 size_of_data_in_bytes) { + COMPILE_ASSERT(T::kArgFlags == cmd::kAtLeastN, Cmd_kArgFlags_not_kAtLeastN); + Init(T::kCmdId, + ComputeNumEntries(sizeof(T) + size_of_data_in_bytes)); // NOLINT + } + // Sets the header by a size in bytes. template <typename T> - void SetCmdBySize(uint32 size_in_bytes) { + void SetCmdByTotalSize(uint32 size_in_bytes) { COMPILE_ASSERT(T::kArgFlags == cmd::kAtLeastN, Cmd_kArgFlags_not_kAtLeastN); - Init(T::kCmdId, ComputeNumEntries(sizeof(T) + size_in_bytes)); // NOLINT + DCHECK_GE(size_in_bytes, sizeof(T)); // NOLINT + Init(T::kCmdId, ComputeNumEntries(size_in_bytes)); } }; @@ -139,6 +148,19 @@ void* NextImmediateCmdAddress(void* cmd, uint32 size_of_data_in_bytes) { RoundSizeToMultipleOfEntries(size_of_data_in_bytes); } +// Gets the address of the place to put the next command in a typesafe way. +// This can only be used for variable sized command like IMMEDIATE commands. +// Parameters: +// cmd: Address of command. +// size_of_cmd_in_bytes: Size of the cmd and data. +template <typename T> +void* NextImmediateCmdAddressTotalSize(void* cmd, uint32 total_size_in_bytes) { + COMPILE_ASSERT(T::kArgFlags == cmd::kAtLeastN, Cmd_kArgFlags_not_kAtLeastN); + DCHECK_GE(total_size_in_bytes, sizeof(T)); // NOLINT + return reinterpret_cast<char*>(cmd) + + RoundSizeToMultipleOfEntries(total_size_in_bytes); +} + struct SharedMemory { void Init(uint32 _id, uint32 _offset) { id = _id; diff --git a/o3d/gpu/command_buffer/common/gles2_cmd_format.cc b/o3d/gpu/command_buffer/common/gles2_cmd_format.cc new file mode 100644 index 0000000..ab8cb5c --- /dev/null +++ b/o3d/gpu/command_buffer/common/gles2_cmd_format.cc @@ -0,0 +1,29 @@ +// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This file contains the binary format definition of the command buffer and +// command buffer commands. + +#include "gpu/command_buffer/common/gles2_cmd_format.h" + +namespace command_buffer { +namespace gles2 { + +const char* GetCommandName(CommandId id) { + static const char* const names[] = { + #define GLES2_CMD_OP(name) "k" # name, + + GLES2_COMMAND_LIST(GLES2_CMD_OP) + + #undef GLES2_CMD_OP + }; + + return (static_cast<int>(id) >= 0 && static_cast<int>(id) < kNumCommands) ? + names[id] : "*unknown-command*"; +} + +} // namespace gles2 +} // namespace command_buffer + + diff --git a/o3d/gpu/command_buffer/common/gles2_cmd_format.h b/o3d/gpu/command_buffer/common/gles2_cmd_format.h new file mode 100644 index 0000000..4c40c1f --- /dev/null +++ b/o3d/gpu/command_buffer/common/gles2_cmd_format.h @@ -0,0 +1,8447 @@ +// This file is auto-generated. DO NOT EDIT! + + +#ifndef O3D_SPUD_O3D_GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_FORMAT_H +#define O3D_SPUD_O3D_GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_FORMAT_H + +#include "gpu/command_buffer/common/gles2_cmd_utils.h" +#include "gpu/command_buffer/common/cmd_buffer_common.h" + +namespace command_buffer { +namespace gles2 { + +#define GLES2_COMMAND_LIST(OP) \ + OP(ActiveTexture) /* 1024 */ \ + OP(AttachShader) /* 1025 */ \ + OP(BindAttribLocation) /* 1026 */ \ + OP(BindAttribLocationImmediate) /* 1027 */ \ + OP(BindBuffer) /* 1028 */ \ + OP(BindFramebuffer) /* 1029 */ \ + OP(BindRenderbuffer) /* 1030 */ \ + OP(BindTexture) /* 1031 */ \ + OP(BlendColor) /* 1032 */ \ + OP(BlendEquation) /* 1033 */ \ + OP(BlendEquationSeparate) /* 1034 */ \ + OP(BlendFunc) /* 1035 */ \ + OP(BlendFuncSeparate) /* 1036 */ \ + OP(BufferData) /* 1037 */ \ + OP(BufferDataImmediate) /* 1038 */ \ + OP(BufferSubData) /* 1039 */ \ + OP(BufferSubDataImmediate) /* 1040 */ \ + OP(CheckFramebufferStatus) /* 1041 */ \ + OP(Clear) /* 1042 */ \ + OP(ClearColor) /* 1043 */ \ + OP(ClearDepthf) /* 1044 */ \ + OP(ClearStencil) /* 1045 */ \ + OP(ColorMask) /* 1046 */ \ + OP(CompileShader) /* 1047 */ \ + OP(CompressedTexImage2D) /* 1048 */ \ + OP(CompressedTexImage2DImmediate) /* 1049 */ \ + OP(CompressedTexSubImage2D) /* 1050 */ \ + OP(CompressedTexSubImage2DImmediate) /* 1051 */ \ + OP(CopyTexImage2D) /* 1052 */ \ + OP(CopyTexSubImage2D) /* 1053 */ \ + OP(CreateProgram) /* 1054 */ \ + OP(CreateShader) /* 1055 */ \ + OP(CullFace) /* 1056 */ \ + OP(DeleteBuffers) /* 1057 */ \ + OP(DeleteBuffersImmediate) /* 1058 */ \ + OP(DeleteFramebuffers) /* 1059 */ \ + OP(DeleteFramebuffersImmediate) /* 1060 */ \ + OP(DeleteProgram) /* 1061 */ \ + OP(DeleteRenderbuffers) /* 1062 */ \ + OP(DeleteRenderbuffersImmediate) /* 1063 */ \ + OP(DeleteShader) /* 1064 */ \ + OP(DeleteTextures) /* 1065 */ \ + OP(DeleteTexturesImmediate) /* 1066 */ \ + OP(DepthFunc) /* 1067 */ \ + OP(DepthMask) /* 1068 */ \ + OP(DepthRangef) /* 1069 */ \ + OP(DetachShader) /* 1070 */ \ + OP(Disable) /* 1071 */ \ + OP(DisableVertexAttribArray) /* 1072 */ \ + OP(DrawArrays) /* 1073 */ \ + OP(DrawElements) /* 1074 */ \ + OP(Enable) /* 1075 */ \ + OP(EnableVertexAttribArray) /* 1076 */ \ + OP(Finish) /* 1077 */ \ + OP(Flush) /* 1078 */ \ + OP(FramebufferRenderbuffer) /* 1079 */ \ + OP(FramebufferTexture2D) /* 1080 */ \ + OP(FrontFace) /* 1081 */ \ + OP(GenBuffers) /* 1082 */ \ + OP(GenBuffersImmediate) /* 1083 */ \ + OP(GenerateMipmap) /* 1084 */ \ + OP(GenFramebuffers) /* 1085 */ \ + OP(GenFramebuffersImmediate) /* 1086 */ \ + OP(GenRenderbuffers) /* 1087 */ \ + OP(GenRenderbuffersImmediate) /* 1088 */ \ + OP(GenTextures) /* 1089 */ \ + OP(GenTexturesImmediate) /* 1090 */ \ + OP(GetActiveAttrib) /* 1091 */ \ + OP(GetActiveUniform) /* 1092 */ \ + OP(GetAttachedShaders) /* 1093 */ \ + OP(GetAttribLocation) /* 1094 */ \ + OP(GetAttribLocationImmediate) /* 1095 */ \ + OP(GetBooleanv) /* 1096 */ \ + OP(GetBufferParameteriv) /* 1097 */ \ + OP(GetError) /* 1098 */ \ + OP(GetFloatv) /* 1099 */ \ + OP(GetFramebufferAttachmentParameteriv) /* 1100 */ \ + OP(GetIntegerv) /* 1101 */ \ + OP(GetProgramiv) /* 1102 */ \ + OP(GetProgramInfoLog) /* 1103 */ \ + OP(GetRenderbufferParameteriv) /* 1104 */ \ + OP(GetShaderiv) /* 1105 */ \ + OP(GetShaderInfoLog) /* 1106 */ \ + OP(GetShaderPrecisionFormat) /* 1107 */ \ + OP(GetShaderSource) /* 1108 */ \ + OP(GetString) /* 1109 */ \ + OP(GetTexParameterfv) /* 1110 */ \ + OP(GetTexParameteriv) /* 1111 */ \ + OP(GetUniformfv) /* 1112 */ \ + OP(GetUniformiv) /* 1113 */ \ + OP(GetUniformLocation) /* 1114 */ \ + OP(GetUniformLocationImmediate) /* 1115 */ \ + OP(GetVertexAttribfv) /* 1116 */ \ + OP(GetVertexAttribiv) /* 1117 */ \ + OP(GetVertexAttribPointerv) /* 1118 */ \ + OP(Hint) /* 1119 */ \ + OP(IsBuffer) /* 1120 */ \ + OP(IsEnabled) /* 1121 */ \ + OP(IsFramebuffer) /* 1122 */ \ + OP(IsProgram) /* 1123 */ \ + OP(IsRenderbuffer) /* 1124 */ \ + OP(IsShader) /* 1125 */ \ + OP(IsTexture) /* 1126 */ \ + OP(LineWidth) /* 1127 */ \ + OP(LinkProgram) /* 1128 */ \ + OP(PixelStorei) /* 1129 */ \ + OP(PolygonOffset) /* 1130 */ \ + OP(ReadPixels) /* 1131 */ \ + OP(RenderbufferStorage) /* 1132 */ \ + OP(SampleCoverage) /* 1133 */ \ + OP(Scissor) /* 1134 */ \ + OP(ShaderSource) /* 1135 */ \ + OP(ShaderSourceImmediate) /* 1136 */ \ + OP(StencilFunc) /* 1137 */ \ + OP(StencilFuncSeparate) /* 1138 */ \ + OP(StencilMask) /* 1139 */ \ + OP(StencilMaskSeparate) /* 1140 */ \ + OP(StencilOp) /* 1141 */ \ + OP(StencilOpSeparate) /* 1142 */ \ + OP(TexImage2D) /* 1143 */ \ + OP(TexImage2DImmediate) /* 1144 */ \ + OP(TexParameterf) /* 1145 */ \ + OP(TexParameterfv) /* 1146 */ \ + OP(TexParameterfvImmediate) /* 1147 */ \ + OP(TexParameteri) /* 1148 */ \ + OP(TexParameteriv) /* 1149 */ \ + OP(TexParameterivImmediate) /* 1150 */ \ + OP(TexSubImage2D) /* 1151 */ \ + OP(TexSubImage2DImmediate) /* 1152 */ \ + OP(Uniform1f) /* 1153 */ \ + OP(Uniform1fv) /* 1154 */ \ + OP(Uniform1fvImmediate) /* 1155 */ \ + OP(Uniform1i) /* 1156 */ \ + OP(Uniform1iv) /* 1157 */ \ + OP(Uniform1ivImmediate) /* 1158 */ \ + OP(Uniform2f) /* 1159 */ \ + OP(Uniform2fv) /* 1160 */ \ + OP(Uniform2fvImmediate) /* 1161 */ \ + OP(Uniform2i) /* 1162 */ \ + OP(Uniform2iv) /* 1163 */ \ + OP(Uniform2ivImmediate) /* 1164 */ \ + OP(Uniform3f) /* 1165 */ \ + OP(Uniform3fv) /* 1166 */ \ + OP(Uniform3fvImmediate) /* 1167 */ \ + OP(Uniform3i) /* 1168 */ \ + OP(Uniform3iv) /* 1169 */ \ + OP(Uniform3ivImmediate) /* 1170 */ \ + OP(Uniform4f) /* 1171 */ \ + OP(Uniform4fv) /* 1172 */ \ + OP(Uniform4fvImmediate) /* 1173 */ \ + OP(Uniform4i) /* 1174 */ \ + OP(Uniform4iv) /* 1175 */ \ + OP(Uniform4ivImmediate) /* 1176 */ \ + OP(UniformMatrix2fv) /* 1177 */ \ + OP(UniformMatrix2fvImmediate) /* 1178 */ \ + OP(UniformMatrix3fv) /* 1179 */ \ + OP(UniformMatrix3fvImmediate) /* 1180 */ \ + OP(UniformMatrix4fv) /* 1181 */ \ + OP(UniformMatrix4fvImmediate) /* 1182 */ \ + OP(UseProgram) /* 1183 */ \ + OP(ValidateProgram) /* 1184 */ \ + OP(VertexAttrib1f) /* 1185 */ \ + OP(VertexAttrib1fv) /* 1186 */ \ + OP(VertexAttrib1fvImmediate) /* 1187 */ \ + OP(VertexAttrib2f) /* 1188 */ \ + OP(VertexAttrib2fv) /* 1189 */ \ + OP(VertexAttrib2fvImmediate) /* 1190 */ \ + OP(VertexAttrib3f) /* 1191 */ \ + OP(VertexAttrib3fv) /* 1192 */ \ + OP(VertexAttrib3fvImmediate) /* 1193 */ \ + OP(VertexAttrib4f) /* 1194 */ \ + OP(VertexAttrib4fv) /* 1195 */ \ + OP(VertexAttrib4fvImmediate) /* 1196 */ \ + OP(VertexAttribPointer) /* 1197 */ \ + OP(Viewport) /* 1198 */ \ + +enum CommandId { + kStartPoint = cmd::kLastCommonId, // All GLES2 commands start after this. +#define GLES2_CMD_OP(name) k ## name, + GLES2_COMMAND_LIST(GLES2_CMD_OP) +#undef GLES2_CMD_OP + kNumCommands +}; + +#pragma pack(push, 1) + +struct ActiveTexture { + typedef ActiveTexture ValueType; + static const CommandId kCmdId = kActiveTexture; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLenum _texture) { + SetHeader(); + texture = _texture; + } + + void* Set(void* cmd, GLenum _texture) { + static_cast<ValueType*>(cmd)->Init(_texture); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 texture; +}; + +COMPILE_ASSERT(sizeof(ActiveTexture) == 8, + Sizeof_ActiveTexture_is_not_8); +COMPILE_ASSERT(offsetof(ActiveTexture, header) == 0, + OffsetOf_ActiveTexture_header_not_0); +COMPILE_ASSERT(offsetof(ActiveTexture, texture) == 4, + OffsetOf_ActiveTexture_texture_not_4); + +struct AttachShader { + typedef AttachShader ValueType; + static const CommandId kCmdId = kAttachShader; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLuint _program, GLuint _shader) { + SetHeader(); + program = _program; + shader = _shader; + } + + void* Set(void* cmd, GLuint _program, GLuint _shader) { + static_cast<ValueType*>(cmd)->Init(_program, _shader); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 program; + uint32 shader; +}; + +COMPILE_ASSERT(sizeof(AttachShader) == 12, + Sizeof_AttachShader_is_not_12); +COMPILE_ASSERT(offsetof(AttachShader, header) == 0, + OffsetOf_AttachShader_header_not_0); +COMPILE_ASSERT(offsetof(AttachShader, program) == 4, + OffsetOf_AttachShader_program_not_4); +COMPILE_ASSERT(offsetof(AttachShader, shader) == 8, + OffsetOf_AttachShader_shader_not_8); + +struct BindAttribLocation { + typedef BindAttribLocation ValueType; + static const CommandId kCmdId = kBindAttribLocation; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLuint _program, GLuint _index, uint32 _name_shm_id, + uint32 _name_shm_offset, uint32 _data_size) { + SetHeader(); + program = _program; + index = _index; + name_shm_id = _name_shm_id; + name_shm_offset = _name_shm_offset; + data_size = _data_size; + } + + void* Set( + void* cmd, GLuint _program, GLuint _index, uint32 _name_shm_id, + uint32 _name_shm_offset, uint32 _data_size) { + static_cast<ValueType*>( + cmd)->Init( + _program, _index, _name_shm_id, _name_shm_offset, _data_size); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 program; + uint32 index; + uint32 name_shm_id; + uint32 name_shm_offset; + uint32 data_size; +}; + +COMPILE_ASSERT(sizeof(BindAttribLocation) == 24, + Sizeof_BindAttribLocation_is_not_24); +COMPILE_ASSERT(offsetof(BindAttribLocation, header) == 0, + OffsetOf_BindAttribLocation_header_not_0); +COMPILE_ASSERT(offsetof(BindAttribLocation, program) == 4, + OffsetOf_BindAttribLocation_program_not_4); +COMPILE_ASSERT(offsetof(BindAttribLocation, index) == 8, + OffsetOf_BindAttribLocation_index_not_8); +COMPILE_ASSERT(offsetof(BindAttribLocation, name_shm_id) == 12, + OffsetOf_BindAttribLocation_name_shm_id_not_12); +COMPILE_ASSERT(offsetof(BindAttribLocation, name_shm_offset) == 16, + OffsetOf_BindAttribLocation_name_shm_offset_not_16); +COMPILE_ASSERT(offsetof(BindAttribLocation, data_size) == 20, + OffsetOf_BindAttribLocation_data_size_not_20); + +struct BindAttribLocationImmediate { + typedef BindAttribLocationImmediate ValueType; + static const CommandId kCmdId = kBindAttribLocationImmediate; + static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN; + + static uint32 ComputeDataSize(const char* s) { + return strlen(s); + } + + static uint32 ComputeSize(const char* s) { + return static_cast<uint32>( + sizeof(ValueType) + ComputeDataSize(s)); // NOLINT + } + + void SetHeader(const char* s) { + header.SetCmdByTotalSize<ValueType>(ComputeSize(s)); + } + + void Init(GLuint _program, GLuint _index, const char* _name) { + SetHeader(_name); + program = _program; + index = _index; + data_size = strlen(_name); + memcpy(ImmediateDataAddress(this), _name, data_size); + } + + void* Set(void* cmd, GLuint _program, GLuint _index, const char* _name) { + static_cast<ValueType*>(cmd)->Init(_program, _index, _name); + const uint32 size = ComputeSize(_name); + return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); + } + + command_buffer::CommandHeader header; + uint32 program; + uint32 index; + uint32 data_size; +}; + +COMPILE_ASSERT(sizeof(BindAttribLocationImmediate) == 16, + Sizeof_BindAttribLocationImmediate_is_not_16); +COMPILE_ASSERT(offsetof(BindAttribLocationImmediate, header) == 0, + OffsetOf_BindAttribLocationImmediate_header_not_0); +COMPILE_ASSERT(offsetof(BindAttribLocationImmediate, program) == 4, + OffsetOf_BindAttribLocationImmediate_program_not_4); +COMPILE_ASSERT(offsetof(BindAttribLocationImmediate, index) == 8, + OffsetOf_BindAttribLocationImmediate_index_not_8); +COMPILE_ASSERT(offsetof(BindAttribLocationImmediate, data_size) == 12, + OffsetOf_BindAttribLocationImmediate_data_size_not_12); + +struct BindBuffer { + typedef BindBuffer ValueType; + static const CommandId kCmdId = kBindBuffer; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLenum _target, GLuint _buffer) { + SetHeader(); + target = _target; + buffer = _buffer; + } + + void* Set(void* cmd, GLenum _target, GLuint _buffer) { + static_cast<ValueType*>(cmd)->Init(_target, _buffer); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 target; + uint32 buffer; +}; + +COMPILE_ASSERT(sizeof(BindBuffer) == 12, + Sizeof_BindBuffer_is_not_12); +COMPILE_ASSERT(offsetof(BindBuffer, header) == 0, + OffsetOf_BindBuffer_header_not_0); +COMPILE_ASSERT(offsetof(BindBuffer, target) == 4, + OffsetOf_BindBuffer_target_not_4); +COMPILE_ASSERT(offsetof(BindBuffer, buffer) == 8, + OffsetOf_BindBuffer_buffer_not_8); + +struct BindFramebuffer { + typedef BindFramebuffer ValueType; + static const CommandId kCmdId = kBindFramebuffer; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLenum _target, GLuint _framebuffer) { + SetHeader(); + target = _target; + framebuffer = _framebuffer; + } + + void* Set(void* cmd, GLenum _target, GLuint _framebuffer) { + static_cast<ValueType*>(cmd)->Init(_target, _framebuffer); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 target; + uint32 framebuffer; +}; + +COMPILE_ASSERT(sizeof(BindFramebuffer) == 12, + Sizeof_BindFramebuffer_is_not_12); +COMPILE_ASSERT(offsetof(BindFramebuffer, header) == 0, + OffsetOf_BindFramebuffer_header_not_0); +COMPILE_ASSERT(offsetof(BindFramebuffer, target) == 4, + OffsetOf_BindFramebuffer_target_not_4); +COMPILE_ASSERT(offsetof(BindFramebuffer, framebuffer) == 8, + OffsetOf_BindFramebuffer_framebuffer_not_8); + +struct BindRenderbuffer { + typedef BindRenderbuffer ValueType; + static const CommandId kCmdId = kBindRenderbuffer; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLenum _target, GLuint _renderbuffer) { + SetHeader(); + target = _target; + renderbuffer = _renderbuffer; + } + + void* Set(void* cmd, GLenum _target, GLuint _renderbuffer) { + static_cast<ValueType*>(cmd)->Init(_target, _renderbuffer); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 target; + uint32 renderbuffer; +}; + +COMPILE_ASSERT(sizeof(BindRenderbuffer) == 12, + Sizeof_BindRenderbuffer_is_not_12); +COMPILE_ASSERT(offsetof(BindRenderbuffer, header) == 0, + OffsetOf_BindRenderbuffer_header_not_0); +COMPILE_ASSERT(offsetof(BindRenderbuffer, target) == 4, + OffsetOf_BindRenderbuffer_target_not_4); +COMPILE_ASSERT(offsetof(BindRenderbuffer, renderbuffer) == 8, + OffsetOf_BindRenderbuffer_renderbuffer_not_8); + +struct BindTexture { + typedef BindTexture ValueType; + static const CommandId kCmdId = kBindTexture; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLenum _target, GLuint _texture) { + SetHeader(); + target = _target; + texture = _texture; + } + + void* Set(void* cmd, GLenum _target, GLuint _texture) { + static_cast<ValueType*>(cmd)->Init(_target, _texture); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 target; + uint32 texture; +}; + +COMPILE_ASSERT(sizeof(BindTexture) == 12, + Sizeof_BindTexture_is_not_12); +COMPILE_ASSERT(offsetof(BindTexture, header) == 0, + OffsetOf_BindTexture_header_not_0); +COMPILE_ASSERT(offsetof(BindTexture, target) == 4, + OffsetOf_BindTexture_target_not_4); +COMPILE_ASSERT(offsetof(BindTexture, texture) == 8, + OffsetOf_BindTexture_texture_not_8); + +struct BlendColor { + typedef BlendColor ValueType; + static const CommandId kCmdId = kBlendColor; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLclampf _red, GLclampf _green, GLclampf _blue, GLclampf _alpha) { + SetHeader(); + red = _red; + green = _green; + blue = _blue; + alpha = _alpha; + } + + void* Set( + void* cmd, GLclampf _red, GLclampf _green, GLclampf _blue, + GLclampf _alpha) { + static_cast<ValueType*>(cmd)->Init(_red, _green, _blue, _alpha); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + float red; + float green; + float blue; + float alpha; +}; + +COMPILE_ASSERT(sizeof(BlendColor) == 20, + Sizeof_BlendColor_is_not_20); +COMPILE_ASSERT(offsetof(BlendColor, header) == 0, + OffsetOf_BlendColor_header_not_0); +COMPILE_ASSERT(offsetof(BlendColor, red) == 4, + OffsetOf_BlendColor_red_not_4); +COMPILE_ASSERT(offsetof(BlendColor, green) == 8, + OffsetOf_BlendColor_green_not_8); +COMPILE_ASSERT(offsetof(BlendColor, blue) == 12, + OffsetOf_BlendColor_blue_not_12); +COMPILE_ASSERT(offsetof(BlendColor, alpha) == 16, + OffsetOf_BlendColor_alpha_not_16); + +struct BlendEquation { + typedef BlendEquation ValueType; + static const CommandId kCmdId = kBlendEquation; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLenum _mode) { + SetHeader(); + mode = _mode; + } + + void* Set(void* cmd, GLenum _mode) { + static_cast<ValueType*>(cmd)->Init(_mode); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 mode; +}; + +COMPILE_ASSERT(sizeof(BlendEquation) == 8, + Sizeof_BlendEquation_is_not_8); +COMPILE_ASSERT(offsetof(BlendEquation, header) == 0, + OffsetOf_BlendEquation_header_not_0); +COMPILE_ASSERT(offsetof(BlendEquation, mode) == 4, + OffsetOf_BlendEquation_mode_not_4); + +struct BlendEquationSeparate { + typedef BlendEquationSeparate ValueType; + static const CommandId kCmdId = kBlendEquationSeparate; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLenum _modeRGB, GLenum _modeAlpha) { + SetHeader(); + modeRGB = _modeRGB; + modeAlpha = _modeAlpha; + } + + void* Set(void* cmd, GLenum _modeRGB, GLenum _modeAlpha) { + static_cast<ValueType*>(cmd)->Init(_modeRGB, _modeAlpha); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 modeRGB; + uint32 modeAlpha; +}; + +COMPILE_ASSERT(sizeof(BlendEquationSeparate) == 12, + Sizeof_BlendEquationSeparate_is_not_12); +COMPILE_ASSERT(offsetof(BlendEquationSeparate, header) == 0, + OffsetOf_BlendEquationSeparate_header_not_0); +COMPILE_ASSERT(offsetof(BlendEquationSeparate, modeRGB) == 4, + OffsetOf_BlendEquationSeparate_modeRGB_not_4); +COMPILE_ASSERT(offsetof(BlendEquationSeparate, modeAlpha) == 8, + OffsetOf_BlendEquationSeparate_modeAlpha_not_8); + +struct BlendFunc { + typedef BlendFunc ValueType; + static const CommandId kCmdId = kBlendFunc; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLenum _sfactor, GLenum _dfactor) { + SetHeader(); + sfactor = _sfactor; + dfactor = _dfactor; + } + + void* Set(void* cmd, GLenum _sfactor, GLenum _dfactor) { + static_cast<ValueType*>(cmd)->Init(_sfactor, _dfactor); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 sfactor; + uint32 dfactor; +}; + +COMPILE_ASSERT(sizeof(BlendFunc) == 12, + Sizeof_BlendFunc_is_not_12); +COMPILE_ASSERT(offsetof(BlendFunc, header) == 0, + OffsetOf_BlendFunc_header_not_0); +COMPILE_ASSERT(offsetof(BlendFunc, sfactor) == 4, + OffsetOf_BlendFunc_sfactor_not_4); +COMPILE_ASSERT(offsetof(BlendFunc, dfactor) == 8, + OffsetOf_BlendFunc_dfactor_not_8); + +struct BlendFuncSeparate { + typedef BlendFuncSeparate ValueType; + static const CommandId kCmdId = kBlendFuncSeparate; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLenum _srcRGB, GLenum _dstRGB, GLenum _srcAlpha, GLenum _dstAlpha) { + SetHeader(); + srcRGB = _srcRGB; + dstRGB = _dstRGB; + srcAlpha = _srcAlpha; + dstAlpha = _dstAlpha; + } + + void* Set( + void* cmd, GLenum _srcRGB, GLenum _dstRGB, GLenum _srcAlpha, + GLenum _dstAlpha) { + static_cast<ValueType*>(cmd)->Init(_srcRGB, _dstRGB, _srcAlpha, _dstAlpha); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 srcRGB; + uint32 dstRGB; + uint32 srcAlpha; + uint32 dstAlpha; +}; + +COMPILE_ASSERT(sizeof(BlendFuncSeparate) == 20, + Sizeof_BlendFuncSeparate_is_not_20); +COMPILE_ASSERT(offsetof(BlendFuncSeparate, header) == 0, + OffsetOf_BlendFuncSeparate_header_not_0); +COMPILE_ASSERT(offsetof(BlendFuncSeparate, srcRGB) == 4, + OffsetOf_BlendFuncSeparate_srcRGB_not_4); +COMPILE_ASSERT(offsetof(BlendFuncSeparate, dstRGB) == 8, + OffsetOf_BlendFuncSeparate_dstRGB_not_8); +COMPILE_ASSERT(offsetof(BlendFuncSeparate, srcAlpha) == 12, + OffsetOf_BlendFuncSeparate_srcAlpha_not_12); +COMPILE_ASSERT(offsetof(BlendFuncSeparate, dstAlpha) == 16, + OffsetOf_BlendFuncSeparate_dstAlpha_not_16); + +struct BufferData { + typedef BufferData ValueType; + static const CommandId kCmdId = kBufferData; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLenum _target, GLsizeiptr _size, uint32 _data_shm_id, + uint32 _data_shm_offset, GLenum _usage) { + SetHeader(); + target = _target; + size = _size; + data_shm_id = _data_shm_id; + data_shm_offset = _data_shm_offset; + usage = _usage; + } + + void* Set( + void* cmd, GLenum _target, GLsizeiptr _size, uint32 _data_shm_id, + uint32 _data_shm_offset, GLenum _usage) { + static_cast<ValueType*>( + cmd)->Init(_target, _size, _data_shm_id, _data_shm_offset, _usage); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 target; + uint32 size; + uint32 data_shm_id; + uint32 data_shm_offset; + uint32 usage; +}; + +COMPILE_ASSERT(sizeof(BufferData) == 24, + Sizeof_BufferData_is_not_24); +COMPILE_ASSERT(offsetof(BufferData, header) == 0, + OffsetOf_BufferData_header_not_0); +COMPILE_ASSERT(offsetof(BufferData, target) == 4, + OffsetOf_BufferData_target_not_4); +COMPILE_ASSERT(offsetof(BufferData, size) == 8, + OffsetOf_BufferData_size_not_8); +COMPILE_ASSERT(offsetof(BufferData, data_shm_id) == 12, + OffsetOf_BufferData_data_shm_id_not_12); +COMPILE_ASSERT(offsetof(BufferData, data_shm_offset) == 16, + OffsetOf_BufferData_data_shm_offset_not_16); +COMPILE_ASSERT(offsetof(BufferData, usage) == 20, + OffsetOf_BufferData_usage_not_20); + +struct BufferDataImmediate { + typedef BufferDataImmediate ValueType; + static const CommandId kCmdId = kBufferDataImmediate; + static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN; + + static uint32 ComputeSize(uint32 size_in_bytes) { + return static_cast<uint32>( + sizeof(ValueType) + // NOLINT + RoundSizeToMultipleOfEntries(size_in_bytes)); + } + + void SetHeader(uint32 size_in_bytes) { + header.SetCmdByTotalSize<ValueType>(size_in_bytes); + } + + void Init(GLenum _target, GLsizeiptr _size, GLenum _usage) { + uint32 total_size = ComputeSize(_size); + SetHeader(total_size); + target = _target; + size = _size; + usage = _usage; + } + + void* Set(void* cmd, GLenum _target, GLsizeiptr _size, GLenum _usage) { + uint32 total_size = ComputeSize(_size); + static_cast<ValueType*>(cmd)->Init(_target, _size, _usage); + return NextImmediateCmdAddressTotalSize<ValueType>(cmd, total_size); + } + + command_buffer::CommandHeader header; + uint32 target; + uint32 size; + uint32 usage; +}; + +COMPILE_ASSERT(sizeof(BufferDataImmediate) == 16, + Sizeof_BufferDataImmediate_is_not_16); +COMPILE_ASSERT(offsetof(BufferDataImmediate, header) == 0, + OffsetOf_BufferDataImmediate_header_not_0); +COMPILE_ASSERT(offsetof(BufferDataImmediate, target) == 4, + OffsetOf_BufferDataImmediate_target_not_4); +COMPILE_ASSERT(offsetof(BufferDataImmediate, size) == 8, + OffsetOf_BufferDataImmediate_size_not_8); +COMPILE_ASSERT(offsetof(BufferDataImmediate, usage) == 12, + OffsetOf_BufferDataImmediate_usage_not_12); + +struct BufferSubData { + typedef BufferSubData ValueType; + static const CommandId kCmdId = kBufferSubData; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLenum _target, GLintptr _offset, GLsizeiptr _size, uint32 _data_shm_id, + uint32 _data_shm_offset) { + SetHeader(); + target = _target; + offset = _offset; + size = _size; + data_shm_id = _data_shm_id; + data_shm_offset = _data_shm_offset; + } + + void* Set( + void* cmd, GLenum _target, GLintptr _offset, GLsizeiptr _size, + uint32 _data_shm_id, uint32 _data_shm_offset) { + static_cast<ValueType*>( + cmd)->Init(_target, _offset, _size, _data_shm_id, _data_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 target; + uint32 offset; + uint32 size; + uint32 data_shm_id; + uint32 data_shm_offset; +}; + +COMPILE_ASSERT(sizeof(BufferSubData) == 24, + Sizeof_BufferSubData_is_not_24); +COMPILE_ASSERT(offsetof(BufferSubData, header) == 0, + OffsetOf_BufferSubData_header_not_0); +COMPILE_ASSERT(offsetof(BufferSubData, target) == 4, + OffsetOf_BufferSubData_target_not_4); +COMPILE_ASSERT(offsetof(BufferSubData, offset) == 8, + OffsetOf_BufferSubData_offset_not_8); +COMPILE_ASSERT(offsetof(BufferSubData, size) == 12, + OffsetOf_BufferSubData_size_not_12); +COMPILE_ASSERT(offsetof(BufferSubData, data_shm_id) == 16, + OffsetOf_BufferSubData_data_shm_id_not_16); +COMPILE_ASSERT(offsetof(BufferSubData, data_shm_offset) == 20, + OffsetOf_BufferSubData_data_shm_offset_not_20); + +struct BufferSubDataImmediate { + typedef BufferSubDataImmediate ValueType; + static const CommandId kCmdId = kBufferSubDataImmediate; + static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN; + + static uint32 ComputeSize(uint32 size_in_bytes) { + return static_cast<uint32>( + sizeof(ValueType) + // NOLINT + RoundSizeToMultipleOfEntries(size_in_bytes)); + } + + void SetHeader(uint32 size_in_bytes) { + header.SetCmdByTotalSize<ValueType>(size_in_bytes); + } + + void Init(GLenum _target, GLintptr _offset, GLsizeiptr _size) { + uint32 total_size = ComputeSize(_size); + SetHeader(total_size); + target = _target; + offset = _offset; + size = _size; + } + + void* Set(void* cmd, GLenum _target, GLintptr _offset, GLsizeiptr _size) { + uint32 total_size = ComputeSize(_size); + static_cast<ValueType*>(cmd)->Init(_target, _offset, _size); + return NextImmediateCmdAddressTotalSize<ValueType>(cmd, total_size); + } + + command_buffer::CommandHeader header; + uint32 target; + uint32 offset; + uint32 size; +}; + +COMPILE_ASSERT(sizeof(BufferSubDataImmediate) == 16, + Sizeof_BufferSubDataImmediate_is_not_16); +COMPILE_ASSERT(offsetof(BufferSubDataImmediate, header) == 0, + OffsetOf_BufferSubDataImmediate_header_not_0); +COMPILE_ASSERT(offsetof(BufferSubDataImmediate, target) == 4, + OffsetOf_BufferSubDataImmediate_target_not_4); +COMPILE_ASSERT(offsetof(BufferSubDataImmediate, offset) == 8, + OffsetOf_BufferSubDataImmediate_offset_not_8); +COMPILE_ASSERT(offsetof(BufferSubDataImmediate, size) == 12, + OffsetOf_BufferSubDataImmediate_size_not_12); + +struct CheckFramebufferStatus { + typedef CheckFramebufferStatus ValueType; + static const CommandId kCmdId = kCheckFramebufferStatus; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLenum _target) { + SetHeader(); + target = _target; + } + + void* Set(void* cmd, GLenum _target) { + static_cast<ValueType*>(cmd)->Init(_target); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 target; +}; + +COMPILE_ASSERT(sizeof(CheckFramebufferStatus) == 8, + Sizeof_CheckFramebufferStatus_is_not_8); +COMPILE_ASSERT(offsetof(CheckFramebufferStatus, header) == 0, + OffsetOf_CheckFramebufferStatus_header_not_0); +COMPILE_ASSERT(offsetof(CheckFramebufferStatus, target) == 4, + OffsetOf_CheckFramebufferStatus_target_not_4); + +struct Clear { + typedef Clear ValueType; + static const CommandId kCmdId = kClear; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLbitfield _mask) { + SetHeader(); + mask = _mask; + } + + void* Set(void* cmd, GLbitfield _mask) { + static_cast<ValueType*>(cmd)->Init(_mask); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 mask; +}; + +COMPILE_ASSERT(sizeof(Clear) == 8, + Sizeof_Clear_is_not_8); +COMPILE_ASSERT(offsetof(Clear, header) == 0, + OffsetOf_Clear_header_not_0); +COMPILE_ASSERT(offsetof(Clear, mask) == 4, + OffsetOf_Clear_mask_not_4); + +struct ClearColor { + typedef ClearColor ValueType; + static const CommandId kCmdId = kClearColor; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLclampf _red, GLclampf _green, GLclampf _blue, GLclampf _alpha) { + SetHeader(); + red = _red; + green = _green; + blue = _blue; + alpha = _alpha; + } + + void* Set( + void* cmd, GLclampf _red, GLclampf _green, GLclampf _blue, + GLclampf _alpha) { + static_cast<ValueType*>(cmd)->Init(_red, _green, _blue, _alpha); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + float red; + float green; + float blue; + float alpha; +}; + +COMPILE_ASSERT(sizeof(ClearColor) == 20, + Sizeof_ClearColor_is_not_20); +COMPILE_ASSERT(offsetof(ClearColor, header) == 0, + OffsetOf_ClearColor_header_not_0); +COMPILE_ASSERT(offsetof(ClearColor, red) == 4, + OffsetOf_ClearColor_red_not_4); +COMPILE_ASSERT(offsetof(ClearColor, green) == 8, + OffsetOf_ClearColor_green_not_8); +COMPILE_ASSERT(offsetof(ClearColor, blue) == 12, + OffsetOf_ClearColor_blue_not_12); +COMPILE_ASSERT(offsetof(ClearColor, alpha) == 16, + OffsetOf_ClearColor_alpha_not_16); + +struct ClearDepthf { + typedef ClearDepthf ValueType; + static const CommandId kCmdId = kClearDepthf; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLclampf _depth) { + SetHeader(); + depth = _depth; + } + + void* Set(void* cmd, GLclampf _depth) { + static_cast<ValueType*>(cmd)->Init(_depth); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + float depth; +}; + +COMPILE_ASSERT(sizeof(ClearDepthf) == 8, + Sizeof_ClearDepthf_is_not_8); +COMPILE_ASSERT(offsetof(ClearDepthf, header) == 0, + OffsetOf_ClearDepthf_header_not_0); +COMPILE_ASSERT(offsetof(ClearDepthf, depth) == 4, + OffsetOf_ClearDepthf_depth_not_4); + +struct ClearStencil { + typedef ClearStencil ValueType; + static const CommandId kCmdId = kClearStencil; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLint _s) { + SetHeader(); + s = _s; + } + + void* Set(void* cmd, GLint _s) { + static_cast<ValueType*>(cmd)->Init(_s); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 s; +}; + +COMPILE_ASSERT(sizeof(ClearStencil) == 8, + Sizeof_ClearStencil_is_not_8); +COMPILE_ASSERT(offsetof(ClearStencil, header) == 0, + OffsetOf_ClearStencil_header_not_0); +COMPILE_ASSERT(offsetof(ClearStencil, s) == 4, + OffsetOf_ClearStencil_s_not_4); + +struct ColorMask { + typedef ColorMask ValueType; + static const CommandId kCmdId = kColorMask; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLboolean _red, GLboolean _green, GLboolean _blue, GLboolean _alpha) { + SetHeader(); + red = _red; + green = _green; + blue = _blue; + alpha = _alpha; + } + + void* Set( + void* cmd, GLboolean _red, GLboolean _green, GLboolean _blue, + GLboolean _alpha) { + static_cast<ValueType*>(cmd)->Init(_red, _green, _blue, _alpha); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 red; + uint32 green; + uint32 blue; + uint32 alpha; +}; + +COMPILE_ASSERT(sizeof(ColorMask) == 20, + Sizeof_ColorMask_is_not_20); +COMPILE_ASSERT(offsetof(ColorMask, header) == 0, + OffsetOf_ColorMask_header_not_0); +COMPILE_ASSERT(offsetof(ColorMask, red) == 4, + OffsetOf_ColorMask_red_not_4); +COMPILE_ASSERT(offsetof(ColorMask, green) == 8, + OffsetOf_ColorMask_green_not_8); +COMPILE_ASSERT(offsetof(ColorMask, blue) == 12, + OffsetOf_ColorMask_blue_not_12); +COMPILE_ASSERT(offsetof(ColorMask, alpha) == 16, + OffsetOf_ColorMask_alpha_not_16); + +struct CompileShader { + typedef CompileShader ValueType; + static const CommandId kCmdId = kCompileShader; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLuint _shader) { + SetHeader(); + shader = _shader; + } + + void* Set(void* cmd, GLuint _shader) { + static_cast<ValueType*>(cmd)->Init(_shader); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 shader; +}; + +COMPILE_ASSERT(sizeof(CompileShader) == 8, + Sizeof_CompileShader_is_not_8); +COMPILE_ASSERT(offsetof(CompileShader, header) == 0, + OffsetOf_CompileShader_header_not_0); +COMPILE_ASSERT(offsetof(CompileShader, shader) == 4, + OffsetOf_CompileShader_shader_not_4); + +struct CompressedTexImage2D { + typedef CompressedTexImage2D ValueType; + static const CommandId kCmdId = kCompressedTexImage2D; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLenum _target, GLint _level, GLenum _internalformat, GLsizei _width, + GLsizei _height, GLint _border, GLsizei _imageSize, uint32 _data_shm_id, + uint32 _data_shm_offset) { + SetHeader(); + target = _target; + level = _level; + internalformat = _internalformat; + width = _width; + height = _height; + border = _border; + imageSize = _imageSize; + data_shm_id = _data_shm_id; + data_shm_offset = _data_shm_offset; + } + + void* Set( + void* cmd, GLenum _target, GLint _level, GLenum _internalformat, + GLsizei _width, GLsizei _height, GLint _border, GLsizei _imageSize, + uint32 _data_shm_id, uint32 _data_shm_offset) { + static_cast<ValueType*>( + cmd)->Init( + _target, _level, _internalformat, _width, _height, _border, + _imageSize, _data_shm_id, _data_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 target; + uint32 level; + uint32 internalformat; + uint32 width; + uint32 height; + uint32 border; + uint32 imageSize; + uint32 data_shm_id; + uint32 data_shm_offset; +}; + +COMPILE_ASSERT(sizeof(CompressedTexImage2D) == 40, + Sizeof_CompressedTexImage2D_is_not_40); +COMPILE_ASSERT(offsetof(CompressedTexImage2D, header) == 0, + OffsetOf_CompressedTexImage2D_header_not_0); +COMPILE_ASSERT(offsetof(CompressedTexImage2D, target) == 4, + OffsetOf_CompressedTexImage2D_target_not_4); +COMPILE_ASSERT(offsetof(CompressedTexImage2D, level) == 8, + OffsetOf_CompressedTexImage2D_level_not_8); +COMPILE_ASSERT(offsetof(CompressedTexImage2D, internalformat) == 12, + OffsetOf_CompressedTexImage2D_internalformat_not_12); +COMPILE_ASSERT(offsetof(CompressedTexImage2D, width) == 16, + OffsetOf_CompressedTexImage2D_width_not_16); +COMPILE_ASSERT(offsetof(CompressedTexImage2D, height) == 20, + OffsetOf_CompressedTexImage2D_height_not_20); +COMPILE_ASSERT(offsetof(CompressedTexImage2D, border) == 24, + OffsetOf_CompressedTexImage2D_border_not_24); +COMPILE_ASSERT(offsetof(CompressedTexImage2D, imageSize) == 28, + OffsetOf_CompressedTexImage2D_imageSize_not_28); +COMPILE_ASSERT(offsetof(CompressedTexImage2D, data_shm_id) == 32, + OffsetOf_CompressedTexImage2D_data_shm_id_not_32); +COMPILE_ASSERT(offsetof(CompressedTexImage2D, data_shm_offset) == 36, + OffsetOf_CompressedTexImage2D_data_shm_offset_not_36); + +struct CompressedTexImage2DImmediate { + typedef CompressedTexImage2DImmediate ValueType; + static const CommandId kCmdId = kCompressedTexImage2DImmediate; + static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN; + + static uint32 ComputeSize(uint32 size_in_bytes) { + return static_cast<uint32>( + sizeof(ValueType) + // NOLINT + RoundSizeToMultipleOfEntries(size_in_bytes)); + } + + void SetHeader(uint32 size_in_bytes) { + header.SetCmdByTotalSize<ValueType>(size_in_bytes); + } + + void Init( + GLenum _target, GLint _level, GLenum _internalformat, GLsizei _width, + GLsizei _height, GLint _border, GLsizei _imageSize) { + uint32 total_size = ComputeSize(_imageSize); + SetHeader(total_size); + target = _target; + level = _level; + internalformat = _internalformat; + width = _width; + height = _height; + border = _border; + imageSize = _imageSize; + } + + void* Set( + void* cmd, GLenum _target, GLint _level, GLenum _internalformat, + GLsizei _width, GLsizei _height, GLint _border, GLsizei _imageSize) { + uint32 total_size = ComputeSize(_imageSize); + static_cast<ValueType*>( + cmd)->Init( + _target, _level, _internalformat, _width, _height, _border, + _imageSize); + return NextImmediateCmdAddressTotalSize<ValueType>(cmd, total_size); + } + + command_buffer::CommandHeader header; + uint32 target; + uint32 level; + uint32 internalformat; + uint32 width; + uint32 height; + uint32 border; + uint32 imageSize; +}; + +COMPILE_ASSERT(sizeof(CompressedTexImage2DImmediate) == 32, + Sizeof_CompressedTexImage2DImmediate_is_not_32); +COMPILE_ASSERT(offsetof(CompressedTexImage2DImmediate, header) == 0, + OffsetOf_CompressedTexImage2DImmediate_header_not_0); +COMPILE_ASSERT(offsetof(CompressedTexImage2DImmediate, target) == 4, + OffsetOf_CompressedTexImage2DImmediate_target_not_4); +COMPILE_ASSERT(offsetof(CompressedTexImage2DImmediate, level) == 8, + OffsetOf_CompressedTexImage2DImmediate_level_not_8); +COMPILE_ASSERT(offsetof(CompressedTexImage2DImmediate, internalformat) == 12, + OffsetOf_CompressedTexImage2DImmediate_internalformat_not_12); +COMPILE_ASSERT(offsetof(CompressedTexImage2DImmediate, width) == 16, + OffsetOf_CompressedTexImage2DImmediate_width_not_16); +COMPILE_ASSERT(offsetof(CompressedTexImage2DImmediate, height) == 20, + OffsetOf_CompressedTexImage2DImmediate_height_not_20); +COMPILE_ASSERT(offsetof(CompressedTexImage2DImmediate, border) == 24, + OffsetOf_CompressedTexImage2DImmediate_border_not_24); +COMPILE_ASSERT(offsetof(CompressedTexImage2DImmediate, imageSize) == 28, + OffsetOf_CompressedTexImage2DImmediate_imageSize_not_28); + +struct CompressedTexSubImage2D { + typedef CompressedTexSubImage2D ValueType; + static const CommandId kCmdId = kCompressedTexSubImage2D; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLenum _target, GLint _level, GLint _xoffset, GLint _yoffset, + GLsizei _width, GLsizei _height, GLenum _format, GLsizei _imageSize, + uint32 _data_shm_id, uint32 _data_shm_offset) { + SetHeader(); + target = _target; + level = _level; + xoffset = _xoffset; + yoffset = _yoffset; + width = _width; + height = _height; + format = _format; + imageSize = _imageSize; + data_shm_id = _data_shm_id; + data_shm_offset = _data_shm_offset; + } + + void* Set( + void* cmd, GLenum _target, GLint _level, GLint _xoffset, GLint _yoffset, + GLsizei _width, GLsizei _height, GLenum _format, GLsizei _imageSize, + uint32 _data_shm_id, uint32 _data_shm_offset) { + static_cast<ValueType*>( + cmd)->Init( + _target, _level, _xoffset, _yoffset, _width, _height, _format, + _imageSize, _data_shm_id, _data_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 target; + uint32 level; + uint32 xoffset; + uint32 yoffset; + uint32 width; + uint32 height; + uint32 format; + uint32 imageSize; + uint32 data_shm_id; + uint32 data_shm_offset; +}; + +COMPILE_ASSERT(sizeof(CompressedTexSubImage2D) == 44, + Sizeof_CompressedTexSubImage2D_is_not_44); +COMPILE_ASSERT(offsetof(CompressedTexSubImage2D, header) == 0, + OffsetOf_CompressedTexSubImage2D_header_not_0); +COMPILE_ASSERT(offsetof(CompressedTexSubImage2D, target) == 4, + OffsetOf_CompressedTexSubImage2D_target_not_4); +COMPILE_ASSERT(offsetof(CompressedTexSubImage2D, level) == 8, + OffsetOf_CompressedTexSubImage2D_level_not_8); +COMPILE_ASSERT(offsetof(CompressedTexSubImage2D, xoffset) == 12, + OffsetOf_CompressedTexSubImage2D_xoffset_not_12); +COMPILE_ASSERT(offsetof(CompressedTexSubImage2D, yoffset) == 16, + OffsetOf_CompressedTexSubImage2D_yoffset_not_16); +COMPILE_ASSERT(offsetof(CompressedTexSubImage2D, width) == 20, + OffsetOf_CompressedTexSubImage2D_width_not_20); +COMPILE_ASSERT(offsetof(CompressedTexSubImage2D, height) == 24, + OffsetOf_CompressedTexSubImage2D_height_not_24); +COMPILE_ASSERT(offsetof(CompressedTexSubImage2D, format) == 28, + OffsetOf_CompressedTexSubImage2D_format_not_28); +COMPILE_ASSERT(offsetof(CompressedTexSubImage2D, imageSize) == 32, + OffsetOf_CompressedTexSubImage2D_imageSize_not_32); +COMPILE_ASSERT(offsetof(CompressedTexSubImage2D, data_shm_id) == 36, + OffsetOf_CompressedTexSubImage2D_data_shm_id_not_36); +COMPILE_ASSERT(offsetof(CompressedTexSubImage2D, data_shm_offset) == 40, + OffsetOf_CompressedTexSubImage2D_data_shm_offset_not_40); + +struct CompressedTexSubImage2DImmediate { + typedef CompressedTexSubImage2DImmediate ValueType; + static const CommandId kCmdId = kCompressedTexSubImage2DImmediate; + static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN; + + static uint32 ComputeSize(uint32 size_in_bytes) { + return static_cast<uint32>( + sizeof(ValueType) + // NOLINT + RoundSizeToMultipleOfEntries(size_in_bytes)); + } + + void SetHeader(uint32 size_in_bytes) { + header.SetCmdByTotalSize<ValueType>(size_in_bytes); + } + + void Init( + GLenum _target, GLint _level, GLint _xoffset, GLint _yoffset, + GLsizei _width, GLsizei _height, GLenum _format, GLsizei _imageSize) { + uint32 total_size = ComputeSize(_imageSize); + SetHeader(total_size); + target = _target; + level = _level; + xoffset = _xoffset; + yoffset = _yoffset; + width = _width; + height = _height; + format = _format; + imageSize = _imageSize; + } + + void* Set( + void* cmd, GLenum _target, GLint _level, GLint _xoffset, GLint _yoffset, + GLsizei _width, GLsizei _height, GLenum _format, GLsizei _imageSize) { + uint32 total_size = ComputeSize(_imageSize); + static_cast<ValueType*>( + cmd)->Init( + _target, _level, _xoffset, _yoffset, _width, _height, _format, + _imageSize); + return NextImmediateCmdAddressTotalSize<ValueType>(cmd, total_size); + } + + command_buffer::CommandHeader header; + uint32 target; + uint32 level; + uint32 xoffset; + uint32 yoffset; + uint32 width; + uint32 height; + uint32 format; + uint32 imageSize; +}; + +COMPILE_ASSERT(sizeof(CompressedTexSubImage2DImmediate) == 36, + Sizeof_CompressedTexSubImage2DImmediate_is_not_36); +COMPILE_ASSERT(offsetof(CompressedTexSubImage2DImmediate, header) == 0, + OffsetOf_CompressedTexSubImage2DImmediate_header_not_0); +COMPILE_ASSERT(offsetof(CompressedTexSubImage2DImmediate, target) == 4, + OffsetOf_CompressedTexSubImage2DImmediate_target_not_4); +COMPILE_ASSERT(offsetof(CompressedTexSubImage2DImmediate, level) == 8, + OffsetOf_CompressedTexSubImage2DImmediate_level_not_8); +COMPILE_ASSERT(offsetof(CompressedTexSubImage2DImmediate, xoffset) == 12, + OffsetOf_CompressedTexSubImage2DImmediate_xoffset_not_12); +COMPILE_ASSERT(offsetof(CompressedTexSubImage2DImmediate, yoffset) == 16, + OffsetOf_CompressedTexSubImage2DImmediate_yoffset_not_16); +COMPILE_ASSERT(offsetof(CompressedTexSubImage2DImmediate, width) == 20, + OffsetOf_CompressedTexSubImage2DImmediate_width_not_20); +COMPILE_ASSERT(offsetof(CompressedTexSubImage2DImmediate, height) == 24, + OffsetOf_CompressedTexSubImage2DImmediate_height_not_24); +COMPILE_ASSERT(offsetof(CompressedTexSubImage2DImmediate, format) == 28, + OffsetOf_CompressedTexSubImage2DImmediate_format_not_28); +COMPILE_ASSERT(offsetof(CompressedTexSubImage2DImmediate, imageSize) == 32, + OffsetOf_CompressedTexSubImage2DImmediate_imageSize_not_32); + +struct CopyTexImage2D { + typedef CopyTexImage2D ValueType; + static const CommandId kCmdId = kCopyTexImage2D; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLenum _target, GLint _level, GLenum _internalformat, GLint _x, GLint _y, + GLsizei _width, GLsizei _height, GLint _border) { + SetHeader(); + target = _target; + level = _level; + internalformat = _internalformat; + x = _x; + y = _y; + width = _width; + height = _height; + border = _border; + } + + void* Set( + void* cmd, GLenum _target, GLint _level, GLenum _internalformat, GLint _x, + GLint _y, GLsizei _width, GLsizei _height, GLint _border) { + static_cast<ValueType*>( + cmd)->Init( + _target, _level, _internalformat, _x, _y, _width, _height, + _border); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 target; + uint32 level; + uint32 internalformat; + uint32 x; + uint32 y; + uint32 width; + uint32 height; + uint32 border; +}; + +COMPILE_ASSERT(sizeof(CopyTexImage2D) == 36, + Sizeof_CopyTexImage2D_is_not_36); +COMPILE_ASSERT(offsetof(CopyTexImage2D, header) == 0, + OffsetOf_CopyTexImage2D_header_not_0); +COMPILE_ASSERT(offsetof(CopyTexImage2D, target) == 4, + OffsetOf_CopyTexImage2D_target_not_4); +COMPILE_ASSERT(offsetof(CopyTexImage2D, level) == 8, + OffsetOf_CopyTexImage2D_level_not_8); +COMPILE_ASSERT(offsetof(CopyTexImage2D, internalformat) == 12, + OffsetOf_CopyTexImage2D_internalformat_not_12); +COMPILE_ASSERT(offsetof(CopyTexImage2D, x) == 16, + OffsetOf_CopyTexImage2D_x_not_16); +COMPILE_ASSERT(offsetof(CopyTexImage2D, y) == 20, + OffsetOf_CopyTexImage2D_y_not_20); +COMPILE_ASSERT(offsetof(CopyTexImage2D, width) == 24, + OffsetOf_CopyTexImage2D_width_not_24); +COMPILE_ASSERT(offsetof(CopyTexImage2D, height) == 28, + OffsetOf_CopyTexImage2D_height_not_28); +COMPILE_ASSERT(offsetof(CopyTexImage2D, border) == 32, + OffsetOf_CopyTexImage2D_border_not_32); + +struct CopyTexSubImage2D { + typedef CopyTexSubImage2D ValueType; + static const CommandId kCmdId = kCopyTexSubImage2D; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLenum _target, GLint _level, GLint _xoffset, GLint _yoffset, GLint _x, + GLint _y, GLsizei _width, GLsizei _height) { + SetHeader(); + target = _target; + level = _level; + xoffset = _xoffset; + yoffset = _yoffset; + x = _x; + y = _y; + width = _width; + height = _height; + } + + void* Set( + void* cmd, GLenum _target, GLint _level, GLint _xoffset, GLint _yoffset, + GLint _x, GLint _y, GLsizei _width, GLsizei _height) { + static_cast<ValueType*>( + cmd)->Init( + _target, _level, _xoffset, _yoffset, _x, _y, _width, _height); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 target; + uint32 level; + uint32 xoffset; + uint32 yoffset; + uint32 x; + uint32 y; + uint32 width; + uint32 height; +}; + +COMPILE_ASSERT(sizeof(CopyTexSubImage2D) == 36, + Sizeof_CopyTexSubImage2D_is_not_36); +COMPILE_ASSERT(offsetof(CopyTexSubImage2D, header) == 0, + OffsetOf_CopyTexSubImage2D_header_not_0); +COMPILE_ASSERT(offsetof(CopyTexSubImage2D, target) == 4, + OffsetOf_CopyTexSubImage2D_target_not_4); +COMPILE_ASSERT(offsetof(CopyTexSubImage2D, level) == 8, + OffsetOf_CopyTexSubImage2D_level_not_8); +COMPILE_ASSERT(offsetof(CopyTexSubImage2D, xoffset) == 12, + OffsetOf_CopyTexSubImage2D_xoffset_not_12); +COMPILE_ASSERT(offsetof(CopyTexSubImage2D, yoffset) == 16, + OffsetOf_CopyTexSubImage2D_yoffset_not_16); +COMPILE_ASSERT(offsetof(CopyTexSubImage2D, x) == 20, + OffsetOf_CopyTexSubImage2D_x_not_20); +COMPILE_ASSERT(offsetof(CopyTexSubImage2D, y) == 24, + OffsetOf_CopyTexSubImage2D_y_not_24); +COMPILE_ASSERT(offsetof(CopyTexSubImage2D, width) == 28, + OffsetOf_CopyTexSubImage2D_width_not_28); +COMPILE_ASSERT(offsetof(CopyTexSubImage2D, height) == 32, + OffsetOf_CopyTexSubImage2D_height_not_32); + +struct CreateProgram { + typedef CreateProgram ValueType; + static const CommandId kCmdId = kCreateProgram; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(uint32 _client_id) { + SetHeader(); + client_id = _client_id; + } + + void* Set(void* cmd, uint32 _client_id) { + static_cast<ValueType*>(cmd)->Init(_client_id); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 client_id; +}; + +COMPILE_ASSERT(sizeof(CreateProgram) == 8, + Sizeof_CreateProgram_is_not_8); +COMPILE_ASSERT(offsetof(CreateProgram, header) == 0, + OffsetOf_CreateProgram_header_not_0); +COMPILE_ASSERT(offsetof(CreateProgram, client_id) == 4, + OffsetOf_CreateProgram_client_id_not_4); + +struct CreateShader { + typedef CreateShader ValueType; + static const CommandId kCmdId = kCreateShader; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLenum _type, uint32 _client_id) { + SetHeader(); + type = _type; + client_id = _client_id; + } + + void* Set(void* cmd, GLenum _type, uint32 _client_id) { + static_cast<ValueType*>(cmd)->Init(_type, _client_id); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 type; + uint32 client_id; +}; + +COMPILE_ASSERT(sizeof(CreateShader) == 12, + Sizeof_CreateShader_is_not_12); +COMPILE_ASSERT(offsetof(CreateShader, header) == 0, + OffsetOf_CreateShader_header_not_0); +COMPILE_ASSERT(offsetof(CreateShader, type) == 4, + OffsetOf_CreateShader_type_not_4); +COMPILE_ASSERT(offsetof(CreateShader, client_id) == 8, + OffsetOf_CreateShader_client_id_not_8); + +struct CullFace { + typedef CullFace ValueType; + static const CommandId kCmdId = kCullFace; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLenum _mode) { + SetHeader(); + mode = _mode; + } + + void* Set(void* cmd, GLenum _mode) { + static_cast<ValueType*>(cmd)->Init(_mode); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 mode; +}; + +COMPILE_ASSERT(sizeof(CullFace) == 8, + Sizeof_CullFace_is_not_8); +COMPILE_ASSERT(offsetof(CullFace, header) == 0, + OffsetOf_CullFace_header_not_0); +COMPILE_ASSERT(offsetof(CullFace, mode) == 4, + OffsetOf_CullFace_mode_not_4); + +struct DeleteBuffers { + typedef DeleteBuffers ValueType; + static const CommandId kCmdId = kDeleteBuffers; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLsizei _n, uint32 _buffers_shm_id, uint32 _buffers_shm_offset) { + SetHeader(); + n = _n; + buffers_shm_id = _buffers_shm_id; + buffers_shm_offset = _buffers_shm_offset; + } + + void* Set( + void* cmd, GLsizei _n, uint32 _buffers_shm_id, + uint32 _buffers_shm_offset) { + static_cast<ValueType*>( + cmd)->Init(_n, _buffers_shm_id, _buffers_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 n; + uint32 buffers_shm_id; + uint32 buffers_shm_offset; +}; + +COMPILE_ASSERT(sizeof(DeleteBuffers) == 16, + Sizeof_DeleteBuffers_is_not_16); +COMPILE_ASSERT(offsetof(DeleteBuffers, header) == 0, + OffsetOf_DeleteBuffers_header_not_0); +COMPILE_ASSERT(offsetof(DeleteBuffers, n) == 4, + OffsetOf_DeleteBuffers_n_not_4); +COMPILE_ASSERT(offsetof(DeleteBuffers, buffers_shm_id) == 8, + OffsetOf_DeleteBuffers_buffers_shm_id_not_8); +COMPILE_ASSERT(offsetof(DeleteBuffers, buffers_shm_offset) == 12, + OffsetOf_DeleteBuffers_buffers_shm_offset_not_12); + +struct DeleteBuffersImmediate { + typedef DeleteBuffersImmediate ValueType; + static const CommandId kCmdId = kDeleteBuffersImmediate; + static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN; + + static uint32 ComputeDataSize(GLsizei n) { + return static_cast<uint32>(sizeof(GLuint) * n); // NOLINT + } + + static uint32 ComputeSize(GLsizei n) { + return static_cast<uint32>( + sizeof(ValueType) + ComputeDataSize(n)); // NOLINT + } + + void SetHeader(GLsizei n) { + header.SetCmdByTotalSize<ValueType>(ComputeSize(n)); + } + + void Init(GLsizei _n, const GLuint* _buffers) { + SetHeader(_n); + n = _n; + memcpy(ImmediateDataAddress(this), + _buffers, ComputeDataSize(_n)); + } + + void* Set(void* cmd, GLsizei _n, const GLuint* _buffers) { + static_cast<ValueType*>(cmd)->Init(_n, _buffers); + const uint32 size = ComputeSize(_n); + return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); + } + + command_buffer::CommandHeader header; + uint32 n; +}; + +COMPILE_ASSERT(sizeof(DeleteBuffersImmediate) == 8, + Sizeof_DeleteBuffersImmediate_is_not_8); +COMPILE_ASSERT(offsetof(DeleteBuffersImmediate, header) == 0, + OffsetOf_DeleteBuffersImmediate_header_not_0); +COMPILE_ASSERT(offsetof(DeleteBuffersImmediate, n) == 4, + OffsetOf_DeleteBuffersImmediate_n_not_4); + +struct DeleteFramebuffers { + typedef DeleteFramebuffers ValueType; + static const CommandId kCmdId = kDeleteFramebuffers; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLsizei _n, uint32 _framebuffers_shm_id, + uint32 _framebuffers_shm_offset) { + SetHeader(); + n = _n; + framebuffers_shm_id = _framebuffers_shm_id; + framebuffers_shm_offset = _framebuffers_shm_offset; + } + + void* Set( + void* cmd, GLsizei _n, uint32 _framebuffers_shm_id, + uint32 _framebuffers_shm_offset) { + static_cast<ValueType*>( + cmd)->Init(_n, _framebuffers_shm_id, _framebuffers_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 n; + uint32 framebuffers_shm_id; + uint32 framebuffers_shm_offset; +}; + +COMPILE_ASSERT(sizeof(DeleteFramebuffers) == 16, + Sizeof_DeleteFramebuffers_is_not_16); +COMPILE_ASSERT(offsetof(DeleteFramebuffers, header) == 0, + OffsetOf_DeleteFramebuffers_header_not_0); +COMPILE_ASSERT(offsetof(DeleteFramebuffers, n) == 4, + OffsetOf_DeleteFramebuffers_n_not_4); +COMPILE_ASSERT(offsetof(DeleteFramebuffers, framebuffers_shm_id) == 8, + OffsetOf_DeleteFramebuffers_framebuffers_shm_id_not_8); +COMPILE_ASSERT(offsetof(DeleteFramebuffers, framebuffers_shm_offset) == 12, + OffsetOf_DeleteFramebuffers_framebuffers_shm_offset_not_12); + +struct DeleteFramebuffersImmediate { + typedef DeleteFramebuffersImmediate ValueType; + static const CommandId kCmdId = kDeleteFramebuffersImmediate; + static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN; + + static uint32 ComputeDataSize(GLsizei n) { + return static_cast<uint32>(sizeof(GLuint) * n); // NOLINT + } + + static uint32 ComputeSize(GLsizei n) { + return static_cast<uint32>( + sizeof(ValueType) + ComputeDataSize(n)); // NOLINT + } + + void SetHeader(GLsizei n) { + header.SetCmdByTotalSize<ValueType>(ComputeSize(n)); + } + + void Init(GLsizei _n, const GLuint* _framebuffers) { + SetHeader(_n); + n = _n; + memcpy(ImmediateDataAddress(this), + _framebuffers, ComputeDataSize(_n)); + } + + void* Set(void* cmd, GLsizei _n, const GLuint* _framebuffers) { + static_cast<ValueType*>(cmd)->Init(_n, _framebuffers); + const uint32 size = ComputeSize(_n); + return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); + } + + command_buffer::CommandHeader header; + uint32 n; +}; + +COMPILE_ASSERT(sizeof(DeleteFramebuffersImmediate) == 8, + Sizeof_DeleteFramebuffersImmediate_is_not_8); +COMPILE_ASSERT(offsetof(DeleteFramebuffersImmediate, header) == 0, + OffsetOf_DeleteFramebuffersImmediate_header_not_0); +COMPILE_ASSERT(offsetof(DeleteFramebuffersImmediate, n) == 4, + OffsetOf_DeleteFramebuffersImmediate_n_not_4); + +struct DeleteProgram { + typedef DeleteProgram ValueType; + static const CommandId kCmdId = kDeleteProgram; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLuint _program) { + SetHeader(); + program = _program; + } + + void* Set(void* cmd, GLuint _program) { + static_cast<ValueType*>(cmd)->Init(_program); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 program; +}; + +COMPILE_ASSERT(sizeof(DeleteProgram) == 8, + Sizeof_DeleteProgram_is_not_8); +COMPILE_ASSERT(offsetof(DeleteProgram, header) == 0, + OffsetOf_DeleteProgram_header_not_0); +COMPILE_ASSERT(offsetof(DeleteProgram, program) == 4, + OffsetOf_DeleteProgram_program_not_4); + +struct DeleteRenderbuffers { + typedef DeleteRenderbuffers ValueType; + static const CommandId kCmdId = kDeleteRenderbuffers; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLsizei _n, uint32 _renderbuffers_shm_id, + uint32 _renderbuffers_shm_offset) { + SetHeader(); + n = _n; + renderbuffers_shm_id = _renderbuffers_shm_id; + renderbuffers_shm_offset = _renderbuffers_shm_offset; + } + + void* Set( + void* cmd, GLsizei _n, uint32 _renderbuffers_shm_id, + uint32 _renderbuffers_shm_offset) { + static_cast<ValueType*>( + cmd)->Init(_n, _renderbuffers_shm_id, _renderbuffers_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 n; + uint32 renderbuffers_shm_id; + uint32 renderbuffers_shm_offset; +}; + +COMPILE_ASSERT(sizeof(DeleteRenderbuffers) == 16, + Sizeof_DeleteRenderbuffers_is_not_16); +COMPILE_ASSERT(offsetof(DeleteRenderbuffers, header) == 0, + OffsetOf_DeleteRenderbuffers_header_not_0); +COMPILE_ASSERT(offsetof(DeleteRenderbuffers, n) == 4, + OffsetOf_DeleteRenderbuffers_n_not_4); +COMPILE_ASSERT(offsetof(DeleteRenderbuffers, renderbuffers_shm_id) == 8, + OffsetOf_DeleteRenderbuffers_renderbuffers_shm_id_not_8); +COMPILE_ASSERT(offsetof(DeleteRenderbuffers, renderbuffers_shm_offset) == 12, + OffsetOf_DeleteRenderbuffers_renderbuffers_shm_offset_not_12); + +struct DeleteRenderbuffersImmediate { + typedef DeleteRenderbuffersImmediate ValueType; + static const CommandId kCmdId = kDeleteRenderbuffersImmediate; + static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN; + + static uint32 ComputeDataSize(GLsizei n) { + return static_cast<uint32>(sizeof(GLuint) * n); // NOLINT + } + + static uint32 ComputeSize(GLsizei n) { + return static_cast<uint32>( + sizeof(ValueType) + ComputeDataSize(n)); // NOLINT + } + + void SetHeader(GLsizei n) { + header.SetCmdByTotalSize<ValueType>(ComputeSize(n)); + } + + void Init(GLsizei _n, const GLuint* _renderbuffers) { + SetHeader(_n); + n = _n; + memcpy(ImmediateDataAddress(this), + _renderbuffers, ComputeDataSize(_n)); + } + + void* Set(void* cmd, GLsizei _n, const GLuint* _renderbuffers) { + static_cast<ValueType*>(cmd)->Init(_n, _renderbuffers); + const uint32 size = ComputeSize(_n); + return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); + } + + command_buffer::CommandHeader header; + uint32 n; +}; + +COMPILE_ASSERT(sizeof(DeleteRenderbuffersImmediate) == 8, + Sizeof_DeleteRenderbuffersImmediate_is_not_8); +COMPILE_ASSERT(offsetof(DeleteRenderbuffersImmediate, header) == 0, + OffsetOf_DeleteRenderbuffersImmediate_header_not_0); +COMPILE_ASSERT(offsetof(DeleteRenderbuffersImmediate, n) == 4, + OffsetOf_DeleteRenderbuffersImmediate_n_not_4); + +struct DeleteShader { + typedef DeleteShader ValueType; + static const CommandId kCmdId = kDeleteShader; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLuint _shader) { + SetHeader(); + shader = _shader; + } + + void* Set(void* cmd, GLuint _shader) { + static_cast<ValueType*>(cmd)->Init(_shader); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 shader; +}; + +COMPILE_ASSERT(sizeof(DeleteShader) == 8, + Sizeof_DeleteShader_is_not_8); +COMPILE_ASSERT(offsetof(DeleteShader, header) == 0, + OffsetOf_DeleteShader_header_not_0); +COMPILE_ASSERT(offsetof(DeleteShader, shader) == 4, + OffsetOf_DeleteShader_shader_not_4); + +struct DeleteTextures { + typedef DeleteTextures ValueType; + static const CommandId kCmdId = kDeleteTextures; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLsizei _n, uint32 _textures_shm_id, uint32 _textures_shm_offset) { + SetHeader(); + n = _n; + textures_shm_id = _textures_shm_id; + textures_shm_offset = _textures_shm_offset; + } + + void* Set( + void* cmd, GLsizei _n, uint32 _textures_shm_id, + uint32 _textures_shm_offset) { + static_cast<ValueType*>( + cmd)->Init(_n, _textures_shm_id, _textures_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 n; + uint32 textures_shm_id; + uint32 textures_shm_offset; +}; + +COMPILE_ASSERT(sizeof(DeleteTextures) == 16, + Sizeof_DeleteTextures_is_not_16); +COMPILE_ASSERT(offsetof(DeleteTextures, header) == 0, + OffsetOf_DeleteTextures_header_not_0); +COMPILE_ASSERT(offsetof(DeleteTextures, n) == 4, + OffsetOf_DeleteTextures_n_not_4); +COMPILE_ASSERT(offsetof(DeleteTextures, textures_shm_id) == 8, + OffsetOf_DeleteTextures_textures_shm_id_not_8); +COMPILE_ASSERT(offsetof(DeleteTextures, textures_shm_offset) == 12, + OffsetOf_DeleteTextures_textures_shm_offset_not_12); + +struct DeleteTexturesImmediate { + typedef DeleteTexturesImmediate ValueType; + static const CommandId kCmdId = kDeleteTexturesImmediate; + static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN; + + static uint32 ComputeDataSize(GLsizei n) { + return static_cast<uint32>(sizeof(GLuint) * n); // NOLINT + } + + static uint32 ComputeSize(GLsizei n) { + return static_cast<uint32>( + sizeof(ValueType) + ComputeDataSize(n)); // NOLINT + } + + void SetHeader(GLsizei n) { + header.SetCmdByTotalSize<ValueType>(ComputeSize(n)); + } + + void Init(GLsizei _n, const GLuint* _textures) { + SetHeader(_n); + n = _n; + memcpy(ImmediateDataAddress(this), + _textures, ComputeDataSize(_n)); + } + + void* Set(void* cmd, GLsizei _n, const GLuint* _textures) { + static_cast<ValueType*>(cmd)->Init(_n, _textures); + const uint32 size = ComputeSize(_n); + return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); + } + + command_buffer::CommandHeader header; + uint32 n; +}; + +COMPILE_ASSERT(sizeof(DeleteTexturesImmediate) == 8, + Sizeof_DeleteTexturesImmediate_is_not_8); +COMPILE_ASSERT(offsetof(DeleteTexturesImmediate, header) == 0, + OffsetOf_DeleteTexturesImmediate_header_not_0); +COMPILE_ASSERT(offsetof(DeleteTexturesImmediate, n) == 4, + OffsetOf_DeleteTexturesImmediate_n_not_4); + +struct DepthFunc { + typedef DepthFunc ValueType; + static const CommandId kCmdId = kDepthFunc; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLenum _func) { + SetHeader(); + func = _func; + } + + void* Set(void* cmd, GLenum _func) { + static_cast<ValueType*>(cmd)->Init(_func); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 func; +}; + +COMPILE_ASSERT(sizeof(DepthFunc) == 8, + Sizeof_DepthFunc_is_not_8); +COMPILE_ASSERT(offsetof(DepthFunc, header) == 0, + OffsetOf_DepthFunc_header_not_0); +COMPILE_ASSERT(offsetof(DepthFunc, func) == 4, + OffsetOf_DepthFunc_func_not_4); + +struct DepthMask { + typedef DepthMask ValueType; + static const CommandId kCmdId = kDepthMask; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLboolean _flag) { + SetHeader(); + flag = _flag; + } + + void* Set(void* cmd, GLboolean _flag) { + static_cast<ValueType*>(cmd)->Init(_flag); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 flag; +}; + +COMPILE_ASSERT(sizeof(DepthMask) == 8, + Sizeof_DepthMask_is_not_8); +COMPILE_ASSERT(offsetof(DepthMask, header) == 0, + OffsetOf_DepthMask_header_not_0); +COMPILE_ASSERT(offsetof(DepthMask, flag) == 4, + OffsetOf_DepthMask_flag_not_4); + +struct DepthRangef { + typedef DepthRangef ValueType; + static const CommandId kCmdId = kDepthRangef; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLclampf _zNear, GLclampf _zFar) { + SetHeader(); + zNear = _zNear; + zFar = _zFar; + } + + void* Set(void* cmd, GLclampf _zNear, GLclampf _zFar) { + static_cast<ValueType*>(cmd)->Init(_zNear, _zFar); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + float zNear; + float zFar; +}; + +COMPILE_ASSERT(sizeof(DepthRangef) == 12, + Sizeof_DepthRangef_is_not_12); +COMPILE_ASSERT(offsetof(DepthRangef, header) == 0, + OffsetOf_DepthRangef_header_not_0); +COMPILE_ASSERT(offsetof(DepthRangef, zNear) == 4, + OffsetOf_DepthRangef_zNear_not_4); +COMPILE_ASSERT(offsetof(DepthRangef, zFar) == 8, + OffsetOf_DepthRangef_zFar_not_8); + +struct DetachShader { + typedef DetachShader ValueType; + static const CommandId kCmdId = kDetachShader; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLuint _program, GLuint _shader) { + SetHeader(); + program = _program; + shader = _shader; + } + + void* Set(void* cmd, GLuint _program, GLuint _shader) { + static_cast<ValueType*>(cmd)->Init(_program, _shader); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 program; + uint32 shader; +}; + +COMPILE_ASSERT(sizeof(DetachShader) == 12, + Sizeof_DetachShader_is_not_12); +COMPILE_ASSERT(offsetof(DetachShader, header) == 0, + OffsetOf_DetachShader_header_not_0); +COMPILE_ASSERT(offsetof(DetachShader, program) == 4, + OffsetOf_DetachShader_program_not_4); +COMPILE_ASSERT(offsetof(DetachShader, shader) == 8, + OffsetOf_DetachShader_shader_not_8); + +struct Disable { + typedef Disable ValueType; + static const CommandId kCmdId = kDisable; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLenum _cap) { + SetHeader(); + cap = _cap; + } + + void* Set(void* cmd, GLenum _cap) { + static_cast<ValueType*>(cmd)->Init(_cap); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 cap; +}; + +COMPILE_ASSERT(sizeof(Disable) == 8, + Sizeof_Disable_is_not_8); +COMPILE_ASSERT(offsetof(Disable, header) == 0, + OffsetOf_Disable_header_not_0); +COMPILE_ASSERT(offsetof(Disable, cap) == 4, + OffsetOf_Disable_cap_not_4); + +struct DisableVertexAttribArray { + typedef DisableVertexAttribArray ValueType; + static const CommandId kCmdId = kDisableVertexAttribArray; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLuint _index) { + SetHeader(); + index = _index; + } + + void* Set(void* cmd, GLuint _index) { + static_cast<ValueType*>(cmd)->Init(_index); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 index; +}; + +COMPILE_ASSERT(sizeof(DisableVertexAttribArray) == 8, + Sizeof_DisableVertexAttribArray_is_not_8); +COMPILE_ASSERT(offsetof(DisableVertexAttribArray, header) == 0, + OffsetOf_DisableVertexAttribArray_header_not_0); +COMPILE_ASSERT(offsetof(DisableVertexAttribArray, index) == 4, + OffsetOf_DisableVertexAttribArray_index_not_4); + +struct DrawArrays { + typedef DrawArrays ValueType; + static const CommandId kCmdId = kDrawArrays; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLenum _mode, GLint _first, GLsizei _count) { + SetHeader(); + mode = _mode; + first = _first; + count = _count; + } + + void* Set(void* cmd, GLenum _mode, GLint _first, GLsizei _count) { + static_cast<ValueType*>(cmd)->Init(_mode, _first, _count); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 mode; + uint32 first; + uint32 count; +}; + +COMPILE_ASSERT(sizeof(DrawArrays) == 16, + Sizeof_DrawArrays_is_not_16); +COMPILE_ASSERT(offsetof(DrawArrays, header) == 0, + OffsetOf_DrawArrays_header_not_0); +COMPILE_ASSERT(offsetof(DrawArrays, mode) == 4, + OffsetOf_DrawArrays_mode_not_4); +COMPILE_ASSERT(offsetof(DrawArrays, first) == 8, + OffsetOf_DrawArrays_first_not_8); +COMPILE_ASSERT(offsetof(DrawArrays, count) == 12, + OffsetOf_DrawArrays_count_not_12); + +struct DrawElements { + typedef DrawElements ValueType; + static const CommandId kCmdId = kDrawElements; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLenum _mode, GLsizei _count, GLenum _type, GLuint _index_offset) { + SetHeader(); + mode = _mode; + count = _count; + type = _type; + index_offset = _index_offset; + } + + void* Set( + void* cmd, GLenum _mode, GLsizei _count, GLenum _type, + GLuint _index_offset) { + static_cast<ValueType*>(cmd)->Init(_mode, _count, _type, _index_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 mode; + uint32 count; + uint32 type; + uint32 index_offset; +}; + +COMPILE_ASSERT(sizeof(DrawElements) == 20, + Sizeof_DrawElements_is_not_20); +COMPILE_ASSERT(offsetof(DrawElements, header) == 0, + OffsetOf_DrawElements_header_not_0); +COMPILE_ASSERT(offsetof(DrawElements, mode) == 4, + OffsetOf_DrawElements_mode_not_4); +COMPILE_ASSERT(offsetof(DrawElements, count) == 8, + OffsetOf_DrawElements_count_not_8); +COMPILE_ASSERT(offsetof(DrawElements, type) == 12, + OffsetOf_DrawElements_type_not_12); +COMPILE_ASSERT(offsetof(DrawElements, index_offset) == 16, + OffsetOf_DrawElements_index_offset_not_16); + +struct Enable { + typedef Enable ValueType; + static const CommandId kCmdId = kEnable; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLenum _cap) { + SetHeader(); + cap = _cap; + } + + void* Set(void* cmd, GLenum _cap) { + static_cast<ValueType*>(cmd)->Init(_cap); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 cap; +}; + +COMPILE_ASSERT(sizeof(Enable) == 8, + Sizeof_Enable_is_not_8); +COMPILE_ASSERT(offsetof(Enable, header) == 0, + OffsetOf_Enable_header_not_0); +COMPILE_ASSERT(offsetof(Enable, cap) == 4, + OffsetOf_Enable_cap_not_4); + +struct EnableVertexAttribArray { + typedef EnableVertexAttribArray ValueType; + static const CommandId kCmdId = kEnableVertexAttribArray; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLuint _index) { + SetHeader(); + index = _index; + } + + void* Set(void* cmd, GLuint _index) { + static_cast<ValueType*>(cmd)->Init(_index); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 index; +}; + +COMPILE_ASSERT(sizeof(EnableVertexAttribArray) == 8, + Sizeof_EnableVertexAttribArray_is_not_8); +COMPILE_ASSERT(offsetof(EnableVertexAttribArray, header) == 0, + OffsetOf_EnableVertexAttribArray_header_not_0); +COMPILE_ASSERT(offsetof(EnableVertexAttribArray, index) == 4, + OffsetOf_EnableVertexAttribArray_index_not_4); + +struct Finish { + typedef Finish ValueType; + static const CommandId kCmdId = kFinish; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init() { + SetHeader(); + } + + void* Set(void* cmd) { + static_cast<ValueType*>(cmd)->Init(); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; +}; + +COMPILE_ASSERT(sizeof(Finish) == 4, + Sizeof_Finish_is_not_4); +COMPILE_ASSERT(offsetof(Finish, header) == 0, + OffsetOf_Finish_header_not_0); + +struct Flush { + typedef Flush ValueType; + static const CommandId kCmdId = kFlush; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init() { + SetHeader(); + } + + void* Set(void* cmd) { + static_cast<ValueType*>(cmd)->Init(); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; +}; + +COMPILE_ASSERT(sizeof(Flush) == 4, + Sizeof_Flush_is_not_4); +COMPILE_ASSERT(offsetof(Flush, header) == 0, + OffsetOf_Flush_header_not_0); + +struct FramebufferRenderbuffer { + typedef FramebufferRenderbuffer ValueType; + static const CommandId kCmdId = kFramebufferRenderbuffer; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLenum _target, GLenum _attachment, GLenum _renderbuffertarget, + GLuint _renderbuffer) { + SetHeader(); + target = _target; + attachment = _attachment; + renderbuffertarget = _renderbuffertarget; + renderbuffer = _renderbuffer; + } + + void* Set( + void* cmd, GLenum _target, GLenum _attachment, GLenum _renderbuffertarget, + GLuint _renderbuffer) { + static_cast<ValueType*>( + cmd)->Init(_target, _attachment, _renderbuffertarget, _renderbuffer); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 target; + uint32 attachment; + uint32 renderbuffertarget; + uint32 renderbuffer; +}; + +COMPILE_ASSERT(sizeof(FramebufferRenderbuffer) == 20, + Sizeof_FramebufferRenderbuffer_is_not_20); +COMPILE_ASSERT(offsetof(FramebufferRenderbuffer, header) == 0, + OffsetOf_FramebufferRenderbuffer_header_not_0); +COMPILE_ASSERT(offsetof(FramebufferRenderbuffer, target) == 4, + OffsetOf_FramebufferRenderbuffer_target_not_4); +COMPILE_ASSERT(offsetof(FramebufferRenderbuffer, attachment) == 8, + OffsetOf_FramebufferRenderbuffer_attachment_not_8); +COMPILE_ASSERT(offsetof(FramebufferRenderbuffer, renderbuffertarget) == 12, + OffsetOf_FramebufferRenderbuffer_renderbuffertarget_not_12); +COMPILE_ASSERT(offsetof(FramebufferRenderbuffer, renderbuffer) == 16, + OffsetOf_FramebufferRenderbuffer_renderbuffer_not_16); + +struct FramebufferTexture2D { + typedef FramebufferTexture2D ValueType; + static const CommandId kCmdId = kFramebufferTexture2D; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLenum _target, GLenum _attachment, GLenum _textarget, GLuint _texture, + GLint _level) { + SetHeader(); + target = _target; + attachment = _attachment; + textarget = _textarget; + texture = _texture; + level = _level; + } + + void* Set( + void* cmd, GLenum _target, GLenum _attachment, GLenum _textarget, + GLuint _texture, GLint _level) { + static_cast<ValueType*>( + cmd)->Init(_target, _attachment, _textarget, _texture, _level); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 target; + uint32 attachment; + uint32 textarget; + uint32 texture; + uint32 level; +}; + +COMPILE_ASSERT(sizeof(FramebufferTexture2D) == 24, + Sizeof_FramebufferTexture2D_is_not_24); +COMPILE_ASSERT(offsetof(FramebufferTexture2D, header) == 0, + OffsetOf_FramebufferTexture2D_header_not_0); +COMPILE_ASSERT(offsetof(FramebufferTexture2D, target) == 4, + OffsetOf_FramebufferTexture2D_target_not_4); +COMPILE_ASSERT(offsetof(FramebufferTexture2D, attachment) == 8, + OffsetOf_FramebufferTexture2D_attachment_not_8); +COMPILE_ASSERT(offsetof(FramebufferTexture2D, textarget) == 12, + OffsetOf_FramebufferTexture2D_textarget_not_12); +COMPILE_ASSERT(offsetof(FramebufferTexture2D, texture) == 16, + OffsetOf_FramebufferTexture2D_texture_not_16); +COMPILE_ASSERT(offsetof(FramebufferTexture2D, level) == 20, + OffsetOf_FramebufferTexture2D_level_not_20); + +struct FrontFace { + typedef FrontFace ValueType; + static const CommandId kCmdId = kFrontFace; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLenum _mode) { + SetHeader(); + mode = _mode; + } + + void* Set(void* cmd, GLenum _mode) { + static_cast<ValueType*>(cmd)->Init(_mode); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 mode; +}; + +COMPILE_ASSERT(sizeof(FrontFace) == 8, + Sizeof_FrontFace_is_not_8); +COMPILE_ASSERT(offsetof(FrontFace, header) == 0, + OffsetOf_FrontFace_header_not_0); +COMPILE_ASSERT(offsetof(FrontFace, mode) == 4, + OffsetOf_FrontFace_mode_not_4); + +struct GenBuffers { + typedef GenBuffers ValueType; + static const CommandId kCmdId = kGenBuffers; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLsizei _n, uint32 _buffers_shm_id, uint32 _buffers_shm_offset) { + SetHeader(); + n = _n; + buffers_shm_id = _buffers_shm_id; + buffers_shm_offset = _buffers_shm_offset; + } + + void* Set( + void* cmd, GLsizei _n, uint32 _buffers_shm_id, + uint32 _buffers_shm_offset) { + static_cast<ValueType*>( + cmd)->Init(_n, _buffers_shm_id, _buffers_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 n; + uint32 buffers_shm_id; + uint32 buffers_shm_offset; +}; + +COMPILE_ASSERT(sizeof(GenBuffers) == 16, + Sizeof_GenBuffers_is_not_16); +COMPILE_ASSERT(offsetof(GenBuffers, header) == 0, + OffsetOf_GenBuffers_header_not_0); +COMPILE_ASSERT(offsetof(GenBuffers, n) == 4, + OffsetOf_GenBuffers_n_not_4); +COMPILE_ASSERT(offsetof(GenBuffers, buffers_shm_id) == 8, + OffsetOf_GenBuffers_buffers_shm_id_not_8); +COMPILE_ASSERT(offsetof(GenBuffers, buffers_shm_offset) == 12, + OffsetOf_GenBuffers_buffers_shm_offset_not_12); + +struct GenBuffersImmediate { + typedef GenBuffersImmediate ValueType; + static const CommandId kCmdId = kGenBuffersImmediate; + static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN; + + static uint32 ComputeDataSize(GLsizei n) { + return static_cast<uint32>(sizeof(GLuint) * n); // NOLINT + } + + static uint32 ComputeSize(GLsizei n) { + return static_cast<uint32>( + sizeof(ValueType) + ComputeDataSize(n)); // NOLINT + } + + void SetHeader(GLsizei n) { + header.SetCmdByTotalSize<ValueType>(ComputeSize(n)); + } + + void Init(GLsizei _n, GLuint* _buffers) { + SetHeader(_n); + n = _n; + memcpy(ImmediateDataAddress(this), + _buffers, ComputeDataSize(_n)); + } + + void* Set(void* cmd, GLsizei _n, GLuint* _buffers) { + static_cast<ValueType*>(cmd)->Init(_n, _buffers); + const uint32 size = ComputeSize(_n); + return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); + } + + command_buffer::CommandHeader header; + uint32 n; +}; + +COMPILE_ASSERT(sizeof(GenBuffersImmediate) == 8, + Sizeof_GenBuffersImmediate_is_not_8); +COMPILE_ASSERT(offsetof(GenBuffersImmediate, header) == 0, + OffsetOf_GenBuffersImmediate_header_not_0); +COMPILE_ASSERT(offsetof(GenBuffersImmediate, n) == 4, + OffsetOf_GenBuffersImmediate_n_not_4); + +struct GenerateMipmap { + typedef GenerateMipmap ValueType; + static const CommandId kCmdId = kGenerateMipmap; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLenum _target) { + SetHeader(); + target = _target; + } + + void* Set(void* cmd, GLenum _target) { + static_cast<ValueType*>(cmd)->Init(_target); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 target; +}; + +COMPILE_ASSERT(sizeof(GenerateMipmap) == 8, + Sizeof_GenerateMipmap_is_not_8); +COMPILE_ASSERT(offsetof(GenerateMipmap, header) == 0, + OffsetOf_GenerateMipmap_header_not_0); +COMPILE_ASSERT(offsetof(GenerateMipmap, target) == 4, + OffsetOf_GenerateMipmap_target_not_4); + +struct GenFramebuffers { + typedef GenFramebuffers ValueType; + static const CommandId kCmdId = kGenFramebuffers; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLsizei _n, uint32 _framebuffers_shm_id, + uint32 _framebuffers_shm_offset) { + SetHeader(); + n = _n; + framebuffers_shm_id = _framebuffers_shm_id; + framebuffers_shm_offset = _framebuffers_shm_offset; + } + + void* Set( + void* cmd, GLsizei _n, uint32 _framebuffers_shm_id, + uint32 _framebuffers_shm_offset) { + static_cast<ValueType*>( + cmd)->Init(_n, _framebuffers_shm_id, _framebuffers_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 n; + uint32 framebuffers_shm_id; + uint32 framebuffers_shm_offset; +}; + +COMPILE_ASSERT(sizeof(GenFramebuffers) == 16, + Sizeof_GenFramebuffers_is_not_16); +COMPILE_ASSERT(offsetof(GenFramebuffers, header) == 0, + OffsetOf_GenFramebuffers_header_not_0); +COMPILE_ASSERT(offsetof(GenFramebuffers, n) == 4, + OffsetOf_GenFramebuffers_n_not_4); +COMPILE_ASSERT(offsetof(GenFramebuffers, framebuffers_shm_id) == 8, + OffsetOf_GenFramebuffers_framebuffers_shm_id_not_8); +COMPILE_ASSERT(offsetof(GenFramebuffers, framebuffers_shm_offset) == 12, + OffsetOf_GenFramebuffers_framebuffers_shm_offset_not_12); + +struct GenFramebuffersImmediate { + typedef GenFramebuffersImmediate ValueType; + static const CommandId kCmdId = kGenFramebuffersImmediate; + static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN; + + static uint32 ComputeDataSize(GLsizei n) { + return static_cast<uint32>(sizeof(GLuint) * n); // NOLINT + } + + static uint32 ComputeSize(GLsizei n) { + return static_cast<uint32>( + sizeof(ValueType) + ComputeDataSize(n)); // NOLINT + } + + void SetHeader(GLsizei n) { + header.SetCmdByTotalSize<ValueType>(ComputeSize(n)); + } + + void Init(GLsizei _n, GLuint* _framebuffers) { + SetHeader(_n); + n = _n; + memcpy(ImmediateDataAddress(this), + _framebuffers, ComputeDataSize(_n)); + } + + void* Set(void* cmd, GLsizei _n, GLuint* _framebuffers) { + static_cast<ValueType*>(cmd)->Init(_n, _framebuffers); + const uint32 size = ComputeSize(_n); + return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); + } + + command_buffer::CommandHeader header; + uint32 n; +}; + +COMPILE_ASSERT(sizeof(GenFramebuffersImmediate) == 8, + Sizeof_GenFramebuffersImmediate_is_not_8); +COMPILE_ASSERT(offsetof(GenFramebuffersImmediate, header) == 0, + OffsetOf_GenFramebuffersImmediate_header_not_0); +COMPILE_ASSERT(offsetof(GenFramebuffersImmediate, n) == 4, + OffsetOf_GenFramebuffersImmediate_n_not_4); + +struct GenRenderbuffers { + typedef GenRenderbuffers ValueType; + static const CommandId kCmdId = kGenRenderbuffers; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLsizei _n, uint32 _renderbuffers_shm_id, + uint32 _renderbuffers_shm_offset) { + SetHeader(); + n = _n; + renderbuffers_shm_id = _renderbuffers_shm_id; + renderbuffers_shm_offset = _renderbuffers_shm_offset; + } + + void* Set( + void* cmd, GLsizei _n, uint32 _renderbuffers_shm_id, + uint32 _renderbuffers_shm_offset) { + static_cast<ValueType*>( + cmd)->Init(_n, _renderbuffers_shm_id, _renderbuffers_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 n; + uint32 renderbuffers_shm_id; + uint32 renderbuffers_shm_offset; +}; + +COMPILE_ASSERT(sizeof(GenRenderbuffers) == 16, + Sizeof_GenRenderbuffers_is_not_16); +COMPILE_ASSERT(offsetof(GenRenderbuffers, header) == 0, + OffsetOf_GenRenderbuffers_header_not_0); +COMPILE_ASSERT(offsetof(GenRenderbuffers, n) == 4, + OffsetOf_GenRenderbuffers_n_not_4); +COMPILE_ASSERT(offsetof(GenRenderbuffers, renderbuffers_shm_id) == 8, + OffsetOf_GenRenderbuffers_renderbuffers_shm_id_not_8); +COMPILE_ASSERT(offsetof(GenRenderbuffers, renderbuffers_shm_offset) == 12, + OffsetOf_GenRenderbuffers_renderbuffers_shm_offset_not_12); + +struct GenRenderbuffersImmediate { + typedef GenRenderbuffersImmediate ValueType; + static const CommandId kCmdId = kGenRenderbuffersImmediate; + static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN; + + static uint32 ComputeDataSize(GLsizei n) { + return static_cast<uint32>(sizeof(GLuint) * n); // NOLINT + } + + static uint32 ComputeSize(GLsizei n) { + return static_cast<uint32>( + sizeof(ValueType) + ComputeDataSize(n)); // NOLINT + } + + void SetHeader(GLsizei n) { + header.SetCmdByTotalSize<ValueType>(ComputeSize(n)); + } + + void Init(GLsizei _n, GLuint* _renderbuffers) { + SetHeader(_n); + n = _n; + memcpy(ImmediateDataAddress(this), + _renderbuffers, ComputeDataSize(_n)); + } + + void* Set(void* cmd, GLsizei _n, GLuint* _renderbuffers) { + static_cast<ValueType*>(cmd)->Init(_n, _renderbuffers); + const uint32 size = ComputeSize(_n); + return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); + } + + command_buffer::CommandHeader header; + uint32 n; +}; + +COMPILE_ASSERT(sizeof(GenRenderbuffersImmediate) == 8, + Sizeof_GenRenderbuffersImmediate_is_not_8); +COMPILE_ASSERT(offsetof(GenRenderbuffersImmediate, header) == 0, + OffsetOf_GenRenderbuffersImmediate_header_not_0); +COMPILE_ASSERT(offsetof(GenRenderbuffersImmediate, n) == 4, + OffsetOf_GenRenderbuffersImmediate_n_not_4); + +struct GenTextures { + typedef GenTextures ValueType; + static const CommandId kCmdId = kGenTextures; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLsizei _n, uint32 _textures_shm_id, uint32 _textures_shm_offset) { + SetHeader(); + n = _n; + textures_shm_id = _textures_shm_id; + textures_shm_offset = _textures_shm_offset; + } + + void* Set( + void* cmd, GLsizei _n, uint32 _textures_shm_id, + uint32 _textures_shm_offset) { + static_cast<ValueType*>( + cmd)->Init(_n, _textures_shm_id, _textures_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 n; + uint32 textures_shm_id; + uint32 textures_shm_offset; +}; + +COMPILE_ASSERT(sizeof(GenTextures) == 16, + Sizeof_GenTextures_is_not_16); +COMPILE_ASSERT(offsetof(GenTextures, header) == 0, + OffsetOf_GenTextures_header_not_0); +COMPILE_ASSERT(offsetof(GenTextures, n) == 4, + OffsetOf_GenTextures_n_not_4); +COMPILE_ASSERT(offsetof(GenTextures, textures_shm_id) == 8, + OffsetOf_GenTextures_textures_shm_id_not_8); +COMPILE_ASSERT(offsetof(GenTextures, textures_shm_offset) == 12, + OffsetOf_GenTextures_textures_shm_offset_not_12); + +struct GenTexturesImmediate { + typedef GenTexturesImmediate ValueType; + static const CommandId kCmdId = kGenTexturesImmediate; + static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN; + + static uint32 ComputeDataSize(GLsizei n) { + return static_cast<uint32>(sizeof(GLuint) * n); // NOLINT + } + + static uint32 ComputeSize(GLsizei n) { + return static_cast<uint32>( + sizeof(ValueType) + ComputeDataSize(n)); // NOLINT + } + + void SetHeader(GLsizei n) { + header.SetCmdByTotalSize<ValueType>(ComputeSize(n)); + } + + void Init(GLsizei _n, GLuint* _textures) { + SetHeader(_n); + n = _n; + memcpy(ImmediateDataAddress(this), + _textures, ComputeDataSize(_n)); + } + + void* Set(void* cmd, GLsizei _n, GLuint* _textures) { + static_cast<ValueType*>(cmd)->Init(_n, _textures); + const uint32 size = ComputeSize(_n); + return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); + } + + command_buffer::CommandHeader header; + uint32 n; +}; + +COMPILE_ASSERT(sizeof(GenTexturesImmediate) == 8, + Sizeof_GenTexturesImmediate_is_not_8); +COMPILE_ASSERT(offsetof(GenTexturesImmediate, header) == 0, + OffsetOf_GenTexturesImmediate_header_not_0); +COMPILE_ASSERT(offsetof(GenTexturesImmediate, n) == 4, + OffsetOf_GenTexturesImmediate_n_not_4); + +struct GetActiveAttrib { + typedef GetActiveAttrib ValueType; + static const CommandId kCmdId = kGetActiveAttrib; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLuint _program, GLuint _index, GLsizei _bufsize, uint32 _length_shm_id, + uint32 _length_shm_offset, uint32 _size_shm_id, uint32 _size_shm_offset, + uint32 _type_shm_id, uint32 _type_shm_offset, uint32 _name_shm_id, + uint32 _name_shm_offset) { + SetHeader(); + program = _program; + index = _index; + bufsize = _bufsize; + length_shm_id = _length_shm_id; + length_shm_offset = _length_shm_offset; + size_shm_id = _size_shm_id; + size_shm_offset = _size_shm_offset; + type_shm_id = _type_shm_id; + type_shm_offset = _type_shm_offset; + name_shm_id = _name_shm_id; + name_shm_offset = _name_shm_offset; + } + + void* Set( + void* cmd, GLuint _program, GLuint _index, GLsizei _bufsize, + uint32 _length_shm_id, uint32 _length_shm_offset, uint32 _size_shm_id, + uint32 _size_shm_offset, uint32 _type_shm_id, uint32 _type_shm_offset, + uint32 _name_shm_id, uint32 _name_shm_offset) { + static_cast<ValueType*>( + cmd)->Init( + _program, _index, _bufsize, _length_shm_id, _length_shm_offset, + _size_shm_id, _size_shm_offset, _type_shm_id, _type_shm_offset, + _name_shm_id, _name_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 program; + uint32 index; + uint32 bufsize; + uint32 length_shm_id; + uint32 length_shm_offset; + uint32 size_shm_id; + uint32 size_shm_offset; + uint32 type_shm_id; + uint32 type_shm_offset; + uint32 name_shm_id; + uint32 name_shm_offset; +}; + +COMPILE_ASSERT(sizeof(GetActiveAttrib) == 48, + Sizeof_GetActiveAttrib_is_not_48); +COMPILE_ASSERT(offsetof(GetActiveAttrib, header) == 0, + OffsetOf_GetActiveAttrib_header_not_0); +COMPILE_ASSERT(offsetof(GetActiveAttrib, program) == 4, + OffsetOf_GetActiveAttrib_program_not_4); +COMPILE_ASSERT(offsetof(GetActiveAttrib, index) == 8, + OffsetOf_GetActiveAttrib_index_not_8); +COMPILE_ASSERT(offsetof(GetActiveAttrib, bufsize) == 12, + OffsetOf_GetActiveAttrib_bufsize_not_12); +COMPILE_ASSERT(offsetof(GetActiveAttrib, length_shm_id) == 16, + OffsetOf_GetActiveAttrib_length_shm_id_not_16); +COMPILE_ASSERT(offsetof(GetActiveAttrib, length_shm_offset) == 20, + OffsetOf_GetActiveAttrib_length_shm_offset_not_20); +COMPILE_ASSERT(offsetof(GetActiveAttrib, size_shm_id) == 24, + OffsetOf_GetActiveAttrib_size_shm_id_not_24); +COMPILE_ASSERT(offsetof(GetActiveAttrib, size_shm_offset) == 28, + OffsetOf_GetActiveAttrib_size_shm_offset_not_28); +COMPILE_ASSERT(offsetof(GetActiveAttrib, type_shm_id) == 32, + OffsetOf_GetActiveAttrib_type_shm_id_not_32); +COMPILE_ASSERT(offsetof(GetActiveAttrib, type_shm_offset) == 36, + OffsetOf_GetActiveAttrib_type_shm_offset_not_36); +COMPILE_ASSERT(offsetof(GetActiveAttrib, name_shm_id) == 40, + OffsetOf_GetActiveAttrib_name_shm_id_not_40); +COMPILE_ASSERT(offsetof(GetActiveAttrib, name_shm_offset) == 44, + OffsetOf_GetActiveAttrib_name_shm_offset_not_44); + +struct GetActiveUniform { + typedef GetActiveUniform ValueType; + static const CommandId kCmdId = kGetActiveUniform; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLuint _program, GLuint _index, GLsizei _bufsize, uint32 _length_shm_id, + uint32 _length_shm_offset, uint32 _size_shm_id, uint32 _size_shm_offset, + uint32 _type_shm_id, uint32 _type_shm_offset, uint32 _name_shm_id, + uint32 _name_shm_offset) { + SetHeader(); + program = _program; + index = _index; + bufsize = _bufsize; + length_shm_id = _length_shm_id; + length_shm_offset = _length_shm_offset; + size_shm_id = _size_shm_id; + size_shm_offset = _size_shm_offset; + type_shm_id = _type_shm_id; + type_shm_offset = _type_shm_offset; + name_shm_id = _name_shm_id; + name_shm_offset = _name_shm_offset; + } + + void* Set( + void* cmd, GLuint _program, GLuint _index, GLsizei _bufsize, + uint32 _length_shm_id, uint32 _length_shm_offset, uint32 _size_shm_id, + uint32 _size_shm_offset, uint32 _type_shm_id, uint32 _type_shm_offset, + uint32 _name_shm_id, uint32 _name_shm_offset) { + static_cast<ValueType*>( + cmd)->Init( + _program, _index, _bufsize, _length_shm_id, _length_shm_offset, + _size_shm_id, _size_shm_offset, _type_shm_id, _type_shm_offset, + _name_shm_id, _name_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 program; + uint32 index; + uint32 bufsize; + uint32 length_shm_id; + uint32 length_shm_offset; + uint32 size_shm_id; + uint32 size_shm_offset; + uint32 type_shm_id; + uint32 type_shm_offset; + uint32 name_shm_id; + uint32 name_shm_offset; +}; + +COMPILE_ASSERT(sizeof(GetActiveUniform) == 48, + Sizeof_GetActiveUniform_is_not_48); +COMPILE_ASSERT(offsetof(GetActiveUniform, header) == 0, + OffsetOf_GetActiveUniform_header_not_0); +COMPILE_ASSERT(offsetof(GetActiveUniform, program) == 4, + OffsetOf_GetActiveUniform_program_not_4); +COMPILE_ASSERT(offsetof(GetActiveUniform, index) == 8, + OffsetOf_GetActiveUniform_index_not_8); +COMPILE_ASSERT(offsetof(GetActiveUniform, bufsize) == 12, + OffsetOf_GetActiveUniform_bufsize_not_12); +COMPILE_ASSERT(offsetof(GetActiveUniform, length_shm_id) == 16, + OffsetOf_GetActiveUniform_length_shm_id_not_16); +COMPILE_ASSERT(offsetof(GetActiveUniform, length_shm_offset) == 20, + OffsetOf_GetActiveUniform_length_shm_offset_not_20); +COMPILE_ASSERT(offsetof(GetActiveUniform, size_shm_id) == 24, + OffsetOf_GetActiveUniform_size_shm_id_not_24); +COMPILE_ASSERT(offsetof(GetActiveUniform, size_shm_offset) == 28, + OffsetOf_GetActiveUniform_size_shm_offset_not_28); +COMPILE_ASSERT(offsetof(GetActiveUniform, type_shm_id) == 32, + OffsetOf_GetActiveUniform_type_shm_id_not_32); +COMPILE_ASSERT(offsetof(GetActiveUniform, type_shm_offset) == 36, + OffsetOf_GetActiveUniform_type_shm_offset_not_36); +COMPILE_ASSERT(offsetof(GetActiveUniform, name_shm_id) == 40, + OffsetOf_GetActiveUniform_name_shm_id_not_40); +COMPILE_ASSERT(offsetof(GetActiveUniform, name_shm_offset) == 44, + OffsetOf_GetActiveUniform_name_shm_offset_not_44); + +struct GetAttachedShaders { + typedef GetAttachedShaders ValueType; + static const CommandId kCmdId = kGetAttachedShaders; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLuint _program, GLsizei _maxcount, uint32 _count_shm_id, + uint32 _count_shm_offset, uint32 _shaders_shm_id, + uint32 _shaders_shm_offset) { + SetHeader(); + program = _program; + maxcount = _maxcount; + count_shm_id = _count_shm_id; + count_shm_offset = _count_shm_offset; + shaders_shm_id = _shaders_shm_id; + shaders_shm_offset = _shaders_shm_offset; + } + + void* Set( + void* cmd, GLuint _program, GLsizei _maxcount, uint32 _count_shm_id, + uint32 _count_shm_offset, uint32 _shaders_shm_id, + uint32 _shaders_shm_offset) { + static_cast<ValueType*>( + cmd)->Init( + _program, _maxcount, _count_shm_id, _count_shm_offset, + _shaders_shm_id, _shaders_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 program; + uint32 maxcount; + uint32 count_shm_id; + uint32 count_shm_offset; + uint32 shaders_shm_id; + uint32 shaders_shm_offset; +}; + +COMPILE_ASSERT(sizeof(GetAttachedShaders) == 28, + Sizeof_GetAttachedShaders_is_not_28); +COMPILE_ASSERT(offsetof(GetAttachedShaders, header) == 0, + OffsetOf_GetAttachedShaders_header_not_0); +COMPILE_ASSERT(offsetof(GetAttachedShaders, program) == 4, + OffsetOf_GetAttachedShaders_program_not_4); +COMPILE_ASSERT(offsetof(GetAttachedShaders, maxcount) == 8, + OffsetOf_GetAttachedShaders_maxcount_not_8); +COMPILE_ASSERT(offsetof(GetAttachedShaders, count_shm_id) == 12, + OffsetOf_GetAttachedShaders_count_shm_id_not_12); +COMPILE_ASSERT(offsetof(GetAttachedShaders, count_shm_offset) == 16, + OffsetOf_GetAttachedShaders_count_shm_offset_not_16); +COMPILE_ASSERT(offsetof(GetAttachedShaders, shaders_shm_id) == 20, + OffsetOf_GetAttachedShaders_shaders_shm_id_not_20); +COMPILE_ASSERT(offsetof(GetAttachedShaders, shaders_shm_offset) == 24, + OffsetOf_GetAttachedShaders_shaders_shm_offset_not_24); + +struct GetAttribLocation { + typedef GetAttribLocation ValueType; + static const CommandId kCmdId = kGetAttribLocation; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLuint _program, uint32 _name_shm_id, uint32 _name_shm_offset, + uint32 _data_size) { + SetHeader(); + program = _program; + name_shm_id = _name_shm_id; + name_shm_offset = _name_shm_offset; + data_size = _data_size; + } + + void* Set( + void* cmd, GLuint _program, uint32 _name_shm_id, uint32 _name_shm_offset, + uint32 _data_size) { + static_cast<ValueType*>( + cmd)->Init(_program, _name_shm_id, _name_shm_offset, _data_size); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 program; + uint32 name_shm_id; + uint32 name_shm_offset; + uint32 data_size; +}; + +COMPILE_ASSERT(sizeof(GetAttribLocation) == 20, + Sizeof_GetAttribLocation_is_not_20); +COMPILE_ASSERT(offsetof(GetAttribLocation, header) == 0, + OffsetOf_GetAttribLocation_header_not_0); +COMPILE_ASSERT(offsetof(GetAttribLocation, program) == 4, + OffsetOf_GetAttribLocation_program_not_4); +COMPILE_ASSERT(offsetof(GetAttribLocation, name_shm_id) == 8, + OffsetOf_GetAttribLocation_name_shm_id_not_8); +COMPILE_ASSERT(offsetof(GetAttribLocation, name_shm_offset) == 12, + OffsetOf_GetAttribLocation_name_shm_offset_not_12); +COMPILE_ASSERT(offsetof(GetAttribLocation, data_size) == 16, + OffsetOf_GetAttribLocation_data_size_not_16); + +struct GetAttribLocationImmediate { + typedef GetAttribLocationImmediate ValueType; + static const CommandId kCmdId = kGetAttribLocationImmediate; + static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN; + + static uint32 ComputeDataSize(const char* s) { + return strlen(s); + } + + static uint32 ComputeSize(const char* s) { + return static_cast<uint32>( + sizeof(ValueType) + ComputeDataSize(s)); // NOLINT + } + + void SetHeader(const char* s) { + header.SetCmdByTotalSize<ValueType>(ComputeSize(s)); + } + + void Init(GLuint _program, const char* _name) { + SetHeader(_name); + program = _program; + data_size = strlen(_name); + memcpy(ImmediateDataAddress(this), _name, data_size); + } + + void* Set(void* cmd, GLuint _program, const char* _name) { + static_cast<ValueType*>(cmd)->Init(_program, _name); + const uint32 size = ComputeSize(_name); + return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); + } + + command_buffer::CommandHeader header; + uint32 program; + uint32 data_size; +}; + +COMPILE_ASSERT(sizeof(GetAttribLocationImmediate) == 12, + Sizeof_GetAttribLocationImmediate_is_not_12); +COMPILE_ASSERT(offsetof(GetAttribLocationImmediate, header) == 0, + OffsetOf_GetAttribLocationImmediate_header_not_0); +COMPILE_ASSERT(offsetof(GetAttribLocationImmediate, program) == 4, + OffsetOf_GetAttribLocationImmediate_program_not_4); +COMPILE_ASSERT(offsetof(GetAttribLocationImmediate, data_size) == 8, + OffsetOf_GetAttribLocationImmediate_data_size_not_8); + +struct GetBooleanv { + typedef GetBooleanv ValueType; + static const CommandId kCmdId = kGetBooleanv; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLenum _pname, uint32 _params_shm_id, uint32 _params_shm_offset) { + SetHeader(); + pname = _pname; + params_shm_id = _params_shm_id; + params_shm_offset = _params_shm_offset; + } + + void* Set( + void* cmd, GLenum _pname, uint32 _params_shm_id, + uint32 _params_shm_offset) { + static_cast<ValueType*>( + cmd)->Init(_pname, _params_shm_id, _params_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 pname; + uint32 params_shm_id; + uint32 params_shm_offset; +}; + +COMPILE_ASSERT(sizeof(GetBooleanv) == 16, + Sizeof_GetBooleanv_is_not_16); +COMPILE_ASSERT(offsetof(GetBooleanv, header) == 0, + OffsetOf_GetBooleanv_header_not_0); +COMPILE_ASSERT(offsetof(GetBooleanv, pname) == 4, + OffsetOf_GetBooleanv_pname_not_4); +COMPILE_ASSERT(offsetof(GetBooleanv, params_shm_id) == 8, + OffsetOf_GetBooleanv_params_shm_id_not_8); +COMPILE_ASSERT(offsetof(GetBooleanv, params_shm_offset) == 12, + OffsetOf_GetBooleanv_params_shm_offset_not_12); + +struct GetBufferParameteriv { + typedef GetBufferParameteriv ValueType; + static const CommandId kCmdId = kGetBufferParameteriv; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLenum _target, GLenum _pname, uint32 _params_shm_id, + uint32 _params_shm_offset) { + SetHeader(); + target = _target; + pname = _pname; + params_shm_id = _params_shm_id; + params_shm_offset = _params_shm_offset; + } + + void* Set( + void* cmd, GLenum _target, GLenum _pname, uint32 _params_shm_id, + uint32 _params_shm_offset) { + static_cast<ValueType*>( + cmd)->Init(_target, _pname, _params_shm_id, _params_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 target; + uint32 pname; + uint32 params_shm_id; + uint32 params_shm_offset; +}; + +COMPILE_ASSERT(sizeof(GetBufferParameteriv) == 20, + Sizeof_GetBufferParameteriv_is_not_20); +COMPILE_ASSERT(offsetof(GetBufferParameteriv, header) == 0, + OffsetOf_GetBufferParameteriv_header_not_0); +COMPILE_ASSERT(offsetof(GetBufferParameteriv, target) == 4, + OffsetOf_GetBufferParameteriv_target_not_4); +COMPILE_ASSERT(offsetof(GetBufferParameteriv, pname) == 8, + OffsetOf_GetBufferParameteriv_pname_not_8); +COMPILE_ASSERT(offsetof(GetBufferParameteriv, params_shm_id) == 12, + OffsetOf_GetBufferParameteriv_params_shm_id_not_12); +COMPILE_ASSERT(offsetof(GetBufferParameteriv, params_shm_offset) == 16, + OffsetOf_GetBufferParameteriv_params_shm_offset_not_16); + +struct GetError { + typedef GetError ValueType; + static const CommandId kCmdId = kGetError; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(uint32 _result_shm_id, uint32 _result_shm_offset) { + SetHeader(); + result_shm_id = _result_shm_id; + result_shm_offset = _result_shm_offset; + } + + void* Set(void* cmd, uint32 _result_shm_id, uint32 _result_shm_offset) { + static_cast<ValueType*>(cmd)->Init(_result_shm_id, _result_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 result_shm_id; + uint32 result_shm_offset; +}; + +COMPILE_ASSERT(sizeof(GetError) == 12, + Sizeof_GetError_is_not_12); +COMPILE_ASSERT(offsetof(GetError, header) == 0, + OffsetOf_GetError_header_not_0); +COMPILE_ASSERT(offsetof(GetError, result_shm_id) == 4, + OffsetOf_GetError_result_shm_id_not_4); +COMPILE_ASSERT(offsetof(GetError, result_shm_offset) == 8, + OffsetOf_GetError_result_shm_offset_not_8); + +struct GetFloatv { + typedef GetFloatv ValueType; + static const CommandId kCmdId = kGetFloatv; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLenum _pname, uint32 _params_shm_id, uint32 _params_shm_offset) { + SetHeader(); + pname = _pname; + params_shm_id = _params_shm_id; + params_shm_offset = _params_shm_offset; + } + + void* Set( + void* cmd, GLenum _pname, uint32 _params_shm_id, + uint32 _params_shm_offset) { + static_cast<ValueType*>( + cmd)->Init(_pname, _params_shm_id, _params_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 pname; + uint32 params_shm_id; + uint32 params_shm_offset; +}; + +COMPILE_ASSERT(sizeof(GetFloatv) == 16, + Sizeof_GetFloatv_is_not_16); +COMPILE_ASSERT(offsetof(GetFloatv, header) == 0, + OffsetOf_GetFloatv_header_not_0); +COMPILE_ASSERT(offsetof(GetFloatv, pname) == 4, + OffsetOf_GetFloatv_pname_not_4); +COMPILE_ASSERT(offsetof(GetFloatv, params_shm_id) == 8, + OffsetOf_GetFloatv_params_shm_id_not_8); +COMPILE_ASSERT(offsetof(GetFloatv, params_shm_offset) == 12, + OffsetOf_GetFloatv_params_shm_offset_not_12); + +struct GetFramebufferAttachmentParameteriv { + typedef GetFramebufferAttachmentParameteriv ValueType; + static const CommandId kCmdId = kGetFramebufferAttachmentParameteriv; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLenum _target, GLenum _attachment, GLenum _pname, uint32 _params_shm_id, + uint32 _params_shm_offset) { + SetHeader(); + target = _target; + attachment = _attachment; + pname = _pname; + params_shm_id = _params_shm_id; + params_shm_offset = _params_shm_offset; + } + + void* Set( + void* cmd, GLenum _target, GLenum _attachment, GLenum _pname, + uint32 _params_shm_id, uint32 _params_shm_offset) { + static_cast<ValueType*>( + cmd)->Init( + _target, _attachment, _pname, _params_shm_id, _params_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 target; + uint32 attachment; + uint32 pname; + uint32 params_shm_id; + uint32 params_shm_offset; +}; + +COMPILE_ASSERT(sizeof(GetFramebufferAttachmentParameteriv) == 24, + Sizeof_GetFramebufferAttachmentParameteriv_is_not_24); +COMPILE_ASSERT(offsetof(GetFramebufferAttachmentParameteriv, header) == 0, + OffsetOf_GetFramebufferAttachmentParameteriv_header_not_0); +COMPILE_ASSERT(offsetof(GetFramebufferAttachmentParameteriv, target) == 4, + OffsetOf_GetFramebufferAttachmentParameteriv_target_not_4); +COMPILE_ASSERT(offsetof(GetFramebufferAttachmentParameteriv, attachment) == 8, + OffsetOf_GetFramebufferAttachmentParameteriv_attachment_not_8); +COMPILE_ASSERT(offsetof(GetFramebufferAttachmentParameteriv, pname) == 12, + OffsetOf_GetFramebufferAttachmentParameteriv_pname_not_12); +COMPILE_ASSERT( + offsetof(GetFramebufferAttachmentParameteriv, params_shm_id) == 16, + OffsetOf_GetFramebufferAttachmentParameteriv_params_shm_id_not_16); +COMPILE_ASSERT( + offsetof(GetFramebufferAttachmentParameteriv, params_shm_offset) == 20, + OffsetOf_GetFramebufferAttachmentParameteriv_params_shm_offset_not_20); + +struct GetIntegerv { + typedef GetIntegerv ValueType; + static const CommandId kCmdId = kGetIntegerv; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLenum _pname, uint32 _params_shm_id, uint32 _params_shm_offset) { + SetHeader(); + pname = _pname; + params_shm_id = _params_shm_id; + params_shm_offset = _params_shm_offset; + } + + void* Set( + void* cmd, GLenum _pname, uint32 _params_shm_id, + uint32 _params_shm_offset) { + static_cast<ValueType*>( + cmd)->Init(_pname, _params_shm_id, _params_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 pname; + uint32 params_shm_id; + uint32 params_shm_offset; +}; + +COMPILE_ASSERT(sizeof(GetIntegerv) == 16, + Sizeof_GetIntegerv_is_not_16); +COMPILE_ASSERT(offsetof(GetIntegerv, header) == 0, + OffsetOf_GetIntegerv_header_not_0); +COMPILE_ASSERT(offsetof(GetIntegerv, pname) == 4, + OffsetOf_GetIntegerv_pname_not_4); +COMPILE_ASSERT(offsetof(GetIntegerv, params_shm_id) == 8, + OffsetOf_GetIntegerv_params_shm_id_not_8); +COMPILE_ASSERT(offsetof(GetIntegerv, params_shm_offset) == 12, + OffsetOf_GetIntegerv_params_shm_offset_not_12); + +struct GetProgramiv { + typedef GetProgramiv ValueType; + static const CommandId kCmdId = kGetProgramiv; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLuint _program, GLenum _pname, uint32 _params_shm_id, + uint32 _params_shm_offset) { + SetHeader(); + program = _program; + pname = _pname; + params_shm_id = _params_shm_id; + params_shm_offset = _params_shm_offset; + } + + void* Set( + void* cmd, GLuint _program, GLenum _pname, uint32 _params_shm_id, + uint32 _params_shm_offset) { + static_cast<ValueType*>( + cmd)->Init(_program, _pname, _params_shm_id, _params_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 program; + uint32 pname; + uint32 params_shm_id; + uint32 params_shm_offset; +}; + +COMPILE_ASSERT(sizeof(GetProgramiv) == 20, + Sizeof_GetProgramiv_is_not_20); +COMPILE_ASSERT(offsetof(GetProgramiv, header) == 0, + OffsetOf_GetProgramiv_header_not_0); +COMPILE_ASSERT(offsetof(GetProgramiv, program) == 4, + OffsetOf_GetProgramiv_program_not_4); +COMPILE_ASSERT(offsetof(GetProgramiv, pname) == 8, + OffsetOf_GetProgramiv_pname_not_8); +COMPILE_ASSERT(offsetof(GetProgramiv, params_shm_id) == 12, + OffsetOf_GetProgramiv_params_shm_id_not_12); +COMPILE_ASSERT(offsetof(GetProgramiv, params_shm_offset) == 16, + OffsetOf_GetProgramiv_params_shm_offset_not_16); + +struct GetProgramInfoLog { + typedef GetProgramInfoLog ValueType; + static const CommandId kCmdId = kGetProgramInfoLog; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLuint _program, GLsizei _bufsize, uint32 _length_shm_id, + uint32 _length_shm_offset, uint32 _infolog_shm_id, + uint32 _infolog_shm_offset) { + SetHeader(); + program = _program; + bufsize = _bufsize; + length_shm_id = _length_shm_id; + length_shm_offset = _length_shm_offset; + infolog_shm_id = _infolog_shm_id; + infolog_shm_offset = _infolog_shm_offset; + } + + void* Set( + void* cmd, GLuint _program, GLsizei _bufsize, uint32 _length_shm_id, + uint32 _length_shm_offset, uint32 _infolog_shm_id, + uint32 _infolog_shm_offset) { + static_cast<ValueType*>( + cmd)->Init( + _program, _bufsize, _length_shm_id, _length_shm_offset, + _infolog_shm_id, _infolog_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 program; + uint32 bufsize; + uint32 length_shm_id; + uint32 length_shm_offset; + uint32 infolog_shm_id; + uint32 infolog_shm_offset; +}; + +COMPILE_ASSERT(sizeof(GetProgramInfoLog) == 28, + Sizeof_GetProgramInfoLog_is_not_28); +COMPILE_ASSERT(offsetof(GetProgramInfoLog, header) == 0, + OffsetOf_GetProgramInfoLog_header_not_0); +COMPILE_ASSERT(offsetof(GetProgramInfoLog, program) == 4, + OffsetOf_GetProgramInfoLog_program_not_4); +COMPILE_ASSERT(offsetof(GetProgramInfoLog, bufsize) == 8, + OffsetOf_GetProgramInfoLog_bufsize_not_8); +COMPILE_ASSERT(offsetof(GetProgramInfoLog, length_shm_id) == 12, + OffsetOf_GetProgramInfoLog_length_shm_id_not_12); +COMPILE_ASSERT(offsetof(GetProgramInfoLog, length_shm_offset) == 16, + OffsetOf_GetProgramInfoLog_length_shm_offset_not_16); +COMPILE_ASSERT(offsetof(GetProgramInfoLog, infolog_shm_id) == 20, + OffsetOf_GetProgramInfoLog_infolog_shm_id_not_20); +COMPILE_ASSERT(offsetof(GetProgramInfoLog, infolog_shm_offset) == 24, + OffsetOf_GetProgramInfoLog_infolog_shm_offset_not_24); + +struct GetRenderbufferParameteriv { + typedef GetRenderbufferParameteriv ValueType; + static const CommandId kCmdId = kGetRenderbufferParameteriv; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLenum _target, GLenum _pname, uint32 _params_shm_id, + uint32 _params_shm_offset) { + SetHeader(); + target = _target; + pname = _pname; + params_shm_id = _params_shm_id; + params_shm_offset = _params_shm_offset; + } + + void* Set( + void* cmd, GLenum _target, GLenum _pname, uint32 _params_shm_id, + uint32 _params_shm_offset) { + static_cast<ValueType*>( + cmd)->Init(_target, _pname, _params_shm_id, _params_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 target; + uint32 pname; + uint32 params_shm_id; + uint32 params_shm_offset; +}; + +COMPILE_ASSERT(sizeof(GetRenderbufferParameteriv) == 20, + Sizeof_GetRenderbufferParameteriv_is_not_20); +COMPILE_ASSERT(offsetof(GetRenderbufferParameteriv, header) == 0, + OffsetOf_GetRenderbufferParameteriv_header_not_0); +COMPILE_ASSERT(offsetof(GetRenderbufferParameteriv, target) == 4, + OffsetOf_GetRenderbufferParameteriv_target_not_4); +COMPILE_ASSERT(offsetof(GetRenderbufferParameteriv, pname) == 8, + OffsetOf_GetRenderbufferParameteriv_pname_not_8); +COMPILE_ASSERT(offsetof(GetRenderbufferParameteriv, params_shm_id) == 12, + OffsetOf_GetRenderbufferParameteriv_params_shm_id_not_12); +COMPILE_ASSERT(offsetof(GetRenderbufferParameteriv, params_shm_offset) == 16, + OffsetOf_GetRenderbufferParameteriv_params_shm_offset_not_16); + +struct GetShaderiv { + typedef GetShaderiv ValueType; + static const CommandId kCmdId = kGetShaderiv; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLuint _shader, GLenum _pname, uint32 _params_shm_id, + uint32 _params_shm_offset) { + SetHeader(); + shader = _shader; + pname = _pname; + params_shm_id = _params_shm_id; + params_shm_offset = _params_shm_offset; + } + + void* Set( + void* cmd, GLuint _shader, GLenum _pname, uint32 _params_shm_id, + uint32 _params_shm_offset) { + static_cast<ValueType*>( + cmd)->Init(_shader, _pname, _params_shm_id, _params_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 shader; + uint32 pname; + uint32 params_shm_id; + uint32 params_shm_offset; +}; + +COMPILE_ASSERT(sizeof(GetShaderiv) == 20, + Sizeof_GetShaderiv_is_not_20); +COMPILE_ASSERT(offsetof(GetShaderiv, header) == 0, + OffsetOf_GetShaderiv_header_not_0); +COMPILE_ASSERT(offsetof(GetShaderiv, shader) == 4, + OffsetOf_GetShaderiv_shader_not_4); +COMPILE_ASSERT(offsetof(GetShaderiv, pname) == 8, + OffsetOf_GetShaderiv_pname_not_8); +COMPILE_ASSERT(offsetof(GetShaderiv, params_shm_id) == 12, + OffsetOf_GetShaderiv_params_shm_id_not_12); +COMPILE_ASSERT(offsetof(GetShaderiv, params_shm_offset) == 16, + OffsetOf_GetShaderiv_params_shm_offset_not_16); + +struct GetShaderInfoLog { + typedef GetShaderInfoLog ValueType; + static const CommandId kCmdId = kGetShaderInfoLog; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLuint _shader, GLsizei _bufsize, uint32 _length_shm_id, + uint32 _length_shm_offset, uint32 _infolog_shm_id, + uint32 _infolog_shm_offset) { + SetHeader(); + shader = _shader; + bufsize = _bufsize; + length_shm_id = _length_shm_id; + length_shm_offset = _length_shm_offset; + infolog_shm_id = _infolog_shm_id; + infolog_shm_offset = _infolog_shm_offset; + } + + void* Set( + void* cmd, GLuint _shader, GLsizei _bufsize, uint32 _length_shm_id, + uint32 _length_shm_offset, uint32 _infolog_shm_id, + uint32 _infolog_shm_offset) { + static_cast<ValueType*>( + cmd)->Init( + _shader, _bufsize, _length_shm_id, _length_shm_offset, + _infolog_shm_id, _infolog_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 shader; + uint32 bufsize; + uint32 length_shm_id; + uint32 length_shm_offset; + uint32 infolog_shm_id; + uint32 infolog_shm_offset; +}; + +COMPILE_ASSERT(sizeof(GetShaderInfoLog) == 28, + Sizeof_GetShaderInfoLog_is_not_28); +COMPILE_ASSERT(offsetof(GetShaderInfoLog, header) == 0, + OffsetOf_GetShaderInfoLog_header_not_0); +COMPILE_ASSERT(offsetof(GetShaderInfoLog, shader) == 4, + OffsetOf_GetShaderInfoLog_shader_not_4); +COMPILE_ASSERT(offsetof(GetShaderInfoLog, bufsize) == 8, + OffsetOf_GetShaderInfoLog_bufsize_not_8); +COMPILE_ASSERT(offsetof(GetShaderInfoLog, length_shm_id) == 12, + OffsetOf_GetShaderInfoLog_length_shm_id_not_12); +COMPILE_ASSERT(offsetof(GetShaderInfoLog, length_shm_offset) == 16, + OffsetOf_GetShaderInfoLog_length_shm_offset_not_16); +COMPILE_ASSERT(offsetof(GetShaderInfoLog, infolog_shm_id) == 20, + OffsetOf_GetShaderInfoLog_infolog_shm_id_not_20); +COMPILE_ASSERT(offsetof(GetShaderInfoLog, infolog_shm_offset) == 24, + OffsetOf_GetShaderInfoLog_infolog_shm_offset_not_24); + +struct GetShaderPrecisionFormat { + typedef GetShaderPrecisionFormat ValueType; + static const CommandId kCmdId = kGetShaderPrecisionFormat; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLenum _shadertype, GLenum _precisiontype, uint32 _range_shm_id, + uint32 _range_shm_offset, uint32 _precision_shm_id, + uint32 _precision_shm_offset) { + SetHeader(); + shadertype = _shadertype; + precisiontype = _precisiontype; + range_shm_id = _range_shm_id; + range_shm_offset = _range_shm_offset; + precision_shm_id = _precision_shm_id; + precision_shm_offset = _precision_shm_offset; + } + + void* Set( + void* cmd, GLenum _shadertype, GLenum _precisiontype, + uint32 _range_shm_id, uint32 _range_shm_offset, uint32 _precision_shm_id, + uint32 _precision_shm_offset) { + static_cast<ValueType*>( + cmd)->Init( + _shadertype, _precisiontype, _range_shm_id, _range_shm_offset, + _precision_shm_id, _precision_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 shadertype; + uint32 precisiontype; + uint32 range_shm_id; + uint32 range_shm_offset; + uint32 precision_shm_id; + uint32 precision_shm_offset; +}; + +COMPILE_ASSERT(sizeof(GetShaderPrecisionFormat) == 28, + Sizeof_GetShaderPrecisionFormat_is_not_28); +COMPILE_ASSERT(offsetof(GetShaderPrecisionFormat, header) == 0, + OffsetOf_GetShaderPrecisionFormat_header_not_0); +COMPILE_ASSERT(offsetof(GetShaderPrecisionFormat, shadertype) == 4, + OffsetOf_GetShaderPrecisionFormat_shadertype_not_4); +COMPILE_ASSERT(offsetof(GetShaderPrecisionFormat, precisiontype) == 8, + OffsetOf_GetShaderPrecisionFormat_precisiontype_not_8); +COMPILE_ASSERT(offsetof(GetShaderPrecisionFormat, range_shm_id) == 12, + OffsetOf_GetShaderPrecisionFormat_range_shm_id_not_12); +COMPILE_ASSERT(offsetof(GetShaderPrecisionFormat, range_shm_offset) == 16, + OffsetOf_GetShaderPrecisionFormat_range_shm_offset_not_16); +COMPILE_ASSERT(offsetof(GetShaderPrecisionFormat, precision_shm_id) == 20, + OffsetOf_GetShaderPrecisionFormat_precision_shm_id_not_20); +COMPILE_ASSERT(offsetof(GetShaderPrecisionFormat, precision_shm_offset) == 24, + OffsetOf_GetShaderPrecisionFormat_precision_shm_offset_not_24); + +struct GetShaderSource { + typedef GetShaderSource ValueType; + static const CommandId kCmdId = kGetShaderSource; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLuint _shader, GLsizei _bufsize, uint32 _length_shm_id, + uint32 _length_shm_offset, uint32 _source_shm_id, + uint32 _source_shm_offset) { + SetHeader(); + shader = _shader; + bufsize = _bufsize; + length_shm_id = _length_shm_id; + length_shm_offset = _length_shm_offset; + source_shm_id = _source_shm_id; + source_shm_offset = _source_shm_offset; + } + + void* Set( + void* cmd, GLuint _shader, GLsizei _bufsize, uint32 _length_shm_id, + uint32 _length_shm_offset, uint32 _source_shm_id, + uint32 _source_shm_offset) { + static_cast<ValueType*>( + cmd)->Init( + _shader, _bufsize, _length_shm_id, _length_shm_offset, + _source_shm_id, _source_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 shader; + uint32 bufsize; + uint32 length_shm_id; + uint32 length_shm_offset; + uint32 source_shm_id; + uint32 source_shm_offset; +}; + +COMPILE_ASSERT(sizeof(GetShaderSource) == 28, + Sizeof_GetShaderSource_is_not_28); +COMPILE_ASSERT(offsetof(GetShaderSource, header) == 0, + OffsetOf_GetShaderSource_header_not_0); +COMPILE_ASSERT(offsetof(GetShaderSource, shader) == 4, + OffsetOf_GetShaderSource_shader_not_4); +COMPILE_ASSERT(offsetof(GetShaderSource, bufsize) == 8, + OffsetOf_GetShaderSource_bufsize_not_8); +COMPILE_ASSERT(offsetof(GetShaderSource, length_shm_id) == 12, + OffsetOf_GetShaderSource_length_shm_id_not_12); +COMPILE_ASSERT(offsetof(GetShaderSource, length_shm_offset) == 16, + OffsetOf_GetShaderSource_length_shm_offset_not_16); +COMPILE_ASSERT(offsetof(GetShaderSource, source_shm_id) == 20, + OffsetOf_GetShaderSource_source_shm_id_not_20); +COMPILE_ASSERT(offsetof(GetShaderSource, source_shm_offset) == 24, + OffsetOf_GetShaderSource_source_shm_offset_not_24); + +struct GetString { + typedef GetString ValueType; + static const CommandId kCmdId = kGetString; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLenum _name) { + SetHeader(); + name = _name; + } + + void* Set(void* cmd, GLenum _name) { + static_cast<ValueType*>(cmd)->Init(_name); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 name; +}; + +COMPILE_ASSERT(sizeof(GetString) == 8, + Sizeof_GetString_is_not_8); +COMPILE_ASSERT(offsetof(GetString, header) == 0, + OffsetOf_GetString_header_not_0); +COMPILE_ASSERT(offsetof(GetString, name) == 4, + OffsetOf_GetString_name_not_4); + +struct GetTexParameterfv { + typedef GetTexParameterfv ValueType; + static const CommandId kCmdId = kGetTexParameterfv; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLenum _target, GLenum _pname, uint32 _params_shm_id, + uint32 _params_shm_offset) { + SetHeader(); + target = _target; + pname = _pname; + params_shm_id = _params_shm_id; + params_shm_offset = _params_shm_offset; + } + + void* Set( + void* cmd, GLenum _target, GLenum _pname, uint32 _params_shm_id, + uint32 _params_shm_offset) { + static_cast<ValueType*>( + cmd)->Init(_target, _pname, _params_shm_id, _params_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 target; + uint32 pname; + uint32 params_shm_id; + uint32 params_shm_offset; +}; + +COMPILE_ASSERT(sizeof(GetTexParameterfv) == 20, + Sizeof_GetTexParameterfv_is_not_20); +COMPILE_ASSERT(offsetof(GetTexParameterfv, header) == 0, + OffsetOf_GetTexParameterfv_header_not_0); +COMPILE_ASSERT(offsetof(GetTexParameterfv, target) == 4, + OffsetOf_GetTexParameterfv_target_not_4); +COMPILE_ASSERT(offsetof(GetTexParameterfv, pname) == 8, + OffsetOf_GetTexParameterfv_pname_not_8); +COMPILE_ASSERT(offsetof(GetTexParameterfv, params_shm_id) == 12, + OffsetOf_GetTexParameterfv_params_shm_id_not_12); +COMPILE_ASSERT(offsetof(GetTexParameterfv, params_shm_offset) == 16, + OffsetOf_GetTexParameterfv_params_shm_offset_not_16); + +struct GetTexParameteriv { + typedef GetTexParameteriv ValueType; + static const CommandId kCmdId = kGetTexParameteriv; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLenum _target, GLenum _pname, uint32 _params_shm_id, + uint32 _params_shm_offset) { + SetHeader(); + target = _target; + pname = _pname; + params_shm_id = _params_shm_id; + params_shm_offset = _params_shm_offset; + } + + void* Set( + void* cmd, GLenum _target, GLenum _pname, uint32 _params_shm_id, + uint32 _params_shm_offset) { + static_cast<ValueType*>( + cmd)->Init(_target, _pname, _params_shm_id, _params_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 target; + uint32 pname; + uint32 params_shm_id; + uint32 params_shm_offset; +}; + +COMPILE_ASSERT(sizeof(GetTexParameteriv) == 20, + Sizeof_GetTexParameteriv_is_not_20); +COMPILE_ASSERT(offsetof(GetTexParameteriv, header) == 0, + OffsetOf_GetTexParameteriv_header_not_0); +COMPILE_ASSERT(offsetof(GetTexParameteriv, target) == 4, + OffsetOf_GetTexParameteriv_target_not_4); +COMPILE_ASSERT(offsetof(GetTexParameteriv, pname) == 8, + OffsetOf_GetTexParameteriv_pname_not_8); +COMPILE_ASSERT(offsetof(GetTexParameteriv, params_shm_id) == 12, + OffsetOf_GetTexParameteriv_params_shm_id_not_12); +COMPILE_ASSERT(offsetof(GetTexParameteriv, params_shm_offset) == 16, + OffsetOf_GetTexParameteriv_params_shm_offset_not_16); + +struct GetUniformfv { + typedef GetUniformfv ValueType; + static const CommandId kCmdId = kGetUniformfv; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLuint _program, GLint _location, uint32 _params_shm_id, + uint32 _params_shm_offset) { + SetHeader(); + program = _program; + location = _location; + params_shm_id = _params_shm_id; + params_shm_offset = _params_shm_offset; + } + + void* Set( + void* cmd, GLuint _program, GLint _location, uint32 _params_shm_id, + uint32 _params_shm_offset) { + static_cast<ValueType*>( + cmd)->Init(_program, _location, _params_shm_id, _params_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 program; + uint32 location; + uint32 params_shm_id; + uint32 params_shm_offset; +}; + +COMPILE_ASSERT(sizeof(GetUniformfv) == 20, + Sizeof_GetUniformfv_is_not_20); +COMPILE_ASSERT(offsetof(GetUniformfv, header) == 0, + OffsetOf_GetUniformfv_header_not_0); +COMPILE_ASSERT(offsetof(GetUniformfv, program) == 4, + OffsetOf_GetUniformfv_program_not_4); +COMPILE_ASSERT(offsetof(GetUniformfv, location) == 8, + OffsetOf_GetUniformfv_location_not_8); +COMPILE_ASSERT(offsetof(GetUniformfv, params_shm_id) == 12, + OffsetOf_GetUniformfv_params_shm_id_not_12); +COMPILE_ASSERT(offsetof(GetUniformfv, params_shm_offset) == 16, + OffsetOf_GetUniformfv_params_shm_offset_not_16); + +struct GetUniformiv { + typedef GetUniformiv ValueType; + static const CommandId kCmdId = kGetUniformiv; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLuint _program, GLint _location, uint32 _params_shm_id, + uint32 _params_shm_offset) { + SetHeader(); + program = _program; + location = _location; + params_shm_id = _params_shm_id; + params_shm_offset = _params_shm_offset; + } + + void* Set( + void* cmd, GLuint _program, GLint _location, uint32 _params_shm_id, + uint32 _params_shm_offset) { + static_cast<ValueType*>( + cmd)->Init(_program, _location, _params_shm_id, _params_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 program; + uint32 location; + uint32 params_shm_id; + uint32 params_shm_offset; +}; + +COMPILE_ASSERT(sizeof(GetUniformiv) == 20, + Sizeof_GetUniformiv_is_not_20); +COMPILE_ASSERT(offsetof(GetUniformiv, header) == 0, + OffsetOf_GetUniformiv_header_not_0); +COMPILE_ASSERT(offsetof(GetUniformiv, program) == 4, + OffsetOf_GetUniformiv_program_not_4); +COMPILE_ASSERT(offsetof(GetUniformiv, location) == 8, + OffsetOf_GetUniformiv_location_not_8); +COMPILE_ASSERT(offsetof(GetUniformiv, params_shm_id) == 12, + OffsetOf_GetUniformiv_params_shm_id_not_12); +COMPILE_ASSERT(offsetof(GetUniformiv, params_shm_offset) == 16, + OffsetOf_GetUniformiv_params_shm_offset_not_16); + +struct GetUniformLocation { + typedef GetUniformLocation ValueType; + static const CommandId kCmdId = kGetUniformLocation; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLuint _program, uint32 _name_shm_id, uint32 _name_shm_offset, + uint32 _data_size) { + SetHeader(); + program = _program; + name_shm_id = _name_shm_id; + name_shm_offset = _name_shm_offset; + data_size = _data_size; + } + + void* Set( + void* cmd, GLuint _program, uint32 _name_shm_id, uint32 _name_shm_offset, + uint32 _data_size) { + static_cast<ValueType*>( + cmd)->Init(_program, _name_shm_id, _name_shm_offset, _data_size); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 program; + uint32 name_shm_id; + uint32 name_shm_offset; + uint32 data_size; +}; + +COMPILE_ASSERT(sizeof(GetUniformLocation) == 20, + Sizeof_GetUniformLocation_is_not_20); +COMPILE_ASSERT(offsetof(GetUniformLocation, header) == 0, + OffsetOf_GetUniformLocation_header_not_0); +COMPILE_ASSERT(offsetof(GetUniformLocation, program) == 4, + OffsetOf_GetUniformLocation_program_not_4); +COMPILE_ASSERT(offsetof(GetUniformLocation, name_shm_id) == 8, + OffsetOf_GetUniformLocation_name_shm_id_not_8); +COMPILE_ASSERT(offsetof(GetUniformLocation, name_shm_offset) == 12, + OffsetOf_GetUniformLocation_name_shm_offset_not_12); +COMPILE_ASSERT(offsetof(GetUniformLocation, data_size) == 16, + OffsetOf_GetUniformLocation_data_size_not_16); + +struct GetUniformLocationImmediate { + typedef GetUniformLocationImmediate ValueType; + static const CommandId kCmdId = kGetUniformLocationImmediate; + static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN; + + static uint32 ComputeDataSize(const char* s) { + return strlen(s); + } + + static uint32 ComputeSize(const char* s) { + return static_cast<uint32>( + sizeof(ValueType) + ComputeDataSize(s)); // NOLINT + } + + void SetHeader(const char* s) { + header.SetCmdByTotalSize<ValueType>(ComputeSize(s)); + } + + void Init(GLuint _program, const char* _name) { + SetHeader(_name); + program = _program; + data_size = strlen(_name); + memcpy(ImmediateDataAddress(this), _name, data_size); + } + + void* Set(void* cmd, GLuint _program, const char* _name) { + static_cast<ValueType*>(cmd)->Init(_program, _name); + const uint32 size = ComputeSize(_name); + return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); + } + + command_buffer::CommandHeader header; + uint32 program; + uint32 data_size; +}; + +COMPILE_ASSERT(sizeof(GetUniformLocationImmediate) == 12, + Sizeof_GetUniformLocationImmediate_is_not_12); +COMPILE_ASSERT(offsetof(GetUniformLocationImmediate, header) == 0, + OffsetOf_GetUniformLocationImmediate_header_not_0); +COMPILE_ASSERT(offsetof(GetUniformLocationImmediate, program) == 4, + OffsetOf_GetUniformLocationImmediate_program_not_4); +COMPILE_ASSERT(offsetof(GetUniformLocationImmediate, data_size) == 8, + OffsetOf_GetUniformLocationImmediate_data_size_not_8); + +struct GetVertexAttribfv { + typedef GetVertexAttribfv ValueType; + static const CommandId kCmdId = kGetVertexAttribfv; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLuint _index, GLenum _pname, uint32 _params_shm_id, + uint32 _params_shm_offset) { + SetHeader(); + index = _index; + pname = _pname; + params_shm_id = _params_shm_id; + params_shm_offset = _params_shm_offset; + } + + void* Set( + void* cmd, GLuint _index, GLenum _pname, uint32 _params_shm_id, + uint32 _params_shm_offset) { + static_cast<ValueType*>( + cmd)->Init(_index, _pname, _params_shm_id, _params_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 index; + uint32 pname; + uint32 params_shm_id; + uint32 params_shm_offset; +}; + +COMPILE_ASSERT(sizeof(GetVertexAttribfv) == 20, + Sizeof_GetVertexAttribfv_is_not_20); +COMPILE_ASSERT(offsetof(GetVertexAttribfv, header) == 0, + OffsetOf_GetVertexAttribfv_header_not_0); +COMPILE_ASSERT(offsetof(GetVertexAttribfv, index) == 4, + OffsetOf_GetVertexAttribfv_index_not_4); +COMPILE_ASSERT(offsetof(GetVertexAttribfv, pname) == 8, + OffsetOf_GetVertexAttribfv_pname_not_8); +COMPILE_ASSERT(offsetof(GetVertexAttribfv, params_shm_id) == 12, + OffsetOf_GetVertexAttribfv_params_shm_id_not_12); +COMPILE_ASSERT(offsetof(GetVertexAttribfv, params_shm_offset) == 16, + OffsetOf_GetVertexAttribfv_params_shm_offset_not_16); + +struct GetVertexAttribiv { + typedef GetVertexAttribiv ValueType; + static const CommandId kCmdId = kGetVertexAttribiv; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLuint _index, GLenum _pname, uint32 _params_shm_id, + uint32 _params_shm_offset) { + SetHeader(); + index = _index; + pname = _pname; + params_shm_id = _params_shm_id; + params_shm_offset = _params_shm_offset; + } + + void* Set( + void* cmd, GLuint _index, GLenum _pname, uint32 _params_shm_id, + uint32 _params_shm_offset) { + static_cast<ValueType*>( + cmd)->Init(_index, _pname, _params_shm_id, _params_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 index; + uint32 pname; + uint32 params_shm_id; + uint32 params_shm_offset; +}; + +COMPILE_ASSERT(sizeof(GetVertexAttribiv) == 20, + Sizeof_GetVertexAttribiv_is_not_20); +COMPILE_ASSERT(offsetof(GetVertexAttribiv, header) == 0, + OffsetOf_GetVertexAttribiv_header_not_0); +COMPILE_ASSERT(offsetof(GetVertexAttribiv, index) == 4, + OffsetOf_GetVertexAttribiv_index_not_4); +COMPILE_ASSERT(offsetof(GetVertexAttribiv, pname) == 8, + OffsetOf_GetVertexAttribiv_pname_not_8); +COMPILE_ASSERT(offsetof(GetVertexAttribiv, params_shm_id) == 12, + OffsetOf_GetVertexAttribiv_params_shm_id_not_12); +COMPILE_ASSERT(offsetof(GetVertexAttribiv, params_shm_offset) == 16, + OffsetOf_GetVertexAttribiv_params_shm_offset_not_16); + +struct GetVertexAttribPointerv { + typedef GetVertexAttribPointerv ValueType; + static const CommandId kCmdId = kGetVertexAttribPointerv; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLuint _index, GLenum _pname, uint32 _pointer_shm_id, + uint32 _pointer_shm_offset) { + SetHeader(); + index = _index; + pname = _pname; + pointer_shm_id = _pointer_shm_id; + pointer_shm_offset = _pointer_shm_offset; + } + + void* Set( + void* cmd, GLuint _index, GLenum _pname, uint32 _pointer_shm_id, + uint32 _pointer_shm_offset) { + static_cast<ValueType*>( + cmd)->Init(_index, _pname, _pointer_shm_id, _pointer_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 index; + uint32 pname; + uint32 pointer_shm_id; + uint32 pointer_shm_offset; +}; + +COMPILE_ASSERT(sizeof(GetVertexAttribPointerv) == 20, + Sizeof_GetVertexAttribPointerv_is_not_20); +COMPILE_ASSERT(offsetof(GetVertexAttribPointerv, header) == 0, + OffsetOf_GetVertexAttribPointerv_header_not_0); +COMPILE_ASSERT(offsetof(GetVertexAttribPointerv, index) == 4, + OffsetOf_GetVertexAttribPointerv_index_not_4); +COMPILE_ASSERT(offsetof(GetVertexAttribPointerv, pname) == 8, + OffsetOf_GetVertexAttribPointerv_pname_not_8); +COMPILE_ASSERT(offsetof(GetVertexAttribPointerv, pointer_shm_id) == 12, + OffsetOf_GetVertexAttribPointerv_pointer_shm_id_not_12); +COMPILE_ASSERT(offsetof(GetVertexAttribPointerv, pointer_shm_offset) == 16, + OffsetOf_GetVertexAttribPointerv_pointer_shm_offset_not_16); + +struct Hint { + typedef Hint ValueType; + static const CommandId kCmdId = kHint; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLenum _target, GLenum _mode) { + SetHeader(); + target = _target; + mode = _mode; + } + + void* Set(void* cmd, GLenum _target, GLenum _mode) { + static_cast<ValueType*>(cmd)->Init(_target, _mode); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 target; + uint32 mode; +}; + +COMPILE_ASSERT(sizeof(Hint) == 12, + Sizeof_Hint_is_not_12); +COMPILE_ASSERT(offsetof(Hint, header) == 0, + OffsetOf_Hint_header_not_0); +COMPILE_ASSERT(offsetof(Hint, target) == 4, + OffsetOf_Hint_target_not_4); +COMPILE_ASSERT(offsetof(Hint, mode) == 8, + OffsetOf_Hint_mode_not_8); + +struct IsBuffer { + typedef IsBuffer ValueType; + static const CommandId kCmdId = kIsBuffer; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLuint _buffer, uint32 _result_shm_id, uint32 _result_shm_offset) { + SetHeader(); + buffer = _buffer; + result_shm_id = _result_shm_id; + result_shm_offset = _result_shm_offset; + } + + void* Set( + void* cmd, GLuint _buffer, uint32 _result_shm_id, + uint32 _result_shm_offset) { + static_cast<ValueType*>( + cmd)->Init(_buffer, _result_shm_id, _result_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 buffer; + uint32 result_shm_id; + uint32 result_shm_offset; +}; + +COMPILE_ASSERT(sizeof(IsBuffer) == 16, + Sizeof_IsBuffer_is_not_16); +COMPILE_ASSERT(offsetof(IsBuffer, header) == 0, + OffsetOf_IsBuffer_header_not_0); +COMPILE_ASSERT(offsetof(IsBuffer, buffer) == 4, + OffsetOf_IsBuffer_buffer_not_4); +COMPILE_ASSERT(offsetof(IsBuffer, result_shm_id) == 8, + OffsetOf_IsBuffer_result_shm_id_not_8); +COMPILE_ASSERT(offsetof(IsBuffer, result_shm_offset) == 12, + OffsetOf_IsBuffer_result_shm_offset_not_12); + +struct IsEnabled { + typedef IsEnabled ValueType; + static const CommandId kCmdId = kIsEnabled; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLenum _cap, uint32 _result_shm_id, uint32 _result_shm_offset) { + SetHeader(); + cap = _cap; + result_shm_id = _result_shm_id; + result_shm_offset = _result_shm_offset; + } + + void* Set( + void* cmd, GLenum _cap, uint32 _result_shm_id, + uint32 _result_shm_offset) { + static_cast<ValueType*>( + cmd)->Init(_cap, _result_shm_id, _result_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 cap; + uint32 result_shm_id; + uint32 result_shm_offset; +}; + +COMPILE_ASSERT(sizeof(IsEnabled) == 16, + Sizeof_IsEnabled_is_not_16); +COMPILE_ASSERT(offsetof(IsEnabled, header) == 0, + OffsetOf_IsEnabled_header_not_0); +COMPILE_ASSERT(offsetof(IsEnabled, cap) == 4, + OffsetOf_IsEnabled_cap_not_4); +COMPILE_ASSERT(offsetof(IsEnabled, result_shm_id) == 8, + OffsetOf_IsEnabled_result_shm_id_not_8); +COMPILE_ASSERT(offsetof(IsEnabled, result_shm_offset) == 12, + OffsetOf_IsEnabled_result_shm_offset_not_12); + +struct IsFramebuffer { + typedef IsFramebuffer ValueType; + static const CommandId kCmdId = kIsFramebuffer; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLuint _framebuffer, uint32 _result_shm_id, uint32 _result_shm_offset) { + SetHeader(); + framebuffer = _framebuffer; + result_shm_id = _result_shm_id; + result_shm_offset = _result_shm_offset; + } + + void* Set( + void* cmd, GLuint _framebuffer, uint32 _result_shm_id, + uint32 _result_shm_offset) { + static_cast<ValueType*>( + cmd)->Init(_framebuffer, _result_shm_id, _result_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 framebuffer; + uint32 result_shm_id; + uint32 result_shm_offset; +}; + +COMPILE_ASSERT(sizeof(IsFramebuffer) == 16, + Sizeof_IsFramebuffer_is_not_16); +COMPILE_ASSERT(offsetof(IsFramebuffer, header) == 0, + OffsetOf_IsFramebuffer_header_not_0); +COMPILE_ASSERT(offsetof(IsFramebuffer, framebuffer) == 4, + OffsetOf_IsFramebuffer_framebuffer_not_4); +COMPILE_ASSERT(offsetof(IsFramebuffer, result_shm_id) == 8, + OffsetOf_IsFramebuffer_result_shm_id_not_8); +COMPILE_ASSERT(offsetof(IsFramebuffer, result_shm_offset) == 12, + OffsetOf_IsFramebuffer_result_shm_offset_not_12); + +struct IsProgram { + typedef IsProgram ValueType; + static const CommandId kCmdId = kIsProgram; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLuint _program, uint32 _result_shm_id, uint32 _result_shm_offset) { + SetHeader(); + program = _program; + result_shm_id = _result_shm_id; + result_shm_offset = _result_shm_offset; + } + + void* Set( + void* cmd, GLuint _program, uint32 _result_shm_id, + uint32 _result_shm_offset) { + static_cast<ValueType*>( + cmd)->Init(_program, _result_shm_id, _result_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 program; + uint32 result_shm_id; + uint32 result_shm_offset; +}; + +COMPILE_ASSERT(sizeof(IsProgram) == 16, + Sizeof_IsProgram_is_not_16); +COMPILE_ASSERT(offsetof(IsProgram, header) == 0, + OffsetOf_IsProgram_header_not_0); +COMPILE_ASSERT(offsetof(IsProgram, program) == 4, + OffsetOf_IsProgram_program_not_4); +COMPILE_ASSERT(offsetof(IsProgram, result_shm_id) == 8, + OffsetOf_IsProgram_result_shm_id_not_8); +COMPILE_ASSERT(offsetof(IsProgram, result_shm_offset) == 12, + OffsetOf_IsProgram_result_shm_offset_not_12); + +struct IsRenderbuffer { + typedef IsRenderbuffer ValueType; + static const CommandId kCmdId = kIsRenderbuffer; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLuint _renderbuffer, uint32 _result_shm_id, uint32 _result_shm_offset) { + SetHeader(); + renderbuffer = _renderbuffer; + result_shm_id = _result_shm_id; + result_shm_offset = _result_shm_offset; + } + + void* Set( + void* cmd, GLuint _renderbuffer, uint32 _result_shm_id, + uint32 _result_shm_offset) { + static_cast<ValueType*>( + cmd)->Init(_renderbuffer, _result_shm_id, _result_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 renderbuffer; + uint32 result_shm_id; + uint32 result_shm_offset; +}; + +COMPILE_ASSERT(sizeof(IsRenderbuffer) == 16, + Sizeof_IsRenderbuffer_is_not_16); +COMPILE_ASSERT(offsetof(IsRenderbuffer, header) == 0, + OffsetOf_IsRenderbuffer_header_not_0); +COMPILE_ASSERT(offsetof(IsRenderbuffer, renderbuffer) == 4, + OffsetOf_IsRenderbuffer_renderbuffer_not_4); +COMPILE_ASSERT(offsetof(IsRenderbuffer, result_shm_id) == 8, + OffsetOf_IsRenderbuffer_result_shm_id_not_8); +COMPILE_ASSERT(offsetof(IsRenderbuffer, result_shm_offset) == 12, + OffsetOf_IsRenderbuffer_result_shm_offset_not_12); + +struct IsShader { + typedef IsShader ValueType; + static const CommandId kCmdId = kIsShader; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLuint _shader, uint32 _result_shm_id, uint32 _result_shm_offset) { + SetHeader(); + shader = _shader; + result_shm_id = _result_shm_id; + result_shm_offset = _result_shm_offset; + } + + void* Set( + void* cmd, GLuint _shader, uint32 _result_shm_id, + uint32 _result_shm_offset) { + static_cast<ValueType*>( + cmd)->Init(_shader, _result_shm_id, _result_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 shader; + uint32 result_shm_id; + uint32 result_shm_offset; +}; + +COMPILE_ASSERT(sizeof(IsShader) == 16, + Sizeof_IsShader_is_not_16); +COMPILE_ASSERT(offsetof(IsShader, header) == 0, + OffsetOf_IsShader_header_not_0); +COMPILE_ASSERT(offsetof(IsShader, shader) == 4, + OffsetOf_IsShader_shader_not_4); +COMPILE_ASSERT(offsetof(IsShader, result_shm_id) == 8, + OffsetOf_IsShader_result_shm_id_not_8); +COMPILE_ASSERT(offsetof(IsShader, result_shm_offset) == 12, + OffsetOf_IsShader_result_shm_offset_not_12); + +struct IsTexture { + typedef IsTexture ValueType; + static const CommandId kCmdId = kIsTexture; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLuint _texture, uint32 _result_shm_id, uint32 _result_shm_offset) { + SetHeader(); + texture = _texture; + result_shm_id = _result_shm_id; + result_shm_offset = _result_shm_offset; + } + + void* Set( + void* cmd, GLuint _texture, uint32 _result_shm_id, + uint32 _result_shm_offset) { + static_cast<ValueType*>( + cmd)->Init(_texture, _result_shm_id, _result_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 texture; + uint32 result_shm_id; + uint32 result_shm_offset; +}; + +COMPILE_ASSERT(sizeof(IsTexture) == 16, + Sizeof_IsTexture_is_not_16); +COMPILE_ASSERT(offsetof(IsTexture, header) == 0, + OffsetOf_IsTexture_header_not_0); +COMPILE_ASSERT(offsetof(IsTexture, texture) == 4, + OffsetOf_IsTexture_texture_not_4); +COMPILE_ASSERT(offsetof(IsTexture, result_shm_id) == 8, + OffsetOf_IsTexture_result_shm_id_not_8); +COMPILE_ASSERT(offsetof(IsTexture, result_shm_offset) == 12, + OffsetOf_IsTexture_result_shm_offset_not_12); + +struct LineWidth { + typedef LineWidth ValueType; + static const CommandId kCmdId = kLineWidth; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLfloat _width) { + SetHeader(); + width = _width; + } + + void* Set(void* cmd, GLfloat _width) { + static_cast<ValueType*>(cmd)->Init(_width); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + float width; +}; + +COMPILE_ASSERT(sizeof(LineWidth) == 8, + Sizeof_LineWidth_is_not_8); +COMPILE_ASSERT(offsetof(LineWidth, header) == 0, + OffsetOf_LineWidth_header_not_0); +COMPILE_ASSERT(offsetof(LineWidth, width) == 4, + OffsetOf_LineWidth_width_not_4); + +struct LinkProgram { + typedef LinkProgram ValueType; + static const CommandId kCmdId = kLinkProgram; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLuint _program) { + SetHeader(); + program = _program; + } + + void* Set(void* cmd, GLuint _program) { + static_cast<ValueType*>(cmd)->Init(_program); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 program; +}; + +COMPILE_ASSERT(sizeof(LinkProgram) == 8, + Sizeof_LinkProgram_is_not_8); +COMPILE_ASSERT(offsetof(LinkProgram, header) == 0, + OffsetOf_LinkProgram_header_not_0); +COMPILE_ASSERT(offsetof(LinkProgram, program) == 4, + OffsetOf_LinkProgram_program_not_4); + +struct PixelStorei { + typedef PixelStorei ValueType; + static const CommandId kCmdId = kPixelStorei; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLenum _pname, GLint _param) { + SetHeader(); + pname = _pname; + param = _param; + } + + void* Set(void* cmd, GLenum _pname, GLint _param) { + static_cast<ValueType*>(cmd)->Init(_pname, _param); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 pname; + uint32 param; +}; + +COMPILE_ASSERT(sizeof(PixelStorei) == 12, + Sizeof_PixelStorei_is_not_12); +COMPILE_ASSERT(offsetof(PixelStorei, header) == 0, + OffsetOf_PixelStorei_header_not_0); +COMPILE_ASSERT(offsetof(PixelStorei, pname) == 4, + OffsetOf_PixelStorei_pname_not_4); +COMPILE_ASSERT(offsetof(PixelStorei, param) == 8, + OffsetOf_PixelStorei_param_not_8); + +struct PolygonOffset { + typedef PolygonOffset ValueType; + static const CommandId kCmdId = kPolygonOffset; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLfloat _factor, GLfloat _units) { + SetHeader(); + factor = _factor; + units = _units; + } + + void* Set(void* cmd, GLfloat _factor, GLfloat _units) { + static_cast<ValueType*>(cmd)->Init(_factor, _units); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + float factor; + float units; +}; + +COMPILE_ASSERT(sizeof(PolygonOffset) == 12, + Sizeof_PolygonOffset_is_not_12); +COMPILE_ASSERT(offsetof(PolygonOffset, header) == 0, + OffsetOf_PolygonOffset_header_not_0); +COMPILE_ASSERT(offsetof(PolygonOffset, factor) == 4, + OffsetOf_PolygonOffset_factor_not_4); +COMPILE_ASSERT(offsetof(PolygonOffset, units) == 8, + OffsetOf_PolygonOffset_units_not_8); + +struct ReadPixels { + typedef ReadPixels ValueType; + static const CommandId kCmdId = kReadPixels; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLint _x, GLint _y, GLsizei _width, GLsizei _height, GLenum _format, + GLenum _type, uint32 _pixels_shm_id, uint32 _pixels_shm_offset) { + SetHeader(); + x = _x; + y = _y; + width = _width; + height = _height; + format = _format; + type = _type; + pixels_shm_id = _pixels_shm_id; + pixels_shm_offset = _pixels_shm_offset; + } + + void* Set( + void* cmd, GLint _x, GLint _y, GLsizei _width, GLsizei _height, + GLenum _format, GLenum _type, uint32 _pixels_shm_id, + uint32 _pixels_shm_offset) { + static_cast<ValueType*>( + cmd)->Init( + _x, _y, _width, _height, _format, _type, _pixels_shm_id, + _pixels_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 x; + uint32 y; + uint32 width; + uint32 height; + uint32 format; + uint32 type; + uint32 pixels_shm_id; + uint32 pixels_shm_offset; +}; + +COMPILE_ASSERT(sizeof(ReadPixels) == 36, + Sizeof_ReadPixels_is_not_36); +COMPILE_ASSERT(offsetof(ReadPixels, header) == 0, + OffsetOf_ReadPixels_header_not_0); +COMPILE_ASSERT(offsetof(ReadPixels, x) == 4, + OffsetOf_ReadPixels_x_not_4); +COMPILE_ASSERT(offsetof(ReadPixels, y) == 8, + OffsetOf_ReadPixels_y_not_8); +COMPILE_ASSERT(offsetof(ReadPixels, width) == 12, + OffsetOf_ReadPixels_width_not_12); +COMPILE_ASSERT(offsetof(ReadPixels, height) == 16, + OffsetOf_ReadPixels_height_not_16); +COMPILE_ASSERT(offsetof(ReadPixels, format) == 20, + OffsetOf_ReadPixels_format_not_20); +COMPILE_ASSERT(offsetof(ReadPixels, type) == 24, + OffsetOf_ReadPixels_type_not_24); +COMPILE_ASSERT(offsetof(ReadPixels, pixels_shm_id) == 28, + OffsetOf_ReadPixels_pixels_shm_id_not_28); +COMPILE_ASSERT(offsetof(ReadPixels, pixels_shm_offset) == 32, + OffsetOf_ReadPixels_pixels_shm_offset_not_32); + +struct RenderbufferStorage { + typedef RenderbufferStorage ValueType; + static const CommandId kCmdId = kRenderbufferStorage; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLenum _target, GLenum _internalformat, GLsizei _width, + GLsizei _height) { + SetHeader(); + target = _target; + internalformat = _internalformat; + width = _width; + height = _height; + } + + void* Set( + void* cmd, GLenum _target, GLenum _internalformat, GLsizei _width, + GLsizei _height) { + static_cast<ValueType*>( + cmd)->Init(_target, _internalformat, _width, _height); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 target; + uint32 internalformat; + uint32 width; + uint32 height; +}; + +COMPILE_ASSERT(sizeof(RenderbufferStorage) == 20, + Sizeof_RenderbufferStorage_is_not_20); +COMPILE_ASSERT(offsetof(RenderbufferStorage, header) == 0, + OffsetOf_RenderbufferStorage_header_not_0); +COMPILE_ASSERT(offsetof(RenderbufferStorage, target) == 4, + OffsetOf_RenderbufferStorage_target_not_4); +COMPILE_ASSERT(offsetof(RenderbufferStorage, internalformat) == 8, + OffsetOf_RenderbufferStorage_internalformat_not_8); +COMPILE_ASSERT(offsetof(RenderbufferStorage, width) == 12, + OffsetOf_RenderbufferStorage_width_not_12); +COMPILE_ASSERT(offsetof(RenderbufferStorage, height) == 16, + OffsetOf_RenderbufferStorage_height_not_16); + +struct SampleCoverage { + typedef SampleCoverage ValueType; + static const CommandId kCmdId = kSampleCoverage; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLclampf _value, GLboolean _invert) { + SetHeader(); + value = _value; + invert = _invert; + } + + void* Set(void* cmd, GLclampf _value, GLboolean _invert) { + static_cast<ValueType*>(cmd)->Init(_value, _invert); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + float value; + uint32 invert; +}; + +COMPILE_ASSERT(sizeof(SampleCoverage) == 12, + Sizeof_SampleCoverage_is_not_12); +COMPILE_ASSERT(offsetof(SampleCoverage, header) == 0, + OffsetOf_SampleCoverage_header_not_0); +COMPILE_ASSERT(offsetof(SampleCoverage, value) == 4, + OffsetOf_SampleCoverage_value_not_4); +COMPILE_ASSERT(offsetof(SampleCoverage, invert) == 8, + OffsetOf_SampleCoverage_invert_not_8); + +struct Scissor { + typedef Scissor ValueType; + static const CommandId kCmdId = kScissor; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLint _x, GLint _y, GLsizei _width, GLsizei _height) { + SetHeader(); + x = _x; + y = _y; + width = _width; + height = _height; + } + + void* Set(void* cmd, GLint _x, GLint _y, GLsizei _width, GLsizei _height) { + static_cast<ValueType*>(cmd)->Init(_x, _y, _width, _height); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 x; + uint32 y; + uint32 width; + uint32 height; +}; + +COMPILE_ASSERT(sizeof(Scissor) == 20, + Sizeof_Scissor_is_not_20); +COMPILE_ASSERT(offsetof(Scissor, header) == 0, + OffsetOf_Scissor_header_not_0); +COMPILE_ASSERT(offsetof(Scissor, x) == 4, + OffsetOf_Scissor_x_not_4); +COMPILE_ASSERT(offsetof(Scissor, y) == 8, + OffsetOf_Scissor_y_not_8); +COMPILE_ASSERT(offsetof(Scissor, width) == 12, + OffsetOf_Scissor_width_not_12); +COMPILE_ASSERT(offsetof(Scissor, height) == 16, + OffsetOf_Scissor_height_not_16); + +struct ShaderSource { + typedef ShaderSource ValueType; + static const CommandId kCmdId = kShaderSource; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLuint _shader, GLsizei _count, uint32 _data_shm_id, + uint32 _data_shm_offset, uint32 _data_size) { + SetHeader(); + shader = _shader; + count = _count; + data_shm_id = _data_shm_id; + data_shm_offset = _data_shm_offset; + data_size = _data_size; + } + + void* Set( + void* cmd, GLuint _shader, GLsizei _count, uint32 _data_shm_id, + uint32 _data_shm_offset, uint32 _data_size) { + static_cast<ValueType*>( + cmd)->Init( + _shader, _count, _data_shm_id, _data_shm_offset, _data_size); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 shader; + uint32 count; + uint32 data_shm_id; + uint32 data_shm_offset; + uint32 data_size; +}; + +COMPILE_ASSERT(sizeof(ShaderSource) == 24, + Sizeof_ShaderSource_is_not_24); +COMPILE_ASSERT(offsetof(ShaderSource, header) == 0, + OffsetOf_ShaderSource_header_not_0); +COMPILE_ASSERT(offsetof(ShaderSource, shader) == 4, + OffsetOf_ShaderSource_shader_not_4); +COMPILE_ASSERT(offsetof(ShaderSource, count) == 8, + OffsetOf_ShaderSource_count_not_8); +COMPILE_ASSERT(offsetof(ShaderSource, data_shm_id) == 12, + OffsetOf_ShaderSource_data_shm_id_not_12); +COMPILE_ASSERT(offsetof(ShaderSource, data_shm_offset) == 16, + OffsetOf_ShaderSource_data_shm_offset_not_16); +COMPILE_ASSERT(offsetof(ShaderSource, data_size) == 20, + OffsetOf_ShaderSource_data_size_not_20); + +struct ShaderSourceImmediate { + typedef ShaderSourceImmediate ValueType; + static const CommandId kCmdId = kShaderSourceImmediate; + static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN; + + static uint32 ComputeSize(uint32 size_in_bytes) { + return static_cast<uint32>( + sizeof(ValueType) + // NOLINT + RoundSizeToMultipleOfEntries(size_in_bytes)); + } + + void SetHeader(uint32 size_in_bytes) { + header.SetCmdByTotalSize<ValueType>(size_in_bytes); + } + + void Init(GLuint _shader, GLsizei _count, uint32 _data_size) { + uint32 total_size = ComputeSize(_data_size); + SetHeader(total_size); + shader = _shader; + count = _count; + data_size = _data_size; + } + + void* Set(void* cmd, GLuint _shader, GLsizei _count, uint32 _data_size) { + uint32 total_size = ComputeSize(_data_size); + static_cast<ValueType*>(cmd)->Init(_shader, _count, _data_size); + return NextImmediateCmdAddressTotalSize<ValueType>(cmd, total_size); + } + + command_buffer::CommandHeader header; + uint32 shader; + uint32 count; + uint32 data_size; +}; + +COMPILE_ASSERT(sizeof(ShaderSourceImmediate) == 16, + Sizeof_ShaderSourceImmediate_is_not_16); +COMPILE_ASSERT(offsetof(ShaderSourceImmediate, header) == 0, + OffsetOf_ShaderSourceImmediate_header_not_0); +COMPILE_ASSERT(offsetof(ShaderSourceImmediate, shader) == 4, + OffsetOf_ShaderSourceImmediate_shader_not_4); +COMPILE_ASSERT(offsetof(ShaderSourceImmediate, count) == 8, + OffsetOf_ShaderSourceImmediate_count_not_8); +COMPILE_ASSERT(offsetof(ShaderSourceImmediate, data_size) == 12, + OffsetOf_ShaderSourceImmediate_data_size_not_12); + +struct StencilFunc { + typedef StencilFunc ValueType; + static const CommandId kCmdId = kStencilFunc; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLenum _func, GLint _ref, GLuint _mask) { + SetHeader(); + func = _func; + ref = _ref; + mask = _mask; + } + + void* Set(void* cmd, GLenum _func, GLint _ref, GLuint _mask) { + static_cast<ValueType*>(cmd)->Init(_func, _ref, _mask); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 func; + uint32 ref; + uint32 mask; +}; + +COMPILE_ASSERT(sizeof(StencilFunc) == 16, + Sizeof_StencilFunc_is_not_16); +COMPILE_ASSERT(offsetof(StencilFunc, header) == 0, + OffsetOf_StencilFunc_header_not_0); +COMPILE_ASSERT(offsetof(StencilFunc, func) == 4, + OffsetOf_StencilFunc_func_not_4); +COMPILE_ASSERT(offsetof(StencilFunc, ref) == 8, + OffsetOf_StencilFunc_ref_not_8); +COMPILE_ASSERT(offsetof(StencilFunc, mask) == 12, + OffsetOf_StencilFunc_mask_not_12); + +struct StencilFuncSeparate { + typedef StencilFuncSeparate ValueType; + static const CommandId kCmdId = kStencilFuncSeparate; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLenum _face, GLenum _func, GLint _ref, GLuint _mask) { + SetHeader(); + face = _face; + func = _func; + ref = _ref; + mask = _mask; + } + + void* Set(void* cmd, GLenum _face, GLenum _func, GLint _ref, GLuint _mask) { + static_cast<ValueType*>(cmd)->Init(_face, _func, _ref, _mask); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 face; + uint32 func; + uint32 ref; + uint32 mask; +}; + +COMPILE_ASSERT(sizeof(StencilFuncSeparate) == 20, + Sizeof_StencilFuncSeparate_is_not_20); +COMPILE_ASSERT(offsetof(StencilFuncSeparate, header) == 0, + OffsetOf_StencilFuncSeparate_header_not_0); +COMPILE_ASSERT(offsetof(StencilFuncSeparate, face) == 4, + OffsetOf_StencilFuncSeparate_face_not_4); +COMPILE_ASSERT(offsetof(StencilFuncSeparate, func) == 8, + OffsetOf_StencilFuncSeparate_func_not_8); +COMPILE_ASSERT(offsetof(StencilFuncSeparate, ref) == 12, + OffsetOf_StencilFuncSeparate_ref_not_12); +COMPILE_ASSERT(offsetof(StencilFuncSeparate, mask) == 16, + OffsetOf_StencilFuncSeparate_mask_not_16); + +struct StencilMask { + typedef StencilMask ValueType; + static const CommandId kCmdId = kStencilMask; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLuint _mask) { + SetHeader(); + mask = _mask; + } + + void* Set(void* cmd, GLuint _mask) { + static_cast<ValueType*>(cmd)->Init(_mask); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 mask; +}; + +COMPILE_ASSERT(sizeof(StencilMask) == 8, + Sizeof_StencilMask_is_not_8); +COMPILE_ASSERT(offsetof(StencilMask, header) == 0, + OffsetOf_StencilMask_header_not_0); +COMPILE_ASSERT(offsetof(StencilMask, mask) == 4, + OffsetOf_StencilMask_mask_not_4); + +struct StencilMaskSeparate { + typedef StencilMaskSeparate ValueType; + static const CommandId kCmdId = kStencilMaskSeparate; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLenum _face, GLuint _mask) { + SetHeader(); + face = _face; + mask = _mask; + } + + void* Set(void* cmd, GLenum _face, GLuint _mask) { + static_cast<ValueType*>(cmd)->Init(_face, _mask); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 face; + uint32 mask; +}; + +COMPILE_ASSERT(sizeof(StencilMaskSeparate) == 12, + Sizeof_StencilMaskSeparate_is_not_12); +COMPILE_ASSERT(offsetof(StencilMaskSeparate, header) == 0, + OffsetOf_StencilMaskSeparate_header_not_0); +COMPILE_ASSERT(offsetof(StencilMaskSeparate, face) == 4, + OffsetOf_StencilMaskSeparate_face_not_4); +COMPILE_ASSERT(offsetof(StencilMaskSeparate, mask) == 8, + OffsetOf_StencilMaskSeparate_mask_not_8); + +struct StencilOp { + typedef StencilOp ValueType; + static const CommandId kCmdId = kStencilOp; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLenum _fail, GLenum _zfail, GLenum _zpass) { + SetHeader(); + fail = _fail; + zfail = _zfail; + zpass = _zpass; + } + + void* Set(void* cmd, GLenum _fail, GLenum _zfail, GLenum _zpass) { + static_cast<ValueType*>(cmd)->Init(_fail, _zfail, _zpass); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 fail; + uint32 zfail; + uint32 zpass; +}; + +COMPILE_ASSERT(sizeof(StencilOp) == 16, + Sizeof_StencilOp_is_not_16); +COMPILE_ASSERT(offsetof(StencilOp, header) == 0, + OffsetOf_StencilOp_header_not_0); +COMPILE_ASSERT(offsetof(StencilOp, fail) == 4, + OffsetOf_StencilOp_fail_not_4); +COMPILE_ASSERT(offsetof(StencilOp, zfail) == 8, + OffsetOf_StencilOp_zfail_not_8); +COMPILE_ASSERT(offsetof(StencilOp, zpass) == 12, + OffsetOf_StencilOp_zpass_not_12); + +struct StencilOpSeparate { + typedef StencilOpSeparate ValueType; + static const CommandId kCmdId = kStencilOpSeparate; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLenum _face, GLenum _fail, GLenum _zfail, GLenum _zpass) { + SetHeader(); + face = _face; + fail = _fail; + zfail = _zfail; + zpass = _zpass; + } + + void* Set( + void* cmd, GLenum _face, GLenum _fail, GLenum _zfail, GLenum _zpass) { + static_cast<ValueType*>(cmd)->Init(_face, _fail, _zfail, _zpass); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 face; + uint32 fail; + uint32 zfail; + uint32 zpass; +}; + +COMPILE_ASSERT(sizeof(StencilOpSeparate) == 20, + Sizeof_StencilOpSeparate_is_not_20); +COMPILE_ASSERT(offsetof(StencilOpSeparate, header) == 0, + OffsetOf_StencilOpSeparate_header_not_0); +COMPILE_ASSERT(offsetof(StencilOpSeparate, face) == 4, + OffsetOf_StencilOpSeparate_face_not_4); +COMPILE_ASSERT(offsetof(StencilOpSeparate, fail) == 8, + OffsetOf_StencilOpSeparate_fail_not_8); +COMPILE_ASSERT(offsetof(StencilOpSeparate, zfail) == 12, + OffsetOf_StencilOpSeparate_zfail_not_12); +COMPILE_ASSERT(offsetof(StencilOpSeparate, zpass) == 16, + OffsetOf_StencilOpSeparate_zpass_not_16); + +struct TexImage2D { + typedef TexImage2D ValueType; + static const CommandId kCmdId = kTexImage2D; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLenum _target, GLint _level, GLint _internalformat, GLsizei _width, + GLsizei _height, GLint _border, GLenum _format, GLenum _type, + uint32 _pixels_shm_id, uint32 _pixels_shm_offset) { + SetHeader(); + target = _target; + level = _level; + internalformat = _internalformat; + width = _width; + height = _height; + border = _border; + format = _format; + type = _type; + pixels_shm_id = _pixels_shm_id; + pixels_shm_offset = _pixels_shm_offset; + } + + void* Set( + void* cmd, GLenum _target, GLint _level, GLint _internalformat, + GLsizei _width, GLsizei _height, GLint _border, GLenum _format, + GLenum _type, uint32 _pixels_shm_id, uint32 _pixels_shm_offset) { + static_cast<ValueType*>( + cmd)->Init( + _target, _level, _internalformat, _width, _height, _border, _format, + _type, _pixels_shm_id, _pixels_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 target; + uint32 level; + uint32 internalformat; + uint32 width; + uint32 height; + uint32 border; + uint32 format; + uint32 type; + uint32 pixels_shm_id; + uint32 pixels_shm_offset; +}; + +COMPILE_ASSERT(sizeof(TexImage2D) == 44, + Sizeof_TexImage2D_is_not_44); +COMPILE_ASSERT(offsetof(TexImage2D, header) == 0, + OffsetOf_TexImage2D_header_not_0); +COMPILE_ASSERT(offsetof(TexImage2D, target) == 4, + OffsetOf_TexImage2D_target_not_4); +COMPILE_ASSERT(offsetof(TexImage2D, level) == 8, + OffsetOf_TexImage2D_level_not_8); +COMPILE_ASSERT(offsetof(TexImage2D, internalformat) == 12, + OffsetOf_TexImage2D_internalformat_not_12); +COMPILE_ASSERT(offsetof(TexImage2D, width) == 16, + OffsetOf_TexImage2D_width_not_16); +COMPILE_ASSERT(offsetof(TexImage2D, height) == 20, + OffsetOf_TexImage2D_height_not_20); +COMPILE_ASSERT(offsetof(TexImage2D, border) == 24, + OffsetOf_TexImage2D_border_not_24); +COMPILE_ASSERT(offsetof(TexImage2D, format) == 28, + OffsetOf_TexImage2D_format_not_28); +COMPILE_ASSERT(offsetof(TexImage2D, type) == 32, + OffsetOf_TexImage2D_type_not_32); +COMPILE_ASSERT(offsetof(TexImage2D, pixels_shm_id) == 36, + OffsetOf_TexImage2D_pixels_shm_id_not_36); +COMPILE_ASSERT(offsetof(TexImage2D, pixels_shm_offset) == 40, + OffsetOf_TexImage2D_pixels_shm_offset_not_40); + +struct TexImage2DImmediate { + typedef TexImage2DImmediate ValueType; + static const CommandId kCmdId = kTexImage2DImmediate; + static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN; + + static uint32 ComputeSize(uint32 size_in_bytes) { + return static_cast<uint32>( + sizeof(ValueType) + // NOLINT + RoundSizeToMultipleOfEntries(size_in_bytes)); + } + + void SetHeader(uint32 size_in_bytes) { + header.SetCmdByTotalSize<ValueType>(size_in_bytes); + } + + void Init( + GLenum _target, GLint _level, GLint _internalformat, GLsizei _width, + GLsizei _height, GLint _border, GLenum _format, GLenum _type) { + uint32 total_size = 0; // TODO(gman): get correct size + SetHeader(total_size); + target = _target; + level = _level; + internalformat = _internalformat; + width = _width; + height = _height; + border = _border; + format = _format; + type = _type; + } + + void* Set( + void* cmd, GLenum _target, GLint _level, GLint _internalformat, + GLsizei _width, GLsizei _height, GLint _border, GLenum _format, + GLenum _type) { + uint32 total_size = 0; // TODO(gman): get correct size + static_cast<ValueType*>( + cmd)->Init( + _target, _level, _internalformat, _width, _height, _border, _format, + _type); + return NextImmediateCmdAddressTotalSize<ValueType>(cmd, total_size); + } + + command_buffer::CommandHeader header; + uint32 target; + uint32 level; + uint32 internalformat; + uint32 width; + uint32 height; + uint32 border; + uint32 format; + uint32 type; +}; + +COMPILE_ASSERT(sizeof(TexImage2DImmediate) == 36, + Sizeof_TexImage2DImmediate_is_not_36); +COMPILE_ASSERT(offsetof(TexImage2DImmediate, header) == 0, + OffsetOf_TexImage2DImmediate_header_not_0); +COMPILE_ASSERT(offsetof(TexImage2DImmediate, target) == 4, + OffsetOf_TexImage2DImmediate_target_not_4); +COMPILE_ASSERT(offsetof(TexImage2DImmediate, level) == 8, + OffsetOf_TexImage2DImmediate_level_not_8); +COMPILE_ASSERT(offsetof(TexImage2DImmediate, internalformat) == 12, + OffsetOf_TexImage2DImmediate_internalformat_not_12); +COMPILE_ASSERT(offsetof(TexImage2DImmediate, width) == 16, + OffsetOf_TexImage2DImmediate_width_not_16); +COMPILE_ASSERT(offsetof(TexImage2DImmediate, height) == 20, + OffsetOf_TexImage2DImmediate_height_not_20); +COMPILE_ASSERT(offsetof(TexImage2DImmediate, border) == 24, + OffsetOf_TexImage2DImmediate_border_not_24); +COMPILE_ASSERT(offsetof(TexImage2DImmediate, format) == 28, + OffsetOf_TexImage2DImmediate_format_not_28); +COMPILE_ASSERT(offsetof(TexImage2DImmediate, type) == 32, + OffsetOf_TexImage2DImmediate_type_not_32); + +struct TexParameterf { + typedef TexParameterf ValueType; + static const CommandId kCmdId = kTexParameterf; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLenum _target, GLenum _pname, GLfloat _param) { + SetHeader(); + target = _target; + pname = _pname; + param = _param; + } + + void* Set(void* cmd, GLenum _target, GLenum _pname, GLfloat _param) { + static_cast<ValueType*>(cmd)->Init(_target, _pname, _param); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 target; + uint32 pname; + float param; +}; + +COMPILE_ASSERT(sizeof(TexParameterf) == 16, + Sizeof_TexParameterf_is_not_16); +COMPILE_ASSERT(offsetof(TexParameterf, header) == 0, + OffsetOf_TexParameterf_header_not_0); +COMPILE_ASSERT(offsetof(TexParameterf, target) == 4, + OffsetOf_TexParameterf_target_not_4); +COMPILE_ASSERT(offsetof(TexParameterf, pname) == 8, + OffsetOf_TexParameterf_pname_not_8); +COMPILE_ASSERT(offsetof(TexParameterf, param) == 12, + OffsetOf_TexParameterf_param_not_12); + +struct TexParameterfv { + typedef TexParameterfv ValueType; + static const CommandId kCmdId = kTexParameterfv; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLenum _target, GLenum _pname, uint32 _params_shm_id, + uint32 _params_shm_offset) { + SetHeader(); + target = _target; + pname = _pname; + params_shm_id = _params_shm_id; + params_shm_offset = _params_shm_offset; + } + + void* Set( + void* cmd, GLenum _target, GLenum _pname, uint32 _params_shm_id, + uint32 _params_shm_offset) { + static_cast<ValueType*>( + cmd)->Init(_target, _pname, _params_shm_id, _params_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 target; + uint32 pname; + uint32 params_shm_id; + uint32 params_shm_offset; +}; + +COMPILE_ASSERT(sizeof(TexParameterfv) == 20, + Sizeof_TexParameterfv_is_not_20); +COMPILE_ASSERT(offsetof(TexParameterfv, header) == 0, + OffsetOf_TexParameterfv_header_not_0); +COMPILE_ASSERT(offsetof(TexParameterfv, target) == 4, + OffsetOf_TexParameterfv_target_not_4); +COMPILE_ASSERT(offsetof(TexParameterfv, pname) == 8, + OffsetOf_TexParameterfv_pname_not_8); +COMPILE_ASSERT(offsetof(TexParameterfv, params_shm_id) == 12, + OffsetOf_TexParameterfv_params_shm_id_not_12); +COMPILE_ASSERT(offsetof(TexParameterfv, params_shm_offset) == 16, + OffsetOf_TexParameterfv_params_shm_offset_not_16); + +struct TexParameterfvImmediate { + typedef TexParameterfvImmediate ValueType; + static const CommandId kCmdId = kTexParameterfvImmediate; + static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN; + + static uint32 ComputeDataSize() { + return static_cast<uint32>( + sizeof(GLfloat) * 1); // NOLINT + } + + static uint32 ComputeSize() { + return static_cast<uint32>( + sizeof(ValueType) + ComputeDataSize()); // NOLINT + } + + void SetHeader() { + header.SetCmdByTotalSize<ValueType>(ComputeSize()); + } + + void Init(GLenum _target, GLenum _pname, const GLfloat* _params) { + SetHeader(); + target = _target; + pname = _pname; + memcpy(ImmediateDataAddress(this), + _params, ComputeDataSize()); + } + + void* Set(void* cmd, GLenum _target, GLenum _pname, const GLfloat* _params) { + static_cast<ValueType*>(cmd)->Init(_target, _pname, _params); + const uint32 size = ComputeSize(); + return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); + } + + command_buffer::CommandHeader header; + uint32 target; + uint32 pname; +}; + +COMPILE_ASSERT(sizeof(TexParameterfvImmediate) == 12, + Sizeof_TexParameterfvImmediate_is_not_12); +COMPILE_ASSERT(offsetof(TexParameterfvImmediate, header) == 0, + OffsetOf_TexParameterfvImmediate_header_not_0); +COMPILE_ASSERT(offsetof(TexParameterfvImmediate, target) == 4, + OffsetOf_TexParameterfvImmediate_target_not_4); +COMPILE_ASSERT(offsetof(TexParameterfvImmediate, pname) == 8, + OffsetOf_TexParameterfvImmediate_pname_not_8); + +struct TexParameteri { + typedef TexParameteri ValueType; + static const CommandId kCmdId = kTexParameteri; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLenum _target, GLenum _pname, GLint _param) { + SetHeader(); + target = _target; + pname = _pname; + param = _param; + } + + void* Set(void* cmd, GLenum _target, GLenum _pname, GLint _param) { + static_cast<ValueType*>(cmd)->Init(_target, _pname, _param); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 target; + uint32 pname; + uint32 param; +}; + +COMPILE_ASSERT(sizeof(TexParameteri) == 16, + Sizeof_TexParameteri_is_not_16); +COMPILE_ASSERT(offsetof(TexParameteri, header) == 0, + OffsetOf_TexParameteri_header_not_0); +COMPILE_ASSERT(offsetof(TexParameteri, target) == 4, + OffsetOf_TexParameteri_target_not_4); +COMPILE_ASSERT(offsetof(TexParameteri, pname) == 8, + OffsetOf_TexParameteri_pname_not_8); +COMPILE_ASSERT(offsetof(TexParameteri, param) == 12, + OffsetOf_TexParameteri_param_not_12); + +struct TexParameteriv { + typedef TexParameteriv ValueType; + static const CommandId kCmdId = kTexParameteriv; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLenum _target, GLenum _pname, uint32 _params_shm_id, + uint32 _params_shm_offset) { + SetHeader(); + target = _target; + pname = _pname; + params_shm_id = _params_shm_id; + params_shm_offset = _params_shm_offset; + } + + void* Set( + void* cmd, GLenum _target, GLenum _pname, uint32 _params_shm_id, + uint32 _params_shm_offset) { + static_cast<ValueType*>( + cmd)->Init(_target, _pname, _params_shm_id, _params_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 target; + uint32 pname; + uint32 params_shm_id; + uint32 params_shm_offset; +}; + +COMPILE_ASSERT(sizeof(TexParameteriv) == 20, + Sizeof_TexParameteriv_is_not_20); +COMPILE_ASSERT(offsetof(TexParameteriv, header) == 0, + OffsetOf_TexParameteriv_header_not_0); +COMPILE_ASSERT(offsetof(TexParameteriv, target) == 4, + OffsetOf_TexParameteriv_target_not_4); +COMPILE_ASSERT(offsetof(TexParameteriv, pname) == 8, + OffsetOf_TexParameteriv_pname_not_8); +COMPILE_ASSERT(offsetof(TexParameteriv, params_shm_id) == 12, + OffsetOf_TexParameteriv_params_shm_id_not_12); +COMPILE_ASSERT(offsetof(TexParameteriv, params_shm_offset) == 16, + OffsetOf_TexParameteriv_params_shm_offset_not_16); + +struct TexParameterivImmediate { + typedef TexParameterivImmediate ValueType; + static const CommandId kCmdId = kTexParameterivImmediate; + static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN; + + static uint32 ComputeDataSize() { + return static_cast<uint32>( + sizeof(GLint) * 1); // NOLINT + } + + static uint32 ComputeSize() { + return static_cast<uint32>( + sizeof(ValueType) + ComputeDataSize()); // NOLINT + } + + void SetHeader() { + header.SetCmdByTotalSize<ValueType>(ComputeSize()); + } + + void Init(GLenum _target, GLenum _pname, const GLint* _params) { + SetHeader(); + target = _target; + pname = _pname; + memcpy(ImmediateDataAddress(this), + _params, ComputeDataSize()); + } + + void* Set(void* cmd, GLenum _target, GLenum _pname, const GLint* _params) { + static_cast<ValueType*>(cmd)->Init(_target, _pname, _params); + const uint32 size = ComputeSize(); + return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); + } + + command_buffer::CommandHeader header; + uint32 target; + uint32 pname; +}; + +COMPILE_ASSERT(sizeof(TexParameterivImmediate) == 12, + Sizeof_TexParameterivImmediate_is_not_12); +COMPILE_ASSERT(offsetof(TexParameterivImmediate, header) == 0, + OffsetOf_TexParameterivImmediate_header_not_0); +COMPILE_ASSERT(offsetof(TexParameterivImmediate, target) == 4, + OffsetOf_TexParameterivImmediate_target_not_4); +COMPILE_ASSERT(offsetof(TexParameterivImmediate, pname) == 8, + OffsetOf_TexParameterivImmediate_pname_not_8); + +struct TexSubImage2D { + typedef TexSubImage2D ValueType; + static const CommandId kCmdId = kTexSubImage2D; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLenum _target, GLint _level, GLint _xoffset, GLint _yoffset, + GLsizei _width, GLsizei _height, GLenum _format, GLenum _type, + uint32 _pixels_shm_id, uint32 _pixels_shm_offset) { + SetHeader(); + target = _target; + level = _level; + xoffset = _xoffset; + yoffset = _yoffset; + width = _width; + height = _height; + format = _format; + type = _type; + pixels_shm_id = _pixels_shm_id; + pixels_shm_offset = _pixels_shm_offset; + } + + void* Set( + void* cmd, GLenum _target, GLint _level, GLint _xoffset, GLint _yoffset, + GLsizei _width, GLsizei _height, GLenum _format, GLenum _type, + uint32 _pixels_shm_id, uint32 _pixels_shm_offset) { + static_cast<ValueType*>( + cmd)->Init( + _target, _level, _xoffset, _yoffset, _width, _height, _format, + _type, _pixels_shm_id, _pixels_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 target; + uint32 level; + uint32 xoffset; + uint32 yoffset; + uint32 width; + uint32 height; + uint32 format; + uint32 type; + uint32 pixels_shm_id; + uint32 pixels_shm_offset; +}; + +COMPILE_ASSERT(sizeof(TexSubImage2D) == 44, + Sizeof_TexSubImage2D_is_not_44); +COMPILE_ASSERT(offsetof(TexSubImage2D, header) == 0, + OffsetOf_TexSubImage2D_header_not_0); +COMPILE_ASSERT(offsetof(TexSubImage2D, target) == 4, + OffsetOf_TexSubImage2D_target_not_4); +COMPILE_ASSERT(offsetof(TexSubImage2D, level) == 8, + OffsetOf_TexSubImage2D_level_not_8); +COMPILE_ASSERT(offsetof(TexSubImage2D, xoffset) == 12, + OffsetOf_TexSubImage2D_xoffset_not_12); +COMPILE_ASSERT(offsetof(TexSubImage2D, yoffset) == 16, + OffsetOf_TexSubImage2D_yoffset_not_16); +COMPILE_ASSERT(offsetof(TexSubImage2D, width) == 20, + OffsetOf_TexSubImage2D_width_not_20); +COMPILE_ASSERT(offsetof(TexSubImage2D, height) == 24, + OffsetOf_TexSubImage2D_height_not_24); +COMPILE_ASSERT(offsetof(TexSubImage2D, format) == 28, + OffsetOf_TexSubImage2D_format_not_28); +COMPILE_ASSERT(offsetof(TexSubImage2D, type) == 32, + OffsetOf_TexSubImage2D_type_not_32); +COMPILE_ASSERT(offsetof(TexSubImage2D, pixels_shm_id) == 36, + OffsetOf_TexSubImage2D_pixels_shm_id_not_36); +COMPILE_ASSERT(offsetof(TexSubImage2D, pixels_shm_offset) == 40, + OffsetOf_TexSubImage2D_pixels_shm_offset_not_40); + +struct TexSubImage2DImmediate { + typedef TexSubImage2DImmediate ValueType; + static const CommandId kCmdId = kTexSubImage2DImmediate; + static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN; + + static uint32 ComputeSize(uint32 size_in_bytes) { + return static_cast<uint32>( + sizeof(ValueType) + // NOLINT + RoundSizeToMultipleOfEntries(size_in_bytes)); + } + + void SetHeader(uint32 size_in_bytes) { + header.SetCmdByTotalSize<ValueType>(size_in_bytes); + } + + void Init( + GLenum _target, GLint _level, GLint _xoffset, GLint _yoffset, + GLsizei _width, GLsizei _height, GLenum _format, GLenum _type) { + uint32 total_size = 0; // TODO(gman): get correct size + SetHeader(total_size); + target = _target; + level = _level; + xoffset = _xoffset; + yoffset = _yoffset; + width = _width; + height = _height; + format = _format; + type = _type; + } + + void* Set( + void* cmd, GLenum _target, GLint _level, GLint _xoffset, GLint _yoffset, + GLsizei _width, GLsizei _height, GLenum _format, GLenum _type) { + uint32 total_size = 0; // TODO(gman): get correct size + static_cast<ValueType*>( + cmd)->Init( + _target, _level, _xoffset, _yoffset, _width, _height, _format, + _type); + return NextImmediateCmdAddressTotalSize<ValueType>(cmd, total_size); + } + + command_buffer::CommandHeader header; + uint32 target; + uint32 level; + uint32 xoffset; + uint32 yoffset; + uint32 width; + uint32 height; + uint32 format; + uint32 type; +}; + +COMPILE_ASSERT(sizeof(TexSubImage2DImmediate) == 36, + Sizeof_TexSubImage2DImmediate_is_not_36); +COMPILE_ASSERT(offsetof(TexSubImage2DImmediate, header) == 0, + OffsetOf_TexSubImage2DImmediate_header_not_0); +COMPILE_ASSERT(offsetof(TexSubImage2DImmediate, target) == 4, + OffsetOf_TexSubImage2DImmediate_target_not_4); +COMPILE_ASSERT(offsetof(TexSubImage2DImmediate, level) == 8, + OffsetOf_TexSubImage2DImmediate_level_not_8); +COMPILE_ASSERT(offsetof(TexSubImage2DImmediate, xoffset) == 12, + OffsetOf_TexSubImage2DImmediate_xoffset_not_12); +COMPILE_ASSERT(offsetof(TexSubImage2DImmediate, yoffset) == 16, + OffsetOf_TexSubImage2DImmediate_yoffset_not_16); +COMPILE_ASSERT(offsetof(TexSubImage2DImmediate, width) == 20, + OffsetOf_TexSubImage2DImmediate_width_not_20); +COMPILE_ASSERT(offsetof(TexSubImage2DImmediate, height) == 24, + OffsetOf_TexSubImage2DImmediate_height_not_24); +COMPILE_ASSERT(offsetof(TexSubImage2DImmediate, format) == 28, + OffsetOf_TexSubImage2DImmediate_format_not_28); +COMPILE_ASSERT(offsetof(TexSubImage2DImmediate, type) == 32, + OffsetOf_TexSubImage2DImmediate_type_not_32); + +struct Uniform1f { + typedef Uniform1f ValueType; + static const CommandId kCmdId = kUniform1f; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLint _location, GLfloat _x) { + SetHeader(); + location = _location; + x = _x; + } + + void* Set(void* cmd, GLint _location, GLfloat _x) { + static_cast<ValueType*>(cmd)->Init(_location, _x); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 location; + float x; +}; + +COMPILE_ASSERT(sizeof(Uniform1f) == 12, + Sizeof_Uniform1f_is_not_12); +COMPILE_ASSERT(offsetof(Uniform1f, header) == 0, + OffsetOf_Uniform1f_header_not_0); +COMPILE_ASSERT(offsetof(Uniform1f, location) == 4, + OffsetOf_Uniform1f_location_not_4); +COMPILE_ASSERT(offsetof(Uniform1f, x) == 8, + OffsetOf_Uniform1f_x_not_8); + +struct Uniform1fv { + typedef Uniform1fv ValueType; + static const CommandId kCmdId = kUniform1fv; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLint _location, GLsizei _count, uint32 _v_shm_id, + uint32 _v_shm_offset) { + SetHeader(); + location = _location; + count = _count; + v_shm_id = _v_shm_id; + v_shm_offset = _v_shm_offset; + } + + void* Set( + void* cmd, GLint _location, GLsizei _count, uint32 _v_shm_id, + uint32 _v_shm_offset) { + static_cast<ValueType*>( + cmd)->Init(_location, _count, _v_shm_id, _v_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 location; + uint32 count; + uint32 v_shm_id; + uint32 v_shm_offset; +}; + +COMPILE_ASSERT(sizeof(Uniform1fv) == 20, + Sizeof_Uniform1fv_is_not_20); +COMPILE_ASSERT(offsetof(Uniform1fv, header) == 0, + OffsetOf_Uniform1fv_header_not_0); +COMPILE_ASSERT(offsetof(Uniform1fv, location) == 4, + OffsetOf_Uniform1fv_location_not_4); +COMPILE_ASSERT(offsetof(Uniform1fv, count) == 8, + OffsetOf_Uniform1fv_count_not_8); +COMPILE_ASSERT(offsetof(Uniform1fv, v_shm_id) == 12, + OffsetOf_Uniform1fv_v_shm_id_not_12); +COMPILE_ASSERT(offsetof(Uniform1fv, v_shm_offset) == 16, + OffsetOf_Uniform1fv_v_shm_offset_not_16); + +struct Uniform1fvImmediate { + typedef Uniform1fvImmediate ValueType; + static const CommandId kCmdId = kUniform1fvImmediate; + static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN; + + static uint32 ComputeDataSize(GLsizei count) { + return static_cast<uint32>( + sizeof(GLfloat) * 1 * count); // NOLINT + } + + static uint32 ComputeSize(GLsizei count) { + return static_cast<uint32>( + sizeof(ValueType) + ComputeDataSize(count)); // NOLINT + } + + void SetHeader(GLsizei count) { + header.SetCmdByTotalSize<ValueType>(ComputeSize(count)); + } + + void Init(GLint _location, GLsizei _count, const GLfloat* _v) { + SetHeader(_count); + location = _location; + count = _count; + memcpy(ImmediateDataAddress(this), + _v, ComputeDataSize(_count)); + } + + void* Set(void* cmd, GLint _location, GLsizei _count, const GLfloat* _v) { + static_cast<ValueType*>(cmd)->Init(_location, _count, _v); + const uint32 size = ComputeSize(_count); + return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); + } + + command_buffer::CommandHeader header; + uint32 location; + uint32 count; +}; + +COMPILE_ASSERT(sizeof(Uniform1fvImmediate) == 12, + Sizeof_Uniform1fvImmediate_is_not_12); +COMPILE_ASSERT(offsetof(Uniform1fvImmediate, header) == 0, + OffsetOf_Uniform1fvImmediate_header_not_0); +COMPILE_ASSERT(offsetof(Uniform1fvImmediate, location) == 4, + OffsetOf_Uniform1fvImmediate_location_not_4); +COMPILE_ASSERT(offsetof(Uniform1fvImmediate, count) == 8, + OffsetOf_Uniform1fvImmediate_count_not_8); + +struct Uniform1i { + typedef Uniform1i ValueType; + static const CommandId kCmdId = kUniform1i; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLint _location, GLint _x) { + SetHeader(); + location = _location; + x = _x; + } + + void* Set(void* cmd, GLint _location, GLint _x) { + static_cast<ValueType*>(cmd)->Init(_location, _x); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 location; + uint32 x; +}; + +COMPILE_ASSERT(sizeof(Uniform1i) == 12, + Sizeof_Uniform1i_is_not_12); +COMPILE_ASSERT(offsetof(Uniform1i, header) == 0, + OffsetOf_Uniform1i_header_not_0); +COMPILE_ASSERT(offsetof(Uniform1i, location) == 4, + OffsetOf_Uniform1i_location_not_4); +COMPILE_ASSERT(offsetof(Uniform1i, x) == 8, + OffsetOf_Uniform1i_x_not_8); + +struct Uniform1iv { + typedef Uniform1iv ValueType; + static const CommandId kCmdId = kUniform1iv; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLint _location, GLsizei _count, uint32 _v_shm_id, + uint32 _v_shm_offset) { + SetHeader(); + location = _location; + count = _count; + v_shm_id = _v_shm_id; + v_shm_offset = _v_shm_offset; + } + + void* Set( + void* cmd, GLint _location, GLsizei _count, uint32 _v_shm_id, + uint32 _v_shm_offset) { + static_cast<ValueType*>( + cmd)->Init(_location, _count, _v_shm_id, _v_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 location; + uint32 count; + uint32 v_shm_id; + uint32 v_shm_offset; +}; + +COMPILE_ASSERT(sizeof(Uniform1iv) == 20, + Sizeof_Uniform1iv_is_not_20); +COMPILE_ASSERT(offsetof(Uniform1iv, header) == 0, + OffsetOf_Uniform1iv_header_not_0); +COMPILE_ASSERT(offsetof(Uniform1iv, location) == 4, + OffsetOf_Uniform1iv_location_not_4); +COMPILE_ASSERT(offsetof(Uniform1iv, count) == 8, + OffsetOf_Uniform1iv_count_not_8); +COMPILE_ASSERT(offsetof(Uniform1iv, v_shm_id) == 12, + OffsetOf_Uniform1iv_v_shm_id_not_12); +COMPILE_ASSERT(offsetof(Uniform1iv, v_shm_offset) == 16, + OffsetOf_Uniform1iv_v_shm_offset_not_16); + +struct Uniform1ivImmediate { + typedef Uniform1ivImmediate ValueType; + static const CommandId kCmdId = kUniform1ivImmediate; + static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN; + + static uint32 ComputeDataSize(GLsizei count) { + return static_cast<uint32>( + sizeof(GLint) * 1 * count); // NOLINT + } + + static uint32 ComputeSize(GLsizei count) { + return static_cast<uint32>( + sizeof(ValueType) + ComputeDataSize(count)); // NOLINT + } + + void SetHeader(GLsizei count) { + header.SetCmdByTotalSize<ValueType>(ComputeSize(count)); + } + + void Init(GLint _location, GLsizei _count, const GLint* _v) { + SetHeader(_count); + location = _location; + count = _count; + memcpy(ImmediateDataAddress(this), + _v, ComputeDataSize(_count)); + } + + void* Set(void* cmd, GLint _location, GLsizei _count, const GLint* _v) { + static_cast<ValueType*>(cmd)->Init(_location, _count, _v); + const uint32 size = ComputeSize(_count); + return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); + } + + command_buffer::CommandHeader header; + uint32 location; + uint32 count; +}; + +COMPILE_ASSERT(sizeof(Uniform1ivImmediate) == 12, + Sizeof_Uniform1ivImmediate_is_not_12); +COMPILE_ASSERT(offsetof(Uniform1ivImmediate, header) == 0, + OffsetOf_Uniform1ivImmediate_header_not_0); +COMPILE_ASSERT(offsetof(Uniform1ivImmediate, location) == 4, + OffsetOf_Uniform1ivImmediate_location_not_4); +COMPILE_ASSERT(offsetof(Uniform1ivImmediate, count) == 8, + OffsetOf_Uniform1ivImmediate_count_not_8); + +struct Uniform2f { + typedef Uniform2f ValueType; + static const CommandId kCmdId = kUniform2f; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLint _location, GLfloat _x, GLfloat _y) { + SetHeader(); + location = _location; + x = _x; + y = _y; + } + + void* Set(void* cmd, GLint _location, GLfloat _x, GLfloat _y) { + static_cast<ValueType*>(cmd)->Init(_location, _x, _y); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 location; + float x; + float y; +}; + +COMPILE_ASSERT(sizeof(Uniform2f) == 16, + Sizeof_Uniform2f_is_not_16); +COMPILE_ASSERT(offsetof(Uniform2f, header) == 0, + OffsetOf_Uniform2f_header_not_0); +COMPILE_ASSERT(offsetof(Uniform2f, location) == 4, + OffsetOf_Uniform2f_location_not_4); +COMPILE_ASSERT(offsetof(Uniform2f, x) == 8, + OffsetOf_Uniform2f_x_not_8); +COMPILE_ASSERT(offsetof(Uniform2f, y) == 12, + OffsetOf_Uniform2f_y_not_12); + +struct Uniform2fv { + typedef Uniform2fv ValueType; + static const CommandId kCmdId = kUniform2fv; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLint _location, GLsizei _count, uint32 _v_shm_id, + uint32 _v_shm_offset) { + SetHeader(); + location = _location; + count = _count; + v_shm_id = _v_shm_id; + v_shm_offset = _v_shm_offset; + } + + void* Set( + void* cmd, GLint _location, GLsizei _count, uint32 _v_shm_id, + uint32 _v_shm_offset) { + static_cast<ValueType*>( + cmd)->Init(_location, _count, _v_shm_id, _v_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 location; + uint32 count; + uint32 v_shm_id; + uint32 v_shm_offset; +}; + +COMPILE_ASSERT(sizeof(Uniform2fv) == 20, + Sizeof_Uniform2fv_is_not_20); +COMPILE_ASSERT(offsetof(Uniform2fv, header) == 0, + OffsetOf_Uniform2fv_header_not_0); +COMPILE_ASSERT(offsetof(Uniform2fv, location) == 4, + OffsetOf_Uniform2fv_location_not_4); +COMPILE_ASSERT(offsetof(Uniform2fv, count) == 8, + OffsetOf_Uniform2fv_count_not_8); +COMPILE_ASSERT(offsetof(Uniform2fv, v_shm_id) == 12, + OffsetOf_Uniform2fv_v_shm_id_not_12); +COMPILE_ASSERT(offsetof(Uniform2fv, v_shm_offset) == 16, + OffsetOf_Uniform2fv_v_shm_offset_not_16); + +struct Uniform2fvImmediate { + typedef Uniform2fvImmediate ValueType; + static const CommandId kCmdId = kUniform2fvImmediate; + static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN; + + static uint32 ComputeDataSize(GLsizei count) { + return static_cast<uint32>( + sizeof(GLfloat) * 2 * count); // NOLINT + } + + static uint32 ComputeSize(GLsizei count) { + return static_cast<uint32>( + sizeof(ValueType) + ComputeDataSize(count)); // NOLINT + } + + void SetHeader(GLsizei count) { + header.SetCmdByTotalSize<ValueType>(ComputeSize(count)); + } + + void Init(GLint _location, GLsizei _count, const GLfloat* _v) { + SetHeader(_count); + location = _location; + count = _count; + memcpy(ImmediateDataAddress(this), + _v, ComputeDataSize(_count)); + } + + void* Set(void* cmd, GLint _location, GLsizei _count, const GLfloat* _v) { + static_cast<ValueType*>(cmd)->Init(_location, _count, _v); + const uint32 size = ComputeSize(_count); + return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); + } + + command_buffer::CommandHeader header; + uint32 location; + uint32 count; +}; + +COMPILE_ASSERT(sizeof(Uniform2fvImmediate) == 12, + Sizeof_Uniform2fvImmediate_is_not_12); +COMPILE_ASSERT(offsetof(Uniform2fvImmediate, header) == 0, + OffsetOf_Uniform2fvImmediate_header_not_0); +COMPILE_ASSERT(offsetof(Uniform2fvImmediate, location) == 4, + OffsetOf_Uniform2fvImmediate_location_not_4); +COMPILE_ASSERT(offsetof(Uniform2fvImmediate, count) == 8, + OffsetOf_Uniform2fvImmediate_count_not_8); + +struct Uniform2i { + typedef Uniform2i ValueType; + static const CommandId kCmdId = kUniform2i; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLint _location, GLint _x, GLint _y) { + SetHeader(); + location = _location; + x = _x; + y = _y; + } + + void* Set(void* cmd, GLint _location, GLint _x, GLint _y) { + static_cast<ValueType*>(cmd)->Init(_location, _x, _y); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 location; + uint32 x; + uint32 y; +}; + +COMPILE_ASSERT(sizeof(Uniform2i) == 16, + Sizeof_Uniform2i_is_not_16); +COMPILE_ASSERT(offsetof(Uniform2i, header) == 0, + OffsetOf_Uniform2i_header_not_0); +COMPILE_ASSERT(offsetof(Uniform2i, location) == 4, + OffsetOf_Uniform2i_location_not_4); +COMPILE_ASSERT(offsetof(Uniform2i, x) == 8, + OffsetOf_Uniform2i_x_not_8); +COMPILE_ASSERT(offsetof(Uniform2i, y) == 12, + OffsetOf_Uniform2i_y_not_12); + +struct Uniform2iv { + typedef Uniform2iv ValueType; + static const CommandId kCmdId = kUniform2iv; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLint _location, GLsizei _count, uint32 _v_shm_id, + uint32 _v_shm_offset) { + SetHeader(); + location = _location; + count = _count; + v_shm_id = _v_shm_id; + v_shm_offset = _v_shm_offset; + } + + void* Set( + void* cmd, GLint _location, GLsizei _count, uint32 _v_shm_id, + uint32 _v_shm_offset) { + static_cast<ValueType*>( + cmd)->Init(_location, _count, _v_shm_id, _v_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 location; + uint32 count; + uint32 v_shm_id; + uint32 v_shm_offset; +}; + +COMPILE_ASSERT(sizeof(Uniform2iv) == 20, + Sizeof_Uniform2iv_is_not_20); +COMPILE_ASSERT(offsetof(Uniform2iv, header) == 0, + OffsetOf_Uniform2iv_header_not_0); +COMPILE_ASSERT(offsetof(Uniform2iv, location) == 4, + OffsetOf_Uniform2iv_location_not_4); +COMPILE_ASSERT(offsetof(Uniform2iv, count) == 8, + OffsetOf_Uniform2iv_count_not_8); +COMPILE_ASSERT(offsetof(Uniform2iv, v_shm_id) == 12, + OffsetOf_Uniform2iv_v_shm_id_not_12); +COMPILE_ASSERT(offsetof(Uniform2iv, v_shm_offset) == 16, + OffsetOf_Uniform2iv_v_shm_offset_not_16); + +struct Uniform2ivImmediate { + typedef Uniform2ivImmediate ValueType; + static const CommandId kCmdId = kUniform2ivImmediate; + static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN; + + static uint32 ComputeDataSize(GLsizei count) { + return static_cast<uint32>( + sizeof(GLint) * 2 * count); // NOLINT + } + + static uint32 ComputeSize(GLsizei count) { + return static_cast<uint32>( + sizeof(ValueType) + ComputeDataSize(count)); // NOLINT + } + + void SetHeader(GLsizei count) { + header.SetCmdByTotalSize<ValueType>(ComputeSize(count)); + } + + void Init(GLint _location, GLsizei _count, const GLint* _v) { + SetHeader(_count); + location = _location; + count = _count; + memcpy(ImmediateDataAddress(this), + _v, ComputeDataSize(_count)); + } + + void* Set(void* cmd, GLint _location, GLsizei _count, const GLint* _v) { + static_cast<ValueType*>(cmd)->Init(_location, _count, _v); + const uint32 size = ComputeSize(_count); + return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); + } + + command_buffer::CommandHeader header; + uint32 location; + uint32 count; +}; + +COMPILE_ASSERT(sizeof(Uniform2ivImmediate) == 12, + Sizeof_Uniform2ivImmediate_is_not_12); +COMPILE_ASSERT(offsetof(Uniform2ivImmediate, header) == 0, + OffsetOf_Uniform2ivImmediate_header_not_0); +COMPILE_ASSERT(offsetof(Uniform2ivImmediate, location) == 4, + OffsetOf_Uniform2ivImmediate_location_not_4); +COMPILE_ASSERT(offsetof(Uniform2ivImmediate, count) == 8, + OffsetOf_Uniform2ivImmediate_count_not_8); + +struct Uniform3f { + typedef Uniform3f ValueType; + static const CommandId kCmdId = kUniform3f; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLint _location, GLfloat _x, GLfloat _y, GLfloat _z) { + SetHeader(); + location = _location; + x = _x; + y = _y; + z = _z; + } + + void* Set(void* cmd, GLint _location, GLfloat _x, GLfloat _y, GLfloat _z) { + static_cast<ValueType*>(cmd)->Init(_location, _x, _y, _z); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 location; + float x; + float y; + float z; +}; + +COMPILE_ASSERT(sizeof(Uniform3f) == 20, + Sizeof_Uniform3f_is_not_20); +COMPILE_ASSERT(offsetof(Uniform3f, header) == 0, + OffsetOf_Uniform3f_header_not_0); +COMPILE_ASSERT(offsetof(Uniform3f, location) == 4, + OffsetOf_Uniform3f_location_not_4); +COMPILE_ASSERT(offsetof(Uniform3f, x) == 8, + OffsetOf_Uniform3f_x_not_8); +COMPILE_ASSERT(offsetof(Uniform3f, y) == 12, + OffsetOf_Uniform3f_y_not_12); +COMPILE_ASSERT(offsetof(Uniform3f, z) == 16, + OffsetOf_Uniform3f_z_not_16); + +struct Uniform3fv { + typedef Uniform3fv ValueType; + static const CommandId kCmdId = kUniform3fv; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLint _location, GLsizei _count, uint32 _v_shm_id, + uint32 _v_shm_offset) { + SetHeader(); + location = _location; + count = _count; + v_shm_id = _v_shm_id; + v_shm_offset = _v_shm_offset; + } + + void* Set( + void* cmd, GLint _location, GLsizei _count, uint32 _v_shm_id, + uint32 _v_shm_offset) { + static_cast<ValueType*>( + cmd)->Init(_location, _count, _v_shm_id, _v_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 location; + uint32 count; + uint32 v_shm_id; + uint32 v_shm_offset; +}; + +COMPILE_ASSERT(sizeof(Uniform3fv) == 20, + Sizeof_Uniform3fv_is_not_20); +COMPILE_ASSERT(offsetof(Uniform3fv, header) == 0, + OffsetOf_Uniform3fv_header_not_0); +COMPILE_ASSERT(offsetof(Uniform3fv, location) == 4, + OffsetOf_Uniform3fv_location_not_4); +COMPILE_ASSERT(offsetof(Uniform3fv, count) == 8, + OffsetOf_Uniform3fv_count_not_8); +COMPILE_ASSERT(offsetof(Uniform3fv, v_shm_id) == 12, + OffsetOf_Uniform3fv_v_shm_id_not_12); +COMPILE_ASSERT(offsetof(Uniform3fv, v_shm_offset) == 16, + OffsetOf_Uniform3fv_v_shm_offset_not_16); + +struct Uniform3fvImmediate { + typedef Uniform3fvImmediate ValueType; + static const CommandId kCmdId = kUniform3fvImmediate; + static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN; + + static uint32 ComputeDataSize(GLsizei count) { + return static_cast<uint32>( + sizeof(GLfloat) * 3 * count); // NOLINT + } + + static uint32 ComputeSize(GLsizei count) { + return static_cast<uint32>( + sizeof(ValueType) + ComputeDataSize(count)); // NOLINT + } + + void SetHeader(GLsizei count) { + header.SetCmdByTotalSize<ValueType>(ComputeSize(count)); + } + + void Init(GLint _location, GLsizei _count, const GLfloat* _v) { + SetHeader(_count); + location = _location; + count = _count; + memcpy(ImmediateDataAddress(this), + _v, ComputeDataSize(_count)); + } + + void* Set(void* cmd, GLint _location, GLsizei _count, const GLfloat* _v) { + static_cast<ValueType*>(cmd)->Init(_location, _count, _v); + const uint32 size = ComputeSize(_count); + return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); + } + + command_buffer::CommandHeader header; + uint32 location; + uint32 count; +}; + +COMPILE_ASSERT(sizeof(Uniform3fvImmediate) == 12, + Sizeof_Uniform3fvImmediate_is_not_12); +COMPILE_ASSERT(offsetof(Uniform3fvImmediate, header) == 0, + OffsetOf_Uniform3fvImmediate_header_not_0); +COMPILE_ASSERT(offsetof(Uniform3fvImmediate, location) == 4, + OffsetOf_Uniform3fvImmediate_location_not_4); +COMPILE_ASSERT(offsetof(Uniform3fvImmediate, count) == 8, + OffsetOf_Uniform3fvImmediate_count_not_8); + +struct Uniform3i { + typedef Uniform3i ValueType; + static const CommandId kCmdId = kUniform3i; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLint _location, GLint _x, GLint _y, GLint _z) { + SetHeader(); + location = _location; + x = _x; + y = _y; + z = _z; + } + + void* Set(void* cmd, GLint _location, GLint _x, GLint _y, GLint _z) { + static_cast<ValueType*>(cmd)->Init(_location, _x, _y, _z); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 location; + uint32 x; + uint32 y; + uint32 z; +}; + +COMPILE_ASSERT(sizeof(Uniform3i) == 20, + Sizeof_Uniform3i_is_not_20); +COMPILE_ASSERT(offsetof(Uniform3i, header) == 0, + OffsetOf_Uniform3i_header_not_0); +COMPILE_ASSERT(offsetof(Uniform3i, location) == 4, + OffsetOf_Uniform3i_location_not_4); +COMPILE_ASSERT(offsetof(Uniform3i, x) == 8, + OffsetOf_Uniform3i_x_not_8); +COMPILE_ASSERT(offsetof(Uniform3i, y) == 12, + OffsetOf_Uniform3i_y_not_12); +COMPILE_ASSERT(offsetof(Uniform3i, z) == 16, + OffsetOf_Uniform3i_z_not_16); + +struct Uniform3iv { + typedef Uniform3iv ValueType; + static const CommandId kCmdId = kUniform3iv; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLint _location, GLsizei _count, uint32 _v_shm_id, + uint32 _v_shm_offset) { + SetHeader(); + location = _location; + count = _count; + v_shm_id = _v_shm_id; + v_shm_offset = _v_shm_offset; + } + + void* Set( + void* cmd, GLint _location, GLsizei _count, uint32 _v_shm_id, + uint32 _v_shm_offset) { + static_cast<ValueType*>( + cmd)->Init(_location, _count, _v_shm_id, _v_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 location; + uint32 count; + uint32 v_shm_id; + uint32 v_shm_offset; +}; + +COMPILE_ASSERT(sizeof(Uniform3iv) == 20, + Sizeof_Uniform3iv_is_not_20); +COMPILE_ASSERT(offsetof(Uniform3iv, header) == 0, + OffsetOf_Uniform3iv_header_not_0); +COMPILE_ASSERT(offsetof(Uniform3iv, location) == 4, + OffsetOf_Uniform3iv_location_not_4); +COMPILE_ASSERT(offsetof(Uniform3iv, count) == 8, + OffsetOf_Uniform3iv_count_not_8); +COMPILE_ASSERT(offsetof(Uniform3iv, v_shm_id) == 12, + OffsetOf_Uniform3iv_v_shm_id_not_12); +COMPILE_ASSERT(offsetof(Uniform3iv, v_shm_offset) == 16, + OffsetOf_Uniform3iv_v_shm_offset_not_16); + +struct Uniform3ivImmediate { + typedef Uniform3ivImmediate ValueType; + static const CommandId kCmdId = kUniform3ivImmediate; + static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN; + + static uint32 ComputeDataSize(GLsizei count) { + return static_cast<uint32>( + sizeof(GLint) * 3 * count); // NOLINT + } + + static uint32 ComputeSize(GLsizei count) { + return static_cast<uint32>( + sizeof(ValueType) + ComputeDataSize(count)); // NOLINT + } + + void SetHeader(GLsizei count) { + header.SetCmdByTotalSize<ValueType>(ComputeSize(count)); + } + + void Init(GLint _location, GLsizei _count, const GLint* _v) { + SetHeader(_count); + location = _location; + count = _count; + memcpy(ImmediateDataAddress(this), + _v, ComputeDataSize(_count)); + } + + void* Set(void* cmd, GLint _location, GLsizei _count, const GLint* _v) { + static_cast<ValueType*>(cmd)->Init(_location, _count, _v); + const uint32 size = ComputeSize(_count); + return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); + } + + command_buffer::CommandHeader header; + uint32 location; + uint32 count; +}; + +COMPILE_ASSERT(sizeof(Uniform3ivImmediate) == 12, + Sizeof_Uniform3ivImmediate_is_not_12); +COMPILE_ASSERT(offsetof(Uniform3ivImmediate, header) == 0, + OffsetOf_Uniform3ivImmediate_header_not_0); +COMPILE_ASSERT(offsetof(Uniform3ivImmediate, location) == 4, + OffsetOf_Uniform3ivImmediate_location_not_4); +COMPILE_ASSERT(offsetof(Uniform3ivImmediate, count) == 8, + OffsetOf_Uniform3ivImmediate_count_not_8); + +struct Uniform4f { + typedef Uniform4f ValueType; + static const CommandId kCmdId = kUniform4f; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLint _location, GLfloat _x, GLfloat _y, GLfloat _z, GLfloat _w) { + SetHeader(); + location = _location; + x = _x; + y = _y; + z = _z; + w = _w; + } + + void* Set( + void* cmd, GLint _location, GLfloat _x, GLfloat _y, GLfloat _z, + GLfloat _w) { + static_cast<ValueType*>(cmd)->Init(_location, _x, _y, _z, _w); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 location; + float x; + float y; + float z; + float w; +}; + +COMPILE_ASSERT(sizeof(Uniform4f) == 24, + Sizeof_Uniform4f_is_not_24); +COMPILE_ASSERT(offsetof(Uniform4f, header) == 0, + OffsetOf_Uniform4f_header_not_0); +COMPILE_ASSERT(offsetof(Uniform4f, location) == 4, + OffsetOf_Uniform4f_location_not_4); +COMPILE_ASSERT(offsetof(Uniform4f, x) == 8, + OffsetOf_Uniform4f_x_not_8); +COMPILE_ASSERT(offsetof(Uniform4f, y) == 12, + OffsetOf_Uniform4f_y_not_12); +COMPILE_ASSERT(offsetof(Uniform4f, z) == 16, + OffsetOf_Uniform4f_z_not_16); +COMPILE_ASSERT(offsetof(Uniform4f, w) == 20, + OffsetOf_Uniform4f_w_not_20); + +struct Uniform4fv { + typedef Uniform4fv ValueType; + static const CommandId kCmdId = kUniform4fv; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLint _location, GLsizei _count, uint32 _v_shm_id, + uint32 _v_shm_offset) { + SetHeader(); + location = _location; + count = _count; + v_shm_id = _v_shm_id; + v_shm_offset = _v_shm_offset; + } + + void* Set( + void* cmd, GLint _location, GLsizei _count, uint32 _v_shm_id, + uint32 _v_shm_offset) { + static_cast<ValueType*>( + cmd)->Init(_location, _count, _v_shm_id, _v_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 location; + uint32 count; + uint32 v_shm_id; + uint32 v_shm_offset; +}; + +COMPILE_ASSERT(sizeof(Uniform4fv) == 20, + Sizeof_Uniform4fv_is_not_20); +COMPILE_ASSERT(offsetof(Uniform4fv, header) == 0, + OffsetOf_Uniform4fv_header_not_0); +COMPILE_ASSERT(offsetof(Uniform4fv, location) == 4, + OffsetOf_Uniform4fv_location_not_4); +COMPILE_ASSERT(offsetof(Uniform4fv, count) == 8, + OffsetOf_Uniform4fv_count_not_8); +COMPILE_ASSERT(offsetof(Uniform4fv, v_shm_id) == 12, + OffsetOf_Uniform4fv_v_shm_id_not_12); +COMPILE_ASSERT(offsetof(Uniform4fv, v_shm_offset) == 16, + OffsetOf_Uniform4fv_v_shm_offset_not_16); + +struct Uniform4fvImmediate { + typedef Uniform4fvImmediate ValueType; + static const CommandId kCmdId = kUniform4fvImmediate; + static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN; + + static uint32 ComputeDataSize(GLsizei count) { + return static_cast<uint32>( + sizeof(GLfloat) * 4 * count); // NOLINT + } + + static uint32 ComputeSize(GLsizei count) { + return static_cast<uint32>( + sizeof(ValueType) + ComputeDataSize(count)); // NOLINT + } + + void SetHeader(GLsizei count) { + header.SetCmdByTotalSize<ValueType>(ComputeSize(count)); + } + + void Init(GLint _location, GLsizei _count, const GLfloat* _v) { + SetHeader(_count); + location = _location; + count = _count; + memcpy(ImmediateDataAddress(this), + _v, ComputeDataSize(_count)); + } + + void* Set(void* cmd, GLint _location, GLsizei _count, const GLfloat* _v) { + static_cast<ValueType*>(cmd)->Init(_location, _count, _v); + const uint32 size = ComputeSize(_count); + return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); + } + + command_buffer::CommandHeader header; + uint32 location; + uint32 count; +}; + +COMPILE_ASSERT(sizeof(Uniform4fvImmediate) == 12, + Sizeof_Uniform4fvImmediate_is_not_12); +COMPILE_ASSERT(offsetof(Uniform4fvImmediate, header) == 0, + OffsetOf_Uniform4fvImmediate_header_not_0); +COMPILE_ASSERT(offsetof(Uniform4fvImmediate, location) == 4, + OffsetOf_Uniform4fvImmediate_location_not_4); +COMPILE_ASSERT(offsetof(Uniform4fvImmediate, count) == 8, + OffsetOf_Uniform4fvImmediate_count_not_8); + +struct Uniform4i { + typedef Uniform4i ValueType; + static const CommandId kCmdId = kUniform4i; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLint _location, GLint _x, GLint _y, GLint _z, GLint _w) { + SetHeader(); + location = _location; + x = _x; + y = _y; + z = _z; + w = _w; + } + + void* Set( + void* cmd, GLint _location, GLint _x, GLint _y, GLint _z, GLint _w) { + static_cast<ValueType*>(cmd)->Init(_location, _x, _y, _z, _w); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 location; + uint32 x; + uint32 y; + uint32 z; + uint32 w; +}; + +COMPILE_ASSERT(sizeof(Uniform4i) == 24, + Sizeof_Uniform4i_is_not_24); +COMPILE_ASSERT(offsetof(Uniform4i, header) == 0, + OffsetOf_Uniform4i_header_not_0); +COMPILE_ASSERT(offsetof(Uniform4i, location) == 4, + OffsetOf_Uniform4i_location_not_4); +COMPILE_ASSERT(offsetof(Uniform4i, x) == 8, + OffsetOf_Uniform4i_x_not_8); +COMPILE_ASSERT(offsetof(Uniform4i, y) == 12, + OffsetOf_Uniform4i_y_not_12); +COMPILE_ASSERT(offsetof(Uniform4i, z) == 16, + OffsetOf_Uniform4i_z_not_16); +COMPILE_ASSERT(offsetof(Uniform4i, w) == 20, + OffsetOf_Uniform4i_w_not_20); + +struct Uniform4iv { + typedef Uniform4iv ValueType; + static const CommandId kCmdId = kUniform4iv; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLint _location, GLsizei _count, uint32 _v_shm_id, + uint32 _v_shm_offset) { + SetHeader(); + location = _location; + count = _count; + v_shm_id = _v_shm_id; + v_shm_offset = _v_shm_offset; + } + + void* Set( + void* cmd, GLint _location, GLsizei _count, uint32 _v_shm_id, + uint32 _v_shm_offset) { + static_cast<ValueType*>( + cmd)->Init(_location, _count, _v_shm_id, _v_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 location; + uint32 count; + uint32 v_shm_id; + uint32 v_shm_offset; +}; + +COMPILE_ASSERT(sizeof(Uniform4iv) == 20, + Sizeof_Uniform4iv_is_not_20); +COMPILE_ASSERT(offsetof(Uniform4iv, header) == 0, + OffsetOf_Uniform4iv_header_not_0); +COMPILE_ASSERT(offsetof(Uniform4iv, location) == 4, + OffsetOf_Uniform4iv_location_not_4); +COMPILE_ASSERT(offsetof(Uniform4iv, count) == 8, + OffsetOf_Uniform4iv_count_not_8); +COMPILE_ASSERT(offsetof(Uniform4iv, v_shm_id) == 12, + OffsetOf_Uniform4iv_v_shm_id_not_12); +COMPILE_ASSERT(offsetof(Uniform4iv, v_shm_offset) == 16, + OffsetOf_Uniform4iv_v_shm_offset_not_16); + +struct Uniform4ivImmediate { + typedef Uniform4ivImmediate ValueType; + static const CommandId kCmdId = kUniform4ivImmediate; + static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN; + + static uint32 ComputeDataSize(GLsizei count) { + return static_cast<uint32>( + sizeof(GLint) * 4 * count); // NOLINT + } + + static uint32 ComputeSize(GLsizei count) { + return static_cast<uint32>( + sizeof(ValueType) + ComputeDataSize(count)); // NOLINT + } + + void SetHeader(GLsizei count) { + header.SetCmdByTotalSize<ValueType>(ComputeSize(count)); + } + + void Init(GLint _location, GLsizei _count, const GLint* _v) { + SetHeader(_count); + location = _location; + count = _count; + memcpy(ImmediateDataAddress(this), + _v, ComputeDataSize(_count)); + } + + void* Set(void* cmd, GLint _location, GLsizei _count, const GLint* _v) { + static_cast<ValueType*>(cmd)->Init(_location, _count, _v); + const uint32 size = ComputeSize(_count); + return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); + } + + command_buffer::CommandHeader header; + uint32 location; + uint32 count; +}; + +COMPILE_ASSERT(sizeof(Uniform4ivImmediate) == 12, + Sizeof_Uniform4ivImmediate_is_not_12); +COMPILE_ASSERT(offsetof(Uniform4ivImmediate, header) == 0, + OffsetOf_Uniform4ivImmediate_header_not_0); +COMPILE_ASSERT(offsetof(Uniform4ivImmediate, location) == 4, + OffsetOf_Uniform4ivImmediate_location_not_4); +COMPILE_ASSERT(offsetof(Uniform4ivImmediate, count) == 8, + OffsetOf_Uniform4ivImmediate_count_not_8); + +struct UniformMatrix2fv { + typedef UniformMatrix2fv ValueType; + static const CommandId kCmdId = kUniformMatrix2fv; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLint _location, GLsizei _count, GLboolean _transpose, + uint32 _value_shm_id, uint32 _value_shm_offset) { + SetHeader(); + location = _location; + count = _count; + transpose = _transpose; + value_shm_id = _value_shm_id; + value_shm_offset = _value_shm_offset; + } + + void* Set( + void* cmd, GLint _location, GLsizei _count, GLboolean _transpose, + uint32 _value_shm_id, uint32 _value_shm_offset) { + static_cast<ValueType*>( + cmd)->Init( + _location, _count, _transpose, _value_shm_id, _value_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 location; + uint32 count; + uint32 transpose; + uint32 value_shm_id; + uint32 value_shm_offset; +}; + +COMPILE_ASSERT(sizeof(UniformMatrix2fv) == 24, + Sizeof_UniformMatrix2fv_is_not_24); +COMPILE_ASSERT(offsetof(UniformMatrix2fv, header) == 0, + OffsetOf_UniformMatrix2fv_header_not_0); +COMPILE_ASSERT(offsetof(UniformMatrix2fv, location) == 4, + OffsetOf_UniformMatrix2fv_location_not_4); +COMPILE_ASSERT(offsetof(UniformMatrix2fv, count) == 8, + OffsetOf_UniformMatrix2fv_count_not_8); +COMPILE_ASSERT(offsetof(UniformMatrix2fv, transpose) == 12, + OffsetOf_UniformMatrix2fv_transpose_not_12); +COMPILE_ASSERT(offsetof(UniformMatrix2fv, value_shm_id) == 16, + OffsetOf_UniformMatrix2fv_value_shm_id_not_16); +COMPILE_ASSERT(offsetof(UniformMatrix2fv, value_shm_offset) == 20, + OffsetOf_UniformMatrix2fv_value_shm_offset_not_20); + +struct UniformMatrix2fvImmediate { + typedef UniformMatrix2fvImmediate ValueType; + static const CommandId kCmdId = kUniformMatrix2fvImmediate; + static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN; + + static uint32 ComputeDataSize(GLsizei count) { + return static_cast<uint32>( + sizeof(GLfloat) * 4 * count); // NOLINT + } + + static uint32 ComputeSize(GLsizei count) { + return static_cast<uint32>( + sizeof(ValueType) + ComputeDataSize(count)); // NOLINT + } + + void SetHeader(GLsizei count) { + header.SetCmdByTotalSize<ValueType>(ComputeSize(count)); + } + + void Init( + GLint _location, GLsizei _count, GLboolean _transpose, + const GLfloat* _value) { + SetHeader(_count); + location = _location; + count = _count; + transpose = _transpose; + memcpy(ImmediateDataAddress(this), + _value, ComputeDataSize(_count)); + } + + void* Set( + void* cmd, GLint _location, GLsizei _count, GLboolean _transpose, + const GLfloat* _value) { + static_cast<ValueType*>(cmd)->Init(_location, _count, _transpose, _value); + const uint32 size = ComputeSize(_count); + return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); + } + + command_buffer::CommandHeader header; + uint32 location; + uint32 count; + uint32 transpose; +}; + +COMPILE_ASSERT(sizeof(UniformMatrix2fvImmediate) == 16, + Sizeof_UniformMatrix2fvImmediate_is_not_16); +COMPILE_ASSERT(offsetof(UniformMatrix2fvImmediate, header) == 0, + OffsetOf_UniformMatrix2fvImmediate_header_not_0); +COMPILE_ASSERT(offsetof(UniformMatrix2fvImmediate, location) == 4, + OffsetOf_UniformMatrix2fvImmediate_location_not_4); +COMPILE_ASSERT(offsetof(UniformMatrix2fvImmediate, count) == 8, + OffsetOf_UniformMatrix2fvImmediate_count_not_8); +COMPILE_ASSERT(offsetof(UniformMatrix2fvImmediate, transpose) == 12, + OffsetOf_UniformMatrix2fvImmediate_transpose_not_12); + +struct UniformMatrix3fv { + typedef UniformMatrix3fv ValueType; + static const CommandId kCmdId = kUniformMatrix3fv; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLint _location, GLsizei _count, GLboolean _transpose, + uint32 _value_shm_id, uint32 _value_shm_offset) { + SetHeader(); + location = _location; + count = _count; + transpose = _transpose; + value_shm_id = _value_shm_id; + value_shm_offset = _value_shm_offset; + } + + void* Set( + void* cmd, GLint _location, GLsizei _count, GLboolean _transpose, + uint32 _value_shm_id, uint32 _value_shm_offset) { + static_cast<ValueType*>( + cmd)->Init( + _location, _count, _transpose, _value_shm_id, _value_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 location; + uint32 count; + uint32 transpose; + uint32 value_shm_id; + uint32 value_shm_offset; +}; + +COMPILE_ASSERT(sizeof(UniformMatrix3fv) == 24, + Sizeof_UniformMatrix3fv_is_not_24); +COMPILE_ASSERT(offsetof(UniformMatrix3fv, header) == 0, + OffsetOf_UniformMatrix3fv_header_not_0); +COMPILE_ASSERT(offsetof(UniformMatrix3fv, location) == 4, + OffsetOf_UniformMatrix3fv_location_not_4); +COMPILE_ASSERT(offsetof(UniformMatrix3fv, count) == 8, + OffsetOf_UniformMatrix3fv_count_not_8); +COMPILE_ASSERT(offsetof(UniformMatrix3fv, transpose) == 12, + OffsetOf_UniformMatrix3fv_transpose_not_12); +COMPILE_ASSERT(offsetof(UniformMatrix3fv, value_shm_id) == 16, + OffsetOf_UniformMatrix3fv_value_shm_id_not_16); +COMPILE_ASSERT(offsetof(UniformMatrix3fv, value_shm_offset) == 20, + OffsetOf_UniformMatrix3fv_value_shm_offset_not_20); + +struct UniformMatrix3fvImmediate { + typedef UniformMatrix3fvImmediate ValueType; + static const CommandId kCmdId = kUniformMatrix3fvImmediate; + static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN; + + static uint32 ComputeDataSize(GLsizei count) { + return static_cast<uint32>( + sizeof(GLfloat) * 9 * count); // NOLINT + } + + static uint32 ComputeSize(GLsizei count) { + return static_cast<uint32>( + sizeof(ValueType) + ComputeDataSize(count)); // NOLINT + } + + void SetHeader(GLsizei count) { + header.SetCmdByTotalSize<ValueType>(ComputeSize(count)); + } + + void Init( + GLint _location, GLsizei _count, GLboolean _transpose, + const GLfloat* _value) { + SetHeader(_count); + location = _location; + count = _count; + transpose = _transpose; + memcpy(ImmediateDataAddress(this), + _value, ComputeDataSize(_count)); + } + + void* Set( + void* cmd, GLint _location, GLsizei _count, GLboolean _transpose, + const GLfloat* _value) { + static_cast<ValueType*>(cmd)->Init(_location, _count, _transpose, _value); + const uint32 size = ComputeSize(_count); + return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); + } + + command_buffer::CommandHeader header; + uint32 location; + uint32 count; + uint32 transpose; +}; + +COMPILE_ASSERT(sizeof(UniformMatrix3fvImmediate) == 16, + Sizeof_UniformMatrix3fvImmediate_is_not_16); +COMPILE_ASSERT(offsetof(UniformMatrix3fvImmediate, header) == 0, + OffsetOf_UniformMatrix3fvImmediate_header_not_0); +COMPILE_ASSERT(offsetof(UniformMatrix3fvImmediate, location) == 4, + OffsetOf_UniformMatrix3fvImmediate_location_not_4); +COMPILE_ASSERT(offsetof(UniformMatrix3fvImmediate, count) == 8, + OffsetOf_UniformMatrix3fvImmediate_count_not_8); +COMPILE_ASSERT(offsetof(UniformMatrix3fvImmediate, transpose) == 12, + OffsetOf_UniformMatrix3fvImmediate_transpose_not_12); + +struct UniformMatrix4fv { + typedef UniformMatrix4fv ValueType; + static const CommandId kCmdId = kUniformMatrix4fv; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLint _location, GLsizei _count, GLboolean _transpose, + uint32 _value_shm_id, uint32 _value_shm_offset) { + SetHeader(); + location = _location; + count = _count; + transpose = _transpose; + value_shm_id = _value_shm_id; + value_shm_offset = _value_shm_offset; + } + + void* Set( + void* cmd, GLint _location, GLsizei _count, GLboolean _transpose, + uint32 _value_shm_id, uint32 _value_shm_offset) { + static_cast<ValueType*>( + cmd)->Init( + _location, _count, _transpose, _value_shm_id, _value_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 location; + uint32 count; + uint32 transpose; + uint32 value_shm_id; + uint32 value_shm_offset; +}; + +COMPILE_ASSERT(sizeof(UniformMatrix4fv) == 24, + Sizeof_UniformMatrix4fv_is_not_24); +COMPILE_ASSERT(offsetof(UniformMatrix4fv, header) == 0, + OffsetOf_UniformMatrix4fv_header_not_0); +COMPILE_ASSERT(offsetof(UniformMatrix4fv, location) == 4, + OffsetOf_UniformMatrix4fv_location_not_4); +COMPILE_ASSERT(offsetof(UniformMatrix4fv, count) == 8, + OffsetOf_UniformMatrix4fv_count_not_8); +COMPILE_ASSERT(offsetof(UniformMatrix4fv, transpose) == 12, + OffsetOf_UniformMatrix4fv_transpose_not_12); +COMPILE_ASSERT(offsetof(UniformMatrix4fv, value_shm_id) == 16, + OffsetOf_UniformMatrix4fv_value_shm_id_not_16); +COMPILE_ASSERT(offsetof(UniformMatrix4fv, value_shm_offset) == 20, + OffsetOf_UniformMatrix4fv_value_shm_offset_not_20); + +struct UniformMatrix4fvImmediate { + typedef UniformMatrix4fvImmediate ValueType; + static const CommandId kCmdId = kUniformMatrix4fvImmediate; + static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN; + + static uint32 ComputeDataSize(GLsizei count) { + return static_cast<uint32>( + sizeof(GLfloat) * 16 * count); // NOLINT + } + + static uint32 ComputeSize(GLsizei count) { + return static_cast<uint32>( + sizeof(ValueType) + ComputeDataSize(count)); // NOLINT + } + + void SetHeader(GLsizei count) { + header.SetCmdByTotalSize<ValueType>(ComputeSize(count)); + } + + void Init( + GLint _location, GLsizei _count, GLboolean _transpose, + const GLfloat* _value) { + SetHeader(_count); + location = _location; + count = _count; + transpose = _transpose; + memcpy(ImmediateDataAddress(this), + _value, ComputeDataSize(_count)); + } + + void* Set( + void* cmd, GLint _location, GLsizei _count, GLboolean _transpose, + const GLfloat* _value) { + static_cast<ValueType*>(cmd)->Init(_location, _count, _transpose, _value); + const uint32 size = ComputeSize(_count); + return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); + } + + command_buffer::CommandHeader header; + uint32 location; + uint32 count; + uint32 transpose; +}; + +COMPILE_ASSERT(sizeof(UniformMatrix4fvImmediate) == 16, + Sizeof_UniformMatrix4fvImmediate_is_not_16); +COMPILE_ASSERT(offsetof(UniformMatrix4fvImmediate, header) == 0, + OffsetOf_UniformMatrix4fvImmediate_header_not_0); +COMPILE_ASSERT(offsetof(UniformMatrix4fvImmediate, location) == 4, + OffsetOf_UniformMatrix4fvImmediate_location_not_4); +COMPILE_ASSERT(offsetof(UniformMatrix4fvImmediate, count) == 8, + OffsetOf_UniformMatrix4fvImmediate_count_not_8); +COMPILE_ASSERT(offsetof(UniformMatrix4fvImmediate, transpose) == 12, + OffsetOf_UniformMatrix4fvImmediate_transpose_not_12); + +struct UseProgram { + typedef UseProgram ValueType; + static const CommandId kCmdId = kUseProgram; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLuint _program) { + SetHeader(); + program = _program; + } + + void* Set(void* cmd, GLuint _program) { + static_cast<ValueType*>(cmd)->Init(_program); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 program; +}; + +COMPILE_ASSERT(sizeof(UseProgram) == 8, + Sizeof_UseProgram_is_not_8); +COMPILE_ASSERT(offsetof(UseProgram, header) == 0, + OffsetOf_UseProgram_header_not_0); +COMPILE_ASSERT(offsetof(UseProgram, program) == 4, + OffsetOf_UseProgram_program_not_4); + +struct ValidateProgram { + typedef ValidateProgram ValueType; + static const CommandId kCmdId = kValidateProgram; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLuint _program) { + SetHeader(); + program = _program; + } + + void* Set(void* cmd, GLuint _program) { + static_cast<ValueType*>(cmd)->Init(_program); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 program; +}; + +COMPILE_ASSERT(sizeof(ValidateProgram) == 8, + Sizeof_ValidateProgram_is_not_8); +COMPILE_ASSERT(offsetof(ValidateProgram, header) == 0, + OffsetOf_ValidateProgram_header_not_0); +COMPILE_ASSERT(offsetof(ValidateProgram, program) == 4, + OffsetOf_ValidateProgram_program_not_4); + +struct VertexAttrib1f { + typedef VertexAttrib1f ValueType; + static const CommandId kCmdId = kVertexAttrib1f; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLuint _indx, GLfloat _x) { + SetHeader(); + indx = _indx; + x = _x; + } + + void* Set(void* cmd, GLuint _indx, GLfloat _x) { + static_cast<ValueType*>(cmd)->Init(_indx, _x); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 indx; + float x; +}; + +COMPILE_ASSERT(sizeof(VertexAttrib1f) == 12, + Sizeof_VertexAttrib1f_is_not_12); +COMPILE_ASSERT(offsetof(VertexAttrib1f, header) == 0, + OffsetOf_VertexAttrib1f_header_not_0); +COMPILE_ASSERT(offsetof(VertexAttrib1f, indx) == 4, + OffsetOf_VertexAttrib1f_indx_not_4); +COMPILE_ASSERT(offsetof(VertexAttrib1f, x) == 8, + OffsetOf_VertexAttrib1f_x_not_8); + +struct VertexAttrib1fv { + typedef VertexAttrib1fv ValueType; + static const CommandId kCmdId = kVertexAttrib1fv; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLuint _indx, uint32 _values_shm_id, uint32 _values_shm_offset) { + SetHeader(); + indx = _indx; + values_shm_id = _values_shm_id; + values_shm_offset = _values_shm_offset; + } + + void* Set( + void* cmd, GLuint _indx, uint32 _values_shm_id, + uint32 _values_shm_offset) { + static_cast<ValueType*>( + cmd)->Init(_indx, _values_shm_id, _values_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 indx; + uint32 values_shm_id; + uint32 values_shm_offset; +}; + +COMPILE_ASSERT(sizeof(VertexAttrib1fv) == 16, + Sizeof_VertexAttrib1fv_is_not_16); +COMPILE_ASSERT(offsetof(VertexAttrib1fv, header) == 0, + OffsetOf_VertexAttrib1fv_header_not_0); +COMPILE_ASSERT(offsetof(VertexAttrib1fv, indx) == 4, + OffsetOf_VertexAttrib1fv_indx_not_4); +COMPILE_ASSERT(offsetof(VertexAttrib1fv, values_shm_id) == 8, + OffsetOf_VertexAttrib1fv_values_shm_id_not_8); +COMPILE_ASSERT(offsetof(VertexAttrib1fv, values_shm_offset) == 12, + OffsetOf_VertexAttrib1fv_values_shm_offset_not_12); + +struct VertexAttrib1fvImmediate { + typedef VertexAttrib1fvImmediate ValueType; + static const CommandId kCmdId = kVertexAttrib1fvImmediate; + static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN; + + static uint32 ComputeDataSize() { + return static_cast<uint32>( + sizeof(GLfloat) * 1); // NOLINT + } + + static uint32 ComputeSize() { + return static_cast<uint32>( + sizeof(ValueType) + ComputeDataSize()); // NOLINT + } + + void SetHeader() { + header.SetCmdByTotalSize<ValueType>(ComputeSize()); + } + + void Init(GLuint _indx, const GLfloat* _values) { + SetHeader(); + indx = _indx; + memcpy(ImmediateDataAddress(this), + _values, ComputeDataSize()); + } + + void* Set(void* cmd, GLuint _indx, const GLfloat* _values) { + static_cast<ValueType*>(cmd)->Init(_indx, _values); + const uint32 size = ComputeSize(); + return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); + } + + command_buffer::CommandHeader header; + uint32 indx; +}; + +COMPILE_ASSERT(sizeof(VertexAttrib1fvImmediate) == 8, + Sizeof_VertexAttrib1fvImmediate_is_not_8); +COMPILE_ASSERT(offsetof(VertexAttrib1fvImmediate, header) == 0, + OffsetOf_VertexAttrib1fvImmediate_header_not_0); +COMPILE_ASSERT(offsetof(VertexAttrib1fvImmediate, indx) == 4, + OffsetOf_VertexAttrib1fvImmediate_indx_not_4); + +struct VertexAttrib2f { + typedef VertexAttrib2f ValueType; + static const CommandId kCmdId = kVertexAttrib2f; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLuint _indx, GLfloat _x, GLfloat _y) { + SetHeader(); + indx = _indx; + x = _x; + y = _y; + } + + void* Set(void* cmd, GLuint _indx, GLfloat _x, GLfloat _y) { + static_cast<ValueType*>(cmd)->Init(_indx, _x, _y); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 indx; + float x; + float y; +}; + +COMPILE_ASSERT(sizeof(VertexAttrib2f) == 16, + Sizeof_VertexAttrib2f_is_not_16); +COMPILE_ASSERT(offsetof(VertexAttrib2f, header) == 0, + OffsetOf_VertexAttrib2f_header_not_0); +COMPILE_ASSERT(offsetof(VertexAttrib2f, indx) == 4, + OffsetOf_VertexAttrib2f_indx_not_4); +COMPILE_ASSERT(offsetof(VertexAttrib2f, x) == 8, + OffsetOf_VertexAttrib2f_x_not_8); +COMPILE_ASSERT(offsetof(VertexAttrib2f, y) == 12, + OffsetOf_VertexAttrib2f_y_not_12); + +struct VertexAttrib2fv { + typedef VertexAttrib2fv ValueType; + static const CommandId kCmdId = kVertexAttrib2fv; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLuint _indx, uint32 _values_shm_id, uint32 _values_shm_offset) { + SetHeader(); + indx = _indx; + values_shm_id = _values_shm_id; + values_shm_offset = _values_shm_offset; + } + + void* Set( + void* cmd, GLuint _indx, uint32 _values_shm_id, + uint32 _values_shm_offset) { + static_cast<ValueType*>( + cmd)->Init(_indx, _values_shm_id, _values_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 indx; + uint32 values_shm_id; + uint32 values_shm_offset; +}; + +COMPILE_ASSERT(sizeof(VertexAttrib2fv) == 16, + Sizeof_VertexAttrib2fv_is_not_16); +COMPILE_ASSERT(offsetof(VertexAttrib2fv, header) == 0, + OffsetOf_VertexAttrib2fv_header_not_0); +COMPILE_ASSERT(offsetof(VertexAttrib2fv, indx) == 4, + OffsetOf_VertexAttrib2fv_indx_not_4); +COMPILE_ASSERT(offsetof(VertexAttrib2fv, values_shm_id) == 8, + OffsetOf_VertexAttrib2fv_values_shm_id_not_8); +COMPILE_ASSERT(offsetof(VertexAttrib2fv, values_shm_offset) == 12, + OffsetOf_VertexAttrib2fv_values_shm_offset_not_12); + +struct VertexAttrib2fvImmediate { + typedef VertexAttrib2fvImmediate ValueType; + static const CommandId kCmdId = kVertexAttrib2fvImmediate; + static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN; + + static uint32 ComputeDataSize() { + return static_cast<uint32>( + sizeof(GLfloat) * 2); // NOLINT + } + + static uint32 ComputeSize() { + return static_cast<uint32>( + sizeof(ValueType) + ComputeDataSize()); // NOLINT + } + + void SetHeader() { + header.SetCmdByTotalSize<ValueType>(ComputeSize()); + } + + void Init(GLuint _indx, const GLfloat* _values) { + SetHeader(); + indx = _indx; + memcpy(ImmediateDataAddress(this), + _values, ComputeDataSize()); + } + + void* Set(void* cmd, GLuint _indx, const GLfloat* _values) { + static_cast<ValueType*>(cmd)->Init(_indx, _values); + const uint32 size = ComputeSize(); + return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); + } + + command_buffer::CommandHeader header; + uint32 indx; +}; + +COMPILE_ASSERT(sizeof(VertexAttrib2fvImmediate) == 8, + Sizeof_VertexAttrib2fvImmediate_is_not_8); +COMPILE_ASSERT(offsetof(VertexAttrib2fvImmediate, header) == 0, + OffsetOf_VertexAttrib2fvImmediate_header_not_0); +COMPILE_ASSERT(offsetof(VertexAttrib2fvImmediate, indx) == 4, + OffsetOf_VertexAttrib2fvImmediate_indx_not_4); + +struct VertexAttrib3f { + typedef VertexAttrib3f ValueType; + static const CommandId kCmdId = kVertexAttrib3f; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLuint _indx, GLfloat _x, GLfloat _y, GLfloat _z) { + SetHeader(); + indx = _indx; + x = _x; + y = _y; + z = _z; + } + + void* Set(void* cmd, GLuint _indx, GLfloat _x, GLfloat _y, GLfloat _z) { + static_cast<ValueType*>(cmd)->Init(_indx, _x, _y, _z); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 indx; + float x; + float y; + float z; +}; + +COMPILE_ASSERT(sizeof(VertexAttrib3f) == 20, + Sizeof_VertexAttrib3f_is_not_20); +COMPILE_ASSERT(offsetof(VertexAttrib3f, header) == 0, + OffsetOf_VertexAttrib3f_header_not_0); +COMPILE_ASSERT(offsetof(VertexAttrib3f, indx) == 4, + OffsetOf_VertexAttrib3f_indx_not_4); +COMPILE_ASSERT(offsetof(VertexAttrib3f, x) == 8, + OffsetOf_VertexAttrib3f_x_not_8); +COMPILE_ASSERT(offsetof(VertexAttrib3f, y) == 12, + OffsetOf_VertexAttrib3f_y_not_12); +COMPILE_ASSERT(offsetof(VertexAttrib3f, z) == 16, + OffsetOf_VertexAttrib3f_z_not_16); + +struct VertexAttrib3fv { + typedef VertexAttrib3fv ValueType; + static const CommandId kCmdId = kVertexAttrib3fv; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLuint _indx, uint32 _values_shm_id, uint32 _values_shm_offset) { + SetHeader(); + indx = _indx; + values_shm_id = _values_shm_id; + values_shm_offset = _values_shm_offset; + } + + void* Set( + void* cmd, GLuint _indx, uint32 _values_shm_id, + uint32 _values_shm_offset) { + static_cast<ValueType*>( + cmd)->Init(_indx, _values_shm_id, _values_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 indx; + uint32 values_shm_id; + uint32 values_shm_offset; +}; + +COMPILE_ASSERT(sizeof(VertexAttrib3fv) == 16, + Sizeof_VertexAttrib3fv_is_not_16); +COMPILE_ASSERT(offsetof(VertexAttrib3fv, header) == 0, + OffsetOf_VertexAttrib3fv_header_not_0); +COMPILE_ASSERT(offsetof(VertexAttrib3fv, indx) == 4, + OffsetOf_VertexAttrib3fv_indx_not_4); +COMPILE_ASSERT(offsetof(VertexAttrib3fv, values_shm_id) == 8, + OffsetOf_VertexAttrib3fv_values_shm_id_not_8); +COMPILE_ASSERT(offsetof(VertexAttrib3fv, values_shm_offset) == 12, + OffsetOf_VertexAttrib3fv_values_shm_offset_not_12); + +struct VertexAttrib3fvImmediate { + typedef VertexAttrib3fvImmediate ValueType; + static const CommandId kCmdId = kVertexAttrib3fvImmediate; + static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN; + + static uint32 ComputeDataSize() { + return static_cast<uint32>( + sizeof(GLfloat) * 3); // NOLINT + } + + static uint32 ComputeSize() { + return static_cast<uint32>( + sizeof(ValueType) + ComputeDataSize()); // NOLINT + } + + void SetHeader() { + header.SetCmdByTotalSize<ValueType>(ComputeSize()); + } + + void Init(GLuint _indx, const GLfloat* _values) { + SetHeader(); + indx = _indx; + memcpy(ImmediateDataAddress(this), + _values, ComputeDataSize()); + } + + void* Set(void* cmd, GLuint _indx, const GLfloat* _values) { + static_cast<ValueType*>(cmd)->Init(_indx, _values); + const uint32 size = ComputeSize(); + return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); + } + + command_buffer::CommandHeader header; + uint32 indx; +}; + +COMPILE_ASSERT(sizeof(VertexAttrib3fvImmediate) == 8, + Sizeof_VertexAttrib3fvImmediate_is_not_8); +COMPILE_ASSERT(offsetof(VertexAttrib3fvImmediate, header) == 0, + OffsetOf_VertexAttrib3fvImmediate_header_not_0); +COMPILE_ASSERT(offsetof(VertexAttrib3fvImmediate, indx) == 4, + OffsetOf_VertexAttrib3fvImmediate_indx_not_4); + +struct VertexAttrib4f { + typedef VertexAttrib4f ValueType; + static const CommandId kCmdId = kVertexAttrib4f; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLuint _indx, GLfloat _x, GLfloat _y, GLfloat _z, GLfloat _w) { + SetHeader(); + indx = _indx; + x = _x; + y = _y; + z = _z; + w = _w; + } + + void* Set( + void* cmd, GLuint _indx, GLfloat _x, GLfloat _y, GLfloat _z, + GLfloat _w) { + static_cast<ValueType*>(cmd)->Init(_indx, _x, _y, _z, _w); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 indx; + float x; + float y; + float z; + float w; +}; + +COMPILE_ASSERT(sizeof(VertexAttrib4f) == 24, + Sizeof_VertexAttrib4f_is_not_24); +COMPILE_ASSERT(offsetof(VertexAttrib4f, header) == 0, + OffsetOf_VertexAttrib4f_header_not_0); +COMPILE_ASSERT(offsetof(VertexAttrib4f, indx) == 4, + OffsetOf_VertexAttrib4f_indx_not_4); +COMPILE_ASSERT(offsetof(VertexAttrib4f, x) == 8, + OffsetOf_VertexAttrib4f_x_not_8); +COMPILE_ASSERT(offsetof(VertexAttrib4f, y) == 12, + OffsetOf_VertexAttrib4f_y_not_12); +COMPILE_ASSERT(offsetof(VertexAttrib4f, z) == 16, + OffsetOf_VertexAttrib4f_z_not_16); +COMPILE_ASSERT(offsetof(VertexAttrib4f, w) == 20, + OffsetOf_VertexAttrib4f_w_not_20); + +struct VertexAttrib4fv { + typedef VertexAttrib4fv ValueType; + static const CommandId kCmdId = kVertexAttrib4fv; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLuint _indx, uint32 _values_shm_id, uint32 _values_shm_offset) { + SetHeader(); + indx = _indx; + values_shm_id = _values_shm_id; + values_shm_offset = _values_shm_offset; + } + + void* Set( + void* cmd, GLuint _indx, uint32 _values_shm_id, + uint32 _values_shm_offset) { + static_cast<ValueType*>( + cmd)->Init(_indx, _values_shm_id, _values_shm_offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 indx; + uint32 values_shm_id; + uint32 values_shm_offset; +}; + +COMPILE_ASSERT(sizeof(VertexAttrib4fv) == 16, + Sizeof_VertexAttrib4fv_is_not_16); +COMPILE_ASSERT(offsetof(VertexAttrib4fv, header) == 0, + OffsetOf_VertexAttrib4fv_header_not_0); +COMPILE_ASSERT(offsetof(VertexAttrib4fv, indx) == 4, + OffsetOf_VertexAttrib4fv_indx_not_4); +COMPILE_ASSERT(offsetof(VertexAttrib4fv, values_shm_id) == 8, + OffsetOf_VertexAttrib4fv_values_shm_id_not_8); +COMPILE_ASSERT(offsetof(VertexAttrib4fv, values_shm_offset) == 12, + OffsetOf_VertexAttrib4fv_values_shm_offset_not_12); + +struct VertexAttrib4fvImmediate { + typedef VertexAttrib4fvImmediate ValueType; + static const CommandId kCmdId = kVertexAttrib4fvImmediate; + static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN; + + static uint32 ComputeDataSize() { + return static_cast<uint32>( + sizeof(GLfloat) * 4); // NOLINT + } + + static uint32 ComputeSize() { + return static_cast<uint32>( + sizeof(ValueType) + ComputeDataSize()); // NOLINT + } + + void SetHeader() { + header.SetCmdByTotalSize<ValueType>(ComputeSize()); + } + + void Init(GLuint _indx, const GLfloat* _values) { + SetHeader(); + indx = _indx; + memcpy(ImmediateDataAddress(this), + _values, ComputeDataSize()); + } + + void* Set(void* cmd, GLuint _indx, const GLfloat* _values) { + static_cast<ValueType*>(cmd)->Init(_indx, _values); + const uint32 size = ComputeSize(); + return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); + } + + command_buffer::CommandHeader header; + uint32 indx; +}; + +COMPILE_ASSERT(sizeof(VertexAttrib4fvImmediate) == 8, + Sizeof_VertexAttrib4fvImmediate_is_not_8); +COMPILE_ASSERT(offsetof(VertexAttrib4fvImmediate, header) == 0, + OffsetOf_VertexAttrib4fvImmediate_header_not_0); +COMPILE_ASSERT(offsetof(VertexAttrib4fvImmediate, indx) == 4, + OffsetOf_VertexAttrib4fvImmediate_indx_not_4); + +struct VertexAttribPointer { + typedef VertexAttribPointer ValueType; + static const CommandId kCmdId = kVertexAttribPointer; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLuint _indx, GLint _size, GLenum _type, GLboolean _normalized, + GLsizei _stride, GLuint _offset) { + SetHeader(); + indx = _indx; + size = _size; + type = _type; + normalized = _normalized; + stride = _stride; + offset = _offset; + } + + void* Set( + void* cmd, GLuint _indx, GLint _size, GLenum _type, GLboolean _normalized, + GLsizei _stride, GLuint _offset) { + static_cast<ValueType*>( + cmd)->Init(_indx, _size, _type, _normalized, _stride, _offset); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 indx; + uint32 size; + uint32 type; + uint32 normalized; + uint32 stride; + uint32 offset; +}; + +COMPILE_ASSERT(sizeof(VertexAttribPointer) == 28, + Sizeof_VertexAttribPointer_is_not_28); +COMPILE_ASSERT(offsetof(VertexAttribPointer, header) == 0, + OffsetOf_VertexAttribPointer_header_not_0); +COMPILE_ASSERT(offsetof(VertexAttribPointer, indx) == 4, + OffsetOf_VertexAttribPointer_indx_not_4); +COMPILE_ASSERT(offsetof(VertexAttribPointer, size) == 8, + OffsetOf_VertexAttribPointer_size_not_8); +COMPILE_ASSERT(offsetof(VertexAttribPointer, type) == 12, + OffsetOf_VertexAttribPointer_type_not_12); +COMPILE_ASSERT(offsetof(VertexAttribPointer, normalized) == 16, + OffsetOf_VertexAttribPointer_normalized_not_16); +COMPILE_ASSERT(offsetof(VertexAttribPointer, stride) == 20, + OffsetOf_VertexAttribPointer_stride_not_20); +COMPILE_ASSERT(offsetof(VertexAttribPointer, offset) == 24, + OffsetOf_VertexAttribPointer_offset_not_24); + +struct Viewport { + typedef Viewport ValueType; + static const CommandId kCmdId = kViewport; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLint _x, GLint _y, GLsizei _width, GLsizei _height) { + SetHeader(); + x = _x; + y = _y; + width = _width; + height = _height; + } + + void* Set(void* cmd, GLint _x, GLint _y, GLsizei _width, GLsizei _height) { + static_cast<ValueType*>(cmd)->Init(_x, _y, _width, _height); + return NextCmdAddress<ValueType>(cmd); + } + + command_buffer::CommandHeader header; + uint32 x; + uint32 y; + uint32 width; + uint32 height; +}; + +COMPILE_ASSERT(sizeof(Viewport) == 20, + Sizeof_Viewport_is_not_20); +COMPILE_ASSERT(offsetof(Viewport, header) == 0, + OffsetOf_Viewport_header_not_0); +COMPILE_ASSERT(offsetof(Viewport, x) == 4, + OffsetOf_Viewport_x_not_4); +COMPILE_ASSERT(offsetof(Viewport, y) == 8, + OffsetOf_Viewport_y_not_8); +COMPILE_ASSERT(offsetof(Viewport, width) == 12, + OffsetOf_Viewport_width_not_12); +COMPILE_ASSERT(offsetof(Viewport, height) == 16, + OffsetOf_Viewport_height_not_16); + +} // namespace gles2 +} // namespace command_buffer + +#pragma pack(pop) + +#endif // O3D_SPUD_O3D_GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_FORMAT_H diff --git a/o3d/gpu/command_buffer/common/gles2_cmd_format_test.cc b/o3d/gpu/command_buffer/common/gles2_cmd_format_test.cc new file mode 100644 index 0000000..ba4c51e --- /dev/null +++ b/o3d/gpu/command_buffer/common/gles2_cmd_format_test.cc @@ -0,0 +1,17 @@ +// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This file contains unit tests for gles2 commmands + +#include "tests/common/win/testing_common.h" +#include "gpu/command_buffer/common/gles2_cmd_format.h" + +namespace command_buffer { +namespace gles2 { + +#include "gpu/command_buffer/common/gles2_cmd_format_test_autogen.h" + +} // namespace gles2 +} // namespace command_buffer + diff --git a/o3d/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h b/o3d/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h new file mode 100644 index 0000000..331efec --- /dev/null +++ b/o3d/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h @@ -0,0 +1,2750 @@ +// This file is auto-generated. DO NOT EDIT! + +// This file contains unit tests for gles2 commmands +// It is included by gles2_cmd_format_test.cc + +TEST(GLES2FormatTest, ActiveTexture) { + ActiveTexture cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLenum>(11)); + EXPECT_EQ(ActiveTexture::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLenum>(11), cmd.texture); +} + +TEST(GLES2FormatTest, AttachShader) { + AttachShader cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11), + static_cast<GLuint>(12)); + EXPECT_EQ(AttachShader::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLuint>(11), cmd.program); + EXPECT_EQ(static_cast<GLuint>(12), cmd.shader); +} + +TEST(GLES2FormatTest, BindAttribLocation) { + BindAttribLocation cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11), + static_cast<GLuint>(12), + static_cast<uint32>(13), + static_cast<uint32>(14), + static_cast<uint32>(15)); + EXPECT_EQ(BindAttribLocation::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLuint>(11), cmd.program); + EXPECT_EQ(static_cast<GLuint>(12), cmd.index); + EXPECT_EQ(static_cast<uint32>(13), cmd.name_shm_id); + EXPECT_EQ(static_cast<uint32>(14), cmd.name_shm_offset); + EXPECT_EQ(static_cast<uint32>(15), cmd.data_size); +} + +TEST(GLES2FormatTest, BindAttribLocationImmediate) { + int8 buf[256] = { 0, }; + BindAttribLocationImmediate& cmd = + *static_cast<BindAttribLocationImmediate*>(static_cast<void*>(&buf)); + static const char* const test_str = "test string"; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11), + static_cast<GLuint>(12), + test_str); + EXPECT_EQ(BindAttribLocationImmediate::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd) + // NOLINT + RoundSizeToMultipleOfEntries(strlen(test_str)), + cmd.header.size * 4); + EXPECT_EQ(static_cast<GLuint>(11), cmd.program); + EXPECT_EQ(static_cast<GLuint>(12), cmd.index); + // TODO(gman): check that string got copied. +} + +TEST(GLES2FormatTest, BindBuffer) { + BindBuffer cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLenum>(11), + static_cast<GLuint>(12)); + EXPECT_EQ(BindBuffer::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLenum>(11), cmd.target); + EXPECT_EQ(static_cast<GLuint>(12), cmd.buffer); +} + +TEST(GLES2FormatTest, BindFramebuffer) { + BindFramebuffer cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLenum>(11), + static_cast<GLuint>(12)); + EXPECT_EQ(BindFramebuffer::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLenum>(11), cmd.target); + EXPECT_EQ(static_cast<GLuint>(12), cmd.framebuffer); +} + +TEST(GLES2FormatTest, BindRenderbuffer) { + BindRenderbuffer cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLenum>(11), + static_cast<GLuint>(12)); + EXPECT_EQ(BindRenderbuffer::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLenum>(11), cmd.target); + EXPECT_EQ(static_cast<GLuint>(12), cmd.renderbuffer); +} + +TEST(GLES2FormatTest, BindTexture) { + BindTexture cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLenum>(11), + static_cast<GLuint>(12)); + EXPECT_EQ(BindTexture::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLenum>(11), cmd.target); + EXPECT_EQ(static_cast<GLuint>(12), cmd.texture); +} + +TEST(GLES2FormatTest, BlendColor) { + BlendColor cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLclampf>(11), + static_cast<GLclampf>(12), + static_cast<GLclampf>(13), + static_cast<GLclampf>(14)); + EXPECT_EQ(BlendColor::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLclampf>(11), cmd.red); + EXPECT_EQ(static_cast<GLclampf>(12), cmd.green); + EXPECT_EQ(static_cast<GLclampf>(13), cmd.blue); + EXPECT_EQ(static_cast<GLclampf>(14), cmd.alpha); +} + +TEST(GLES2FormatTest, BlendEquation) { + BlendEquation cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLenum>(11)); + EXPECT_EQ(BlendEquation::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLenum>(11), cmd.mode); +} + +TEST(GLES2FormatTest, BlendEquationSeparate) { + BlendEquationSeparate cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLenum>(11), + static_cast<GLenum>(12)); + EXPECT_EQ(BlendEquationSeparate::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLenum>(11), cmd.modeRGB); + EXPECT_EQ(static_cast<GLenum>(12), cmd.modeAlpha); +} + +TEST(GLES2FormatTest, BlendFunc) { + BlendFunc cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLenum>(11), + static_cast<GLenum>(12)); + EXPECT_EQ(BlendFunc::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLenum>(11), cmd.sfactor); + EXPECT_EQ(static_cast<GLenum>(12), cmd.dfactor); +} + +TEST(GLES2FormatTest, BlendFuncSeparate) { + BlendFuncSeparate cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLenum>(11), + static_cast<GLenum>(12), + static_cast<GLenum>(13), + static_cast<GLenum>(14)); + EXPECT_EQ(BlendFuncSeparate::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLenum>(11), cmd.srcRGB); + EXPECT_EQ(static_cast<GLenum>(12), cmd.dstRGB); + EXPECT_EQ(static_cast<GLenum>(13), cmd.srcAlpha); + EXPECT_EQ(static_cast<GLenum>(14), cmd.dstAlpha); +} + +TEST(GLES2FormatTest, BufferData) { + BufferData cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLenum>(11), + static_cast<GLsizeiptr>(12), + static_cast<uint32>(13), + static_cast<uint32>(14), + static_cast<GLenum>(15)); + EXPECT_EQ(BufferData::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLenum>(11), cmd.target); + EXPECT_EQ(static_cast<GLsizeiptr>(12), cmd.size); + EXPECT_EQ(static_cast<uint32>(13), cmd.data_shm_id); + EXPECT_EQ(static_cast<uint32>(14), cmd.data_shm_offset); + EXPECT_EQ(static_cast<GLenum>(15), cmd.usage); +} + +// TODO(gman): Implement test for BufferDataImmediate +TEST(GLES2FormatTest, BufferSubData) { + BufferSubData cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLenum>(11), + static_cast<GLintptr>(12), + static_cast<GLsizeiptr>(13), + static_cast<uint32>(14), + static_cast<uint32>(15)); + EXPECT_EQ(BufferSubData::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLenum>(11), cmd.target); + EXPECT_EQ(static_cast<GLintptr>(12), cmd.offset); + EXPECT_EQ(static_cast<GLsizeiptr>(13), cmd.size); + EXPECT_EQ(static_cast<uint32>(14), cmd.data_shm_id); + EXPECT_EQ(static_cast<uint32>(15), cmd.data_shm_offset); +} + +// TODO(gman): Implement test for BufferSubDataImmediate +TEST(GLES2FormatTest, CheckFramebufferStatus) { + CheckFramebufferStatus cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLenum>(11)); + EXPECT_EQ(CheckFramebufferStatus::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLenum>(11), cmd.target); +} + +TEST(GLES2FormatTest, Clear) { + Clear cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLbitfield>(11)); + EXPECT_EQ(Clear::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLbitfield>(11), cmd.mask); +} + +TEST(GLES2FormatTest, ClearColor) { + ClearColor cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLclampf>(11), + static_cast<GLclampf>(12), + static_cast<GLclampf>(13), + static_cast<GLclampf>(14)); + EXPECT_EQ(ClearColor::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLclampf>(11), cmd.red); + EXPECT_EQ(static_cast<GLclampf>(12), cmd.green); + EXPECT_EQ(static_cast<GLclampf>(13), cmd.blue); + EXPECT_EQ(static_cast<GLclampf>(14), cmd.alpha); +} + +TEST(GLES2FormatTest, ClearDepthf) { + ClearDepthf cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLclampf>(11)); + EXPECT_EQ(ClearDepthf::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLclampf>(11), cmd.depth); +} + +TEST(GLES2FormatTest, ClearStencil) { + ClearStencil cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLint>(11)); + EXPECT_EQ(ClearStencil::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLint>(11), cmd.s); +} + +TEST(GLES2FormatTest, ColorMask) { + ColorMask cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLboolean>(11), + static_cast<GLboolean>(12), + static_cast<GLboolean>(13), + static_cast<GLboolean>(14)); + EXPECT_EQ(ColorMask::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLboolean>(11), cmd.red); + EXPECT_EQ(static_cast<GLboolean>(12), cmd.green); + EXPECT_EQ(static_cast<GLboolean>(13), cmd.blue); + EXPECT_EQ(static_cast<GLboolean>(14), cmd.alpha); +} + +TEST(GLES2FormatTest, CompileShader) { + CompileShader cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11)); + EXPECT_EQ(CompileShader::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLuint>(11), cmd.shader); +} + +TEST(GLES2FormatTest, CompressedTexImage2D) { + CompressedTexImage2D cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLenum>(11), + static_cast<GLint>(12), + static_cast<GLenum>(13), + static_cast<GLsizei>(14), + static_cast<GLsizei>(15), + static_cast<GLint>(16), + static_cast<GLsizei>(17), + static_cast<uint32>(18), + static_cast<uint32>(19)); + EXPECT_EQ(CompressedTexImage2D::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLenum>(11), cmd.target); + EXPECT_EQ(static_cast<GLint>(12), cmd.level); + EXPECT_EQ(static_cast<GLenum>(13), cmd.internalformat); + EXPECT_EQ(static_cast<GLsizei>(14), cmd.width); + EXPECT_EQ(static_cast<GLsizei>(15), cmd.height); + EXPECT_EQ(static_cast<GLint>(16), cmd.border); + EXPECT_EQ(static_cast<GLsizei>(17), cmd.imageSize); + EXPECT_EQ(static_cast<uint32>(18), cmd.data_shm_id); + EXPECT_EQ(static_cast<uint32>(19), cmd.data_shm_offset); +} + +// TODO(gman): Implement test for CompressedTexImage2DImmediate +TEST(GLES2FormatTest, CompressedTexSubImage2D) { + CompressedTexSubImage2D cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLenum>(11), + static_cast<GLint>(12), + static_cast<GLint>(13), + static_cast<GLint>(14), + static_cast<GLsizei>(15), + static_cast<GLsizei>(16), + static_cast<GLenum>(17), + static_cast<GLsizei>(18), + static_cast<uint32>(19), + static_cast<uint32>(20)); + EXPECT_EQ(CompressedTexSubImage2D::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLenum>(11), cmd.target); + EXPECT_EQ(static_cast<GLint>(12), cmd.level); + EXPECT_EQ(static_cast<GLint>(13), cmd.xoffset); + EXPECT_EQ(static_cast<GLint>(14), cmd.yoffset); + EXPECT_EQ(static_cast<GLsizei>(15), cmd.width); + EXPECT_EQ(static_cast<GLsizei>(16), cmd.height); + EXPECT_EQ(static_cast<GLenum>(17), cmd.format); + EXPECT_EQ(static_cast<GLsizei>(18), cmd.imageSize); + EXPECT_EQ(static_cast<uint32>(19), cmd.data_shm_id); + EXPECT_EQ(static_cast<uint32>(20), cmd.data_shm_offset); +} + +// TODO(gman): Implement test for CompressedTexSubImage2DImmediate +TEST(GLES2FormatTest, CopyTexImage2D) { + CopyTexImage2D cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLenum>(11), + static_cast<GLint>(12), + static_cast<GLenum>(13), + static_cast<GLint>(14), + static_cast<GLint>(15), + static_cast<GLsizei>(16), + static_cast<GLsizei>(17), + static_cast<GLint>(18)); + EXPECT_EQ(CopyTexImage2D::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLenum>(11), cmd.target); + EXPECT_EQ(static_cast<GLint>(12), cmd.level); + EXPECT_EQ(static_cast<GLenum>(13), cmd.internalformat); + EXPECT_EQ(static_cast<GLint>(14), cmd.x); + EXPECT_EQ(static_cast<GLint>(15), cmd.y); + EXPECT_EQ(static_cast<GLsizei>(16), cmd.width); + EXPECT_EQ(static_cast<GLsizei>(17), cmd.height); + EXPECT_EQ(static_cast<GLint>(18), cmd.border); +} + +TEST(GLES2FormatTest, CopyTexSubImage2D) { + CopyTexSubImage2D cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLenum>(11), + static_cast<GLint>(12), + static_cast<GLint>(13), + static_cast<GLint>(14), + static_cast<GLint>(15), + static_cast<GLint>(16), + static_cast<GLsizei>(17), + static_cast<GLsizei>(18)); + EXPECT_EQ(CopyTexSubImage2D::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLenum>(11), cmd.target); + EXPECT_EQ(static_cast<GLint>(12), cmd.level); + EXPECT_EQ(static_cast<GLint>(13), cmd.xoffset); + EXPECT_EQ(static_cast<GLint>(14), cmd.yoffset); + EXPECT_EQ(static_cast<GLint>(15), cmd.x); + EXPECT_EQ(static_cast<GLint>(16), cmd.y); + EXPECT_EQ(static_cast<GLsizei>(17), cmd.width); + EXPECT_EQ(static_cast<GLsizei>(18), cmd.height); +} + +TEST(GLES2FormatTest, CreateProgram) { + CreateProgram cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<uint32>(11)); + EXPECT_EQ(CreateProgram::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<uint32>(11), cmd.client_id); +} + +TEST(GLES2FormatTest, CreateShader) { + CreateShader cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLenum>(11), + static_cast<uint32>(12)); + EXPECT_EQ(CreateShader::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLenum>(11), cmd.type); + EXPECT_EQ(static_cast<uint32>(12), cmd.client_id); +} + +TEST(GLES2FormatTest, CullFace) { + CullFace cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLenum>(11)); + EXPECT_EQ(CullFace::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLenum>(11), cmd.mode); +} + +TEST(GLES2FormatTest, DeleteBuffers) { + DeleteBuffers cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLsizei>(11), + static_cast<uint32>(12), + static_cast<uint32>(13)); + EXPECT_EQ(DeleteBuffers::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLsizei>(11), cmd.n); + EXPECT_EQ(static_cast<uint32>(12), cmd.buffers_shm_id); + EXPECT_EQ(static_cast<uint32>(13), cmd.buffers_shm_offset); +} + +TEST(GLES2FormatTest, DeleteBuffersImmediate) { + static GLuint ids[] = { 12, 23, 34, }; + int8 buf[256] = { 0, }; + DeleteBuffersImmediate& cmd = + *static_cast<DeleteBuffersImmediate*>(static_cast<void*>(&buf)); + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLsizei>(11), + ids); + EXPECT_EQ(DeleteBuffersImmediate::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd) + + RoundSizeToMultipleOfEntries(cmd.n * 4), + cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLsizei>(11), cmd.n); + // TODO(gman): Check that ids were inserted; +} + +TEST(GLES2FormatTest, DeleteFramebuffers) { + DeleteFramebuffers cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLsizei>(11), + static_cast<uint32>(12), + static_cast<uint32>(13)); + EXPECT_EQ(DeleteFramebuffers::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLsizei>(11), cmd.n); + EXPECT_EQ(static_cast<uint32>(12), cmd.framebuffers_shm_id); + EXPECT_EQ(static_cast<uint32>(13), cmd.framebuffers_shm_offset); +} + +TEST(GLES2FormatTest, DeleteFramebuffersImmediate) { + static GLuint ids[] = { 12, 23, 34, }; + int8 buf[256] = { 0, }; + DeleteFramebuffersImmediate& cmd = + *static_cast<DeleteFramebuffersImmediate*>(static_cast<void*>(&buf)); + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLsizei>(11), + ids); + EXPECT_EQ(DeleteFramebuffersImmediate::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd) + + RoundSizeToMultipleOfEntries(cmd.n * 4), + cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLsizei>(11), cmd.n); + // TODO(gman): Check that ids were inserted; +} + +TEST(GLES2FormatTest, DeleteProgram) { + DeleteProgram cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11)); + EXPECT_EQ(DeleteProgram::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLuint>(11), cmd.program); +} + +TEST(GLES2FormatTest, DeleteRenderbuffers) { + DeleteRenderbuffers cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLsizei>(11), + static_cast<uint32>(12), + static_cast<uint32>(13)); + EXPECT_EQ(DeleteRenderbuffers::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLsizei>(11), cmd.n); + EXPECT_EQ(static_cast<uint32>(12), cmd.renderbuffers_shm_id); + EXPECT_EQ(static_cast<uint32>(13), cmd.renderbuffers_shm_offset); +} + +TEST(GLES2FormatTest, DeleteRenderbuffersImmediate) { + static GLuint ids[] = { 12, 23, 34, }; + int8 buf[256] = { 0, }; + DeleteRenderbuffersImmediate& cmd = + *static_cast<DeleteRenderbuffersImmediate*>(static_cast<void*>(&buf)); + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLsizei>(11), + ids); + EXPECT_EQ(DeleteRenderbuffersImmediate::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd) + + RoundSizeToMultipleOfEntries(cmd.n * 4), + cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLsizei>(11), cmd.n); + // TODO(gman): Check that ids were inserted; +} + +TEST(GLES2FormatTest, DeleteShader) { + DeleteShader cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11)); + EXPECT_EQ(DeleteShader::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLuint>(11), cmd.shader); +} + +TEST(GLES2FormatTest, DeleteTextures) { + DeleteTextures cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLsizei>(11), + static_cast<uint32>(12), + static_cast<uint32>(13)); + EXPECT_EQ(DeleteTextures::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLsizei>(11), cmd.n); + EXPECT_EQ(static_cast<uint32>(12), cmd.textures_shm_id); + EXPECT_EQ(static_cast<uint32>(13), cmd.textures_shm_offset); +} + +TEST(GLES2FormatTest, DeleteTexturesImmediate) { + static GLuint ids[] = { 12, 23, 34, }; + int8 buf[256] = { 0, }; + DeleteTexturesImmediate& cmd = + *static_cast<DeleteTexturesImmediate*>(static_cast<void*>(&buf)); + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLsizei>(11), + ids); + EXPECT_EQ(DeleteTexturesImmediate::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd) + + RoundSizeToMultipleOfEntries(cmd.n * 4), + cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLsizei>(11), cmd.n); + // TODO(gman): Check that ids were inserted; +} + +TEST(GLES2FormatTest, DepthFunc) { + DepthFunc cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLenum>(11)); + EXPECT_EQ(DepthFunc::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLenum>(11), cmd.func); +} + +TEST(GLES2FormatTest, DepthMask) { + DepthMask cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLboolean>(11)); + EXPECT_EQ(DepthMask::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLboolean>(11), cmd.flag); +} + +TEST(GLES2FormatTest, DepthRangef) { + DepthRangef cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLclampf>(11), + static_cast<GLclampf>(12)); + EXPECT_EQ(DepthRangef::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLclampf>(11), cmd.zNear); + EXPECT_EQ(static_cast<GLclampf>(12), cmd.zFar); +} + +TEST(GLES2FormatTest, DetachShader) { + DetachShader cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11), + static_cast<GLuint>(12)); + EXPECT_EQ(DetachShader::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLuint>(11), cmd.program); + EXPECT_EQ(static_cast<GLuint>(12), cmd.shader); +} + +TEST(GLES2FormatTest, Disable) { + Disable cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLenum>(11)); + EXPECT_EQ(Disable::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLenum>(11), cmd.cap); +} + +TEST(GLES2FormatTest, DisableVertexAttribArray) { + DisableVertexAttribArray cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11)); + EXPECT_EQ(DisableVertexAttribArray::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLuint>(11), cmd.index); +} + +TEST(GLES2FormatTest, DrawArrays) { + DrawArrays cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLenum>(11), + static_cast<GLint>(12), + static_cast<GLsizei>(13)); + EXPECT_EQ(DrawArrays::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLenum>(11), cmd.mode); + EXPECT_EQ(static_cast<GLint>(12), cmd.first); + EXPECT_EQ(static_cast<GLsizei>(13), cmd.count); +} + +TEST(GLES2FormatTest, DrawElements) { + DrawElements cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLenum>(11), + static_cast<GLsizei>(12), + static_cast<GLenum>(13), + static_cast<GLuint>(14)); + EXPECT_EQ(DrawElements::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLenum>(11), cmd.mode); + EXPECT_EQ(static_cast<GLsizei>(12), cmd.count); + EXPECT_EQ(static_cast<GLenum>(13), cmd.type); + EXPECT_EQ(static_cast<GLuint>(14), cmd.index_offset); +} + +TEST(GLES2FormatTest, Enable) { + Enable cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLenum>(11)); + EXPECT_EQ(Enable::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLenum>(11), cmd.cap); +} + +TEST(GLES2FormatTest, EnableVertexAttribArray) { + EnableVertexAttribArray cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11)); + EXPECT_EQ(EnableVertexAttribArray::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLuint>(11), cmd.index); +} + +TEST(GLES2FormatTest, Finish) { + Finish cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd); + EXPECT_EQ(Finish::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT +} + +TEST(GLES2FormatTest, Flush) { + Flush cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd); + EXPECT_EQ(Flush::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT +} + +TEST(GLES2FormatTest, FramebufferRenderbuffer) { + FramebufferRenderbuffer cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLenum>(11), + static_cast<GLenum>(12), + static_cast<GLenum>(13), + static_cast<GLuint>(14)); + EXPECT_EQ(FramebufferRenderbuffer::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLenum>(11), cmd.target); + EXPECT_EQ(static_cast<GLenum>(12), cmd.attachment); + EXPECT_EQ(static_cast<GLenum>(13), cmd.renderbuffertarget); + EXPECT_EQ(static_cast<GLuint>(14), cmd.renderbuffer); +} + +TEST(GLES2FormatTest, FramebufferTexture2D) { + FramebufferTexture2D cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLenum>(11), + static_cast<GLenum>(12), + static_cast<GLenum>(13), + static_cast<GLuint>(14), + static_cast<GLint>(15)); + EXPECT_EQ(FramebufferTexture2D::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLenum>(11), cmd.target); + EXPECT_EQ(static_cast<GLenum>(12), cmd.attachment); + EXPECT_EQ(static_cast<GLenum>(13), cmd.textarget); + EXPECT_EQ(static_cast<GLuint>(14), cmd.texture); + EXPECT_EQ(static_cast<GLint>(15), cmd.level); +} + +TEST(GLES2FormatTest, FrontFace) { + FrontFace cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLenum>(11)); + EXPECT_EQ(FrontFace::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLenum>(11), cmd.mode); +} + +TEST(GLES2FormatTest, GenBuffers) { + GenBuffers cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLsizei>(11), + static_cast<uint32>(12), + static_cast<uint32>(13)); + EXPECT_EQ(GenBuffers::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLsizei>(11), cmd.n); + EXPECT_EQ(static_cast<uint32>(12), cmd.buffers_shm_id); + EXPECT_EQ(static_cast<uint32>(13), cmd.buffers_shm_offset); +} + +TEST(GLES2FormatTest, GenBuffersImmediate) { + static GLuint ids[] = { 12, 23, 34, }; + int8 buf[256] = { 0, }; + GenBuffersImmediate& cmd = + *static_cast<GenBuffersImmediate*>(static_cast<void*>(&buf)); + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLsizei>(11), + ids); + EXPECT_EQ(GenBuffersImmediate::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd) + + RoundSizeToMultipleOfEntries(cmd.n * 4), + cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLsizei>(11), cmd.n); + // TODO(gman): Check that ids were inserted; +} + +TEST(GLES2FormatTest, GenerateMipmap) { + GenerateMipmap cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLenum>(11)); + EXPECT_EQ(GenerateMipmap::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLenum>(11), cmd.target); +} + +TEST(GLES2FormatTest, GenFramebuffers) { + GenFramebuffers cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLsizei>(11), + static_cast<uint32>(12), + static_cast<uint32>(13)); + EXPECT_EQ(GenFramebuffers::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLsizei>(11), cmd.n); + EXPECT_EQ(static_cast<uint32>(12), cmd.framebuffers_shm_id); + EXPECT_EQ(static_cast<uint32>(13), cmd.framebuffers_shm_offset); +} + +TEST(GLES2FormatTest, GenFramebuffersImmediate) { + static GLuint ids[] = { 12, 23, 34, }; + int8 buf[256] = { 0, }; + GenFramebuffersImmediate& cmd = + *static_cast<GenFramebuffersImmediate*>(static_cast<void*>(&buf)); + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLsizei>(11), + ids); + EXPECT_EQ(GenFramebuffersImmediate::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd) + + RoundSizeToMultipleOfEntries(cmd.n * 4), + cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLsizei>(11), cmd.n); + // TODO(gman): Check that ids were inserted; +} + +TEST(GLES2FormatTest, GenRenderbuffers) { + GenRenderbuffers cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLsizei>(11), + static_cast<uint32>(12), + static_cast<uint32>(13)); + EXPECT_EQ(GenRenderbuffers::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLsizei>(11), cmd.n); + EXPECT_EQ(static_cast<uint32>(12), cmd.renderbuffers_shm_id); + EXPECT_EQ(static_cast<uint32>(13), cmd.renderbuffers_shm_offset); +} + +TEST(GLES2FormatTest, GenRenderbuffersImmediate) { + static GLuint ids[] = { 12, 23, 34, }; + int8 buf[256] = { 0, }; + GenRenderbuffersImmediate& cmd = + *static_cast<GenRenderbuffersImmediate*>(static_cast<void*>(&buf)); + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLsizei>(11), + ids); + EXPECT_EQ(GenRenderbuffersImmediate::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd) + + RoundSizeToMultipleOfEntries(cmd.n * 4), + cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLsizei>(11), cmd.n); + // TODO(gman): Check that ids were inserted; +} + +TEST(GLES2FormatTest, GenTextures) { + GenTextures cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLsizei>(11), + static_cast<uint32>(12), + static_cast<uint32>(13)); + EXPECT_EQ(GenTextures::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLsizei>(11), cmd.n); + EXPECT_EQ(static_cast<uint32>(12), cmd.textures_shm_id); + EXPECT_EQ(static_cast<uint32>(13), cmd.textures_shm_offset); +} + +TEST(GLES2FormatTest, GenTexturesImmediate) { + static GLuint ids[] = { 12, 23, 34, }; + int8 buf[256] = { 0, }; + GenTexturesImmediate& cmd = + *static_cast<GenTexturesImmediate*>(static_cast<void*>(&buf)); + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLsizei>(11), + ids); + EXPECT_EQ(GenTexturesImmediate::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd) + + RoundSizeToMultipleOfEntries(cmd.n * 4), + cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLsizei>(11), cmd.n); + // TODO(gman): Check that ids were inserted; +} + +TEST(GLES2FormatTest, GetActiveAttrib) { + GetActiveAttrib cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11), + static_cast<GLuint>(12), + static_cast<GLsizei>(13), + static_cast<uint32>(14), + static_cast<uint32>(15), + static_cast<uint32>(16), + static_cast<uint32>(17), + static_cast<uint32>(18), + static_cast<uint32>(19), + static_cast<uint32>(20), + static_cast<uint32>(21)); + EXPECT_EQ(GetActiveAttrib::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLuint>(11), cmd.program); + EXPECT_EQ(static_cast<GLuint>(12), cmd.index); + EXPECT_EQ(static_cast<GLsizei>(13), cmd.bufsize); + EXPECT_EQ(static_cast<uint32>(14), cmd.length_shm_id); + EXPECT_EQ(static_cast<uint32>(15), cmd.length_shm_offset); + EXPECT_EQ(static_cast<uint32>(16), cmd.size_shm_id); + EXPECT_EQ(static_cast<uint32>(17), cmd.size_shm_offset); + EXPECT_EQ(static_cast<uint32>(18), cmd.type_shm_id); + EXPECT_EQ(static_cast<uint32>(19), cmd.type_shm_offset); + EXPECT_EQ(static_cast<uint32>(20), cmd.name_shm_id); + EXPECT_EQ(static_cast<uint32>(21), cmd.name_shm_offset); +} + +TEST(GLES2FormatTest, GetActiveUniform) { + GetActiveUniform cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11), + static_cast<GLuint>(12), + static_cast<GLsizei>(13), + static_cast<uint32>(14), + static_cast<uint32>(15), + static_cast<uint32>(16), + static_cast<uint32>(17), + static_cast<uint32>(18), + static_cast<uint32>(19), + static_cast<uint32>(20), + static_cast<uint32>(21)); + EXPECT_EQ(GetActiveUniform::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLuint>(11), cmd.program); + EXPECT_EQ(static_cast<GLuint>(12), cmd.index); + EXPECT_EQ(static_cast<GLsizei>(13), cmd.bufsize); + EXPECT_EQ(static_cast<uint32>(14), cmd.length_shm_id); + EXPECT_EQ(static_cast<uint32>(15), cmd.length_shm_offset); + EXPECT_EQ(static_cast<uint32>(16), cmd.size_shm_id); + EXPECT_EQ(static_cast<uint32>(17), cmd.size_shm_offset); + EXPECT_EQ(static_cast<uint32>(18), cmd.type_shm_id); + EXPECT_EQ(static_cast<uint32>(19), cmd.type_shm_offset); + EXPECT_EQ(static_cast<uint32>(20), cmd.name_shm_id); + EXPECT_EQ(static_cast<uint32>(21), cmd.name_shm_offset); +} + +TEST(GLES2FormatTest, GetAttachedShaders) { + GetAttachedShaders cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11), + static_cast<GLsizei>(12), + static_cast<uint32>(13), + static_cast<uint32>(14), + static_cast<uint32>(15), + static_cast<uint32>(16)); + EXPECT_EQ(GetAttachedShaders::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLuint>(11), cmd.program); + EXPECT_EQ(static_cast<GLsizei>(12), cmd.maxcount); + EXPECT_EQ(static_cast<uint32>(13), cmd.count_shm_id); + EXPECT_EQ(static_cast<uint32>(14), cmd.count_shm_offset); + EXPECT_EQ(static_cast<uint32>(15), cmd.shaders_shm_id); + EXPECT_EQ(static_cast<uint32>(16), cmd.shaders_shm_offset); +} + +TEST(GLES2FormatTest, GetAttribLocation) { + GetAttribLocation cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11), + static_cast<uint32>(12), + static_cast<uint32>(13), + static_cast<uint32>(14)); + EXPECT_EQ(GetAttribLocation::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLuint>(11), cmd.program); + EXPECT_EQ(static_cast<uint32>(12), cmd.name_shm_id); + EXPECT_EQ(static_cast<uint32>(13), cmd.name_shm_offset); + EXPECT_EQ(static_cast<uint32>(14), cmd.data_size); +} + +TEST(GLES2FormatTest, GetAttribLocationImmediate) { + int8 buf[256] = { 0, }; + GetAttribLocationImmediate& cmd = + *static_cast<GetAttribLocationImmediate*>(static_cast<void*>(&buf)); + static const char* const test_str = "test string"; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11), + test_str); + EXPECT_EQ(GetAttribLocationImmediate::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd) + // NOLINT + RoundSizeToMultipleOfEntries(strlen(test_str)), + cmd.header.size * 4); + EXPECT_EQ(static_cast<GLuint>(11), cmd.program); + // TODO(gman): check that string got copied. +} + +TEST(GLES2FormatTest, GetBooleanv) { + GetBooleanv cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLenum>(11), + static_cast<uint32>(12), + static_cast<uint32>(13)); + EXPECT_EQ(GetBooleanv::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLenum>(11), cmd.pname); + EXPECT_EQ(static_cast<uint32>(12), cmd.params_shm_id); + EXPECT_EQ(static_cast<uint32>(13), cmd.params_shm_offset); +} + +TEST(GLES2FormatTest, GetBufferParameteriv) { + GetBufferParameteriv cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLenum>(11), + static_cast<GLenum>(12), + static_cast<uint32>(13), + static_cast<uint32>(14)); + EXPECT_EQ(GetBufferParameteriv::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLenum>(11), cmd.target); + EXPECT_EQ(static_cast<GLenum>(12), cmd.pname); + EXPECT_EQ(static_cast<uint32>(13), cmd.params_shm_id); + EXPECT_EQ(static_cast<uint32>(14), cmd.params_shm_offset); +} + +TEST(GLES2FormatTest, GetError) { + GetError cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<uint32>(11), + static_cast<uint32>(12)); + EXPECT_EQ(GetError::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<uint32>(11), cmd.result_shm_id); + EXPECT_EQ(static_cast<uint32>(12), cmd.result_shm_offset); +} + +TEST(GLES2FormatTest, GetFloatv) { + GetFloatv cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLenum>(11), + static_cast<uint32>(12), + static_cast<uint32>(13)); + EXPECT_EQ(GetFloatv::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLenum>(11), cmd.pname); + EXPECT_EQ(static_cast<uint32>(12), cmd.params_shm_id); + EXPECT_EQ(static_cast<uint32>(13), cmd.params_shm_offset); +} + +TEST(GLES2FormatTest, GetFramebufferAttachmentParameteriv) { + GetFramebufferAttachmentParameteriv cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLenum>(11), + static_cast<GLenum>(12), + static_cast<GLenum>(13), + static_cast<uint32>(14), + static_cast<uint32>(15)); + EXPECT_EQ(GetFramebufferAttachmentParameteriv::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLenum>(11), cmd.target); + EXPECT_EQ(static_cast<GLenum>(12), cmd.attachment); + EXPECT_EQ(static_cast<GLenum>(13), cmd.pname); + EXPECT_EQ(static_cast<uint32>(14), cmd.params_shm_id); + EXPECT_EQ(static_cast<uint32>(15), cmd.params_shm_offset); +} + +TEST(GLES2FormatTest, GetIntegerv) { + GetIntegerv cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLenum>(11), + static_cast<uint32>(12), + static_cast<uint32>(13)); + EXPECT_EQ(GetIntegerv::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLenum>(11), cmd.pname); + EXPECT_EQ(static_cast<uint32>(12), cmd.params_shm_id); + EXPECT_EQ(static_cast<uint32>(13), cmd.params_shm_offset); +} + +TEST(GLES2FormatTest, GetProgramiv) { + GetProgramiv cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11), + static_cast<GLenum>(12), + static_cast<uint32>(13), + static_cast<uint32>(14)); + EXPECT_EQ(GetProgramiv::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLuint>(11), cmd.program); + EXPECT_EQ(static_cast<GLenum>(12), cmd.pname); + EXPECT_EQ(static_cast<uint32>(13), cmd.params_shm_id); + EXPECT_EQ(static_cast<uint32>(14), cmd.params_shm_offset); +} + +TEST(GLES2FormatTest, GetProgramInfoLog) { + GetProgramInfoLog cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11), + static_cast<GLsizei>(12), + static_cast<uint32>(13), + static_cast<uint32>(14), + static_cast<uint32>(15), + static_cast<uint32>(16)); + EXPECT_EQ(GetProgramInfoLog::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLuint>(11), cmd.program); + EXPECT_EQ(static_cast<GLsizei>(12), cmd.bufsize); + EXPECT_EQ(static_cast<uint32>(13), cmd.length_shm_id); + EXPECT_EQ(static_cast<uint32>(14), cmd.length_shm_offset); + EXPECT_EQ(static_cast<uint32>(15), cmd.infolog_shm_id); + EXPECT_EQ(static_cast<uint32>(16), cmd.infolog_shm_offset); +} + +TEST(GLES2FormatTest, GetRenderbufferParameteriv) { + GetRenderbufferParameteriv cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLenum>(11), + static_cast<GLenum>(12), + static_cast<uint32>(13), + static_cast<uint32>(14)); + EXPECT_EQ(GetRenderbufferParameteriv::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLenum>(11), cmd.target); + EXPECT_EQ(static_cast<GLenum>(12), cmd.pname); + EXPECT_EQ(static_cast<uint32>(13), cmd.params_shm_id); + EXPECT_EQ(static_cast<uint32>(14), cmd.params_shm_offset); +} + +TEST(GLES2FormatTest, GetShaderiv) { + GetShaderiv cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11), + static_cast<GLenum>(12), + static_cast<uint32>(13), + static_cast<uint32>(14)); + EXPECT_EQ(GetShaderiv::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLuint>(11), cmd.shader); + EXPECT_EQ(static_cast<GLenum>(12), cmd.pname); + EXPECT_EQ(static_cast<uint32>(13), cmd.params_shm_id); + EXPECT_EQ(static_cast<uint32>(14), cmd.params_shm_offset); +} + +TEST(GLES2FormatTest, GetShaderInfoLog) { + GetShaderInfoLog cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11), + static_cast<GLsizei>(12), + static_cast<uint32>(13), + static_cast<uint32>(14), + static_cast<uint32>(15), + static_cast<uint32>(16)); + EXPECT_EQ(GetShaderInfoLog::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLuint>(11), cmd.shader); + EXPECT_EQ(static_cast<GLsizei>(12), cmd.bufsize); + EXPECT_EQ(static_cast<uint32>(13), cmd.length_shm_id); + EXPECT_EQ(static_cast<uint32>(14), cmd.length_shm_offset); + EXPECT_EQ(static_cast<uint32>(15), cmd.infolog_shm_id); + EXPECT_EQ(static_cast<uint32>(16), cmd.infolog_shm_offset); +} + +TEST(GLES2FormatTest, GetShaderPrecisionFormat) { + GetShaderPrecisionFormat cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLenum>(11), + static_cast<GLenum>(12), + static_cast<uint32>(13), + static_cast<uint32>(14), + static_cast<uint32>(15), + static_cast<uint32>(16)); + EXPECT_EQ(GetShaderPrecisionFormat::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLenum>(11), cmd.shadertype); + EXPECT_EQ(static_cast<GLenum>(12), cmd.precisiontype); + EXPECT_EQ(static_cast<uint32>(13), cmd.range_shm_id); + EXPECT_EQ(static_cast<uint32>(14), cmd.range_shm_offset); + EXPECT_EQ(static_cast<uint32>(15), cmd.precision_shm_id); + EXPECT_EQ(static_cast<uint32>(16), cmd.precision_shm_offset); +} + +TEST(GLES2FormatTest, GetShaderSource) { + GetShaderSource cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11), + static_cast<GLsizei>(12), + static_cast<uint32>(13), + static_cast<uint32>(14), + static_cast<uint32>(15), + static_cast<uint32>(16)); + EXPECT_EQ(GetShaderSource::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLuint>(11), cmd.shader); + EXPECT_EQ(static_cast<GLsizei>(12), cmd.bufsize); + EXPECT_EQ(static_cast<uint32>(13), cmd.length_shm_id); + EXPECT_EQ(static_cast<uint32>(14), cmd.length_shm_offset); + EXPECT_EQ(static_cast<uint32>(15), cmd.source_shm_id); + EXPECT_EQ(static_cast<uint32>(16), cmd.source_shm_offset); +} + +TEST(GLES2FormatTest, GetString) { + GetString cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLenum>(11)); + EXPECT_EQ(GetString::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLenum>(11), cmd.name); +} + +TEST(GLES2FormatTest, GetTexParameterfv) { + GetTexParameterfv cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLenum>(11), + static_cast<GLenum>(12), + static_cast<uint32>(13), + static_cast<uint32>(14)); + EXPECT_EQ(GetTexParameterfv::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLenum>(11), cmd.target); + EXPECT_EQ(static_cast<GLenum>(12), cmd.pname); + EXPECT_EQ(static_cast<uint32>(13), cmd.params_shm_id); + EXPECT_EQ(static_cast<uint32>(14), cmd.params_shm_offset); +} + +TEST(GLES2FormatTest, GetTexParameteriv) { + GetTexParameteriv cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLenum>(11), + static_cast<GLenum>(12), + static_cast<uint32>(13), + static_cast<uint32>(14)); + EXPECT_EQ(GetTexParameteriv::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLenum>(11), cmd.target); + EXPECT_EQ(static_cast<GLenum>(12), cmd.pname); + EXPECT_EQ(static_cast<uint32>(13), cmd.params_shm_id); + EXPECT_EQ(static_cast<uint32>(14), cmd.params_shm_offset); +} + +TEST(GLES2FormatTest, GetUniformfv) { + GetUniformfv cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11), + static_cast<GLint>(12), + static_cast<uint32>(13), + static_cast<uint32>(14)); + EXPECT_EQ(GetUniformfv::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLuint>(11), cmd.program); + EXPECT_EQ(static_cast<GLint>(12), cmd.location); + EXPECT_EQ(static_cast<uint32>(13), cmd.params_shm_id); + EXPECT_EQ(static_cast<uint32>(14), cmd.params_shm_offset); +} + +TEST(GLES2FormatTest, GetUniformiv) { + GetUniformiv cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11), + static_cast<GLint>(12), + static_cast<uint32>(13), + static_cast<uint32>(14)); + EXPECT_EQ(GetUniformiv::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLuint>(11), cmd.program); + EXPECT_EQ(static_cast<GLint>(12), cmd.location); + EXPECT_EQ(static_cast<uint32>(13), cmd.params_shm_id); + EXPECT_EQ(static_cast<uint32>(14), cmd.params_shm_offset); +} + +TEST(GLES2FormatTest, GetUniformLocation) { + GetUniformLocation cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11), + static_cast<uint32>(12), + static_cast<uint32>(13), + static_cast<uint32>(14)); + EXPECT_EQ(GetUniformLocation::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLuint>(11), cmd.program); + EXPECT_EQ(static_cast<uint32>(12), cmd.name_shm_id); + EXPECT_EQ(static_cast<uint32>(13), cmd.name_shm_offset); + EXPECT_EQ(static_cast<uint32>(14), cmd.data_size); +} + +TEST(GLES2FormatTest, GetUniformLocationImmediate) { + int8 buf[256] = { 0, }; + GetUniformLocationImmediate& cmd = + *static_cast<GetUniformLocationImmediate*>(static_cast<void*>(&buf)); + static const char* const test_str = "test string"; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11), + test_str); + EXPECT_EQ(GetUniformLocationImmediate::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd) + // NOLINT + RoundSizeToMultipleOfEntries(strlen(test_str)), + cmd.header.size * 4); + EXPECT_EQ(static_cast<GLuint>(11), cmd.program); + // TODO(gman): check that string got copied. +} + +TEST(GLES2FormatTest, GetVertexAttribfv) { + GetVertexAttribfv cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11), + static_cast<GLenum>(12), + static_cast<uint32>(13), + static_cast<uint32>(14)); + EXPECT_EQ(GetVertexAttribfv::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLuint>(11), cmd.index); + EXPECT_EQ(static_cast<GLenum>(12), cmd.pname); + EXPECT_EQ(static_cast<uint32>(13), cmd.params_shm_id); + EXPECT_EQ(static_cast<uint32>(14), cmd.params_shm_offset); +} + +TEST(GLES2FormatTest, GetVertexAttribiv) { + GetVertexAttribiv cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11), + static_cast<GLenum>(12), + static_cast<uint32>(13), + static_cast<uint32>(14)); + EXPECT_EQ(GetVertexAttribiv::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLuint>(11), cmd.index); + EXPECT_EQ(static_cast<GLenum>(12), cmd.pname); + EXPECT_EQ(static_cast<uint32>(13), cmd.params_shm_id); + EXPECT_EQ(static_cast<uint32>(14), cmd.params_shm_offset); +} + +TEST(GLES2FormatTest, GetVertexAttribPointerv) { + GetVertexAttribPointerv cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11), + static_cast<GLenum>(12), + static_cast<uint32>(13), + static_cast<uint32>(14)); + EXPECT_EQ(GetVertexAttribPointerv::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLuint>(11), cmd.index); + EXPECT_EQ(static_cast<GLenum>(12), cmd.pname); + EXPECT_EQ(static_cast<uint32>(13), cmd.pointer_shm_id); + EXPECT_EQ(static_cast<uint32>(14), cmd.pointer_shm_offset); +} + +TEST(GLES2FormatTest, Hint) { + Hint cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLenum>(11), + static_cast<GLenum>(12)); + EXPECT_EQ(Hint::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLenum>(11), cmd.target); + EXPECT_EQ(static_cast<GLenum>(12), cmd.mode); +} + +TEST(GLES2FormatTest, IsBuffer) { + IsBuffer cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11), + static_cast<uint32>(12), + static_cast<uint32>(13)); + EXPECT_EQ(IsBuffer::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLuint>(11), cmd.buffer); + EXPECT_EQ(static_cast<uint32>(12), cmd.result_shm_id); + EXPECT_EQ(static_cast<uint32>(13), cmd.result_shm_offset); +} + +TEST(GLES2FormatTest, IsEnabled) { + IsEnabled cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLenum>(11), + static_cast<uint32>(12), + static_cast<uint32>(13)); + EXPECT_EQ(IsEnabled::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLenum>(11), cmd.cap); + EXPECT_EQ(static_cast<uint32>(12), cmd.result_shm_id); + EXPECT_EQ(static_cast<uint32>(13), cmd.result_shm_offset); +} + +TEST(GLES2FormatTest, IsFramebuffer) { + IsFramebuffer cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11), + static_cast<uint32>(12), + static_cast<uint32>(13)); + EXPECT_EQ(IsFramebuffer::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLuint>(11), cmd.framebuffer); + EXPECT_EQ(static_cast<uint32>(12), cmd.result_shm_id); + EXPECT_EQ(static_cast<uint32>(13), cmd.result_shm_offset); +} + +TEST(GLES2FormatTest, IsProgram) { + IsProgram cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11), + static_cast<uint32>(12), + static_cast<uint32>(13)); + EXPECT_EQ(IsProgram::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLuint>(11), cmd.program); + EXPECT_EQ(static_cast<uint32>(12), cmd.result_shm_id); + EXPECT_EQ(static_cast<uint32>(13), cmd.result_shm_offset); +} + +TEST(GLES2FormatTest, IsRenderbuffer) { + IsRenderbuffer cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11), + static_cast<uint32>(12), + static_cast<uint32>(13)); + EXPECT_EQ(IsRenderbuffer::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLuint>(11), cmd.renderbuffer); + EXPECT_EQ(static_cast<uint32>(12), cmd.result_shm_id); + EXPECT_EQ(static_cast<uint32>(13), cmd.result_shm_offset); +} + +TEST(GLES2FormatTest, IsShader) { + IsShader cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11), + static_cast<uint32>(12), + static_cast<uint32>(13)); + EXPECT_EQ(IsShader::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLuint>(11), cmd.shader); + EXPECT_EQ(static_cast<uint32>(12), cmd.result_shm_id); + EXPECT_EQ(static_cast<uint32>(13), cmd.result_shm_offset); +} + +TEST(GLES2FormatTest, IsTexture) { + IsTexture cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11), + static_cast<uint32>(12), + static_cast<uint32>(13)); + EXPECT_EQ(IsTexture::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLuint>(11), cmd.texture); + EXPECT_EQ(static_cast<uint32>(12), cmd.result_shm_id); + EXPECT_EQ(static_cast<uint32>(13), cmd.result_shm_offset); +} + +TEST(GLES2FormatTest, LineWidth) { + LineWidth cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLfloat>(11)); + EXPECT_EQ(LineWidth::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLfloat>(11), cmd.width); +} + +TEST(GLES2FormatTest, LinkProgram) { + LinkProgram cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11)); + EXPECT_EQ(LinkProgram::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLuint>(11), cmd.program); +} + +TEST(GLES2FormatTest, PixelStorei) { + PixelStorei cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLenum>(11), + static_cast<GLint>(12)); + EXPECT_EQ(PixelStorei::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLenum>(11), cmd.pname); + EXPECT_EQ(static_cast<GLint>(12), cmd.param); +} + +TEST(GLES2FormatTest, PolygonOffset) { + PolygonOffset cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLfloat>(11), + static_cast<GLfloat>(12)); + EXPECT_EQ(PolygonOffset::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLfloat>(11), cmd.factor); + EXPECT_EQ(static_cast<GLfloat>(12), cmd.units); +} + +TEST(GLES2FormatTest, ReadPixels) { + ReadPixels cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLint>(11), + static_cast<GLint>(12), + static_cast<GLsizei>(13), + static_cast<GLsizei>(14), + static_cast<GLenum>(15), + static_cast<GLenum>(16), + static_cast<uint32>(17), + static_cast<uint32>(18)); + EXPECT_EQ(ReadPixels::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLint>(11), cmd.x); + EXPECT_EQ(static_cast<GLint>(12), cmd.y); + EXPECT_EQ(static_cast<GLsizei>(13), cmd.width); + EXPECT_EQ(static_cast<GLsizei>(14), cmd.height); + EXPECT_EQ(static_cast<GLenum>(15), cmd.format); + EXPECT_EQ(static_cast<GLenum>(16), cmd.type); + EXPECT_EQ(static_cast<uint32>(17), cmd.pixels_shm_id); + EXPECT_EQ(static_cast<uint32>(18), cmd.pixels_shm_offset); +} + +TEST(GLES2FormatTest, RenderbufferStorage) { + RenderbufferStorage cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLenum>(11), + static_cast<GLenum>(12), + static_cast<GLsizei>(13), + static_cast<GLsizei>(14)); + EXPECT_EQ(RenderbufferStorage::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLenum>(11), cmd.target); + EXPECT_EQ(static_cast<GLenum>(12), cmd.internalformat); + EXPECT_EQ(static_cast<GLsizei>(13), cmd.width); + EXPECT_EQ(static_cast<GLsizei>(14), cmd.height); +} + +TEST(GLES2FormatTest, SampleCoverage) { + SampleCoverage cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLclampf>(11), + static_cast<GLboolean>(12)); + EXPECT_EQ(SampleCoverage::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLclampf>(11), cmd.value); + EXPECT_EQ(static_cast<GLboolean>(12), cmd.invert); +} + +TEST(GLES2FormatTest, Scissor) { + Scissor cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLint>(11), + static_cast<GLint>(12), + static_cast<GLsizei>(13), + static_cast<GLsizei>(14)); + EXPECT_EQ(Scissor::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLint>(11), cmd.x); + EXPECT_EQ(static_cast<GLint>(12), cmd.y); + EXPECT_EQ(static_cast<GLsizei>(13), cmd.width); + EXPECT_EQ(static_cast<GLsizei>(14), cmd.height); +} + +TEST(GLES2FormatTest, ShaderSource) { + ShaderSource cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11), + static_cast<GLsizei>(12), + static_cast<uint32>(13), + static_cast<uint32>(14), + static_cast<uint32>(15)); + EXPECT_EQ(ShaderSource::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLuint>(11), cmd.shader); + EXPECT_EQ(static_cast<GLsizei>(12), cmd.count); + EXPECT_EQ(static_cast<uint32>(13), cmd.data_shm_id); + EXPECT_EQ(static_cast<uint32>(14), cmd.data_shm_offset); + EXPECT_EQ(static_cast<uint32>(15), cmd.data_size); +} + +// TODO(gman): Implement test for ShaderSourceImmediate +TEST(GLES2FormatTest, StencilFunc) { + StencilFunc cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLenum>(11), + static_cast<GLint>(12), + static_cast<GLuint>(13)); + EXPECT_EQ(StencilFunc::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLenum>(11), cmd.func); + EXPECT_EQ(static_cast<GLint>(12), cmd.ref); + EXPECT_EQ(static_cast<GLuint>(13), cmd.mask); +} + +TEST(GLES2FormatTest, StencilFuncSeparate) { + StencilFuncSeparate cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLenum>(11), + static_cast<GLenum>(12), + static_cast<GLint>(13), + static_cast<GLuint>(14)); + EXPECT_EQ(StencilFuncSeparate::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLenum>(11), cmd.face); + EXPECT_EQ(static_cast<GLenum>(12), cmd.func); + EXPECT_EQ(static_cast<GLint>(13), cmd.ref); + EXPECT_EQ(static_cast<GLuint>(14), cmd.mask); +} + +TEST(GLES2FormatTest, StencilMask) { + StencilMask cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11)); + EXPECT_EQ(StencilMask::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLuint>(11), cmd.mask); +} + +TEST(GLES2FormatTest, StencilMaskSeparate) { + StencilMaskSeparate cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLenum>(11), + static_cast<GLuint>(12)); + EXPECT_EQ(StencilMaskSeparate::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLenum>(11), cmd.face); + EXPECT_EQ(static_cast<GLuint>(12), cmd.mask); +} + +TEST(GLES2FormatTest, StencilOp) { + StencilOp cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLenum>(11), + static_cast<GLenum>(12), + static_cast<GLenum>(13)); + EXPECT_EQ(StencilOp::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLenum>(11), cmd.fail); + EXPECT_EQ(static_cast<GLenum>(12), cmd.zfail); + EXPECT_EQ(static_cast<GLenum>(13), cmd.zpass); +} + +TEST(GLES2FormatTest, StencilOpSeparate) { + StencilOpSeparate cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLenum>(11), + static_cast<GLenum>(12), + static_cast<GLenum>(13), + static_cast<GLenum>(14)); + EXPECT_EQ(StencilOpSeparate::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLenum>(11), cmd.face); + EXPECT_EQ(static_cast<GLenum>(12), cmd.fail); + EXPECT_EQ(static_cast<GLenum>(13), cmd.zfail); + EXPECT_EQ(static_cast<GLenum>(14), cmd.zpass); +} + +TEST(GLES2FormatTest, TexImage2D) { + TexImage2D cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLenum>(11), + static_cast<GLint>(12), + static_cast<GLint>(13), + static_cast<GLsizei>(14), + static_cast<GLsizei>(15), + static_cast<GLint>(16), + static_cast<GLenum>(17), + static_cast<GLenum>(18), + static_cast<uint32>(19), + static_cast<uint32>(20)); + EXPECT_EQ(TexImage2D::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLenum>(11), cmd.target); + EXPECT_EQ(static_cast<GLint>(12), cmd.level); + EXPECT_EQ(static_cast<GLint>(13), cmd.internalformat); + EXPECT_EQ(static_cast<GLsizei>(14), cmd.width); + EXPECT_EQ(static_cast<GLsizei>(15), cmd.height); + EXPECT_EQ(static_cast<GLint>(16), cmd.border); + EXPECT_EQ(static_cast<GLenum>(17), cmd.format); + EXPECT_EQ(static_cast<GLenum>(18), cmd.type); + EXPECT_EQ(static_cast<uint32>(19), cmd.pixels_shm_id); + EXPECT_EQ(static_cast<uint32>(20), cmd.pixels_shm_offset); +} + +// TODO(gman): Implement test for TexImage2DImmediate +TEST(GLES2FormatTest, TexParameterf) { + TexParameterf cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLenum>(11), + static_cast<GLenum>(12), + static_cast<GLfloat>(13)); + EXPECT_EQ(TexParameterf::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLenum>(11), cmd.target); + EXPECT_EQ(static_cast<GLenum>(12), cmd.pname); + EXPECT_EQ(static_cast<GLfloat>(13), cmd.param); +} + +TEST(GLES2FormatTest, TexParameterfv) { + TexParameterfv cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLenum>(11), + static_cast<GLenum>(12), + static_cast<uint32>(13), + static_cast<uint32>(14)); + EXPECT_EQ(TexParameterfv::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLenum>(11), cmd.target); + EXPECT_EQ(static_cast<GLenum>(12), cmd.pname); + EXPECT_EQ(static_cast<uint32>(13), cmd.params_shm_id); + EXPECT_EQ(static_cast<uint32>(14), cmd.params_shm_offset); +} + +TEST(GLES2FormatTest, TexParameterfvImmediate) { + const int kSomeBaseValueToTestWith = 51; + static GLfloat data[] = { + static_cast<GLfloat>(kSomeBaseValueToTestWith + 0), + }; + int8 buf[256] = { 0, }; + TexParameterfvImmediate& cmd = + *static_cast<TexParameterfvImmediate*>(static_cast<void*>(&buf)); + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLenum>(11), + static_cast<GLenum>(12), + data); + EXPECT_EQ(TexParameterfvImmediate::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd) + + RoundSizeToMultipleOfEntries(sizeof(data)), + cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLenum>(11), cmd.target); + EXPECT_EQ(static_cast<GLenum>(12), cmd.pname); + // TODO(gman): Check that data was inserted; +} + +TEST(GLES2FormatTest, TexParameteri) { + TexParameteri cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLenum>(11), + static_cast<GLenum>(12), + static_cast<GLint>(13)); + EXPECT_EQ(TexParameteri::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLenum>(11), cmd.target); + EXPECT_EQ(static_cast<GLenum>(12), cmd.pname); + EXPECT_EQ(static_cast<GLint>(13), cmd.param); +} + +TEST(GLES2FormatTest, TexParameteriv) { + TexParameteriv cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLenum>(11), + static_cast<GLenum>(12), + static_cast<uint32>(13), + static_cast<uint32>(14)); + EXPECT_EQ(TexParameteriv::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLenum>(11), cmd.target); + EXPECT_EQ(static_cast<GLenum>(12), cmd.pname); + EXPECT_EQ(static_cast<uint32>(13), cmd.params_shm_id); + EXPECT_EQ(static_cast<uint32>(14), cmd.params_shm_offset); +} + +TEST(GLES2FormatTest, TexParameterivImmediate) { + const int kSomeBaseValueToTestWith = 51; + static GLint data[] = { + static_cast<GLint>(kSomeBaseValueToTestWith + 0), + }; + int8 buf[256] = { 0, }; + TexParameterivImmediate& cmd = + *static_cast<TexParameterivImmediate*>(static_cast<void*>(&buf)); + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLenum>(11), + static_cast<GLenum>(12), + data); + EXPECT_EQ(TexParameterivImmediate::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd) + + RoundSizeToMultipleOfEntries(sizeof(data)), + cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLenum>(11), cmd.target); + EXPECT_EQ(static_cast<GLenum>(12), cmd.pname); + // TODO(gman): Check that data was inserted; +} + +TEST(GLES2FormatTest, TexSubImage2D) { + TexSubImage2D cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLenum>(11), + static_cast<GLint>(12), + static_cast<GLint>(13), + static_cast<GLint>(14), + static_cast<GLsizei>(15), + static_cast<GLsizei>(16), + static_cast<GLenum>(17), + static_cast<GLenum>(18), + static_cast<uint32>(19), + static_cast<uint32>(20)); + EXPECT_EQ(TexSubImage2D::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLenum>(11), cmd.target); + EXPECT_EQ(static_cast<GLint>(12), cmd.level); + EXPECT_EQ(static_cast<GLint>(13), cmd.xoffset); + EXPECT_EQ(static_cast<GLint>(14), cmd.yoffset); + EXPECT_EQ(static_cast<GLsizei>(15), cmd.width); + EXPECT_EQ(static_cast<GLsizei>(16), cmd.height); + EXPECT_EQ(static_cast<GLenum>(17), cmd.format); + EXPECT_EQ(static_cast<GLenum>(18), cmd.type); + EXPECT_EQ(static_cast<uint32>(19), cmd.pixels_shm_id); + EXPECT_EQ(static_cast<uint32>(20), cmd.pixels_shm_offset); +} + +// TODO(gman): Implement test for TexSubImage2DImmediate +TEST(GLES2FormatTest, Uniform1f) { + Uniform1f cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLint>(11), + static_cast<GLfloat>(12)); + EXPECT_EQ(Uniform1f::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLint>(11), cmd.location); + EXPECT_EQ(static_cast<GLfloat>(12), cmd.x); +} + +TEST(GLES2FormatTest, Uniform1fv) { + Uniform1fv cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLint>(11), + static_cast<GLsizei>(12), + static_cast<uint32>(13), + static_cast<uint32>(14)); + EXPECT_EQ(Uniform1fv::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLint>(11), cmd.location); + EXPECT_EQ(static_cast<GLsizei>(12), cmd.count); + EXPECT_EQ(static_cast<uint32>(13), cmd.v_shm_id); + EXPECT_EQ(static_cast<uint32>(14), cmd.v_shm_offset); +} + +TEST(GLES2FormatTest, Uniform1fvImmediate) { + const int kSomeBaseValueToTestWith = 51; + static GLfloat data[] = { + static_cast<GLfloat>(kSomeBaseValueToTestWith + 0), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 1), + }; + int8 buf[256] = { 0, }; + Uniform1fvImmediate& cmd = + *static_cast<Uniform1fvImmediate*>(static_cast<void*>(&buf)); + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLint>(1), + static_cast<GLsizei>(2), + data); + EXPECT_EQ(Uniform1fvImmediate::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd) + + RoundSizeToMultipleOfEntries(sizeof(data)), + cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLint>(1), cmd.location); + EXPECT_EQ(static_cast<GLsizei>(2), cmd.count); + // TODO(gman): Check that data was inserted; +} + +TEST(GLES2FormatTest, Uniform1i) { + Uniform1i cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLint>(11), + static_cast<GLint>(12)); + EXPECT_EQ(Uniform1i::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLint>(11), cmd.location); + EXPECT_EQ(static_cast<GLint>(12), cmd.x); +} + +TEST(GLES2FormatTest, Uniform1iv) { + Uniform1iv cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLint>(11), + static_cast<GLsizei>(12), + static_cast<uint32>(13), + static_cast<uint32>(14)); + EXPECT_EQ(Uniform1iv::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLint>(11), cmd.location); + EXPECT_EQ(static_cast<GLsizei>(12), cmd.count); + EXPECT_EQ(static_cast<uint32>(13), cmd.v_shm_id); + EXPECT_EQ(static_cast<uint32>(14), cmd.v_shm_offset); +} + +TEST(GLES2FormatTest, Uniform1ivImmediate) { + const int kSomeBaseValueToTestWith = 51; + static GLint data[] = { + static_cast<GLint>(kSomeBaseValueToTestWith + 0), + static_cast<GLint>(kSomeBaseValueToTestWith + 1), + }; + int8 buf[256] = { 0, }; + Uniform1ivImmediate& cmd = + *static_cast<Uniform1ivImmediate*>(static_cast<void*>(&buf)); + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLint>(1), + static_cast<GLsizei>(2), + data); + EXPECT_EQ(Uniform1ivImmediate::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd) + + RoundSizeToMultipleOfEntries(sizeof(data)), + cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLint>(1), cmd.location); + EXPECT_EQ(static_cast<GLsizei>(2), cmd.count); + // TODO(gman): Check that data was inserted; +} + +TEST(GLES2FormatTest, Uniform2f) { + Uniform2f cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLint>(11), + static_cast<GLfloat>(12), + static_cast<GLfloat>(13)); + EXPECT_EQ(Uniform2f::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLint>(11), cmd.location); + EXPECT_EQ(static_cast<GLfloat>(12), cmd.x); + EXPECT_EQ(static_cast<GLfloat>(13), cmd.y); +} + +TEST(GLES2FormatTest, Uniform2fv) { + Uniform2fv cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLint>(11), + static_cast<GLsizei>(12), + static_cast<uint32>(13), + static_cast<uint32>(14)); + EXPECT_EQ(Uniform2fv::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLint>(11), cmd.location); + EXPECT_EQ(static_cast<GLsizei>(12), cmd.count); + EXPECT_EQ(static_cast<uint32>(13), cmd.v_shm_id); + EXPECT_EQ(static_cast<uint32>(14), cmd.v_shm_offset); +} + +TEST(GLES2FormatTest, Uniform2fvImmediate) { + const int kSomeBaseValueToTestWith = 51; + static GLfloat data[] = { + static_cast<GLfloat>(kSomeBaseValueToTestWith + 0), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 1), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 2), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 3), + }; + int8 buf[256] = { 0, }; + Uniform2fvImmediate& cmd = + *static_cast<Uniform2fvImmediate*>(static_cast<void*>(&buf)); + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLint>(1), + static_cast<GLsizei>(2), + data); + EXPECT_EQ(Uniform2fvImmediate::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd) + + RoundSizeToMultipleOfEntries(sizeof(data)), + cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLint>(1), cmd.location); + EXPECT_EQ(static_cast<GLsizei>(2), cmd.count); + // TODO(gman): Check that data was inserted; +} + +TEST(GLES2FormatTest, Uniform2i) { + Uniform2i cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLint>(11), + static_cast<GLint>(12), + static_cast<GLint>(13)); + EXPECT_EQ(Uniform2i::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLint>(11), cmd.location); + EXPECT_EQ(static_cast<GLint>(12), cmd.x); + EXPECT_EQ(static_cast<GLint>(13), cmd.y); +} + +TEST(GLES2FormatTest, Uniform2iv) { + Uniform2iv cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLint>(11), + static_cast<GLsizei>(12), + static_cast<uint32>(13), + static_cast<uint32>(14)); + EXPECT_EQ(Uniform2iv::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLint>(11), cmd.location); + EXPECT_EQ(static_cast<GLsizei>(12), cmd.count); + EXPECT_EQ(static_cast<uint32>(13), cmd.v_shm_id); + EXPECT_EQ(static_cast<uint32>(14), cmd.v_shm_offset); +} + +TEST(GLES2FormatTest, Uniform2ivImmediate) { + const int kSomeBaseValueToTestWith = 51; + static GLint data[] = { + static_cast<GLint>(kSomeBaseValueToTestWith + 0), + static_cast<GLint>(kSomeBaseValueToTestWith + 1), + static_cast<GLint>(kSomeBaseValueToTestWith + 2), + static_cast<GLint>(kSomeBaseValueToTestWith + 3), + }; + int8 buf[256] = { 0, }; + Uniform2ivImmediate& cmd = + *static_cast<Uniform2ivImmediate*>(static_cast<void*>(&buf)); + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLint>(1), + static_cast<GLsizei>(2), + data); + EXPECT_EQ(Uniform2ivImmediate::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd) + + RoundSizeToMultipleOfEntries(sizeof(data)), + cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLint>(1), cmd.location); + EXPECT_EQ(static_cast<GLsizei>(2), cmd.count); + // TODO(gman): Check that data was inserted; +} + +TEST(GLES2FormatTest, Uniform3f) { + Uniform3f cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLint>(11), + static_cast<GLfloat>(12), + static_cast<GLfloat>(13), + static_cast<GLfloat>(14)); + EXPECT_EQ(Uniform3f::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLint>(11), cmd.location); + EXPECT_EQ(static_cast<GLfloat>(12), cmd.x); + EXPECT_EQ(static_cast<GLfloat>(13), cmd.y); + EXPECT_EQ(static_cast<GLfloat>(14), cmd.z); +} + +TEST(GLES2FormatTest, Uniform3fv) { + Uniform3fv cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLint>(11), + static_cast<GLsizei>(12), + static_cast<uint32>(13), + static_cast<uint32>(14)); + EXPECT_EQ(Uniform3fv::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLint>(11), cmd.location); + EXPECT_EQ(static_cast<GLsizei>(12), cmd.count); + EXPECT_EQ(static_cast<uint32>(13), cmd.v_shm_id); + EXPECT_EQ(static_cast<uint32>(14), cmd.v_shm_offset); +} + +TEST(GLES2FormatTest, Uniform3fvImmediate) { + const int kSomeBaseValueToTestWith = 51; + static GLfloat data[] = { + static_cast<GLfloat>(kSomeBaseValueToTestWith + 0), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 1), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 2), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 3), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 4), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 5), + }; + int8 buf[256] = { 0, }; + Uniform3fvImmediate& cmd = + *static_cast<Uniform3fvImmediate*>(static_cast<void*>(&buf)); + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLint>(1), + static_cast<GLsizei>(2), + data); + EXPECT_EQ(Uniform3fvImmediate::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd) + + RoundSizeToMultipleOfEntries(sizeof(data)), + cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLint>(1), cmd.location); + EXPECT_EQ(static_cast<GLsizei>(2), cmd.count); + // TODO(gman): Check that data was inserted; +} + +TEST(GLES2FormatTest, Uniform3i) { + Uniform3i cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLint>(11), + static_cast<GLint>(12), + static_cast<GLint>(13), + static_cast<GLint>(14)); + EXPECT_EQ(Uniform3i::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLint>(11), cmd.location); + EXPECT_EQ(static_cast<GLint>(12), cmd.x); + EXPECT_EQ(static_cast<GLint>(13), cmd.y); + EXPECT_EQ(static_cast<GLint>(14), cmd.z); +} + +TEST(GLES2FormatTest, Uniform3iv) { + Uniform3iv cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLint>(11), + static_cast<GLsizei>(12), + static_cast<uint32>(13), + static_cast<uint32>(14)); + EXPECT_EQ(Uniform3iv::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLint>(11), cmd.location); + EXPECT_EQ(static_cast<GLsizei>(12), cmd.count); + EXPECT_EQ(static_cast<uint32>(13), cmd.v_shm_id); + EXPECT_EQ(static_cast<uint32>(14), cmd.v_shm_offset); +} + +TEST(GLES2FormatTest, Uniform3ivImmediate) { + const int kSomeBaseValueToTestWith = 51; + static GLint data[] = { + static_cast<GLint>(kSomeBaseValueToTestWith + 0), + static_cast<GLint>(kSomeBaseValueToTestWith + 1), + static_cast<GLint>(kSomeBaseValueToTestWith + 2), + static_cast<GLint>(kSomeBaseValueToTestWith + 3), + static_cast<GLint>(kSomeBaseValueToTestWith + 4), + static_cast<GLint>(kSomeBaseValueToTestWith + 5), + }; + int8 buf[256] = { 0, }; + Uniform3ivImmediate& cmd = + *static_cast<Uniform3ivImmediate*>(static_cast<void*>(&buf)); + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLint>(1), + static_cast<GLsizei>(2), + data); + EXPECT_EQ(Uniform3ivImmediate::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd) + + RoundSizeToMultipleOfEntries(sizeof(data)), + cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLint>(1), cmd.location); + EXPECT_EQ(static_cast<GLsizei>(2), cmd.count); + // TODO(gman): Check that data was inserted; +} + +TEST(GLES2FormatTest, Uniform4f) { + Uniform4f cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLint>(11), + static_cast<GLfloat>(12), + static_cast<GLfloat>(13), + static_cast<GLfloat>(14), + static_cast<GLfloat>(15)); + EXPECT_EQ(Uniform4f::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLint>(11), cmd.location); + EXPECT_EQ(static_cast<GLfloat>(12), cmd.x); + EXPECT_EQ(static_cast<GLfloat>(13), cmd.y); + EXPECT_EQ(static_cast<GLfloat>(14), cmd.z); + EXPECT_EQ(static_cast<GLfloat>(15), cmd.w); +} + +TEST(GLES2FormatTest, Uniform4fv) { + Uniform4fv cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLint>(11), + static_cast<GLsizei>(12), + static_cast<uint32>(13), + static_cast<uint32>(14)); + EXPECT_EQ(Uniform4fv::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLint>(11), cmd.location); + EXPECT_EQ(static_cast<GLsizei>(12), cmd.count); + EXPECT_EQ(static_cast<uint32>(13), cmd.v_shm_id); + EXPECT_EQ(static_cast<uint32>(14), cmd.v_shm_offset); +} + +TEST(GLES2FormatTest, Uniform4fvImmediate) { + const int kSomeBaseValueToTestWith = 51; + static GLfloat data[] = { + static_cast<GLfloat>(kSomeBaseValueToTestWith + 0), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 1), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 2), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 3), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 4), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 5), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 6), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 7), + }; + int8 buf[256] = { 0, }; + Uniform4fvImmediate& cmd = + *static_cast<Uniform4fvImmediate*>(static_cast<void*>(&buf)); + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLint>(1), + static_cast<GLsizei>(2), + data); + EXPECT_EQ(Uniform4fvImmediate::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd) + + RoundSizeToMultipleOfEntries(sizeof(data)), + cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLint>(1), cmd.location); + EXPECT_EQ(static_cast<GLsizei>(2), cmd.count); + // TODO(gman): Check that data was inserted; +} + +TEST(GLES2FormatTest, Uniform4i) { + Uniform4i cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLint>(11), + static_cast<GLint>(12), + static_cast<GLint>(13), + static_cast<GLint>(14), + static_cast<GLint>(15)); + EXPECT_EQ(Uniform4i::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLint>(11), cmd.location); + EXPECT_EQ(static_cast<GLint>(12), cmd.x); + EXPECT_EQ(static_cast<GLint>(13), cmd.y); + EXPECT_EQ(static_cast<GLint>(14), cmd.z); + EXPECT_EQ(static_cast<GLint>(15), cmd.w); +} + +TEST(GLES2FormatTest, Uniform4iv) { + Uniform4iv cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLint>(11), + static_cast<GLsizei>(12), + static_cast<uint32>(13), + static_cast<uint32>(14)); + EXPECT_EQ(Uniform4iv::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLint>(11), cmd.location); + EXPECT_EQ(static_cast<GLsizei>(12), cmd.count); + EXPECT_EQ(static_cast<uint32>(13), cmd.v_shm_id); + EXPECT_EQ(static_cast<uint32>(14), cmd.v_shm_offset); +} + +TEST(GLES2FormatTest, Uniform4ivImmediate) { + const int kSomeBaseValueToTestWith = 51; + static GLint data[] = { + static_cast<GLint>(kSomeBaseValueToTestWith + 0), + static_cast<GLint>(kSomeBaseValueToTestWith + 1), + static_cast<GLint>(kSomeBaseValueToTestWith + 2), + static_cast<GLint>(kSomeBaseValueToTestWith + 3), + static_cast<GLint>(kSomeBaseValueToTestWith + 4), + static_cast<GLint>(kSomeBaseValueToTestWith + 5), + static_cast<GLint>(kSomeBaseValueToTestWith + 6), + static_cast<GLint>(kSomeBaseValueToTestWith + 7), + }; + int8 buf[256] = { 0, }; + Uniform4ivImmediate& cmd = + *static_cast<Uniform4ivImmediate*>(static_cast<void*>(&buf)); + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLint>(1), + static_cast<GLsizei>(2), + data); + EXPECT_EQ(Uniform4ivImmediate::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd) + + RoundSizeToMultipleOfEntries(sizeof(data)), + cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLint>(1), cmd.location); + EXPECT_EQ(static_cast<GLsizei>(2), cmd.count); + // TODO(gman): Check that data was inserted; +} + +TEST(GLES2FormatTest, UniformMatrix2fv) { + UniformMatrix2fv cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLint>(11), + static_cast<GLsizei>(12), + static_cast<GLboolean>(13), + static_cast<uint32>(14), + static_cast<uint32>(15)); + EXPECT_EQ(UniformMatrix2fv::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLint>(11), cmd.location); + EXPECT_EQ(static_cast<GLsizei>(12), cmd.count); + EXPECT_EQ(static_cast<GLboolean>(13), cmd.transpose); + EXPECT_EQ(static_cast<uint32>(14), cmd.value_shm_id); + EXPECT_EQ(static_cast<uint32>(15), cmd.value_shm_offset); +} + +TEST(GLES2FormatTest, UniformMatrix2fvImmediate) { + const int kSomeBaseValueToTestWith = 51; + static GLfloat data[] = { + static_cast<GLfloat>(kSomeBaseValueToTestWith + 0), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 1), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 2), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 3), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 4), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 5), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 6), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 7), + }; + int8 buf[256] = { 0, }; + UniformMatrix2fvImmediate& cmd = + *static_cast<UniformMatrix2fvImmediate*>(static_cast<void*>(&buf)); + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLint>(1), + static_cast<GLsizei>(2), + static_cast<GLboolean>(3), + data); + EXPECT_EQ(UniformMatrix2fvImmediate::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd) + + RoundSizeToMultipleOfEntries(sizeof(data)), + cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLint>(1), cmd.location); + EXPECT_EQ(static_cast<GLsizei>(2), cmd.count); + EXPECT_EQ(static_cast<GLboolean>(3), cmd.transpose); + // TODO(gman): Check that data was inserted; +} + +TEST(GLES2FormatTest, UniformMatrix3fv) { + UniformMatrix3fv cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLint>(11), + static_cast<GLsizei>(12), + static_cast<GLboolean>(13), + static_cast<uint32>(14), + static_cast<uint32>(15)); + EXPECT_EQ(UniformMatrix3fv::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLint>(11), cmd.location); + EXPECT_EQ(static_cast<GLsizei>(12), cmd.count); + EXPECT_EQ(static_cast<GLboolean>(13), cmd.transpose); + EXPECT_EQ(static_cast<uint32>(14), cmd.value_shm_id); + EXPECT_EQ(static_cast<uint32>(15), cmd.value_shm_offset); +} + +TEST(GLES2FormatTest, UniformMatrix3fvImmediate) { + const int kSomeBaseValueToTestWith = 51; + static GLfloat data[] = { + static_cast<GLfloat>(kSomeBaseValueToTestWith + 0), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 1), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 2), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 3), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 4), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 5), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 6), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 7), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 8), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 9), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 10), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 11), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 12), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 13), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 14), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 15), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 16), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 17), + }; + int8 buf[256] = { 0, }; + UniformMatrix3fvImmediate& cmd = + *static_cast<UniformMatrix3fvImmediate*>(static_cast<void*>(&buf)); + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLint>(1), + static_cast<GLsizei>(2), + static_cast<GLboolean>(3), + data); + EXPECT_EQ(UniformMatrix3fvImmediate::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd) + + RoundSizeToMultipleOfEntries(sizeof(data)), + cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLint>(1), cmd.location); + EXPECT_EQ(static_cast<GLsizei>(2), cmd.count); + EXPECT_EQ(static_cast<GLboolean>(3), cmd.transpose); + // TODO(gman): Check that data was inserted; +} + +TEST(GLES2FormatTest, UniformMatrix4fv) { + UniformMatrix4fv cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLint>(11), + static_cast<GLsizei>(12), + static_cast<GLboolean>(13), + static_cast<uint32>(14), + static_cast<uint32>(15)); + EXPECT_EQ(UniformMatrix4fv::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLint>(11), cmd.location); + EXPECT_EQ(static_cast<GLsizei>(12), cmd.count); + EXPECT_EQ(static_cast<GLboolean>(13), cmd.transpose); + EXPECT_EQ(static_cast<uint32>(14), cmd.value_shm_id); + EXPECT_EQ(static_cast<uint32>(15), cmd.value_shm_offset); +} + +TEST(GLES2FormatTest, UniformMatrix4fvImmediate) { + const int kSomeBaseValueToTestWith = 51; + static GLfloat data[] = { + static_cast<GLfloat>(kSomeBaseValueToTestWith + 0), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 1), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 2), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 3), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 4), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 5), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 6), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 7), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 8), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 9), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 10), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 11), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 12), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 13), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 14), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 15), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 16), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 17), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 18), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 19), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 20), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 21), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 22), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 23), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 24), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 25), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 26), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 27), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 28), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 29), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 30), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 31), + }; + int8 buf[256] = { 0, }; + UniformMatrix4fvImmediate& cmd = + *static_cast<UniformMatrix4fvImmediate*>(static_cast<void*>(&buf)); + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLint>(1), + static_cast<GLsizei>(2), + static_cast<GLboolean>(3), + data); + EXPECT_EQ(UniformMatrix4fvImmediate::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd) + + RoundSizeToMultipleOfEntries(sizeof(data)), + cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLint>(1), cmd.location); + EXPECT_EQ(static_cast<GLsizei>(2), cmd.count); + EXPECT_EQ(static_cast<GLboolean>(3), cmd.transpose); + // TODO(gman): Check that data was inserted; +} + +TEST(GLES2FormatTest, UseProgram) { + UseProgram cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11)); + EXPECT_EQ(UseProgram::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLuint>(11), cmd.program); +} + +TEST(GLES2FormatTest, ValidateProgram) { + ValidateProgram cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11)); + EXPECT_EQ(ValidateProgram::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLuint>(11), cmd.program); +} + +TEST(GLES2FormatTest, VertexAttrib1f) { + VertexAttrib1f cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11), + static_cast<GLfloat>(12)); + EXPECT_EQ(VertexAttrib1f::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLuint>(11), cmd.indx); + EXPECT_EQ(static_cast<GLfloat>(12), cmd.x); +} + +TEST(GLES2FormatTest, VertexAttrib1fv) { + VertexAttrib1fv cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11), + static_cast<uint32>(12), + static_cast<uint32>(13)); + EXPECT_EQ(VertexAttrib1fv::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLuint>(11), cmd.indx); + EXPECT_EQ(static_cast<uint32>(12), cmd.values_shm_id); + EXPECT_EQ(static_cast<uint32>(13), cmd.values_shm_offset); +} + +TEST(GLES2FormatTest, VertexAttrib1fvImmediate) { + const int kSomeBaseValueToTestWith = 51; + static GLfloat data[] = { + static_cast<GLfloat>(kSomeBaseValueToTestWith + 0), + }; + int8 buf[256] = { 0, }; + VertexAttrib1fvImmediate& cmd = + *static_cast<VertexAttrib1fvImmediate*>(static_cast<void*>(&buf)); + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11), + data); + EXPECT_EQ(VertexAttrib1fvImmediate::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd) + + RoundSizeToMultipleOfEntries(sizeof(data)), + cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLuint>(11), cmd.indx); + // TODO(gman): Check that data was inserted; +} + +TEST(GLES2FormatTest, VertexAttrib2f) { + VertexAttrib2f cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11), + static_cast<GLfloat>(12), + static_cast<GLfloat>(13)); + EXPECT_EQ(VertexAttrib2f::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLuint>(11), cmd.indx); + EXPECT_EQ(static_cast<GLfloat>(12), cmd.x); + EXPECT_EQ(static_cast<GLfloat>(13), cmd.y); +} + +TEST(GLES2FormatTest, VertexAttrib2fv) { + VertexAttrib2fv cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11), + static_cast<uint32>(12), + static_cast<uint32>(13)); + EXPECT_EQ(VertexAttrib2fv::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLuint>(11), cmd.indx); + EXPECT_EQ(static_cast<uint32>(12), cmd.values_shm_id); + EXPECT_EQ(static_cast<uint32>(13), cmd.values_shm_offset); +} + +TEST(GLES2FormatTest, VertexAttrib2fvImmediate) { + const int kSomeBaseValueToTestWith = 51; + static GLfloat data[] = { + static_cast<GLfloat>(kSomeBaseValueToTestWith + 0), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 1), + }; + int8 buf[256] = { 0, }; + VertexAttrib2fvImmediate& cmd = + *static_cast<VertexAttrib2fvImmediate*>(static_cast<void*>(&buf)); + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11), + data); + EXPECT_EQ(VertexAttrib2fvImmediate::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd) + + RoundSizeToMultipleOfEntries(sizeof(data)), + cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLuint>(11), cmd.indx); + // TODO(gman): Check that data was inserted; +} + +TEST(GLES2FormatTest, VertexAttrib3f) { + VertexAttrib3f cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11), + static_cast<GLfloat>(12), + static_cast<GLfloat>(13), + static_cast<GLfloat>(14)); + EXPECT_EQ(VertexAttrib3f::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLuint>(11), cmd.indx); + EXPECT_EQ(static_cast<GLfloat>(12), cmd.x); + EXPECT_EQ(static_cast<GLfloat>(13), cmd.y); + EXPECT_EQ(static_cast<GLfloat>(14), cmd.z); +} + +TEST(GLES2FormatTest, VertexAttrib3fv) { + VertexAttrib3fv cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11), + static_cast<uint32>(12), + static_cast<uint32>(13)); + EXPECT_EQ(VertexAttrib3fv::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLuint>(11), cmd.indx); + EXPECT_EQ(static_cast<uint32>(12), cmd.values_shm_id); + EXPECT_EQ(static_cast<uint32>(13), cmd.values_shm_offset); +} + +TEST(GLES2FormatTest, VertexAttrib3fvImmediate) { + const int kSomeBaseValueToTestWith = 51; + static GLfloat data[] = { + static_cast<GLfloat>(kSomeBaseValueToTestWith + 0), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 1), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 2), + }; + int8 buf[256] = { 0, }; + VertexAttrib3fvImmediate& cmd = + *static_cast<VertexAttrib3fvImmediate*>(static_cast<void*>(&buf)); + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11), + data); + EXPECT_EQ(VertexAttrib3fvImmediate::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd) + + RoundSizeToMultipleOfEntries(sizeof(data)), + cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLuint>(11), cmd.indx); + // TODO(gman): Check that data was inserted; +} + +TEST(GLES2FormatTest, VertexAttrib4f) { + VertexAttrib4f cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11), + static_cast<GLfloat>(12), + static_cast<GLfloat>(13), + static_cast<GLfloat>(14), + static_cast<GLfloat>(15)); + EXPECT_EQ(VertexAttrib4f::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLuint>(11), cmd.indx); + EXPECT_EQ(static_cast<GLfloat>(12), cmd.x); + EXPECT_EQ(static_cast<GLfloat>(13), cmd.y); + EXPECT_EQ(static_cast<GLfloat>(14), cmd.z); + EXPECT_EQ(static_cast<GLfloat>(15), cmd.w); +} + +TEST(GLES2FormatTest, VertexAttrib4fv) { + VertexAttrib4fv cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11), + static_cast<uint32>(12), + static_cast<uint32>(13)); + EXPECT_EQ(VertexAttrib4fv::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLuint>(11), cmd.indx); + EXPECT_EQ(static_cast<uint32>(12), cmd.values_shm_id); + EXPECT_EQ(static_cast<uint32>(13), cmd.values_shm_offset); +} + +TEST(GLES2FormatTest, VertexAttrib4fvImmediate) { + const int kSomeBaseValueToTestWith = 51; + static GLfloat data[] = { + static_cast<GLfloat>(kSomeBaseValueToTestWith + 0), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 1), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 2), + static_cast<GLfloat>(kSomeBaseValueToTestWith + 3), + }; + int8 buf[256] = { 0, }; + VertexAttrib4fvImmediate& cmd = + *static_cast<VertexAttrib4fvImmediate*>(static_cast<void*>(&buf)); + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11), + data); + EXPECT_EQ(VertexAttrib4fvImmediate::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd) + + RoundSizeToMultipleOfEntries(sizeof(data)), + cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLuint>(11), cmd.indx); + // TODO(gman): Check that data was inserted; +} + +TEST(GLES2FormatTest, VertexAttribPointer) { + VertexAttribPointer cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11), + static_cast<GLint>(12), + static_cast<GLenum>(13), + static_cast<GLboolean>(14), + static_cast<GLsizei>(15), + static_cast<GLuint>(16)); + EXPECT_EQ(VertexAttribPointer::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLuint>(11), cmd.indx); + EXPECT_EQ(static_cast<GLint>(12), cmd.size); + EXPECT_EQ(static_cast<GLenum>(13), cmd.type); + EXPECT_EQ(static_cast<GLboolean>(14), cmd.normalized); + EXPECT_EQ(static_cast<GLsizei>(15), cmd.stride); + EXPECT_EQ(static_cast<GLuint>(16), cmd.offset); +} + +TEST(GLES2FormatTest, Viewport) { + Viewport cmd = { 0, }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLint>(11), + static_cast<GLint>(12), + static_cast<GLsizei>(13), + static_cast<GLsizei>(14)); + EXPECT_EQ(Viewport::kCmdId, cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4); // NOLINT + EXPECT_EQ(static_cast<GLint>(11), cmd.x); + EXPECT_EQ(static_cast<GLint>(12), cmd.y); + EXPECT_EQ(static_cast<GLsizei>(13), cmd.width); + EXPECT_EQ(static_cast<GLsizei>(14), cmd.height); +} + diff --git a/o3d/gpu/command_buffer/common/gles2_cmd_id_test.cc b/o3d/gpu/command_buffer/common/gles2_cmd_id_test.cc new file mode 100644 index 0000000..8bcb00b --- /dev/null +++ b/o3d/gpu/command_buffer/common/gles2_cmd_id_test.cc @@ -0,0 +1,368 @@ +// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// This file contains unit tests for gles2 commmand ids + +#include "tests/common/win/testing_common.h" +#include "gpu/command_buffer/common/gles2_cmd_format.h" + +namespace command_buffer { +namespace gles2 { + +// *** These IDs MUST NOT CHANGE!!! *** +// Changing them will break all client programs. +TEST(GLES2CommandIdTest, CommandIdsMatch) { + COMPILE_ASSERT(ActiveTexture::kCmdId == 1024, + GLES2_ActiveTexture_kCmdId_mismatch); + COMPILE_ASSERT(AttachShader::kCmdId == 1025, + GLES2_AttachShader_kCmdId_mismatch); + COMPILE_ASSERT(BindAttribLocation::kCmdId == 1026, + GLES2_BindAttribLocation_kCmdId_mismatch); + COMPILE_ASSERT(BindAttribLocationImmediate::kCmdId == 1027, + GLES2_BindAttribLocationImmediate_kCmdId_mismatch); + COMPILE_ASSERT(BindBuffer::kCmdId == 1028, + GLES2_BindBuffer_kCmdId_mismatch); + COMPILE_ASSERT(BindFramebuffer::kCmdId == 1029, + GLES2_BindFramebuffer_kCmdId_mismatch); + COMPILE_ASSERT(BindRenderbuffer::kCmdId == 1030, + GLES2_BindRenderbuffer_kCmdId_mismatch); + COMPILE_ASSERT(BindTexture::kCmdId == 1031, + GLES2_BindTexture_kCmdId_mismatch); + COMPILE_ASSERT(BlendColor::kCmdId == 1032, + GLES2_BlendColor_kCmdId_mismatch); + COMPILE_ASSERT(BlendEquation::kCmdId == 1033, + GLES2_BlendEquation_kCmdId_mismatch); + COMPILE_ASSERT(BlendEquationSeparate::kCmdId == 1034, + GLES2_BlendEquationSeparate_kCmdId_mismatch); + COMPILE_ASSERT(BlendFunc::kCmdId == 1035, + GLES2_BlendFunc_kCmdId_mismatch); + COMPILE_ASSERT(BlendFuncSeparate::kCmdId == 1036, + GLES2_BlendFuncSeparate_kCmdId_mismatch); + COMPILE_ASSERT(BufferData::kCmdId == 1037, + GLES2_BufferData_kCmdId_mismatch); + COMPILE_ASSERT(BufferDataImmediate::kCmdId == 1038, + GLES2_BufferDataImmediate_kCmdId_mismatch); + COMPILE_ASSERT(BufferSubData::kCmdId == 1039, + GLES2_BufferSubData_kCmdId_mismatch); + COMPILE_ASSERT(BufferSubDataImmediate::kCmdId == 1040, + GLES2_BufferSubDataImmediate_kCmdId_mismatch); + COMPILE_ASSERT(CheckFramebufferStatus::kCmdId == 1041, + GLES2_CheckFramebufferStatus_kCmdId_mismatch); + COMPILE_ASSERT(Clear::kCmdId == 1042, + GLES2_Clear_kCmdId_mismatch); + COMPILE_ASSERT(ClearColor::kCmdId == 1043, + GLES2_ClearColor_kCmdId_mismatch); + COMPILE_ASSERT(ClearDepthf::kCmdId == 1044, + GLES2_ClearDepthf_kCmdId_mismatch); + COMPILE_ASSERT(ClearStencil::kCmdId == 1045, + GLES2_ClearStencil_kCmdId_mismatch); + COMPILE_ASSERT(ColorMask::kCmdId == 1046, + GLES2_ColorMask_kCmdId_mismatch); + COMPILE_ASSERT(CompileShader::kCmdId == 1047, + GLES2_CompileShader_kCmdId_mismatch); + COMPILE_ASSERT(CompressedTexImage2D::kCmdId == 1048, + GLES2_CompressedTexImage2D_kCmdId_mismatch); + COMPILE_ASSERT(CompressedTexImage2DImmediate::kCmdId == 1049, + GLES2_CompressedTexImage2DImmediate_kCmdId_mismatch); + COMPILE_ASSERT(CompressedTexSubImage2D::kCmdId == 1050, + GLES2_CompressedTexSubImage2D_kCmdId_mismatch); + COMPILE_ASSERT(CompressedTexSubImage2DImmediate::kCmdId == 1051, + GLES2_CompressedTexSubImage2DImmediate_kCmdId_mismatch); + COMPILE_ASSERT(CopyTexImage2D::kCmdId == 1052, + GLES2_CopyTexImage2D_kCmdId_mismatch); + COMPILE_ASSERT(CopyTexSubImage2D::kCmdId == 1053, + GLES2_CopyTexSubImage2D_kCmdId_mismatch); + COMPILE_ASSERT(CreateProgram::kCmdId == 1054, + GLES2_CreateProgram_kCmdId_mismatch); + COMPILE_ASSERT(CreateShader::kCmdId == 1055, + GLES2_CreateShader_kCmdId_mismatch); + COMPILE_ASSERT(CullFace::kCmdId == 1056, + GLES2_CullFace_kCmdId_mismatch); + COMPILE_ASSERT(DeleteBuffers::kCmdId == 1057, + GLES2_DeleteBuffers_kCmdId_mismatch); + COMPILE_ASSERT(DeleteBuffersImmediate::kCmdId == 1058, + GLES2_DeleteBuffersImmediate_kCmdId_mismatch); + COMPILE_ASSERT(DeleteFramebuffers::kCmdId == 1059, + GLES2_DeleteFramebuffers_kCmdId_mismatch); + COMPILE_ASSERT(DeleteFramebuffersImmediate::kCmdId == 1060, + GLES2_DeleteFramebuffersImmediate_kCmdId_mismatch); + COMPILE_ASSERT(DeleteProgram::kCmdId == 1061, + GLES2_DeleteProgram_kCmdId_mismatch); + COMPILE_ASSERT(DeleteRenderbuffers::kCmdId == 1062, + GLES2_DeleteRenderbuffers_kCmdId_mismatch); + COMPILE_ASSERT(DeleteRenderbuffersImmediate::kCmdId == 1063, + GLES2_DeleteRenderbuffersImmediate_kCmdId_mismatch); + COMPILE_ASSERT(DeleteShader::kCmdId == 1064, + GLES2_DeleteShader_kCmdId_mismatch); + COMPILE_ASSERT(DeleteTextures::kCmdId == 1065, + GLES2_DeleteTextures_kCmdId_mismatch); + COMPILE_ASSERT(DeleteTexturesImmediate::kCmdId == 1066, + GLES2_DeleteTexturesImmediate_kCmdId_mismatch); + COMPILE_ASSERT(DepthFunc::kCmdId == 1067, + GLES2_DepthFunc_kCmdId_mismatch); + COMPILE_ASSERT(DepthMask::kCmdId == 1068, + GLES2_DepthMask_kCmdId_mismatch); + COMPILE_ASSERT(DepthRangef::kCmdId == 1069, + GLES2_DepthRangef_kCmdId_mismatch); + COMPILE_ASSERT(DetachShader::kCmdId == 1070, + GLES2_DetachShader_kCmdId_mismatch); + COMPILE_ASSERT(Disable::kCmdId == 1071, + GLES2_Disable_kCmdId_mismatch); + COMPILE_ASSERT(DisableVertexAttribArray::kCmdId == 1072, + GLES2_DisableVertexAttribArray_kCmdId_mismatch); + COMPILE_ASSERT(DrawArrays::kCmdId == 1073, + GLES2_DrawArrays_kCmdId_mismatch); + COMPILE_ASSERT(DrawElements::kCmdId == 1074, + GLES2_DrawElements_kCmdId_mismatch); + COMPILE_ASSERT(Enable::kCmdId == 1075, + GLES2_Enable_kCmdId_mismatch); + COMPILE_ASSERT(EnableVertexAttribArray::kCmdId == 1076, + GLES2_EnableVertexAttribArray_kCmdId_mismatch); + COMPILE_ASSERT(Finish::kCmdId == 1077, + GLES2_Finish_kCmdId_mismatch); + COMPILE_ASSERT(Flush::kCmdId == 1078, + GLES2_Flush_kCmdId_mismatch); + COMPILE_ASSERT(FramebufferRenderbuffer::kCmdId == 1079, + GLES2_FramebufferRenderbuffer_kCmdId_mismatch); + COMPILE_ASSERT(FramebufferTexture2D::kCmdId == 1080, + GLES2_FramebufferTexture2D_kCmdId_mismatch); + COMPILE_ASSERT(FrontFace::kCmdId == 1081, + GLES2_FrontFace_kCmdId_mismatch); + COMPILE_ASSERT(GenBuffers::kCmdId == 1082, + GLES2_GenBuffers_kCmdId_mismatch); + COMPILE_ASSERT(GenBuffersImmediate::kCmdId == 1083, + GLES2_GenBuffersImmediate_kCmdId_mismatch); + COMPILE_ASSERT(GenerateMipmap::kCmdId == 1084, + GLES2_GenerateMipmap_kCmdId_mismatch); + COMPILE_ASSERT(GenFramebuffers::kCmdId == 1085, + GLES2_GenFramebuffers_kCmdId_mismatch); + COMPILE_ASSERT(GenFramebuffersImmediate::kCmdId == 1086, + GLES2_GenFramebuffersImmediate_kCmdId_mismatch); + COMPILE_ASSERT(GenRenderbuffers::kCmdId == 1087, + GLES2_GenRenderbuffers_kCmdId_mismatch); + COMPILE_ASSERT(GenRenderbuffersImmediate::kCmdId == 1088, + GLES2_GenRenderbuffersImmediate_kCmdId_mismatch); + COMPILE_ASSERT(GenTextures::kCmdId == 1089, + GLES2_GenTextures_kCmdId_mismatch); + COMPILE_ASSERT(GenTexturesImmediate::kCmdId == 1090, + GLES2_GenTexturesImmediate_kCmdId_mismatch); + COMPILE_ASSERT(GetActiveAttrib::kCmdId == 1091, + GLES2_GetActiveAttrib_kCmdId_mismatch); + COMPILE_ASSERT(GetActiveUniform::kCmdId == 1092, + GLES2_GetActiveUniform_kCmdId_mismatch); + COMPILE_ASSERT(GetAttachedShaders::kCmdId == 1093, + GLES2_GetAttachedShaders_kCmdId_mismatch); + COMPILE_ASSERT(GetAttribLocation::kCmdId == 1094, + GLES2_GetAttribLocation_kCmdId_mismatch); + COMPILE_ASSERT(GetAttribLocationImmediate::kCmdId == 1095, + GLES2_GetAttribLocationImmediate_kCmdId_mismatch); + COMPILE_ASSERT(GetBooleanv::kCmdId == 1096, + GLES2_GetBooleanv_kCmdId_mismatch); + COMPILE_ASSERT(GetBufferParameteriv::kCmdId == 1097, + GLES2_GetBufferParameteriv_kCmdId_mismatch); + COMPILE_ASSERT(GetError::kCmdId == 1098, + GLES2_GetError_kCmdId_mismatch); + COMPILE_ASSERT(GetFloatv::kCmdId == 1099, + GLES2_GetFloatv_kCmdId_mismatch); + COMPILE_ASSERT(GetFramebufferAttachmentParameteriv::kCmdId == 1100, + GLES2_GetFramebufferAttachmentParameteriv_kCmdId_mismatch); + COMPILE_ASSERT(GetIntegerv::kCmdId == 1101, + GLES2_GetIntegerv_kCmdId_mismatch); + COMPILE_ASSERT(GetProgramiv::kCmdId == 1102, + GLES2_GetProgramiv_kCmdId_mismatch); + COMPILE_ASSERT(GetProgramInfoLog::kCmdId == 1103, + GLES2_GetProgramInfoLog_kCmdId_mismatch); + COMPILE_ASSERT(GetRenderbufferParameteriv::kCmdId == 1104, + GLES2_GetRenderbufferParameteriv_kCmdId_mismatch); + COMPILE_ASSERT(GetShaderiv::kCmdId == 1105, + GLES2_GetShaderiv_kCmdId_mismatch); + COMPILE_ASSERT(GetShaderInfoLog::kCmdId == 1106, + GLES2_GetShaderInfoLog_kCmdId_mismatch); + COMPILE_ASSERT(GetShaderPrecisionFormat::kCmdId == 1107, + GLES2_GetShaderPrecisionFormat_kCmdId_mismatch); + COMPILE_ASSERT(GetShaderSource::kCmdId == 1108, + GLES2_GetShaderSource_kCmdId_mismatch); + COMPILE_ASSERT(GetString::kCmdId == 1109, + GLES2_GetString_kCmdId_mismatch); + COMPILE_ASSERT(GetTexParameterfv::kCmdId == 1110, + GLES2_GetTexParameterfv_kCmdId_mismatch); + COMPILE_ASSERT(GetTexParameteriv::kCmdId == 1111, + GLES2_GetTexParameteriv_kCmdId_mismatch); + COMPILE_ASSERT(GetUniformfv::kCmdId == 1112, + GLES2_GetUniformfv_kCmdId_mismatch); + COMPILE_ASSERT(GetUniformiv::kCmdId == 1113, + GLES2_GetUniformiv_kCmdId_mismatch); + COMPILE_ASSERT(GetUniformLocation::kCmdId == 1114, + GLES2_GetUniformLocation_kCmdId_mismatch); + COMPILE_ASSERT(GetUniformLocationImmediate::kCmdId == 1115, + GLES2_GetUniformLocationImmediate_kCmdId_mismatch); + COMPILE_ASSERT(GetVertexAttribfv::kCmdId == 1116, + GLES2_GetVertexAttribfv_kCmdId_mismatch); + COMPILE_ASSERT(GetVertexAttribiv::kCmdId == 1117, + GLES2_GetVertexAttribiv_kCmdId_mismatch); + COMPILE_ASSERT(GetVertexAttribPointerv::kCmdId == 1118, + GLES2_GetVertexAttribPointerv_kCmdId_mismatch); + COMPILE_ASSERT(Hint::kCmdId == 1119, + GLES2_Hint_kCmdId_mismatch); + COMPILE_ASSERT(IsBuffer::kCmdId == 1120, + GLES2_IsBuffer_kCmdId_mismatch); + COMPILE_ASSERT(IsEnabled::kCmdId == 1121, + GLES2_IsEnabled_kCmdId_mismatch); + COMPILE_ASSERT(IsFramebuffer::kCmdId == 1122, + GLES2_IsFramebuffer_kCmdId_mismatch); + COMPILE_ASSERT(IsProgram::kCmdId == 1123, + GLES2_IsProgram_kCmdId_mismatch); + COMPILE_ASSERT(IsRenderbuffer::kCmdId == 1124, + GLES2_IsRenderbuffer_kCmdId_mismatch); + COMPILE_ASSERT(IsShader::kCmdId == 1125, + GLES2_IsShader_kCmdId_mismatch); + COMPILE_ASSERT(IsTexture::kCmdId == 1126, + GLES2_IsTexture_kCmdId_mismatch); + COMPILE_ASSERT(LineWidth::kCmdId == 1127, + GLES2_LineWidth_kCmdId_mismatch); + COMPILE_ASSERT(LinkProgram::kCmdId == 1128, + GLES2_LinkProgram_kCmdId_mismatch); + COMPILE_ASSERT(PixelStorei::kCmdId == 1129, + GLES2_PixelStorei_kCmdId_mismatch); + COMPILE_ASSERT(PolygonOffset::kCmdId == 1130, + GLES2_PolygonOffset_kCmdId_mismatch); + COMPILE_ASSERT(ReadPixels::kCmdId == 1131, + GLES2_ReadPixels_kCmdId_mismatch); + COMPILE_ASSERT(RenderbufferStorage::kCmdId == 1132, + GLES2_RenderbufferStorage_kCmdId_mismatch); + COMPILE_ASSERT(SampleCoverage::kCmdId == 1133, + GLES2_SampleCoverage_kCmdId_mismatch); + COMPILE_ASSERT(Scissor::kCmdId == 1134, + GLES2_Scissor_kCmdId_mismatch); + COMPILE_ASSERT(ShaderSource::kCmdId == 1135, + GLES2_ShaderSource_kCmdId_mismatch); + COMPILE_ASSERT(ShaderSourceImmediate::kCmdId == 1136, + GLES2_ShaderSourceImmediate_kCmdId_mismatch); + COMPILE_ASSERT(StencilFunc::kCmdId == 1137, + GLES2_StencilFunc_kCmdId_mismatch); + COMPILE_ASSERT(StencilFuncSeparate::kCmdId == 1138, + GLES2_StencilFuncSeparate_kCmdId_mismatch); + COMPILE_ASSERT(StencilMask::kCmdId == 1139, + GLES2_StencilMask_kCmdId_mismatch); + COMPILE_ASSERT(StencilMaskSeparate::kCmdId == 1140, + GLES2_StencilMaskSeparate_kCmdId_mismatch); + COMPILE_ASSERT(StencilOp::kCmdId == 1141, + GLES2_StencilOp_kCmdId_mismatch); + COMPILE_ASSERT(StencilOpSeparate::kCmdId == 1142, + GLES2_StencilOpSeparate_kCmdId_mismatch); + COMPILE_ASSERT(TexImage2D::kCmdId == 1143, + GLES2_TexImage2D_kCmdId_mismatch); + COMPILE_ASSERT(TexImage2DImmediate::kCmdId == 1144, + GLES2_TexImage2DImmediate_kCmdId_mismatch); + COMPILE_ASSERT(TexParameterf::kCmdId == 1145, + GLES2_TexParameterf_kCmdId_mismatch); + COMPILE_ASSERT(TexParameterfv::kCmdId == 1146, + GLES2_TexParameterfv_kCmdId_mismatch); + COMPILE_ASSERT(TexParameterfvImmediate::kCmdId == 1147, + GLES2_TexParameterfvImmediate_kCmdId_mismatch); + COMPILE_ASSERT(TexParameteri::kCmdId == 1148, + GLES2_TexParameteri_kCmdId_mismatch); + COMPILE_ASSERT(TexParameteriv::kCmdId == 1149, + GLES2_TexParameteriv_kCmdId_mismatch); + COMPILE_ASSERT(TexParameterivImmediate::kCmdId == 1150, + GLES2_TexParameterivImmediate_kCmdId_mismatch); + COMPILE_ASSERT(TexSubImage2D::kCmdId == 1151, + GLES2_TexSubImage2D_kCmdId_mismatch); + COMPILE_ASSERT(TexSubImage2DImmediate::kCmdId == 1152, + GLES2_TexSubImage2DImmediate_kCmdId_mismatch); + COMPILE_ASSERT(Uniform1f::kCmdId == 1153, + GLES2_Uniform1f_kCmdId_mismatch); + COMPILE_ASSERT(Uniform1fv::kCmdId == 1154, + GLES2_Uniform1fv_kCmdId_mismatch); + COMPILE_ASSERT(Uniform1fvImmediate::kCmdId == 1155, + GLES2_Uniform1fvImmediate_kCmdId_mismatch); + COMPILE_ASSERT(Uniform1i::kCmdId == 1156, + GLES2_Uniform1i_kCmdId_mismatch); + COMPILE_ASSERT(Uniform1iv::kCmdId == 1157, + GLES2_Uniform1iv_kCmdId_mismatch); + COMPILE_ASSERT(Uniform1ivImmediate::kCmdId == 1158, + GLES2_Uniform1ivImmediate_kCmdId_mismatch); + COMPILE_ASSERT(Uniform2f::kCmdId == 1159, + GLES2_Uniform2f_kCmdId_mismatch); + COMPILE_ASSERT(Uniform2fv::kCmdId == 1160, + GLES2_Uniform2fv_kCmdId_mismatch); + COMPILE_ASSERT(Uniform2fvImmediate::kCmdId == 1161, + GLES2_Uniform2fvImmediate_kCmdId_mismatch); + COMPILE_ASSERT(Uniform2i::kCmdId == 1162, + GLES2_Uniform2i_kCmdId_mismatch); + COMPILE_ASSERT(Uniform2iv::kCmdId == 1163, + GLES2_Uniform2iv_kCmdId_mismatch); + COMPILE_ASSERT(Uniform2ivImmediate::kCmdId == 1164, + GLES2_Uniform2ivImmediate_kCmdId_mismatch); + COMPILE_ASSERT(Uniform3f::kCmdId == 1165, + GLES2_Uniform3f_kCmdId_mismatch); + COMPILE_ASSERT(Uniform3fv::kCmdId == 1166, + GLES2_Uniform3fv_kCmdId_mismatch); + COMPILE_ASSERT(Uniform3fvImmediate::kCmdId == 1167, + GLES2_Uniform3fvImmediate_kCmdId_mismatch); + COMPILE_ASSERT(Uniform3i::kCmdId == 1168, + GLES2_Uniform3i_kCmdId_mismatch); + COMPILE_ASSERT(Uniform3iv::kCmdId == 1169, + GLES2_Uniform3iv_kCmdId_mismatch); + COMPILE_ASSERT(Uniform3ivImmediate::kCmdId == 1170, + GLES2_Uniform3ivImmediate_kCmdId_mismatch); + COMPILE_ASSERT(Uniform4f::kCmdId == 1171, + GLES2_Uniform4f_kCmdId_mismatch); + COMPILE_ASSERT(Uniform4fv::kCmdId == 1172, + GLES2_Uniform4fv_kCmdId_mismatch); + COMPILE_ASSERT(Uniform4fvImmediate::kCmdId == 1173, + GLES2_Uniform4fvImmediate_kCmdId_mismatch); + COMPILE_ASSERT(Uniform4i::kCmdId == 1174, + GLES2_Uniform4i_kCmdId_mismatch); + COMPILE_ASSERT(Uniform4iv::kCmdId == 1175, + GLES2_Uniform4iv_kCmdId_mismatch); + COMPILE_ASSERT(Uniform4ivImmediate::kCmdId == 1176, + GLES2_Uniform4ivImmediate_kCmdId_mismatch); + COMPILE_ASSERT(UniformMatrix2fv::kCmdId == 1177, + GLES2_UniformMatrix2fv_kCmdId_mismatch); + COMPILE_ASSERT(UniformMatrix2fvImmediate::kCmdId == 1178, + GLES2_UniformMatrix2fvImmediate_kCmdId_mismatch); + COMPILE_ASSERT(UniformMatrix3fv::kCmdId == 1179, + GLES2_UniformMatrix3fv_kCmdId_mismatch); + COMPILE_ASSERT(UniformMatrix3fvImmediate::kCmdId == 1180, + GLES2_UniformMatrix3fvImmediate_kCmdId_mismatch); + COMPILE_ASSERT(UniformMatrix4fv::kCmdId == 1181, + GLES2_UniformMatrix4fv_kCmdId_mismatch); + COMPILE_ASSERT(UniformMatrix4fvImmediate::kCmdId == 1182, + GLES2_UniformMatrix4fvImmediate_kCmdId_mismatch); + COMPILE_ASSERT(UseProgram::kCmdId == 1183, + GLES2_UseProgram_kCmdId_mismatch); + COMPILE_ASSERT(ValidateProgram::kCmdId == 1184, + GLES2_ValidateProgram_kCmdId_mismatch); + COMPILE_ASSERT(VertexAttrib1f::kCmdId == 1185, + GLES2_VertexAttrib1f_kCmdId_mismatch); + COMPILE_ASSERT(VertexAttrib1fv::kCmdId == 1186, + GLES2_VertexAttrib1fv_kCmdId_mismatch); + COMPILE_ASSERT(VertexAttrib1fvImmediate::kCmdId == 1187, + GLES2_VertexAttrib1fvImmediate_kCmdId_mismatch); + COMPILE_ASSERT(VertexAttrib2f::kCmdId == 1188, + GLES2_VertexAttrib2f_kCmdId_mismatch); + COMPILE_ASSERT(VertexAttrib2fv::kCmdId == 1189, + GLES2_VertexAttrib2fv_kCmdId_mismatch); + COMPILE_ASSERT(VertexAttrib2fvImmediate::kCmdId == 1190, + GLES2_VertexAttrib2fvImmediate_kCmdId_mismatch); + COMPILE_ASSERT(VertexAttrib3f::kCmdId == 1191, + GLES2_VertexAttrib3f_kCmdId_mismatch); + COMPILE_ASSERT(VertexAttrib3fv::kCmdId == 1192, + GLES2_VertexAttrib3fv_kCmdId_mismatch); + COMPILE_ASSERT(VertexAttrib3fvImmediate::kCmdId == 1193, + GLES2_VertexAttrib3fvImmediate_kCmdId_mismatch); + COMPILE_ASSERT(VertexAttrib4f::kCmdId == 1194, + GLES2_VertexAttrib4f_kCmdId_mismatch); + COMPILE_ASSERT(VertexAttrib4fv::kCmdId == 1195, + GLES2_VertexAttrib4fv_kCmdId_mismatch); + COMPILE_ASSERT(VertexAttrib4fvImmediate::kCmdId == 1196, + GLES2_VertexAttrib4fvImmediate_kCmdId_mismatch); + COMPILE_ASSERT(VertexAttribPointer::kCmdId == 1197, + GLES2_VertexAttribPointer_kCmdId_mismatch); + COMPILE_ASSERT(Viewport::kCmdId == 1198, + GLES2_Viewport_kCmdId_mismatch); +} +} // namespace gles2 +} // namespace command_buffer + diff --git a/o3d/gpu/command_buffer/common/gles2_cmd_utils.cc b/o3d/gpu/command_buffer/common/gles2_cmd_utils.cc new file mode 100644 index 0000000..eb5b95b --- /dev/null +++ b/o3d/gpu/command_buffer/common/gles2_cmd_utils.cc @@ -0,0 +1,347 @@ +// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This file is here so other GLES2 related files can have a common set of +// includes where appropriate. + +#include "gpu/command_buffer/common/gles2_cmd_utils.h" + +namespace command_buffer { +namespace gles2 { + +GLsizei GLES2Util::GLGetNumValuesReturned(GLenum id) const { + switch (id) { + // -- glGetBooleanv, glGetFloatv, glGetIntergerv + case GL_ACTIVE_TEXTURE: + return 1; + case GL_ALIASED_LINE_WIDTH_RANGE: + return 2; + case GL_ALIASED_POINT_SIZE_RANGE: + return 1; + case GL_ALPHA_BITS: + return 1; + case GL_ARRAY_BUFFER_BINDING: + return 1; + case GL_BLEND: + return 1; + case GL_BLEND_COLOR: + return 4; + case GL_BLEND_DST_ALPHA: + return 1; + case GL_BLEND_DST_RGB: + return 1; + case GL_BLEND_EQUATION_ALPHA: + return 1; + case GL_BLEND_EQUATION_RGB: + return 1; + case GL_BLEND_SRC_ALPHA: + return 1; + case GL_BLEND_SRC_RGB: + return 1; + case GL_BLUE_BITS: + return 1; + case GL_COLOR_CLEAR_VALUE: + return 4; + case GL_COLOR_WRITEMASK: + return 4; + case GL_COMPRESSED_TEXTURE_FORMATS: + return num_compressed_texture_formats_; + case GL_CULL_FACE: + return 1; + case GL_CULL_FACE_MODE: + return 1; + case GL_CURRENT_PROGRAM: + return 1; + case GL_DEPTH_BITS: + return 1; + case GL_DEPTH_CLEAR_VALUE: + return 1; + case GL_DEPTH_FUNC: + return 1; + case GL_DEPTH_RANGE: + return 2; + case GL_DEPTH_TEST: + return 1; + case GL_DEPTH_WRITEMASK: + return 1; + case GL_DITHER: + return 1; + case GL_ELEMENT_ARRAY_BUFFER_BINDING: + return 1; + case GL_FRAMEBUFFER_BINDING: + return 1; + case GL_FRONT_FACE: + return 1; + case GL_GENERATE_MIPMAP_HINT: + return 1; + case GL_GREEN_BITS: + return 1; + case GL_IMPLEMENTATION_COLOR_READ_FORMAT: + return 1; + case GL_IMPLEMENTATION_COLOR_READ_TYPE: + return 1; + case GL_LINE_WIDTH: + return 1; + case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: + return 1; + case GL_MAX_CUBE_MAP_TEXTURE_SIZE: + return 1; + case GL_MAX_FRAGMENT_UNIFORM_VECTORS: + return 1; + case GL_MAX_RENDERBUFFER_SIZE: + return 1; + case GL_MAX_TEXTURE_IMAGE_UNITS: + return 1; + case GL_MAX_TEXTURE_SIZE: + return 1; + case GL_MAX_VARYING_VECTORS: + return 1; + case GL_MAX_VERTEX_ATTRIBS: + return 1; + case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS: + return 1; + case GL_MAX_VERTEX_UNIFORM_VECTORS: + return 1; + case GL_MAX_VIEWPORT_DIMS: + return 2; + case GL_NUM_COMPRESSED_TEXTURE_FORMATS: + return 1; + case GL_PACK_ALIGNMENT: + return 1; + case GL_POLYGON_OFFSET_FACTOR: + return 1; + case GL_POLYGON_OFFSET_FILL: + return 1; + case GL_POLYGON_OFFSET_UNITS: + return 1; + case GL_RED_BITS: + return 1; + case GL_RENDERBUFFER_BINDING: + return 1; + case GL_SAMPLE_BUFFERS: + return 1; + case GL_SAMPLE_COVERAGE_INVERT: + return 1; + case GL_SAMPLE_COVERAGE_VALUE: + return 1; + case GL_SAMPLES: + return 1; + case GL_SCISSOR_BOX: + return 4; + case GL_SCISSOR_TEST: + return 1; + case GL_SHADER_COMPILER: + return 1; + case GL_STENCIL_BACK_FAIL: + return 1; + case GL_STENCIL_BACK_FUNC: + return 1; + case GL_STENCIL_BACK_PASS_DEPTH_FAIL: + return 1; + case GL_STENCIL_BACK_PASS_DEPTH_PASS: + return 1; + case GL_STENCIL_BACK_REF: + return 1; + case GL_STENCIL_BACK_VALUE_MASK: + return 1; + case GL_STENCIL_BACK_WRITEMASK: + return 1; + case GL_STENCIL_BITS: + return 1; + case GL_STENCIL_CLEAR_VALUE: + return 1; + case GL_STENCIL_FAIL: + return 1; + case GL_STENCIL_FUNC: + return 1; + case GL_STENCIL_PASS_DEPTH_FAIL: + return 1; + case GL_STENCIL_PASS_DEPTH_PASS: + return 1; + case GL_STENCIL_REF: + return 1; + case GL_STENCIL_TEST: + return 1; + case GL_STENCIL_VALUE_MASK: + return 1; + case GL_STENCIL_WRITEMASK: + return 1; + case GL_SUBPIXEL_BITS: + return 1; + case GL_TEXTURE_BINDING_2D: + return 1; + case GL_TEXTURE_BINDING_CUBE_MAP: + return 1; + case GL_UNPACK_ALIGNMENT: + return 1; + case GL_VIEWPORT: + return 4; + + // -- glGetBufferParameteriv + case GL_BUFFER_SIZE: + return 1; + case GL_BUFFER_USAGE: + return 1; + + // -- glGetFramebufferAttachmentParameteriv + case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: + return 1; + case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: + return 1; + case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: + return 1; + case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: + return 1; + + // -- glGetFramebufferAttachmentParameteriv + case GL_DELETE_STATUS: + return 1; + case GL_LINK_STATUS: + return 1; + case GL_VALIDATE_STATUS: + return 1; + case GL_INFO_LOG_LENGTH: + return 1; + case GL_ATTACHED_SHADERS: + return 1; + case GL_ACTIVE_ATTRIBUTES: + return 1; + case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH: + return 1; + case GL_ACTIVE_UNIFORMS: + return 1; + case GL_ACTIVE_UNIFORM_MAX_LENGTH: + return 1; + + + // -- glGetRenderbufferAttachmentParameteriv + case GL_RENDERBUFFER_WIDTH: + return 1; + case GL_RENDERBUFFER_HEIGHT: + return 1; + case GL_RENDERBUFFER_INTERNAL_FORMAT: + return 1; + case GL_RENDERBUFFER_RED_SIZE: + return 1; + case GL_RENDERBUFFER_GREEN_SIZE: + return 1; + case GL_RENDERBUFFER_BLUE_SIZE: + return 1; + case GL_RENDERBUFFER_ALPHA_SIZE: + return 1; + case GL_RENDERBUFFER_DEPTH_SIZE: + return 1; + case GL_RENDERBUFFER_STENCIL_SIZE: + return 1; + + // -- glGetShaderiv + case GL_SHADER_TYPE: + return 1; + // Already defined under glGetFramebufferAttachemntParameteriv. + // case GL_DELETE_STATUS: + // return 1; + case GL_COMPILE_STATUS: + return 1; + // Already defined under glGetFramebufferAttachemntParameteriv. + // case GL_INFO_LOG_LENGTH: + // return 1; + case GL_SHADER_SOURCE_LENGTH: + return 1; + + // -- glGetTexParameterfv, glGetTexParameteriv + case GL_TEXTURE_MAG_FILTER: + return 1; + case GL_TEXTURE_MIN_FILTER: + return 1; + case GL_TEXTURE_WRAP_S: + return 1; + case GL_TEXTURE_WRAP_T: + return 1; + + // -- glGetVertexAttribfv, glGetVertexAttribiv + case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: + return 1; + case GL_VERTEX_ATTRIB_ARRAY_ENABLED: + return 1; + case GL_VERTEX_ATTRIB_ARRAY_SIZE: + return 1; + case GL_VERTEX_ATTRIB_ARRAY_STRIDE: + return 1; + case GL_VERTEX_ATTRIB_ARRAY_TYPE: + return 1; + case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: + return 1; + case GL_CURRENT_VERTEX_ATTRIB: + return 4; + + // bad enum + default: + return 0; + } +} + +namespace { + +// Return the number of elements per group of a specified format. +GLint ElementsPerGroup(GLenum format, GLenum type) { + switch (type) { + case GL_UNSIGNED_SHORT_5_6_5: + case GL_UNSIGNED_SHORT_4_4_4_4: + case GL_UNSIGNED_SHORT_5_5_5_1: + return 1; + default: + break; + } + + switch (format) { + case GL_RGB: + return 3; + case GL_LUMINANCE_ALPHA: + return 2; + case GL_RGBA: + return 4; + case GL_ALPHA: + case GL_LUMINANCE: + return 1; + default: + return 0; + } +} + +// Return the number of bytes per element, based on the element type. +GLint BytesPerElement(GLenum type) { + switch (type) { + case GL_UNSIGNED_SHORT: + case GL_SHORT: + case GL_UNSIGNED_SHORT_5_6_5: + case GL_UNSIGNED_SHORT_4_4_4_4: + case GL_UNSIGNED_SHORT_5_5_5_1: + return 2; + case GL_UNSIGNED_BYTE: + case GL_BYTE: + return 1; + default: + return 0; + } +} + +} // anonymous namespace + +// Returns the amount of data glTexImage2D or glTexSubImage2D will access. +uint32 GLES2Util::ComputeImageDataSize( + GLsizei width, GLsizei height, GLenum format, GLenum type, + GLint unpack_alignment) { + uint32 bytes_per_group = BytesPerElement(ElementsPerGroup(format, type)); + uint32 row_size = width * bytes_per_group; + if (height > 1) { + uint32 padded_row_size = ((row_size + unpack_alignment - 1) / + unpack_alignment) * unpack_alignment; + return height - 1 * padded_row_size + row_size; + } + return height * row_size; +} + +} // namespace gles2 +} // namespace command_buffer + diff --git a/o3d/gpu/command_buffer/common/gles2_cmd_utils.h b/o3d/gpu/command_buffer/common/gles2_cmd_utils.h new file mode 100644 index 0000000..0e6b2f2 --- /dev/null +++ b/o3d/gpu/command_buffer/common/gles2_cmd_utils.h @@ -0,0 +1,52 @@ +// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This file is here so other GLES2 related files can have a common set of +// includes where appropriate. + +#ifndef GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_UTILS_H +#define GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_UTILS_H + +// The GPU Service needs to include the OS's GL headers. +#ifdef GPU_SERVICE +#include <GL/glew.h> +#if defined(OS_WIN) +#include <GL/wglew.h> +#endif +#else +#include <GLES2/gl2.h> +#endif +#include "base/basictypes.h" +#include "gpu/command_buffer/common/types.h" +#include "gpu/command_buffer/common/bitfield_helpers.h" + +namespace command_buffer { +namespace gles2 { + +// Utilties for GLES2 support. +class GLES2Util { + public: + explicit GLES2Util( + GLsizei num_compressed_texture_formats) + : num_compressed_texture_formats_(num_compressed_texture_formats) { + } + + // Gets the number of values a particular id will return when a glGet + // function is called. If 0 is returned the id is invalid. + GLsizei GLGetNumValuesReturned(GLenum id) const; + + // Computes the size of image data for TexImage2D and TexSubImage2D. + static uint32 GLES2Util::ComputeImageDataSize( + GLsizei width, GLsizei height, GLenum format, GLenum type, + GLint unpack_alignment); + + private: + GLsizei num_compressed_texture_formats_; +}; + +} // namespace gles2 +} // namespace command_buffer + +#endif // GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_UTILS_H + diff --git a/o3d/gpu/command_buffer/service/gles2_cmd_decoder.cc b/o3d/gpu/command_buffer/service/gles2_cmd_decoder.cc new file mode 100644 index 0000000..4881dff --- /dev/null +++ b/o3d/gpu/command_buffer/service/gles2_cmd_decoder.cc @@ -0,0 +1,344 @@ +// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include <vector> +#include <string> +#include "gpu/command_buffer/service/gles2_cmd_decoder.h" +#include "gpu/command_buffer/common/gles2_cmd_format.h" +#include "gpu/command_buffer/service/cmd_buffer_engine.h" + +namespace command_buffer { +namespace gles2 { + +bool IdMap::AddMapping(GLuint client_id, GLuint service_id) { + std::pair<MapType::iterator, bool> result = id_map_.insert( + std::make_pair(client_id, service_id)); + return result.second; +} + +bool IdMap::RemoveMapping(GLuint client_id, GLuint service_id) { + MapType::iterator iter = id_map_.find(client_id); + if (iter != id_map_.end() && iter->second == service_id) { + id_map_.erase(iter); + return true; + } + return false; +} + +bool IdMap::GetServiceId(GLuint client_id, GLuint* service_id) { + DCHECK(service_id); + MapType::iterator iter = id_map_.find(client_id); + if (iter != id_map_.end()) { + *service_id = iter->second; + return true; + } + return false; +} + +bool IdMap::GetClientId(GLuint service_id, GLuint* client_id) { + DCHECK(client_id); + MapType::iterator end(id_map_.end()); + for (MapType::iterator iter(id_map_.begin()); + iter != end; + ++iter) { + if (iter->second == service_id) { + *client_id = iter->first; + return true; + } + } + return false; +} + +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 address of the frst byte after the struct. +template <typename RETURN_TYPE, typename COMMAND_TYPE> +RETURN_TYPE GetImmediateDataAs(const COMMAND_TYPE& pod) { + return static_cast<RETURN_TYPE>(const_cast<void*>(AddressAfterStruct(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 ImmediateDataSize(uint32 arg_count) { + return static_cast<unsigned int>( + (arg_count + 1 - ComputeNumEntries(sizeof(T))) * + sizeof(CommandBufferEntry)); // NOLINT +} + +// Checks if there is enough immediate data. +template<typename T> +bool CheckImmediateDataSize( + unsigned int arg_count, + GLuint count, + size_t size, + unsigned int elements_per_unit) { + return ImmediateDataSize<T>(arg_count) == count * size * elements_per_unit; +} + +// A struct to hold info about each command. +struct CommandInfo { + 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 GLES2_CMD_OP(name) { \ + name::kArgFlags, \ + sizeof(name) / sizeof(CommandBufferEntry) - 1, }, /* NOLINT */ \ + + GLES2_COMMAND_LIST(GLES2_CMD_OP) + + #undef GLES2_CMD_OP +}; + +// These commands convert from c calls to local os calls. +void GLGenBuffersHelper(GLsizei n, GLuint* ids) { + glGenBuffers(n, ids); +} + +void GLGenFramebuffersHelper(GLsizei n, GLuint* ids) { + glGenFramebuffers(n, ids); +} + +void GLGenRenderbuffersHelper(GLsizei n, GLuint* ids) { + glGenRenderbuffers(n, ids); +} + +void GLGenTexturesHelper(GLsizei n, GLuint* ids) { + glGenTextures(n, ids); +} + +void GLDeleteBuffersHelper(GLsizei n, GLuint* ids) { + glDeleteBuffers(n, ids); +} + +void GLDeleteFramebuffersHelper(GLsizei n, GLuint* ids) { + glDeleteFramebuffers(n, ids); +} + +void GLDeleteRenderbuffersHelper(GLsizei n, GLuint* ids) { + glDeleteRenderbuffers(n, ids); +} + +void GLDeleteTexturesHelper(GLsizei n, GLuint* ids) { + glDeleteTextures(n, ids); +} + +} // anonymous namespace. + +GLES2Decoder::GLES2Decoder() + : util_(0), // TODO(gman): Set to actual num compress texture formats. + pack_alignment_(4), + unpack_alignment_(4), + bound_array_buffer_(0), + bound_element_array_buffer_(0) { +} + +// Decode command with its arguments, and call the corresponding GAPIInterface +// method. +// Note: args is a pointer to the command buffer. As such, it could be changed +// by a (malicious) client at any time, so if validation has to happen, it +// should operate on a copy of them. +parse_error::ParseError GLES2Decoder::DoCommand( + unsigned int command, + unsigned int arg_count, + const void* cmd_data) { + unsigned int command_index = command - kStartPoint - 1; + if (command_index < arraysize(g_command_info)) { + const CommandInfo& info = g_command_info[command_index]; + 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 GLES2_CMD_OP(name) \ + case name::kCmdId: \ + return Handle ## name( \ + arg_count, \ + *static_cast<const name*>(cmd_data)); \ + + GLES2_COMMAND_LIST(GLES2_CMD_OP) + + #undef GLES2_CMD_OP + } + } else { + return parse_error::kParseInvalidArguments; + } + } + return DoCommonCommand(command, arg_count, cmd_data); +} + +} // namespace gles2 +} // namespace command_buffer + +// This is included so the compiler will make these inline. +#include "gpu/command_buffer/service/gles2_cmd_decoder_validate.h" + +namespace command_buffer { +namespace gles2 { + +void GLES2Decoder::CreateProgramHelper(GLuint client_id) { + // TODO(gman): verify client_id is unused. + GLuint service_id = glCreateProgram(); + if (service_id) { + id_map_.AddMapping(client_id, service_id); + } +} + +void GLES2Decoder::CreateShaderHelper(GLenum type, GLuint client_id) { + // TODO(gman): verify client_id is unused. + GLuint service_id = glCreateShader(type); + if (service_id) { + id_map_.AddMapping(client_id, service_id); + } +} + +void GLES2Decoder::DoBindBuffer(GLenum target, GLuint buffer) { + switch (target) { + case GL_ARRAY_BUFFER: + bound_array_buffer_ = buffer; + break; + case GL_ELEMENT_ARRAY_BUFFER: + bound_element_array_buffer_ = buffer; + break; + default: + break; + } + glBindBuffer(target, buffer); +} + +void GLES2Decoder::DoDeleteProgram(GLuint program) { + GLuint service_id; + if (id_map_.GetServiceId(program, &service_id)) { + glDeleteProgram(service_id); + id_map_.RemoveMapping(program, service_id); + } +} + +void GLES2Decoder::DoDeleteShader(GLuint shader) { + GLuint service_id; + if (id_map_.GetServiceId(shader, &service_id)) { + glDeleteProgram(service_id); + id_map_.RemoveMapping(shader, service_id); + } +} + +parse_error::ParseError GLES2Decoder::HandleDrawElements( + unsigned int arg_count, const gles2::DrawElements& c) { + if (bound_element_array_buffer_ != 0) { + GLenum mode = c.mode; + GLsizei count = c.count; + GLenum type = c.type; + const GLvoid* indices = reinterpret_cast<const GLvoid*>(c.index_offset); + glDrawElements(mode, count, type, indices); + } else { + // TODO(gman): set our wrapped glGetError value to GL_INVALID_VALUE + DCHECK(false); + } + return parse_error::kParseNoError; +} + +namespace { + +// Calls glShaderSource for the various versions of the ShaderSource command. +// Assumes that data / data_size points to a piece of memory that is in range +// of whatever context it came from (shared memory, immediate memory, bucket +// memory.) +parse_error::ParseError ShaderSourceHelper( + GLuint shader, GLsizei count, const char* data, uint32 data_size) { + std::vector<std::string> strings(count); + scoped_array<const char*> string_pointers(new const char* [count]); + + const uint32* ends = reinterpret_cast<const uint32*>(data); + uint32 start_offset = count * sizeof(*ends); + if (start_offset > data_size) { + return parse_error::kParseOutOfBounds; + } + for (GLsizei ii = 0; ii < count; ++ii) { + uint32 end_offset = ends[ii]; + if (end_offset > data_size || end_offset < start_offset) { + return parse_error::kParseOutOfBounds; + } + strings[ii] = std::string(data + start_offset, end_offset - start_offset); + string_pointers[ii] = strings[ii].c_str(); + } + + glShaderSource(shader, count, string_pointers.get(), NULL); + return parse_error::kParseNoError; +} + +} // anonymous namespace. + +parse_error::ParseError GLES2Decoder::HandleShaderSource( + unsigned int arg_count, const gles2::ShaderSource& c) { + GLuint shader = c.shader; + GLsizei count = c.count; + uint32 data_size = c.data_size; + const char** data = GetSharedMemoryAs<const char**>( + c.data_shm_id, c.data_shm_offset, data_size); + parse_error::ParseError result = + ValidateShaderSource(this, arg_count, shader, count, data, NULL); + if (result != parse_error::kParseNoError) { + return result; + } + return ShaderSourceHelper( + shader, count, reinterpret_cast<const char*>(data), data_size); +} + +parse_error::ParseError GLES2Decoder::HandleShaderSourceImmediate( + unsigned int arg_count, const gles2::ShaderSourceImmediate& c) { + GLuint shader = c.shader; + GLsizei count = c.count; + uint32 data_size = c.data_size; + // TODO(gman): need to check that data_size is in range for arg_count. + const char** data = GetImmediateDataAs<const char**>(c); + parse_error::ParseError result = + ValidateShaderSourceImmediate( + this, arg_count, shader, count, data, NULL); + if (result != parse_error::kParseNoError) { + return result; + } + return ShaderSourceHelper( + shader, count, reinterpret_cast<const char*>(data), data_size); +} + +parse_error::ParseError GLES2Decoder::HandleVertexAttribPointer( + unsigned int arg_count, const gles2::VertexAttribPointer& c) { + if (bound_array_buffer_ != 0) { + GLuint indx = c.indx; + GLint size = c.size; + GLenum type = c.type; + GLboolean normalized = c.normalized; + GLsizei stride = c.stride; + GLuint offset = c.offset; + const void* ptr = reinterpret_cast<const void*>(c.offset); + parse_error::ParseError result = + ValidateVertexAttribPointer( + this, arg_count, indx, size, type, normalized, stride, ptr); + if (result != parse_error::kParseNoError) { + return result; + } + glVertexAttribPointer(indx, size, type, normalized, stride, ptr); + } else { + // TODO(gman): set our wrapped glGetError value to GL_INVALID_VALUE + DCHECK(false); + } + return parse_error::kParseNoError; +} + +// Include the auto-generated part of this file. We split this because it means +// we can easily edit the non-auto generated parts right here in this file +// instead of having to edit some template or the code generator. +#include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" + +} // namespace gles2 +} // namespace command_buffer + diff --git a/o3d/gpu/command_buffer/service/gles2_cmd_decoder.h b/o3d/gpu/command_buffer/service/gles2_cmd_decoder.h new file mode 100644 index 0000000..72afe06 --- /dev/null +++ b/o3d/gpu/command_buffer/service/gles2_cmd_decoder.h @@ -0,0 +1,162 @@ +// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This file contains the GLES2Decoder class. + +#ifndef O3D_COMMAND_BUFFER_SERVICE_CROSS_GLES2_CMD_DECODER_H +#define O3D_COMMAND_BUFFER_SERVICE_CROSS_GLES2_CMD_DECODER_H + +#include <map> +#include "base/scoped_ptr.h" +#include "gpu/command_buffer/common/gles2_cmd_utils.h" +#include "gpu/command_buffer/common/gles2_cmd_format.h" +#include "gpu/command_buffer/service/common_decoder.h" + +namespace command_buffer { +namespace gles2 { + +// This class maps one set of ids to another. +class IdMap { + public: + // Maps a client_id to a service_id. Return false if the client_id or + // service_id are already mapped to something else. + bool AddMapping(GLuint client_id, GLuint service_id); + + // Unmaps a pair of ids. Returns false if the pair were not previously mapped. + bool RemoveMapping(GLuint client_id, GLuint service_id); + + // Gets the corresponding service_id for the given client_id. + // Returns false if there is no corresponding service_id. + bool GetServiceId(GLuint client_id, GLuint* service_id); + + // Gets the corresponding client_id for the given service_id. + // Returns false if there is no corresponding client_id. + bool GetClientId(GLuint service_id, GLuint* client_id); + + private: + // TODO(gman): Replace with faster implementation. + typedef std::map<GLuint, GLuint> MapType; + MapType id_map_; +}; + +// This class implements the AsyncAPIInterface interface, decoding GAPI +// commands and sending them to a GAPI interface. +class GLES2Decoder : public CommonDecoder { + public: + typedef parse_error::ParseError ParseError; + + GLES2Decoder(); + virtual ~GLES2Decoder() { + } + + // Overridden from AsyncAPIInterface. + virtual ParseError DoCommand(unsigned int command, + unsigned int arg_count, + const void* args); + + // Overridden from AsyncAPIInterface. + virtual const char* GetCommandName(unsigned int command_id); + + private: + // Gets the address of shared memory. + // Parameters: + // shm_id: the id of the shared memory buffer. + // offset: the offset of the data in the shared memory buffer. + // size: size of area to get. + // Returns: + // NULL if shm_id isn't a valid shared memory buffer ID or if the offset is + // outside or if the offset + size are outside. + void* GetSharedMemory(unsigned int shm_id, unsigned int offset, + unsigned int size); + + // Typed version of GetSharedMemory + template <typename T> + T GetSharedMemoryAs(unsigned int shm_id, unsigned int offset, + unsigned int size) { + return static_cast<T>(GetSharedMemory(shm_id, offset, size)); + } + + // Template to help call glGenXXX functions. + template <void gl_gen_function(GLsizei, GLuint*)> + bool GenGLObjects(GLsizei n, const GLuint* client_ids) { + // TODO(gman): Verify client ids are unused. + scoped_array<GLuint>temp(new GLuint[n]); + gl_gen_function(n, temp.get()); + // TODO(gman): check for success before copying results. + for (GLsizei ii = 0; ii < n; ++ii) { + if (!id_map_.AddMapping(client_ids[ii], temp[ii])) { + // TODO(gman): fail. + } + } + return true; + } + + // Template to help call glDeleteXXX functions. + template <void gl_delete_function(GLsizei, GLuint*)> + bool DeleteGLObjects(GLsizei n, const GLuint* client_ids) { + scoped_array<GLuint>temp(new GLuint[n]); + // TODO(gman): check for success before copying results. + for (GLsizei ii = 0; ii < n; ++ii) { + if (id_map_.GetServiceId(client_ids[ii], &temp[ii])) { + id_map_.RemoveMapping(client_ids[ii], temp[ii]); + } else { + temp[ii] = 0; + } + } + gl_delete_function(n, temp.get()); + return true; + } + + // Wrapper for glCreateProgram + void CreateProgramHelper(GLuint client_id); + + // Wrapper for glCreateShader + void CreateShaderHelper(GLenum type, GLuint client_id); + + // Wrapper for glBindBuffer since we need to track the current targets. + void DoBindBuffer(GLenum target, GLuint buffer); + + // Wrapper for glDeleteProgram. + void DoDeleteProgram(GLuint program); + + // Wrapper for glDeleteShader. + void DoDeleteShader(GLuint shader); + + // Generate a member function prototype for each command in an automated and + // typesafe way. + #define GLES2_CMD_OP(name) \ + ParseError Handle ## name( \ + unsigned int arg_count, \ + const gles2::name& args); \ + + GLES2_COMMAND_LIST(GLES2_CMD_OP) + + #undef GLES2_CMD_OP + + // Map of client ids to GL ids. + IdMap id_map_; + GLES2Util util_; + + // pack alignment as last set by glPixelStorei + GLint pack_alignment_; + + // unpack alignment as last set by glPixelStorei + GLint unpack_alignment_; + + // The currently bound array buffer. If this is 0 it is illegal to call + // glVertexAttribPointer. + GLuint bound_array_buffer_; + + // The currently bound element array buffer. If this is 0 it is illegal + // to call glDrawElements. + GLuint bound_element_array_buffer_; + + DISALLOW_COPY_AND_ASSIGN(GLES2Decoder); +}; + +} // namespace gles2 +} // namespace command_buffer + +#endif // O3D_COMMAND_BUFFER_SERVICE_CROSS_GLES2_CMD_DECODER_H + diff --git a/o3d/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h b/o3d/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h new file mode 100644 index 0000000..399f6ce --- /dev/null +++ b/o3d/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h @@ -0,0 +1,2462 @@ +// This file is auto-generated. DO NOT EDIT! + +// It is included by gles2_cmd_decoder.cc + +parse_error::ParseError GLES2Decoder::HandleActiveTexture( + unsigned int arg_count, const gles2::ActiveTexture& c) { + GLenum texture = static_cast<GLenum>(c.texture); + parse_error::ParseError result = + ValidateActiveTexture(this, arg_count, texture); + if (result != parse_error::kParseNoError) { + return result; + } + glActiveTexture(texture); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleAttachShader( + unsigned int arg_count, const gles2::AttachShader& c) { + GLuint program = static_cast<GLuint>(c.program); + GLuint shader = static_cast<GLuint>(c.shader); + parse_error::ParseError result = + ValidateAttachShader(this, arg_count, program, shader); + if (result != parse_error::kParseNoError) { + return result; + } + glAttachShader(program, shader); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleBindAttribLocation( + unsigned int arg_count, const gles2::BindAttribLocation& c) { + GLuint program = static_cast<GLuint>(c.program); + GLuint index = static_cast<GLuint>(c.index); + uint32 name_size = c.data_size; + const char* name = GetSharedMemoryAs<const char*>( + c.name_shm_id, c.name_shm_offset, name_size); + parse_error::ParseError result = + ValidateBindAttribLocation(this, arg_count, program, index, name); + if (result != parse_error::kParseNoError) { + return result; + } + String name_str(name, name_size); + glBindAttribLocation(program, index, name_str.c_str()); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleBindAttribLocationImmediate( + unsigned int arg_count, const gles2::BindAttribLocationImmediate& c) { + GLuint program = static_cast<GLuint>(c.program); + GLuint index = static_cast<GLuint>(c.index); + uint32 name_size = c.data_size; + const char* name = GetImmediateDataAs<const char*>(c); + // TODO(gman): Make sure validate checks arg_count + // covers data_size. + parse_error::ParseError result = + ValidateBindAttribLocationImmediate( + this, arg_count, program, index, name); + if (result != parse_error::kParseNoError) { + return result; + } + String name_str(name, name_size); + glBindAttribLocation(program, index, name_str.c_str()); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleBindBuffer( + unsigned int arg_count, const gles2::BindBuffer& c) { + GLenum target = static_cast<GLenum>(c.target); + GLuint buffer = static_cast<GLuint>(c.buffer); + parse_error::ParseError result = + ValidateBindBuffer(this, arg_count, target, buffer); + if (result != parse_error::kParseNoError) { + return result; + } + DoBindBuffer(target, buffer); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleBindFramebuffer( + unsigned int arg_count, const gles2::BindFramebuffer& c) { + GLenum target = static_cast<GLenum>(c.target); + GLuint framebuffer = static_cast<GLuint>(c.framebuffer); + parse_error::ParseError result = + ValidateBindFramebuffer(this, arg_count, target, framebuffer); + if (result != parse_error::kParseNoError) { + return result; + } + glBindFramebuffer(target, framebuffer); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleBindRenderbuffer( + unsigned int arg_count, const gles2::BindRenderbuffer& c) { + GLenum target = static_cast<GLenum>(c.target); + GLuint renderbuffer = static_cast<GLuint>(c.renderbuffer); + parse_error::ParseError result = + ValidateBindRenderbuffer(this, arg_count, target, renderbuffer); + if (result != parse_error::kParseNoError) { + return result; + } + glBindRenderbuffer(target, renderbuffer); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleBindTexture( + unsigned int arg_count, const gles2::BindTexture& c) { + GLenum target = static_cast<GLenum>(c.target); + GLuint texture = static_cast<GLuint>(c.texture); + parse_error::ParseError result = + ValidateBindTexture(this, arg_count, target, texture); + if (result != parse_error::kParseNoError) { + return result; + } + glBindTexture(target, texture); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleBlendColor( + unsigned int arg_count, const gles2::BlendColor& c) { + GLclampf red = static_cast<GLclampf>(c.red); + GLclampf green = static_cast<GLclampf>(c.green); + GLclampf blue = static_cast<GLclampf>(c.blue); + GLclampf alpha = static_cast<GLclampf>(c.alpha); + parse_error::ParseError result = + ValidateBlendColor(this, arg_count, red, green, blue, alpha); + if (result != parse_error::kParseNoError) { + return result; + } + glBlendColor(red, green, blue, alpha); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleBlendEquation( + unsigned int arg_count, const gles2::BlendEquation& c) { + GLenum mode = static_cast<GLenum>(c.mode); + parse_error::ParseError result = + ValidateBlendEquation(this, arg_count, mode); + if (result != parse_error::kParseNoError) { + return result; + } + glBlendEquation(mode); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleBlendEquationSeparate( + unsigned int arg_count, const gles2::BlendEquationSeparate& c) { + GLenum modeRGB = static_cast<GLenum>(c.modeRGB); + GLenum modeAlpha = static_cast<GLenum>(c.modeAlpha); + parse_error::ParseError result = + ValidateBlendEquationSeparate(this, arg_count, modeRGB, modeAlpha); + if (result != parse_error::kParseNoError) { + return result; + } + glBlendEquationSeparate(modeRGB, modeAlpha); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleBlendFunc( + unsigned int arg_count, const gles2::BlendFunc& c) { + GLenum sfactor = static_cast<GLenum>(c.sfactor); + GLenum dfactor = static_cast<GLenum>(c.dfactor); + parse_error::ParseError result = + ValidateBlendFunc(this, arg_count, sfactor, dfactor); + if (result != parse_error::kParseNoError) { + return result; + } + glBlendFunc(sfactor, dfactor); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleBlendFuncSeparate( + unsigned int arg_count, const gles2::BlendFuncSeparate& c) { + GLenum srcRGB = static_cast<GLenum>(c.srcRGB); + GLenum dstRGB = static_cast<GLenum>(c.dstRGB); + GLenum srcAlpha = static_cast<GLenum>(c.srcAlpha); + GLenum dstAlpha = static_cast<GLenum>(c.dstAlpha); + parse_error::ParseError result = + ValidateBlendFuncSeparate( + this, arg_count, srcRGB, dstRGB, srcAlpha, dstAlpha); + if (result != parse_error::kParseNoError) { + return result; + } + glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleBufferData( + unsigned int arg_count, const gles2::BufferData& c) { + GLenum target = static_cast<GLenum>(c.target); + GLsizeiptr size = static_cast<GLsizeiptr>(c.size); + uint32 data_shm_id = static_cast<uint32>(c.data_shm_id); + uint32 data_shm_offset = static_cast<uint32>(c.data_shm_offset); + GLenum usage = static_cast<GLenum>(c.usage); + uint32 data_size = size; + const void* data = GetSharedMemoryAs<const void*>( + data_shm_id, data_shm_offset, data_size); + parse_error::ParseError result = + ValidateBufferData(this, arg_count, target, size, data, usage); + if (result != parse_error::kParseNoError) { + return result; + } + glBufferData(target, size, data, usage); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleBufferDataImmediate( + unsigned int arg_count, const gles2::BufferDataImmediate& c) { + GLenum target = static_cast<GLenum>(c.target); + GLsizeiptr size = static_cast<GLsizeiptr>(c.size); + const void* data = GetImmediateDataAs<const void*>(c); + GLenum usage = static_cast<GLenum>(c.usage); + // Immediate version. + parse_error::ParseError result = + ValidateBufferDataImmediate(this, arg_count, target, size, data, usage); + if (result != parse_error::kParseNoError) { + return result; + } + glBufferData(target, size, data, usage); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleBufferSubData( + unsigned int arg_count, const gles2::BufferSubData& c) { + GLenum target = static_cast<GLenum>(c.target); + GLintptr offset = static_cast<GLintptr>(c.offset); + GLsizeiptr size = static_cast<GLsizeiptr>(c.size); + uint32 data_shm_id = static_cast<uint32>(c.data_shm_id); + uint32 data_shm_offset = static_cast<uint32>(c.data_shm_offset); + uint32 data_size = size; + const void* data = GetSharedMemoryAs<const void*>( + data_shm_id, data_shm_offset, data_size); + parse_error::ParseError result = + ValidateBufferSubData(this, arg_count, target, offset, size, data); + if (result != parse_error::kParseNoError) { + return result; + } + glBufferSubData(target, offset, size, data); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleBufferSubDataImmediate( + unsigned int arg_count, const gles2::BufferSubDataImmediate& c) { + GLenum target = static_cast<GLenum>(c.target); + GLintptr offset = static_cast<GLintptr>(c.offset); + GLsizeiptr size = static_cast<GLsizeiptr>(c.size); + const void* data = GetImmediateDataAs<const void*>(c); + // Immediate version. + parse_error::ParseError result = + ValidateBufferSubDataImmediate( + this, arg_count, target, offset, size, data); + if (result != parse_error::kParseNoError) { + return result; + } + glBufferSubData(target, offset, size, data); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleCheckFramebufferStatus( + unsigned int arg_count, const gles2::CheckFramebufferStatus& c) { + GLenum target = static_cast<GLenum>(c.target); + parse_error::ParseError result = + ValidateCheckFramebufferStatus(this, arg_count, target); + if (result != parse_error::kParseNoError) { + return result; + } + glCheckFramebufferStatus(target); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleClear( + unsigned int arg_count, const gles2::Clear& c) { + GLbitfield mask = static_cast<GLbitfield>(c.mask); + parse_error::ParseError result = + ValidateClear(this, arg_count, mask); + if (result != parse_error::kParseNoError) { + return result; + } + glClear(mask); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleClearColor( + unsigned int arg_count, const gles2::ClearColor& c) { + GLclampf red = static_cast<GLclampf>(c.red); + GLclampf green = static_cast<GLclampf>(c.green); + GLclampf blue = static_cast<GLclampf>(c.blue); + GLclampf alpha = static_cast<GLclampf>(c.alpha); + parse_error::ParseError result = + ValidateClearColor(this, arg_count, red, green, blue, alpha); + if (result != parse_error::kParseNoError) { + return result; + } + glClearColor(red, green, blue, alpha); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleClearDepthf( + unsigned int arg_count, const gles2::ClearDepthf& c) { + GLclampf depth = static_cast<GLclampf>(c.depth); + parse_error::ParseError result = + ValidateClearDepthf(this, arg_count, depth); + if (result != parse_error::kParseNoError) { + return result; + } + glClearDepth(depth); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleClearStencil( + unsigned int arg_count, const gles2::ClearStencil& c) { + GLint s = static_cast<GLint>(c.s); + parse_error::ParseError result = + ValidateClearStencil(this, arg_count, s); + if (result != parse_error::kParseNoError) { + return result; + } + glClearStencil(s); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleColorMask( + unsigned int arg_count, const gles2::ColorMask& c) { + GLboolean red = static_cast<GLboolean>(c.red); + GLboolean green = static_cast<GLboolean>(c.green); + GLboolean blue = static_cast<GLboolean>(c.blue); + GLboolean alpha = static_cast<GLboolean>(c.alpha); + parse_error::ParseError result = + ValidateColorMask(this, arg_count, red, green, blue, alpha); + if (result != parse_error::kParseNoError) { + return result; + } + glColorMask(red, green, blue, alpha); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleCompileShader( + unsigned int arg_count, const gles2::CompileShader& c) { + GLuint shader = static_cast<GLuint>(c.shader); + parse_error::ParseError result = + ValidateCompileShader(this, arg_count, shader); + if (result != parse_error::kParseNoError) { + return result; + } + glCompileShader(shader); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleCompressedTexImage2D( + unsigned int arg_count, const gles2::CompressedTexImage2D& c) { + GLenum target = static_cast<GLenum>(c.target); + GLint level = static_cast<GLint>(c.level); + GLenum internalformat = static_cast<GLenum>(c.internalformat); + GLsizei width = static_cast<GLsizei>(c.width); + GLsizei height = static_cast<GLsizei>(c.height); + GLint border = static_cast<GLint>(c.border); + GLsizei imageSize = static_cast<GLsizei>(c.imageSize); + uint32 data_shm_id = static_cast<uint32>(c.data_shm_id); + uint32 data_shm_offset = static_cast<uint32>(c.data_shm_offset); + uint32 data_size = imageSize; + const void* data = GetSharedMemoryAs<const void*>( + data_shm_id, data_shm_offset, data_size); + parse_error::ParseError result = + ValidateCompressedTexImage2D( + this, arg_count, target, level, internalformat, width, height, border, + imageSize, data); + if (result != parse_error::kParseNoError) { + return result; + } + glCompressedTexImage2D( + target, level, internalformat, width, height, border, imageSize, data); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleCompressedTexImage2DImmediate( + unsigned int arg_count, const gles2::CompressedTexImage2DImmediate& c) { + GLenum target = static_cast<GLenum>(c.target); + GLint level = static_cast<GLint>(c.level); + GLenum internalformat = static_cast<GLenum>(c.internalformat); + GLsizei width = static_cast<GLsizei>(c.width); + GLsizei height = static_cast<GLsizei>(c.height); + GLint border = static_cast<GLint>(c.border); + GLsizei imageSize = static_cast<GLsizei>(c.imageSize); + const void* data = GetImmediateDataAs<const void*>(c); + // Immediate version. + parse_error::ParseError result = + ValidateCompressedTexImage2DImmediate( + this, arg_count, target, level, internalformat, width, height, border, + imageSize, data); + if (result != parse_error::kParseNoError) { + return result; + } + glCompressedTexImage2D( + target, level, internalformat, width, height, border, imageSize, data); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleCompressedTexSubImage2D( + unsigned int arg_count, const gles2::CompressedTexSubImage2D& c) { + GLenum target = static_cast<GLenum>(c.target); + GLint level = static_cast<GLint>(c.level); + GLint xoffset = static_cast<GLint>(c.xoffset); + GLint yoffset = static_cast<GLint>(c.yoffset); + GLsizei width = static_cast<GLsizei>(c.width); + GLsizei height = static_cast<GLsizei>(c.height); + GLenum format = static_cast<GLenum>(c.format); + GLsizei imageSize = static_cast<GLsizei>(c.imageSize); + uint32 data_shm_id = static_cast<uint32>(c.data_shm_id); + uint32 data_shm_offset = static_cast<uint32>(c.data_shm_offset); + uint32 data_size = imageSize; + const void* data = GetSharedMemoryAs<const void*>( + data_shm_id, data_shm_offset, data_size); + parse_error::ParseError result = + ValidateCompressedTexSubImage2D( + this, arg_count, target, level, xoffset, yoffset, width, height, + format, imageSize, data); + if (result != parse_error::kParseNoError) { + return result; + } + glCompressedTexSubImage2D( + target, level, xoffset, yoffset, width, height, format, imageSize, data); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleCompressedTexSubImage2DImmediate( + unsigned int arg_count, const gles2::CompressedTexSubImage2DImmediate& c) { + GLenum target = static_cast<GLenum>(c.target); + GLint level = static_cast<GLint>(c.level); + GLint xoffset = static_cast<GLint>(c.xoffset); + GLint yoffset = static_cast<GLint>(c.yoffset); + GLsizei width = static_cast<GLsizei>(c.width); + GLsizei height = static_cast<GLsizei>(c.height); + GLenum format = static_cast<GLenum>(c.format); + GLsizei imageSize = static_cast<GLsizei>(c.imageSize); + const void* data = GetImmediateDataAs<const void*>(c); + // Immediate version. + parse_error::ParseError result = + ValidateCompressedTexSubImage2DImmediate( + this, arg_count, target, level, xoffset, yoffset, width, height, + format, imageSize, data); + if (result != parse_error::kParseNoError) { + return result; + } + glCompressedTexSubImage2D( + target, level, xoffset, yoffset, width, height, format, imageSize, data); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleCopyTexImage2D( + unsigned int arg_count, const gles2::CopyTexImage2D& c) { + GLenum target = static_cast<GLenum>(c.target); + GLint level = static_cast<GLint>(c.level); + GLenum internalformat = static_cast<GLenum>(c.internalformat); + GLint x = static_cast<GLint>(c.x); + GLint y = static_cast<GLint>(c.y); + GLsizei width = static_cast<GLsizei>(c.width); + GLsizei height = static_cast<GLsizei>(c.height); + GLint border = static_cast<GLint>(c.border); + parse_error::ParseError result = + ValidateCopyTexImage2D( + this, arg_count, target, level, internalformat, x, y, width, height, + border); + if (result != parse_error::kParseNoError) { + return result; + } + glCopyTexImage2D(target, level, internalformat, x, y, width, height, border); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleCopyTexSubImage2D( + unsigned int arg_count, const gles2::CopyTexSubImage2D& c) { + GLenum target = static_cast<GLenum>(c.target); + GLint level = static_cast<GLint>(c.level); + GLint xoffset = static_cast<GLint>(c.xoffset); + GLint yoffset = static_cast<GLint>(c.yoffset); + GLint x = static_cast<GLint>(c.x); + GLint y = static_cast<GLint>(c.y); + GLsizei width = static_cast<GLsizei>(c.width); + GLsizei height = static_cast<GLsizei>(c.height); + parse_error::ParseError result = + ValidateCopyTexSubImage2D( + this, arg_count, target, level, xoffset, yoffset, x, y, width, + height); + if (result != parse_error::kParseNoError) { + return result; + } + glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleCreateProgram( + unsigned int arg_count, const gles2::CreateProgram& c) { + uint32 client_id = c.client_id; + parse_error::ParseError result = + ValidateCreateProgram(this, arg_count); + if (result != parse_error::kParseNoError) { + return result; + } + CreateProgramHelper(client_id); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleCreateShader( + unsigned int arg_count, const gles2::CreateShader& c) { + GLenum type = static_cast<GLenum>(c.type); + uint32 client_id = c.client_id; + parse_error::ParseError result = + ValidateCreateShader(this, arg_count, type); + if (result != parse_error::kParseNoError) { + return result; + } + CreateShaderHelper(type, client_id); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleCullFace( + unsigned int arg_count, const gles2::CullFace& c) { + GLenum mode = static_cast<GLenum>(c.mode); + parse_error::ParseError result = + ValidateCullFace(this, arg_count, mode); + if (result != parse_error::kParseNoError) { + return result; + } + glCullFace(mode); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleDeleteBuffers( + unsigned int arg_count, const gles2::DeleteBuffers& c) { + GLsizei n = static_cast<GLsizei>(c.n); + const GLuint* buffers = GetSharedMemoryAs<const GLuint*>( + c.buffers_shm_id, c.buffers_shm_offset, 0 /* TODO(gman): size */); + parse_error::ParseError result = + ValidateDeleteBuffers(this, arg_count, n, buffers); + if (result != parse_error::kParseNoError) { + return result; + } + DeleteGLObjects<GLDeleteBuffersHelper>(n, buffers); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleDeleteBuffersImmediate( + unsigned int arg_count, const gles2::DeleteBuffersImmediate& c) { + GLsizei n = static_cast<GLsizei>(c.n); + const GLuint* buffers = GetImmediateDataAs<const GLuint*>(c); + parse_error::ParseError result = + ValidateDeleteBuffersImmediate(this, arg_count, n, buffers); + if (result != parse_error::kParseNoError) { + return result; + } + DeleteGLObjects<GLDeleteBuffersHelper>(n, buffers); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleDeleteFramebuffers( + unsigned int arg_count, const gles2::DeleteFramebuffers& c) { + GLsizei n = static_cast<GLsizei>(c.n); + const GLuint* framebuffers = GetSharedMemoryAs<const GLuint*>( + c.framebuffers_shm_id, c.framebuffers_shm_offset, 0 /* TODO( + gman): size */); + parse_error::ParseError result = + ValidateDeleteFramebuffers(this, arg_count, n, framebuffers); + if (result != parse_error::kParseNoError) { + return result; + } + DeleteGLObjects<GLDeleteFramebuffersHelper>(n, framebuffers); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleDeleteFramebuffersImmediate( + unsigned int arg_count, const gles2::DeleteFramebuffersImmediate& c) { + GLsizei n = static_cast<GLsizei>(c.n); + const GLuint* framebuffers = GetImmediateDataAs<const GLuint*>(c); + parse_error::ParseError result = + ValidateDeleteFramebuffersImmediate(this, arg_count, n, framebuffers); + if (result != parse_error::kParseNoError) { + return result; + } + DeleteGLObjects<GLDeleteFramebuffersHelper>(n, framebuffers); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleDeleteProgram( + unsigned int arg_count, const gles2::DeleteProgram& c) { + GLuint program = static_cast<GLuint>(c.program); + parse_error::ParseError result = + ValidateDeleteProgram(this, arg_count, program); + if (result != parse_error::kParseNoError) { + return result; + } + DoDeleteProgram(program); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleDeleteRenderbuffers( + unsigned int arg_count, const gles2::DeleteRenderbuffers& c) { + GLsizei n = static_cast<GLsizei>(c.n); + const GLuint* renderbuffers = GetSharedMemoryAs<const GLuint*>( + c.renderbuffers_shm_id, c.renderbuffers_shm_offset, 0 /* TODO( + gman): size */); + parse_error::ParseError result = + ValidateDeleteRenderbuffers(this, arg_count, n, renderbuffers); + if (result != parse_error::kParseNoError) { + return result; + } + DeleteGLObjects<GLDeleteRenderbuffersHelper>(n, renderbuffers); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleDeleteRenderbuffersImmediate( + unsigned int arg_count, const gles2::DeleteRenderbuffersImmediate& c) { + GLsizei n = static_cast<GLsizei>(c.n); + const GLuint* renderbuffers = GetImmediateDataAs<const GLuint*>(c); + parse_error::ParseError result = + ValidateDeleteRenderbuffersImmediate(this, arg_count, n, renderbuffers); + if (result != parse_error::kParseNoError) { + return result; + } + DeleteGLObjects<GLDeleteRenderbuffersHelper>(n, renderbuffers); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleDeleteShader( + unsigned int arg_count, const gles2::DeleteShader& c) { + GLuint shader = static_cast<GLuint>(c.shader); + parse_error::ParseError result = + ValidateDeleteShader(this, arg_count, shader); + if (result != parse_error::kParseNoError) { + return result; + } + DoDeleteShader(shader); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleDeleteTextures( + unsigned int arg_count, const gles2::DeleteTextures& c) { + GLsizei n = static_cast<GLsizei>(c.n); + const GLuint* textures = GetSharedMemoryAs<const GLuint*>( + c.textures_shm_id, c.textures_shm_offset, 0 /* TODO(gman): size */); + parse_error::ParseError result = + ValidateDeleteTextures(this, arg_count, n, textures); + if (result != parse_error::kParseNoError) { + return result; + } + DeleteGLObjects<GLDeleteTexturesHelper>(n, textures); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleDeleteTexturesImmediate( + unsigned int arg_count, const gles2::DeleteTexturesImmediate& c) { + GLsizei n = static_cast<GLsizei>(c.n); + const GLuint* textures = GetImmediateDataAs<const GLuint*>(c); + parse_error::ParseError result = + ValidateDeleteTexturesImmediate(this, arg_count, n, textures); + if (result != parse_error::kParseNoError) { + return result; + } + DeleteGLObjects<GLDeleteTexturesHelper>(n, textures); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleDepthFunc( + unsigned int arg_count, const gles2::DepthFunc& c) { + GLenum func = static_cast<GLenum>(c.func); + parse_error::ParseError result = + ValidateDepthFunc(this, arg_count, func); + if (result != parse_error::kParseNoError) { + return result; + } + glDepthFunc(func); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleDepthMask( + unsigned int arg_count, const gles2::DepthMask& c) { + GLboolean flag = static_cast<GLboolean>(c.flag); + parse_error::ParseError result = + ValidateDepthMask(this, arg_count, flag); + if (result != parse_error::kParseNoError) { + return result; + } + glDepthMask(flag); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleDepthRangef( + unsigned int arg_count, const gles2::DepthRangef& c) { + GLclampf zNear = static_cast<GLclampf>(c.zNear); + GLclampf zFar = static_cast<GLclampf>(c.zFar); + parse_error::ParseError result = + ValidateDepthRangef(this, arg_count, zNear, zFar); + if (result != parse_error::kParseNoError) { + return result; + } + glDepthRange(zNear, zFar); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleDetachShader( + unsigned int arg_count, const gles2::DetachShader& c) { + GLuint program = static_cast<GLuint>(c.program); + GLuint shader = static_cast<GLuint>(c.shader); + parse_error::ParseError result = + ValidateDetachShader(this, arg_count, program, shader); + if (result != parse_error::kParseNoError) { + return result; + } + glDetachShader(program, shader); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleDisable( + unsigned int arg_count, const gles2::Disable& c) { + GLenum cap = static_cast<GLenum>(c.cap); + parse_error::ParseError result = + ValidateDisable(this, arg_count, cap); + if (result != parse_error::kParseNoError) { + return result; + } + glDisable(cap); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleDisableVertexAttribArray( + unsigned int arg_count, const gles2::DisableVertexAttribArray& c) { + GLuint index = static_cast<GLuint>(c.index); + parse_error::ParseError result = + ValidateDisableVertexAttribArray(this, arg_count, index); + if (result != parse_error::kParseNoError) { + return result; + } + glDisableVertexAttribArray(index); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleDrawArrays( + unsigned int arg_count, const gles2::DrawArrays& c) { + GLenum mode = static_cast<GLenum>(c.mode); + GLint first = static_cast<GLint>(c.first); + GLsizei count = static_cast<GLsizei>(c.count); + parse_error::ParseError result = + ValidateDrawArrays(this, arg_count, mode, first, count); + if (result != parse_error::kParseNoError) { + return result; + } + glDrawArrays(mode, first, count); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleEnable( + unsigned int arg_count, const gles2::Enable& c) { + GLenum cap = static_cast<GLenum>(c.cap); + parse_error::ParseError result = + ValidateEnable(this, arg_count, cap); + if (result != parse_error::kParseNoError) { + return result; + } + glEnable(cap); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleEnableVertexAttribArray( + unsigned int arg_count, const gles2::EnableVertexAttribArray& c) { + GLuint index = static_cast<GLuint>(c.index); + parse_error::ParseError result = + ValidateEnableVertexAttribArray(this, arg_count, index); + if (result != parse_error::kParseNoError) { + return result; + } + glEnableVertexAttribArray(index); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleFinish( + unsigned int arg_count, const gles2::Finish& c) { + parse_error::ParseError result = + ValidateFinish(this, arg_count); + if (result != parse_error::kParseNoError) { + return result; + } + glFinish(); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleFlush( + unsigned int arg_count, const gles2::Flush& c) { + parse_error::ParseError result = + ValidateFlush(this, arg_count); + if (result != parse_error::kParseNoError) { + return result; + } + glFlush(); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleFramebufferRenderbuffer( + unsigned int arg_count, const gles2::FramebufferRenderbuffer& c) { + GLenum target = static_cast<GLenum>(c.target); + GLenum attachment = static_cast<GLenum>(c.attachment); + GLenum renderbuffertarget = static_cast<GLenum>(c.renderbuffertarget); + GLuint renderbuffer = static_cast<GLuint>(c.renderbuffer); + parse_error::ParseError result = + ValidateFramebufferRenderbuffer( + this, arg_count, target, attachment, renderbuffertarget, + renderbuffer); + if (result != parse_error::kParseNoError) { + return result; + } + glFramebufferRenderbuffer( + target, attachment, renderbuffertarget, renderbuffer); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleFramebufferTexture2D( + unsigned int arg_count, const gles2::FramebufferTexture2D& c) { + GLenum target = static_cast<GLenum>(c.target); + GLenum attachment = static_cast<GLenum>(c.attachment); + GLenum textarget = static_cast<GLenum>(c.textarget); + GLuint texture = static_cast<GLuint>(c.texture); + GLint level = static_cast<GLint>(c.level); + parse_error::ParseError result = + ValidateFramebufferTexture2D( + this, arg_count, target, attachment, textarget, texture, level); + if (result != parse_error::kParseNoError) { + return result; + } + glFramebufferTexture2D(target, attachment, textarget, texture, level); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleFrontFace( + unsigned int arg_count, const gles2::FrontFace& c) { + GLenum mode = static_cast<GLenum>(c.mode); + parse_error::ParseError result = + ValidateFrontFace(this, arg_count, mode); + if (result != parse_error::kParseNoError) { + return result; + } + glFrontFace(mode); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleGenBuffers( + unsigned int arg_count, const gles2::GenBuffers& c) { + GLsizei n = static_cast<GLsizei>(c.n); + GLuint* buffers = GetSharedMemoryAs<GLuint*>( + c.buffers_shm_id, c.buffers_shm_offset, 0 /* TODO(gman): size */); + parse_error::ParseError result = + ValidateGenBuffers(this, arg_count, n, buffers); + if (result != parse_error::kParseNoError) { + return result; + } + GenGLObjects<GLGenBuffersHelper>(n, buffers); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleGenBuffersImmediate( + unsigned int arg_count, const gles2::GenBuffersImmediate& c) { + GLsizei n = static_cast<GLsizei>(c.n); + GLuint* buffers = GetImmediateDataAs<GLuint*>(c); + parse_error::ParseError result = + ValidateGenBuffersImmediate(this, arg_count, n, buffers); + if (result != parse_error::kParseNoError) { + return result; + } + GenGLObjects<GLGenBuffersHelper>(n, buffers); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleGenerateMipmap( + unsigned int arg_count, const gles2::GenerateMipmap& c) { + GLenum target = static_cast<GLenum>(c.target); + parse_error::ParseError result = + ValidateGenerateMipmap(this, arg_count, target); + if (result != parse_error::kParseNoError) { + return result; + } + glGenerateMipmap(target); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleGenFramebuffers( + unsigned int arg_count, const gles2::GenFramebuffers& c) { + GLsizei n = static_cast<GLsizei>(c.n); + GLuint* framebuffers = GetSharedMemoryAs<GLuint*>( + c.framebuffers_shm_id, c.framebuffers_shm_offset, 0 /* TODO( + gman): size */); + parse_error::ParseError result = + ValidateGenFramebuffers(this, arg_count, n, framebuffers); + if (result != parse_error::kParseNoError) { + return result; + } + GenGLObjects<GLGenFramebuffersHelper>(n, framebuffers); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleGenFramebuffersImmediate( + unsigned int arg_count, const gles2::GenFramebuffersImmediate& c) { + GLsizei n = static_cast<GLsizei>(c.n); + GLuint* framebuffers = GetImmediateDataAs<GLuint*>(c); + parse_error::ParseError result = + ValidateGenFramebuffersImmediate(this, arg_count, n, framebuffers); + if (result != parse_error::kParseNoError) { + return result; + } + GenGLObjects<GLGenFramebuffersHelper>(n, framebuffers); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleGenRenderbuffers( + unsigned int arg_count, const gles2::GenRenderbuffers& c) { + GLsizei n = static_cast<GLsizei>(c.n); + GLuint* renderbuffers = GetSharedMemoryAs<GLuint*>( + c.renderbuffers_shm_id, c.renderbuffers_shm_offset, 0 /* TODO( + gman): size */); + parse_error::ParseError result = + ValidateGenRenderbuffers(this, arg_count, n, renderbuffers); + if (result != parse_error::kParseNoError) { + return result; + } + GenGLObjects<GLGenRenderbuffersHelper>(n, renderbuffers); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleGenRenderbuffersImmediate( + unsigned int arg_count, const gles2::GenRenderbuffersImmediate& c) { + GLsizei n = static_cast<GLsizei>(c.n); + GLuint* renderbuffers = GetImmediateDataAs<GLuint*>(c); + parse_error::ParseError result = + ValidateGenRenderbuffersImmediate(this, arg_count, n, renderbuffers); + if (result != parse_error::kParseNoError) { + return result; + } + GenGLObjects<GLGenRenderbuffersHelper>(n, renderbuffers); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleGenTextures( + unsigned int arg_count, const gles2::GenTextures& c) { + GLsizei n = static_cast<GLsizei>(c.n); + GLuint* textures = GetSharedMemoryAs<GLuint*>( + c.textures_shm_id, c.textures_shm_offset, 0 /* TODO(gman): size */); + parse_error::ParseError result = + ValidateGenTextures(this, arg_count, n, textures); + if (result != parse_error::kParseNoError) { + return result; + } + GenGLObjects<GLGenTexturesHelper>(n, textures); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleGenTexturesImmediate( + unsigned int arg_count, const gles2::GenTexturesImmediate& c) { + GLsizei n = static_cast<GLsizei>(c.n); + GLuint* textures = GetImmediateDataAs<GLuint*>(c); + parse_error::ParseError result = + ValidateGenTexturesImmediate(this, arg_count, n, textures); + if (result != parse_error::kParseNoError) { + return result; + } + GenGLObjects<GLGenTexturesHelper>(n, textures); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleGetAttribLocation( + unsigned int arg_count, const gles2::GetAttribLocation& c) { + GLuint program = static_cast<GLuint>(c.program); + uint32 name_size = c.data_size; + const char* name = GetSharedMemoryAs<const char*>( + c.name_shm_id, c.name_shm_offset, name_size); + parse_error::ParseError result = + ValidateGetAttribLocation(this, arg_count, program, name); + if (result != parse_error::kParseNoError) { + return result; + } + String name_str(name, name_size); + glGetAttribLocation(program, name_str.c_str()); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleGetAttribLocationImmediate( + unsigned int arg_count, const gles2::GetAttribLocationImmediate& c) { + GLuint program = static_cast<GLuint>(c.program); + uint32 name_size = c.data_size; + const char* name = GetImmediateDataAs<const char*>(c); + // TODO(gman): Make sure validate checks arg_count + // covers data_size. + parse_error::ParseError result = + ValidateGetAttribLocationImmediate(this, arg_count, program, name); + if (result != parse_error::kParseNoError) { + return result; + } + String name_str(name, name_size); + glGetAttribLocation(program, name_str.c_str()); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleGetBooleanv( + unsigned int arg_count, const gles2::GetBooleanv& c) { + GLenum pname = static_cast<GLenum>(c.pname); + GLboolean* params; + GLsizei num_values = util_.GLGetNumValuesReturned(pname); + uint32 params_size = num_values * sizeof(*params); + params = GetSharedMemoryAs<GLboolean*>( + c.params_shm_id, c.params_shm_offset, params_size); + parse_error::ParseError result = + ValidateGetBooleanv(this, arg_count, pname, params); + if (result != parse_error::kParseNoError) { + return result; + } + glGetBooleanv(pname, params); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleGetBufferParameteriv( + unsigned int arg_count, const gles2::GetBufferParameteriv& c) { + GLenum target = static_cast<GLenum>(c.target); + GLenum pname = static_cast<GLenum>(c.pname); + GLint* params; + GLsizei num_values = util_.GLGetNumValuesReturned(pname); + uint32 params_size = num_values * sizeof(*params); + params = GetSharedMemoryAs<GLint*>( + c.params_shm_id, c.params_shm_offset, params_size); + parse_error::ParseError result = + ValidateGetBufferParameteriv(this, arg_count, target, pname, params); + if (result != parse_error::kParseNoError) { + return result; + } + glGetBufferParameteriv(target, pname, params); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleGetError( + unsigned int arg_count, const gles2::GetError& c) { + GLenum* result_dst = GetSharedMemoryAs<GLenum*>( + c.result_shm_id, c.result_shm_offset, sizeof(*result_dst)); + parse_error::ParseError result = + ValidateGetError(this, arg_count); + if (result != parse_error::kParseNoError) { + return result; + } + *result_dst = glGetError(); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleGetFloatv( + unsigned int arg_count, const gles2::GetFloatv& c) { + GLenum pname = static_cast<GLenum>(c.pname); + GLfloat* params; + GLsizei num_values = util_.GLGetNumValuesReturned(pname); + uint32 params_size = num_values * sizeof(*params); + params = GetSharedMemoryAs<GLfloat*>( + c.params_shm_id, c.params_shm_offset, params_size); + parse_error::ParseError result = + ValidateGetFloatv(this, arg_count, pname, params); + if (result != parse_error::kParseNoError) { + return result; + } + glGetFloatv(pname, params); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleGetFramebufferAttachmentParameteriv( + + unsigned int arg_count, + const gles2::GetFramebufferAttachmentParameteriv& c) { + GLenum target = static_cast<GLenum>(c.target); + GLenum attachment = static_cast<GLenum>(c.attachment); + GLenum pname = static_cast<GLenum>(c.pname); + GLint* params; + GLsizei num_values = util_.GLGetNumValuesReturned(pname); + uint32 params_size = num_values * sizeof(*params); + params = GetSharedMemoryAs<GLint*>( + c.params_shm_id, c.params_shm_offset, params_size); + parse_error::ParseError result = + ValidateGetFramebufferAttachmentParameteriv( + this, arg_count, target, attachment, pname, params); + if (result != parse_error::kParseNoError) { + return result; + } + glGetFramebufferAttachmentParameteriv(target, attachment, pname, params); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleGetIntegerv( + unsigned int arg_count, const gles2::GetIntegerv& c) { + GLenum pname = static_cast<GLenum>(c.pname); + GLint* params; + GLsizei num_values = util_.GLGetNumValuesReturned(pname); + uint32 params_size = num_values * sizeof(*params); + params = GetSharedMemoryAs<GLint*>( + c.params_shm_id, c.params_shm_offset, params_size); + parse_error::ParseError result = + ValidateGetIntegerv(this, arg_count, pname, params); + if (result != parse_error::kParseNoError) { + return result; + } + glGetIntegerv(pname, params); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleGetProgramiv( + unsigned int arg_count, const gles2::GetProgramiv& c) { + GLuint program = static_cast<GLuint>(c.program); + GLenum pname = static_cast<GLenum>(c.pname); + GLint* params; + GLsizei num_values = util_.GLGetNumValuesReturned(pname); + uint32 params_size = num_values * sizeof(*params); + params = GetSharedMemoryAs<GLint*>( + c.params_shm_id, c.params_shm_offset, params_size); + parse_error::ParseError result = + ValidateGetProgramiv(this, arg_count, program, pname, params); + if (result != parse_error::kParseNoError) { + return result; + } + glGetProgramiv(program, pname, params); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleGetProgramInfoLog( + unsigned int arg_count, const gles2::GetProgramInfoLog& c) { + GLuint program = static_cast<GLuint>(c.program); + GLsizei bufsize = static_cast<GLsizei>(c.bufsize); + GLsizei* length = GetSharedMemoryAs<GLsizei*>( + c.length_shm_id, c.length_shm_offset, 0 /* TODO(gman): size */); + char* infolog = GetSharedMemoryAs<char*>( + c.infolog_shm_id, c.infolog_shm_offset, 0 /* TODO(gman): size */); + parse_error::ParseError result = + ValidateGetProgramInfoLog( + this, arg_count, program, bufsize, length, infolog); + if (result != parse_error::kParseNoError) { + return result; + } + glGetProgramInfoLog(program, bufsize, length, infolog); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleGetRenderbufferParameteriv( + unsigned int arg_count, const gles2::GetRenderbufferParameteriv& c) { + GLenum target = static_cast<GLenum>(c.target); + GLenum pname = static_cast<GLenum>(c.pname); + GLint* params; + GLsizei num_values = util_.GLGetNumValuesReturned(pname); + uint32 params_size = num_values * sizeof(*params); + params = GetSharedMemoryAs<GLint*>( + c.params_shm_id, c.params_shm_offset, params_size); + parse_error::ParseError result = + ValidateGetRenderbufferParameteriv( + this, arg_count, target, pname, params); + if (result != parse_error::kParseNoError) { + return result; + } + glGetRenderbufferParameteriv(target, pname, params); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleGetShaderiv( + unsigned int arg_count, const gles2::GetShaderiv& c) { + GLuint shader = static_cast<GLuint>(c.shader); + GLenum pname = static_cast<GLenum>(c.pname); + GLint* params; + GLsizei num_values = util_.GLGetNumValuesReturned(pname); + uint32 params_size = num_values * sizeof(*params); + params = GetSharedMemoryAs<GLint*>( + c.params_shm_id, c.params_shm_offset, params_size); + parse_error::ParseError result = + ValidateGetShaderiv(this, arg_count, shader, pname, params); + if (result != parse_error::kParseNoError) { + return result; + } + glGetShaderiv(shader, pname, params); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleGetShaderInfoLog( + unsigned int arg_count, const gles2::GetShaderInfoLog& c) { + GLuint shader = static_cast<GLuint>(c.shader); + GLsizei bufsize = static_cast<GLsizei>(c.bufsize); + GLsizei* length = GetSharedMemoryAs<GLsizei*>( + c.length_shm_id, c.length_shm_offset, 0 /* TODO(gman): size */); + char* infolog = GetSharedMemoryAs<char*>( + c.infolog_shm_id, c.infolog_shm_offset, 0 /* TODO(gman): size */); + parse_error::ParseError result = + ValidateGetShaderInfoLog( + this, arg_count, shader, bufsize, length, infolog); + if (result != parse_error::kParseNoError) { + return result; + } + glGetShaderInfoLog(shader, bufsize, length, infolog); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleGetShaderSource( + unsigned int arg_count, const gles2::GetShaderSource& c) { + GLuint shader = static_cast<GLuint>(c.shader); + GLsizei bufsize = static_cast<GLsizei>(c.bufsize); + GLsizei* length = GetSharedMemoryAs<GLsizei*>( + c.length_shm_id, c.length_shm_offset, 0 /* TODO(gman): size */); + char* source = GetSharedMemoryAs<char*>( + c.source_shm_id, c.source_shm_offset, 0 /* TODO(gman): size */); + parse_error::ParseError result = + ValidateGetShaderSource( + this, arg_count, shader, bufsize, length, source); + if (result != parse_error::kParseNoError) { + return result; + } + glGetShaderSource(shader, bufsize, length, source); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleGetString( + unsigned int arg_count, const gles2::GetString& c) { + GLenum name = static_cast<GLenum>(c.name); + parse_error::ParseError result = + ValidateGetString(this, arg_count, name); + if (result != parse_error::kParseNoError) { + return result; + } + glGetString(name); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleGetTexParameterfv( + unsigned int arg_count, const gles2::GetTexParameterfv& c) { + GLenum target = static_cast<GLenum>(c.target); + GLenum pname = static_cast<GLenum>(c.pname); + GLfloat* params; + GLsizei num_values = util_.GLGetNumValuesReturned(pname); + uint32 params_size = num_values * sizeof(*params); + params = GetSharedMemoryAs<GLfloat*>( + c.params_shm_id, c.params_shm_offset, params_size); + parse_error::ParseError result = + ValidateGetTexParameterfv(this, arg_count, target, pname, params); + if (result != parse_error::kParseNoError) { + return result; + } + glGetTexParameterfv(target, pname, params); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleGetTexParameteriv( + unsigned int arg_count, const gles2::GetTexParameteriv& c) { + GLenum target = static_cast<GLenum>(c.target); + GLenum pname = static_cast<GLenum>(c.pname); + GLint* params; + GLsizei num_values = util_.GLGetNumValuesReturned(pname); + uint32 params_size = num_values * sizeof(*params); + params = GetSharedMemoryAs<GLint*>( + c.params_shm_id, c.params_shm_offset, params_size); + parse_error::ParseError result = + ValidateGetTexParameteriv(this, arg_count, target, pname, params); + if (result != parse_error::kParseNoError) { + return result; + } + glGetTexParameteriv(target, pname, params); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleGetUniformLocation( + unsigned int arg_count, const gles2::GetUniformLocation& c) { + GLuint program = static_cast<GLuint>(c.program); + uint32 name_size = c.data_size; + const char* name = GetSharedMemoryAs<const char*>( + c.name_shm_id, c.name_shm_offset, name_size); + parse_error::ParseError result = + ValidateGetUniformLocation(this, arg_count, program, name); + if (result != parse_error::kParseNoError) { + return result; + } + String name_str(name, name_size); + glGetUniformLocation(program, name_str.c_str()); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleGetUniformLocationImmediate( + unsigned int arg_count, const gles2::GetUniformLocationImmediate& c) { + GLuint program = static_cast<GLuint>(c.program); + uint32 name_size = c.data_size; + const char* name = GetImmediateDataAs<const char*>(c); + // TODO(gman): Make sure validate checks arg_count + // covers data_size. + parse_error::ParseError result = + ValidateGetUniformLocationImmediate(this, arg_count, program, name); + if (result != parse_error::kParseNoError) { + return result; + } + String name_str(name, name_size); + glGetUniformLocation(program, name_str.c_str()); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleGetVertexAttribfv( + unsigned int arg_count, const gles2::GetVertexAttribfv& c) { + GLuint index = static_cast<GLuint>(c.index); + GLenum pname = static_cast<GLenum>(c.pname); + GLfloat* params; + GLsizei num_values = util_.GLGetNumValuesReturned(pname); + uint32 params_size = num_values * sizeof(*params); + params = GetSharedMemoryAs<GLfloat*>( + c.params_shm_id, c.params_shm_offset, params_size); + parse_error::ParseError result = + ValidateGetVertexAttribfv(this, arg_count, index, pname, params); + if (result != parse_error::kParseNoError) { + return result; + } + glGetVertexAttribfv(index, pname, params); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleGetVertexAttribiv( + unsigned int arg_count, const gles2::GetVertexAttribiv& c) { + GLuint index = static_cast<GLuint>(c.index); + GLenum pname = static_cast<GLenum>(c.pname); + GLint* params; + GLsizei num_values = util_.GLGetNumValuesReturned(pname); + uint32 params_size = num_values * sizeof(*params); + params = GetSharedMemoryAs<GLint*>( + c.params_shm_id, c.params_shm_offset, params_size); + parse_error::ParseError result = + ValidateGetVertexAttribiv(this, arg_count, index, pname, params); + if (result != parse_error::kParseNoError) { + return result; + } + glGetVertexAttribiv(index, pname, params); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleHint( + unsigned int arg_count, const gles2::Hint& c) { + GLenum target = static_cast<GLenum>(c.target); + GLenum mode = static_cast<GLenum>(c.mode); + parse_error::ParseError result = + ValidateHint(this, arg_count, target, mode); + if (result != parse_error::kParseNoError) { + return result; + } + glHint(target, mode); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleIsBuffer( + unsigned int arg_count, const gles2::IsBuffer& c) { + GLuint buffer = static_cast<GLuint>(c.buffer); + GLboolean* result_dst = GetSharedMemoryAs<GLboolean*>( + c.result_shm_id, c.result_shm_offset, sizeof(*result_dst)); + parse_error::ParseError result = + ValidateIsBuffer(this, arg_count, buffer); + if (result != parse_error::kParseNoError) { + return result; + } + *result_dst = glIsBuffer(buffer); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleIsEnabled( + unsigned int arg_count, const gles2::IsEnabled& c) { + GLenum cap = static_cast<GLenum>(c.cap); + GLboolean* result_dst = GetSharedMemoryAs<GLboolean*>( + c.result_shm_id, c.result_shm_offset, sizeof(*result_dst)); + parse_error::ParseError result = + ValidateIsEnabled(this, arg_count, cap); + if (result != parse_error::kParseNoError) { + return result; + } + *result_dst = glIsEnabled(cap); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleIsFramebuffer( + unsigned int arg_count, const gles2::IsFramebuffer& c) { + GLuint framebuffer = static_cast<GLuint>(c.framebuffer); + GLboolean* result_dst = GetSharedMemoryAs<GLboolean*>( + c.result_shm_id, c.result_shm_offset, sizeof(*result_dst)); + parse_error::ParseError result = + ValidateIsFramebuffer(this, arg_count, framebuffer); + if (result != parse_error::kParseNoError) { + return result; + } + *result_dst = glIsFramebuffer(framebuffer); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleIsProgram( + unsigned int arg_count, const gles2::IsProgram& c) { + GLuint program = static_cast<GLuint>(c.program); + GLboolean* result_dst = GetSharedMemoryAs<GLboolean*>( + c.result_shm_id, c.result_shm_offset, sizeof(*result_dst)); + parse_error::ParseError result = + ValidateIsProgram(this, arg_count, program); + if (result != parse_error::kParseNoError) { + return result; + } + *result_dst = glIsProgram(program); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleIsRenderbuffer( + unsigned int arg_count, const gles2::IsRenderbuffer& c) { + GLuint renderbuffer = static_cast<GLuint>(c.renderbuffer); + GLboolean* result_dst = GetSharedMemoryAs<GLboolean*>( + c.result_shm_id, c.result_shm_offset, sizeof(*result_dst)); + parse_error::ParseError result = + ValidateIsRenderbuffer(this, arg_count, renderbuffer); + if (result != parse_error::kParseNoError) { + return result; + } + *result_dst = glIsRenderbuffer(renderbuffer); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleIsShader( + unsigned int arg_count, const gles2::IsShader& c) { + GLuint shader = static_cast<GLuint>(c.shader); + GLboolean* result_dst = GetSharedMemoryAs<GLboolean*>( + c.result_shm_id, c.result_shm_offset, sizeof(*result_dst)); + parse_error::ParseError result = + ValidateIsShader(this, arg_count, shader); + if (result != parse_error::kParseNoError) { + return result; + } + *result_dst = glIsShader(shader); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleIsTexture( + unsigned int arg_count, const gles2::IsTexture& c) { + GLuint texture = static_cast<GLuint>(c.texture); + GLboolean* result_dst = GetSharedMemoryAs<GLboolean*>( + c.result_shm_id, c.result_shm_offset, sizeof(*result_dst)); + parse_error::ParseError result = + ValidateIsTexture(this, arg_count, texture); + if (result != parse_error::kParseNoError) { + return result; + } + *result_dst = glIsTexture(texture); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleLineWidth( + unsigned int arg_count, const gles2::LineWidth& c) { + GLfloat width = static_cast<GLfloat>(c.width); + parse_error::ParseError result = + ValidateLineWidth(this, arg_count, width); + if (result != parse_error::kParseNoError) { + return result; + } + glLineWidth(width); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleLinkProgram( + unsigned int arg_count, const gles2::LinkProgram& c) { + GLuint program = static_cast<GLuint>(c.program); + parse_error::ParseError result = + ValidateLinkProgram(this, arg_count, program); + if (result != parse_error::kParseNoError) { + return result; + } + glLinkProgram(program); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandlePolygonOffset( + unsigned int arg_count, const gles2::PolygonOffset& c) { + GLfloat factor = static_cast<GLfloat>(c.factor); + GLfloat units = static_cast<GLfloat>(c.units); + parse_error::ParseError result = + ValidatePolygonOffset(this, arg_count, factor, units); + if (result != parse_error::kParseNoError) { + return result; + } + glPolygonOffset(factor, units); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleRenderbufferStorage( + unsigned int arg_count, const gles2::RenderbufferStorage& c) { + GLenum target = static_cast<GLenum>(c.target); + GLenum internalformat = static_cast<GLenum>(c.internalformat); + GLsizei width = static_cast<GLsizei>(c.width); + GLsizei height = static_cast<GLsizei>(c.height); + parse_error::ParseError result = + ValidateRenderbufferStorage( + this, arg_count, target, internalformat, width, height); + if (result != parse_error::kParseNoError) { + return result; + } + glRenderbufferStorage(target, internalformat, width, height); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleSampleCoverage( + unsigned int arg_count, const gles2::SampleCoverage& c) { + GLclampf value = static_cast<GLclampf>(c.value); + GLboolean invert = static_cast<GLboolean>(c.invert); + parse_error::ParseError result = + ValidateSampleCoverage(this, arg_count, value, invert); + if (result != parse_error::kParseNoError) { + return result; + } + glSampleCoverage(value, invert); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleScissor( + unsigned int arg_count, const gles2::Scissor& c) { + GLint x = static_cast<GLint>(c.x); + GLint y = static_cast<GLint>(c.y); + GLsizei width = static_cast<GLsizei>(c.width); + GLsizei height = static_cast<GLsizei>(c.height); + parse_error::ParseError result = + ValidateScissor(this, arg_count, x, y, width, height); + if (result != parse_error::kParseNoError) { + return result; + } + glScissor(x, y, width, height); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleStencilFunc( + unsigned int arg_count, const gles2::StencilFunc& c) { + GLenum func = static_cast<GLenum>(c.func); + GLint ref = static_cast<GLint>(c.ref); + GLuint mask = static_cast<GLuint>(c.mask); + parse_error::ParseError result = + ValidateStencilFunc(this, arg_count, func, ref, mask); + if (result != parse_error::kParseNoError) { + return result; + } + glStencilFunc(func, ref, mask); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleStencilFuncSeparate( + unsigned int arg_count, const gles2::StencilFuncSeparate& c) { + GLenum face = static_cast<GLenum>(c.face); + GLenum func = static_cast<GLenum>(c.func); + GLint ref = static_cast<GLint>(c.ref); + GLuint mask = static_cast<GLuint>(c.mask); + parse_error::ParseError result = + ValidateStencilFuncSeparate(this, arg_count, face, func, ref, mask); + if (result != parse_error::kParseNoError) { + return result; + } + glStencilFuncSeparate(face, func, ref, mask); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleStencilMask( + unsigned int arg_count, const gles2::StencilMask& c) { + GLuint mask = static_cast<GLuint>(c.mask); + parse_error::ParseError result = + ValidateStencilMask(this, arg_count, mask); + if (result != parse_error::kParseNoError) { + return result; + } + glStencilMask(mask); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleStencilMaskSeparate( + unsigned int arg_count, const gles2::StencilMaskSeparate& c) { + GLenum face = static_cast<GLenum>(c.face); + GLuint mask = static_cast<GLuint>(c.mask); + parse_error::ParseError result = + ValidateStencilMaskSeparate(this, arg_count, face, mask); + if (result != parse_error::kParseNoError) { + return result; + } + glStencilMaskSeparate(face, mask); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleStencilOp( + unsigned int arg_count, const gles2::StencilOp& c) { + GLenum fail = static_cast<GLenum>(c.fail); + GLenum zfail = static_cast<GLenum>(c.zfail); + GLenum zpass = static_cast<GLenum>(c.zpass); + parse_error::ParseError result = + ValidateStencilOp(this, arg_count, fail, zfail, zpass); + if (result != parse_error::kParseNoError) { + return result; + } + glStencilOp(fail, zfail, zpass); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleStencilOpSeparate( + unsigned int arg_count, const gles2::StencilOpSeparate& c) { + GLenum face = static_cast<GLenum>(c.face); + GLenum fail = static_cast<GLenum>(c.fail); + GLenum zfail = static_cast<GLenum>(c.zfail); + GLenum zpass = static_cast<GLenum>(c.zpass); + parse_error::ParseError result = + ValidateStencilOpSeparate(this, arg_count, face, fail, zfail, zpass); + if (result != parse_error::kParseNoError) { + return result; + } + glStencilOpSeparate(face, fail, zfail, zpass); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleTexImage2D( + unsigned int arg_count, const gles2::TexImage2D& c) { + GLenum target = static_cast<GLenum>(c.target); + GLint level = static_cast<GLint>(c.level); + GLint internalformat = static_cast<GLint>(c.internalformat); + GLsizei width = static_cast<GLsizei>(c.width); + GLsizei height = static_cast<GLsizei>(c.height); + GLint border = static_cast<GLint>(c.border); + GLenum format = static_cast<GLenum>(c.format); + GLenum type = static_cast<GLenum>(c.type); + uint32 pixels_shm_id = static_cast<uint32>(c.pixels_shm_id); + uint32 pixels_shm_offset = static_cast<uint32>(c.pixels_shm_offset); + uint32 pixels_size = GLES2Util::ComputeImageDataSize( + width, height, format, type, unpack_alignment_); + const void* pixels = GetSharedMemoryAs<const void*>( + pixels_shm_id, pixels_shm_offset, pixels_size); + parse_error::ParseError result = + ValidateTexImage2D( + this, arg_count, target, level, internalformat, width, height, border, + format, type, pixels); + if (result != parse_error::kParseNoError) { + return result; + } + glTexImage2D( + target, level, internalformat, width, height, border, format, type, + pixels); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleTexImage2DImmediate( + unsigned int arg_count, const gles2::TexImage2DImmediate& c) { + GLenum target = static_cast<GLenum>(c.target); + GLint level = static_cast<GLint>(c.level); + GLint internalformat = static_cast<GLint>(c.internalformat); + GLsizei width = static_cast<GLsizei>(c.width); + GLsizei height = static_cast<GLsizei>(c.height); + GLint border = static_cast<GLint>(c.border); + GLenum format = static_cast<GLenum>(c.format); + GLenum type = static_cast<GLenum>(c.type); + const void* pixels = GetImmediateDataAs<const void*>(c); + // Immediate version. + parse_error::ParseError result = + ValidateTexImage2DImmediate( + this, arg_count, target, level, internalformat, width, height, border, + format, type, pixels); + if (result != parse_error::kParseNoError) { + return result; + } + glTexImage2D( + target, level, internalformat, width, height, border, format, type, + pixels); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleTexParameterf( + unsigned int arg_count, const gles2::TexParameterf& c) { + GLenum target = static_cast<GLenum>(c.target); + GLenum pname = static_cast<GLenum>(c.pname); + GLfloat param = static_cast<GLfloat>(c.param); + parse_error::ParseError result = + ValidateTexParameterf(this, arg_count, target, pname, param); + if (result != parse_error::kParseNoError) { + return result; + } + glTexParameterf(target, pname, param); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleTexParameterfv( + unsigned int arg_count, const gles2::TexParameterfv& c) { + GLenum target = static_cast<GLenum>(c.target); + GLenum pname = static_cast<GLenum>(c.pname); + const GLfloat* params = GetSharedMemoryAs<const GLfloat*>( + c.params_shm_id, c.params_shm_offset, 0 /* TODO(gman): size */); + parse_error::ParseError result = + ValidateTexParameterfv(this, arg_count, target, pname, params); + if (result != parse_error::kParseNoError) { + return result; + } + glTexParameterfv(target, pname, params); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleTexParameterfvImmediate( + unsigned int arg_count, const gles2::TexParameterfvImmediate& c) { + GLenum target = static_cast<GLenum>(c.target); + GLenum pname = static_cast<GLenum>(c.pname); + const GLfloat* params = GetImmediateDataAs<const GLfloat*>(c); + // Immediate version. + parse_error::ParseError result = + ValidateTexParameterfvImmediate(this, arg_count, target, pname, params); + if (result != parse_error::kParseNoError) { + return result; + } + glTexParameterfv(target, pname, params); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleTexParameteri( + unsigned int arg_count, const gles2::TexParameteri& c) { + GLenum target = static_cast<GLenum>(c.target); + GLenum pname = static_cast<GLenum>(c.pname); + GLint param = static_cast<GLint>(c.param); + parse_error::ParseError result = + ValidateTexParameteri(this, arg_count, target, pname, param); + if (result != parse_error::kParseNoError) { + return result; + } + glTexParameteri(target, pname, param); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleTexParameteriv( + unsigned int arg_count, const gles2::TexParameteriv& c) { + GLenum target = static_cast<GLenum>(c.target); + GLenum pname = static_cast<GLenum>(c.pname); + const GLint* params = GetSharedMemoryAs<const GLint*>( + c.params_shm_id, c.params_shm_offset, 0 /* TODO(gman): size */); + parse_error::ParseError result = + ValidateTexParameteriv(this, arg_count, target, pname, params); + if (result != parse_error::kParseNoError) { + return result; + } + glTexParameteriv(target, pname, params); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleTexParameterivImmediate( + unsigned int arg_count, const gles2::TexParameterivImmediate& c) { + GLenum target = static_cast<GLenum>(c.target); + GLenum pname = static_cast<GLenum>(c.pname); + const GLint* params = GetImmediateDataAs<const GLint*>(c); + // Immediate version. + parse_error::ParseError result = + ValidateTexParameterivImmediate(this, arg_count, target, pname, params); + if (result != parse_error::kParseNoError) { + return result; + } + glTexParameteriv(target, pname, params); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleTexSubImage2D( + unsigned int arg_count, const gles2::TexSubImage2D& c) { + GLenum target = static_cast<GLenum>(c.target); + GLint level = static_cast<GLint>(c.level); + GLint xoffset = static_cast<GLint>(c.xoffset); + GLint yoffset = static_cast<GLint>(c.yoffset); + GLsizei width = static_cast<GLsizei>(c.width); + GLsizei height = static_cast<GLsizei>(c.height); + GLenum format = static_cast<GLenum>(c.format); + GLenum type = static_cast<GLenum>(c.type); + uint32 pixels_shm_id = static_cast<uint32>(c.pixels_shm_id); + uint32 pixels_shm_offset = static_cast<uint32>(c.pixels_shm_offset); + uint32 pixels_size = GLES2Util::ComputeImageDataSize( + width, height, format, type, unpack_alignment_); + const void* pixels = GetSharedMemoryAs<const void*>( + pixels_shm_id, pixels_shm_offset, pixels_size); + parse_error::ParseError result = + ValidateTexSubImage2D( + this, arg_count, target, level, xoffset, yoffset, width, height, + format, type, pixels); + if (result != parse_error::kParseNoError) { + return result; + } + glTexSubImage2D( + target, level, xoffset, yoffset, width, height, format, type, pixels); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleTexSubImage2DImmediate( + unsigned int arg_count, const gles2::TexSubImage2DImmediate& c) { + GLenum target = static_cast<GLenum>(c.target); + GLint level = static_cast<GLint>(c.level); + GLint xoffset = static_cast<GLint>(c.xoffset); + GLint yoffset = static_cast<GLint>(c.yoffset); + GLsizei width = static_cast<GLsizei>(c.width); + GLsizei height = static_cast<GLsizei>(c.height); + GLenum format = static_cast<GLenum>(c.format); + GLenum type = static_cast<GLenum>(c.type); + const void* pixels = GetImmediateDataAs<const void*>(c); + // Immediate version. + parse_error::ParseError result = + ValidateTexSubImage2DImmediate( + this, arg_count, target, level, xoffset, yoffset, width, height, + format, type, pixels); + if (result != parse_error::kParseNoError) { + return result; + } + glTexSubImage2D( + target, level, xoffset, yoffset, width, height, format, type, pixels); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleUniform1f( + unsigned int arg_count, const gles2::Uniform1f& c) { + GLint location = static_cast<GLint>(c.location); + GLfloat x = static_cast<GLfloat>(c.x); + parse_error::ParseError result = + ValidateUniform1f(this, arg_count, location, x); + if (result != parse_error::kParseNoError) { + return result; + } + glUniform1f(location, x); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleUniform1fv( + unsigned int arg_count, const gles2::Uniform1fv& c) { + GLint location = static_cast<GLint>(c.location); + GLsizei count = static_cast<GLsizei>(c.count); + const GLfloat* v = GetSharedMemoryAs<const GLfloat*>( + c.v_shm_id, c.v_shm_offset, 0 /* TODO(gman): size */); + parse_error::ParseError result = + ValidateUniform1fv(this, arg_count, location, count, v); + if (result != parse_error::kParseNoError) { + return result; + } + glUniform1fv(location, count, v); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleUniform1fvImmediate( + unsigned int arg_count, const gles2::Uniform1fvImmediate& c) { + GLint location = static_cast<GLint>(c.location); + GLsizei count = static_cast<GLsizei>(c.count); + const GLfloat* v = GetImmediateDataAs<const GLfloat*>(c); + // Immediate version. + parse_error::ParseError result = + ValidateUniform1fvImmediate(this, arg_count, location, count, v); + if (result != parse_error::kParseNoError) { + return result; + } + glUniform1fv(location, count, v); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleUniform1i( + unsigned int arg_count, const gles2::Uniform1i& c) { + GLint location = static_cast<GLint>(c.location); + GLint x = static_cast<GLint>(c.x); + parse_error::ParseError result = + ValidateUniform1i(this, arg_count, location, x); + if (result != parse_error::kParseNoError) { + return result; + } + glUniform1i(location, x); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleUniform1iv( + unsigned int arg_count, const gles2::Uniform1iv& c) { + GLint location = static_cast<GLint>(c.location); + GLsizei count = static_cast<GLsizei>(c.count); + const GLint* v = GetSharedMemoryAs<const GLint*>( + c.v_shm_id, c.v_shm_offset, 0 /* TODO(gman): size */); + parse_error::ParseError result = + ValidateUniform1iv(this, arg_count, location, count, v); + if (result != parse_error::kParseNoError) { + return result; + } + glUniform1iv(location, count, v); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleUniform1ivImmediate( + unsigned int arg_count, const gles2::Uniform1ivImmediate& c) { + GLint location = static_cast<GLint>(c.location); + GLsizei count = static_cast<GLsizei>(c.count); + const GLint* v = GetImmediateDataAs<const GLint*>(c); + // Immediate version. + parse_error::ParseError result = + ValidateUniform1ivImmediate(this, arg_count, location, count, v); + if (result != parse_error::kParseNoError) { + return result; + } + glUniform1iv(location, count, v); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleUniform2f( + unsigned int arg_count, const gles2::Uniform2f& c) { + GLint location = static_cast<GLint>(c.location); + GLfloat x = static_cast<GLfloat>(c.x); + GLfloat y = static_cast<GLfloat>(c.y); + parse_error::ParseError result = + ValidateUniform2f(this, arg_count, location, x, y); + if (result != parse_error::kParseNoError) { + return result; + } + glUniform2f(location, x, y); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleUniform2fv( + unsigned int arg_count, const gles2::Uniform2fv& c) { + GLint location = static_cast<GLint>(c.location); + GLsizei count = static_cast<GLsizei>(c.count); + const GLfloat* v = GetSharedMemoryAs<const GLfloat*>( + c.v_shm_id, c.v_shm_offset, 0 /* TODO(gman): size */); + parse_error::ParseError result = + ValidateUniform2fv(this, arg_count, location, count, v); + if (result != parse_error::kParseNoError) { + return result; + } + glUniform2fv(location, count, v); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleUniform2fvImmediate( + unsigned int arg_count, const gles2::Uniform2fvImmediate& c) { + GLint location = static_cast<GLint>(c.location); + GLsizei count = static_cast<GLsizei>(c.count); + const GLfloat* v = GetImmediateDataAs<const GLfloat*>(c); + // Immediate version. + parse_error::ParseError result = + ValidateUniform2fvImmediate(this, arg_count, location, count, v); + if (result != parse_error::kParseNoError) { + return result; + } + glUniform2fv(location, count, v); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleUniform2i( + unsigned int arg_count, const gles2::Uniform2i& c) { + GLint location = static_cast<GLint>(c.location); + GLint x = static_cast<GLint>(c.x); + GLint y = static_cast<GLint>(c.y); + parse_error::ParseError result = + ValidateUniform2i(this, arg_count, location, x, y); + if (result != parse_error::kParseNoError) { + return result; + } + glUniform2i(location, x, y); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleUniform2iv( + unsigned int arg_count, const gles2::Uniform2iv& c) { + GLint location = static_cast<GLint>(c.location); + GLsizei count = static_cast<GLsizei>(c.count); + const GLint* v = GetSharedMemoryAs<const GLint*>( + c.v_shm_id, c.v_shm_offset, 0 /* TODO(gman): size */); + parse_error::ParseError result = + ValidateUniform2iv(this, arg_count, location, count, v); + if (result != parse_error::kParseNoError) { + return result; + } + glUniform2iv(location, count, v); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleUniform2ivImmediate( + unsigned int arg_count, const gles2::Uniform2ivImmediate& c) { + GLint location = static_cast<GLint>(c.location); + GLsizei count = static_cast<GLsizei>(c.count); + const GLint* v = GetImmediateDataAs<const GLint*>(c); + // Immediate version. + parse_error::ParseError result = + ValidateUniform2ivImmediate(this, arg_count, location, count, v); + if (result != parse_error::kParseNoError) { + return result; + } + glUniform2iv(location, count, v); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleUniform3f( + unsigned int arg_count, const gles2::Uniform3f& c) { + GLint location = static_cast<GLint>(c.location); + GLfloat x = static_cast<GLfloat>(c.x); + GLfloat y = static_cast<GLfloat>(c.y); + GLfloat z = static_cast<GLfloat>(c.z); + parse_error::ParseError result = + ValidateUniform3f(this, arg_count, location, x, y, z); + if (result != parse_error::kParseNoError) { + return result; + } + glUniform3f(location, x, y, z); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleUniform3fv( + unsigned int arg_count, const gles2::Uniform3fv& c) { + GLint location = static_cast<GLint>(c.location); + GLsizei count = static_cast<GLsizei>(c.count); + const GLfloat* v = GetSharedMemoryAs<const GLfloat*>( + c.v_shm_id, c.v_shm_offset, 0 /* TODO(gman): size */); + parse_error::ParseError result = + ValidateUniform3fv(this, arg_count, location, count, v); + if (result != parse_error::kParseNoError) { + return result; + } + glUniform3fv(location, count, v); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleUniform3fvImmediate( + unsigned int arg_count, const gles2::Uniform3fvImmediate& c) { + GLint location = static_cast<GLint>(c.location); + GLsizei count = static_cast<GLsizei>(c.count); + const GLfloat* v = GetImmediateDataAs<const GLfloat*>(c); + // Immediate version. + parse_error::ParseError result = + ValidateUniform3fvImmediate(this, arg_count, location, count, v); + if (result != parse_error::kParseNoError) { + return result; + } + glUniform3fv(location, count, v); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleUniform3i( + unsigned int arg_count, const gles2::Uniform3i& c) { + GLint location = static_cast<GLint>(c.location); + GLint x = static_cast<GLint>(c.x); + GLint y = static_cast<GLint>(c.y); + GLint z = static_cast<GLint>(c.z); + parse_error::ParseError result = + ValidateUniform3i(this, arg_count, location, x, y, z); + if (result != parse_error::kParseNoError) { + return result; + } + glUniform3i(location, x, y, z); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleUniform3iv( + unsigned int arg_count, const gles2::Uniform3iv& c) { + GLint location = static_cast<GLint>(c.location); + GLsizei count = static_cast<GLsizei>(c.count); + const GLint* v = GetSharedMemoryAs<const GLint*>( + c.v_shm_id, c.v_shm_offset, 0 /* TODO(gman): size */); + parse_error::ParseError result = + ValidateUniform3iv(this, arg_count, location, count, v); + if (result != parse_error::kParseNoError) { + return result; + } + glUniform3iv(location, count, v); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleUniform3ivImmediate( + unsigned int arg_count, const gles2::Uniform3ivImmediate& c) { + GLint location = static_cast<GLint>(c.location); + GLsizei count = static_cast<GLsizei>(c.count); + const GLint* v = GetImmediateDataAs<const GLint*>(c); + // Immediate version. + parse_error::ParseError result = + ValidateUniform3ivImmediate(this, arg_count, location, count, v); + if (result != parse_error::kParseNoError) { + return result; + } + glUniform3iv(location, count, v); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleUniform4f( + unsigned int arg_count, const gles2::Uniform4f& c) { + GLint location = static_cast<GLint>(c.location); + GLfloat x = static_cast<GLfloat>(c.x); + GLfloat y = static_cast<GLfloat>(c.y); + GLfloat z = static_cast<GLfloat>(c.z); + GLfloat w = static_cast<GLfloat>(c.w); + parse_error::ParseError result = + ValidateUniform4f(this, arg_count, location, x, y, z, w); + if (result != parse_error::kParseNoError) { + return result; + } + glUniform4f(location, x, y, z, w); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleUniform4fv( + unsigned int arg_count, const gles2::Uniform4fv& c) { + GLint location = static_cast<GLint>(c.location); + GLsizei count = static_cast<GLsizei>(c.count); + const GLfloat* v = GetSharedMemoryAs<const GLfloat*>( + c.v_shm_id, c.v_shm_offset, 0 /* TODO(gman): size */); + parse_error::ParseError result = + ValidateUniform4fv(this, arg_count, location, count, v); + if (result != parse_error::kParseNoError) { + return result; + } + glUniform4fv(location, count, v); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleUniform4fvImmediate( + unsigned int arg_count, const gles2::Uniform4fvImmediate& c) { + GLint location = static_cast<GLint>(c.location); + GLsizei count = static_cast<GLsizei>(c.count); + const GLfloat* v = GetImmediateDataAs<const GLfloat*>(c); + // Immediate version. + parse_error::ParseError result = + ValidateUniform4fvImmediate(this, arg_count, location, count, v); + if (result != parse_error::kParseNoError) { + return result; + } + glUniform4fv(location, count, v); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleUniform4i( + unsigned int arg_count, const gles2::Uniform4i& c) { + GLint location = static_cast<GLint>(c.location); + GLint x = static_cast<GLint>(c.x); + GLint y = static_cast<GLint>(c.y); + GLint z = static_cast<GLint>(c.z); + GLint w = static_cast<GLint>(c.w); + parse_error::ParseError result = + ValidateUniform4i(this, arg_count, location, x, y, z, w); + if (result != parse_error::kParseNoError) { + return result; + } + glUniform4i(location, x, y, z, w); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleUniform4iv( + unsigned int arg_count, const gles2::Uniform4iv& c) { + GLint location = static_cast<GLint>(c.location); + GLsizei count = static_cast<GLsizei>(c.count); + const GLint* v = GetSharedMemoryAs<const GLint*>( + c.v_shm_id, c.v_shm_offset, 0 /* TODO(gman): size */); + parse_error::ParseError result = + ValidateUniform4iv(this, arg_count, location, count, v); + if (result != parse_error::kParseNoError) { + return result; + } + glUniform4iv(location, count, v); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleUniform4ivImmediate( + unsigned int arg_count, const gles2::Uniform4ivImmediate& c) { + GLint location = static_cast<GLint>(c.location); + GLsizei count = static_cast<GLsizei>(c.count); + const GLint* v = GetImmediateDataAs<const GLint*>(c); + // Immediate version. + parse_error::ParseError result = + ValidateUniform4ivImmediate(this, arg_count, location, count, v); + if (result != parse_error::kParseNoError) { + return result; + } + glUniform4iv(location, count, v); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleUniformMatrix2fv( + unsigned int arg_count, const gles2::UniformMatrix2fv& c) { + GLint location = static_cast<GLint>(c.location); + GLsizei count = static_cast<GLsizei>(c.count); + GLboolean transpose = static_cast<GLboolean>(c.transpose); + const GLfloat* value = GetSharedMemoryAs<const GLfloat*>( + c.value_shm_id, c.value_shm_offset, 0 /* TODO(gman): size */); + parse_error::ParseError result = + ValidateUniformMatrix2fv( + this, arg_count, location, count, transpose, value); + if (result != parse_error::kParseNoError) { + return result; + } + glUniformMatrix2fv(location, count, transpose, value); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleUniformMatrix2fvImmediate( + unsigned int arg_count, const gles2::UniformMatrix2fvImmediate& c) { + GLint location = static_cast<GLint>(c.location); + GLsizei count = static_cast<GLsizei>(c.count); + GLboolean transpose = static_cast<GLboolean>(c.transpose); + const GLfloat* value = GetImmediateDataAs<const GLfloat*>(c); + // Immediate version. + parse_error::ParseError result = + ValidateUniformMatrix2fvImmediate( + this, arg_count, location, count, transpose, value); + if (result != parse_error::kParseNoError) { + return result; + } + glUniformMatrix2fv(location, count, transpose, value); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleUniformMatrix3fv( + unsigned int arg_count, const gles2::UniformMatrix3fv& c) { + GLint location = static_cast<GLint>(c.location); + GLsizei count = static_cast<GLsizei>(c.count); + GLboolean transpose = static_cast<GLboolean>(c.transpose); + const GLfloat* value = GetSharedMemoryAs<const GLfloat*>( + c.value_shm_id, c.value_shm_offset, 0 /* TODO(gman): size */); + parse_error::ParseError result = + ValidateUniformMatrix3fv( + this, arg_count, location, count, transpose, value); + if (result != parse_error::kParseNoError) { + return result; + } + glUniformMatrix3fv(location, count, transpose, value); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleUniformMatrix3fvImmediate( + unsigned int arg_count, const gles2::UniformMatrix3fvImmediate& c) { + GLint location = static_cast<GLint>(c.location); + GLsizei count = static_cast<GLsizei>(c.count); + GLboolean transpose = static_cast<GLboolean>(c.transpose); + const GLfloat* value = GetImmediateDataAs<const GLfloat*>(c); + // Immediate version. + parse_error::ParseError result = + ValidateUniformMatrix3fvImmediate( + this, arg_count, location, count, transpose, value); + if (result != parse_error::kParseNoError) { + return result; + } + glUniformMatrix3fv(location, count, transpose, value); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleUniformMatrix4fv( + unsigned int arg_count, const gles2::UniformMatrix4fv& c) { + GLint location = static_cast<GLint>(c.location); + GLsizei count = static_cast<GLsizei>(c.count); + GLboolean transpose = static_cast<GLboolean>(c.transpose); + const GLfloat* value = GetSharedMemoryAs<const GLfloat*>( + c.value_shm_id, c.value_shm_offset, 0 /* TODO(gman): size */); + parse_error::ParseError result = + ValidateUniformMatrix4fv( + this, arg_count, location, count, transpose, value); + if (result != parse_error::kParseNoError) { + return result; + } + glUniformMatrix4fv(location, count, transpose, value); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleUniformMatrix4fvImmediate( + unsigned int arg_count, const gles2::UniformMatrix4fvImmediate& c) { + GLint location = static_cast<GLint>(c.location); + GLsizei count = static_cast<GLsizei>(c.count); + GLboolean transpose = static_cast<GLboolean>(c.transpose); + const GLfloat* value = GetImmediateDataAs<const GLfloat*>(c); + // Immediate version. + parse_error::ParseError result = + ValidateUniformMatrix4fvImmediate( + this, arg_count, location, count, transpose, value); + if (result != parse_error::kParseNoError) { + return result; + } + glUniformMatrix4fv(location, count, transpose, value); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleUseProgram( + unsigned int arg_count, const gles2::UseProgram& c) { + GLuint program = static_cast<GLuint>(c.program); + parse_error::ParseError result = + ValidateUseProgram(this, arg_count, program); + if (result != parse_error::kParseNoError) { + return result; + } + glUseProgram(program); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleValidateProgram( + unsigned int arg_count, const gles2::ValidateProgram& c) { + GLuint program = static_cast<GLuint>(c.program); + parse_error::ParseError result = + ValidateValidateProgram(this, arg_count, program); + if (result != parse_error::kParseNoError) { + return result; + } + glValidateProgram(program); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleVertexAttrib1f( + unsigned int arg_count, const gles2::VertexAttrib1f& c) { + GLuint indx = static_cast<GLuint>(c.indx); + GLfloat x = static_cast<GLfloat>(c.x); + parse_error::ParseError result = + ValidateVertexAttrib1f(this, arg_count, indx, x); + if (result != parse_error::kParseNoError) { + return result; + } + glVertexAttrib1f(indx, x); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleVertexAttrib1fv( + unsigned int arg_count, const gles2::VertexAttrib1fv& c) { + GLuint indx = static_cast<GLuint>(c.indx); + const GLfloat* values = GetSharedMemoryAs<const GLfloat*>( + c.values_shm_id, c.values_shm_offset, 0 /* TODO(gman): size */); + parse_error::ParseError result = + ValidateVertexAttrib1fv(this, arg_count, indx, values); + if (result != parse_error::kParseNoError) { + return result; + } + glVertexAttrib1fv(indx, values); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleVertexAttrib1fvImmediate( + unsigned int arg_count, const gles2::VertexAttrib1fvImmediate& c) { + GLuint indx = static_cast<GLuint>(c.indx); + const GLfloat* values = GetImmediateDataAs<const GLfloat*>(c); + // Immediate version. + parse_error::ParseError result = + ValidateVertexAttrib1fvImmediate(this, arg_count, indx, values); + if (result != parse_error::kParseNoError) { + return result; + } + glVertexAttrib1fv(indx, values); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleVertexAttrib2f( + unsigned int arg_count, const gles2::VertexAttrib2f& c) { + GLuint indx = static_cast<GLuint>(c.indx); + GLfloat x = static_cast<GLfloat>(c.x); + GLfloat y = static_cast<GLfloat>(c.y); + parse_error::ParseError result = + ValidateVertexAttrib2f(this, arg_count, indx, x, y); + if (result != parse_error::kParseNoError) { + return result; + } + glVertexAttrib2f(indx, x, y); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleVertexAttrib2fv( + unsigned int arg_count, const gles2::VertexAttrib2fv& c) { + GLuint indx = static_cast<GLuint>(c.indx); + const GLfloat* values = GetSharedMemoryAs<const GLfloat*>( + c.values_shm_id, c.values_shm_offset, 0 /* TODO(gman): size */); + parse_error::ParseError result = + ValidateVertexAttrib2fv(this, arg_count, indx, values); + if (result != parse_error::kParseNoError) { + return result; + } + glVertexAttrib2fv(indx, values); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleVertexAttrib2fvImmediate( + unsigned int arg_count, const gles2::VertexAttrib2fvImmediate& c) { + GLuint indx = static_cast<GLuint>(c.indx); + const GLfloat* values = GetImmediateDataAs<const GLfloat*>(c); + // Immediate version. + parse_error::ParseError result = + ValidateVertexAttrib2fvImmediate(this, arg_count, indx, values); + if (result != parse_error::kParseNoError) { + return result; + } + glVertexAttrib2fv(indx, values); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleVertexAttrib3f( + unsigned int arg_count, const gles2::VertexAttrib3f& c) { + GLuint indx = static_cast<GLuint>(c.indx); + GLfloat x = static_cast<GLfloat>(c.x); + GLfloat y = static_cast<GLfloat>(c.y); + GLfloat z = static_cast<GLfloat>(c.z); + parse_error::ParseError result = + ValidateVertexAttrib3f(this, arg_count, indx, x, y, z); + if (result != parse_error::kParseNoError) { + return result; + } + glVertexAttrib3f(indx, x, y, z); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleVertexAttrib3fv( + unsigned int arg_count, const gles2::VertexAttrib3fv& c) { + GLuint indx = static_cast<GLuint>(c.indx); + const GLfloat* values = GetSharedMemoryAs<const GLfloat*>( + c.values_shm_id, c.values_shm_offset, 0 /* TODO(gman): size */); + parse_error::ParseError result = + ValidateVertexAttrib3fv(this, arg_count, indx, values); + if (result != parse_error::kParseNoError) { + return result; + } + glVertexAttrib3fv(indx, values); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleVertexAttrib3fvImmediate( + unsigned int arg_count, const gles2::VertexAttrib3fvImmediate& c) { + GLuint indx = static_cast<GLuint>(c.indx); + const GLfloat* values = GetImmediateDataAs<const GLfloat*>(c); + // Immediate version. + parse_error::ParseError result = + ValidateVertexAttrib3fvImmediate(this, arg_count, indx, values); + if (result != parse_error::kParseNoError) { + return result; + } + glVertexAttrib3fv(indx, values); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleVertexAttrib4f( + unsigned int arg_count, const gles2::VertexAttrib4f& c) { + GLuint indx = static_cast<GLuint>(c.indx); + GLfloat x = static_cast<GLfloat>(c.x); + GLfloat y = static_cast<GLfloat>(c.y); + GLfloat z = static_cast<GLfloat>(c.z); + GLfloat w = static_cast<GLfloat>(c.w); + parse_error::ParseError result = + ValidateVertexAttrib4f(this, arg_count, indx, x, y, z, w); + if (result != parse_error::kParseNoError) { + return result; + } + glVertexAttrib4f(indx, x, y, z, w); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleVertexAttrib4fv( + unsigned int arg_count, const gles2::VertexAttrib4fv& c) { + GLuint indx = static_cast<GLuint>(c.indx); + const GLfloat* values = GetSharedMemoryAs<const GLfloat*>( + c.values_shm_id, c.values_shm_offset, 0 /* TODO(gman): size */); + parse_error::ParseError result = + ValidateVertexAttrib4fv(this, arg_count, indx, values); + if (result != parse_error::kParseNoError) { + return result; + } + glVertexAttrib4fv(indx, values); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleVertexAttrib4fvImmediate( + unsigned int arg_count, const gles2::VertexAttrib4fvImmediate& c) { + GLuint indx = static_cast<GLuint>(c.indx); + const GLfloat* values = GetImmediateDataAs<const GLfloat*>(c); + // Immediate version. + parse_error::ParseError result = + ValidateVertexAttrib4fvImmediate(this, arg_count, indx, values); + if (result != parse_error::kParseNoError) { + return result; + } + glVertexAttrib4fv(indx, values); + return parse_error::kParseNoError; +} + +parse_error::ParseError GLES2Decoder::HandleViewport( + unsigned int arg_count, const gles2::Viewport& c) { + GLint x = static_cast<GLint>(c.x); + GLint y = static_cast<GLint>(c.y); + GLsizei width = static_cast<GLsizei>(c.width); + GLsizei height = static_cast<GLsizei>(c.height); + parse_error::ParseError result = + ValidateViewport(this, arg_count, x, y, width, height); + if (result != parse_error::kParseNoError) { + return result; + } + glViewport(x, y, width, height); + return parse_error::kParseNoError; +} + diff --git a/o3d/gpu/command_buffer/service/gles2_cmd_decoder_validate.h b/o3d/gpu/command_buffer/service/gles2_cmd_decoder_validate.h new file mode 100644 index 0000000..6d7696b --- /dev/null +++ b/o3d/gpu/command_buffer/service/gles2_cmd_decoder_validate.h @@ -0,0 +1,1249 @@ +// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +namespace command_buffer { +namespace gles2 { + +namespace { + +parse_error::ParseError ValidateActiveTexture( + GLES2Decoder* decoder, unsigned int arg_count, GLenum texture) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateAttachShader( + GLES2Decoder* decoder, unsigned int arg_count, GLuint program, + GLuint shader) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateBindAttribLocation( + GLES2Decoder* decoder, unsigned int arg_count, GLuint program, GLuint index, + const char* name) { + if (name == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateBindAttribLocationImmediate( + GLES2Decoder* decoder, unsigned int arg_count, GLuint program, GLuint index, + const char* name) { + if (name == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateBindBuffer( + GLES2Decoder* decoder, unsigned int arg_count, GLenum target, + GLuint buffer) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateBindFramebuffer( + GLES2Decoder* decoder, unsigned int arg_count, GLenum target, + GLuint framebuffer) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateBindRenderbuffer( + GLES2Decoder* decoder, unsigned int arg_count, GLenum target, + GLuint renderbuffer) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateBindTexture( + GLES2Decoder* decoder, unsigned int arg_count, GLenum target, + GLuint texture) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateBlendColor( + GLES2Decoder* decoder, unsigned int arg_count, GLclampf red, GLclampf green, + GLclampf blue, GLclampf alpha) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateBlendEquation( + GLES2Decoder* decoder, unsigned int arg_count, GLenum mode) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateBlendEquationSeparate( + GLES2Decoder* decoder, unsigned int arg_count, GLenum modeRGB, + GLenum modeAlpha) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateBlendFunc( + GLES2Decoder* decoder, unsigned int arg_count, GLenum sfactor, + GLenum dfactor) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateBlendFuncSeparate( + GLES2Decoder* decoder, unsigned int arg_count, GLenum srcRGB, GLenum dstRGB, + GLenum srcAlpha, GLenum dstAlpha) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateBufferData( + GLES2Decoder* decoder, unsigned int arg_count, GLenum target, + GLsizeiptr size, const void* data, GLenum usage) { + if (data == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateBufferDataImmediate( + GLES2Decoder* decoder, unsigned int arg_count, GLenum target, + GLsizeiptr size, const void* data, GLenum usage) { + if (data == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateBufferSubData( + GLES2Decoder* decoder, unsigned int arg_count, GLenum target, + GLintptr offset, GLsizeiptr size, const void* data) { + if (data == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateBufferSubDataImmediate( + GLES2Decoder* decoder, unsigned int arg_count, GLenum target, + GLintptr offset, GLsizeiptr size, const void* data) { + if (data == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateCheckFramebufferStatus( + GLES2Decoder* decoder, unsigned int arg_count, GLenum target) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateClear( + GLES2Decoder* decoder, unsigned int arg_count, GLbitfield mask) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateClearColor( + GLES2Decoder* decoder, unsigned int arg_count, GLclampf red, GLclampf green, + GLclampf blue, GLclampf alpha) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateClearDepthf( + GLES2Decoder* decoder, unsigned int arg_count, GLclampf depth) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateClearStencil( + GLES2Decoder* decoder, unsigned int arg_count, GLint s) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateColorMask( + GLES2Decoder* decoder, unsigned int arg_count, GLboolean red, + GLboolean green, GLboolean blue, GLboolean alpha) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateCompileShader( + GLES2Decoder* decoder, unsigned int arg_count, GLuint shader) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateCompressedTexImage2D( + GLES2Decoder* decoder, unsigned int arg_count, GLenum target, GLint level, + GLenum internalformat, GLsizei width, GLsizei height, GLint border, + GLsizei imageSize, const void* data) { + if (data == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateCompressedTexImage2DImmediate( + GLES2Decoder* decoder, unsigned int arg_count, GLenum target, GLint level, + GLenum internalformat, GLsizei width, GLsizei height, GLint border, + GLsizei imageSize, const void* data) { + if (data == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateCompressedTexSubImage2D( + GLES2Decoder* decoder, unsigned int arg_count, GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, + GLsizei imageSize, const void* data) { + if (data == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateCompressedTexSubImage2DImmediate( + GLES2Decoder* decoder, unsigned int arg_count, GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, + GLsizei imageSize, const void* data) { + if (data == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateCopyTexImage2D( + GLES2Decoder* decoder, unsigned int arg_count, GLenum target, GLint level, + GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, + GLint border) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateCopyTexSubImage2D( + GLES2Decoder* decoder, unsigned int arg_count, GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, + GLsizei height) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateCreateProgram( + GLES2Decoder* decoder, unsigned int arg_count) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateCreateShader( + GLES2Decoder* decoder, unsigned int arg_count, GLenum type) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateCullFace( + GLES2Decoder* decoder, unsigned int arg_count, GLenum mode) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateDeleteBuffers( + GLES2Decoder* decoder, unsigned int arg_count, GLsizei n, + const GLuint* buffers) { + if (buffers == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateDeleteBuffersImmediate( + GLES2Decoder* decoder, unsigned int arg_count, GLsizei n, + const GLuint* buffers) { + if (buffers == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateDeleteFramebuffers( + GLES2Decoder* decoder, unsigned int arg_count, GLsizei n, + const GLuint* framebuffers) { + if (framebuffers == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateDeleteFramebuffersImmediate( + GLES2Decoder* decoder, unsigned int arg_count, GLsizei n, + const GLuint* framebuffers) { + if (framebuffers == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateDeleteProgram( + GLES2Decoder* decoder, unsigned int arg_count, GLuint program) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateDeleteRenderbuffers( + GLES2Decoder* decoder, unsigned int arg_count, GLsizei n, + const GLuint* renderbuffers) { + if (renderbuffers == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateDeleteRenderbuffersImmediate( + GLES2Decoder* decoder, unsigned int arg_count, GLsizei n, + const GLuint* renderbuffers) { + if (renderbuffers == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateDeleteShader( + GLES2Decoder* decoder, unsigned int arg_count, GLuint shader) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateDeleteTextures( + GLES2Decoder* decoder, unsigned int arg_count, GLsizei n, + const GLuint* textures) { + if (textures == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateDeleteTexturesImmediate( + GLES2Decoder* decoder, unsigned int arg_count, GLsizei n, + const GLuint* textures) { + if (textures == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateDepthFunc( + GLES2Decoder* decoder, unsigned int arg_count, GLenum func) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateDepthMask( + GLES2Decoder* decoder, unsigned int arg_count, GLboolean flag) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateDepthRangef( + GLES2Decoder* decoder, unsigned int arg_count, GLclampf zNear, + GLclampf zFar) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateDetachShader( + GLES2Decoder* decoder, unsigned int arg_count, GLuint program, + GLuint shader) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateDisable( + GLES2Decoder* decoder, unsigned int arg_count, GLenum cap) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateDisableVertexAttribArray( + GLES2Decoder* decoder, unsigned int arg_count, GLuint index) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateDrawArrays( + GLES2Decoder* decoder, unsigned int arg_count, GLenum mode, GLint first, + GLsizei count) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateDrawElements( + GLES2Decoder* decoder, unsigned int arg_count, GLenum mode, GLsizei count, + GLenum type, const void* indices) { + if (indices == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateEnable( + GLES2Decoder* decoder, unsigned int arg_count, GLenum cap) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateEnableVertexAttribArray( + GLES2Decoder* decoder, unsigned int arg_count, GLuint index) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateFinish( + GLES2Decoder* decoder, unsigned int arg_count) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateFlush( + GLES2Decoder* decoder, unsigned int arg_count) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateFramebufferRenderbuffer( + GLES2Decoder* decoder, unsigned int arg_count, GLenum target, + GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateFramebufferTexture2D( + GLES2Decoder* decoder, unsigned int arg_count, GLenum target, + GLenum attachment, GLenum textarget, GLuint texture, GLint level) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateFrontFace( + GLES2Decoder* decoder, unsigned int arg_count, GLenum mode) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateGenBuffers( + GLES2Decoder* decoder, unsigned int arg_count, GLsizei n, + GLuint* buffers) { + if (buffers == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateGenBuffersImmediate( + GLES2Decoder* decoder, unsigned int arg_count, GLsizei n, + GLuint* buffers) { + if (buffers == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateGenerateMipmap( + GLES2Decoder* decoder, unsigned int arg_count, GLenum target) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateGenFramebuffers( + GLES2Decoder* decoder, unsigned int arg_count, GLsizei n, + GLuint* framebuffers) { + if (framebuffers == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateGenFramebuffersImmediate( + GLES2Decoder* decoder, unsigned int arg_count, GLsizei n, + GLuint* framebuffers) { + if (framebuffers == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateGenRenderbuffers( + GLES2Decoder* decoder, unsigned int arg_count, GLsizei n, + GLuint* renderbuffers) { + if (renderbuffers == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateGenRenderbuffersImmediate( + GLES2Decoder* decoder, unsigned int arg_count, GLsizei n, + GLuint* renderbuffers) { + if (renderbuffers == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateGenTextures( + GLES2Decoder* decoder, unsigned int arg_count, GLsizei n, + GLuint* textures) { + if (textures == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateGenTexturesImmediate( + GLES2Decoder* decoder, unsigned int arg_count, GLsizei n, + GLuint* textures) { + if (textures == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateGetActiveAttrib( + GLES2Decoder* decoder, unsigned int arg_count, GLuint program, GLuint index, + GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) { + if (length == NULL) { + return parse_error::kParseOutOfBounds; + } + if (size == NULL) { + return parse_error::kParseOutOfBounds; + } + if (type == NULL) { + return parse_error::kParseOutOfBounds; + } + if (name == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateGetActiveUniform( + GLES2Decoder* decoder, unsigned int arg_count, GLuint program, GLuint index, + GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) { + if (length == NULL) { + return parse_error::kParseOutOfBounds; + } + if (size == NULL) { + return parse_error::kParseOutOfBounds; + } + if (type == NULL) { + return parse_error::kParseOutOfBounds; + } + if (name == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateGetAttachedShaders( + GLES2Decoder* decoder, unsigned int arg_count, GLuint program, + GLsizei maxcount, GLsizei* count, GLuint* shaders) { + if (count == NULL) { + return parse_error::kParseOutOfBounds; + } + if (shaders == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateGetAttribLocation( + GLES2Decoder* decoder, unsigned int arg_count, GLuint program, + const char* name) { + if (name == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateGetAttribLocationImmediate( + GLES2Decoder* decoder, unsigned int arg_count, GLuint program, + const char* name) { + if (name == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateGetBooleanv( + GLES2Decoder* decoder, unsigned int arg_count, GLenum pname, + GLboolean* params) { + if (params == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateGetBufferParameteriv( + GLES2Decoder* decoder, unsigned int arg_count, GLenum target, GLenum pname, + GLint* params) { + if (params == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateGetError( + GLES2Decoder* decoder, unsigned int arg_count) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateGetFloatv( + GLES2Decoder* decoder, unsigned int arg_count, GLenum pname, + GLfloat* params) { + if (params == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateGetFramebufferAttachmentParameteriv( + GLES2Decoder* decoder, unsigned int arg_count, GLenum target, + GLenum attachment, GLenum pname, GLint* params) { + if (params == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateGetIntegerv( + GLES2Decoder* decoder, unsigned int arg_count, GLenum pname, + GLint* params) { + if (params == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateGetProgramiv( + GLES2Decoder* decoder, unsigned int arg_count, GLuint program, GLenum pname, + GLint* params) { + if (params == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateGetProgramInfoLog( + GLES2Decoder* decoder, unsigned int arg_count, GLuint program, + GLsizei bufsize, GLsizei* length, char* infolog) { + if (length == NULL) { + return parse_error::kParseOutOfBounds; + } + if (infolog == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateGetRenderbufferParameteriv( + GLES2Decoder* decoder, unsigned int arg_count, GLenum target, GLenum pname, + GLint* params) { + if (params == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateGetShaderiv( + GLES2Decoder* decoder, unsigned int arg_count, GLuint shader, GLenum pname, + GLint* params) { + if (params == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateGetShaderInfoLog( + GLES2Decoder* decoder, unsigned int arg_count, GLuint shader, + GLsizei bufsize, GLsizei* length, char* infolog) { + if (length == NULL) { + return parse_error::kParseOutOfBounds; + } + if (infolog == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateGetShaderPrecisionFormat( + GLES2Decoder* decoder, unsigned int arg_count, GLenum shadertype, + GLenum precisiontype, GLint* range, GLint* precision) { + if (range == NULL) { + return parse_error::kParseOutOfBounds; + } + if (precision == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateGetShaderSource( + GLES2Decoder* decoder, unsigned int arg_count, GLuint shader, + GLsizei bufsize, GLsizei* length, char* source) { + if (length == NULL) { + return parse_error::kParseOutOfBounds; + } + if (source == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateGetString( + GLES2Decoder* decoder, unsigned int arg_count, GLenum name) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateGetTexParameterfv( + GLES2Decoder* decoder, unsigned int arg_count, GLenum target, GLenum pname, + GLfloat* params) { + if (params == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateGetTexParameteriv( + GLES2Decoder* decoder, unsigned int arg_count, GLenum target, GLenum pname, + GLint* params) { + if (params == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateGetUniformfv( + GLES2Decoder* decoder, unsigned int arg_count, GLuint program, + GLint location, GLfloat* params) { + if (params == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateGetUniformiv( + GLES2Decoder* decoder, unsigned int arg_count, GLuint program, + GLint location, GLint* params) { + if (params == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateGetUniformLocation( + GLES2Decoder* decoder, unsigned int arg_count, GLuint program, + const char* name) { + if (name == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateGetUniformLocationImmediate( + GLES2Decoder* decoder, unsigned int arg_count, GLuint program, + const char* name) { + if (name == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateGetVertexAttribfv( + GLES2Decoder* decoder, unsigned int arg_count, GLuint index, GLenum pname, + GLfloat* params) { + if (params == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateGetVertexAttribiv( + GLES2Decoder* decoder, unsigned int arg_count, GLuint index, GLenum pname, + GLint* params) { + if (params == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateGetVertexAttribPointerv( + GLES2Decoder* decoder, unsigned int arg_count, GLuint index, GLenum pname, + void** pointer) { + if (pointer == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateHint( + GLES2Decoder* decoder, unsigned int arg_count, GLenum target, + GLenum mode) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateIsBuffer( + GLES2Decoder* decoder, unsigned int arg_count, GLuint buffer) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateIsEnabled( + GLES2Decoder* decoder, unsigned int arg_count, GLenum cap) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateIsFramebuffer( + GLES2Decoder* decoder, unsigned int arg_count, GLuint framebuffer) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateIsProgram( + GLES2Decoder* decoder, unsigned int arg_count, GLuint program) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateIsRenderbuffer( + GLES2Decoder* decoder, unsigned int arg_count, GLuint renderbuffer) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateIsShader( + GLES2Decoder* decoder, unsigned int arg_count, GLuint shader) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateIsTexture( + GLES2Decoder* decoder, unsigned int arg_count, GLuint texture) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateLineWidth( + GLES2Decoder* decoder, unsigned int arg_count, GLfloat width) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateLinkProgram( + GLES2Decoder* decoder, unsigned int arg_count, GLuint program) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidatePixelStorei( + GLES2Decoder* decoder, unsigned int arg_count, GLenum pname, GLint param) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidatePolygonOffset( + GLES2Decoder* decoder, unsigned int arg_count, GLfloat factor, + GLfloat units) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateReadPixels( + GLES2Decoder* decoder, unsigned int arg_count, GLint x, GLint y, + GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels) { + if (pixels == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateRenderbufferStorage( + GLES2Decoder* decoder, unsigned int arg_count, GLenum target, + GLenum internalformat, GLsizei width, GLsizei height) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateSampleCoverage( + GLES2Decoder* decoder, unsigned int arg_count, GLclampf value, + GLboolean invert) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateScissor( + GLES2Decoder* decoder, unsigned int arg_count, GLint x, GLint y, + GLsizei width, GLsizei height) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateShaderSource( + GLES2Decoder* decoder, unsigned int arg_count, GLuint shader, GLsizei count, + const char** string, const GLint* length) { + if (string == NULL) { + return parse_error::kParseOutOfBounds; + } + if (length == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateShaderSourceImmediate( + GLES2Decoder* decoder, unsigned int arg_count, GLuint shader, GLsizei count, + const char** string, const GLint* length) { + if (string == NULL) { + return parse_error::kParseOutOfBounds; + } + if (length == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateStencilFunc( + GLES2Decoder* decoder, unsigned int arg_count, GLenum func, GLint ref, + GLuint mask) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateStencilFuncSeparate( + GLES2Decoder* decoder, unsigned int arg_count, GLenum face, GLenum func, + GLint ref, GLuint mask) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateStencilMask( + GLES2Decoder* decoder, unsigned int arg_count, GLuint mask) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateStencilMaskSeparate( + GLES2Decoder* decoder, unsigned int arg_count, GLenum face, GLuint mask) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateStencilOp( + GLES2Decoder* decoder, unsigned int arg_count, GLenum fail, GLenum zfail, + GLenum zpass) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateStencilOpSeparate( + GLES2Decoder* decoder, unsigned int arg_count, GLenum face, GLenum fail, + GLenum zfail, GLenum zpass) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateTexImage2D( + GLES2Decoder* decoder, unsigned int arg_count, GLenum target, GLint level, + GLint internalformat, GLsizei width, GLsizei height, GLint border, + GLenum format, GLenum type, const void* pixels) { + if (pixels == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateTexImage2DImmediate( + GLES2Decoder* decoder, unsigned int arg_count, GLenum target, GLint level, + GLint internalformat, GLsizei width, GLsizei height, GLint border, + GLenum format, GLenum type, const void* pixels) { + if (pixels == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateTexParameterf( + GLES2Decoder* decoder, unsigned int arg_count, GLenum target, GLenum pname, + GLfloat param) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateTexParameterfv( + GLES2Decoder* decoder, unsigned int arg_count, GLenum target, GLenum pname, + const GLfloat* params) { + if (params == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateTexParameterfvImmediate( + GLES2Decoder* decoder, unsigned int arg_count, GLenum target, GLenum pname, + const GLfloat* params) { + if (params == NULL) { + return parse_error::kParseOutOfBounds; + } + if (!CheckImmediateDataSize<TexParameterfvImmediate>( + arg_count, 1, sizeof(GLfloat), 1)) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateTexParameteri( + GLES2Decoder* decoder, unsigned int arg_count, GLenum target, GLenum pname, + GLint param) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateTexParameteriv( + GLES2Decoder* decoder, unsigned int arg_count, GLenum target, GLenum pname, + const GLint* params) { + if (params == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateTexParameterivImmediate( + GLES2Decoder* decoder, unsigned int arg_count, GLenum target, GLenum pname, + const GLint* params) { + if (params == NULL) { + return parse_error::kParseOutOfBounds; + } + if (!CheckImmediateDataSize<TexParameterivImmediate>( + arg_count, 1, sizeof(GLint), 1)) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateTexSubImage2D( + GLES2Decoder* decoder, unsigned int arg_count, GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, + GLenum type, const void* pixels) { + if (pixels == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateTexSubImage2DImmediate( + GLES2Decoder* decoder, unsigned int arg_count, GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, + GLenum type, const void* pixels) { + if (pixels == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateUniform1f( + GLES2Decoder* decoder, unsigned int arg_count, GLint location, GLfloat x) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateUniform1fv( + GLES2Decoder* decoder, unsigned int arg_count, GLint location, + GLsizei count, const GLfloat* v) { + if (v == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateUniform1fvImmediate( + GLES2Decoder* decoder, unsigned int arg_count, GLint location, + GLsizei count, const GLfloat* v) { + if (v == NULL) { + return parse_error::kParseOutOfBounds; + } + if (!CheckImmediateDataSize<Uniform1fvImmediate>( + arg_count, count, sizeof(GLfloat), 1)) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateUniform1i( + GLES2Decoder* decoder, unsigned int arg_count, GLint location, GLint x) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateUniform1iv( + GLES2Decoder* decoder, unsigned int arg_count, GLint location, + GLsizei count, const GLint* v) { + if (v == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateUniform1ivImmediate( + GLES2Decoder* decoder, unsigned int arg_count, GLint location, + GLsizei count, const GLint* v) { + if (v == NULL) { + return parse_error::kParseOutOfBounds; + } + if (!CheckImmediateDataSize<Uniform1ivImmediate>( + arg_count, count, sizeof(GLint), 1)) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateUniform2f( + GLES2Decoder* decoder, unsigned int arg_count, GLint location, GLfloat x, + GLfloat y) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateUniform2fv( + GLES2Decoder* decoder, unsigned int arg_count, GLint location, + GLsizei count, const GLfloat* v) { + if (v == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateUniform2fvImmediate( + GLES2Decoder* decoder, unsigned int arg_count, GLint location, + GLsizei count, const GLfloat* v) { + if (v == NULL) { + return parse_error::kParseOutOfBounds; + } + if (!CheckImmediateDataSize<Uniform2fvImmediate>( + arg_count, count, sizeof(GLfloat), 2)) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateUniform2i( + GLES2Decoder* decoder, unsigned int arg_count, GLint location, GLint x, + GLint y) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateUniform2iv( + GLES2Decoder* decoder, unsigned int arg_count, GLint location, + GLsizei count, const GLint* v) { + if (v == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateUniform2ivImmediate( + GLES2Decoder* decoder, unsigned int arg_count, GLint location, + GLsizei count, const GLint* v) { + if (v == NULL) { + return parse_error::kParseOutOfBounds; + } + if (!CheckImmediateDataSize<Uniform2ivImmediate>( + arg_count, count, sizeof(GLint), 2)) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateUniform3f( + GLES2Decoder* decoder, unsigned int arg_count, GLint location, GLfloat x, + GLfloat y, GLfloat z) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateUniform3fv( + GLES2Decoder* decoder, unsigned int arg_count, GLint location, + GLsizei count, const GLfloat* v) { + if (v == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateUniform3fvImmediate( + GLES2Decoder* decoder, unsigned int arg_count, GLint location, + GLsizei count, const GLfloat* v) { + if (v == NULL) { + return parse_error::kParseOutOfBounds; + } + if (!CheckImmediateDataSize<Uniform3fvImmediate>( + arg_count, count, sizeof(GLfloat), 3)) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateUniform3i( + GLES2Decoder* decoder, unsigned int arg_count, GLint location, GLint x, + GLint y, GLint z) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateUniform3iv( + GLES2Decoder* decoder, unsigned int arg_count, GLint location, + GLsizei count, const GLint* v) { + if (v == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateUniform3ivImmediate( + GLES2Decoder* decoder, unsigned int arg_count, GLint location, + GLsizei count, const GLint* v) { + if (v == NULL) { + return parse_error::kParseOutOfBounds; + } + if (!CheckImmediateDataSize<Uniform3ivImmediate>( + arg_count, count, sizeof(GLint), 3)) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateUniform4f( + GLES2Decoder* decoder, unsigned int arg_count, GLint location, GLfloat x, + GLfloat y, GLfloat z, GLfloat w) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateUniform4fv( + GLES2Decoder* decoder, unsigned int arg_count, GLint location, + GLsizei count, const GLfloat* v) { + if (v == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateUniform4fvImmediate( + GLES2Decoder* decoder, unsigned int arg_count, GLint location, + GLsizei count, const GLfloat* v) { + if (v == NULL) { + return parse_error::kParseOutOfBounds; + } + if (!CheckImmediateDataSize<Uniform4fvImmediate>( + arg_count, count, sizeof(GLfloat), 4)) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateUniform4i( + GLES2Decoder* decoder, unsigned int arg_count, GLint location, GLint x, + GLint y, GLint z, GLint w) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateUniform4iv( + GLES2Decoder* decoder, unsigned int arg_count, GLint location, + GLsizei count, const GLint* v) { + if (v == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateUniform4ivImmediate( + GLES2Decoder* decoder, unsigned int arg_count, GLint location, + GLsizei count, const GLint* v) { + if (v == NULL) { + return parse_error::kParseOutOfBounds; + } + if (!CheckImmediateDataSize<Uniform4ivImmediate>( + arg_count, count, sizeof(GLint), 4)) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateUniformMatrix2fv( + GLES2Decoder* decoder, unsigned int arg_count, GLint location, + GLsizei count, GLboolean transpose, const GLfloat* value) { + if (value == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateUniformMatrix2fvImmediate( + GLES2Decoder* decoder, unsigned int arg_count, GLint location, + GLsizei count, GLboolean transpose, const GLfloat* value) { + if (value == NULL) { + return parse_error::kParseOutOfBounds; + } + if (!CheckImmediateDataSize<UniformMatrix2fvImmediate>( + arg_count, count, sizeof(GLfloat), 4)) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateUniformMatrix3fv( + GLES2Decoder* decoder, unsigned int arg_count, GLint location, + GLsizei count, GLboolean transpose, const GLfloat* value) { + if (value == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateUniformMatrix3fvImmediate( + GLES2Decoder* decoder, unsigned int arg_count, GLint location, + GLsizei count, GLboolean transpose, const GLfloat* value) { + if (value == NULL) { + return parse_error::kParseOutOfBounds; + } + if (!CheckImmediateDataSize<UniformMatrix3fvImmediate>( + arg_count, count, sizeof(GLfloat), 9)) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateUniformMatrix4fv( + GLES2Decoder* decoder, unsigned int arg_count, GLint location, + GLsizei count, GLboolean transpose, const GLfloat* value) { + if (value == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateUniformMatrix4fvImmediate( + GLES2Decoder* decoder, unsigned int arg_count, GLint location, + GLsizei count, GLboolean transpose, const GLfloat* value) { + if (value == NULL) { + return parse_error::kParseOutOfBounds; + } + if (!CheckImmediateDataSize<UniformMatrix4fvImmediate>( + arg_count, count, sizeof(GLfloat), 16)) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateUseProgram( + GLES2Decoder* decoder, unsigned int arg_count, GLuint program) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateValidateProgram( + GLES2Decoder* decoder, unsigned int arg_count, GLuint program) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateVertexAttrib1f( + GLES2Decoder* decoder, unsigned int arg_count, GLuint indx, GLfloat x) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateVertexAttrib1fv( + GLES2Decoder* decoder, unsigned int arg_count, GLuint indx, + const GLfloat* values) { + if (values == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateVertexAttrib1fvImmediate( + GLES2Decoder* decoder, unsigned int arg_count, GLuint indx, + const GLfloat* values) { + if (values == NULL) { + return parse_error::kParseOutOfBounds; + } + if (!CheckImmediateDataSize<VertexAttrib1fvImmediate>( + arg_count, 1, sizeof(GLfloat), 1)) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateVertexAttrib2f( + GLES2Decoder* decoder, unsigned int arg_count, GLuint indx, GLfloat x, + GLfloat y) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateVertexAttrib2fv( + GLES2Decoder* decoder, unsigned int arg_count, GLuint indx, + const GLfloat* values) { + if (values == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateVertexAttrib2fvImmediate( + GLES2Decoder* decoder, unsigned int arg_count, GLuint indx, + const GLfloat* values) { + if (values == NULL) { + return parse_error::kParseOutOfBounds; + } + if (!CheckImmediateDataSize<VertexAttrib2fvImmediate>( + arg_count, 1, sizeof(GLfloat), 2)) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateVertexAttrib3f( + GLES2Decoder* decoder, unsigned int arg_count, GLuint indx, GLfloat x, + GLfloat y, GLfloat z) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateVertexAttrib3fv( + GLES2Decoder* decoder, unsigned int arg_count, GLuint indx, + const GLfloat* values) { + if (values == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateVertexAttrib3fvImmediate( + GLES2Decoder* decoder, unsigned int arg_count, GLuint indx, + const GLfloat* values) { + if (values == NULL) { + return parse_error::kParseOutOfBounds; + } + if (!CheckImmediateDataSize<VertexAttrib3fvImmediate>( + arg_count, 1, sizeof(GLfloat), 3)) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateVertexAttrib4f( + GLES2Decoder* decoder, unsigned int arg_count, GLuint indx, GLfloat x, + GLfloat y, GLfloat z, GLfloat w) { + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateVertexAttrib4fv( + GLES2Decoder* decoder, unsigned int arg_count, GLuint indx, + const GLfloat* values) { + if (values == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateVertexAttrib4fvImmediate( + GLES2Decoder* decoder, unsigned int arg_count, GLuint indx, + const GLfloat* values) { + if (values == NULL) { + return parse_error::kParseOutOfBounds; + } + if (!CheckImmediateDataSize<VertexAttrib4fvImmediate>( + arg_count, 1, sizeof(GLfloat), 4)) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateVertexAttribPointer( + GLES2Decoder* decoder, unsigned int arg_count, GLuint indx, GLint size, + GLenum type, GLboolean normalized, GLsizei stride, const void* ptr) { + if (ptr == NULL) { + return parse_error::kParseOutOfBounds; + } + return parse_error::kParseNoError; +} +parse_error::ParseError ValidateViewport( + GLES2Decoder* decoder, unsigned int arg_count, GLint x, GLint y, + GLsizei width, GLsizei height) { + return parse_error::kParseNoError; +} +} // anonymous namespace +} // namespace gles2 +} // namespace command_buffer + diff --git a/o3d/gpu/gpu.gyp b/o3d/gpu/gpu.gyp index 2079e1e..7e348da 100644 --- a/o3d/gpu/gpu.gyp +++ b/o3d/gpu/gpu.gyp @@ -14,11 +14,13 @@ 'target_name': 'command_buffer_common', 'type': 'static_library', 'include_dirs': [ + 'command_buffer/common', '..', '../..', ], 'all_dependent_settings': { 'include_dirs': [ + 'command_buffer/common', '..', '../..', ], @@ -27,6 +29,10 @@ 'command_buffer/common/bitfield_helpers.h', 'command_buffer/common/cmd_buffer_common.h', 'command_buffer/common/cmd_buffer_common.cc', + 'command_buffer/common/gles2_cmd_format.cc', + 'command_buffer/common/gles2_cmd_format.h', + 'command_buffer/common/gles2_cmd_utils.cc', + 'command_buffer/common/gles2_cmd_utils.h', 'command_buffer/common/o3d_cmd_format.h', 'command_buffer/common/o3d_cmd_format.cc', 'command_buffer/common/gapi_interface.h', @@ -38,11 +44,64 @@ ], }, { + # Library helps make GLES2 command buffers. + 'target_name': 'gles2_cmd_helper', + 'type': 'static_library', + 'dependencies': [ + 'command_buffer_common', + 'np_utils', + ], + 'sources': [ + 'command_buffer/client/gles2_cmd_helper.cc', + 'command_buffer/client/gles2_cmd_helper.h', + 'command_buffer/client/gles2_cmd_helper_autogen.h', + ], + }, + { + # Library emulates GLES2 using command_buffers. + 'target_name': 'gles2_implementation', + 'type': 'static_library', + 'dependencies': [ + 'gles2_cmd_helper', + ], + 'sources': [ + 'command_buffer/client/gles2_implementation_autogen.h', + 'command_buffer/client/gles2_implementation.cc', + 'command_buffer/client/gles2_implementation_gen.h', + 'command_buffer/client/gles2_implementation.h', + ], + }, + { + # Stub to expose gles2_implementation as a namespace rather than a class + # so GLES2 programs can work with no changes. + 'target_name': 'gles2_lib', + 'type': 'static_library', + 'dependencies': [ + 'gles2_implementation', + ], + 'sources': [ + 'command_buffer/client/gles2_lib.cc', + 'command_buffer/client/gles2_lib.h', + 'command_buffer/client/gles2_lib_autogen.h', + ], + }, + { 'target_name': 'command_buffer_common_unittests', 'type': 'none', + 'include_dirs': [ + 'command_buffer/common', + ], + 'dependencies': [ + 'gles2_lib', + 'gles2_implementation', + 'gles2_cmd_helper', + ], 'direct_dependent_settings': { 'sources': [ 'command_buffer/common/bitfield_helpers_test.cc', + 'command_buffer/common/gles2_cmd_format_test.cc', + 'command_buffer/common/gles2_cmd_format_test_autogen.h', + 'command_buffer/common/gles2_cmd_id_test.cc', ], }, }, @@ -80,6 +139,9 @@ { 'target_name': 'command_buffer_service', 'type': 'static_library', + 'defines': [ + 'GPU_SERVICE=1', + ], 'include_dirs': [ '..', '../..', @@ -168,6 +230,10 @@ 'command_buffer/service/gapi_gl.h', 'command_buffer/service/geometry_gl.cc', 'command_buffer/service/geometry_gl.h', + 'command_buffer/service/gles2_cmd_decoder.h', + 'command_buffer/service/gles2_cmd_decoder_validate.h', + 'command_buffer/service/gles2_cmd_decoder_autogen.h', + 'command_buffer/service/gles2_cmd_decoder.cc', 'command_buffer/service/gl_utils.h', 'command_buffer/service/render_surface_gl.cc', 'command_buffer/service/render_surface_gl.h', |