blob: 535b13e185de6502b09bd247102844b976fc1d3f [file] [log] [blame]
David Li55c94cc2011-03-04 17:50:48 -08001#!/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
20import os
21
22def 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 Li5036a052011-04-21 14:15:10 -070028 return i
David Li55c94cc2011-03-04 17:50:48 -080029
30
31def 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
40if __name__ == "__main__":
41 output = open("debugger_message.proto",'w')
David Li5c425f22011-03-10 16:40:37 -080042 output.write("""\
David Li55c94cc2011-03-04 17:50:48 -080043/*
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
61package com.android.glesv2debugger;
62
63option optimize_for = LITE_RUNTIME;
64
65message Message
66{
67 required int32 context_id = 1; // GL context id
68 enum Function
69 {
70""")
71
72 i = 0;
David Lie2ad4d02011-04-08 18:41:00 -070073
David Li55c94cc2011-03-04 17:50:48 -080074 lines = open("gl2_api_annotated.in").readlines()
75 i = generate_gl_entries(output, lines, i)
76 output.write(" // end of GL functions\n")
David Lie2ad4d02011-04-08 18:41:00 -070077
David Li55c94cc2011-03-04 17:50:48 -080078 #lines = open("gl2ext_api.in").readlines()
79 #i = generate_gl_entries(output, lines, i)
80 #output.write(" // end of GL EXT functions\n")
David Lie2ad4d02011-04-08 18:41:00 -070081
David Li55c94cc2011-03-04 17:50:48 -080082 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 Lie2ad4d02011-04-08 18:41:00 -070085
David Li55c94cc2011-03-04 17:50:48 -080086 output.write(" ACK = %d;\n" % (i))
87 i += 1
David Lie2ad4d02011-04-08 18:41:00 -070088
David Li55c94cc2011-03-04 17:50:48 -080089 output.write(" NEG = %d;\n" % (i))
90 i += 1
David Lie2ad4d02011-04-08 18:41:00 -070091
David Li55c94cc2011-03-04 17:50:48 -080092 output.write(" CONTINUE = %d;\n" % (i))
93 i += 1
David Lie2ad4d02011-04-08 18:41:00 -070094
David Li55c94cc2011-03-04 17:50:48 -080095 output.write(" SKIP = %d;\n" % (i))
96 i += 1
David Lie2ad4d02011-04-08 18:41:00 -070097
David Li55c94cc2011-03-04 17:50:48 -080098 output.write(" SETPROP = %d;\n" % (i))
99 i += 1
David Lie2ad4d02011-04-08 18:41:00 -0700100
David Li55c94cc2011-03-04 17:50:48 -0800101 output.write(""" }
102 required Function function = 2 [default = NEG]; // type/function of message
103 enum Type
104 {
105 BeforeCall = 0;
106 AfterCall = 1;
David Lie2ad4d02011-04-08 18:41:00 -0700107 AfterGeneratedCall = 2;
108 Response = 3; // currently used for misc messages
David Li27f130a2011-04-08 18:43:16 -0700109 CompleteCall = 4; // BeforeCall and AfterCall merged
David Li55c94cc2011-03-04 17:50:48 -0800110 }
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 Li5036a052011-04-21 14:15:10 -0700121 optional int32 arg7 = 19; // glDrawArrays/Elements sets this to active number of attributes
David Li55c94cc2011-03-04 17:50:48 -0800122 optional int32 arg8 = 20;
David Lif9bc1242011-03-22 18:42:03 -0700123
David Li55c94cc2011-03-04 17:50:48 -0800124 optional bytes data = 10; // variable length data used for GL call
David Lif9bc1242011-03-22 18:42:03 -0700125 enum DataType
126 {
127 ReferencedImage = 0; // for image sourced from ReadPixels
128 NonreferencedImage = 1; // for image sourced from ReadPixels
129 };
David Lie7180e82011-04-08 18:45:45 -0700130 // 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 Lie2ad4d02011-04-08 18:41:00 -0700137
David Li55c94cc2011-03-04 17:50:48 -0800138 optional float time = 11; // duration of previous GL call (ms)
139 enum Prop
140 {
David Lie7180e82011-04-08 18:45:45 -0700141 CaptureDraw = 0; // arg0 = number of glDrawArrays/Elements to glReadPixels
David Li55c94cc2011-03-04 17:50:48 -0800142 TimeMode = 1; // arg0 = SYSTEM_TIME_* in utils/Timers.h
David Lifbfc7032011-03-21 16:25:58 -0700143 ExpectResponse = 2; // arg0 = enum Function, arg1 = true/false
David Lie7180e82011-04-08 18:45:45 -0700144 CaptureSwap = 3; // arg0 = number of eglSwapBuffers to glReadPixels
David Li31918cc2011-04-15 15:35:10 -0700145 GLConstant = 4; // arg0 = GLenum, arg1 = constant; send GL impl. constants
David Li55c94cc2011-03-04 17:50:48 -0800146 };
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 Lie2ad4d02011-04-08 18:41:00 -0700153
David Li55c94cc2011-03-04 17:50:48 -0800154 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"')