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

Side by Side Diff: gpu/command_buffer/build_gles2_cmd_buffer.py

Issue 5383001: Revert 67293 BrowserTestCanLaunchWithOSMesa was consistently failing - Initia... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # 2 #
3 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 3 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """code generator for GLES2 command buffers.""" 7 """code generator for GLES2 command buffers."""
8 8
9 import os 9 import os
10 import os.path 10 import os.path
(...skipping 2107 matching lines...) Expand 10 before | Expand all | Expand 10 after
2118 func.MakeTypedOriginalArgString(""))) 2118 func.MakeTypedOriginalArgString("")))
2119 for arg in func.GetOriginalArgs(): 2119 for arg in func.GetOriginalArgs():
2120 arg.WriteClientSideValidationCode(file, func) 2120 arg.WriteClientSideValidationCode(file, func)
2121 file.Write(" helper_->%s(%s);\n" % 2121 file.Write(" helper_->%s(%s);\n" %
2122 (func.name, func.MakeOriginalArgString(""))) 2122 (func.name, func.MakeOriginalArgString("")))
2123 file.Write("}\n") 2123 file.Write("}\n")
2124 file.Write("\n") 2124 file.Write("\n")
2125 else: 2125 else:
2126 self.WriteGLES2ImplementationDeclaration(func, file) 2126 self.WriteGLES2ImplementationDeclaration(func, file)
2127 2127
2128 def WriteDestinationInitalizationValidation(self, func, file):
2129 """Writes the client side destintion initialization validation."""
2130 for arg in func.GetOriginalArgs():
2131 arg.WriteDestinationInitalizationValidation(file, func)
2132
2133 def WriteImmediateCmdComputeSize(self, func, file): 2128 def WriteImmediateCmdComputeSize(self, func, file):
2134 """Writes the size computation code for the immediate version of a cmd.""" 2129 """Writes the size computation code for the immediate version of a cmd."""
2135 file.Write(" static uint32 ComputeSize(uint32 size_in_bytes) {\n") 2130 file.Write(" static uint32 ComputeSize(uint32 size_in_bytes) {\n")
2136 file.Write(" return static_cast<uint32>(\n") 2131 file.Write(" return static_cast<uint32>(\n")
2137 file.Write(" sizeof(ValueType) + // NOLINT\n") 2132 file.Write(" sizeof(ValueType) + // NOLINT\n")
2138 file.Write(" RoundSizeToMultipleOfEntries(size_in_bytes));\n") 2133 file.Write(" RoundSizeToMultipleOfEntries(size_in_bytes));\n")
2139 file.Write(" }\n") 2134 file.Write(" }\n")
2140 file.Write("\n") 2135 file.Write("\n")
2141 2136
2142 def WriteImmediateCmdSetHeader(self, func, file): 2137 def WriteImmediateCmdSetHeader(self, func, file):
(...skipping 1835 matching lines...) Expand 10 before | Expand all | Expand 10 after
3978 3973
3979 cmd_type_map_ = { 3974 cmd_type_map_ = {
3980 'GLenum': 'uint32', 3975 'GLenum': 'uint32',
3981 'GLint': 'int32', 3976 'GLint': 'int32',
3982 'GLintptr': 'int32', 3977 'GLintptr': 'int32',
3983 'GLsizei': 'int32', 3978 'GLsizei': 'int32',
3984 'GLsizeiptr': 'int32', 3979 'GLsizeiptr': 'int32',
3985 'GLfloat': 'float', 3980 'GLfloat': 'float',
3986 'GLclampf': 'float', 3981 'GLclampf': 'float',
3987 } 3982 }
3988 need_validation_ = ['GLsizei*', 'GLboolean*', 'GLenum*', 'GLint*']
3989 3983
3990 def __init__(self, name, type): 3984 def __init__(self, name, type):
3991 self.name = name 3985 self.name = name
3992 self.type = type 3986 self.type = type
3993 3987
3994 if type in self.cmd_type_map_: 3988 if type in self.cmd_type_map_:
3995 self.cmd_type = self.cmd_type_map_[type] 3989 self.cmd_type = self.cmd_type_map_[type]
3996 else: 3990 else:
3997 self.cmd_type = 'uint32' 3991 self.cmd_type = 'uint32'
3998 3992
(...skipping 29 matching lines...) Expand all
4028 (self.type, self.name, self.type, self.name)) 4022 (self.type, self.name, self.type, self.name))
4029 4023
4030 def WriteValidationCode(self, file, func): 4024 def WriteValidationCode(self, file, func):
4031 """Writes the validation code for an argument.""" 4025 """Writes the validation code for an argument."""
4032 pass 4026 pass
4033 4027
4034 def WriteClientSideValidationCode(self, file, func): 4028 def WriteClientSideValidationCode(self, file, func):
4035 """Writes the validation code for an argument.""" 4029 """Writes the validation code for an argument."""
4036 pass 4030 pass
4037 4031
4038 def WriteDestinationInitalizationValidation(self, file, func):
4039 """Writes the client side destintion initialization validation."""
4040 pass
4041
4042 def WriteDestinationInitalizationValidatationIfNeeded(self, file, func):
4043 """Writes the client side destintion initialization validation if needed."""
4044 parts = self.type.split(" ")
4045 if len(parts) > 1:
4046 return
4047 if parts[0] in self.need_validation_:
4048 file.Write(" GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION(%s, %s);\n" %
4049 (self.type[:-1], self.name))
4050
4051
4052 def WriteGetAddress(self, file): 4032 def WriteGetAddress(self, file):
4053 """Writes the code to get the address this argument refers to.""" 4033 """Writes the code to get the address this argument refers to."""
4054 pass 4034 pass
4055 4035
4056 def GetImmediateVersion(self): 4036 def GetImmediateVersion(self):
4057 """Gets the immediate version of this argument.""" 4037 """Gets the immediate version of this argument."""
4058 return self 4038 return self
4059 4039
4060 def GetBucketVersion(self): 4040 def GetBucketVersion(self):
4061 """Gets the bucket version of this argument.""" 4041 """Gets the bucket version of this argument."""
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
4226 def WriteValidationCode(self, file, func): 4206 def WriteValidationCode(self, file, func):
4227 """Overridden from Argument.""" 4207 """Overridden from Argument."""
4228 file.Write(" if (%s == NULL) {\n" % self.name) 4208 file.Write(" if (%s == NULL) {\n" % self.name)
4229 file.Write(" return error::kOutOfBounds;\n") 4209 file.Write(" return error::kOutOfBounds;\n")
4230 file.Write(" }\n") 4210 file.Write(" }\n")
4231 4211
4232 def GetImmediateVersion(self): 4212 def GetImmediateVersion(self):
4233 """Overridden from Argument.""" 4213 """Overridden from Argument."""
4234 return None 4214 return None
4235 4215
4236 def WriteDestinationInitalizationValidation(self, file, func):
4237 """Overridden from Argument."""
4238 self.WriteDestinationInitalizationValidatationIfNeeded(file, func)
4239
4240 4216
4241 class BucketPointerArgument(Argument): 4217 class BucketPointerArgument(Argument):
4242 """A class that represents an bucket argument to a function.""" 4218 """A class that represents an bucket argument to a function."""
4243 4219
4244 def __init__(self, name, type): 4220 def __init__(self, name, type):
4245 Argument.__init__(self, name, type) 4221 Argument.__init__(self, name, type)
4246 4222
4247 def AddCmdArgs(self, args): 4223 def AddCmdArgs(self, args):
4248 """Overridden from Argument.""" 4224 """Overridden from Argument."""
4249 pass 4225 pass
4250 4226
4251 def WriteGetCode(self, file): 4227 def WriteGetCode(self, file):
4252 """Overridden from Argument.""" 4228 """Overridden from Argument."""
4253 file.Write( 4229 file.Write(
4254 " %s %s = bucket->GetData(0, data_size);\n" % 4230 " %s %s = bucket->GetData(0, data_size);\n" %
4255 (self.type, self.name)) 4231 (self.type, self.name))
4256 4232
4257 def WriteValidationCode(self, file, func): 4233 def WriteValidationCode(self, file, func):
4258 """Overridden from Argument.""" 4234 """Overridden from Argument."""
4259 pass 4235 pass
4260 4236
4261 def GetImmediateVersion(self): 4237 def GetImmediateVersion(self):
4262 """Overridden from Argument.""" 4238 """Overridden from Argument."""
4263 return None 4239 return None
4264 4240
4265 def WriteDestinationInitalizationValidation(self, file, func):
4266 """Overridden from Argument."""
4267 self.WriteDestinationInitalizationValidatationIfNeeded(file, func)
4268
4269 4241
4270 class PointerArgument(Argument): 4242 class PointerArgument(Argument):
4271 """A class that represents a pointer argument to a function.""" 4243 """A class that represents a pointer argument to a function."""
4272 4244
4273 def __init__(self, name, type): 4245 def __init__(self, name, type):
4274 Argument.__init__(self, name, type) 4246 Argument.__init__(self, name, type)
4275 4247
4276 def IsPointer(self): 4248 def IsPointer(self):
4277 """Returns true if argument is a pointer.""" 4249 """Returns true if argument is a pointer."""
4278 return True 4250 return True
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
4329 def GetImmediateVersion(self): 4301 def GetImmediateVersion(self):
4330 """Overridden from Argument.""" 4302 """Overridden from Argument."""
4331 return ImmediatePointerArgument(self.name, self.type) 4303 return ImmediatePointerArgument(self.name, self.type)
4332 4304
4333 def GetBucketVersion(self): 4305 def GetBucketVersion(self):
4334 """Overridden from Argument.""" 4306 """Overridden from Argument."""
4335 if self.type == "const char*": 4307 if self.type == "const char*":
4336 return InputStringBucketArgument(self.name, self.type) 4308 return InputStringBucketArgument(self.name, self.type)
4337 return BucketPointerArgument(self.name, self.type) 4309 return BucketPointerArgument(self.name, self.type)
4338 4310
4339 def WriteDestinationInitalizationValidation(self, file, func):
4340 """Overridden from Argument."""
4341 self.WriteDestinationInitalizationValidatationIfNeeded(file, func)
4342
4343 4311
4344 class InputStringBucketArgument(Argument): 4312 class InputStringBucketArgument(Argument):
4345 """An string input argument where the string is passed in a bucket.""" 4313 """An string input argument where the string is passed in a bucket."""
4346 4314
4347 def __init__(self, name, type): 4315 def __init__(self, name, type):
4348 Argument.__init__(self, name + "_bucket_id", "uint32") 4316 Argument.__init__(self, name + "_bucket_id", "uint32")
4349 4317
4350 def WriteGetCode(self, file): 4318 def WriteGetCode(self, file):
4351 """Overridden from Argument.""" 4319 """Overridden from Argument."""
4352 code = """ 4320 code = """
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
4654 self.type_handler.WriteServiceImplementation(self, file) 4622 self.type_handler.WriteServiceImplementation(self, file)
4655 4623
4656 def WriteServiceUnitTest(self, file): 4624 def WriteServiceUnitTest(self, file):
4657 """Writes the service implementation for a command.""" 4625 """Writes the service implementation for a command."""
4658 self.type_handler.WriteServiceUnitTest(self, file) 4626 self.type_handler.WriteServiceUnitTest(self, file)
4659 4627
4660 def WriteGLES2ImplementationHeader(self, file): 4628 def WriteGLES2ImplementationHeader(self, file):
4661 """Writes the GLES2 Implemention declaration.""" 4629 """Writes the GLES2 Implemention declaration."""
4662 self.type_handler.WriteGLES2ImplementationHeader(self, file) 4630 self.type_handler.WriteGLES2ImplementationHeader(self, file)
4663 4631
4664 def WriteDestinationInitalizationValidation(self, file):
4665 """Writes the client side destintion initialization validation."""
4666 self.type_handler.WriteDestinationInitalizationValidation(self, file)
4667
4668 def WriteFormatTest(self, file): 4632 def WriteFormatTest(self, file):
4669 """Writes the cmd's format test.""" 4633 """Writes the cmd's format test."""
4670 self.type_handler.WriteFormatTest(self, file) 4634 self.type_handler.WriteFormatTest(self, file)
4671 4635
4672 4636
4673 class ImmediateFunction(Function): 4637 class ImmediateFunction(Function):
4674 """A class that represnets an immediate function command.""" 4638 """A class that represnets an immediate function command."""
4675 4639
4676 def __init__(self, func): 4640 def __init__(self, func):
4677 new_args = [] 4641 new_args = []
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
5142 def WriteGLES2CLibImplementation(self, filename): 5106 def WriteGLES2CLibImplementation(self, filename):
5143 """Writes the GLES2 c lib implementation.""" 5107 """Writes the GLES2 c lib implementation."""
5144 file = CHeaderWriter( 5108 file = CHeaderWriter(
5145 filename, 5109 filename,
5146 "// These functions emluate GLES2 over command buffers.\n") 5110 "// These functions emluate GLES2 over command buffers.\n")
5147 5111
5148 for func in self.original_functions: 5112 for func in self.original_functions:
5149 file.Write("%s GLES2%s(%s) {\n" % 5113 file.Write("%s GLES2%s(%s) {\n" %
5150 (func.return_type, func.name, 5114 (func.return_type, func.name,
5151 func.MakeTypedOriginalArgString(""))) 5115 func.MakeTypedOriginalArgString("")))
5152 func.WriteDestinationInitalizationValidation(file)
5153 comma = "" 5116 comma = ""
5154 if len(func.GetOriginalArgs()): 5117 if len(func.GetOriginalArgs()):
5155 comma = " << " 5118 comma = " << "
5156 file.Write( 5119 file.Write(
5157 ' GPU_CLIENT_LOG("%s" << "("%s%s << ")");\n' % 5120 ' GPU_CLIENT_LOG("%s" << "("%s%s << ")");\n' %
5158 (func.original_name, comma, func.MakeOriginalArgString( 5121 (func.original_name, comma, func.MakeOriginalArgString(
5159 "", separator=' << ", " << '))) 5122 "", separator=' << ", " << ')))
5160 result_string = "%s result = " % func.return_type 5123 result_string = "%s result = " % func.return_type
5161 return_string = ( 5124 return_string = (
5162 ' GPU_CLIENT_LOG("return:" << result)\n return result;\n') 5125 ' GPU_CLIENT_LOG("return:" << result)\n return result;\n')
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
5356 5319
5357 if options.generate_docs: 5320 if options.generate_docs:
5358 gen.WriteDocs("docs/gles2_cmd_format_docs_autogen.h") 5321 gen.WriteDocs("docs/gles2_cmd_format_docs_autogen.h")
5359 5322
5360 if gen.errors > 0: 5323 if gen.errors > 0:
5361 print "%d errors" % gen.errors 5324 print "%d errors" % gen.errors
5362 sys.exit(1) 5325 sys.exit(1)
5363 5326
5364 if __name__ == '__main__': 5327 if __name__ == '__main__':
5365 main(sys.argv[1:]) 5328 main(sys.argv[1:])
OLDNEW
« no previous file with comments | « chrome/renderer/webgraphicscontext3d_command_buffer_impl.cc ('k') | gpu/command_buffer/client/gles2_c_lib.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698