OLD | NEW |
---|---|
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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
58 GL_APICALL void GL_APIENTRY glBindBuffer (GLenumBufferTarget target, GLi dBindBuffer buffer); | 58 GL_APICALL void GL_APIENTRY glBindBuffer (GLenumBufferTarget target, GLi dBindBuffer buffer); |
59 GL_APICALL void GL_APIENTRY glBindFramebuffer (GLenumFrameBufferTarget t arget, GLidBindFramebuffer framebuffer); | 59 GL_APICALL void GL_APIENTRY glBindFramebuffer (GLenumFrameBufferTarget t arget, GLidBindFramebuffer framebuffer); |
60 GL_APICALL void GL_APIENTRY glBindRenderbuffer (GLenumRenderBufferTarget target, GLidBindRenderbuffer renderbuffer); | 60 GL_APICALL void GL_APIENTRY glBindRenderbuffer (GLenumRenderBufferTarget target, GLidBindRenderbuffer renderbuffer); |
61 GL_APICALL void GL_APIENTRY glBindTexture (GLenumTextureBindTarget targe t, GLidBindTexture texture); | 61 GL_APICALL void GL_APIENTRY glBindTexture (GLenumTextureBindTarget targe t, GLidBindTexture texture); |
62 GL_APICALL void GL_APIENTRY glBlendColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); | 62 GL_APICALL void GL_APIENTRY glBlendColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); |
63 GL_APICALL void GL_APIENTRY glBlendEquation ( GLenumEquation mode ); | 63 GL_APICALL void GL_APIENTRY glBlendEquation ( GLenumEquation mode ); |
64 GL_APICALL void GL_APIENTRY glBlendEquationSeparate (GLenumEquation mode RGB, GLenumEquation modeAlpha); | 64 GL_APICALL void GL_APIENTRY glBlendEquationSeparate (GLenumEquation mode RGB, GLenumEquation modeAlpha); |
65 GL_APICALL void GL_APIENTRY glBlendFunc (GLenumSrcBlendFactor sfactor, G LenumDstBlendFactor dfactor); | 65 GL_APICALL void GL_APIENTRY glBlendFunc (GLenumSrcBlendFactor sfactor, G LenumDstBlendFactor dfactor); |
66 GL_APICALL void GL_APIENTRY glBlendFuncSeparate (GLenumSrcBlendFactor sr cRGB, GLenumDstBlendFactor dstRGB, GLenumSrcBlendFactor srcAlpha, GLenumDstBlend Factor dstAlpha); | 66 GL_APICALL void GL_APIENTRY glBlendFuncSeparate (GLenumSrcBlendFactor sr cRGB, GLenumDstBlendFactor dstRGB, GLenumSrcBlendFactor srcAlpha, GLenumDstBlend Factor dstAlpha); |
67 GL_APICALL void GL_APIENTRY glBufferData (GLenumBufferTarget target, GLs izeiptr size, const void* data, GLenumBufferUsage usage); | 67 GL_APICALL void GL_APIENTRY glBufferData (GLenumBufferTarget target, GLs izeiptr size, const void* data, GLenumBufferUsage usage); |
68 GL_APICALL void GL_APIENTRY glBufferSubData (GLenumBufferTarget target, GLintptr offset, GLsizeiptr size, const void* data); | 68 GL_APICALL void GL_APIENTRY glBufferSubData (GLenumBufferTarget target, GLintptrNotNegative offset, GLsizeiptr size, const void* data); |
69 GL_APICALL GLenum GL_APIENTRY glCheckFramebufferStatus (GLenumFrameBufferT arget target); | 69 GL_APICALL GLenum GL_APIENTRY glCheckFramebufferStatus (GLenumFrameBufferT arget target); |
70 GL_APICALL void GL_APIENTRY glClear (GLbitfield mask); | 70 GL_APICALL void GL_APIENTRY glClear (GLbitfield mask); |
71 GL_APICALL void GL_APIENTRY glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); | 71 GL_APICALL void GL_APIENTRY glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); |
72 GL_APICALL void GL_APIENTRY glClearDepthf (GLclampf depth); | 72 GL_APICALL void GL_APIENTRY glClearDepthf (GLclampf depth); |
73 GL_APICALL void GL_APIENTRY glClearStencil (GLint s); | 73 GL_APICALL void GL_APIENTRY glClearStencil (GLint s); |
74 GL_APICALL void GL_APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); | 74 GL_APICALL void GL_APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); |
75 GL_APICALL void GL_APIENTRY glCompileShader (GLidShader shader); | 75 GL_APICALL void GL_APIENTRY glCompileShader (GLidShader shader); |
76 GL_APICALL void GL_APIENTRY glCompressedTexImage2D (GLenumTextureTarget target, GLint level, GLenumCompressedTextureFormat internalformat, GLsizei width , GLsizei height, GLint border, GLsizei imageSize, const void* data); | 76 GL_APICALL void GL_APIENTRY glCompressedTexImage2D (GLenumTextureTarget target, GLint level, GLenumCompressedTextureFormat internalformat, GLsizei width , GLsizei height, GLint border, GLsizei imageSize, const void* data); |
77 GL_APICALL void GL_APIENTRY glCompressedTexSubImage2D (GLenumTextureTarg et target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei hei ght, GLenumCompressedTextureFormat format, GLsizei imageSize, const void* data); | 77 GL_APICALL void GL_APIENTRY glCompressedTexSubImage2D (GLenumTextureTarg et target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei hei ght, GLenumCompressedTextureFormat format, GLsizei imageSize, const void* data); |
78 GL_APICALL void GL_APIENTRY glCopyTexImage2D (GLenumTextureTarget target , GLint level, GLenumTextureInternalFormat internalformat, GLint x, GLint y, GLs izei width, GLsizei height, GLint border); | 78 GL_APICALL void GL_APIENTRY glCopyTexImage2D (GLenumTextureTarget target , GLint level, GLenumTextureInternalFormat internalformat, GLint x, GLint y, GLs izei width, GLsizei height, GLint border); |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
196 GL_APICALL void GL_APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height); | 196 GL_APICALL void GL_APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height); |
197 GL_APICALL void GL_APIENTRY glBlitFramebufferEXT (GLint srcX0, GLint src Y0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1 , GLbitfield mask, GLenumBlitFilter filter); | 197 GL_APICALL void GL_APIENTRY glBlitFramebufferEXT (GLint srcX0, GLint src Y0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1 , GLbitfield mask, GLenumBlitFilter filter); |
198 GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleEXT (GLenumR enderBufferTarget target, GLsizei samples, GLenumRenderBufferFormat internalform at, GLsizei width, GLsizei height); | 198 GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleEXT (GLenumR enderBufferTarget target, GLsizei samples, GLenumRenderBufferFormat internalform at, GLsizei width, GLsizei height); |
199 // Non-GL commands. | 199 // Non-GL commands. |
200 GL_APICALL void GL_APIENTRY glSwapBuffers (void); | 200 GL_APICALL void GL_APIENTRY glSwapBuffers (void); |
201 GL_APICALL GLuint GL_APIENTRY glGetMaxValueInBufferCHROMIUM (GLidBuffer bu ffer_id, GLsizei count, GLenumGetMaxIndexType type, GLuint offset); | 201 GL_APICALL GLuint GL_APIENTRY glGetMaxValueInBufferCHROMIUM (GLidBuffer bu ffer_id, GLsizei count, GLenumGetMaxIndexType type, GLuint offset); |
202 GL_APICALL void GL_APIENTRY glGenSharedIdsCHROMIUM (GLuint namespace_id, GLuint id_offset, GLsizeiNotNegative n, GLuint* ids); | 202 GL_APICALL void GL_APIENTRY glGenSharedIdsCHROMIUM (GLuint namespace_id, GLuint id_offset, GLsizeiNotNegative n, GLuint* ids); |
203 GL_APICALL void GL_APIENTRY glDeleteSharedIdsCHROMIUM (GLuint namespace_ id, GLsizeiNotNegative n, const GLuint* ids); | 203 GL_APICALL void GL_APIENTRY glDeleteSharedIdsCHROMIUM (GLuint namespace_ id, GLsizeiNotNegative n, const GLuint* ids); |
204 GL_APICALL void GL_APIENTRY glRegisterSharedIdsCHROMIUM (GLuint namespac e_id, GLsizeiNotNegative n, const GLuint* ids); | 204 GL_APICALL void GL_APIENTRY glRegisterSharedIdsCHROMIUM (GLuint namespac e_id, GLsizeiNotNegative n, const GLuint* ids); |
205 GL_APICALL GLboolean GL_APIENTRY glCommandBufferEnableCHROMIUM (const char* f eature); | 205 GL_APICALL GLboolean GL_APIENTRY glCommandBufferEnableCHROMIUM (const char* f eature); |
206 GL_APICALL void* GL_APIENTRY glMapBufferSubDataCHROMIUM (GLuint target, G Lintptr offset, GLsizeiptr size, GLenum access); | 206 GL_APICALL void* GL_APIENTRY glMapBufferSubDataCHROMIUM (GLuint target, G LintptrNotNegative offset, GLsizeiptr size, GLenum access); |
207 GL_APICALL void GL_APIENTRY glUnmapBufferSubDataCHROMIUM (const void* me m); | 207 GL_APICALL void GL_APIENTRY glUnmapBufferSubDataCHROMIUM (const void* me m); |
208 GL_APICALL void* GL_APIENTRY glMapTexSubImage2DCHROMIUM (GLenum target, G Lint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLenum access); | 208 GL_APICALL void* GL_APIENTRY glMapTexSubImage2DCHROMIUM (GLenum target, G Lint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLenum access); |
209 GL_APICALL void GL_APIENTRY glUnmapTexSubImage2DCHROMIUM (const void* me m); | 209 GL_APICALL void GL_APIENTRY glUnmapTexSubImage2DCHROMIUM (const void* me m); |
210 GL_APICALL void GL_APIENTRY glCopyTextureToParentTextureCHROMIUM (GLidBi ndTexture client_child_id, GLidBindTexture client_parent_id); | 210 GL_APICALL void GL_APIENTRY glCopyTextureToParentTextureCHROMIUM (GLidBi ndTexture client_child_id, GLidBindTexture client_parent_id); |
211 GL_APICALL void GL_APIENTRY glResizeCHROMIUM (GLuint width, GLuint heigh t); | 211 GL_APICALL void GL_APIENTRY glResizeCHROMIUM (GLuint width, GLuint heigh t); |
212 """ | 212 """ |
213 | 213 |
214 # This is the list of all commmands that will be generated and their Id. | 214 # This is the list of all commmands that will be generated and their Id. |
215 # If a command is not listed in this table it is an error. | 215 # If a command is not listed in this table it is an error. |
216 # This lets us make sure that command ids do not change as the generator | 216 # This lets us make sure that command ids do not change as the generator |
(...skipping 3863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4080 file.Write(" if (%s < 0) {\n" % self.name) | 4080 file.Write(" if (%s < 0) {\n" % self.name) |
4081 file.Write(" SetGLError(GL_INVALID_VALUE, \"gl%s: %s < 0\");\n" % | 4081 file.Write(" SetGLError(GL_INVALID_VALUE, \"gl%s: %s < 0\");\n" % |
4082 (func.original_name, self.name)) | 4082 (func.original_name, self.name)) |
4083 file.Write(" return;\n") | 4083 file.Write(" return;\n") |
4084 file.Write(" }\n") | 4084 file.Write(" }\n") |
4085 | 4085 |
4086 | 4086 |
4087 class SizeNotNegativeArgument(SizeArgument): | 4087 class SizeNotNegativeArgument(SizeArgument): |
4088 """class for GLsizeiNotNegative. It's NEVER allowed to be negative""" | 4088 """class for GLsizeiNotNegative. It's NEVER allowed to be negative""" |
4089 | 4089 |
4090 def __init__(self, name, type): | 4090 def __init__(self, name, type, gl_type): |
4091 SizeArgument.__init__(self, name, "GLsizei") | 4091 SizeArgument.__init__(self, name, gl_type) |
4092 | 4092 |
4093 def GetInvalidArg(self, offset, index): | 4093 def GetInvalidArg(self, offset, index): |
4094 """overridden from SizeArgument.""" | 4094 """overridden from SizeArgument.""" |
4095 return ("-1", "kOutOfBounds", "GL_NO_ERROR") | 4095 return ("-1", "kOutOfBounds", "GL_NO_ERROR") |
4096 | 4096 |
4097 def WriteValidationCode(self, file, func): | 4097 def WriteValidationCode(self, file, func): |
4098 """overridden from SizeArgument.""" | 4098 """overridden from SizeArgument.""" |
4099 pass | 4099 pass |
4100 #file.Write(" if (%s < 0) {\n" % self.name) | 4100 #file.Write(" if (%s < 0) {\n" % self.name) |
4101 #file.Write(" SetGLError(GL_INVALID_VALUE, \"gl%s: %s < 0\");\n" % | 4101 #file.Write(" SetGLError(GL_INVALID_VALUE, \"gl%s: %s < 0\");\n" % |
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4795 return ResourceIdBindArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) | 4795 return ResourceIdBindArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) |
4796 elif arg_parts[0].startswith('GLidZero'): | 4796 elif arg_parts[0].startswith('GLidZero'): |
4797 return ResourceIdZeroArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) | 4797 return ResourceIdZeroArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) |
4798 elif arg_parts[0].startswith('GLid'): | 4798 elif arg_parts[0].startswith('GLid'): |
4799 return ResourceIdArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) | 4799 return ResourceIdArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) |
4800 elif arg_parts[0].startswith('GLenum') and len(arg_parts[0]) > 6: | 4800 elif arg_parts[0].startswith('GLenum') and len(arg_parts[0]) > 6: |
4801 return EnumArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) | 4801 return EnumArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) |
4802 elif arg_parts[0].startswith('GLboolean') and len(arg_parts[0]) > 9: | 4802 elif arg_parts[0].startswith('GLboolean') and len(arg_parts[0]) > 9: |
4803 return BoolArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) | 4803 return BoolArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) |
4804 elif (arg_parts[0].startswith('GLint') and len(arg_parts[0]) > 5 and | 4804 elif (arg_parts[0].startswith('GLint') and len(arg_parts[0]) > 5 and |
4805 arg_parts[0] != "GLintptr"): | 4805 not arg_parts[0].startswith('GLintptr')): |
4806 return IntArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) | 4806 return IntArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) |
4807 elif arg_parts[0].startswith('GLsizeiNotNegative'): | 4807 elif (arg_parts[0].startswith('GLsizeiNotNegative') or |
4808 return SizeNotNegativeArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) | 4808 arg_parts[0].startswith('GLintptrNotNegative')): |
4809 return SizeNotNegativeArgument(arg_parts[-1], " ".join(arg_parts[0:-1]), arg _parts[0][0:-11]) | |
greggman
2010/12/02 00:04:48
> 80 chars
| |
4809 elif arg_parts[0].startswith('GLsize'): | 4810 elif arg_parts[0].startswith('GLsize'): |
4810 return SizeArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) | 4811 return SizeArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) |
4811 else: | 4812 else: |
4812 return Argument(arg_parts[-1], " ".join(arg_parts[0:-1])) | 4813 return Argument(arg_parts[-1], " ".join(arg_parts[0:-1])) |
4813 | 4814 |
4814 | 4815 |
4815 class GLGenerator(object): | 4816 class GLGenerator(object): |
4816 """A class to generate GL command buffers.""" | 4817 """A class to generate GL command buffers.""" |
4817 | 4818 |
4818 _function_re = re.compile(r'GL_APICALL(.*?)GL_APIENTRY (.*?) \((.*?)\);') | 4819 _function_re = re.compile(r'GL_APICALL(.*?)GL_APIENTRY (.*?) \((.*?)\);') |
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5319 | 5320 |
5320 if options.generate_docs: | 5321 if options.generate_docs: |
5321 gen.WriteDocs("docs/gles2_cmd_format_docs_autogen.h") | 5322 gen.WriteDocs("docs/gles2_cmd_format_docs_autogen.h") |
5322 | 5323 |
5323 if gen.errors > 0: | 5324 if gen.errors > 0: |
5324 print "%d errors" % gen.errors | 5325 print "%d errors" % gen.errors |
5325 sys.exit(1) | 5326 sys.exit(1) |
5326 | 5327 |
5327 if __name__ == '__main__': | 5328 if __name__ == '__main__': |
5328 main(sys.argv[1:]) | 5329 main(sys.argv[1:]) |
OLD | NEW |