def addRenderTargetSection(g):
  s = g.report.create(Report.Section, "Render targets")
  
  # Check the used EGL configurations and surfaces
  configs = set()
  for event in g.trace.events:
    for key, value in event.values.items():
      if isinstance(value, Trace.Object):
        if value.cls.name == "EGLConfig":
          id = value.attrs.get("config_id")
          if not id or id in configs:
            continue
          configs.add(id)
          s2 = s.create(Report.Section, "EGL configuration #%d" % id)
          t  = s2.create(Report.Table, ["Property", "Value"])
          for cfgKey, cfgValue in value.attrs.items():
            cfgKey = cfgKey.replace("_", " ").capitalize()
            t.addRow(cfgKey, cfgValue)
    if event.name == "eglCreateWindowSurface":
      window = event.values.get("window")
      
      if not window:
        continue
      
      s2 = s.create(Report.Section, "Window surface 0x%x" % event.values[None].id)
      t  = s2.create(Report.Table, ["Property", "Value"])
      t.addRow("Width",  window.attrs["width"])
      t.addRow("Height", window.attrs["height"])
      t.addRow("Config ID", event.values["config"].id)
    elif event.name == "eglCreatePixmapSurface":
      pixmap = event.values.get("pixmap")
      
      if not pixmap:
        continue
      
      s2 = s.create(Report.Section, "Pixmap surface 0x%x" % event.values[None].id)
      t  = s2.create(Report.Table, ["Property", "Value"])
      t.addRow("Width",  pixmap.attrs["width"])
      t.addRow("Height", pixmap.attrs["height"])
      t.addRow("Config ID", event.values["config"].id)
    elif event.name == "eglCreatePbufferSurface":      
      attrs = event.values.get("attrib_list")
      
      if not attrs:
        continue
        
      try:
        width  = attrs[attrs.index(g.constants.EGL_WIDTH) + 1]
        height = attrs[attrs.index(g.constants.EGL_HEIGHT) + 1]
      except ValueError:
        continue

      s2 = s.create(Report.Section, "Pbuffer surface 0x%x" % event.values[None].id)
      t  = s2.create(Report.Table, ["Property", "Value"])
      t.addRow("Width",  width)
      t.addRow("Height", height)
      t.addRow("Config ID", event.values["config"].id)
dataset/ETHPy150Open skyostil/tracy/src/analyzer/plugins/gles/GlesReport.py/addRenderTargetSection/original