From 9bf308380b76bba227bee4e12342dd20fb205a53 Mon Sep 17 00:00:00 2001 From: kylechar Date: Tue, 12 Apr 2022 13:59:44 +0000 Subject: [PATCH] Convert command buffer autogen to python3 The python scripts to generate GLES2/raster/WebGPU command buffer was still running with vpython which is 2.7. Update the PRESUBMIT to run with python3 and fix python3 compatibility issues. Bug: none Change-Id: Ibe11208afb11bfe9870dc261865a7c909f76bde2 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3577186 Reviewed-by: Zhenyao Mo Reviewed-by: Derek Schuff Commit-Queue: Kyle Charbonneau Cr-Commit-Position: refs/heads/main@{#991501} --- gpu/command_buffer/PRESUBMIT.py | 6 ++--- gpu/command_buffer/build_cmd_buffer_lib.py | 22 +++++++++---------- gpu/command_buffer/build_gles2_cmd_buffer.py | 10 ++++----- gpu/command_buffer/build_raster_cmd_buffer.py | 10 ++++----- gpu/command_buffer/build_webgpu_cmd_buffer.py | 10 ++++----- .../common/gles2_cmd_format_autogen.h | 4 ++-- ppapi/api/ppb_opengles2.idl | 16 +++++++------- 7 files changed, 39 insertions(+), 39 deletions(-) diff --git a/gpu/command_buffer/PRESUBMIT.py b/gpu/command_buffer/PRESUBMIT.py index 9c8df9fc6787fb..e54d94b6bd6737 100644 --- a/gpu/command_buffer/PRESUBMIT.py +++ b/gpu/command_buffer/PRESUBMIT.py @@ -65,7 +65,7 @@ def CommonChecks(input_api, output_api): input_api.Command( name='build_gles2_cmd_buffer', cmd=[ - input_api.python_executable, 'build_gles2_cmd_buffer.py', + input_api.python3_executable, 'build_gles2_cmd_buffer.py', '--check', '--output-dir=' + temp_dir ], kwargs={}, @@ -75,7 +75,7 @@ def CommonChecks(input_api, output_api): input_api.Command( name='build_raster_cmd_buffer', cmd=[ - input_api.python_executable, 'build_raster_cmd_buffer.py', + input_api.python3_executable, 'build_raster_cmd_buffer.py', '--check', '--output-dir=' + temp_dir ], kwargs={}, @@ -85,7 +85,7 @@ def CommonChecks(input_api, output_api): input_api.Command( name='build_webgpu_cmd_buffer', cmd=[ - input_api.python_executable, 'build_webgpu_cmd_buffer.py', + input_api.python3_executable, 'build_webgpu_cmd_buffer.py', '--check', '--output-dir=' + temp_dir ], kwargs={}, diff --git a/gpu/command_buffer/build_cmd_buffer_lib.py b/gpu/command_buffer/build_cmd_buffer_lib.py index 8a727de0cf94ce..29cc27e945c546 100644 --- a/gpu/command_buffer/build_cmd_buffer_lib.py +++ b/gpu/command_buffer/build_cmd_buffer_lib.py @@ -682,7 +682,7 @@ def _Namespace(): def Grouper(n, iterable, fillvalue=None): """Collect data into fixed-length chunks or blocks""" args = [iter(iterable)] * n - return itertools.izip_longest(fillvalue=fillvalue, *args) + return itertools.zip_longest(fillvalue=fillvalue, *args) def SplitWords(input_string): @@ -831,7 +831,7 @@ def __init__(self, filename, year): except OSError as e: if e.errno == errno.EEXIST: pass - self._file = open(filename, 'wb') + self._file = open(filename, 'w') def __enter__(self): self._file.write(self._ENTER_MSG) @@ -1477,7 +1477,7 @@ def WriteGLES2ImplementationUnitTest(self, func, f): """ for invalid_arg in constants: gl_arg_strings = [] - invalid = invalid_arg.GetInvalidArg(func) + invalid = invalid_arg.GetInvalidArg(0) for arg in func.GetOriginalArgs(): if arg is invalid_arg: gl_arg_strings.append(invalid[0]) @@ -5923,7 +5923,7 @@ def WriteCmdFlag(self, f): """Writes the cmd cmd_flags constant.""" # By default trace only at the highest level 3. trace_level = int(self.GetInfo('trace_level', default = 3)) - if trace_level not in xrange(0, 4): + if trace_level not in range(0, 4): raise KeyError("Unhandled trace_level: %d" % trace_level) cmd_flags = ('CMD_FLAG_SET_TRACE_LEVEL(%d)' % trace_level) @@ -6351,11 +6351,11 @@ def GetFunctionInfo(self, name): def Log(self, msg): """Prints something if verbose is true.""" if self.verbose: - print msg + print(msg) def Error(self, msg): """Prints an error.""" - print "Error: %s" % msg + print("Error: %s" % msg) self.errors += 1 def ParseGLH(self, filename): @@ -6703,7 +6703,7 @@ def WriteStates(test_prev): continue if state['type'] == 'FrontBack': num_states = len(state['states']) - for ndx, group in enumerate(Grouper(num_states / 2, + for ndx, group in enumerate(Grouper(num_states // 2, state['states'])): if test_prev: f.write(" if (") @@ -6992,7 +6992,7 @@ def WriteServiceContextStateTestHelpers(self, filename): state = _STATE_INFO[state_name] if state['type'] == 'FrontBack': num_states = len(state['states']) - for ndx, group in enumerate(Grouper(num_states / 2, + for ndx, group in enumerate(Grouper(num_states // 2, state['states'])): args = [] for item in group: @@ -7424,13 +7424,13 @@ def WritePepperGLES2Interface(self, filename, dev): f.write("#include \"ppapi/c/ppb_opengles2.h\"\n\n") else: f.write("\n#ifndef __gl2_h_\n") - for (k, v) in _GL_TYPES.iteritems(): + for (k, v) in _GL_TYPES.items(): f.write("typedef %s %s;\n" % (v, k)) f.write("#ifdef _WIN64\n") - for (k, v) in _GL_TYPES_64.iteritems(): + for (k, v) in _GL_TYPES_64.items(): f.write("typedef %s %s;\n" % (v, k)) f.write("#else\n") - for (k, v) in _GL_TYPES_32.iteritems(): + for (k, v) in _GL_TYPES_32.items(): f.write("typedef %s %s;\n" % (v, k)) f.write("#endif // _WIN64\n") f.write("#endif // __gl2_h_\n\n") diff --git a/gpu/command_buffer/build_gles2_cmd_buffer.py b/gpu/command_buffer/build_gles2_cmd_buffer.py index f759df7f9920a0..92e68825223bd5 100755 --- a/gpu/command_buffer/build_gles2_cmd_buffer.py +++ b/gpu/command_buffer/build_gles2_cmd_buffer.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright (c) 2012 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. @@ -4318,7 +4318,7 @@ def main(argv): chromium_root_dir) if gen.errors > 0: - print "build_gles2_cmd_buffer.py: Failed with %d errors" % gen.errors + print("build_gles2_cmd_buffer.py: Failed with %d errors" % gen.errors) return 1 check_failed_filenames = [] @@ -4329,10 +4329,10 @@ def main(argv): check_failed_filenames.append(filename) if len(check_failed_filenames) > 0: - print 'Please run gpu/command_buffer/build_gles2_cmd_buffer.py' - print 'Failed check on autogenerated command buffer files:' + print('Please run gpu/command_buffer/build_gles2_cmd_buffer.py') + print('Failed check on autogenerated command buffer files:') for filename in check_failed_filenames: - print filename + print(filename) return 1 return 0 diff --git a/gpu/command_buffer/build_raster_cmd_buffer.py b/gpu/command_buffer/build_raster_cmd_buffer.py index e3ad4527286abd..1a008945226298 100755 --- a/gpu/command_buffer/build_raster_cmd_buffer.py +++ b/gpu/command_buffer/build_raster_cmd_buffer.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright 2018 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. @@ -468,7 +468,7 @@ def main(argv): chromium_root_dir) if gen.errors > 0: - print "build_raster_cmd_buffer.py: Failed with %d errors" % gen.errors + print("build_raster_cmd_buffer.py: Failed with %d errors" % gen.errors) return 1 check_failed_filenames = [] @@ -479,10 +479,10 @@ def main(argv): check_failed_filenames.append(filename) if len(check_failed_filenames) > 0: - print 'Please run gpu/command_buffer/build_raster_cmd_buffer.py' - print 'Failed check on autogenerated command buffer files:' + print('Please run gpu/command_buffer/build_raster_cmd_buffer.py') + print('Failed check on autogenerated command buffer files:') for filename in check_failed_filenames: - print filename + print(filename) return 1 return 0 diff --git a/gpu/command_buffer/build_webgpu_cmd_buffer.py b/gpu/command_buffer/build_webgpu_cmd_buffer.py index 0902050698bec2..fdb171550beee1 100755 --- a/gpu/command_buffer/build_webgpu_cmd_buffer.py +++ b/gpu/command_buffer/build_webgpu_cmd_buffer.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright 2018 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. @@ -168,7 +168,7 @@ def main(argv): chromium_root_dir) if gen.errors > 0: - print "build_webgpu_cmd_buffer.py: Failed with %d errors" % gen.errors + print("build_webgpu_cmd_buffer.py: Failed with %d errors" % gen.errors) return 1 check_failed_filenames = [] @@ -179,10 +179,10 @@ def main(argv): check_failed_filenames.append(filename) if len(check_failed_filenames) > 0: - print 'Please run gpu/command_buffer/build_webgpu_cmd_buffer.py' - print 'Failed check on autogenerated command buffer files:' + print('Please run gpu/command_buffer/build_webgpu_cmd_buffer.py') + print('Failed check on autogenerated command buffer files:') for filename in check_failed_filenames: - print filename + print(filename) return 1 return 0 diff --git a/gpu/command_buffer/common/gles2_cmd_format_autogen.h b/gpu/command_buffer/common/gles2_cmd_format_autogen.h index 98961dbaef56cf..3c392f592bb824 100644 --- a/gpu/command_buffer/common/gles2_cmd_format_autogen.h +++ b/gpu/command_buffer/common/gles2_cmd_format_autogen.h @@ -11,9 +11,9 @@ #ifndef GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_FORMAT_AUTOGEN_H_ #define GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_FORMAT_AUTOGEN_H_ -#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001 -#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 #define GL_SCANOUT_CHROMIUM 0x6000 +#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 +#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001 struct ActiveTexture { typedef ActiveTexture ValueType; diff --git a/ppapi/api/ppb_opengles2.idl b/ppapi/api/ppb_opengles2.idl index 5f080992860058..5bfb0259d54a37 100644 --- a/ppapi/api/ppb_opengles2.idl +++ b/ppapi/api/ppb_opengles2.idl @@ -52,19 +52,19 @@ describe { #include "ppapi/c/pp_resource.h" #ifndef __gl2_h_ -typedef void GLvoid; -typedef int GLsizei; -typedef unsigned short GLushort; -typedef short GLshort; -typedef unsigned char GLubyte; typedef unsigned int GLenum; -typedef int GLint; typedef unsigned char GLboolean; typedef unsigned int GLbitfield; -typedef float GLfloat; -typedef float GLclampf; typedef signed char GLbyte; +typedef short GLshort; +typedef int GLint; +typedef int GLsizei; +typedef unsigned char GLubyte; +typedef unsigned short GLushort; typedef unsigned int GLuint; +typedef float GLfloat; +typedef float GLclampf; +typedef void GLvoid; typedef int GLfixed; typedef int GLclampx; #ifdef _WIN64