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

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

Issue 5254006: Initialize destinations variables before calling GL functions... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years 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 2127 matching lines...) Expand 10 before | Expand all | Expand 10 after
2138 func.MakeTypedOriginalArgString(""))) 2138 func.MakeTypedOriginalArgString("")))
2139 for arg in func.GetOriginalArgs(): 2139 for arg in func.GetOriginalArgs():
2140 arg.WriteClientSideValidationCode(file, func) 2140 arg.WriteClientSideValidationCode(file, func)
2141 file.Write(" helper_->%s(%s);\n" % 2141 file.Write(" helper_->%s(%s);\n" %
2142 (func.name, func.MakeOriginalArgString(""))) 2142 (func.name, func.MakeOriginalArgString("")))
2143 file.Write("}\n") 2143 file.Write("}\n")
2144 file.Write("\n") 2144 file.Write("\n")
2145 else: 2145 else:
2146 self.WriteGLES2ImplementationDeclaration(func, file) 2146 self.WriteGLES2ImplementationDeclaration(func, file)
2147 2147
2148 def WriteDestinationInitalizationValidation(self, func, file):
2149 """Writes the client side destintion initialization validation."""
2150 for arg in func.GetOriginalArgs():
2151 arg.WriteDestinationInitalizationValidation(file, func)
2152
2148 def WriteImmediateCmdComputeSize(self, func, file): 2153 def WriteImmediateCmdComputeSize(self, func, file):
2149 """Writes the size computation code for the immediate version of a cmd.""" 2154 """Writes the size computation code for the immediate version of a cmd."""
2150 file.Write(" static uint32 ComputeSize(uint32 size_in_bytes) {\n") 2155 file.Write(" static uint32 ComputeSize(uint32 size_in_bytes) {\n")
2151 file.Write(" return static_cast<uint32>(\n") 2156 file.Write(" return static_cast<uint32>(\n")
2152 file.Write(" sizeof(ValueType) + // NOLINT\n") 2157 file.Write(" sizeof(ValueType) + // NOLINT\n")
2153 file.Write(" RoundSizeToMultipleOfEntries(size_in_bytes));\n") 2158 file.Write(" RoundSizeToMultipleOfEntries(size_in_bytes));\n")
2154 file.Write(" }\n") 2159 file.Write(" }\n")
2155 file.Write("\n") 2160 file.Write("\n")
2156 2161
2157 def WriteImmediateCmdSetHeader(self, func, file): 2162 def WriteImmediateCmdSetHeader(self, func, file):
(...skipping 1835 matching lines...) Expand 10 before | Expand all | Expand 10 after
3993 3998
3994 cmd_type_map_ = { 3999 cmd_type_map_ = {
3995 'GLenum': 'uint32', 4000 'GLenum': 'uint32',
3996 'GLint': 'int32', 4001 'GLint': 'int32',
3997 'GLintptr': 'int32', 4002 'GLintptr': 'int32',
3998 'GLsizei': 'int32', 4003 'GLsizei': 'int32',
3999 'GLsizeiptr': 'int32', 4004 'GLsizeiptr': 'int32',
4000 'GLfloat': 'float', 4005 'GLfloat': 'float',
4001 'GLclampf': 'float', 4006 'GLclampf': 'float',
4002 } 4007 }
4008 need_validation_ = ['GLsizei*', 'GLboolean*', 'GLenum*', 'GLint*']
4003 4009
4004 def __init__(self, name, type): 4010 def __init__(self, name, type):
4005 self.name = name 4011 self.name = name
4006 self.type = type 4012 self.type = type
4007 4013
4008 if type in self.cmd_type_map_: 4014 if type in self.cmd_type_map_:
4009 self.cmd_type = self.cmd_type_map_[type] 4015 self.cmd_type = self.cmd_type_map_[type]
4010 else: 4016 else:
4011 self.cmd_type = 'uint32' 4017 self.cmd_type = 'uint32'
4012 4018
(...skipping 29 matching lines...) Expand all
4042 (self.type, self.name, self.type, self.name)) 4048 (self.type, self.name, self.type, self.name))
4043 4049
4044 def WriteValidationCode(self, file, func): 4050 def WriteValidationCode(self, file, func):
4045 """Writes the validation code for an argument.""" 4051 """Writes the validation code for an argument."""
4046 pass 4052 pass
4047 4053
4048 def WriteClientSideValidationCode(self, file, func): 4054 def WriteClientSideValidationCode(self, file, func):
4049 """Writes the validation code for an argument.""" 4055 """Writes the validation code for an argument."""
4050 pass 4056 pass
4051 4057
4058 def WriteDestinationInitalizationValidation(self, file, func):
4059 """Writes the client side destintion initialization validation."""
4060 pass
4061
4062 def WriteDestinationInitalizationValidatationIfNeeded(self, file, func):
4063 """Writes the client side destintion initialization validation if needed."""
4064 parts = self.type.split(" ")
4065 if len(parts) > 1:
4066 return
4067 if parts[0] in self.need_validation_:
4068 file.Write(" GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION(%s, %s);\n" %
4069 (self.type[:-1], self.name))
4070
4071
4052 def WriteGetAddress(self, file): 4072 def WriteGetAddress(self, file):
4053 """Writes the code to get the address this argument refers to.""" 4073 """Writes the code to get the address this argument refers to."""
4054 pass 4074 pass
4055 4075
4056 def GetImmediateVersion(self): 4076 def GetImmediateVersion(self):
4057 """Gets the immediate version of this argument.""" 4077 """Gets the immediate version of this argument."""
4058 return self 4078 return self
4059 4079
4060 def GetBucketVersion(self): 4080 def GetBucketVersion(self):
4061 """Gets the bucket version of this argument.""" 4081 """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): 4246 def WriteValidationCode(self, file, func):
4227 """Overridden from Argument.""" 4247 """Overridden from Argument."""
4228 file.Write(" if (%s == NULL) {\n" % self.name) 4248 file.Write(" if (%s == NULL) {\n" % self.name)
4229 file.Write(" return error::kOutOfBounds;\n") 4249 file.Write(" return error::kOutOfBounds;\n")
4230 file.Write(" }\n") 4250 file.Write(" }\n")
4231 4251
4232 def GetImmediateVersion(self): 4252 def GetImmediateVersion(self):
4233 """Overridden from Argument.""" 4253 """Overridden from Argument."""
4234 return None 4254 return None
4235 4255
4256 def WriteDestinationInitalizationValidation(self, file, func):
4257 """Overridden from Argument."""
4258 self.WriteDestinationInitalizationValidatationIfNeeded(file, func)
4259
4236 4260
4237 class BucketPointerArgument(Argument): 4261 class BucketPointerArgument(Argument):
4238 """A class that represents an bucket argument to a function.""" 4262 """A class that represents an bucket argument to a function."""
4239 4263
4240 def __init__(self, name, type): 4264 def __init__(self, name, type):
4241 Argument.__init__(self, name, type) 4265 Argument.__init__(self, name, type)
4242 4266
4243 def AddCmdArgs(self, args): 4267 def AddCmdArgs(self, args):
4244 """Overridden from Argument.""" 4268 """Overridden from Argument."""
4245 pass 4269 pass
4246 4270
4247 def WriteGetCode(self, file): 4271 def WriteGetCode(self, file):
4248 """Overridden from Argument.""" 4272 """Overridden from Argument."""
4249 file.Write( 4273 file.Write(
4250 " %s %s = bucket->GetData(0, data_size);\n" % 4274 " %s %s = bucket->GetData(0, data_size);\n" %
4251 (self.type, self.name)) 4275 (self.type, self.name))
4252 4276
4253 def WriteValidationCode(self, file, func): 4277 def WriteValidationCode(self, file, func):
4254 """Overridden from Argument.""" 4278 """Overridden from Argument."""
4255 pass 4279 pass
4256 4280
4257 def GetImmediateVersion(self): 4281 def GetImmediateVersion(self):
4258 """Overridden from Argument.""" 4282 """Overridden from Argument."""
4259 return None 4283 return None
4260 4284
4285 def WriteDestinationInitalizationValidation(self, file, func):
4286 """Overridden from Argument."""
4287 self.WriteDestinationInitalizationValidatationIfNeeded(file, func)
4288
4261 4289
4262 class PointerArgument(Argument): 4290 class PointerArgument(Argument):
4263 """A class that represents a pointer argument to a function.""" 4291 """A class that represents a pointer argument to a function."""
4264 4292
4265 def __init__(self, name, type): 4293 def __init__(self, name, type):
4266 Argument.__init__(self, name, type) 4294 Argument.__init__(self, name, type)
4267 4295
4268 def IsPointer(self): 4296 def IsPointer(self):
4269 """Returns true if argument is a pointer.""" 4297 """Returns true if argument is a pointer."""
4270 return True 4298 return True
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
4321 def GetImmediateVersion(self): 4349 def GetImmediateVersion(self):
4322 """Overridden from Argument.""" 4350 """Overridden from Argument."""
4323 return ImmediatePointerArgument(self.name, self.type) 4351 return ImmediatePointerArgument(self.name, self.type)
4324 4352
4325 def GetBucketVersion(self): 4353 def GetBucketVersion(self):
4326 """Overridden from Argument.""" 4354 """Overridden from Argument."""
4327 if self.type == "const char*": 4355 if self.type == "const char*":
4328 return InputStringBucketArgument(self.name, self.type) 4356 return InputStringBucketArgument(self.name, self.type)
4329 return BucketPointerArgument(self.name, self.type) 4357 return BucketPointerArgument(self.name, self.type)
4330 4358
4359 def WriteDestinationInitalizationValidation(self, file, func):
4360 """Overridden from Argument."""
4361 self.WriteDestinationInitalizationValidatationIfNeeded(file, func)
4362
4331 4363
4332 class InputStringBucketArgument(Argument): 4364 class InputStringBucketArgument(Argument):
4333 """An string input argument where the string is passed in a bucket.""" 4365 """An string input argument where the string is passed in a bucket."""
4334 4366
4335 def __init__(self, name, type): 4367 def __init__(self, name, type):
4336 Argument.__init__(self, name + "_bucket_id", "uint32") 4368 Argument.__init__(self, name + "_bucket_id", "uint32")
4337 4369
4338 def WriteGetCode(self, file): 4370 def WriteGetCode(self, file):
4339 """Overridden from Argument.""" 4371 """Overridden from Argument."""
4340 code = """ 4372 code = """
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
4642 self.type_handler.WriteServiceImplementation(self, file) 4674 self.type_handler.WriteServiceImplementation(self, file)
4643 4675
4644 def WriteServiceUnitTest(self, file): 4676 def WriteServiceUnitTest(self, file):
4645 """Writes the service implementation for a command.""" 4677 """Writes the service implementation for a command."""
4646 self.type_handler.WriteServiceUnitTest(self, file) 4678 self.type_handler.WriteServiceUnitTest(self, file)
4647 4679
4648 def WriteGLES2ImplementationHeader(self, file): 4680 def WriteGLES2ImplementationHeader(self, file):
4649 """Writes the GLES2 Implemention declaration.""" 4681 """Writes the GLES2 Implemention declaration."""
4650 self.type_handler.WriteGLES2ImplementationHeader(self, file) 4682 self.type_handler.WriteGLES2ImplementationHeader(self, file)
4651 4683
4684 def WriteDestinationInitalizationValidation(self, file):
4685 """Writes the client side destintion initialization validation."""
4686 self.type_handler.WriteDestinationInitalizationValidation(self, file)
4687
4652 def WriteFormatTest(self, file): 4688 def WriteFormatTest(self, file):
4653 """Writes the cmd's format test.""" 4689 """Writes the cmd's format test."""
4654 self.type_handler.WriteFormatTest(self, file) 4690 self.type_handler.WriteFormatTest(self, file)
4655 4691
4656 4692
4657 class ImmediateFunction(Function): 4693 class ImmediateFunction(Function):
4658 """A class that represnets an immediate function command.""" 4694 """A class that represnets an immediate function command."""
4659 4695
4660 def __init__(self, func): 4696 def __init__(self, func):
4661 new_args = [] 4697 new_args = []
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
5129 def WriteGLES2CLibImplementation(self, filename): 5165 def WriteGLES2CLibImplementation(self, filename):
5130 """Writes the GLES2 c lib implementation.""" 5166 """Writes the GLES2 c lib implementation."""
5131 file = CHeaderWriter( 5167 file = CHeaderWriter(
5132 filename, 5168 filename,
5133 "// These functions emluate GLES2 over command buffers.\n") 5169 "// These functions emluate GLES2 over command buffers.\n")
5134 5170
5135 for func in self.original_functions: 5171 for func in self.original_functions:
5136 file.Write("%s GLES2%s(%s) {\n" % 5172 file.Write("%s GLES2%s(%s) {\n" %
5137 (func.return_type, func.name, 5173 (func.return_type, func.name,
5138 func.MakeTypedOriginalArgString(""))) 5174 func.MakeTypedOriginalArgString("")))
5175 func.WriteDestinationInitalizationValidation(file)
5139 comma = "" 5176 comma = ""
5140 if len(func.GetOriginalArgs()): 5177 if len(func.GetOriginalArgs()):
5141 comma = " << " 5178 comma = " << "
5142 file.Write( 5179 file.Write(
5143 ' GPU_CLIENT_LOG("%s" << "("%s%s << ")");\n' % 5180 ' GPU_CLIENT_LOG("%s" << "("%s%s << ")");\n' %
5144 (func.original_name, comma, func.MakeOriginalArgString( 5181 (func.original_name, comma, func.MakeOriginalArgString(
5145 "", separator=' << ", " << '))) 5182 "", separator=' << ", " << ')))
5146 result_string = "%s result = " % func.return_type 5183 result_string = "%s result = " % func.return_type
5147 return_string = ( 5184 return_string = (
5148 ' GPU_CLIENT_LOG("return:" << result)\n return result;\n') 5185 ' GPU_CLIENT_LOG("return:" << result)\n return result;\n')
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
5342 5379
5343 if options.generate_docs: 5380 if options.generate_docs:
5344 gen.WriteDocs("docs/gles2_cmd_format_docs_autogen.h") 5381 gen.WriteDocs("docs/gles2_cmd_format_docs_autogen.h")
5345 5382
5346 if gen.errors > 0: 5383 if gen.errors > 0:
5347 print "%d errors" % gen.errors 5384 print "%d errors" % gen.errors
5348 sys.exit(1) 5385 sys.exit(1)
5349 5386
5350 if __name__ == '__main__': 5387 if __name__ == '__main__':
5351 main(sys.argv[1:]) 5388 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