David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | # -*- coding: utf-8 -*- |
| 3 | |
| 4 | # |
| 5 | # Copyright 2011, The Android Open Source Project |
| 6 | # |
| 7 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | # you may not use this file except in compliance with the License. |
| 9 | # You may obtain a copy of the License at |
| 10 | # |
| 11 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | # |
| 13 | # Unless required by applicable law or agreed to in writing, software |
| 14 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | # See the License for the specific language governing permissions and |
| 17 | # limitations under the License. |
| 18 | # |
| 19 | |
| 20 | import os |
| 21 | |
| 22 | def generate_egl_entries(output, lines, i): |
| 23 | for line in lines: |
| 24 | if line.find("EGL_ENTRY(") >= 0: |
| 25 | line = line.split(",")[1].strip() #extract EGL function name |
| 26 | output.write(" %s = %d;\n" % (line, i)) |
| 27 | i += 1 |
David Li | 5036a05 | 2011-04-21 14:15:10 -0700 | [diff] [blame] | 28 | return i |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 29 | |
| 30 | |
| 31 | def generate_gl_entries(output,lines,i): |
| 32 | for line in lines: |
| 33 | if line.find("API_ENTRY(") >= 0: |
| 34 | line = line[line.find("(") + 1: line.find(")")] #extract GL function name |
| 35 | output.write(" %s = %d;\n" % (line, i)) |
| 36 | i += 1 |
| 37 | return i |
| 38 | |
| 39 | |
| 40 | if __name__ == "__main__": |
| 41 | output = open("debugger_message.proto",'w') |
David Li | 5c425f2 | 2011-03-10 16:40:37 -0800 | [diff] [blame] | 42 | output.write("""\ |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 43 | /* |
| 44 | * Copyright (C) 2011 The Android Open Source Project |
| 45 | * |
| 46 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 47 | * you may not use this file except in compliance with the License. |
| 48 | * You may obtain a copy of the License at |
| 49 | * |
| 50 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 51 | * |
| 52 | * Unless required by applicable law or agreed to in writing, software |
| 53 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 54 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 55 | * See the License for the specific language governing permissions and |
| 56 | * limitations under the License. |
| 57 | */ |
| 58 | |
| 59 | // do not edit; auto generated by generate_debugger_message_proto.py |
| 60 | |
| 61 | package com.android.glesv2debugger; |
| 62 | |
| 63 | option optimize_for = LITE_RUNTIME; |
| 64 | |
| 65 | message Message |
| 66 | { |
| 67 | required int32 context_id = 1; // GL context id |
| 68 | enum Function |
| 69 | { |
| 70 | """) |
| 71 | |
| 72 | i = 0; |
David Li | e2ad4d0 | 2011-04-08 18:41:00 -0700 | [diff] [blame] | 73 | |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 74 | lines = open("gl2_api_annotated.in").readlines() |
| 75 | i = generate_gl_entries(output, lines, i) |
| 76 | output.write(" // end of GL functions\n") |
David Li | e2ad4d0 | 2011-04-08 18:41:00 -0700 | [diff] [blame] | 77 | |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 78 | #lines = open("gl2ext_api.in").readlines() |
| 79 | #i = generate_gl_entries(output, lines, i) |
| 80 | #output.write(" // end of GL EXT functions\n") |
David Li | e2ad4d0 | 2011-04-08 18:41:00 -0700 | [diff] [blame] | 81 | |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 82 | lines = open("../EGL/egl_entries.in").readlines() |
| 83 | i = generate_egl_entries(output, lines, i) |
| 84 | output.write(" // end of GL EXT functions\n") |
David Li | e2ad4d0 | 2011-04-08 18:41:00 -0700 | [diff] [blame] | 85 | |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 86 | output.write(" ACK = %d;\n" % (i)) |
| 87 | i += 1 |
David Li | e2ad4d0 | 2011-04-08 18:41:00 -0700 | [diff] [blame] | 88 | |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 89 | output.write(" NEG = %d;\n" % (i)) |
| 90 | i += 1 |
David Li | e2ad4d0 | 2011-04-08 18:41:00 -0700 | [diff] [blame] | 91 | |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 92 | output.write(" CONTINUE = %d;\n" % (i)) |
| 93 | i += 1 |
David Li | e2ad4d0 | 2011-04-08 18:41:00 -0700 | [diff] [blame] | 94 | |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 95 | output.write(" SKIP = %d;\n" % (i)) |
| 96 | i += 1 |
David Li | e2ad4d0 | 2011-04-08 18:41:00 -0700 | [diff] [blame] | 97 | |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 98 | output.write(" SETPROP = %d;\n" % (i)) |
| 99 | i += 1 |
David Li | e2ad4d0 | 2011-04-08 18:41:00 -0700 | [diff] [blame] | 100 | |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 101 | output.write(""" } |
| 102 | required Function function = 2 [default = NEG]; // type/function of message |
| 103 | enum Type |
| 104 | { |
| 105 | BeforeCall = 0; |
| 106 | AfterCall = 1; |
David Li | e2ad4d0 | 2011-04-08 18:41:00 -0700 | [diff] [blame] | 107 | AfterGeneratedCall = 2; |
| 108 | Response = 3; // currently used for misc messages |
David Li | 27f130a | 2011-04-08 18:43:16 -0700 | [diff] [blame] | 109 | CompleteCall = 4; // BeforeCall and AfterCall merged |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 110 | } |
| 111 | required Type type = 3; |
| 112 | required bool expect_response = 4; |
| 113 | optional int32 ret = 5; // return value from previous GL call |
| 114 | optional int32 arg0 = 6; // args to GL call |
| 115 | optional int32 arg1 = 7; |
| 116 | optional int32 arg2 = 8; |
| 117 | optional int32 arg3 = 9; |
| 118 | optional int32 arg4 = 16; |
| 119 | optional int32 arg5 = 17; |
| 120 | optional int32 arg6 = 18; |
David Li | 5036a05 | 2011-04-21 14:15:10 -0700 | [diff] [blame] | 121 | optional int32 arg7 = 19; // glDrawArrays/Elements sets this to active number of attributes |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 122 | optional int32 arg8 = 20; |
David Li | f9bc124 | 2011-03-22 18:42:03 -0700 | [diff] [blame] | 123 | |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 124 | optional bytes data = 10; // variable length data used for GL call |
David Li | f9bc124 | 2011-03-22 18:42:03 -0700 | [diff] [blame] | 125 | enum DataType |
| 126 | { |
| 127 | ReferencedImage = 0; // for image sourced from ReadPixels |
| 128 | NonreferencedImage = 1; // for image sourced from ReadPixels |
| 129 | }; |
David Li | e7180e8 | 2011-04-08 18:45:45 -0700 | [diff] [blame] | 130 | // most data types can be inferred from function |
| 131 | optional DataType data_type = 23; |
| 132 | // these are used for image data when they cannot be determined from args |
| 133 | optional int32 pixel_format = 24; |
| 134 | optional int32 pixel_type = 25; |
| 135 | optional int32 image_width = 26; |
| 136 | optional int32 image_height = 27; |
David Li | e2ad4d0 | 2011-04-08 18:41:00 -0700 | [diff] [blame] | 137 | |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 138 | optional float time = 11; // duration of previous GL call (ms) |
| 139 | enum Prop |
| 140 | { |
David Li | e7180e8 | 2011-04-08 18:45:45 -0700 | [diff] [blame] | 141 | CaptureDraw = 0; // arg0 = number of glDrawArrays/Elements to glReadPixels |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 142 | TimeMode = 1; // arg0 = SYSTEM_TIME_* in utils/Timers.h |
David Li | fbfc703 | 2011-03-21 16:25:58 -0700 | [diff] [blame] | 143 | ExpectResponse = 2; // arg0 = enum Function, arg1 = true/false |
David Li | e7180e8 | 2011-04-08 18:45:45 -0700 | [diff] [blame] | 144 | CaptureSwap = 3; // arg0 = number of eglSwapBuffers to glReadPixels |
David Li | 31918cc | 2011-04-15 15:35:10 -0700 | [diff] [blame] | 145 | GLConstant = 4; // arg0 = GLenum, arg1 = constant; send GL impl. constants |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 146 | }; |
| 147 | optional Prop prop = 21; // used with SETPROP, value in arg0 |
| 148 | optional float clock = 22; // wall clock in seconds |
| 149 | } |
| 150 | """) |
| 151 | |
| 152 | output.close() |
David Li | e2ad4d0 | 2011-04-08 18:41:00 -0700 | [diff] [blame] | 153 | |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 154 | os.system("aprotoc --cpp_out=src --java_out=../../../../../development/tools/glesv2debugger/src debugger_message.proto") |
| 155 | os.system('mv -f "src/debugger_message.pb.cc" "src/debugger_message.pb.cpp"') |