Home | History | Annotate | Download | only in GLES2_dbg
      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
     28     return i
     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')
     42     output.write("""\
     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;
     73 
     74     lines = open("gl2_api_annotated.in").readlines()
     75     i = generate_gl_entries(output, lines, i)
     76     output.write("        // end of GL functions\n")
     77 
     78     #lines = open("gl2ext_api.in").readlines()
     79     #i = generate_gl_entries(output, lines, i)
     80     #output.write("        // end of GL EXT functions\n")
     81 
     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")
     85 
     86     output.write("        ACK = %d;\n" % (i))
     87     i += 1
     88 
     89     output.write("        NEG = %d;\n" % (i))
     90     i += 1
     91 
     92     output.write("        CONTINUE = %d;\n" % (i))
     93     i += 1
     94 
     95     output.write("        SKIP = %d;\n" % (i))
     96     i += 1
     97 
     98     output.write("        SETPROP = %d;\n" % (i))
     99     i += 1
    100 
    101     output.write("""    }
    102     required Function function = 2 [default = NEG]; // type/function of message
    103     enum Type
    104     {
    105         BeforeCall = 0;
    106         AfterCall = 1;
    107         AfterGeneratedCall = 2;
    108         Response = 3; // currently used for misc messages
    109         CompleteCall = 4; // BeforeCall and AfterCall merged
    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;
    121     optional int32 arg7 = 19; // glDrawArrays/Elements sets this to active number of attributes
    122     optional int32 arg8 = 20;
    123 
    124     optional bytes data = 10; // variable length data used for GL call
    125     enum DataType
    126     {
    127         ReferencedImage = 0; // for image sourced from ReadPixels
    128         NonreferencedImage = 1; // for image sourced from ReadPixels
    129     };
    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;
    137 
    138     optional float time = 11; // duration of previous GL call (ms)
    139     enum Prop
    140     {
    141         CaptureDraw = 0; // arg0 = number of glDrawArrays/Elements to glReadPixels
    142         TimeMode = 1; // arg0 = SYSTEM_TIME_* in utils/Timers.h
    143         ExpectResponse = 2; // arg0 = enum Function, arg1 = true/false
    144         CaptureSwap = 3; // arg0 = number of eglSwapBuffers to glReadPixels
    145         GLConstant = 4; // arg0 = GLenum, arg1 = constant; send GL impl. constants
    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()
    153 
    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"')
    156